Open corymsmith opened 3 years ago
It looks like within the withdraw
function itself the amount is changed based on the exchange rate here: https://github.com/Anchor-Protocol/anchor-earn/blob/cfddf82475ddd90323ce8770c2cf7f9dc3577843/src/facade/terra-anchor-earn.ts#L275
But the docs indicate that the amount being passed into that function are denominated in the currency
you are specifying.
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.
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.
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.
https://github.com/Anchor-Protocol/anchor-earn/blob/cfddf82475ddd90323ce8770c2cf7f9dc3577843/src/facade/terra-anchor-earn.ts#L275
For the confusion, the currency related to fabricators is market currencies, which for now, we have only UST.
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: https://github.com/Anchor-Protocol/anchor-earn/blob/cfddf82475ddd90323ce8770c2cf7f9dc3577843/src/facade/terra-anchor-earn.ts#L275
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.
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 :)
Thanks for the report, We will reflect that on the document. May I close this issue?
I would expect this to withdraw
0.5 UST
and not0.5 aUST
This was with
1.1.0-alpha.2
and usingbombay-12
.This is how I was calling the function:
And here is the tx: https://finder.terra.money/bombay-12/address/terra1cq8l6fxx5gfs9qde80f2rcp7n0j020zwffrlx0