Open kieutuan218 opened 11 months ago
@kieutuan218 The Testnet Enviroment is quite different with the Mainnet. There's no Token Metadata, it means that all Token on the Testnet will have decimal zero as well (except ADA, we assume that ADA always has 6 decimals)
In that case, you are exchanging 10 tMELD
to get around 9 tMIN
, not 10_000_000 tMELD
1 Tip for it is we always show Invisible Token
on the Swap page for zero decimals Tokens
like the picture you provided above.
Thank you. @h2physics I have 1 more question. If I reverse swap tMIN -> tMELD, the parameters reserveIn, reserveOut, assetIn, assetOut will be reversed, right?
const data = calculateSwapExactIn({
amountIn,
reserveIn: pool.assetA === tMinAddress ? pool.reserveA : pool.reserveB,
reserveOut: pool.assetB === tMeldAddress ? pool.reserveB : pool.reserveA,
});
@h2physics Decimal = 0 then amount out is the same as UI but priceImpact is always different from UI
amountOut 9. amountOut 9
priceImpact 0.00099300609363561084
I use calculateSwapExactIn function to calculate amount out but it is returning different data than the interface. Tried with the ADA/tMELD pair and it is displaying amount out correctly with the interface. But it doesn't need divide by 10^6
Where is it going wrong?
Output:
UI: