liquidapps-io / zeus-sdk

EOSIO & EVM smart contract unit testing suite and API provider
51 stars 24 forks source link

User can withdraw only the entire balance #1

Closed barakman closed 5 years ago

barakman commented 5 years ago

In file airhodl.cpp, in function airhodl::withdraw, you do:

   from_acnts.erase(from);

This is probably a product-decision, but shouldn't this function support a partial withdrawal as well (i.e., not just the entire balance)?

It would be pretty easy to implement I believe...


For example:

supply = 4000 virtual tokens

reserve = 4000 real tokens

balances =
    user a: 1000 virtual tokens
    user b: 1000 virtual tokens
    user c: 2000 virtual tokens

user a sells 200 virtual tokens after 1/2 vesting period has elapsed

user a gets 200 * 1/2 * reserve / supply = 100 real tokens

supply = supply - 200 = 3800 virtual tokens

reserve = reserve - 100 = 3900 real tokens

user b sells 200 virtual tokens immediately after that

user b gets 200 * 1/2 * reserve / supply = 102 real tokens
NatPDeveloper commented 5 years ago

Thank you for the comment @barakman. If you would like to deploy the contract for your own use case, you may feel free to adjust the code how you see fit to include a partial withdrawal option.