ProofSuite / OrFeed

DeFi & Distributed Data Service Aggregator
https://www.orfeed.org
Apache License 2.0
241 stars 152 forks source link

Binary Option/Prediction Market Consumer Contract Example #44

Closed mikedeshazer closed 4 years ago

mikedeshazer commented 4 years ago

One OrFeed use-case might be a binary options/prediction market smart contract in which a user specifies the direction of an asset like BTC or ETH (long or short), funds are locked for 5 minutes, and then the user settles after expiry (doubling if the direction is in their favor, while receiving a 0 return otherwise).

When another user placed a prediction market transaction, it would check all pending transactions and settle them if they are expired (5 minutes elapsed), so that it doesn't rely on a centralized party to ping the contract. Obviously, settling a max for the for-loop to 5, so it can't run out/use too much gas per transaction that detects things that need to be settled.

Ideally this would use the OrFeed default oracle (relying on Uniswap and Kyber)for the settlement price. This is a rough concept and could be added to the repo as inspiration for dApp developers who need reliable oracles. maybe leading to other interesting ideas.

For any questions/comments on this issue, please feel free to join us on Discord: https://discord.gg/byCPVsY

gitcoinbot commented 4 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 0.23 ETH (40.06 USD @ $174.17/ETH) attached to it as part of the ProofSuite fund.

gitcoinbot commented 4 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work has been started.

These users each claimed they can complete the work by 2 weeks, 3 days from now. Please review their action plans below:

1) nikhil3000 has been approved to start work.

For this bounty, I will create a contract which will let users create an option (with required details like long or short), this function will fetch the price of the asset at the time of the creation of option and store it with the other details. This function will also check for any existing expired bets and settle them all (max 5).

Here my key assumption is that there will be many users and there won't be much time difference (and hence the price difference) between the expiry of a bet and the time it is settled (there is no way to get historical price data from the oracle). Please tell me if I am missing anything and there is some workaround this assumption.

I have already developed an ERC20 Options trading Platform POC for Kyber hackathon and have used oracles. So it shouldn't be too difficult for me to complete this bounty. 2) 1toya999 has applied to start work _(Funders only: approve worker | reject worker)_.

Ehayhywfk2jg3nnEHEHYH2NJOITFW82

Learn more on the Gitcoin Issue Details page.

gitcoinbot commented 4 years ago

@nikhil3000 Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

nikhil3000 commented 4 years ago

Hey, I am still working on it. Will send a PR as soon as I am ready.

gitcoinbot commented 4 years ago

@nikhil3000 Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

gitcoinbot commented 4 years ago

@nikhil3000 Hello from Gitcoin Core - are you still working on this issue? Please submit a WIP PR or comment back within the next 3 days or you will be removed from this ticket and it will be returned to an ‘Open’ status. Please let us know if you have questions!

Funders only: Snooze warnings for 1 day | 3 days | 5 days | 10 days | 100 days

nikhil3000 commented 4 years ago

Hey guys, I have written my contract. But there the call to getExchangeRate is returning 0 on both rinkeby and kovan testnet. Here is the code I deployed in rinkeby.

OrFeedInterface orfeed;
    constructor() public {
        orfeed = OrFeedInterface(0x97875355eF55Ae35613029df8B1C8Cf8f89c9066);
    }

   function exchangeRate(string _symbol1, string _symbol2, uint amount)  public view returns(uint){
       uint strikePrice = orfeed.getExchangeRate(_symbol1,_symbol2,"DEFAULT",amount);
        return strikePrice;

   }

I tried for BTC/USD, BTC/USDC, JPY/USD pairs. Please point out the mistake. My bounty task will be complete if this issue is fixed.

mikedeshazer commented 4 years ago

@nikhil3000 the orfeed contract of 0x97875355eF55Ae35613029df8B1C8Cf8f89c9066 is for mainnet. If you post your eth address, we can send over some eth for testing on mainnet

nikhil3000 commented 4 years ago

Sent on discord.

gitcoinbot commented 4 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 0.23 ETH (56.37 USD @ $245.09/ETH) has been submitted by:

  1. @nikhil3000

@mikedeshazer please take a look at the submitted work:


gitcoinbot commented 4 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 0.23 ETH (56.37 USD @ $245.09/ETH) attached to this issue has been approved & issued to @nikhil3000.