Skip to content

RefundableOracleLock

midenaio edited this page Jan 13, 2021 · 22 revisions

RefundableOracleLock smart contract

The smart contract blocks iDNA deposited by multiple users until a decision is made by oracles. It works similarly to OracleLock: if the voting result matches the expected value, coins are transferred to address A (if specified), otherwise to address B (if specified). However, a refund is provided to all users if the destination address A or B is not specified or oracle voting fails to reach a consensus. The amount of the refund is equal to the initial deposit or proportional to the initial deposit if the RefundableOracleLock address has been funded additionally.

Use case 1

The contractor promises to complete the work by a certain deadline. The community is ready to fund the work. An oracle voting is created so that oracles at some point in the future confirm whether the work is done. Community members fund the work by depositing money from different wallets to RefundableOracleLock. If the result of the oracle voting confirms that the work is done, the money is transferred to the contractor. Otherwise, all contributors get a refund.

Use case 2 (prediction market)

An oracle voting is created so that oracles at some point in the future confirm the occurrence or non-occurrence of the event. Bets on the occurrence or non-occurrence of the event are locked on two linked RefundableOracleLock contracts. According to the results of the oracle voting, one of the two contracts will be the RefundableOracleLock-winner and the other will be the RefundableOracleLock-loser. All money locked on the RefundableOracleLock-loser contract is sent to the address of the RefundableOracleLock-winner contract. After that, the money from the RefundableOracleLock-winner is returned to the winning users in the form of a refund in proportion to the bets made.

RefundableOracleLock states

Default state of the smart contract is locked. Once the voting at the referenced OracleVoting smart contract is finished anyone can call Push method which changes the state as follows:

  • unlocked_success if the result on the OracleVoting smart contract matches the expected Value and Success address is specified. Coins are sent to the Success address.
  • unlocked_failed if the result on the OracleVoting smart contract does not match the expected Value and Fail address is specified. Coins are sent to the Fail address.
  • unlocked_refund otherwise.

Methods

deploy method

...

deposit method

...

push method

...

refund method

...

terminate method

...

Clone this wiki locally