Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tech]: LiquidityProxy::quote() with deduce fee desired in/out difference #963

Open
Alexey-N-Chernyshov opened this issue Apr 1, 2024 · 0 comments
Labels
tech Technical task

Comments

@Alexey-N-Chernyshov
Copy link
Contributor

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:

  1. LiquidityProxy::quote is called with desired_input and deduce_fee flag is set, then some amount is returned
  2. LiquidityProxy::quote is called with desired output with deduce fee and with the amount from step 1.
  3. 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!(&quote_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

@Alexey-N-Chernyshov Alexey-N-Chernyshov added the tech Technical task label Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech Technical task
Projects
None yet
Development

No branches or pull requests

1 participant