Smart Contracts for the Grayblock Swap - The first yield farm backed by clean energy.
Branches :
-
main - A branch with V1 of smart contract for IDO,staking, Project Token
-
mobiloitte - A branch with smart contracts for tGVS (test Project token) , tUSD and IDO contract along with their tests
-
Staking - A branch with smart contracts for energy yield farming
The staking smart contract works in the following way:
staking contract is that we would preload the contract with say 10k BUSD (say 2 months worth yield) Lets take an example to understand the requirements, lets say A and B put in 100 project tokens each into the staking contract (so the total project tokens in the staking contract is 200). now every 6hrs we will execute a smart contract call setting the amount of busd that can be allocated to the stakers. so lets say the energy generated by the solar farm for that 6hr period is 100$ ( This means that every hour a and b can see their realtime yield via the dapp (which is fetched from the backend / smart meter feeds) BUT THEY CAN ONLY CLAIM IT EVRY 6HRS ) so then the smart contract will increase the allowance of each staker by a fraction of this 100$ in proportion to the fraction of the pool they contribute it to. So in this instance since both A and B have 50 50 % stake, the 50BUSD will be added to the allowance of each user (totalling to 100 busd) Now C joins in and adds another 800 tokens to the staking pool, so now A , B and C have their % staked as 10% 10% 80%, So now for the next 6 hour, lets say that the solar farm generates another 100$ So this time, A and B gets only 10BUSD accumulated and C gets 80BUSD accumulation. (this data about the solar farm yield will be read by a backend server that essentially does the smart contract calls so this updateAllowance function of the staking contract needs to be restricted to "backendOnly" modifier, backend server address can be taken in the constructor). The users can withdraw the accumulated rewards anytime. ( the rewards should be a public mapping ) The users start accumulating rewards (Ie get a share of the yield ) only 24 hrs after they start to stake (for security purposes)
For more detailed information see https://grayblock.github.io/Docs/#/smartcontracts