HydraDX-node icon indicating copy to clipboard operation
HydraDX-node copied to clipboard

Setting on chain route when asset_in is stable share asset

Open dmoka opened this issue 9 months ago • 0 comments

When we want to store a route on-chain where the first trade asset_in, or last trade asset_out is share asset, then the first validation phase fails because we retrieve the reference amount in a wrong way for share asset

https://github.com/galacticcouncil/HydraDX-node/blob/e3821e078bdb72a0416f8aebca21ba4a7a599f64/pallets/stableswap/src/trade_execution.rs#L201

Namely, free_balance returns 0 for share assets.

The fix would be to use total_issuance in case of share assets.

But when a validation fails with an amount, then we try to revalidate with amount out from the sell validation coming from opposite direction. Since it solves the issue, we park it for now, low prio.

dmoka avatar May 17 '24 15:05 dmoka