pppeiie / Crypto_Supreme_Prophecy

0 stars 1 forks source link

Question #15

Open PatrickAlphaC opened 3 years ago

PatrickAlphaC commented 3 years ago

Hi here,

This is really cool, thank you for submitting! How are you able to return 2.9 times the staked amount?

drnguyenn commented 3 years ago

Good afternoon, sir. Thanks for paying attention to our project. Sorry for the late reply.

The information including stake amount and the betting time of all bets of an user are stored in an array of their own called bets. When the user send a request to check for the result, first we make sure to check whether result is available by checking to current time and the betting time of the specified bet in bets array. If result were available, we would use APIs provided by Chainlink to check for the exchange rate of BTC exactly at the moment after the betting time 60 minutes. If result matched the gambler's prediction, we would create a transaction to send reward to him/her. Finally, we update the status and isWin field of the specified bet in bets array.

PatrickAlphaC commented 3 years ago

Thank you for your detailed reply. I'm still a bit confused how you're able to send 2.9 times instead of 2 times

drnguyenn commented 3 years ago

Thank you for your detailed reply. I'm still a bit confused how you're able to send 2.9 times instead of 2 times

Ah, it's a little tricky here to multiply the amount by 2.9. We just multiplied the stake by 3 and then subtract 1/10 of it like this:

msg.sender.transfer([msg.sender][_index].amount *3 - [msg.sender][_index].amount /10)