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

reduce amount of pools being queried #100

Merged
merged 1 commit into from
Feb 12, 2024
Merged

reduce amount of pools being queried #100

merged 1 commit into from
Feb 12, 2024

Conversation

KillariDev
Copy link

Here's explanations for these settings:

export declare type ProtocolPoolSelection = {
    /**
     * The top N pools by TVL out of all pools on the protocol.
     */
    topN: number;
    /**
     * The top N pools by TVL of pools that consist of tokenIn and tokenOut.
     */
    topNDirectSwaps: number;
    /**
     * The top N pools by TVL of pools where one token is tokenIn and the
     * top N pools by TVL of pools where one token is tokenOut tokenOut.
     */
    topNTokenInOut: number;
    /**
     * Given the topNTokenInOut pools, gets the top N pools that involve the other token.
     * E.g. for a WETH -> USDC swap, if topNTokenInOut found WETH -> DAI and WETH -> USDT,
     * a value of 2 would find the top 2 pools that involve DAI and top 2 pools that involve USDT.
     */
    topNSecondHop: number;
    /**
     * Given the topNTokenInOut pools and a token address,
     * gets the top N pools that involve the other token.
     * If token address is not on the list, we default to topNSecondHop.
     * E.g. for a WETH -> USDC swap, if topNTokenInOut found WETH -> DAI and WETH -> USDT,
     * and there's a mapping USDT => 4, but no mapping for DAI
     * it would find the top 4 pools that involve USDT, and find the topNSecondHop pools that involve DAI
     */
    topNSecondHopForTokenAddress?: MapWithLowerCaseKey<number>;
    /**
     * The top N pools for token in and token out that involve a token from a list of
     * hardcoded 'base tokens'. These are standard tokens such as WETH, USDC, DAI, etc.
     * This is similar to how the legacy routing algorithm used by Uniswap would select
     * pools and is intended to make the new pool selection algorithm close to a superset
     * of the old algorithm.
     */
    topNWithEachBaseToken: number;
    /**
     * Given the topNWithEachBaseToken pools, takes the top N pools from the full list.
     * E.g. for a WETH -> USDC swap, if topNWithEachBaseToken found WETH -0.05-> DAI,
     * WETH -0.01-> DAI, WETH -0.05-> USDC, WETH -0.3-> USDC, a value of 2 would reduce
     * this set to the top 2 pools from that full list.
     */
    topNWithBaseToken: number;
};

Copy link

@MicahZoltu MicahZoltu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea how much this decreases volume/complexity by?

@KillariDev
Copy link
Author

Any idea how much this decreases volume/complexity by?

about ~30-40% from the tests I made

@KillariDev KillariDev merged commit 4491ca1 into main Feb 12, 2024
14 checks passed
@KillariDev KillariDev deleted the reduce-pool-amount branch February 12, 2024 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants