sora2-network
sora2-network copied to clipboard
[Tech]: LiquidityProxy::quote() with deduce fee desired in/out difference
Problem statement
LiquidityProxy quote with deduce fee has some calculation error for xyk-pool. For example: LiquidityProxy quote that results 10 DAI for 1 XOR with deduced fee for desired input doesn't mean 1 XOR for 10 DAI for desired output.
Description
Steps to reproduce:
- LiquidityProxy::quote is called with desired_input and deduce_fee flag is set, then some amount is returned
- LiquidityProxy::quote is called with desired output with deduce fee and with the amount from step 1.
- the resulting amount from step 2 is different from initial input amount.
let desired_amount_in = balance!(1);
let quote_in = LiquidityProxy::quote(
DEX_A_ID,
&KSM,
&USDT,
QuoteAmount::WithDesiredInput {
desired_amount_in
},
LiquiditySourceFilter::with_allowed(DEX_A_ID, [LiquiditySourceType::XYKPool].into()),
true,
).unwrap();
dbg!("e_in);
// 496509477816324473
let desired_amount_out = quote_in.amount;
let quote_out = LiquidityProxy::quote(
DEX_A_ID,
&KSM,
&USDT,
QuoteAmount::WithDesiredOutput {
desired_amount_out
},
LiquiditySourceFilter::with_allowed(DEX_A_ID, [LiquiditySourceType::XYKPool].into()),
true,
).unwrap();
dbg!(quote_out);
// 999999999999999997
// quote_in != quote_out
Definition of Done
Beforementioned test is added and passed.
Requirements
No response