sora2-network
sora2-network copied to clipboard
ALT: xyk pool quote error
quote
that uses ALT for order-book & xyk-pool sources with desired amount > order-book liquidity, returns UnavailableExchangePath
error.
Swap XOR --> Asset
Prices are equal.
xyk-pool reserves are too low.
Problem root cause
Specifically for xyk-pool
the problem is related with calculations in calc_input_for_exact_output
when the denominator becomes negative.
In general, the problem is a case when quote/swap amount exceeds the reserves. We have to check these cases for all sources.
It is possible to fix it for ALT with several sources, because if one liquidity source doesn't have enough liquidity, it doesn't mean that total liquidity of all sources is not enough for a deal.
Definition of done
- [x] adapt xyk-pool::step_quote for case when reserves are exceeded
- [x] new unit tests for xyk-pool
- [x] adapt tbc::step_quote for case when reserves are exceeded if it's needed
- [x] new unit tests for tbc if they are needed
- [x] check order-book
- [x] check xst
- [x] check ALT with case when total sources liquidity is less then amount
- [ ] add irreducible reserve mechanism