@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
|
@@ -110,17 +110,22 @@ export abstract class ComposedEventSubscriber<
|
|
|
110
110
|
.call({}, blockNumber)
|
|
111
111
|
).returnData;
|
|
112
112
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
try {
|
|
114
|
+
const stateParts = await Promise.all(
|
|
115
|
+
this.parts.map((p, i) =>
|
|
116
|
+
p.generateState(
|
|
117
|
+
returnData.slice(...this.multiCallSlices[i]),
|
|
118
|
+
blockNumber,
|
|
119
|
+
),
|
|
118
120
|
),
|
|
119
|
-
)
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
)
|
|
121
|
+
);
|
|
122
|
+
return this.parts.reduce(
|
|
123
|
+
(acc, p, i) => p.lens.set(stateParts[i])(acc),
|
|
124
|
+
this.blankState,
|
|
125
|
+
);
|
|
126
|
+
} catch (e) {
|
|
127
|
+
this.logger.error(`Error generating state: ${e}`);
|
|
128
|
+
throw e;
|
|
129
|
+
}
|
|
125
130
|
}
|
|
126
131
|
}
|
package/src/config.ts
CHANGED
|
@@ -30,6 +30,7 @@ type BaseConfig = {
|
|
|
30
30
|
hashFlowAuthToken?: string;
|
|
31
31
|
hashFlowDisabledMMs: string[];
|
|
32
32
|
swaapV2AuthToken?: string;
|
|
33
|
+
forceRpcFallbackDexs: string[];
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
const baseConfigs: { [network: number]: BaseConfig } = {
|
|
@@ -49,9 +50,9 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
49
50
|
adapterAddresses: {
|
|
50
51
|
Adapter01: '0x9bE264469eF954c139Da4A45Cf76CbCC5e3A6A73',
|
|
51
52
|
Adapter02: '0xFC2Ba6E830a04C25e207B8214b26d8C713F6881F',
|
|
52
|
-
Adapter03: '
|
|
53
|
+
Adapter03: '0xfb2a3de6c7B8c77b520E3da16021f3D8A4E93168',
|
|
53
54
|
Adapter04: '0x30F6B9b6485ff0B67E881f5ac80D3F1c70A4B23d',
|
|
54
|
-
BuyAdapter: '
|
|
55
|
+
BuyAdapter: '0x613876f3dE2Ec633f8054fE7a561324c1a01d9cB',
|
|
55
56
|
},
|
|
56
57
|
uniswapV2ExchangeRouterAddress:
|
|
57
58
|
'0xF9234CB08edb93c0d4a4d4c70cC3FfD070e78e07',
|
|
@@ -115,6 +116,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
115
116
|
},
|
|
116
117
|
},
|
|
117
118
|
},
|
|
119
|
+
forceRpcFallbackDexs: [],
|
|
118
120
|
},
|
|
119
121
|
[Network.ROPSTEN]: {
|
|
120
122
|
network: Network.ROPSTEN,
|
|
@@ -142,6 +144,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
142
144
|
rfqConfigs: {},
|
|
143
145
|
rpcPollingMaxAllowedStateDelayInBlocks: 5,
|
|
144
146
|
rpcPollingBlocksBackToTriggerUpdate: 3,
|
|
147
|
+
forceRpcFallbackDexs: [],
|
|
145
148
|
},
|
|
146
149
|
[Network.BSC]: {
|
|
147
150
|
network: Network.BSC,
|
|
@@ -160,14 +163,15 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
160
163
|
process.env[`HASHFLOW_DISABLED_MMS_56`]?.split(',') || [],
|
|
161
164
|
adapterAddresses: {
|
|
162
165
|
BscAdapter01: '0xA31d9C571DF00e0F428B0bD24c34D103E8112222',
|
|
163
|
-
BscAdapter02: '
|
|
164
|
-
BscBuyAdapter: '
|
|
166
|
+
BscAdapter02: '0x02f2c31ebDE63E871AD0E74c01E21c819292a59D',
|
|
167
|
+
BscBuyAdapter: '0x301c2813e3ceb43A448a12f21551EDBcdC37F157',
|
|
165
168
|
},
|
|
166
169
|
rpcPollingMaxAllowedStateDelayInBlocks: 1,
|
|
167
170
|
rpcPollingBlocksBackToTriggerUpdate: 1,
|
|
168
171
|
uniswapV2ExchangeRouterAddress:
|
|
169
172
|
'0x53e693c6C7FFC4446c53B205Cf513105Bf140D7b',
|
|
170
173
|
rfqConfigs: {},
|
|
174
|
+
forceRpcFallbackDexs: [],
|
|
171
175
|
},
|
|
172
176
|
[Network.POLYGON]: {
|
|
173
177
|
network: Network.POLYGON,
|
|
@@ -187,8 +191,8 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
187
191
|
process.env[`HASHFLOW_DISABLED_MMS_137`]?.split(',') || [],
|
|
188
192
|
adapterAddresses: {
|
|
189
193
|
PolygonAdapter01: '0xE44769f42E1e9592f86B82f206407a8f7C84b4ed',
|
|
190
|
-
PolygonAdapter02: '
|
|
191
|
-
PolygonBuyAdapter: '
|
|
194
|
+
PolygonAdapter02: '0x654cD2Cf97D23059B3db4FaA38BB2b1F8351211d',
|
|
195
|
+
PolygonBuyAdapter: '0x4426a1F87Ee7e366542c58e29c02AFa2b5878b37',
|
|
192
196
|
},
|
|
193
197
|
uniswapV2ExchangeRouterAddress:
|
|
194
198
|
'0xf3938337F7294fEf84e9B2c6D548A93F956Cc281',
|
|
@@ -197,6 +201,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
197
201
|
rpcPollingMaxAllowedStateDelayInBlocks: 2,
|
|
198
202
|
rpcPollingBlocksBackToTriggerUpdate: 1,
|
|
199
203
|
swaapV2AuthToken: process.env.API_KEY_SWAAP_V2_AUTH_TOKEN || '',
|
|
204
|
+
forceRpcFallbackDexs: [],
|
|
200
205
|
},
|
|
201
206
|
[Network.AVALANCHE]: {
|
|
202
207
|
network: Network.AVALANCHE,
|
|
@@ -216,14 +221,15 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
216
221
|
process.env[`HASHFLOW_DISABLED_MMS_43114`]?.split(',') || [],
|
|
217
222
|
adapterAddresses: {
|
|
218
223
|
AvalancheAdapter01: '0x745Ec73855CeC7249E5fF4c9DD81cc65b4D297a9',
|
|
219
|
-
AvalancheAdapter02: '
|
|
220
|
-
AvalancheBuyAdapter: '
|
|
224
|
+
AvalancheAdapter02: '0xFb8773AA4Fd02e54bbd352061D8Be1911FAa210a',
|
|
225
|
+
AvalancheBuyAdapter: '0x434C1Cca4842629230067674Dd54E21a14D9FD5D',
|
|
221
226
|
},
|
|
222
227
|
uniswapV2ExchangeRouterAddress:
|
|
223
228
|
'0x53e693c6C7FFC4446c53B205Cf513105Bf140D7b',
|
|
224
229
|
rfqConfigs: {},
|
|
225
230
|
rpcPollingMaxAllowedStateDelayInBlocks: 2,
|
|
226
231
|
rpcPollingBlocksBackToTriggerUpdate: 1,
|
|
232
|
+
forceRpcFallbackDexs: [],
|
|
227
233
|
},
|
|
228
234
|
[Network.FANTOM]: {
|
|
229
235
|
network: Network.FANTOM,
|
|
@@ -251,6 +257,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
251
257
|
rfqConfigs: {},
|
|
252
258
|
rpcPollingMaxAllowedStateDelayInBlocks: 2,
|
|
253
259
|
rpcPollingBlocksBackToTriggerUpdate: 1,
|
|
260
|
+
forceRpcFallbackDexs: [],
|
|
254
261
|
},
|
|
255
262
|
[Network.ARBITRUM]: {
|
|
256
263
|
network: Network.ARBITRUM,
|
|
@@ -269,9 +276,9 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
269
276
|
hashFlowDisabledMMs:
|
|
270
277
|
process.env[`HASHFLOW_DISABLED_MMS_42161`]?.split(',') || [],
|
|
271
278
|
adapterAddresses: {
|
|
272
|
-
ArbitrumAdapter01: '
|
|
273
|
-
ArbitrumAdapter02: '
|
|
274
|
-
ArbitrumBuyAdapter: '
|
|
279
|
+
ArbitrumAdapter01: '0xD8134ACfc9c71Ab51452b5bA23A31354F4739032',
|
|
280
|
+
ArbitrumAdapter02: '0xD1F70c98a78d48A93F0B4dDa49057469dc5aC126',
|
|
281
|
+
ArbitrumBuyAdapter: '0x434C1Cca4842629230067674Dd54E21a14D9FD5D',
|
|
275
282
|
},
|
|
276
283
|
uniswapV2ExchangeRouterAddress:
|
|
277
284
|
'0xB41dD984730dAf82f5C41489E21ac79D5e3B61bC',
|
|
@@ -279,6 +286,7 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
279
286
|
rfqConfigs: {},
|
|
280
287
|
rpcPollingMaxAllowedStateDelayInBlocks: 4,
|
|
281
288
|
rpcPollingBlocksBackToTriggerUpdate: 3,
|
|
289
|
+
forceRpcFallbackDexs: [],
|
|
282
290
|
},
|
|
283
291
|
[Network.OPTIMISM]: {
|
|
284
292
|
network: Network.OPTIMISM,
|
|
@@ -298,8 +306,8 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
298
306
|
process.env[`HASHFLOW_DISABLED_MMS_10`]?.split(',') || [],
|
|
299
307
|
|
|
300
308
|
adapterAddresses: {
|
|
301
|
-
OptimismAdapter01: '
|
|
302
|
-
OptimismBuyAdapter: '
|
|
309
|
+
OptimismAdapter01: '0x3ad7f275E27AC579cA88e0b4765828242A9E8C49',
|
|
310
|
+
OptimismBuyAdapter: '0xfdDD975FE4c1af20c24A3Ad2b33e8609a62DDC73',
|
|
303
311
|
},
|
|
304
312
|
uniswapV2ExchangeRouterAddress:
|
|
305
313
|
'0xB41dD984730dAf82f5C41489E21ac79D5e3B61bC',
|
|
@@ -307,6 +315,63 @@ const baseConfigs: { [network: number]: BaseConfig } = {
|
|
|
307
315
|
rfqConfigs: {},
|
|
308
316
|
rpcPollingMaxAllowedStateDelayInBlocks: 5,
|
|
309
317
|
rpcPollingBlocksBackToTriggerUpdate: 3,
|
|
318
|
+
forceRpcFallbackDexs: [],
|
|
319
|
+
},
|
|
320
|
+
[Network.ZKEVM]: {
|
|
321
|
+
network: Network.ZKEVM,
|
|
322
|
+
networkName: 'Polygon zkEVM',
|
|
323
|
+
isTestnet: false,
|
|
324
|
+
nativeTokenName: 'Ether',
|
|
325
|
+
nativeTokenSymbol: 'ETH',
|
|
326
|
+
wrappedNativeTokenAddress: '0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9',
|
|
327
|
+
hasEIP1559: true,
|
|
328
|
+
augustusAddress: '0xB83B554730d29cE4Cb55BB42206c3E2c03E4A40A',
|
|
329
|
+
augustusRFQAddress: '0x7Ee1F7fa4C0b2eDB0Fdd5944c14A07167700486E',
|
|
330
|
+
tokenTransferProxyAddress: '0xc8a21fcd5a100c3ecc037c97e2f9c53a8d3a02a1',
|
|
331
|
+
multicallV2Address: '0x6cA478C852DfA8941FC819fDf248606eA04780B6',
|
|
332
|
+
privateHttpProvider: process.env.HTTP_PROVIDER_1101,
|
|
333
|
+
adapterAddresses: {
|
|
334
|
+
PolygonZkEvmAdapter01: '0xd63B7691dD98fa89A2ea5e1604700489c585aa7B',
|
|
335
|
+
PolygonZkEvmBuyAdapter: '0xe2137168CdA486a2555E16c597905854C84F9127',
|
|
336
|
+
},
|
|
337
|
+
|
|
338
|
+
rpcPollingMaxAllowedStateDelayInBlocks: 0,
|
|
339
|
+
rpcPollingBlocksBackToTriggerUpdate: 0,
|
|
340
|
+
hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN || '',
|
|
341
|
+
hashFlowDisabledMMs:
|
|
342
|
+
process.env[`HASHFLOW_DISABLED_MMS_10`]?.split(',') || [],
|
|
343
|
+
uniswapV3EventLoggingSampleRate: 0,
|
|
344
|
+
rfqConfigs: {},
|
|
345
|
+
forceRpcFallbackDexs: [],
|
|
346
|
+
// FIXME: Not set properly
|
|
347
|
+
uniswapV2ExchangeRouterAddress: '',
|
|
348
|
+
},
|
|
349
|
+
[Network.BASE]: {
|
|
350
|
+
network: Network.BASE,
|
|
351
|
+
networkName: 'Base',
|
|
352
|
+
isTestnet: false,
|
|
353
|
+
nativeTokenName: 'Ether',
|
|
354
|
+
nativeTokenSymbol: 'ETH',
|
|
355
|
+
wrappedNativeTokenAddress: '0x4200000000000000000000000000000000000006',
|
|
356
|
+
hasEIP1559: false,
|
|
357
|
+
augustusAddress: '0x59C7C832e96D2568bea6db468C1aAdcbbDa08A52',
|
|
358
|
+
augustusRFQAddress: '0xa003dFBA51C9e1e56C67ae445b852bdEd7aC5EEd',
|
|
359
|
+
tokenTransferProxyAddress: '0x93aAAe79a53759cD164340E4C8766E4Db5331cD7',
|
|
360
|
+
multicallV2Address: '0xeDF6D2a16e8081F777eB623EeB4411466556aF3d',
|
|
361
|
+
privateHttpProvider: process.env.HTTP_PROVIDER_8453,
|
|
362
|
+
hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN || '',
|
|
363
|
+
hashFlowDisabledMMs: [],
|
|
364
|
+
adapterAddresses: {
|
|
365
|
+
BaseAdapter01: '0x30F6B9b6485ff0B67E881f5ac80D3F1c70A4B23d',
|
|
366
|
+
BaseBuyAdapter: '0xB11bCA7B01b425afD0743A4D77B4f593883f94C0',
|
|
367
|
+
},
|
|
368
|
+
uniswapV2ExchangeRouterAddress:
|
|
369
|
+
'0x75d199EfB540e47D27D52c62Da3E7daC2B9e834F',
|
|
370
|
+
uniswapV3EventLoggingSampleRate: 0,
|
|
371
|
+
rfqConfigs: {},
|
|
372
|
+
rpcPollingMaxAllowedStateDelayInBlocks: 5,
|
|
373
|
+
rpcPollingBlocksBackToTriggerUpdate: 3,
|
|
374
|
+
forceRpcFallbackDexs: [],
|
|
310
375
|
},
|
|
311
376
|
};
|
|
312
377
|
|
|
@@ -350,6 +415,7 @@ export function generateConfig(network: number): Config {
|
|
|
350
415
|
hashFlowAuthToken: baseConfig.hashFlowAuthToken,
|
|
351
416
|
swaapV2AuthToken: baseConfig.swaapV2AuthToken,
|
|
352
417
|
hashFlowDisabledMMs: baseConfig.hashFlowDisabledMMs,
|
|
418
|
+
forceRpcFallbackDexs: baseConfig.forceRpcFallbackDexs,
|
|
353
419
|
};
|
|
354
420
|
}
|
|
355
421
|
|
|
@@ -359,7 +425,7 @@ export class ConfigHelper {
|
|
|
359
425
|
constructor(
|
|
360
426
|
public isSlave: boolean,
|
|
361
427
|
public data: Config,
|
|
362
|
-
|
|
428
|
+
masterCachePrefix: string,
|
|
363
429
|
) {
|
|
364
430
|
this.masterBlockNumberCacheKey =
|
|
365
431
|
`${masterCachePrefix}_${data.network}_bn`.toLowerCase();
|
package/src/constants.ts
CHANGED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Interface } from '@ethersproject/abi';
|
|
2
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import FactoryABI from '../../abi/algebra/AlgebraFactory-v1_1.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 './types';
|
|
9
|
+
|
|
10
|
+
export type OnPoolCreatedCallback = ({
|
|
11
|
+
token0,
|
|
12
|
+
token1,
|
|
13
|
+
}: {
|
|
14
|
+
token0: string;
|
|
15
|
+
token1: string;
|
|
16
|
+
}) => Promise<void>;
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
* "Stateless" event subscriber in order to capture "PoolCreated" event on new pools created.
|
|
20
|
+
* 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)
|
|
21
|
+
*/
|
|
22
|
+
export class AlgebraFactory extends StatefulEventSubscriber<FactoryState> {
|
|
23
|
+
handlers: {
|
|
24
|
+
[event: string]: (event: any) => Promise<void>;
|
|
25
|
+
} = {};
|
|
26
|
+
|
|
27
|
+
logDecoder: (log: Log) => any;
|
|
28
|
+
|
|
29
|
+
public readonly factoryIface = new Interface(FactoryABI);
|
|
30
|
+
|
|
31
|
+
constructor(
|
|
32
|
+
readonly dexHelper: IDexHelper,
|
|
33
|
+
parentName: string,
|
|
34
|
+
protected readonly factoryAddress: Address,
|
|
35
|
+
logger: Logger,
|
|
36
|
+
protected readonly onPoolCreated: OnPoolCreatedCallback,
|
|
37
|
+
mapKey: string = '',
|
|
38
|
+
) {
|
|
39
|
+
super(parentName, `${parentName} Factory`, dexHelper, logger, true, mapKey);
|
|
40
|
+
|
|
41
|
+
this.addressesSubscribed = [factoryAddress];
|
|
42
|
+
|
|
43
|
+
this.logDecoder = (log: Log) => this.factoryIface.parseLog(log);
|
|
44
|
+
|
|
45
|
+
this.handlers['Pool'] = this.handleNewPool.bind(this);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
generateState(): FactoryState {
|
|
49
|
+
return {};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
protected async processLog(
|
|
53
|
+
_: DeepReadonly<FactoryState>,
|
|
54
|
+
log: Readonly<Log>,
|
|
55
|
+
): Promise<FactoryState> {
|
|
56
|
+
const event = this.logDecoder(log);
|
|
57
|
+
if (event.name in this.handlers) {
|
|
58
|
+
await this.handlers[event.name](event);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async handleNewPool(event: LogDescription) {
|
|
65
|
+
const token0 = event.args.token0.toLowerCase();
|
|
66
|
+
const token1 = event.args.token1.toLowerCase();
|
|
67
|
+
|
|
68
|
+
await this.onPoolCreated({ token0, token1 });
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -14,21 +14,8 @@ import {
|
|
|
14
14
|
} from '../../../tests/utils';
|
|
15
15
|
import { Tokens } from '../../../tests/constants-e2e';
|
|
16
16
|
import { Address } from '@paraswap/core';
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
README
|
|
20
|
-
======
|
|
21
|
-
|
|
22
|
-
This test script adds tests for Algebra general integration
|
|
23
|
-
with the DEX interface. The test cases below are example tests.
|
|
24
|
-
It is recommended to add tests which cover Algebra specific
|
|
25
|
-
logic.
|
|
26
|
-
|
|
27
|
-
You can run this individual test script by running:
|
|
28
|
-
`npx jest src/dex/<dex-name>/<dex-name>-integration.test.ts`
|
|
29
|
-
|
|
30
|
-
(This comment should be removed from the final implementation)
|
|
31
|
-
*/
|
|
17
|
+
import { AlgebraEventPoolV1_1 } from './algebra-pool-v1_1';
|
|
18
|
+
import { DecodedStateMultiCallResultWithRelativeBitmapsV1_1 } from './types';
|
|
32
19
|
|
|
33
20
|
function getReaderCalldata(
|
|
34
21
|
exchangeAddress: string,
|
|
@@ -70,7 +57,7 @@ async function checkOnChainPricing(
|
|
|
70
57
|
tokenOut: Address,
|
|
71
58
|
amounts: bigint[],
|
|
72
59
|
) {
|
|
73
|
-
const exchangeAddress =
|
|
60
|
+
const exchangeAddress = algebra.config.quoter;
|
|
74
61
|
|
|
75
62
|
const readerIface = algebra.quoterIface;
|
|
76
63
|
|
|
@@ -155,6 +142,199 @@ async function testPricingOnNetwork(
|
|
|
155
142
|
);
|
|
156
143
|
}
|
|
157
144
|
|
|
145
|
+
describe('CamelotV3', function () {
|
|
146
|
+
const dexKey = 'CamelotV3';
|
|
147
|
+
let blockNumber: number;
|
|
148
|
+
let algebra: Algebra;
|
|
149
|
+
|
|
150
|
+
describe('Arbitrum', () => {
|
|
151
|
+
const network = Network.ARBITRUM;
|
|
152
|
+
const dexHelper = new DummyDexHelper(network);
|
|
153
|
+
|
|
154
|
+
const tokens = Tokens[network];
|
|
155
|
+
|
|
156
|
+
describe('GRAIL => USDCe', () => {
|
|
157
|
+
const srcTokenSymbol = 'GRAIL';
|
|
158
|
+
const destTokenSymbol = 'USDCe';
|
|
159
|
+
|
|
160
|
+
const amountsForSell = [
|
|
161
|
+
0n,
|
|
162
|
+
10n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
163
|
+
20n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
164
|
+
30n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
165
|
+
40n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
166
|
+
50n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
167
|
+
60n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
168
|
+
70n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
169
|
+
80n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
170
|
+
90n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
171
|
+
100n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
172
|
+
];
|
|
173
|
+
|
|
174
|
+
const amountsForBuy = [
|
|
175
|
+
0n,
|
|
176
|
+
1n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
177
|
+
2n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
178
|
+
3n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
179
|
+
4n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
180
|
+
5n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
181
|
+
6n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
182
|
+
7n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
183
|
+
8n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
184
|
+
9n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
185
|
+
10n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
186
|
+
];
|
|
187
|
+
|
|
188
|
+
beforeAll(async () => {
|
|
189
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
190
|
+
algebra = new Algebra(network, dexKey, dexHelper);
|
|
191
|
+
if (algebra.initializePricing) {
|
|
192
|
+
await algebra.initializePricing(blockNumber);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
197
|
+
await testPricingOnNetwork(
|
|
198
|
+
algebra,
|
|
199
|
+
network,
|
|
200
|
+
dexKey,
|
|
201
|
+
dexHelper,
|
|
202
|
+
blockNumber,
|
|
203
|
+
srcTokenSymbol,
|
|
204
|
+
destTokenSymbol,
|
|
205
|
+
SwapSide.SELL,
|
|
206
|
+
amountsForSell,
|
|
207
|
+
'quoteExactInputSingle',
|
|
208
|
+
);
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it('getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
212
|
+
await testPricingOnNetwork(
|
|
213
|
+
algebra,
|
|
214
|
+
network,
|
|
215
|
+
dexKey,
|
|
216
|
+
dexHelper,
|
|
217
|
+
blockNumber,
|
|
218
|
+
srcTokenSymbol,
|
|
219
|
+
destTokenSymbol,
|
|
220
|
+
SwapSide.BUY,
|
|
221
|
+
amountsForBuy,
|
|
222
|
+
'quoteExactOutputSingle',
|
|
223
|
+
);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('getTopPoolsForToken', async function () {
|
|
227
|
+
// We have to check without calling initializePricing, because
|
|
228
|
+
// pool-tracker is not calling that function
|
|
229
|
+
const newAlgebra = new Algebra(network, dexKey, dexHelper);
|
|
230
|
+
const poolLiquidity = await newAlgebra.getTopPoolsForToken(
|
|
231
|
+
tokens[srcTokenSymbol].address,
|
|
232
|
+
10,
|
|
233
|
+
);
|
|
234
|
+
console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
|
|
235
|
+
|
|
236
|
+
if (!newAlgebra.hasConstantPriceLargeAmounts) {
|
|
237
|
+
checkPoolsLiquidity(
|
|
238
|
+
poolLiquidity,
|
|
239
|
+
Tokens[network][srcTokenSymbol].address,
|
|
240
|
+
dexKey,
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
describe('USDCe => GRAIL', () => {
|
|
247
|
+
const srcTokenSymbol = 'USDCe';
|
|
248
|
+
const destTokenSymbol = 'GRAIL';
|
|
249
|
+
|
|
250
|
+
const amountsForSell = [
|
|
251
|
+
0n,
|
|
252
|
+
10n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
253
|
+
20n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
254
|
+
30n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
255
|
+
40n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
256
|
+
50n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
257
|
+
60n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
258
|
+
70n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
259
|
+
80n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
260
|
+
90n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
261
|
+
100n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
262
|
+
];
|
|
263
|
+
|
|
264
|
+
const amountsForBuy = [
|
|
265
|
+
0n,
|
|
266
|
+
1n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
267
|
+
2n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
268
|
+
3n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
269
|
+
4n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
270
|
+
5n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
271
|
+
6n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
272
|
+
7n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
273
|
+
8n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
274
|
+
9n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
275
|
+
10n * BI_POWS[tokens[destTokenSymbol].decimals],
|
|
276
|
+
];
|
|
277
|
+
|
|
278
|
+
beforeAll(async () => {
|
|
279
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
280
|
+
algebra = new Algebra(network, dexKey, dexHelper);
|
|
281
|
+
if (algebra.initializePricing) {
|
|
282
|
+
await algebra.initializePricing(blockNumber);
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
287
|
+
await testPricingOnNetwork(
|
|
288
|
+
algebra,
|
|
289
|
+
network,
|
|
290
|
+
dexKey,
|
|
291
|
+
dexHelper,
|
|
292
|
+
blockNumber,
|
|
293
|
+
srcTokenSymbol,
|
|
294
|
+
destTokenSymbol,
|
|
295
|
+
SwapSide.SELL,
|
|
296
|
+
amountsForSell,
|
|
297
|
+
'quoteExactInputSingle',
|
|
298
|
+
);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
it('getPoolIdentifiers and getPricesVolume BUY', async function () {
|
|
302
|
+
await testPricingOnNetwork(
|
|
303
|
+
algebra,
|
|
304
|
+
network,
|
|
305
|
+
dexKey,
|
|
306
|
+
dexHelper,
|
|
307
|
+
blockNumber,
|
|
308
|
+
srcTokenSymbol,
|
|
309
|
+
destTokenSymbol,
|
|
310
|
+
SwapSide.BUY,
|
|
311
|
+
amountsForBuy,
|
|
312
|
+
'quoteExactOutputSingle',
|
|
313
|
+
);
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it('getTopPoolsForToken', async function () {
|
|
317
|
+
// We have to check without calling initializePricing, because
|
|
318
|
+
// pool-tracker is not calling that function
|
|
319
|
+
const newAlgebra = new Algebra(network, dexKey, dexHelper);
|
|
320
|
+
const poolLiquidity = await newAlgebra.getTopPoolsForToken(
|
|
321
|
+
tokens[srcTokenSymbol].address,
|
|
322
|
+
10,
|
|
323
|
+
);
|
|
324
|
+
console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
|
|
325
|
+
|
|
326
|
+
if (!newAlgebra.hasConstantPriceLargeAmounts) {
|
|
327
|
+
checkPoolsLiquidity(
|
|
328
|
+
poolLiquidity,
|
|
329
|
+
Tokens[network][srcTokenSymbol].address,
|
|
330
|
+
dexKey,
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
|
|
158
338
|
describe('Algebra', function () {
|
|
159
339
|
const dexKey = 'QuickSwapV3';
|
|
160
340
|
let blockNumber: number;
|
|
@@ -254,5 +434,125 @@ describe('Algebra', function () {
|
|
|
254
434
|
);
|
|
255
435
|
}
|
|
256
436
|
});
|
|
437
|
+
|
|
438
|
+
it('both generate state result match', async function () {
|
|
439
|
+
const pool = (await algebra.getPool(
|
|
440
|
+
tokens[srcTokenSymbol].address,
|
|
441
|
+
tokens[destTokenSymbol].address,
|
|
442
|
+
blockNumber,
|
|
443
|
+
)) as AlgebraEventPoolV1_1;
|
|
444
|
+
|
|
445
|
+
const [balance0, balance1, stateMulticallFull] =
|
|
446
|
+
await pool.fetchPoolStateSingleStep(blockNumber);
|
|
447
|
+
|
|
448
|
+
const stateMulticall = {
|
|
449
|
+
pool: stateMulticallFull.pool.toLowerCase(),
|
|
450
|
+
globalState: {
|
|
451
|
+
price: stateMulticallFull.globalState.price,
|
|
452
|
+
tick: stateMulticallFull.globalState.tick,
|
|
453
|
+
fee: stateMulticallFull.globalState.fee,
|
|
454
|
+
communityFeeToken0: stateMulticallFull.globalState.communityFeeToken0,
|
|
455
|
+
communityFeeToken1: stateMulticallFull.globalState.communityFeeToken1,
|
|
456
|
+
},
|
|
457
|
+
liquidity: stateMulticallFull.liquidity,
|
|
458
|
+
tickSpacing: stateMulticallFull.tickSpacing,
|
|
459
|
+
maxLiquidityPerTick: stateMulticallFull.maxLiquidityPerTick,
|
|
460
|
+
tickBitmap: stateMulticallFull.tickBitmap.map(t => ({
|
|
461
|
+
index: t.index,
|
|
462
|
+
value: t.value,
|
|
463
|
+
})),
|
|
464
|
+
ticks: stateMulticallFull.ticks.map(t => ({
|
|
465
|
+
index: t.index,
|
|
466
|
+
value: {
|
|
467
|
+
liquidityNet: t.value.liquidityNet,
|
|
468
|
+
liquidityGross: t.value.liquidityGross,
|
|
469
|
+
secondsOutside: t.value.secondsOutside,
|
|
470
|
+
secondsPerLiquidityOutsideX128:
|
|
471
|
+
t.value.secondsPerLiquidityOutsideX128,
|
|
472
|
+
tickCumulativeOutside: t.value.tickCumulativeOutside,
|
|
473
|
+
initialized: t.value.initialized,
|
|
474
|
+
},
|
|
475
|
+
})),
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
const stateMulticallWithBalance = [balance0, balance1, stateMulticall];
|
|
479
|
+
const stateManually = await pool.fetchStateManually(blockNumber);
|
|
480
|
+
// @ts-ignore
|
|
481
|
+
delete stateManually[2]['blockTimestamp'];
|
|
482
|
+
stateManually[2].pool = stateManually[2].pool.toLowerCase();
|
|
483
|
+
|
|
484
|
+
expect(stateMulticallWithBalance).toStrictEqual(stateManually);
|
|
485
|
+
});
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
describe('ZKEVM', () => {
|
|
489
|
+
const network = Network.ZKEVM;
|
|
490
|
+
const dexHelper = new DummyDexHelper(network);
|
|
491
|
+
|
|
492
|
+
beforeAll(async () => {
|
|
493
|
+
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
494
|
+
algebra = new Algebra(network, dexKey, dexHelper);
|
|
495
|
+
if (algebra.initializePricing) {
|
|
496
|
+
await algebra.initializePricing(blockNumber);
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
it('WETH/DAI generate state is working for problematic pool', async function () {
|
|
501
|
+
const pool = (await algebra.getPool(
|
|
502
|
+
'0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9',
|
|
503
|
+
'0xc5015b9d9161dca7e18e32f6f25c4ad850731fd4',
|
|
504
|
+
blockNumber,
|
|
505
|
+
)) as AlgebraEventPoolV1_1;
|
|
506
|
+
|
|
507
|
+
const stateManually = await pool.fetchStateManually(blockNumber);
|
|
508
|
+
// We can not compare with usual way, because this pool can not be requested normally
|
|
509
|
+
expect(Array.isArray(stateManually)).toBeTruthy();
|
|
510
|
+
});
|
|
511
|
+
|
|
512
|
+
it('WETH/MATIC generate state is working for problematic pool', async function () {
|
|
513
|
+
const pool = (await algebra.getPool(
|
|
514
|
+
'0x4f9a0e7fd2bf6067db6994cf12e4495df938e6e9',
|
|
515
|
+
'0xa2036f0538221a77a3937f1379699f44945018d0',
|
|
516
|
+
blockNumber,
|
|
517
|
+
)) as AlgebraEventPoolV1_1;
|
|
518
|
+
|
|
519
|
+
const stateManually = await pool.fetchStateManually(blockNumber);
|
|
520
|
+
// We can not compare with usual way, because this pool can not be requested normally
|
|
521
|
+
expect(Array.isArray(stateManually)).toBeTruthy();
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
it('stMATIC/WETH generate state is working for problematic pool', async function () {
|
|
525
|
+
const pool = (await algebra.getPool(
|
|
526
|
+
'0x83b874c1e09d316059d929da402dcb1a98e92082',
|
|
527
|
+
'0x4f9a0e7fd2bf6067db6994cf12e4495df938e6e9',
|
|
528
|
+
blockNumber,
|
|
529
|
+
)) as AlgebraEventPoolV1_1;
|
|
530
|
+
|
|
531
|
+
const stateManually = await pool.fetchStateManually(blockNumber);
|
|
532
|
+
// We can not compare with usual way, because this pool can not be requested normally
|
|
533
|
+
expect(Array.isArray(stateManually)).toBeTruthy();
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
it('WETH/USDC generate state is working for problematic pool', async function () {
|
|
537
|
+
const pool = (await algebra.getPool(
|
|
538
|
+
'0x4f9a0e7fd2bf6067db6994cf12e4495df938e6e9',
|
|
539
|
+
'0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035',
|
|
540
|
+
blockNumber,
|
|
541
|
+
)) as AlgebraEventPoolV1_1;
|
|
542
|
+
|
|
543
|
+
const stateManually = await pool.fetchStateManually(blockNumber);
|
|
544
|
+
// We can not compare with usual way, because this pool can not be requested normally
|
|
545
|
+
expect(Array.isArray(stateManually)).toBeTruthy();
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
it('recognize pool does not exist error', async function () {
|
|
549
|
+
const pool = (await algebra.getPool(
|
|
550
|
+
'0x8aaebb46e1742f4623e6e1621f909f01846ca5e2',
|
|
551
|
+
'0xf9ed88937b2d82707d0eabd8c3d9aa4870b714d3',
|
|
552
|
+
blockNumber,
|
|
553
|
+
)) as AlgebraEventPoolV1_1;
|
|
554
|
+
|
|
555
|
+
expect(pool).toBeNull();
|
|
556
|
+
});
|
|
257
557
|
});
|
|
258
558
|
});
|