DarkFlorist / Horswap

🐎 Open source and censorship resistant interface for the Uniswap protocol
https://www.dark.florist/
GNU General Public License v3.0
29 stars 17 forks source link

reduce amount of pools being queried #100

Closed KillariDev closed 9 months ago

KillariDev commented 9 months ago

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;
};
KillariDev commented 9 months ago

Any idea how much this decreases volume/complexity by?

about ~30-40% from the tests I made