-
Notifications
You must be signed in to change notification settings - Fork 57
Description
It's a true story from some user, who wants to withdraw lp token from farming but failed.
Scenario
First try :
- Alice adds liquidity to some pool, let's say pool#1429, and got 1.0 lp token,
- Alice stakes 0.5 lp token to farming,
- Alice remove all remain liquidity (0.5) from pool#1429,
- Alice withdraw lp token from farming.
Then, bom....ERR13_LP_NOT_REGISTERED;
What happened:
In step 3, as Alice removed all her liquidity, the pool unregister her from its LP to save storage;
So, in step 4, you can not transfer lp token to someone not registered on that token contract.
Resolution:
There is only a mft_balance_of can tell us something about user in the LP token, Maybe we just re-register Alice before she withdraws lp token from farming?
Second try :
- Alice adds liquidity to some pool, let say pool#1429, and got 1.0 lp token,
- Alice stakes 1.0 lp token to farming,
- Alice starts withdraw lp token from farming:
- See her lp token remaining using
mft_balance_of, and got 0, - Register her into the lp token before withdraw;
Then, bom....ERR14_LP_ALREADY_REGISTERED;
What's wrong:
For transfer of lp tokens, there is no unregsiter logic in it. So Alice is still hang in there even if she has no lp toke left.
Conclusion and Suggestion
Transferring and remove_liqudity are different at register management logic. It's hard to tell a user whether or not he is registered in a lp token, we may need to add a storage_balance_of interface to lp token here.