Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fabricateMarketRedeemStable redeemed amount in aUST and not UST #14

Open
corymsmith opened this issue Sep 29, 2021 · 8 comments
Open

fabricateMarketRedeemStable redeemed amount in aUST and not UST #14

corymsmith opened this issue Sep 29, 2021 · 8 comments
Labels
question Further information is requested

Comments

@corymsmith
Copy link

I would expect this to withdraw 0.5 UST and not 0.5 aUST

This was with 1.1.0-alpha.2 and using bombay-12.

This is how I was calling the function:

fabricateMarketRedeemStable({
    address: 'terra1cq8l6fxx5gfs9qde80f2rcp7n0j020zwffrlx0',
    currency: DENOMS.UST,
    amount: '0.5'
})(addressProvider);

And here is the tx:
https://finder.terra.money/bombay-12/address/terra1cq8l6fxx5gfs9qde80f2rcp7n0j020zwffrlx0

Screen Shot 2021-09-29 at 10 30 58 AM

@corymsmith
Copy link
Author

It looks like within the withdraw function itself the amount is changed based on the exchange rate here:

withdrawOption.amount = getNaturalDecimals(

But the docs indicate that the amount being passed into that function are denominated in the currency you are specifying.

@MSNTCS
Copy link
Contributor

MSNTCS commented Sep 30, 2021

Hello there, thanks for your report. As far as I understood, you are using message fabricators not anchor-earn itself. But, using the anchor-earn withdraw function will always lead to a withdrawal of less than the amount that you specified (as the doc notes), here is one example https://finder.terra.money/bombay-12/tx/79236004282349B59A74B047E77454C8008DA29B38384C1990EF35B3F613E5A5.
The withdrawal amount here is 0.5.
here is the code for the above example:

const withdraw = await anchorEarn.withdraw({
      amount: '0.5',
      currency: DENOMS.UST,
    }); 

I think you are using message fabricators that withdraw aUST and the denom there, represent market denomination, not currency. Please instantiate anchor-earn and use withdraw function like the above code snippet.

@corymsmith
Copy link
Author

Yes, we are using fabricators on purpose since we are generating the tx to be serialized and signed elsewhere. We require specifying the UST amount to be withdrawn vs. the aUST amount. The confusing part is that both deposit and withdraw take an amount and currency param but only deposit actually uses that currency for the amount.

@MSNTCS
Copy link
Contributor

MSNTCS commented Sep 30, 2021

If you use anchor-earn for only fabricators, I recommend using anchor.js.
If you want to have your own customSigner or customBroadcaster, anchor-earn supports that.
Besides that, fabricators have nothing to do with this function that you mentioned.

withdrawOption.amount = getNaturalDecimals(

For the confusion, the currency related to fabricators is market currencies, which for now, we have only UST.

@corymsmith
Copy link
Author

My main question is:

How would I specify that I want to withdraw 100 UST for example (knowing that I would get less after fees).
is the only way to calculate the exchangeRate between aUST and UST like anchor-earn is doing here:

withdrawOption.amount = getNaturalDecimals(

@MSNTCS
Copy link
Contributor

MSNTCS commented Sep 30, 2021

yes exactly like that. My point was, fabricateMarketRedeemStable withdraws the amount you specified in aUST denom; if you need to get it in UST denom, you have to calculate it like that function you mentioned.

@corymsmith
Copy link
Author

Thanks for clarifying. My point was that the way the params are documented in the code and the inconsistency between deposit and redeem fabricators made that confusing :)

@MSNTCS
Copy link
Contributor

MSNTCS commented Sep 30, 2021

Thanks for the report, We will reflect that on the document. May I close this issue?

@MSNTCS MSNTCS added the question Further information is requested label Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants