@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
package/src/dex/index.ts
CHANGED
|
@@ -42,13 +42,17 @@ import { WooFiV2 } from './woo-fi-v2/woo-fi-v2';
|
|
|
42
42
|
import { ParaSwapLimitOrders } from './paraswap-limit-orders/paraswap-limit-orders';
|
|
43
43
|
import { AugustusRFQOrder } from './augustus-rfq';
|
|
44
44
|
import { Solidly } from './solidly/solidly';
|
|
45
|
+
import { Ramses } from './solidly/forks-override/ramses';
|
|
45
46
|
import { Thena } from './solidly/forks-override/thena';
|
|
46
47
|
import { Chronos } from './solidly/forks-override/chronos';
|
|
47
48
|
import { Velodrome } from './solidly/forks-override/velodrome';
|
|
49
|
+
import { VelodromeV2 } from './solidly/forks-override/velodromeV2';
|
|
50
|
+
import { Aerodrome } from './solidly/forks-override/aerodrome';
|
|
48
51
|
import { SpiritSwapV2 } from './solidly/forks-override/spiritSwapV2';
|
|
49
52
|
import { Synthetix } from './synthetix/synthetix';
|
|
50
53
|
import { Cone } from './solidly/forks-override/cone';
|
|
51
54
|
import { SoliSnek } from './solidly/forks-override/solisnek';
|
|
55
|
+
import { Equalizer } from './solidly/forks-override/equalizer';
|
|
52
56
|
import { BalancerV1 } from './balancer-v1/balancer-v1';
|
|
53
57
|
import { balancerV1Merge } from './balancer-v1/optimizer';
|
|
54
58
|
import { CurveV1 } from './curve-v1/curve-v1';
|
|
@@ -70,6 +74,8 @@ import { SpiritSwapV3 } from './quickswap/spiritswap-v3';
|
|
|
70
74
|
import { TraderJoeV21 } from './trader-joe-v2.1';
|
|
71
75
|
import { PancakeswapV3 } from './pancakeswap-v3/pancakeswap-v3';
|
|
72
76
|
import { Algebra } from './algebra/algebra';
|
|
77
|
+
import { QuickPerps } from './quick-perps/quick-perps';
|
|
78
|
+
import { NomiswapV2 } from './uniswap-v2/nomiswap-v2';
|
|
73
79
|
|
|
74
80
|
const LegacyDexes = [
|
|
75
81
|
CurveV2,
|
|
@@ -124,11 +130,15 @@ const Dexes = [
|
|
|
124
130
|
Solidly,
|
|
125
131
|
SolidlyEthereum,
|
|
126
132
|
SpiritSwapV2,
|
|
133
|
+
Ramses,
|
|
127
134
|
Thena,
|
|
128
135
|
Chronos,
|
|
129
136
|
Velodrome,
|
|
137
|
+
VelodromeV2,
|
|
138
|
+
Aerodrome,
|
|
130
139
|
Cone,
|
|
131
140
|
SoliSnek,
|
|
141
|
+
Equalizer,
|
|
132
142
|
Synthetix,
|
|
133
143
|
CurveV1Factory,
|
|
134
144
|
SwaapV1,
|
|
@@ -137,6 +147,8 @@ const Dexes = [
|
|
|
137
147
|
MaverickV1,
|
|
138
148
|
Camelot,
|
|
139
149
|
SwaapV2,
|
|
150
|
+
QuickPerps,
|
|
151
|
+
NomiswapV2,
|
|
140
152
|
];
|
|
141
153
|
|
|
142
154
|
export type LegacyDexConstructor = new (dexHelper: IDexHelper) => IDexTxBuilder<
|
|
@@ -303,4 +315,13 @@ export class DexAdapterService {
|
|
|
303
315
|
? this.sellAdapters[specialDexKey]
|
|
304
316
|
: this.buyAdapters[specialDexKey];
|
|
305
317
|
}
|
|
318
|
+
|
|
319
|
+
doesPreProcessingRequireSequentiality(dexKey: string): boolean {
|
|
320
|
+
try {
|
|
321
|
+
const dex = this.getDexByKey(dexKey);
|
|
322
|
+
return !!dex.needsSequentialPreprocessing;
|
|
323
|
+
} catch (e) {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
306
327
|
}
|
|
@@ -14,6 +14,12 @@ export const MaverickV1Config: DexConfigMap<DexParams> = {
|
|
|
14
14
|
routerAddress: '0x4a585e0f7c18e2c414221d6402652d5e0990e5f8',
|
|
15
15
|
poolInspectorAddress: '0xaA5BF61a664109e959D69C38734d4EA7dF74e456',
|
|
16
16
|
},
|
|
17
|
+
[Network.BASE]: {
|
|
18
|
+
subgraphURL:
|
|
19
|
+
'https://api.studio.thegraph.com/query/42519/maverick-base/version/latest',
|
|
20
|
+
routerAddress: '0x32AED3Bce901DA12ca8489788F3A99fCe1056e14',
|
|
21
|
+
poolInspectorAddress: '0x65A3AD03Be97619284bA7AA1E3Ca05638B9d6364',
|
|
22
|
+
},
|
|
17
23
|
},
|
|
18
24
|
};
|
|
19
25
|
|
|
@@ -22,4 +28,8 @@ export const Adapters: Record<number, AdapterMappings> = {
|
|
|
22
28
|
[SwapSide.SELL]: [{ name: 'Adapter04', index: 2 }],
|
|
23
29
|
[SwapSide.BUY]: [{ name: 'BuyAdapter', index: 8 }],
|
|
24
30
|
},
|
|
31
|
+
[Network.BASE]: {
|
|
32
|
+
[SwapSide.SELL]: [{ name: 'BaseAdapter01', index: 2 }],
|
|
33
|
+
[SwapSide.BUY]: [{ name: 'BaseBuyAdapter', index: 2 }],
|
|
34
|
+
},
|
|
25
35
|
};
|
|
@@ -11,10 +11,103 @@ import { Network, ContractMethod, SwapSide } from '../../constants';
|
|
|
11
11
|
import { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
12
12
|
import { generateConfig } from '../../config';
|
|
13
13
|
|
|
14
|
+
function testForNetwork(
|
|
15
|
+
network: Network,
|
|
16
|
+
dexKey: string,
|
|
17
|
+
tokenASymbol: string,
|
|
18
|
+
tokenBSymbol: string,
|
|
19
|
+
tokenAAmount: string,
|
|
20
|
+
tokenBAmount: string,
|
|
21
|
+
nativeTokenAmount: string,
|
|
22
|
+
slippage?: number | undefined,
|
|
23
|
+
) {
|
|
24
|
+
const provider = new StaticJsonRpcProvider(
|
|
25
|
+
generateConfig(network).privateHttpProvider,
|
|
26
|
+
network,
|
|
27
|
+
);
|
|
28
|
+
const tokens = Tokens[network];
|
|
29
|
+
const holders = Holders[network];
|
|
30
|
+
const nativeTokenSymbol = NativeTokenSymbols[network];
|
|
31
|
+
|
|
32
|
+
const sideToContractMethods = new Map([
|
|
33
|
+
[
|
|
34
|
+
SwapSide.SELL,
|
|
35
|
+
[
|
|
36
|
+
ContractMethod.simpleSwap,
|
|
37
|
+
ContractMethod.multiSwap,
|
|
38
|
+
ContractMethod.megaSwap,
|
|
39
|
+
],
|
|
40
|
+
],
|
|
41
|
+
[SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
describe(`${network}`, () => {
|
|
45
|
+
sideToContractMethods.forEach((contractMethods, side) =>
|
|
46
|
+
describe(`${side}`, () => {
|
|
47
|
+
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
48
|
+
describe(`${contractMethod}`, () => {
|
|
49
|
+
it(`${nativeTokenSymbol} -> ${tokenASymbol}`, async () => {
|
|
50
|
+
await testE2E(
|
|
51
|
+
tokens[nativeTokenSymbol],
|
|
52
|
+
tokens[tokenASymbol],
|
|
53
|
+
holders[nativeTokenSymbol],
|
|
54
|
+
side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
|
|
55
|
+
side,
|
|
56
|
+
dexKey,
|
|
57
|
+
contractMethod,
|
|
58
|
+
network,
|
|
59
|
+
provider,
|
|
60
|
+
undefined,
|
|
61
|
+
undefined,
|
|
62
|
+
undefined,
|
|
63
|
+
slippage,
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
|
|
67
|
+
await testE2E(
|
|
68
|
+
tokens[tokenASymbol],
|
|
69
|
+
tokens[nativeTokenSymbol],
|
|
70
|
+
holders[tokenASymbol],
|
|
71
|
+
side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
|
|
72
|
+
side,
|
|
73
|
+
dexKey,
|
|
74
|
+
contractMethod,
|
|
75
|
+
network,
|
|
76
|
+
provider,
|
|
77
|
+
undefined,
|
|
78
|
+
undefined,
|
|
79
|
+
undefined,
|
|
80
|
+
slippage,
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
|
|
84
|
+
await testE2E(
|
|
85
|
+
tokens[tokenASymbol],
|
|
86
|
+
tokens[tokenBSymbol],
|
|
87
|
+
holders[tokenASymbol],
|
|
88
|
+
side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
|
|
89
|
+
side,
|
|
90
|
+
dexKey,
|
|
91
|
+
contractMethod,
|
|
92
|
+
network,
|
|
93
|
+
provider,
|
|
94
|
+
undefined,
|
|
95
|
+
undefined,
|
|
96
|
+
undefined,
|
|
97
|
+
slippage,
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}),
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
14
107
|
describe('MaverickV1 E2E', () => {
|
|
15
108
|
const dexKey = 'MaverickV1';
|
|
16
109
|
|
|
17
|
-
describe('
|
|
110
|
+
describe('MAINNET', () => {
|
|
18
111
|
const network = Network.MAINNET;
|
|
19
112
|
const tokens = Tokens[network];
|
|
20
113
|
const holders = Holders[network];
|
|
@@ -121,4 +214,25 @@ describe('MaverickV1 E2E', () => {
|
|
|
121
214
|
);
|
|
122
215
|
});
|
|
123
216
|
});
|
|
217
|
+
|
|
218
|
+
describe('BASE', () => {
|
|
219
|
+
const network = Network.BASE;
|
|
220
|
+
|
|
221
|
+
const tokenASymbol: string = 'USDbC';
|
|
222
|
+
const tokenBSymbol: string = 'MAV';
|
|
223
|
+
|
|
224
|
+
const tokenAAmount: string = '1111100000';
|
|
225
|
+
const tokenBAmount: string = '1100000000000000000';
|
|
226
|
+
const nativeTokenAmount = '100000000000000000';
|
|
227
|
+
|
|
228
|
+
testForNetwork(
|
|
229
|
+
network,
|
|
230
|
+
dexKey,
|
|
231
|
+
tokenASymbol,
|
|
232
|
+
tokenBSymbol,
|
|
233
|
+
tokenAAmount,
|
|
234
|
+
tokenBAmount,
|
|
235
|
+
nativeTokenAmount,
|
|
236
|
+
);
|
|
237
|
+
});
|
|
124
238
|
});
|
|
@@ -78,6 +78,7 @@ export class MaverickV1
|
|
|
78
78
|
|
|
79
79
|
async setupEventPools(blockNumber: number) {
|
|
80
80
|
const pools = await this.fetchAllSubgraphPools();
|
|
81
|
+
|
|
81
82
|
await Promise.all(
|
|
82
83
|
pools.map(async (pool: any) => {
|
|
83
84
|
const eventPool = new MaverickV1EventPool(
|
|
@@ -181,8 +182,17 @@ export class MaverickV1
|
|
|
181
182
|
getCalldataGasCost(
|
|
182
183
|
poolPrices: PoolPrices<MaverickV1Data>,
|
|
183
184
|
): number | number[] {
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
const gasCost = CALLDATA_GAS_COST.DEX_NO_PAYLOAD;
|
|
186
|
+
|
|
187
|
+
const arr = new Array(poolPrices.prices.length);
|
|
188
|
+
poolPrices.prices.forEach((p, index) => {
|
|
189
|
+
if (p == 0n) {
|
|
190
|
+
arr[index] = 0;
|
|
191
|
+
} else {
|
|
192
|
+
arr[index] = gasCost;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
return arr;
|
|
186
196
|
}
|
|
187
197
|
|
|
188
198
|
// Returns pool prices for amounts.
|
|
@@ -53,6 +53,21 @@ export const PancakeswapV3Config: DexConfigMap<DexParams> = {
|
|
|
53
53
|
subgraphURL:
|
|
54
54
|
'https://api.studio.thegraph.com/query/45376/exchange-v3-arbitrum/version/latest',
|
|
55
55
|
},
|
|
56
|
+
[Network.BASE]: {
|
|
57
|
+
factory: '0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865',
|
|
58
|
+
deployer: '0x41ff9AA7e16B8B1a8a8dc4f0eFacd93D02d071c9',
|
|
59
|
+
quoter: '0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997',
|
|
60
|
+
router: '0x1b81D678ffb9C0263b24A97847620C99d213eB14',
|
|
61
|
+
supportedFees: PANCAKE_SUPPORTED_FEES,
|
|
62
|
+
stateMulticall: '0xeBF40A40CA3D4310Bf53048F48e860656e1D7C81',
|
|
63
|
+
uniswapMulticall: '0x091e99cb1C49331a94dD62755D168E941AbD0693',
|
|
64
|
+
chunksCount: 10,
|
|
65
|
+
initRetryFrequency: 30,
|
|
66
|
+
initHash:
|
|
67
|
+
'0x6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2',
|
|
68
|
+
subgraphURL:
|
|
69
|
+
'https://api.studio.thegraph.com/query/45376/exchange-v3-base/version/latest',
|
|
70
|
+
},
|
|
56
71
|
},
|
|
57
72
|
};
|
|
58
73
|
|
|
@@ -69,4 +84,8 @@ export const Adapters: Record<number, AdapterMappings> = {
|
|
|
69
84
|
[SwapSide.SELL]: [{ name: 'ArbitrumAdapter01', index: 3 }],
|
|
70
85
|
[SwapSide.BUY]: [{ name: 'ArbitrumBuyAdapter', index: 2 }],
|
|
71
86
|
},
|
|
87
|
+
[Network.BASE]: {
|
|
88
|
+
[SwapSide.SELL]: [{ name: 'BaseAdapter01', index: 1 }],
|
|
89
|
+
[SwapSide.BUY]: [{ name: 'BaseBuyAdapter', index: 1 }],
|
|
90
|
+
},
|
|
72
91
|
};
|
|
@@ -11,6 +11,99 @@ import { Network, ContractMethod, SwapSide } from '../../constants';
|
|
|
11
11
|
import { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
12
12
|
import { generateConfig } from '../../config';
|
|
13
13
|
|
|
14
|
+
function testForNetwork(
|
|
15
|
+
network: Network,
|
|
16
|
+
dexKey: string,
|
|
17
|
+
tokenASymbol: string,
|
|
18
|
+
tokenBSymbol: string,
|
|
19
|
+
tokenAAmount: string,
|
|
20
|
+
tokenBAmount: string,
|
|
21
|
+
nativeTokenAmount: string,
|
|
22
|
+
slippage?: number | undefined,
|
|
23
|
+
) {
|
|
24
|
+
const provider = new StaticJsonRpcProvider(
|
|
25
|
+
generateConfig(network).privateHttpProvider,
|
|
26
|
+
network,
|
|
27
|
+
);
|
|
28
|
+
const tokens = Tokens[network];
|
|
29
|
+
const holders = Holders[network];
|
|
30
|
+
const nativeTokenSymbol = NativeTokenSymbols[network];
|
|
31
|
+
|
|
32
|
+
const sideToContractMethods = new Map([
|
|
33
|
+
[
|
|
34
|
+
SwapSide.SELL,
|
|
35
|
+
[
|
|
36
|
+
ContractMethod.simpleSwap,
|
|
37
|
+
ContractMethod.multiSwap,
|
|
38
|
+
ContractMethod.megaSwap,
|
|
39
|
+
],
|
|
40
|
+
],
|
|
41
|
+
[SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
describe(`${network}`, () => {
|
|
45
|
+
sideToContractMethods.forEach((contractMethods, side) =>
|
|
46
|
+
describe(`${side}`, () => {
|
|
47
|
+
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
48
|
+
describe(`${contractMethod}`, () => {
|
|
49
|
+
it(`${nativeTokenSymbol} -> ${tokenASymbol}`, async () => {
|
|
50
|
+
await testE2E(
|
|
51
|
+
tokens[nativeTokenSymbol],
|
|
52
|
+
tokens[tokenASymbol],
|
|
53
|
+
holders[nativeTokenSymbol],
|
|
54
|
+
side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
|
|
55
|
+
side,
|
|
56
|
+
dexKey,
|
|
57
|
+
contractMethod,
|
|
58
|
+
network,
|
|
59
|
+
provider,
|
|
60
|
+
undefined,
|
|
61
|
+
undefined,
|
|
62
|
+
undefined,
|
|
63
|
+
slippage,
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
|
|
67
|
+
await testE2E(
|
|
68
|
+
tokens[tokenASymbol],
|
|
69
|
+
tokens[nativeTokenSymbol],
|
|
70
|
+
holders[tokenASymbol],
|
|
71
|
+
side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
|
|
72
|
+
side,
|
|
73
|
+
dexKey,
|
|
74
|
+
contractMethod,
|
|
75
|
+
network,
|
|
76
|
+
provider,
|
|
77
|
+
undefined,
|
|
78
|
+
undefined,
|
|
79
|
+
undefined,
|
|
80
|
+
slippage,
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
|
|
84
|
+
await testE2E(
|
|
85
|
+
tokens[tokenASymbol],
|
|
86
|
+
tokens[tokenBSymbol],
|
|
87
|
+
holders[tokenASymbol],
|
|
88
|
+
side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
|
|
89
|
+
side,
|
|
90
|
+
dexKey,
|
|
91
|
+
contractMethod,
|
|
92
|
+
network,
|
|
93
|
+
provider,
|
|
94
|
+
undefined,
|
|
95
|
+
undefined,
|
|
96
|
+
undefined,
|
|
97
|
+
slippage,
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
}),
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
14
107
|
describe('PancakeswapV3 E2E', () => {
|
|
15
108
|
const dexKey = 'PancakeswapV3';
|
|
16
109
|
|
|
@@ -307,4 +400,25 @@ describe('PancakeswapV3 E2E', () => {
|
|
|
307
400
|
}),
|
|
308
401
|
);
|
|
309
402
|
});
|
|
403
|
+
|
|
404
|
+
describe('PancakeswapV3 Base', () => {
|
|
405
|
+
const network = Network.BASE;
|
|
406
|
+
|
|
407
|
+
const tokenASymbol: string = 'USDbC';
|
|
408
|
+
const tokenBSymbol: string = 'DAI';
|
|
409
|
+
|
|
410
|
+
const tokenAAmount: string = '11111000000';
|
|
411
|
+
const tokenBAmount: string = '210000000000000000';
|
|
412
|
+
const nativeTokenAmount = '110000000000000000000';
|
|
413
|
+
|
|
414
|
+
testForNetwork(
|
|
415
|
+
network,
|
|
416
|
+
dexKey,
|
|
417
|
+
tokenASymbol,
|
|
418
|
+
tokenBSymbol,
|
|
419
|
+
tokenAAmount,
|
|
420
|
+
tokenBAmount,
|
|
421
|
+
nativeTokenAmount,
|
|
422
|
+
);
|
|
423
|
+
});
|
|
310
424
|
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import FactoryABI from '../../abi/pancakeswap-v3/PancakeswapV3Factory.abi.json';
|
|
4
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
5
|
+
import { StatefulEventSubscriber } from '../../stateful-event-subscriber';
|
|
6
|
+
import { Address, Log, Logger } from '../../types';
|
|
7
|
+
import { LogDescription } from 'ethers/lib/utils';
|
|
8
|
+
import { FactoryState } from '../uniswap-v3/types';
|
|
9
|
+
|
|
10
|
+
export type OnPoolCreatedCallback = ({
|
|
11
|
+
token0,
|
|
12
|
+
token1,
|
|
13
|
+
fee,
|
|
14
|
+
}: {
|
|
15
|
+
token0: string;
|
|
16
|
+
token1: string;
|
|
17
|
+
fee: bigint;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
* "Stateless" event subscriber in order to capture "PoolCreated" event on new pools created.
|
|
22
|
+
* State is present, but it's a placeholder to actually make the events reach handlers (if there's no previous state - `processBlockLogs` is not called)
|
|
23
|
+
*/
|
|
24
|
+
export class PancakeswapV3Factory extends StatefulEventSubscriber<FactoryState> {
|
|
25
|
+
handlers: {
|
|
26
|
+
[event: string]: (event: any) => Promise<void>;
|
|
27
|
+
} = {};
|
|
28
|
+
|
|
29
|
+
logDecoder: (log: Log) => any;
|
|
30
|
+
|
|
31
|
+
public readonly factoryIface = new Interface(FactoryABI);
|
|
32
|
+
|
|
33
|
+
constructor(
|
|
34
|
+
readonly dexHelper: IDexHelper,
|
|
35
|
+
parentName: string,
|
|
36
|
+
protected readonly factoryAddress: Address,
|
|
37
|
+
logger: Logger,
|
|
38
|
+
protected readonly onPoolCreated: OnPoolCreatedCallback,
|
|
39
|
+
mapKey: string = '',
|
|
40
|
+
) {
|
|
41
|
+
super(parentName, `${parentName} Factory`, dexHelper, logger, true, mapKey);
|
|
42
|
+
|
|
43
|
+
this.addressesSubscribed = [factoryAddress];
|
|
44
|
+
|
|
45
|
+
this.logDecoder = (log: Log) => this.factoryIface.parseLog(log);
|
|
46
|
+
|
|
47
|
+
this.handlers['PoolCreated'] = this.handleNewPool.bind(this);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
generateState(): FactoryState {
|
|
51
|
+
return {};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
protected async processLog(
|
|
55
|
+
_: DeepReadonly<FactoryState>,
|
|
56
|
+
log: Readonly<Log>,
|
|
57
|
+
): Promise<FactoryState> {
|
|
58
|
+
const event = this.logDecoder(log);
|
|
59
|
+
if (event.name in this.handlers) {
|
|
60
|
+
await this.handlers[event.name](event);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async handleNewPool(event: LogDescription) {
|
|
67
|
+
const token0 = event.args.token0.toLowerCase();
|
|
68
|
+
const token1 = event.args.token1.toLowerCase();
|
|
69
|
+
const fee = event.args.fee;
|
|
70
|
+
|
|
71
|
+
await this.onPoolCreated({ token0, token1, fee });
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -56,6 +56,10 @@ import {
|
|
|
56
56
|
DEFAULT_ID_ERC20,
|
|
57
57
|
DEFAULT_ID_ERC20_AS_STRING,
|
|
58
58
|
} from '../../lib/tokens/types';
|
|
59
|
+
import {
|
|
60
|
+
OnPoolCreatedCallback,
|
|
61
|
+
PancakeswapV3Factory,
|
|
62
|
+
} from './pancakeswap-v3-factory';
|
|
59
63
|
|
|
60
64
|
type PoolPairsInfo = {
|
|
61
65
|
token0: Address;
|
|
@@ -63,14 +67,15 @@ type PoolPairsInfo = {
|
|
|
63
67
|
fee: string;
|
|
64
68
|
};
|
|
65
69
|
|
|
66
|
-
const PANCAKESWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS =
|
|
67
|
-
const PANCAKESWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS =
|
|
70
|
+
const PANCAKESWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS = 3 * 24 * 60 * 60 * 1000; // 3 days
|
|
71
|
+
const PANCAKESWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS = 24 * 60 * 60 * 1000; // Once in a day
|
|
68
72
|
const PANCAKESWAPV3_QUOTE_GASLIMIT = 200_000;
|
|
69
73
|
|
|
70
74
|
export class PancakeswapV3
|
|
71
75
|
extends SimpleExchange
|
|
72
76
|
implements IDex<UniswapV3Data>
|
|
73
77
|
{
|
|
78
|
+
private readonly factory: PancakeswapV3Factory;
|
|
74
79
|
readonly isFeeOnTransferSupported: boolean = false;
|
|
75
80
|
readonly eventPools: Record<string, PancakeSwapV3EventPool | null> = {};
|
|
76
81
|
|
|
@@ -117,6 +122,14 @@ export class PancakeswapV3
|
|
|
117
122
|
|
|
118
123
|
this.notExistingPoolSetKey =
|
|
119
124
|
`${CACHE_PREFIX}_${network}_${dexKey}_not_existings_pool_set`.toLowerCase();
|
|
125
|
+
|
|
126
|
+
this.factory = new PancakeswapV3Factory(
|
|
127
|
+
dexHelper,
|
|
128
|
+
dexKey,
|
|
129
|
+
this.config.factory,
|
|
130
|
+
this.logger,
|
|
131
|
+
this.onPoolCreatedDeleteFromNonExistingSet,
|
|
132
|
+
);
|
|
120
133
|
}
|
|
121
134
|
|
|
122
135
|
get supportedFees() {
|
|
@@ -133,6 +146,9 @@ export class PancakeswapV3
|
|
|
133
146
|
}
|
|
134
147
|
|
|
135
148
|
async initializePricing(blockNumber: number) {
|
|
149
|
+
// Init listening to new pools creation
|
|
150
|
+
await this.factory.initialize(blockNumber);
|
|
151
|
+
|
|
136
152
|
if (!this.dexHelper.config.isSlave) {
|
|
137
153
|
const cleanExpiredNotExistingPoolsKeys = async () => {
|
|
138
154
|
const maxTimestamp =
|
|
@@ -151,6 +167,38 @@ export class PancakeswapV3
|
|
|
151
167
|
}
|
|
152
168
|
}
|
|
153
169
|
|
|
170
|
+
/*
|
|
171
|
+
* When a non existing pool is queried, it's blacklisted for an arbitrary long period in order to prevent issuing too many rpc calls
|
|
172
|
+
* Once the pool is created, it gets immediately flagged
|
|
173
|
+
*/
|
|
174
|
+
onPoolCreatedDeleteFromNonExistingSet: OnPoolCreatedCallback = async ({
|
|
175
|
+
token0,
|
|
176
|
+
token1,
|
|
177
|
+
fee,
|
|
178
|
+
}) => {
|
|
179
|
+
const logPrefix = '[PancakeV3.onPoolCreatedDeleteFromNonExistingSet]';
|
|
180
|
+
const [_token0, _token1] = this._sortTokens(token0, token1);
|
|
181
|
+
const poolKey = `${_token0}_${_token1}_${fee}`;
|
|
182
|
+
|
|
183
|
+
// consider doing it only from master pool for less calls to distant cache
|
|
184
|
+
|
|
185
|
+
// delete entry locally to let local instance discover the pool
|
|
186
|
+
delete this.eventPools[this.getPoolIdentifier(_token0, _token1, fee)];
|
|
187
|
+
|
|
188
|
+
try {
|
|
189
|
+
this.logger.info(
|
|
190
|
+
`${logPrefix} delete pool from not existing set: ${poolKey}`,
|
|
191
|
+
);
|
|
192
|
+
// delete pool record from set
|
|
193
|
+
await this.dexHelper.cache.zrem(this.notExistingPoolSetKey, [poolKey]);
|
|
194
|
+
} catch (error) {
|
|
195
|
+
this.logger.error(
|
|
196
|
+
`${logPrefix} failed to delete pool from set :${poolKey}`,
|
|
197
|
+
error,
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
154
202
|
async getPool(
|
|
155
203
|
srcAddress: Address,
|
|
156
204
|
destAddress: Address,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DexParams } from './types';
|
|
2
|
+
import { DexConfigMap } from '../../types';
|
|
3
|
+
import { Network, SwapSide } from '../../constants';
|
|
4
|
+
|
|
5
|
+
export const QuickPerpsConfig: DexConfigMap<DexParams> = {
|
|
6
|
+
QuickPerps: {
|
|
7
|
+
[Network.ZKEVM]: {
|
|
8
|
+
vault: '0x99B31498B0a1Dae01fc3433e3Cb60F095340935C',
|
|
9
|
+
reader: '0xf1CFB75854DE535475B88Bb6FBad317eea98c0F9',
|
|
10
|
+
priceFeed: '0x5b1F500134bdD7f4359F5B2adC65f839737290f4',
|
|
11
|
+
fastPriceFeed: '0x73903fEc691a80Ec47bc830bf3F0baD127A06e30',
|
|
12
|
+
fastPriceEvents: '0x08bC8ef0b71238055f9Ee6BBc90869D8d0DBdCCa',
|
|
13
|
+
usdq: '0x48aC594dd00c4aAcF40f83337fc6dA31F9F439A7',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const Adapters: {
|
|
19
|
+
[chainId: number]: {
|
|
20
|
+
[side: string]: { name: string; index: number }[] | null;
|
|
21
|
+
};
|
|
22
|
+
} = {
|
|
23
|
+
[Network.ZKEVM]: {
|
|
24
|
+
[SwapSide.SELL]: [
|
|
25
|
+
{
|
|
26
|
+
name: 'PolygonZkEvmAdapter01',
|
|
27
|
+
index: 2,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
};
|