Oracle game examples

Here we will walk through how the smart contract's flows work. Bob reports an ETH price too low We can use the previous page's example. First, Bob puts 1 ETH and 3000 USDC into the contract, earning a 0.01 ETH reward for being the first reporter. Contract balances: 1 ETH and 3000 USDC Next, since the true value of 1 ETH is 4000 USDC, Alice comes along and decides to swap 3000 of her USDC for 1 of Bob's ETH, earning ~$1000 in the process. Bob receives the 3000 USDC he already put in the contract back and 3000 USDC from Alice, for a total of 6000 USDC. Alice receives 1 ETH in exchange for her 3000 USDC. Next, by openOracle contract rule, Alice must become the next reporter at the same time she swaps. Since the multiplier is 1.5x, Alice must put up 1.5 ETH and her choice of USDC. Since 1 ETH is 4000 USDC, she chooses to put up 6000 USDC. Contract balances: 1.5 ETH and 6000 USDC. Since we do the swap and report in a single step, we net out the flows: Alice only needs to transfer 0.5 ETH (since previous balance was 1 ETH) into the contract. She also must transfer 9000 USDC: 3000 USDC to Bob and 6000 USDC to match her 1.5 ETH. Once the game ends in 10 minutes, assuming nobody swapped against Alice, she gets 1.5 ETH and 6000 USDC back. Bob reports an ETH price too high Let's say Bob put 1 ETH and 5000 USDC into the contract when the true value of 1 ETH is 4000 USDC. Contract balances: 1 ETH and 5000 USDC Alice would now choose to swap 1 of her ETH for 5000 of Bob's USDC, earning ~$1000 in the process. Bob receives the 1 ETH he already put in the contract back and 1 ETH from Alice, for a total of 2 ETH. Alice receives 5000 USDC in exchange for her 1 ETH. By openOracle contract rule, Alice must become the next reporter at the same time she swaps. Since the multiplier is 1.5x, Alice must put up 1.5 ETH and her choice of USDC. Since 1 ETH is 4000 USDC, she chooses to put up 6000 USDC. Contract balances: 1.5 ETH and 6000 USDC. We net out the flows: Alice only needs to transfer 1000 USDC (since previous balance was 5000 USDC) into the contract. She also must transfer 2.5 ETH: 1 ETH to Bob and 1.5 ETH to the oracle contract (multiplier of 1.5x ⇒ she must put up 1.5 ETH next). Once the game ends in 10 minutes, assuming nobody swapped against Alice, she gets 1.5 ETH and 6000 USDC back. Bob reports an ETH price way too high Let's say Bob put 1 ETH and 10000 USDC into the contract when the true value of 1 ETH is 4000 USDC. Contract balances: 1 ETH and 10000 USDC Alice would now choose to swap 1 of her ETH for 10000 of Bob's USDC, earning ~$6000 in the process. Bob receives the 1 ETH he already put in the contract back and 1 ETH from Alice, for a total of 2 ETH. Alice receives 10000 USDC in exchange for her 1 ETH. By openOracle contract rule, Alice must become the next reporter at the same time she swaps. Since the multiplier is 1.5x, Alice must put up 1.5 ETH and her choice of USDC. Since 1 ETH is 4000 USDC, she chooses to put up 6000 USDC. Contract balances: 1.5 ETH and 6000 USDC. When we net out the flows here, Alice doesn't need to transfer any USDC. In fact, she receives an immediate USDC refund from the oracle contract of 4000 USDC since there was already 10000 USDC there and she chose 6000 USDC to go along with her 1.5 ETH requirement. While Alice receives an immediate 4000 USDC refund, she still must transfer 2.5 ETH: 1 ETH to Bob and 1.5 ETH to the oracle contract. Once the game ends in 10 minutes, assuming nobody swapped against Alice, she receives 1.5 ETH and 6000 USDC.

Last updated