Hodler.sol
Below the overview of all state changing functions in the smart contract.
State changing functions overview
initialize is called by the factory when creating the new game. It can only be called once.
deposit is called by the participant to deposit assets. It can only be called before the game started and at max 2 times the start amount.
withdraw is called by the participant to withdraw assets. It can always be called before the end of the game (all funds withdrawn). When the game has started the asset amount to withdraw is calculated by calculateAssetOut.
Bonding curve implementation
calculateAssetOut calculates the amount of assets to withdraw based on the linear bonding curve. It does this in multiple steps:
1. Calculate the old and new percentage of total assets withdrawn (based on previous total withdraw and total withdraw + new withdraw amount)
2. Calculate the mean of the difference between the old and new percentage of assets withdrawn
3. Finally calculate the assets to withdraw
Last updated
Was this helpful?