fuguefoundation / smart-contracts

https://etherscan.io/address/0xfbf9ae92ecb05bc436d9b1e6c1d928824aedb2f1
1 stars 1 forks source link
ethereum smart-contract solidity

Gist

Contract address - 0xfbf9ae92ecb05bc436d9b1e6c1d928824aedb2f1 - Self destructed

This contract allows participants to guess when they believe the price of ether (ETH) will next reach 500 USD. The contract is loaded with 0.5 ETH (though anyone can add more), and there are two possibilities to receive these funds.

  1. 10% of balance: The participant to first call claimCheckPriceReward() once the oracle has set priceConfirmedOver500 to true.
  2. 90% of balance: The participant whose timestamp guess is closest to when ETH hits the 500 USD mark according to the Kraken API.

So bottomline, if you want to participate, call makeGuess with your UNIX timestamp, and if you think your guess is strong relative to when we hit 500, call nominateSelfAsWinner with your address. If you want to win the 10% prize, keep an eye on this API call (specifically, the first value of the c array) as we approach 500 and call checkPrice followed by claimCheckPriceReward.

Functionality and Contract Logic

  1. When making a guess, participants include a UNIX timestamp. msg.sender is the address that is making the guess and would receive the ETH.
  1. When checkPrice is called, and assuming the price is greater than 500 USD based on Kraken's last trade between the ETHUSD pairing on their API, the oracle callback function sets priceConfirmedOver500 to true and winningTimestamp is set to the current block timestamp.
  1. Now the nomination period begins and lasts for seven days. Instead of iterating over the myriad guesses that may exist, creating possible gas issues, people who think they have a chance of winning nominate themselves, creating a smaller subset of possible winners who effectively compete for the lowest difference between their guess and winningTimestamp.
  1. Self Destruct - I have included an escape hatch that the owner can call in the event that there is some unforeseen logic error or if Kraken's API changes. The address hard-coded in the contract is for the nonprofit Give Directly (proof), who would receive the contract balance if this function is called.

How to deploy

Test contracts

These contracts evolved during the testing period, and differed (in terms of the variables) only by setting the threshold lower for ETHUSD price (relative to current market price) and eliminating the amount of time to elapse to call certain functions.


Contributing to the project

This is an open source project. Contributions are welcomed & encouraged! :smile:

TODO

References