@paraswap/dex-lib 2.28.9-take-surplus.0 → 2.28.9-take-surplus.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/abi/RamsesV2StateMulticall.abi.json +891 -0
- package/build/abi/aerodrome/aerodrome-pool-factory.json +586 -0
- package/build/abi/algebra/AlgebraFactory-v1_1.abi.json +250 -0
- package/build/abi/api3-proxy.json +53 -0
- package/build/abi/api3-server-v1.json +463 -0
- package/build/abi/nomiswap-v2/nomiswap-v2-pool.json +773 -0
- package/build/abi/pancakeswap-v3/PancakeswapV3Factory.abi.json +300 -0
- package/build/abi/quick-perps/fast-price-events.json +70 -0
- package/build/abi/quick-perps/fast-price-feed.json +741 -0
- package/build/abi/quick-perps/reader.json +313 -0
- package/build/abi/quick-perps/vault-price-feed.json +323 -0
- package/build/abi/quick-perps/vault.json +1953 -0
- package/build/abi/quickPerps/fast-price-events.json +70 -0
- package/build/abi/quickPerps/fast-price-feed.json +748 -0
- package/build/abi/quickPerps/reader.json +313 -0
- package/build/abi/quickPerps/vault-price-feed.json +477 -0
- package/build/abi/quickPerps/vault.json +1953 -0
- package/build/abi/ramses-v2/RamsesV2Pool.abi.json +1599 -0
- package/build/abi/uniswap-v3/UniswapV3Factory.abi.json +148 -0
- package/build/abi/uniswap-v3/UniswapV3QuoterV2.abi.json +155 -0
- package/build/composed-event-subscriber.js +8 -2
- package/build/composed-event-subscriber.js.map +1 -1
- package/build/config.d.ts +0 -1
- package/build/config.js +75 -14
- package/build/config.js.map +1 -1
- package/build/constants.d.ts +2 -1
- package/build/constants.js +1 -0
- package/build/constants.js.map +1 -1
- package/build/dex/algebra/algebra-factory.d.ts +25 -0
- package/build/dex/algebra/algebra-factory.js +43 -0
- package/build/dex/algebra/algebra-factory.js.map +1 -0
- package/build/dex/algebra/algebra-pool-v1_1.d.ts +16 -2
- package/build/dex/algebra/algebra-pool-v1_1.js +166 -4
- package/build/dex/algebra/algebra-pool-v1_1.js.map +1 -1
- package/build/dex/algebra/algebra.d.ts +4 -1
- package/build/dex/algebra/algebra.js +42 -21
- package/build/dex/algebra/algebra.js.map +1 -1
- package/build/dex/algebra/config.js +1 -0
- package/build/dex/algebra/config.js.map +1 -1
- package/build/dex/algebra/lib/TickTable.js +51 -40
- package/build/dex/algebra/lib/TickTable.js.map +1 -1
- package/build/dex/algebra/types.d.ts +5 -2
- package/build/dex/algebra/utils.d.ts +3 -1
- package/build/dex/algebra/utils.js +59 -1
- package/build/dex/algebra/utils.js.map +1 -1
- package/build/dex/balancer-v2/balancer-v2.js +79 -6
- package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
- package/build/dex/balancer-v2/config.js +10 -2
- package/build/dex/balancer-v2/config.js.map +1 -1
- package/build/dex/balancer-v2/optimizer.js +38 -51
- package/build/dex/balancer-v2/optimizer.js.map +1 -1
- package/build/dex/balancer-v2/types.d.ts +0 -4
- package/build/dex/balancer-v2/types.js.map +1 -1
- package/build/dex/curve-v1/config.js +40 -38
- package/build/dex/curve-v1/config.js.map +1 -1
- package/build/dex/curve-v1-factory/config.js +17 -9
- package/build/dex/curve-v1-factory/config.js.map +1 -1
- package/build/dex/curve-v1-factory/curve-v1-factory.d.ts +1 -1
- package/build/dex/curve-v1-factory/curve-v1-factory.js +205 -182
- package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
- package/build/dex/curve-v1-factory/curve-v1-pool-manager.d.ts +2 -1
- package/build/dex/curve-v1-factory/curve-v1-pool-manager.js +8 -2
- package/build/dex/curve-v1-factory/curve-v1-pool-manager.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_rates.js +2 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_rates.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp_mem.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/_xp_mem.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js +61 -14
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/constants.js +10 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/constants.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_mem.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_mem.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y.js.map +1 -1
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js +1 -0
- package/build/dex/curve-v1-factory/price-handlers/functions/get_y_D.js.map +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.js +11 -4
- package/build/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.js.map +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.d.ts +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js +2 -2
- package/build/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.js.map +1 -1
- package/build/dex/curve-v1-factory/types.d.ts +4 -1
- package/build/dex/curve-v1-factory/types.js +1 -0
- package/build/dex/curve-v1-factory/types.js.map +1 -1
- package/build/dex/generic-rfq/generic-rfq.d.ts +2 -1
- package/build/dex/generic-rfq/generic-rfq.js +9 -5
- package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
- package/build/dex/generic-rfq/rate-fetcher.d.ts +1 -1
- package/build/dex/generic-rfq/rate-fetcher.js +2 -1
- package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
- package/build/dex/generic-rfq/types.d.ts +1 -0
- package/build/dex/generic-rfq/types.js.map +1 -1
- package/build/dex/hashflow/hashflow.d.ts +1 -0
- package/build/dex/hashflow/hashflow.js +1 -0
- package/build/dex/hashflow/hashflow.js.map +1 -1
- package/build/dex/idex.d.ts +1 -0
- package/build/dex/index.d.ts +1 -0
- package/build/dex/index.js +21 -0
- package/build/dex/index.js.map +1 -1
- package/build/dex/maverick-v1/config.js +9 -0
- package/build/dex/maverick-v1/config.js.map +1 -1
- package/build/dex/maverick-v1/maverick-v1.js +11 -2
- package/build/dex/maverick-v1/maverick-v1.js.map +1 -1
- package/build/dex/maverick-v1/scripts/event-sequence.d.ts +1 -0
- package/build/dex/maverick-v1/scripts/event-sequence.js +110 -0
- package/build/dex/maverick-v1/scripts/event-sequence.js.map +1 -0
- package/build/dex/pancakeswap-v3/config.js +17 -0
- package/build/dex/pancakeswap-v3/config.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.d.ts +26 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.js +44 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3-factory.js.map +1 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3.d.ts +3 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js +26 -2
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js.map +1 -1
- package/build/dex/quick-perps/config.d.ts +11 -0
- package/build/dex/quick-perps/config.js +27 -0
- package/build/dex/quick-perps/config.js.map +1 -0
- package/build/dex/quick-perps/fast-price-feed.d.ts +26 -0
- package/build/dex/quick-perps/fast-price-feed.js +176 -0
- package/build/dex/quick-perps/fast-price-feed.js.map +1 -0
- package/build/dex/quick-perps/pool.d.ts +21 -0
- package/build/dex/quick-perps/pool.js +225 -0
- package/build/dex/quick-perps/pool.js.map +1 -0
- package/build/dex/quick-perps/quick-perps.d.ts +52 -0
- package/build/dex/quick-perps/quick-perps.js +211 -0
- package/build/dex/quick-perps/quick-perps.js.map +1 -0
- package/build/dex/quick-perps/types.d.ts +98 -0
- package/build/dex/quick-perps/types.js +3 -0
- package/build/dex/quick-perps/types.js.map +1 -0
- package/build/dex/quick-perps/usdq.d.ts +15 -0
- package/build/dex/quick-perps/usdq.js +61 -0
- package/build/dex/quick-perps/usdq.js.map +1 -0
- package/build/dex/quick-perps/vault-price-feed.d.ts +43 -0
- package/build/dex/quick-perps/vault-price-feed.js +194 -0
- package/build/dex/quick-perps/vault-price-feed.js.map +1 -0
- package/build/dex/quick-perps/vault-utils.d.ts +8 -0
- package/build/dex/quick-perps/vault-utils.js +41 -0
- package/build/dex/quick-perps/vault-utils.js.map +1 -0
- package/build/dex/quick-perps/vault.d.ts +46 -0
- package/build/dex/quick-perps/vault.js +166 -0
- package/build/dex/quick-perps/vault.js.map +1 -0
- package/build/dex/solidly/config.js +52 -2
- package/build/dex/solidly/config.js.map +1 -1
- package/build/dex/solidly/forks-override/aerodrome.d.ts +14 -0
- package/build/dex/solidly/forks-override/aerodrome.js +48 -0
- package/build/dex/solidly/forks-override/aerodrome.js.map +1 -0
- package/build/dex/solidly/forks-override/equalizer.d.ts +20 -0
- package/build/dex/solidly/forks-override/equalizer.js +46 -0
- package/build/dex/solidly/forks-override/equalizer.js.map +1 -0
- package/build/dex/solidly/forks-override/ramses.d.ts +44 -0
- package/build/dex/solidly/forks-override/ramses.js +144 -0
- package/build/dex/solidly/forks-override/ramses.js.map +1 -0
- package/build/dex/solidly/forks-override/velodromeV2.d.ts +20 -0
- package/build/dex/solidly/forks-override/velodromeV2.js +50 -0
- package/build/dex/solidly/forks-override/velodromeV2.js.map +1 -0
- package/build/dex/solidly/solidly.js +4 -0
- package/build/dex/solidly/solidly.js.map +1 -1
- package/build/dex/uniswap-v2/nomiswap-v2.d.ts +24 -0
- package/build/dex/uniswap-v2/nomiswap-v2.js +44 -0
- package/build/dex/uniswap-v2/nomiswap-v2.js.map +1 -0
- package/build/dex/uniswap-v3/config.js +166 -0
- package/build/dex/uniswap-v3/config.js.map +1 -1
- package/build/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.d.ts +19 -0
- package/build/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.js +99 -0
- package/build/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.js.map +1 -0
- package/build/dex/uniswap-v3/forks/ramses-v2/utils.d.ts +4 -0
- package/build/dex/uniswap-v3/forks/ramses-v2/utils.js +63 -0
- package/build/dex/uniswap-v3/forks/ramses-v2/utils.js.map +1 -0
- package/build/dex/uniswap-v3/types.d.ts +10 -1
- package/build/dex/uniswap-v3/types.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3-factory.d.ts +26 -0
- package/build/dex/uniswap-v3/uniswap-v3-factory.js +44 -0
- package/build/dex/uniswap-v3/uniswap-v3-factory.js.map +1 -0
- package/build/dex/uniswap-v3/uniswap-v3-pool.d.ts +8 -6
- package/build/dex/uniswap-v3/uniswap-v3-pool.js +5 -2
- package/build/dex/uniswap-v3/uniswap-v3-pool.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3.d.ts +7 -4
- package/build/dex/uniswap-v3/uniswap-v3.js +51 -10
- package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
- package/build/dex/weth/config.js +3 -0
- package/build/dex/weth/config.js.map +1 -1
- package/build/dex/woo-fi-v2/config.js +13 -0
- package/build/dex/woo-fi-v2/config.js.map +1 -1
- package/build/dex-helper/dummy-dex-helper.js +7 -1
- package/build/dex-helper/dummy-dex-helper.js.map +1 -1
- package/build/dex-helper/icache.d.ts +1 -0
- package/build/lib/api3-feed.d.ts +30 -0
- package/build/lib/api3-feed.js +100 -0
- package/build/lib/api3-feed.js.map +1 -0
- package/build/lib/decoders.d.ts +3 -0
- package/build/lib/decoders.js +9 -1
- package/build/lib/decoders.js.map +1 -1
- package/build/stateful-event-subscriber.d.ts +1 -0
- package/build/stateful-event-subscriber.js +6 -0
- package/build/stateful-event-subscriber.js.map +1 -1
- package/build/types.d.ts +2 -0
- package/build/workers.d.ts +0 -0
- package/build/workers.js +2 -0
- package/build/workers.js.map +1 -0
- package/package.json +1 -1
- package/src/abi/RamsesV2Pool.abi.json +1554 -0
- package/src/abi/RamsesV2Quoter.abi.json +274 -0
- package/src/abi/RamsesV2StateMulticall.abi.json +891 -0
- package/src/abi/aerodrome/aerodrome-pool-factory.json +586 -0
- package/src/abi/algebra/AlgebraFactory-v1_1.abi.json +250 -0
- package/src/abi/api3-proxy.json +53 -0
- package/src/abi/api3-server-v1.json +463 -0
- package/src/abi/nomiswap-v2/nomiswap-v2-pool.json +773 -0
- package/src/abi/pancakeswap-v3/PancakeswapV3Factory.abi.json +300 -0
- package/src/abi/quick-perps/fast-price-events.json +70 -0
- package/src/abi/quick-perps/fast-price-feed.json +741 -0
- package/src/abi/quick-perps/reader.json +313 -0
- package/src/abi/quick-perps/vault-price-feed.json +323 -0
- package/src/abi/quick-perps/vault.json +1953 -0
- package/src/abi/ramses-v2/RamsesV2Pool.abi.json +1599 -0
- package/src/composed-event-subscriber.ts +16 -11
- package/src/config.ts +80 -14
- package/src/constants.ts +1 -0
- package/src/dex/algebra/algebra-factory.ts +70 -0
- package/src/dex/algebra/algebra-integration.test.ts +316 -16
- package/src/dex/algebra/algebra-pool-v1_1.ts +259 -8
- package/src/dex/algebra/algebra.ts +73 -22
- package/src/dex/algebra/config.ts +1 -0
- package/src/dex/algebra/lib/TickTable.ts +75 -74
- package/src/dex/algebra/types.ts +6 -2
- package/src/dex/algebra/utils.ts +83 -2
- package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +133 -4
- package/src/dex/balancer-v2/balancer-v2.ts +87 -6
- package/src/dex/balancer-v2/config.ts +11 -2
- package/src/dex/balancer-v2/optimizer.ts +49 -62
- package/src/dex/balancer-v2/types.ts +0 -4
- package/src/dex/curve-v1/config.ts +40 -38
- package/src/dex/curve-v1-factory/config.ts +17 -9
- package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +19 -0
- package/src/dex/curve-v1-factory/curve-v1-factory-integration.test.ts +165 -45
- package/src/dex/curve-v1-factory/curve-v1-factory.ts +477 -415
- package/src/dex/curve-v1-factory/curve-v1-pool-manager.ts +15 -2
- package/src/dex/curve-v1-factory/price-handlers/functions/_calc_withdraw_one_coin.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_dynamic_fee.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_rates.ts +2 -1
- package/src/dex/curve-v1-factory/price-handlers/functions/_xp.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/_xp_mem.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/calc_token_amount.ts +71 -13
- package/src/dex/curve-v1-factory/price-handlers/functions/calc_withdraw_one_coin.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/constants.ts +11 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D.ts +2 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D_mem.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_D_precisions.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_dy.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_dy_underlying.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_y.ts +1 -0
- package/src/dex/curve-v1-factory/price-handlers/functions/get_y_D.ts +1 -0
- package/src/dex/curve-v1-factory/state-polling-pools/custom-pool-polling.ts +13 -5
- package/src/dex/curve-v1-factory/state-polling-pools/factory-pool-polling.ts +2 -1
- package/src/dex/curve-v1-factory/types.ts +3 -1
- package/src/dex/generic-rfq/example-api.test.ts +1 -1
- package/src/dex/generic-rfq/generic-rfq.ts +12 -4
- package/src/dex/generic-rfq/rate-fetcher.ts +4 -2
- package/src/dex/generic-rfq/types.ts +1 -0
- package/src/dex/hashflow/hashflow-e2e.test.ts +36 -3
- package/src/dex/hashflow/hashflow.ts +2 -1
- package/src/dex/idex.ts +1 -0
- package/src/dex/index.ts +21 -0
- package/src/dex/maverick-v1/config.ts +10 -0
- package/src/dex/maverick-v1/maverick-v1-e2e.test.ts +115 -1
- package/src/dex/maverick-v1/maverick-v1.ts +12 -2
- package/src/dex/pancakeswap-v3/config.ts +19 -0
- package/src/dex/pancakeswap-v3/pancakeswap-v3-e2e.test.ts +114 -0
- package/src/dex/pancakeswap-v3/pancakeswap-v3-factory.ts +73 -0
- package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +50 -2
- package/src/dex/quick-perps/config.ts +31 -0
- package/src/dex/quick-perps/fast-price-feed.ts +279 -0
- package/src/dex/quick-perps/pool.ts +407 -0
- package/src/dex/quick-perps/quick-perps-e2e.test.ts +65 -0
- package/src/dex/quick-perps/quick-perps-events.test.ts +100 -0
- package/src/dex/quick-perps/quick-perps-integration.test.ts +153 -0
- package/src/dex/quick-perps/quick-perps.ts +302 -0
- package/src/dex/quick-perps/types.ts +97 -0
- package/src/dex/quick-perps/usdq.ts +83 -0
- package/src/dex/quick-perps/vault-price-feed.ts +322 -0
- package/src/dex/quick-perps/vault-utils.ts +53 -0
- package/src/dex/quick-perps/vault.ts +290 -0
- package/src/dex/solidly/config.ts +58 -2
- package/src/dex/solidly/forks-override/aerodrome.ts +53 -0
- package/src/dex/solidly/forks-override/equalizer.ts +58 -0
- package/src/dex/solidly/forks-override/ramses.ts +253 -0
- package/src/dex/solidly/forks-override/velodromeV2.ts +63 -0
- package/src/dex/solidly/solidly-e2e.test.ts +313 -1
- package/src/dex/solidly/solidly-integration.test.ts +540 -41
- package/src/dex/solidly/solidly.ts +5 -0
- package/src/dex/uniswap-v2/nomiswap-v2.ts +63 -0
- package/src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts +120 -1
- package/src/dex/uniswap-v3/config.ts +174 -0
- package/src/dex/uniswap-v3/forks/ramses-v2/ramses-v2-pool.ts +156 -0
- package/src/dex/uniswap-v3/forks/ramses-v2/utils.ts +72 -0
- package/src/dex/uniswap-v3/types.ts +14 -1
- package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +1071 -346
- package/src/dex/uniswap-v3/uniswap-v3-factory.ts +73 -0
- package/src/dex/uniswap-v3/uniswap-v3-integration.test.ts +787 -14
- package/src/dex/uniswap-v3/uniswap-v3-pool.ts +13 -5
- package/src/dex/uniswap-v3/uniswap-v3.ts +87 -20
- package/src/dex/weth/config.ts +3 -0
- package/src/dex/woo-fi-v2/config.ts +13 -0
- package/src/dex/woo-fi-v2/woo-fi-v2-e2e.test.ts +64 -0
- package/src/dex-helper/dummy-dex-helper.ts +8 -1
- package/src/dex-helper/icache.ts +2 -0
- package/src/lib/api3-feed.ts +175 -0
- package/src/lib/decoders.ts +13 -0
- package/src/stateful-event-subscriber.ts +8 -0
- package/src/types.ts +2 -0
- package/tests/constants-e2e.ts +102 -6
- package/tests/tenderly-simulation.ts +48 -4
- package/tests/utils-e2e.ts +21 -11
|
@@ -3,13 +3,13 @@ import dotenv from 'dotenv';
|
|
|
3
3
|
dotenv.config();
|
|
4
4
|
|
|
5
5
|
import { Interface, Result } from '@ethersproject/abi';
|
|
6
|
-
import { DummyDexHelper } from '../../dex-helper/index';
|
|
6
|
+
import { DummyDexHelper, IDexHelper } from '../../dex-helper/index';
|
|
7
7
|
import { Network, SwapSide } from '../../constants';
|
|
8
8
|
import { BI_POWS } from '../../bigint-constants';
|
|
9
9
|
import { UniswapV3 } from './uniswap-v3';
|
|
10
10
|
import { checkPoolPrices, checkPoolsLiquidity } from '../../../tests/utils';
|
|
11
11
|
import { Tokens } from '../../../tests/constants-e2e';
|
|
12
|
-
import
|
|
12
|
+
import UniswapV3QuoterV2ABI from '../../abi/uniswap-v3/UniswapV3QuoterV2.abi.json';
|
|
13
13
|
import { Address } from '@paraswap/core';
|
|
14
14
|
|
|
15
15
|
const network = Network.POLYGON;
|
|
@@ -28,10 +28,7 @@ const amounts = [
|
|
|
28
28
|
|
|
29
29
|
const amountsBuy = [0n, 1n * BI_POWS[18], 2n * BI_POWS[18], 3n * BI_POWS[18]];
|
|
30
30
|
|
|
31
|
-
const
|
|
32
|
-
const dexKey = 'UniswapV3';
|
|
33
|
-
|
|
34
|
-
const quoterIface = new Interface(UniswapV3QuoterABI);
|
|
31
|
+
const quoterIface = new Interface(UniswapV3QuoterV2ABI);
|
|
35
32
|
|
|
36
33
|
function getReaderCalldata(
|
|
37
34
|
exchangeAddress: string,
|
|
@@ -45,11 +42,7 @@ function getReaderCalldata(
|
|
|
45
42
|
return amounts.map(amount => ({
|
|
46
43
|
target: exchangeAddress,
|
|
47
44
|
callData: readerIface.encodeFunctionData(funcName, [
|
|
48
|
-
tokenIn,
|
|
49
|
-
tokenOut,
|
|
50
|
-
fee,
|
|
51
|
-
amount,
|
|
52
|
-
0n,
|
|
45
|
+
[tokenIn, tokenOut, amount.toString(), fee.toString(), 0],
|
|
53
46
|
]),
|
|
54
47
|
}));
|
|
55
48
|
}
|
|
@@ -66,9 +59,11 @@ function decodeReaderResult(
|
|
|
66
59
|
}
|
|
67
60
|
|
|
68
61
|
async function checkOnChainPricing(
|
|
62
|
+
dexHelper: IDexHelper,
|
|
69
63
|
uniswapV3: UniswapV3,
|
|
70
64
|
funcName: string,
|
|
71
65
|
blockNumber: number,
|
|
66
|
+
exchangeAddress: string,
|
|
72
67
|
prices: bigint[],
|
|
73
68
|
tokenIn: Address,
|
|
74
69
|
tokenOut: Address,
|
|
@@ -76,7 +71,7 @@ async function checkOnChainPricing(
|
|
|
76
71
|
_amounts: bigint[],
|
|
77
72
|
) {
|
|
78
73
|
// Quoter address
|
|
79
|
-
const exchangeAddress = '0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6';
|
|
74
|
+
// const exchangeAddress = '0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6';
|
|
80
75
|
const readerIface = quoterIface;
|
|
81
76
|
|
|
82
77
|
const sum = prices.reduce((acc, curr) => (acc += curr), 0n);
|
|
@@ -117,6 +112,8 @@ async function checkOnChainPricing(
|
|
|
117
112
|
decodeReaderResult(readerResult, readerIface, funcName),
|
|
118
113
|
);
|
|
119
114
|
|
|
115
|
+
console.log('EXPECTED PRICES: ', expectedPrices);
|
|
116
|
+
|
|
120
117
|
let firstZeroIndex = prices.slice(1).indexOf(0n);
|
|
121
118
|
|
|
122
119
|
// we skipped first, so add +1 on result
|
|
@@ -130,6 +127,9 @@ async function checkOnChainPricing(
|
|
|
130
127
|
}
|
|
131
128
|
|
|
132
129
|
describe('UniswapV3', function () {
|
|
130
|
+
const dexHelper = new DummyDexHelper(network);
|
|
131
|
+
const dexKey = 'UniswapV3';
|
|
132
|
+
|
|
133
133
|
let blockNumber: number;
|
|
134
134
|
let uniswapV3: UniswapV3;
|
|
135
135
|
let uniswapV3Mainnet: UniswapV3;
|
|
@@ -138,9 +138,9 @@ describe('UniswapV3', function () {
|
|
|
138
138
|
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
139
139
|
uniswapV3 = new UniswapV3(network, dexKey, dexHelper);
|
|
140
140
|
uniswapV3Mainnet = new UniswapV3(
|
|
141
|
-
Network.
|
|
141
|
+
Network.ARBITRUM,
|
|
142
142
|
dexKey,
|
|
143
|
-
new DummyDexHelper(Network.
|
|
143
|
+
new DummyDexHelper(Network.ARBITRUM),
|
|
144
144
|
);
|
|
145
145
|
});
|
|
146
146
|
|
|
@@ -173,9 +173,11 @@ describe('UniswapV3', function () {
|
|
|
173
173
|
poolPrices!.map(async price => {
|
|
174
174
|
const fee = uniswapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
175
175
|
const res = await checkOnChainPricing(
|
|
176
|
+
dexHelper,
|
|
176
177
|
uniswapV3,
|
|
177
178
|
'quoteExactInputSingle',
|
|
178
179
|
blockNumber,
|
|
180
|
+
'0x61fFE014bA17989E743c5F6cB21bF9697530B21e',
|
|
179
181
|
price.prices,
|
|
180
182
|
TokenA.address,
|
|
181
183
|
TokenB.address,
|
|
@@ -219,9 +221,11 @@ describe('UniswapV3', function () {
|
|
|
219
221
|
poolPrices!.map(async price => {
|
|
220
222
|
const fee = uniswapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
221
223
|
const res = await checkOnChainPricing(
|
|
224
|
+
dexHelper,
|
|
222
225
|
uniswapV3,
|
|
223
226
|
'quoteExactOutputSingle',
|
|
224
227
|
blockNumber,
|
|
228
|
+
'0x61fFE014bA17989E743c5F6cB21bF9697530B21e',
|
|
225
229
|
price.prices,
|
|
226
230
|
TokenA.address,
|
|
227
231
|
TokenB.address,
|
|
@@ -329,9 +333,11 @@ describe('UniswapV3', function () {
|
|
|
329
333
|
poolPrices!.map(async price => {
|
|
330
334
|
const fee = uniswapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
331
335
|
const res = await checkOnChainPricing(
|
|
336
|
+
dexHelper,
|
|
332
337
|
uniswapV3,
|
|
333
338
|
'quoteExactInputSingle',
|
|
334
339
|
blockNumber,
|
|
340
|
+
'0x61fFE014bA17989E743c5F6cB21bF9697530B21e',
|
|
335
341
|
price.prices,
|
|
336
342
|
TokenA.address,
|
|
337
343
|
TokenB.address,
|
|
@@ -439,9 +445,11 @@ describe('UniswapV3', function () {
|
|
|
439
445
|
poolPrices!.map(async price => {
|
|
440
446
|
const fee = uniswapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
441
447
|
const res = await checkOnChainPricing(
|
|
448
|
+
dexHelper,
|
|
442
449
|
uniswapV3,
|
|
443
450
|
'quoteExactOutputSingle',
|
|
444
451
|
blockNumber,
|
|
452
|
+
'0x61fFE014bA17989E743c5F6cB21bF9697530B21e',
|
|
445
453
|
price.prices,
|
|
446
454
|
TokenA.address,
|
|
447
455
|
TokenB.address,
|
|
@@ -466,3 +474,768 @@ describe('UniswapV3', function () {
|
|
|
466
474
|
}
|
|
467
475
|
});
|
|
468
476
|
});
|
|
477
|
+
|
|
478
|
+
describe('RamsesV2', () => {
|
|
479
|
+
const dexKey = 'RamsesV2';
|
|
480
|
+
let blockNumber: number;
|
|
481
|
+
let uniswapV3: UniswapV3;
|
|
482
|
+
let uniswapV3Mainnet: UniswapV3;
|
|
483
|
+
|
|
484
|
+
const network = Network.ARBITRUM;
|
|
485
|
+
const dexHelper = new DummyDexHelper(network);
|
|
486
|
+
const TokenASymbol = 'USDCe';
|
|
487
|
+
const TokenA = Tokens[network][TokenASymbol];
|
|
488
|
+
|
|
489
|
+
const TokenBSymbol = 'USDC';
|
|
490
|
+
const TokenB = Tokens[network][TokenBSymbol];
|
|
491
|
+
|
|
492
|
+
beforeEach(async () => {
|
|
493
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
494
|
+
uniswapV3 = new UniswapV3(network, dexKey, dexHelper);
|
|
495
|
+
uniswapV3Mainnet = new UniswapV3(Network.ARBITRUM, dexKey, dexHelper);
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
499
|
+
const amounts = [
|
|
500
|
+
0n,
|
|
501
|
+
6000000n,
|
|
502
|
+
12000000n,
|
|
503
|
+
18000000n,
|
|
504
|
+
24000000n,
|
|
505
|
+
30000000n,
|
|
506
|
+
36000000n,
|
|
507
|
+
42000000n,
|
|
508
|
+
];
|
|
509
|
+
|
|
510
|
+
const pools = await uniswapV3.getPoolIdentifiers(
|
|
511
|
+
TokenA,
|
|
512
|
+
TokenB,
|
|
513
|
+
SwapSide.SELL,
|
|
514
|
+
blockNumber,
|
|
515
|
+
);
|
|
516
|
+
console.log(`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `, pools);
|
|
517
|
+
|
|
518
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
519
|
+
|
|
520
|
+
const poolPrices = await uniswapV3.getPricesVolume(
|
|
521
|
+
TokenA,
|
|
522
|
+
TokenB,
|
|
523
|
+
amounts,
|
|
524
|
+
SwapSide.SELL,
|
|
525
|
+
blockNumber,
|
|
526
|
+
pools,
|
|
527
|
+
);
|
|
528
|
+
console.log(`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `, poolPrices);
|
|
529
|
+
|
|
530
|
+
expect(poolPrices).not.toBeNull();
|
|
531
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
532
|
+
|
|
533
|
+
let falseChecksCounter = 0;
|
|
534
|
+
await Promise.all(
|
|
535
|
+
poolPrices!.map(async price => {
|
|
536
|
+
const fee = uniswapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
537
|
+
const res = await checkOnChainPricing(
|
|
538
|
+
dexHelper,
|
|
539
|
+
uniswapV3,
|
|
540
|
+
'quoteExactInputSingle',
|
|
541
|
+
blockNumber,
|
|
542
|
+
'0xAA20EFF7ad2F523590dE6c04918DaAE0904E3b20',
|
|
543
|
+
price.prices,
|
|
544
|
+
TokenA.address,
|
|
545
|
+
TokenB.address,
|
|
546
|
+
fee,
|
|
547
|
+
amounts,
|
|
548
|
+
);
|
|
549
|
+
if (res === false) falseChecksCounter++;
|
|
550
|
+
}),
|
|
551
|
+
);
|
|
552
|
+
|
|
553
|
+
expect(falseChecksCounter).toBeLessThan(poolPrices!.length);
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
it('getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
557
|
+
const amounts = [
|
|
558
|
+
0n,
|
|
559
|
+
6000000n,
|
|
560
|
+
12000000n,
|
|
561
|
+
18000000n,
|
|
562
|
+
24000000n,
|
|
563
|
+
30000000n,
|
|
564
|
+
36000000n,
|
|
565
|
+
42000000n,
|
|
566
|
+
];
|
|
567
|
+
|
|
568
|
+
const pools = await uniswapV3.getPoolIdentifiers(
|
|
569
|
+
TokenA,
|
|
570
|
+
TokenB,
|
|
571
|
+
SwapSide.BUY,
|
|
572
|
+
blockNumber,
|
|
573
|
+
);
|
|
574
|
+
console.log(`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `, pools);
|
|
575
|
+
|
|
576
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
577
|
+
|
|
578
|
+
const poolPrices = await uniswapV3.getPricesVolume(
|
|
579
|
+
TokenA,
|
|
580
|
+
TokenB,
|
|
581
|
+
amounts,
|
|
582
|
+
SwapSide.BUY,
|
|
583
|
+
blockNumber,
|
|
584
|
+
pools,
|
|
585
|
+
);
|
|
586
|
+
console.log(`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `, poolPrices);
|
|
587
|
+
|
|
588
|
+
expect(poolPrices).not.toBeNull();
|
|
589
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
590
|
+
|
|
591
|
+
let falseChecksCounter = 0;
|
|
592
|
+
await Promise.all(
|
|
593
|
+
poolPrices!.map(async price => {
|
|
594
|
+
const fee = uniswapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
595
|
+
const res = await checkOnChainPricing(
|
|
596
|
+
dexHelper,
|
|
597
|
+
uniswapV3,
|
|
598
|
+
'quoteExactOutputSingle',
|
|
599
|
+
blockNumber,
|
|
600
|
+
'0xAA20EFF7ad2F523590dE6c04918DaAE0904E3b20',
|
|
601
|
+
price.prices,
|
|
602
|
+
TokenA.address,
|
|
603
|
+
TokenB.address,
|
|
604
|
+
fee,
|
|
605
|
+
amounts,
|
|
606
|
+
);
|
|
607
|
+
if (res === false) falseChecksCounter++;
|
|
608
|
+
}),
|
|
609
|
+
);
|
|
610
|
+
|
|
611
|
+
expect(falseChecksCounter).toBeLessThan(poolPrices!.length);
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
describe('ChronosV3', () => {
|
|
616
|
+
const dexKey = 'ChronosV3';
|
|
617
|
+
let blockNumber: number;
|
|
618
|
+
let uniswapV3: UniswapV3;
|
|
619
|
+
let uniswapV3Mainnet: UniswapV3;
|
|
620
|
+
|
|
621
|
+
const network = Network.ARBITRUM;
|
|
622
|
+
const dexHelper = new DummyDexHelper(network);
|
|
623
|
+
const TokenASymbol = 'USDCe';
|
|
624
|
+
const TokenA = Tokens[network][TokenASymbol];
|
|
625
|
+
|
|
626
|
+
const TokenBSymbol = 'USDT';
|
|
627
|
+
const TokenB = Tokens[network][TokenBSymbol];
|
|
628
|
+
|
|
629
|
+
beforeEach(async () => {
|
|
630
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
631
|
+
uniswapV3 = new UniswapV3(network, dexKey, dexHelper);
|
|
632
|
+
uniswapV3Mainnet = new UniswapV3(Network.ARBITRUM, dexKey, dexHelper);
|
|
633
|
+
});
|
|
634
|
+
|
|
635
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
636
|
+
const amounts = [0n, BI_POWS[6], 2000000n];
|
|
637
|
+
|
|
638
|
+
const pools = await uniswapV3.getPoolIdentifiers(
|
|
639
|
+
TokenA,
|
|
640
|
+
TokenB,
|
|
641
|
+
SwapSide.SELL,
|
|
642
|
+
blockNumber,
|
|
643
|
+
);
|
|
644
|
+
console.log(`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `, pools);
|
|
645
|
+
|
|
646
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
647
|
+
|
|
648
|
+
const poolPrices = await uniswapV3.getPricesVolume(
|
|
649
|
+
TokenA,
|
|
650
|
+
TokenB,
|
|
651
|
+
amounts,
|
|
652
|
+
SwapSide.SELL,
|
|
653
|
+
blockNumber,
|
|
654
|
+
pools,
|
|
655
|
+
);
|
|
656
|
+
console.log(`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `, poolPrices);
|
|
657
|
+
|
|
658
|
+
expect(poolPrices).not.toBeNull();
|
|
659
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
660
|
+
|
|
661
|
+
let falseChecksCounter = 0;
|
|
662
|
+
await Promise.all(
|
|
663
|
+
poolPrices!.map(async price => {
|
|
664
|
+
const fee = uniswapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
665
|
+
const res = await checkOnChainPricing(
|
|
666
|
+
dexHelper,
|
|
667
|
+
uniswapV3,
|
|
668
|
+
'quoteExactInputSingle',
|
|
669
|
+
blockNumber,
|
|
670
|
+
'0x6E7f0Ca45171a4440c0CDdF3A46A8dC5D4c2d4A0',
|
|
671
|
+
price.prices,
|
|
672
|
+
TokenA.address,
|
|
673
|
+
TokenB.address,
|
|
674
|
+
fee,
|
|
675
|
+
amounts,
|
|
676
|
+
);
|
|
677
|
+
if (res === false) falseChecksCounter++;
|
|
678
|
+
}),
|
|
679
|
+
);
|
|
680
|
+
|
|
681
|
+
expect(falseChecksCounter).toBeLessThan(poolPrices!.length);
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
it('getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
685
|
+
const amounts = [0n, BI_POWS[6], 2000000n];
|
|
686
|
+
|
|
687
|
+
const pools = await uniswapV3.getPoolIdentifiers(
|
|
688
|
+
TokenA,
|
|
689
|
+
TokenB,
|
|
690
|
+
SwapSide.BUY,
|
|
691
|
+
blockNumber,
|
|
692
|
+
);
|
|
693
|
+
console.log(`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `, pools);
|
|
694
|
+
|
|
695
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
696
|
+
|
|
697
|
+
const poolPrices = await uniswapV3.getPricesVolume(
|
|
698
|
+
TokenA,
|
|
699
|
+
TokenB,
|
|
700
|
+
amounts,
|
|
701
|
+
SwapSide.BUY,
|
|
702
|
+
blockNumber,
|
|
703
|
+
pools,
|
|
704
|
+
);
|
|
705
|
+
console.log(`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `, poolPrices);
|
|
706
|
+
|
|
707
|
+
expect(poolPrices).not.toBeNull();
|
|
708
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
709
|
+
|
|
710
|
+
let falseChecksCounter = 0;
|
|
711
|
+
await Promise.all(
|
|
712
|
+
poolPrices!.map(async price => {
|
|
713
|
+
const fee = uniswapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
714
|
+
const res = await checkOnChainPricing(
|
|
715
|
+
dexHelper,
|
|
716
|
+
uniswapV3,
|
|
717
|
+
'quoteExactOutputSingle',
|
|
718
|
+
blockNumber,
|
|
719
|
+
'0x6E7f0Ca45171a4440c0CDdF3A46A8dC5D4c2d4A0',
|
|
720
|
+
price.prices,
|
|
721
|
+
TokenA.address,
|
|
722
|
+
TokenB.address,
|
|
723
|
+
fee,
|
|
724
|
+
amounts,
|
|
725
|
+
);
|
|
726
|
+
if (res === false) falseChecksCounter++;
|
|
727
|
+
}),
|
|
728
|
+
);
|
|
729
|
+
|
|
730
|
+
expect(falseChecksCounter).toBeLessThan(poolPrices!.length);
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
it.skip('getTopPoolsForToken', async function () {
|
|
734
|
+
const poolLiquidity = await uniswapV3.getTopPoolsForToken(
|
|
735
|
+
TokenB.address,
|
|
736
|
+
10,
|
|
737
|
+
);
|
|
738
|
+
console.log(`${TokenASymbol} Top Pools:`, poolLiquidity);
|
|
739
|
+
|
|
740
|
+
checkPoolsLiquidity(poolLiquidity, TokenB.address, dexKey);
|
|
741
|
+
});
|
|
742
|
+
});
|
|
743
|
+
|
|
744
|
+
describe('SushiSwapV3', () => {
|
|
745
|
+
const dexKey = 'SushiSwapV3';
|
|
746
|
+
|
|
747
|
+
describe('Mainnet', () => {
|
|
748
|
+
let blockNumber: number;
|
|
749
|
+
let sushiSwapV3: UniswapV3;
|
|
750
|
+
let sushiSwapV3Mainnet: UniswapV3;
|
|
751
|
+
|
|
752
|
+
const network = Network.MAINNET;
|
|
753
|
+
const dexHelper = new DummyDexHelper(network);
|
|
754
|
+
const TokenASymbol = 'USDC';
|
|
755
|
+
const TokenA = Tokens[network][TokenASymbol];
|
|
756
|
+
|
|
757
|
+
const TokenBSymbol = 'USDT';
|
|
758
|
+
const TokenB = Tokens[network][TokenBSymbol];
|
|
759
|
+
|
|
760
|
+
beforeEach(async () => {
|
|
761
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
762
|
+
sushiSwapV3 = new UniswapV3(network, dexKey, dexHelper);
|
|
763
|
+
sushiSwapV3Mainnet = new UniswapV3(Network.MAINNET, dexKey, dexHelper);
|
|
764
|
+
});
|
|
765
|
+
|
|
766
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
767
|
+
const amounts = [0n, BI_POWS[6], 2000000n];
|
|
768
|
+
|
|
769
|
+
const pools = await sushiSwapV3.getPoolIdentifiers(
|
|
770
|
+
TokenA,
|
|
771
|
+
TokenB,
|
|
772
|
+
SwapSide.SELL,
|
|
773
|
+
blockNumber,
|
|
774
|
+
);
|
|
775
|
+
console.log(
|
|
776
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
|
|
777
|
+
pools,
|
|
778
|
+
);
|
|
779
|
+
|
|
780
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
781
|
+
|
|
782
|
+
const poolPrices = await sushiSwapV3.getPricesVolume(
|
|
783
|
+
TokenA,
|
|
784
|
+
TokenB,
|
|
785
|
+
amounts,
|
|
786
|
+
SwapSide.SELL,
|
|
787
|
+
blockNumber,
|
|
788
|
+
pools,
|
|
789
|
+
);
|
|
790
|
+
console.log(
|
|
791
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
|
|
792
|
+
poolPrices,
|
|
793
|
+
);
|
|
794
|
+
|
|
795
|
+
expect(poolPrices).not.toBeNull();
|
|
796
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
797
|
+
|
|
798
|
+
let falseChecksCounter = 0;
|
|
799
|
+
await Promise.all(
|
|
800
|
+
poolPrices!.map(async price => {
|
|
801
|
+
const fee = sushiSwapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
802
|
+
const res = await checkOnChainPricing(
|
|
803
|
+
dexHelper,
|
|
804
|
+
sushiSwapV3,
|
|
805
|
+
'quoteExactInputSingle',
|
|
806
|
+
blockNumber,
|
|
807
|
+
'0x64e8802FE490fa7cc61d3463958199161Bb608A7',
|
|
808
|
+
price.prices,
|
|
809
|
+
TokenA.address,
|
|
810
|
+
TokenB.address,
|
|
811
|
+
fee,
|
|
812
|
+
amounts,
|
|
813
|
+
);
|
|
814
|
+
if (res === false) falseChecksCounter++;
|
|
815
|
+
}),
|
|
816
|
+
);
|
|
817
|
+
|
|
818
|
+
expect(falseChecksCounter).toBeLessThan(poolPrices!.length);
|
|
819
|
+
});
|
|
820
|
+
|
|
821
|
+
it('getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
822
|
+
const amounts = [0n, BI_POWS[6], 2000000n];
|
|
823
|
+
|
|
824
|
+
const pools = await sushiSwapV3.getPoolIdentifiers(
|
|
825
|
+
TokenA,
|
|
826
|
+
TokenB,
|
|
827
|
+
SwapSide.BUY,
|
|
828
|
+
blockNumber,
|
|
829
|
+
);
|
|
830
|
+
console.log(
|
|
831
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
|
|
832
|
+
pools,
|
|
833
|
+
);
|
|
834
|
+
|
|
835
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
836
|
+
|
|
837
|
+
const poolPrices = await sushiSwapV3.getPricesVolume(
|
|
838
|
+
TokenA,
|
|
839
|
+
TokenB,
|
|
840
|
+
amounts,
|
|
841
|
+
SwapSide.BUY,
|
|
842
|
+
blockNumber,
|
|
843
|
+
pools,
|
|
844
|
+
);
|
|
845
|
+
console.log(
|
|
846
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
|
|
847
|
+
poolPrices,
|
|
848
|
+
);
|
|
849
|
+
|
|
850
|
+
expect(poolPrices).not.toBeNull();
|
|
851
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
852
|
+
|
|
853
|
+
let falseChecksCounter = 0;
|
|
854
|
+
await Promise.all(
|
|
855
|
+
poolPrices!.map(async price => {
|
|
856
|
+
const fee = sushiSwapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
857
|
+
const res = await checkOnChainPricing(
|
|
858
|
+
dexHelper,
|
|
859
|
+
sushiSwapV3,
|
|
860
|
+
'quoteExactOutputSingle',
|
|
861
|
+
blockNumber,
|
|
862
|
+
'0x64e8802FE490fa7cc61d3463958199161Bb608A7',
|
|
863
|
+
price.prices,
|
|
864
|
+
TokenA.address,
|
|
865
|
+
TokenB.address,
|
|
866
|
+
fee,
|
|
867
|
+
amounts,
|
|
868
|
+
);
|
|
869
|
+
if (res === false) falseChecksCounter++;
|
|
870
|
+
}),
|
|
871
|
+
);
|
|
872
|
+
|
|
873
|
+
expect(falseChecksCounter).toBeLessThan(poolPrices!.length);
|
|
874
|
+
});
|
|
875
|
+
|
|
876
|
+
it('getTopPoolsForToken', async function () {
|
|
877
|
+
const poolLiquidity = await sushiSwapV3.getTopPoolsForToken(
|
|
878
|
+
TokenB.address,
|
|
879
|
+
10,
|
|
880
|
+
);
|
|
881
|
+
console.log(`${TokenASymbol} Top Pools:`, poolLiquidity);
|
|
882
|
+
|
|
883
|
+
checkPoolsLiquidity(poolLiquidity, TokenB.address, dexKey);
|
|
884
|
+
});
|
|
885
|
+
});
|
|
886
|
+
|
|
887
|
+
describe('Arbitrum', () => {
|
|
888
|
+
let blockNumber: number;
|
|
889
|
+
let sushiSwapV3: UniswapV3;
|
|
890
|
+
let sushiSwapV3Mainnet: UniswapV3;
|
|
891
|
+
|
|
892
|
+
const network = Network.ARBITRUM;
|
|
893
|
+
const dexHelper = new DummyDexHelper(network);
|
|
894
|
+
const TokenASymbol = 'USDCe';
|
|
895
|
+
const TokenA = Tokens[network][TokenASymbol];
|
|
896
|
+
|
|
897
|
+
const TokenBSymbol = 'USDT';
|
|
898
|
+
const TokenB = Tokens[network][TokenBSymbol];
|
|
899
|
+
|
|
900
|
+
beforeEach(async () => {
|
|
901
|
+
// blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
902
|
+
blockNumber = 125789437;
|
|
903
|
+
sushiSwapV3 = new UniswapV3(network, dexKey, dexHelper);
|
|
904
|
+
sushiSwapV3Mainnet = new UniswapV3(Network.ARBITRUM, dexKey, dexHelper);
|
|
905
|
+
});
|
|
906
|
+
|
|
907
|
+
it('getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
908
|
+
const amounts = [0n, 100000000n, 200000000n];
|
|
909
|
+
|
|
910
|
+
const pools = await sushiSwapV3.getPoolIdentifiers(
|
|
911
|
+
TokenA,
|
|
912
|
+
TokenB,
|
|
913
|
+
SwapSide.BUY,
|
|
914
|
+
blockNumber,
|
|
915
|
+
);
|
|
916
|
+
console.log(
|
|
917
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
|
|
918
|
+
pools,
|
|
919
|
+
);
|
|
920
|
+
|
|
921
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
922
|
+
|
|
923
|
+
const poolPrices = await sushiSwapV3.getPricesVolume(
|
|
924
|
+
TokenA,
|
|
925
|
+
TokenB,
|
|
926
|
+
amounts,
|
|
927
|
+
SwapSide.BUY,
|
|
928
|
+
blockNumber,
|
|
929
|
+
pools,
|
|
930
|
+
);
|
|
931
|
+
console.log(
|
|
932
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
|
|
933
|
+
poolPrices,
|
|
934
|
+
);
|
|
935
|
+
|
|
936
|
+
expect(poolPrices).not.toBeNull();
|
|
937
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
938
|
+
|
|
939
|
+
let falseChecksCounter = 0;
|
|
940
|
+
await Promise.all(
|
|
941
|
+
poolPrices!.map(async price => {
|
|
942
|
+
const fee = sushiSwapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
943
|
+
const res = await checkOnChainPricing(
|
|
944
|
+
dexHelper,
|
|
945
|
+
sushiSwapV3,
|
|
946
|
+
'quoteExactOutputSingle',
|
|
947
|
+
blockNumber,
|
|
948
|
+
'0x0524E833cCD057e4d7A296e3aaAb9f7675964Ce1',
|
|
949
|
+
price.prices,
|
|
950
|
+
TokenA.address,
|
|
951
|
+
TokenB.address,
|
|
952
|
+
fee,
|
|
953
|
+
amounts,
|
|
954
|
+
);
|
|
955
|
+
if (res === false) falseChecksCounter++;
|
|
956
|
+
}),
|
|
957
|
+
);
|
|
958
|
+
|
|
959
|
+
expect(falseChecksCounter).toBeLessThan(poolPrices!.length);
|
|
960
|
+
});
|
|
961
|
+
});
|
|
962
|
+
|
|
963
|
+
describe('Base', () => {
|
|
964
|
+
let blockNumber: number;
|
|
965
|
+
let sushiSwapV3: UniswapV3;
|
|
966
|
+
let sushiSwapV3Mainnet: UniswapV3;
|
|
967
|
+
|
|
968
|
+
const network = Network.BASE;
|
|
969
|
+
const dexHelper = new DummyDexHelper(network);
|
|
970
|
+
const TokenASymbol = 'USDbC';
|
|
971
|
+
const TokenA = Tokens[network][TokenASymbol];
|
|
972
|
+
|
|
973
|
+
const TokenBSymbol = 'DAI';
|
|
974
|
+
const TokenB = Tokens[network][TokenBSymbol];
|
|
975
|
+
|
|
976
|
+
beforeEach(async () => {
|
|
977
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
978
|
+
sushiSwapV3 = new UniswapV3(network, dexKey, dexHelper);
|
|
979
|
+
sushiSwapV3Mainnet = new UniswapV3(Network.MAINNET, dexKey, dexHelper);
|
|
980
|
+
});
|
|
981
|
+
|
|
982
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
983
|
+
const amounts = [0n, BI_POWS[6], 2000000n];
|
|
984
|
+
|
|
985
|
+
const pools = await sushiSwapV3.getPoolIdentifiers(
|
|
986
|
+
TokenA,
|
|
987
|
+
TokenB,
|
|
988
|
+
SwapSide.SELL,
|
|
989
|
+
blockNumber,
|
|
990
|
+
);
|
|
991
|
+
console.log(
|
|
992
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
|
|
993
|
+
pools,
|
|
994
|
+
);
|
|
995
|
+
|
|
996
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
997
|
+
|
|
998
|
+
const poolPrices = await sushiSwapV3.getPricesVolume(
|
|
999
|
+
TokenA,
|
|
1000
|
+
TokenB,
|
|
1001
|
+
amounts,
|
|
1002
|
+
SwapSide.SELL,
|
|
1003
|
+
blockNumber,
|
|
1004
|
+
pools,
|
|
1005
|
+
);
|
|
1006
|
+
console.log(
|
|
1007
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
|
|
1008
|
+
poolPrices,
|
|
1009
|
+
);
|
|
1010
|
+
|
|
1011
|
+
expect(poolPrices).not.toBeNull();
|
|
1012
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
1013
|
+
|
|
1014
|
+
let falseChecksCounter = 0;
|
|
1015
|
+
await Promise.all(
|
|
1016
|
+
poolPrices!.map(async price => {
|
|
1017
|
+
const fee = sushiSwapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
1018
|
+
const res = await checkOnChainPricing(
|
|
1019
|
+
dexHelper,
|
|
1020
|
+
sushiSwapV3,
|
|
1021
|
+
'quoteExactInputSingle',
|
|
1022
|
+
blockNumber,
|
|
1023
|
+
'0xb1E835Dc2785b52265711e17fCCb0fd018226a6e',
|
|
1024
|
+
price.prices,
|
|
1025
|
+
TokenA.address,
|
|
1026
|
+
TokenB.address,
|
|
1027
|
+
fee,
|
|
1028
|
+
amounts,
|
|
1029
|
+
);
|
|
1030
|
+
if (res === false) falseChecksCounter++;
|
|
1031
|
+
}),
|
|
1032
|
+
);
|
|
1033
|
+
|
|
1034
|
+
expect(falseChecksCounter).toBeLessThan(poolPrices!.length);
|
|
1035
|
+
});
|
|
1036
|
+
|
|
1037
|
+
it('getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
1038
|
+
const amounts = [0n, BI_POWS[6], 2000000n];
|
|
1039
|
+
|
|
1040
|
+
const pools = await sushiSwapV3.getPoolIdentifiers(
|
|
1041
|
+
TokenA,
|
|
1042
|
+
TokenB,
|
|
1043
|
+
SwapSide.BUY,
|
|
1044
|
+
blockNumber,
|
|
1045
|
+
);
|
|
1046
|
+
console.log(
|
|
1047
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
|
|
1048
|
+
pools,
|
|
1049
|
+
);
|
|
1050
|
+
|
|
1051
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
1052
|
+
|
|
1053
|
+
const poolPrices = await sushiSwapV3.getPricesVolume(
|
|
1054
|
+
TokenA,
|
|
1055
|
+
TokenB,
|
|
1056
|
+
amounts,
|
|
1057
|
+
SwapSide.BUY,
|
|
1058
|
+
blockNumber,
|
|
1059
|
+
pools,
|
|
1060
|
+
);
|
|
1061
|
+
console.log(
|
|
1062
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
|
|
1063
|
+
poolPrices,
|
|
1064
|
+
);
|
|
1065
|
+
|
|
1066
|
+
expect(poolPrices).not.toBeNull();
|
|
1067
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
1068
|
+
|
|
1069
|
+
let falseChecksCounter = 0;
|
|
1070
|
+
await Promise.all(
|
|
1071
|
+
poolPrices!.map(async price => {
|
|
1072
|
+
const fee = sushiSwapV3.eventPools[price.poolIdentifier!]!.feeCode;
|
|
1073
|
+
const res = await checkOnChainPricing(
|
|
1074
|
+
dexHelper,
|
|
1075
|
+
sushiSwapV3,
|
|
1076
|
+
'quoteExactOutputSingle',
|
|
1077
|
+
blockNumber,
|
|
1078
|
+
'0xb1E835Dc2785b52265711e17fCCb0fd018226a6e',
|
|
1079
|
+
price.prices,
|
|
1080
|
+
TokenA.address,
|
|
1081
|
+
TokenB.address,
|
|
1082
|
+
fee,
|
|
1083
|
+
amounts,
|
|
1084
|
+
);
|
|
1085
|
+
if (res === false) falseChecksCounter++;
|
|
1086
|
+
}),
|
|
1087
|
+
);
|
|
1088
|
+
|
|
1089
|
+
expect(falseChecksCounter).toBeLessThan(poolPrices!.length);
|
|
1090
|
+
});
|
|
1091
|
+
|
|
1092
|
+
it('getTopPoolsForToken', async function () {
|
|
1093
|
+
const poolLiquidity = await sushiSwapV3.getTopPoolsForToken(
|
|
1094
|
+
TokenB.address,
|
|
1095
|
+
10,
|
|
1096
|
+
);
|
|
1097
|
+
console.log(`${TokenASymbol} Top Pools:`, poolLiquidity);
|
|
1098
|
+
|
|
1099
|
+
checkPoolsLiquidity(poolLiquidity, TokenB.address, dexKey);
|
|
1100
|
+
});
|
|
1101
|
+
});
|
|
1102
|
+
});
|
|
1103
|
+
|
|
1104
|
+
describe('Retro', () => {
|
|
1105
|
+
const dexKey = 'Retro';
|
|
1106
|
+
|
|
1107
|
+
describe('Polygon', () => {
|
|
1108
|
+
let blockNumber: number;
|
|
1109
|
+
let retro: UniswapV3;
|
|
1110
|
+
|
|
1111
|
+
const network = Network.POLYGON;
|
|
1112
|
+
const dexHelper = new DummyDexHelper(network);
|
|
1113
|
+
const TokenASymbol = 'USDC';
|
|
1114
|
+
const TokenA = Tokens[network][TokenASymbol];
|
|
1115
|
+
|
|
1116
|
+
const TokenBSymbol = 'USDT';
|
|
1117
|
+
const TokenB = Tokens[network][TokenBSymbol];
|
|
1118
|
+
|
|
1119
|
+
beforeEach(async () => {
|
|
1120
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
1121
|
+
retro = new UniswapV3(network, dexKey, dexHelper);
|
|
1122
|
+
});
|
|
1123
|
+
|
|
1124
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
1125
|
+
const amounts = [0n, BI_POWS[6], 2000000n];
|
|
1126
|
+
|
|
1127
|
+
const pools = await retro.getPoolIdentifiers(
|
|
1128
|
+
TokenA,
|
|
1129
|
+
TokenB,
|
|
1130
|
+
SwapSide.SELL,
|
|
1131
|
+
blockNumber,
|
|
1132
|
+
);
|
|
1133
|
+
console.log(
|
|
1134
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
|
|
1135
|
+
pools,
|
|
1136
|
+
);
|
|
1137
|
+
|
|
1138
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
1139
|
+
|
|
1140
|
+
const poolPrices = await retro.getPricesVolume(
|
|
1141
|
+
TokenA,
|
|
1142
|
+
TokenB,
|
|
1143
|
+
amounts,
|
|
1144
|
+
SwapSide.SELL,
|
|
1145
|
+
blockNumber,
|
|
1146
|
+
pools,
|
|
1147
|
+
);
|
|
1148
|
+
console.log(
|
|
1149
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
|
|
1150
|
+
poolPrices,
|
|
1151
|
+
);
|
|
1152
|
+
|
|
1153
|
+
expect(poolPrices).not.toBeNull();
|
|
1154
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
1155
|
+
|
|
1156
|
+
let falseChecksCounter = 0;
|
|
1157
|
+
await Promise.all(
|
|
1158
|
+
poolPrices!.map(async price => {
|
|
1159
|
+
const fee = retro.eventPools[price.poolIdentifier!]!.feeCode;
|
|
1160
|
+
const res = await checkOnChainPricing(
|
|
1161
|
+
dexHelper,
|
|
1162
|
+
retro,
|
|
1163
|
+
'quoteExactInputSingle',
|
|
1164
|
+
blockNumber,
|
|
1165
|
+
'0xfe08be075758935cb6cb9318d1fbb60920416d4e',
|
|
1166
|
+
price.prices,
|
|
1167
|
+
TokenA.address,
|
|
1168
|
+
TokenB.address,
|
|
1169
|
+
fee,
|
|
1170
|
+
amounts,
|
|
1171
|
+
);
|
|
1172
|
+
if (res === false) falseChecksCounter++;
|
|
1173
|
+
}),
|
|
1174
|
+
);
|
|
1175
|
+
|
|
1176
|
+
expect(falseChecksCounter).toBeLessThan(poolPrices!.length);
|
|
1177
|
+
});
|
|
1178
|
+
|
|
1179
|
+
it('getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
1180
|
+
const amounts = [0n, BI_POWS[6], 2000000n];
|
|
1181
|
+
|
|
1182
|
+
const pools = await retro.getPoolIdentifiers(
|
|
1183
|
+
TokenA,
|
|
1184
|
+
TokenB,
|
|
1185
|
+
SwapSide.BUY,
|
|
1186
|
+
blockNumber,
|
|
1187
|
+
);
|
|
1188
|
+
console.log(
|
|
1189
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `,
|
|
1190
|
+
pools,
|
|
1191
|
+
);
|
|
1192
|
+
|
|
1193
|
+
expect(pools.length).toBeGreaterThan(0);
|
|
1194
|
+
|
|
1195
|
+
const poolPrices = await retro.getPricesVolume(
|
|
1196
|
+
TokenA,
|
|
1197
|
+
TokenB,
|
|
1198
|
+
amounts,
|
|
1199
|
+
SwapSide.BUY,
|
|
1200
|
+
blockNumber,
|
|
1201
|
+
pools,
|
|
1202
|
+
);
|
|
1203
|
+
console.log(
|
|
1204
|
+
`${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `,
|
|
1205
|
+
poolPrices,
|
|
1206
|
+
);
|
|
1207
|
+
|
|
1208
|
+
expect(poolPrices).not.toBeNull();
|
|
1209
|
+
checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey);
|
|
1210
|
+
|
|
1211
|
+
let falseChecksCounter = 0;
|
|
1212
|
+
await Promise.all(
|
|
1213
|
+
poolPrices!.map(async price => {
|
|
1214
|
+
const fee = retro.eventPools[price.poolIdentifier!]!.feeCode;
|
|
1215
|
+
const res = await checkOnChainPricing(
|
|
1216
|
+
dexHelper,
|
|
1217
|
+
retro,
|
|
1218
|
+
'quoteExactOutputSingle',
|
|
1219
|
+
blockNumber,
|
|
1220
|
+
'0xfe08be075758935cb6cb9318d1fbb60920416d4e',
|
|
1221
|
+
price.prices,
|
|
1222
|
+
TokenA.address,
|
|
1223
|
+
TokenB.address,
|
|
1224
|
+
fee,
|
|
1225
|
+
amounts,
|
|
1226
|
+
);
|
|
1227
|
+
if (res === false) falseChecksCounter++;
|
|
1228
|
+
}),
|
|
1229
|
+
);
|
|
1230
|
+
|
|
1231
|
+
expect(falseChecksCounter).toBeLessThan(poolPrices!.length);
|
|
1232
|
+
});
|
|
1233
|
+
|
|
1234
|
+
it('getTopPoolsForToken', async function () {
|
|
1235
|
+
const poolLiquidity = await retro.getTopPoolsForToken(TokenB.address, 10);
|
|
1236
|
+
console.log(`${TokenASymbol} Top Pools:`, poolLiquidity);
|
|
1237
|
+
|
|
1238
|
+
checkPoolsLiquidity(poolLiquidity, TokenB.address, dexKey);
|
|
1239
|
+
});
|
|
1240
|
+
});
|
|
1241
|
+
});
|