@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
|
@@ -1,83 +1,70 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { UnoptimizedRate, OptimalSwapExchange } from '../../types';
|
|
2
|
+
import { BalancerSwapV2 } from './types';
|
|
3
3
|
import { SwapSide } from '../../constants';
|
|
4
4
|
import { BalancerConfig } from './config';
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
const MAX_UINT256 =
|
|
7
|
+
'115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
|
8
|
+
|
|
9
|
+
const AllBalancerV2Forks = Object.keys(BalancerConfig);
|
|
6
10
|
|
|
7
11
|
export function balancerV2Merge(or: UnoptimizedRate): UnoptimizedRate {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
!
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
lastExchangeSwap.srcAmount = (
|
|
33
|
-
BigInt(lastExchangeSwap.srcAmount) + BigInt(currentSwap.srcAmount)
|
|
12
|
+
const fixSwap = (
|
|
13
|
+
rawSwap: OptimalSwapExchange<any>[],
|
|
14
|
+
side: SwapSide,
|
|
15
|
+
): OptimalSwapExchange<any>[] => {
|
|
16
|
+
const newBalancers: { [key: string]: OptimalSwapExchange<any> } = {};
|
|
17
|
+
let optimizedSwap = new Array<OptimalSwapExchange<any>>();
|
|
18
|
+
rawSwap.forEach((s: OptimalSwapExchange<any>) => {
|
|
19
|
+
const exchangeKey = s.exchange.toLowerCase();
|
|
20
|
+
if (AllBalancerV2Forks.some(d => d.toLowerCase() === exchangeKey)) {
|
|
21
|
+
if (!(exchangeKey in newBalancers)) {
|
|
22
|
+
newBalancers[exchangeKey] = {
|
|
23
|
+
exchange: s.exchange,
|
|
24
|
+
srcAmount: '0',
|
|
25
|
+
destAmount: '0',
|
|
26
|
+
percent: 0,
|
|
27
|
+
poolAddresses: [],
|
|
28
|
+
data: {
|
|
29
|
+
swaps: new Array<BalancerSwapV2>(),
|
|
30
|
+
gasUSD: '0',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
newBalancers[exchangeKey].srcAmount = (
|
|
35
|
+
BigInt(newBalancers[exchangeKey].srcAmount) + BigInt(s.srcAmount)
|
|
34
36
|
).toString();
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
BigInt(
|
|
38
|
+
newBalancers[exchangeKey].destAmount = (
|
|
39
|
+
BigInt(newBalancers[exchangeKey].destAmount) + BigInt(s.destAmount)
|
|
38
40
|
).toString();
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
parseFloat(
|
|
42
|
+
newBalancers[exchangeKey].percent += s.percent;
|
|
43
|
+
newBalancers[exchangeKey].data.exchangeProxy = s.data.exchangeProxy;
|
|
44
|
+
newBalancers[exchangeKey].data.gasUSD = (
|
|
45
|
+
parseFloat(newBalancers[exchangeKey].data.gasUSD) +
|
|
46
|
+
parseFloat(s.data.gasUSD)
|
|
44
47
|
).toFixed(6);
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
poolId:
|
|
48
|
-
amount:
|
|
49
|
-
side === SwapSide.SELL
|
|
50
|
-
? currentSwap.srcAmount
|
|
51
|
-
: currentSwap.destAmount,
|
|
52
|
-
tokenIn: currentSwap.data.tokenIn,
|
|
53
|
-
tokenOut: currentSwap.data.tokenOut,
|
|
49
|
+
newBalancers[exchangeKey].data.swaps.push({
|
|
50
|
+
poolId: s.data.poolId,
|
|
51
|
+
amount: side === SwapSide.SELL ? s.srcAmount : s.destAmount,
|
|
54
52
|
});
|
|
55
|
-
|
|
53
|
+
newBalancers[exchangeKey].poolAddresses!.push(s.poolAddresses![0]);
|
|
56
54
|
} else {
|
|
57
|
-
|
|
58
|
-
lastExchange.swapExchanges[0].data = {};
|
|
59
|
-
lastExchange.swapExchanges[0].data.gasUSD =
|
|
60
|
-
s.swapExchanges[0].data.gasUSD;
|
|
61
|
-
lastExchange.swapExchanges[0].data.swaps = [
|
|
62
|
-
{
|
|
63
|
-
poolId: s.swapExchanges[0].data.poolId,
|
|
64
|
-
amount:
|
|
65
|
-
side === SwapSide.SELL
|
|
66
|
-
? s.swapExchanges[0].srcAmount
|
|
67
|
-
: s.swapExchanges[0].destAmount,
|
|
68
|
-
tokenIn: s.swapExchanges[0].data.tokenIn,
|
|
69
|
-
tokenOut: s.swapExchanges[0].data.tokenOut,
|
|
70
|
-
},
|
|
71
|
-
];
|
|
72
|
-
optimizedRate.push(lastExchange);
|
|
55
|
+
optimizedSwap.push(s);
|
|
73
56
|
}
|
|
74
57
|
});
|
|
75
|
-
|
|
58
|
+
optimizedSwap = optimizedSwap.concat(Object.values(newBalancers));
|
|
59
|
+
return optimizedSwap;
|
|
76
60
|
};
|
|
77
61
|
|
|
78
62
|
or.bestRoute = or.bestRoute.map(r => ({
|
|
79
63
|
...r,
|
|
80
|
-
swaps:
|
|
64
|
+
swaps: r.swaps.map(s => ({
|
|
65
|
+
...s,
|
|
66
|
+
swapExchanges: fixSwap(s.swapExchanges, or.side),
|
|
67
|
+
})),
|
|
81
68
|
}));
|
|
82
69
|
return or;
|
|
83
70
|
}
|
|
@@ -82,8 +82,6 @@ export interface SubgraphPoolBase {
|
|
|
82
82
|
export type BalancerSwapV2 = {
|
|
83
83
|
poolId: string;
|
|
84
84
|
amount: string;
|
|
85
|
-
tokenIn: string;
|
|
86
|
-
tokenOut: string;
|
|
87
85
|
};
|
|
88
86
|
|
|
89
87
|
export type OptimizedBalancerV2Data = {
|
|
@@ -141,8 +139,6 @@ export type BalancerV2DirectParam = [
|
|
|
141
139
|
|
|
142
140
|
export type BalancerV2Data = {
|
|
143
141
|
poolId: string;
|
|
144
|
-
tokenIn: string;
|
|
145
|
-
tokenOut: string;
|
|
146
142
|
};
|
|
147
143
|
|
|
148
144
|
export type DexParams = {
|
|
@@ -939,44 +939,46 @@ export const CurveV1Config: DexConfigMap<DexParams> = {
|
|
|
939
939
|
isMetapool: false,
|
|
940
940
|
baseToken: '0x321162Cd933E2Be498Cd2267a90534A804051b11',
|
|
941
941
|
},
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
942
|
+
// Disabled pool
|
|
943
|
+
// main_gDAI_gUSDC_gUSDT: {
|
|
944
|
+
// underlying: [
|
|
945
|
+
// '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E', // DAI
|
|
946
|
+
// '0x04068DA6C83AFCFA0e13ba15A6696662335D5B75', // USDC
|
|
947
|
+
// '0x049d68029688eAbF473097a2fC38ef61633A3C7A', // fUSDT
|
|
948
|
+
// ],
|
|
949
|
+
// coins: [
|
|
950
|
+
// '0x07E6332dD090D287d3489245038daF987955DCFB', // gDAI
|
|
951
|
+
// '0xe578C856933D8e1082740bf7661e379Aa2A30b26', // gUSDC
|
|
952
|
+
// '0x940F41F0ec9ba1A34CF001cc03347ac092F5F6B5', // gUSDT
|
|
953
|
+
// ],
|
|
954
|
+
// address: '0x0fa949783947Bf6c1b171DB13AEACBB488845B3f',
|
|
955
|
+
// name: 'main_gDAI_gUSDC_gUSDT',
|
|
956
|
+
// type: 2,
|
|
957
|
+
// version: 3,
|
|
958
|
+
// isLending: true,
|
|
959
|
+
// isMetapool: false,
|
|
960
|
+
// baseToken: '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E',
|
|
961
|
+
// },
|
|
962
|
+
// Disabled pool
|
|
963
|
+
// main_iDAI_iUSDC_iFUSDT: {
|
|
964
|
+
// underlying: [
|
|
965
|
+
// '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E', // DAI
|
|
966
|
+
// '0x04068DA6C83AFCFA0e13ba15A6696662335D5B75', // USDC
|
|
967
|
+
// '0x049d68029688eAbF473097a2fC38ef61633A3C7A', // fUSDT
|
|
968
|
+
// ],
|
|
969
|
+
// coins: [
|
|
970
|
+
// '0x04c762a5dF2Fa02FE868F25359E0C259fB811CfE', // iDAI
|
|
971
|
+
// '0x328A7b4d538A2b3942653a9983fdA3C12c571141', // iUSDC
|
|
972
|
+
// '0x70faC71debfD67394D1278D98A29dea79DC6E57A', // iFUSDT
|
|
973
|
+
// ],
|
|
974
|
+
// address: '0x4FC8D635c3cB1d0aa123859e2B2587d0FF2707b1',
|
|
975
|
+
// name: 'main_iDAI_iUSDC_iFUSDT',
|
|
976
|
+
// type: 2,
|
|
977
|
+
// version: 3,
|
|
978
|
+
// isLending: true,
|
|
979
|
+
// isMetapool: false,
|
|
980
|
+
// baseToken: '0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E',
|
|
981
|
+
// },
|
|
980
982
|
},
|
|
981
983
|
},
|
|
982
984
|
[Network.AVALANCHE]: {
|
|
@@ -13,7 +13,10 @@ import { normalizeAddress } from '../../utils';
|
|
|
13
13
|
const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
14
14
|
CurveV1Factory: {
|
|
15
15
|
[Network.MAINNET]: {
|
|
16
|
-
|
|
16
|
+
factoryAddresses: [
|
|
17
|
+
'0xB9fC157394Af804a3578134A6585C0dc9cc990d4',
|
|
18
|
+
'0x4f8846ae9380b90d2e71d5e3d042dff3e7ebb40d',
|
|
19
|
+
],
|
|
17
20
|
stateUpdatePeriodMs: 5 * 1000,
|
|
18
21
|
disabledPools: new Set([
|
|
19
22
|
'0x28B0Cf1baFB707F2c6826d10caf6DD901a6540C5', // It is rug pool token
|
|
@@ -150,6 +153,11 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
150
153
|
name: ImplementationNames.FACTORY_PLAIN_4_OPTIMIZED,
|
|
151
154
|
address: '0xad4753d045d3aed5c1a6606dfb6a7d7ad67c1ad7',
|
|
152
155
|
},
|
|
156
|
+
'0x67fe41A94e779CcFa22cff02cc2957DC9C0e4286': {
|
|
157
|
+
name: ImplementationNames.FACTORY_PLAIN_2_CRV_EMA,
|
|
158
|
+
address: '0x67fe41A94e779CcFa22cff02cc2957DC9C0e4286',
|
|
159
|
+
liquidityApiSlug: '/factory-crvusd',
|
|
160
|
+
},
|
|
153
161
|
},
|
|
154
162
|
customPools: {
|
|
155
163
|
'0xDcEF968d416a41Cdac0ED8702fAC8128A64241A2': {
|
|
@@ -200,7 +208,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
200
208
|
},
|
|
201
209
|
},
|
|
202
210
|
[Network.POLYGON]: {
|
|
203
|
-
|
|
211
|
+
factoryAddresses: ['0x722272D36ef0Da72FF51c5A65Db7b870E2e8D4ee'],
|
|
204
212
|
stateUpdatePeriodMs: 2 * 1000,
|
|
205
213
|
disabledPools: new Set([
|
|
206
214
|
'0x666Dc3b4baBfd063FaF965BD020024AF0dC51B64',
|
|
@@ -306,7 +314,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
306
314
|
},
|
|
307
315
|
},
|
|
308
316
|
[Network.FANTOM]: {
|
|
309
|
-
|
|
317
|
+
factoryAddresses: ['0x686d67265703D1f124c45E33d47d794c566889Ba'],
|
|
310
318
|
stateUpdatePeriodMs: 2 * 1000,
|
|
311
319
|
disabledPools: new Set([]),
|
|
312
320
|
disabledImplementations: new Set([]),
|
|
@@ -421,7 +429,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
421
429
|
},
|
|
422
430
|
},
|
|
423
431
|
[Network.AVALANCHE]: {
|
|
424
|
-
|
|
432
|
+
factoryAddresses: ['0xb17b674D9c5CB2e441F8e196a2f048A81355d031'],
|
|
425
433
|
stateUpdatePeriodMs: 2 * 1000,
|
|
426
434
|
// FIX: This must be removed when we go for full CurveV1 event based support
|
|
427
435
|
disabledPools: new Set(['0x16a7da911a4dd1d83f3ff066fe28f3c792c50d90']),
|
|
@@ -519,7 +527,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
519
527
|
},
|
|
520
528
|
},
|
|
521
529
|
[Network.ARBITRUM]: {
|
|
522
|
-
|
|
530
|
+
factoryAddresses: ['0xb17b674D9c5CB2e441F8e196a2f048A81355d031'],
|
|
523
531
|
stateUpdatePeriodMs: 2 * 1000,
|
|
524
532
|
disabledPools: new Set([]),
|
|
525
533
|
disabledImplementations: new Set([]),
|
|
@@ -645,7 +653,7 @@ const CurveV1FactoryConfig: DexConfigMap<DexParams> = {
|
|
|
645
653
|
},
|
|
646
654
|
},
|
|
647
655
|
[Network.OPTIMISM]: {
|
|
648
|
-
|
|
656
|
+
factoryAddresses: ['0x2db0E83599a91b508Ac268a6197b8B14F5e72840'],
|
|
649
657
|
stateUpdatePeriodMs: 2 * 1000,
|
|
650
658
|
disabledPools: new Set([]),
|
|
651
659
|
disabledImplementations: new Set([]),
|
|
@@ -869,9 +877,9 @@ const configAddressesNormalizer = (
|
|
|
869
877
|
|
|
870
878
|
// Unite everything into top level config
|
|
871
879
|
const normalizedConfig: DexParams = {
|
|
872
|
-
|
|
873
|
-
? _config.
|
|
874
|
-
: _config.
|
|
880
|
+
factoryAddresses: _config.factoryAddresses
|
|
881
|
+
? _config.factoryAddresses.map(e => e.toLowerCase())
|
|
882
|
+
: _config.factoryAddresses,
|
|
875
883
|
stateUpdatePeriodMs: _config.stateUpdatePeriodMs,
|
|
876
884
|
factoryPoolImplementations,
|
|
877
885
|
customPools,
|
|
@@ -111,6 +111,25 @@ describe('CurveV1Factory E2E', () => {
|
|
|
111
111
|
tokenBAmount,
|
|
112
112
|
);
|
|
113
113
|
});
|
|
114
|
+
|
|
115
|
+
describe('Mainnet crvUSD', () => {
|
|
116
|
+
const network = Network.MAINNET;
|
|
117
|
+
|
|
118
|
+
const tokenASymbol: string = 'crvUSD';
|
|
119
|
+
const tokenBSymbol: string = 'USDT';
|
|
120
|
+
|
|
121
|
+
const tokenAAmount: string = '10000000000000000000';
|
|
122
|
+
const tokenBAmount: string = '10000000';
|
|
123
|
+
|
|
124
|
+
testForNetwork(
|
|
125
|
+
network,
|
|
126
|
+
dexKey,
|
|
127
|
+
tokenASymbol,
|
|
128
|
+
tokenBSymbol,
|
|
129
|
+
tokenAAmount,
|
|
130
|
+
tokenBAmount,
|
|
131
|
+
);
|
|
132
|
+
});
|
|
114
133
|
describe('Mainnet ng pool', () => {
|
|
115
134
|
const network = Network.MAINNET;
|
|
116
135
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
1
2
|
import dotenv from 'dotenv';
|
|
2
3
|
dotenv.config();
|
|
3
4
|
|
|
@@ -143,23 +144,6 @@ describe('CurveV1Factory', function () {
|
|
|
143
144
|
|
|
144
145
|
const tokens = Tokens[network];
|
|
145
146
|
|
|
146
|
-
const srcTokenSymbol = 'USDD';
|
|
147
|
-
const destTokenSymbol = 'USDT';
|
|
148
|
-
|
|
149
|
-
const amountsForSell = [
|
|
150
|
-
0n,
|
|
151
|
-
1n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
152
|
-
2n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
153
|
-
3n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
154
|
-
4n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
155
|
-
5n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
156
|
-
6n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
157
|
-
7n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
158
|
-
8n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
159
|
-
9n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
160
|
-
10n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
161
|
-
];
|
|
162
|
-
|
|
163
147
|
beforeAll(async () => {
|
|
164
148
|
blockNumber = await dexHelper.web3Provider.eth.getBlockNumber();
|
|
165
149
|
// @ts-expect-error for testing there is dummy blocknumber, but it is not
|
|
@@ -178,39 +162,175 @@ describe('CurveV1Factory', function () {
|
|
|
178
162
|
if (curveV1Factory) curveV1Factory.releaseResources();
|
|
179
163
|
});
|
|
180
164
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
srcTokenSymbol,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
165
|
+
describe(`USDD-USDT`, () => {
|
|
166
|
+
const srcTokenSymbol = 'USDD';
|
|
167
|
+
const destTokenSymbol = 'USDT';
|
|
168
|
+
const amountsForSell = [
|
|
169
|
+
0n,
|
|
170
|
+
1n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
171
|
+
2n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
172
|
+
3n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
173
|
+
4n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
174
|
+
5n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
175
|
+
6n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
176
|
+
7n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
177
|
+
8n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
178
|
+
9n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
179
|
+
10n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
180
|
+
];
|
|
181
|
+
|
|
182
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
183
|
+
await testPricingOnNetwork(
|
|
184
|
+
curveV1Factory,
|
|
185
|
+
network,
|
|
186
|
+
dexKey,
|
|
187
|
+
blockNumber,
|
|
188
|
+
srcTokenSymbol,
|
|
189
|
+
destTokenSymbol,
|
|
190
|
+
SwapSide.SELL,
|
|
191
|
+
amountsForSell,
|
|
192
|
+
);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('getTopPoolsForToken', async function () {
|
|
196
|
+
// We have to check without calling initializePricing, because
|
|
197
|
+
// pool-tracker is not calling that function
|
|
198
|
+
const newCurveV1Factory = new CurveV1Factory(
|
|
199
|
+
network,
|
|
200
|
+
dexKey,
|
|
201
|
+
dexHelper,
|
|
202
|
+
);
|
|
203
|
+
if (newCurveV1Factory.updatePoolState) {
|
|
204
|
+
await newCurveV1Factory.updatePoolState();
|
|
205
|
+
}
|
|
206
|
+
const poolLiquidity = await newCurveV1Factory.getTopPoolsForToken(
|
|
207
|
+
tokens[srcTokenSymbol].address,
|
|
208
|
+
10,
|
|
209
|
+
);
|
|
210
|
+
console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
|
|
211
|
+
|
|
212
|
+
if (!newCurveV1Factory.hasConstantPriceLargeAmounts) {
|
|
213
|
+
checkPoolsLiquidity(
|
|
214
|
+
poolLiquidity,
|
|
215
|
+
Tokens[network][srcTokenSymbol].address,
|
|
216
|
+
dexKey,
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
});
|
|
192
220
|
});
|
|
193
221
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
tokens[srcTokenSymbol].
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
222
|
+
describe(`crvUSD-GHO`, () => {
|
|
223
|
+
const srcTokenSymbol = 'crvUSD';
|
|
224
|
+
const destTokenSymbol = 'GHO';
|
|
225
|
+
const amountsForSell = [
|
|
226
|
+
0n,
|
|
227
|
+
1n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
228
|
+
2n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
229
|
+
3n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
230
|
+
4n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
231
|
+
5n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
232
|
+
6n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
233
|
+
7n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
234
|
+
8n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
235
|
+
9n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
236
|
+
10n * BI_POWS[tokens[srcTokenSymbol].decimals],
|
|
237
|
+
];
|
|
238
|
+
|
|
239
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
240
|
+
await testPricingOnNetwork(
|
|
241
|
+
curveV1Factory,
|
|
242
|
+
network,
|
|
243
|
+
dexKey,
|
|
244
|
+
blockNumber,
|
|
245
|
+
srcTokenSymbol,
|
|
246
|
+
destTokenSymbol,
|
|
247
|
+
SwapSide.SELL,
|
|
248
|
+
amountsForSell,
|
|
249
|
+
);
|
|
250
|
+
});
|
|
206
251
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
252
|
+
it('getTopPoolsForToken', async function () {
|
|
253
|
+
// We have to check without calling initializePricing, because
|
|
254
|
+
// pool-tracker is not calling that function
|
|
255
|
+
const newCurveV1Factory = new CurveV1Factory(
|
|
256
|
+
network,
|
|
211
257
|
dexKey,
|
|
258
|
+
dexHelper,
|
|
212
259
|
);
|
|
213
|
-
|
|
260
|
+
if (newCurveV1Factory.updatePoolState) {
|
|
261
|
+
await newCurveV1Factory.updatePoolState();
|
|
262
|
+
}
|
|
263
|
+
const poolLiquidity = await newCurveV1Factory.getTopPoolsForToken(
|
|
264
|
+
tokens[srcTokenSymbol].address,
|
|
265
|
+
10,
|
|
266
|
+
);
|
|
267
|
+
console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
|
|
268
|
+
|
|
269
|
+
if (!newCurveV1Factory.hasConstantPriceLargeAmounts) {
|
|
270
|
+
checkPoolsLiquidity(
|
|
271
|
+
poolLiquidity,
|
|
272
|
+
Tokens[network][srcTokenSymbol].address,
|
|
273
|
+
dexKey,
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
describe(`renBTC-wibBTC`, () => {
|
|
280
|
+
const srcTokenSymbol = 'renBTC';
|
|
281
|
+
const destTokenSymbol = 'wibBTC';
|
|
282
|
+
const amountsForSell = [
|
|
283
|
+
0n,
|
|
284
|
+
1n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
|
|
285
|
+
2n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
|
|
286
|
+
3n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
|
|
287
|
+
4n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
|
|
288
|
+
5n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
|
|
289
|
+
6n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
|
|
290
|
+
7n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
|
|
291
|
+
8n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
|
|
292
|
+
9n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
|
|
293
|
+
10n * BI_POWS[tokens[srcTokenSymbol].decimals - 1],
|
|
294
|
+
];
|
|
295
|
+
|
|
296
|
+
it('getPoolIdentifiers and getPricesVolume SELL', async function () {
|
|
297
|
+
await testPricingOnNetwork(
|
|
298
|
+
curveV1Factory,
|
|
299
|
+
network,
|
|
300
|
+
dexKey,
|
|
301
|
+
blockNumber,
|
|
302
|
+
srcTokenSymbol,
|
|
303
|
+
destTokenSymbol,
|
|
304
|
+
SwapSide.SELL,
|
|
305
|
+
amountsForSell,
|
|
306
|
+
);
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
it('getTopPoolsForToken', async function () {
|
|
310
|
+
// We have to check without calling initializePricing, because
|
|
311
|
+
// pool-tracker is not calling that function
|
|
312
|
+
const newCurveV1Factory = new CurveV1Factory(
|
|
313
|
+
network,
|
|
314
|
+
dexKey,
|
|
315
|
+
dexHelper,
|
|
316
|
+
);
|
|
317
|
+
if (newCurveV1Factory.updatePoolState) {
|
|
318
|
+
await newCurveV1Factory.updatePoolState();
|
|
319
|
+
}
|
|
320
|
+
const poolLiquidity = await newCurveV1Factory.getTopPoolsForToken(
|
|
321
|
+
tokens[srcTokenSymbol].address,
|
|
322
|
+
10,
|
|
323
|
+
);
|
|
324
|
+
console.log(`${srcTokenSymbol} Top Pools:`, poolLiquidity);
|
|
325
|
+
|
|
326
|
+
if (!newCurveV1Factory.hasConstantPriceLargeAmounts) {
|
|
327
|
+
checkPoolsLiquidity(
|
|
328
|
+
poolLiquidity,
|
|
329
|
+
Tokens[network][srcTokenSymbol].address,
|
|
330
|
+
dexKey,
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
});
|
|
214
334
|
});
|
|
215
335
|
});
|
|
216
336
|
describe('Polygon', () => {
|