Anchor-Protocol / anchor-earn

The Earn JavaScript SDK for Anchor Protocol.
Apache License 2.0
45 stars 24 forks source link

Can't withdraw full balance at once #27

Open xapss opened 2 years ago

xapss commented 2 years ago

I put 100.5 UST in my Anchor. I check the balance over time and it's increasing. 10 minutes in, I try to withdraw the 100.5. By now it's 100.500454.

However, I can only withdraw 80 UST at this time. It throws me an error: Error: Cannot withdraw more than balance. 100500000 > 83228385

I withdraw 80.5 UST. Then I try to withdraw the other 20 UST. I can withdraw only 16 UST now. It throws me an error: Error: Cannot withdraw more than balance. 20000000 > 16563164

What am I missing? Why can't I withdraw the full balance?

(using 2.0.0 alpha1)

nimishpatel19 commented 2 years ago

@xapss Yes I am also facing the same issue. I think SDK has issue and It is comparing user's aUST token even if we pass currency as UST (Same here using 2.0.0-alpha1).

nimishpatel19 commented 2 years ago

I put 100.5 UST in my Anchor. I check the balance over time and it's increasing. 10 minutes in, I try to withdraw the 100.5. By now it's 100.500454.

However, I can only withdraw 80 UST at this time. It throws me an error: Error: Cannot withdraw more than balance. 100500000 > 83228385

I withdraw 80.5 UST. Then I try to withdraw the other 20 UST. I can withdraw only 16 UST now. It throws me an error: Error: Cannot withdraw more than balance. 20000000 > 16563164

What am I missing? Why can't I withdraw the full balance?

(using 2.0.0 alpha1)

I did quick fix

Remove this line from here : https://github.com/Anchor-Protocol/anchor-earn/blob/4c43c6f35381603d58c2f33f61ccb61c7477c68e/src/facade/terra-anchor-earn.ts#L251 and paste it here: https://github.com/Anchor-Protocol/anchor-earn/blob/4c43c6f35381603d58c2f33f61ccb61c7477c68e/src/facade/terra-anchor-earn.ts#L280

nimishpatel19 commented 2 years ago

I put 100.5 UST in my Anchor. I check the balance over time and it's increasing. 10 minutes in, I try to withdraw the 100.5. By now it's 100.500454. However, I can only withdraw 80 UST at this time. It throws me an error: Error: Cannot withdraw more than balance. 100500000 > 83228385 I withdraw 80.5 UST. Then I try to withdraw the other 20 UST. I can withdraw only 16 UST now. It throws me an error: Error: Cannot withdraw more than balance. 20000000 > 16563164 What am I missing? Why can't I withdraw the full balance? (using 2.0.0 alpha1)

I did quick fix

Remove this line from here : https://github.com/Anchor-Protocol/anchor-earn/blob/4c43c6f35381603d58c2f33f61ccb61c7477c68e/src/facade/terra-anchor-earn.ts#L251 and paste it here: https://github.com/Anchor-Protocol/anchor-earn/blob/4c43c6f35381603d58c2f33f61ccb61c7477c68e/src/facade/terra-anchor-earn.ts#L280

Reason: Actually in code, it is comparing UST deposits with aUST. So that's why assert creating insufficient balance error while withdrawing full deposits. @MSNTCS You can solve it by doing it.

nimishpatel19 commented 2 years ago

@xapss Issue is solved in latest version : '2.0.0'. Install it. Thanks.