@paraswap/dex-lib 2.45.0 → 3.0.0
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/.github/workflows/release-package.yml +32 -0
- package/.vscode/launch.json +72 -0
- package/.vscode/settings.json +2 -0
- package/.vscode/tasks.json +15 -0
- package/build/abi/AugustusV6.abi.json +1454 -0
- package/build/abi/augustus-v6/ABI.json +1075 -0
- package/build/config.d.ts +1 -0
- package/build/config.js +53 -1
- package/build/config.js.map +1 -1
- package/build/constants.d.ts +6 -0
- package/build/constants.js +9 -2
- package/build/constants.js.map +1 -1
- package/build/dex/aave-v1/aave-v1.d.ts +2 -1
- package/build/dex/aave-v1/aave-v1.js +22 -0
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/aave-v2/aave-v2.d.ts +2 -1
- package/build/dex/aave-v2/aave-v2.js +80 -0
- package/build/dex/aave-v2/aave-v2.js.map +1 -1
- package/build/dex/aave-v3/aave-v3.d.ts +3 -1
- package/build/dex/aave-v3/aave-v3.js +39 -0
- package/build/dex/aave-v3/aave-v3.js.map +1 -1
- package/build/dex/algebra/algebra.d.ts +2 -1
- package/build/dex/algebra/algebra.js +52 -1
- package/build/dex/algebra/algebra.js.map +1 -1
- package/build/dex/algebra/scripts/validate-state-v1-1.d.ts +1 -0
- package/build/dex/algebra/scripts/validate-state-v1-1.js +206 -0
- package/build/dex/algebra/scripts/validate-state-v1-1.js.map +1 -0
- package/build/dex/augustus-approvals-helper.d.ts +22 -0
- package/build/dex/augustus-approvals-helper.js +110 -0
- package/build/dex/augustus-approvals-helper.js.map +1 -0
- package/build/dex/augustus-approvals.d.ts +24 -0
- package/build/dex/augustus-approvals.js +106 -0
- package/build/dex/augustus-approvals.js.map +1 -0
- package/build/dex/bProtocol/bProtocol.d.ts +15 -0
- package/build/dex/bProtocol/bProtocol.js +51 -0
- package/build/dex/bProtocol/bProtocol.js.map +1 -0
- package/build/dex/bProtocol/types.d.ts +11 -0
- package/build/dex/bProtocol/types.js +8 -0
- package/build/dex/bProtocol/types.js.map +1 -0
- package/build/dex/bProtocol.d.ts +2 -1
- package/build/dex/bProtocol.js +15 -0
- package/build/dex/bProtocol.js.map +1 -1
- package/build/dex/balancer-v1/balancer-v1.d.ts +5 -3
- package/build/dex/balancer-v1/balancer-v1.js +72 -3
- package/build/dex/balancer-v1/balancer-v1.js.map +1 -1
- package/build/dex/balancer-v2/balancer-v2.d.ts +16 -4
- package/build/dex/balancer-v2/balancer-v2.js +154 -7
- package/build/dex/balancer-v2/balancer-v2.js.map +1 -1
- package/build/dex/balancer-v2/constants.d.ts +4 -0
- package/build/dex/balancer-v2/constants.js +6 -1
- package/build/dex/balancer-v2/constants.js.map +1 -1
- package/build/dex/balancer-v2/types.d.ts +11 -0
- package/build/dex/bancor/bancor.d.ts +15 -0
- package/build/dex/bancor/bancor.js +69 -0
- package/build/dex/bancor/bancor.js.map +1 -0
- package/build/dex/bancor/config.d.ts +6 -0
- package/build/dex/bancor/config.js +11 -0
- package/build/dex/bancor/config.js.map +1 -0
- package/build/dex/bancor/types.d.ts +16 -0
- package/build/dex/bancor/types.js +8 -0
- package/build/dex/bancor/types.js.map +1 -0
- package/build/dex/bancor.d.ts +2 -1
- package/build/dex/bancor.js +19 -0
- package/build/dex/bancor.js.map +1 -1
- package/build/dex/camelot/camelot.d.ts +3 -1
- package/build/dex/camelot/camelot.js +31 -0
- package/build/dex/camelot/camelot.js.map +1 -1
- package/build/dex/camelot/scripts/validate-state.d.ts +1 -0
- package/build/dex/camelot/scripts/validate-state.js +84 -0
- package/build/dex/camelot/scripts/validate-state.js.map +1 -0
- package/build/dex/compound/compound.d.ts +15 -0
- package/build/dex/compound/compound.js +54 -0
- package/build/dex/compound/compound.js.map +1 -0
- package/build/dex/compound/types.d.ts +8 -0
- package/build/dex/compound/types.js +9 -0
- package/build/dex/compound/types.js.map +1 -0
- package/build/dex/compound.d.ts +2 -1
- package/build/dex/compound.js +12 -0
- package/build/dex/compound.js.map +1 -1
- package/build/dex/curve-v1/constants.d.ts +1 -0
- package/build/dex/curve-v1/constants.js +2 -1
- package/build/dex/curve-v1/constants.js.map +1 -1
- package/build/dex/curve-v1/curve-v1.d.ts +10 -3
- package/build/dex/curve-v1/curve-v1.js +57 -7
- package/build/dex/curve-v1/curve-v1.js.map +1 -1
- package/build/dex/curve-v1/packer.d.ts +2 -0
- package/build/dex/curve-v1/packer.js +18 -0
- package/build/dex/curve-v1/packer.js.map +1 -0
- package/build/dex/curve-v1/types.d.ts +16 -0
- package/build/dex/curve-v1-factory/curve-v1-factory.d.ts +2 -1
- package/build/dex/curve-v1-factory/curve-v1-factory.js +19 -7
- package/build/dex/curve-v1-factory/curve-v1-factory.js.map +1 -1
- package/build/dex/curve-v1-factory/state-polling-pools/polling-manager.js +3 -1
- package/build/dex/curve-v1-factory/state-polling-pools/polling-manager.js.map +1 -1
- package/build/dex/curve-v2/constants.d.ts +1 -0
- package/build/dex/curve-v2/constants.js +5 -0
- package/build/dex/curve-v2/constants.js.map +1 -0
- package/build/dex/curve-v2/curve-v2.d.ts +61 -0
- package/build/dex/curve-v2/curve-v2.js +245 -0
- package/build/dex/curve-v2/curve-v2.js.map +1 -0
- package/build/dex/curve-v2/types.d.ts +24 -0
- package/build/dex/curve-v2/types.js +10 -0
- package/build/dex/curve-v2/types.js.map +1 -0
- package/build/dex/dexalot/dexalot.d.ts +2 -1
- package/build/dex/dexalot/dexalot.js +25 -0
- package/build/dex/dexalot/dexalot.js.map +1 -1
- package/build/dex/dodo-v1/config.d.ts +7 -0
- package/build/dex/dodo-v1/config.js +16 -0
- package/build/dex/dodo-v1/config.js.map +1 -0
- package/build/dex/dodo-v1/dodo-v1.d.ts +16 -0
- package/build/dex/dodo-v1/dodo-v1.js +71 -0
- package/build/dex/dodo-v1/dodo-v1.js.map +1 -0
- package/build/dex/dodo-v1/types.d.ts +22 -0
- package/build/dex/dodo-v1/types.js +8 -0
- package/build/dex/dodo-v1/types.js.map +1 -0
- package/build/dex/dodo-v1.d.ts +2 -1
- package/build/dex/dodo-v1.js +20 -0
- package/build/dex/dodo-v1.js.map +1 -1
- package/build/dex/dodo-v2.d.ts +2 -1
- package/build/dex/dodo-v2.js +54 -0
- package/build/dex/dodo-v2.js.map +1 -1
- package/build/dex/generic-rfq/e2e-test-config.js +50 -6
- package/build/dex/generic-rfq/e2e-test-config.js.map +1 -1
- package/build/dex/generic-rfq/fetch-mm-api.js +2 -2
- package/build/dex/generic-rfq/fetch-mm-api.js.map +1 -1
- package/build/dex/generic-rfq/generic-rfq.d.ts +10 -3
- package/build/dex/generic-rfq/generic-rfq.js +68 -10
- package/build/dex/generic-rfq/generic-rfq.js.map +1 -1
- package/build/dex/generic-rfq/rate-fetcher.js +2 -2
- package/build/dex/generic-rfq/rate-fetcher.js.map +1 -1
- package/build/dex/generic-rfq/test-v6/constants.d.ts +1 -0
- package/build/dex/generic-rfq/test-v6/constants.js +5 -0
- package/build/dex/generic-rfq/test-v6/constants.js.map +1 -0
- package/build/dex/generic-rfq/test-v6/get-config.d.ts +1 -0
- package/build/dex/generic-rfq/test-v6/get-config.js +63 -0
- package/build/dex/generic-rfq/test-v6/get-config.js.map +1 -0
- package/build/dex/generic-rfq/test-v6/types.d.ts +14 -0
- package/build/dex/generic-rfq/test-v6/types.js +3 -0
- package/build/dex/generic-rfq/test-v6/types.js.map +1 -0
- package/build/dex/generic-rfq/tokens.json +570 -0
- package/build/dex/generic-rfq/types.d.ts +14 -2
- package/build/dex/generic-rfq/types.js.map +1 -1
- package/build/dex/generic-rfq/utils.d.ts +1 -1
- package/build/dex/generic-rfq/utils.js +4 -7
- package/build/dex/generic-rfq/utils.js.map +1 -1
- package/build/dex/generic-rfq/validators.d.ts +1 -0
- package/build/dex/generic-rfq/validators.js +9 -12
- package/build/dex/generic-rfq/validators.js.map +1 -1
- package/build/dex/gmx/gmx.d.ts +2 -1
- package/build/dex/gmx/gmx.js +15 -0
- package/build/dex/gmx/gmx.js.map +1 -1
- package/build/dex/hashflow/hashflow.d.ts +2 -1
- package/build/dex/hashflow/hashflow.js +31 -1
- package/build/dex/hashflow/hashflow.js.map +1 -1
- package/build/dex/idex.d.ts +7 -1
- package/build/dex/index.d.ts +2 -0
- package/build/dex/index.js +23 -10
- package/build/dex/index.js.map +1 -1
- package/build/dex/jarvis-v6/jarvis-v6.d.ts +2 -1
- package/build/dex/jarvis-v6/jarvis-v6.js +24 -0
- package/build/dex/jarvis-v6/jarvis-v6.js.map +1 -1
- package/build/dex/jarvis.d.ts +2 -1
- package/build/dex/jarvis.js +50 -0
- package/build/dex/jarvis.js.map +1 -1
- package/build/dex/kyberdmm/kyberdmm.d.ts +2 -1
- package/build/dex/kyberdmm/kyberdmm.js +20 -0
- package/build/dex/kyberdmm/kyberdmm.js.map +1 -1
- package/build/dex/lido/config.d.ts +1 -0
- package/build/dex/lido/config.js +8 -0
- package/build/dex/lido/config.js.map +1 -0
- package/build/dex/lido/lido.d.ts +16 -0
- package/build/dex/lido/lido.js +46 -0
- package/build/dex/lido/lido.js.map +1 -0
- package/build/dex/lido/types.d.ts +4 -0
- package/build/dex/lido/types.js +8 -0
- package/build/dex/lido/types.js.map +1 -0
- package/build/dex/lido.d.ts +2 -1
- package/build/dex/lido.js +9 -0
- package/build/dex/lido.js.map +1 -1
- package/build/dex/maker-psm/maker-psm.d.ts +2 -1
- package/build/dex/maker-psm/maker-psm.js +27 -0
- package/build/dex/maker-psm/maker-psm.js.map +1 -1
- package/build/dex/maverick-v1/maverick-v1.d.ts +3 -1
- package/build/dex/maverick-v1/maverick-v1.js +35 -0
- package/build/dex/maverick-v1/maverick-v1.js.map +1 -1
- package/build/dex/nerve/nerve.d.ts +2 -1
- package/build/dex/nerve/nerve.js +19 -0
- package/build/dex/nerve/nerve.js.map +1 -1
- package/build/dex/onebit/onebit.d.ts +16 -0
- package/build/dex/onebit/onebit.js +56 -0
- package/build/dex/onebit/onebit.js.map +1 -0
- package/build/dex/onebit/types.d.ts +14 -0
- package/build/dex/onebit/types.js +8 -0
- package/build/dex/onebit/types.js.map +1 -0
- package/build/dex/onebit.d.ts +2 -1
- package/build/dex/onebit.js +17 -0
- package/build/dex/onebit.js.map +1 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3.d.ts +2 -1
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js +30 -0
- package/build/dex/pancakeswap-v3/pancakeswap-v3.js.map +1 -1
- package/build/dex/paraswap-limit-orders/paraswap-limit-orders.d.ts +2 -1
- package/build/dex/paraswap-limit-orders/paraswap-limit-orders.js +15 -0
- package/build/dex/paraswap-limit-orders/paraswap-limit-orders.js.map +1 -1
- package/build/dex/paraswap-limit-orders/types.d.ts +1 -0
- package/build/dex/platypus/platypus.d.ts +2 -1
- package/build/dex/platypus/platypus.js +31 -0
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/polygon-migrator/polygon-migrator.d.ts +2 -1
- package/build/dex/polygon-migrator/polygon-migrator.js +11 -0
- package/build/dex/polygon-migrator/polygon-migrator.js.map +1 -1
- package/build/dex/quick-perps/quick-perps.d.ts +2 -1
- package/build/dex/quick-perps/quick-perps.js +15 -0
- package/build/dex/quick-perps/quick-perps.js.map +1 -1
- package/build/dex/simple-exchange.d.ts +2 -5
- package/build/dex/simple-exchange.js +4 -32
- package/build/dex/simple-exchange.js.map +1 -1
- package/build/dex/smoothy/smoothy.d.ts +16 -0
- package/build/dex/smoothy/smoothy.js +58 -0
- package/build/dex/smoothy/smoothy.js.map +1 -0
- package/build/dex/smoothy/types.d.ts +15 -0
- package/build/dex/smoothy/types.js +8 -0
- package/build/dex/smoothy/types.js.map +1 -0
- package/build/dex/smoothy.d.ts +2 -1
- package/build/dex/smoothy.js +13 -0
- package/build/dex/smoothy.js.map +1 -1
- package/build/dex/solidly/solidly.d.ts +2 -1
- package/build/dex/solidly/solidly.js +30 -0
- package/build/dex/solidly/solidly.js.map +1 -1
- package/build/dex/solidly-v3/contract-math/Tick.js.map +1 -1
- package/build/dex/solidly-v3/contract-math/uniswap-v3-math.js +4 -4
- package/build/dex/solidly-v3/contract-math/uniswap-v3-math.js.map +1 -1
- package/build/dex/solidly-v3/solidly-v3.d.ts +2 -3
- package/build/dex/solidly-v3/solidly-v3.js +25 -37
- package/build/dex/solidly-v3/solidly-v3.js.map +1 -1
- package/build/dex/stable-pool/stable-pool.d.ts +16 -0
- package/build/dex/stable-pool/stable-pool.js +78 -0
- package/build/dex/stable-pool/stable-pool.js.map +1 -0
- package/build/dex/stable-pool/types.d.ts +17 -0
- package/build/dex/stable-pool/types.js +8 -0
- package/build/dex/stable-pool/types.js.map +1 -0
- package/build/dex/stable-pool.d.ts +2 -1
- package/build/dex/stable-pool.js +19 -0
- package/build/dex/stable-pool.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
- package/build/dex/swaap-v1/swaap-v1.js +10 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/swaap-v2/rate-fetcher.d.ts +1 -1
- package/build/dex/swaap-v2/rate-fetcher.js +4 -4
- package/build/dex/swaap-v2/rate-fetcher.js.map +1 -1
- package/build/dex/swaap-v2/swaap-v2.d.ts +3 -1
- package/build/dex/swaap-v2/swaap-v2.js +17 -1
- package/build/dex/swaap-v2/swaap-v2.js.map +1 -1
- package/build/dex/swaap-v2/validators.d.ts +1 -0
- package/build/dex/swaap-v2/validators.js +9 -12
- package/build/dex/swaap-v2/validators.js.map +1 -1
- package/build/dex/swell/swell.d.ts +2 -1
- package/build/dex/swell/swell.js +12 -2
- package/build/dex/swell/swell.js.map +1 -1
- package/build/dex/synthetix/synthetix.d.ts +2 -1
- package/build/dex/synthetix/synthetix.js +24 -0
- package/build/dex/synthetix/synthetix.js.map +1 -1
- package/build/dex/trader-joe-v2.1/config.d.ts +4 -0
- package/build/dex/trader-joe-v2.1/config.js +11 -0
- package/build/dex/trader-joe-v2.1/config.js.map +1 -0
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1.d.ts +19 -0
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1.js +98 -0
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1.js.map +1 -0
- package/build/dex/trader-joe-v2.1/types.d.ts +31 -0
- package/build/dex/trader-joe-v2.1/types.js +9 -0
- package/build/dex/trader-joe-v2.1/types.js.map +1 -0
- package/build/dex/trader-joe-v2.1.d.ts +2 -1
- package/build/dex/trader-joe-v2.1.js +28 -0
- package/build/dex/trader-joe-v2.1.js.map +1 -1
- package/build/dex/uniswap-v2/config.js +36 -0
- package/build/dex/uniswap-v2/config.js.map +1 -1
- package/build/dex/uniswap-v2/constants.js +7 -6
- package/build/dex/uniswap-v2/constants.js.map +1 -1
- package/build/dex/uniswap-v2/dfyn.d.ts +4 -2
- package/build/dex/uniswap-v2/dfyn.js +13 -0
- package/build/dex/uniswap-v2/dfyn.js.map +1 -1
- package/build/dex/uniswap-v2/types.d.ts +19 -0
- package/build/dex/uniswap-v2/types.js +6 -1
- package/build/dex/uniswap-v2/types.js.map +1 -1
- package/build/dex/uniswap-v2/uniswap-v2-optimizer.d.ts +2 -0
- package/build/dex/uniswap-v2/uniswap-v2-optimizer.js +75 -0
- package/build/dex/uniswap-v2/uniswap-v2-optimizer.js.map +1 -0
- package/build/dex/uniswap-v2/uniswap-v2.d.ts +15 -4
- package/build/dex/uniswap-v2/uniswap-v2.js +124 -1
- package/build/dex/uniswap-v2/uniswap-v2.js.map +1 -1
- package/build/dex/uniswap-v3/constants.d.ts +4 -0
- package/build/dex/uniswap-v3/constants.js +6 -1
- package/build/dex/uniswap-v3/constants.js.map +1 -1
- package/build/dex/uniswap-v3/types.d.ts +15 -0
- package/build/dex/uniswap-v3/types.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3.d.ts +13 -4
- package/build/dex/uniswap-v3/uniswap-v3.js +130 -27
- package/build/dex/uniswap-v3/uniswap-v3.js.map +1 -1
- package/build/dex/uniswap-v3.d.ts +2 -1
- package/build/dex/uniswap-v3.js +28 -0
- package/build/dex/uniswap-v3.js.map +1 -1
- package/build/dex/weth/weth.d.ts +3 -1
- package/build/dex/weth/weth.js +17 -2
- package/build/dex/weth/weth.js.map +1 -1
- package/build/dex/wombat/wombat.d.ts +3 -2
- package/build/dex/wombat/wombat.js +20 -0
- package/build/dex/wombat/wombat.js.map +1 -1
- package/build/dex/woo-fi-v2/woo-fi-v2.d.ts +2 -1
- package/build/dex/woo-fi-v2/woo-fi-v2.js +27 -0
- package/build/dex/woo-fi-v2/woo-fi-v2.js.map +1 -1
- package/build/dex/wsteth/wsteth.d.ts +2 -1
- package/build/dex/wsteth/wsteth.js +9 -0
- package/build/dex/wsteth/wsteth.js.map +1 -1
- package/build/dex/zerox/config.d.ts +2 -0
- package/build/dex/zerox/config.js +33 -0
- package/build/dex/zerox/config.js.map +1 -0
- package/build/dex/zerox/index.d.ts +3 -25
- package/build/dex/zerox/index.js +49 -42
- package/build/dex/zerox/index.js.map +1 -1
- package/build/dex/zerox/types.d.ts +29 -0
- package/build/dex/zerox/types.js +8 -1
- package/build/dex/zerox/types.js.map +1 -1
- package/build/dex-helper/dummy-dex-helper.d.ts +2 -0
- package/build/dex-helper/dummy-dex-helper.js +20 -1
- package/build/dex-helper/dummy-dex-helper.js.map +1 -1
- package/build/dex-helper/icache.d.ts +2 -0
- package/build/dex-helper/idex-helper.d.ts +2 -0
- package/build/executor/Executor01BytecodeBuilder.d.ts +53 -0
- package/build/executor/Executor01BytecodeBuilder.js +253 -0
- package/build/executor/Executor01BytecodeBuilder.js.map +1 -0
- package/build/executor/Executor02BytecodeBuilder.d.ts +77 -0
- package/build/executor/Executor02BytecodeBuilder.js +717 -0
- package/build/executor/Executor02BytecodeBuilder.js.map +1 -0
- package/build/executor/Executor03BytecodeBuilder.d.ts +41 -0
- package/build/executor/Executor03BytecodeBuilder.js +226 -0
- package/build/executor/Executor03BytecodeBuilder.js.map +1 -0
- package/build/executor/ExecutorBytecodeBuilder.d.ts +42 -0
- package/build/executor/ExecutorBytecodeBuilder.js +150 -0
- package/build/executor/ExecutorBytecodeBuilder.js.map +1 -0
- package/build/executor/ExecutorDetector.d.ts +16 -0
- package/build/executor/ExecutorDetector.js +93 -0
- package/build/executor/ExecutorDetector.js.map +1 -0
- package/build/executor/IExecutorBytecodeBuilder.d.ts +6 -0
- package/build/executor/IExecutorBytecodeBuilder.js +3 -0
- package/build/executor/IExecutorBytecodeBuilder.js.map +1 -0
- package/build/executor/constants.d.ts +18 -0
- package/build/executor/constants.js +49 -0
- package/build/executor/constants.js.map +1 -0
- package/build/executor/tests/utils-e2e-v6.d.ts +8 -0
- package/build/executor/tests/utils-e2e-v6.js +175 -0
- package/build/executor/tests/utils-e2e-v6.js.map +1 -0
- package/build/executor/types.d.ts +37 -0
- package/build/executor/types.js +46 -0
- package/build/executor/types.js.map +1 -0
- package/build/generic-swap-transaction-builder.d.ts +56 -0
- package/build/generic-swap-transaction-builder.js +306 -0
- package/build/generic-swap-transaction-builder.js.map +1 -0
- package/build/implementations/local-paraswap-sdk.d.ts +15 -9
- package/build/implementations/local-paraswap-sdk.js +43 -27
- package/build/implementations/local-paraswap-sdk.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/lib/curve/encoder.d.ts +5 -0
- package/build/lib/curve/encoder.js +13 -0
- package/build/lib/curve/encoder.js.map +1 -0
- package/build/transaction-builder.d.ts +13 -1
- package/build/transaction-builder.js +17 -0
- package/build/transaction-builder.js.map +1 -1
- package/build/types.d.ts +34 -1
- package/jest.config.js +1 -1
- package/package.json +2 -2
- package/src/abi/augustus-v6/ABI.json +1075 -0
- package/src/config.ts +59 -3
- package/src/constants.ts +10 -1
- package/src/dex/aave-v1/aave-v1-e2e.test.ts +4 -8
- package/src/dex/aave-v1/aave-v1.ts +44 -0
- package/src/dex/aave-v2/aave-v2-e2e.test.ts +8 -5
- package/src/dex/aave-v2/aave-v2.ts +104 -0
- package/src/dex/aave-v3/aave-v3-e2e.test.ts +7 -5
- package/src/dex/aave-v3/aave-v3.ts +63 -0
- package/src/dex/algebra/algebra-e2e.test.ts +42 -72
- package/src/dex/algebra/algebra.ts +70 -3
- package/src/dex/augustus-approvals.ts +175 -0
- package/src/dex/bProtocol/bProtocol-e2e.test.ts +93 -0
- package/src/dex/{bProtocol.ts → bProtocol/bProtocol.ts} +40 -14
- package/src/dex/bProtocol/types.ts +13 -0
- package/src/dex/balancer-v1/balancer-v1-e2e.test.ts +7 -5
- package/src/dex/balancer-v1/balancer-v1.ts +116 -14
- package/src/dex/balancer-v2/balancer-v2-e2e.test.ts +303 -267
- package/src/dex/balancer-v2/balancer-v2.ts +295 -15
- package/src/dex/balancer-v2/constants.ts +5 -0
- package/src/dex/balancer-v2/types.ts +13 -0
- package/src/dex/bancor/bancor-e2e.test.ts +91 -0
- package/src/dex/{bancor.ts → bancor/bancor.ts} +46 -33
- package/src/dex/bancor/config.ts +9 -0
- package/src/dex/bancor/types.ts +19 -0
- package/src/dex/camelot/camelot-e2e.test.ts +72 -4
- package/src/dex/camelot/camelot.ts +50 -0
- package/src/dex/compound/compound-e2e.test.ts +91 -0
- package/src/dex/{compound.ts → compound/compound.ts} +39 -17
- package/src/dex/compound/types.ts +10 -0
- package/src/dex/curve-v1/constants.ts +1 -0
- package/src/dex/curve-v1/curve-v1-e2e.test.ts +124 -64
- package/src/dex/curve-v1/curve-v1.ts +108 -9
- package/src/dex/curve-v1/packer.ts +17 -0
- package/src/dex/curve-v1/types.ts +18 -0
- package/src/dex/curve-v1-factory/curve-v1-factory-e2e.test.ts +9 -8
- package/src/dex/curve-v1-factory/curve-v1-factory.ts +37 -7
- package/src/dex/curve-v1-factory/state-polling-pools/polling-manager.ts +3 -3
- package/src/dex/curve-v2/constants.ts +1 -0
- package/src/dex/curve-v2/curve-v2-e2e.test.ts +104 -0
- package/src/dex/{curve-v2.ts → curve-v2/curve-v2.ts} +143 -23
- package/src/dex/curve-v2/types.ts +27 -0
- package/src/dex/dexalot/dexalot-e2e.test.ts +8 -6
- package/src/dex/dexalot/dexalot.ts +46 -0
- package/src/dex/dodo-v1/config.ts +15 -0
- package/src/dex/dodo-v1/dodo-v1-e2e.test.ts +101 -0
- package/src/dex/{dodo-v1.ts → dodo-v1/dodo-v1.ts} +52 -48
- package/src/dex/dodo-v1/types.ts +25 -0
- package/src/dex/dodo-v2.ts +80 -1
- package/src/dex/generic-rfq/e2e-test-config.ts +50 -6
- package/src/dex/generic-rfq/fetch-mm-api.ts +2 -4
- package/src/dex/generic-rfq/generic-rfq-e2e.test.ts +3 -3
- package/src/dex/generic-rfq/generic-rfq.ts +128 -11
- package/src/dex/generic-rfq/rate-fetcher.ts +2 -3
- package/src/dex/generic-rfq/types.ts +19 -2
- package/src/dex/generic-rfq/utils.ts +3 -9
- package/src/dex/generic-rfq/validators.ts +12 -15
- package/src/dex/gmx/gmx-e2e.test.ts +11 -8
- package/src/dex/gmx/gmx.ts +27 -0
- package/src/dex/hashflow/hashflow-e2e.test.ts +7 -5
- package/src/dex/hashflow/hashflow.ts +48 -1
- package/src/dex/idex.ts +34 -0
- package/src/dex/index.ts +27 -10
- package/src/dex/jarvis-v6/jarvis-v6-e2e.test.ts +5 -4
- package/src/dex/jarvis-v6/jarvis-v6.ts +37 -0
- package/src/dex/jarvis.ts +68 -1
- package/src/dex/kyberdmm/kyberdmm-e2e.test.ts +8 -5
- package/src/dex/kyberdmm/kyberdmm.ts +36 -0
- package/src/dex/lido/config.ts +5 -0
- package/src/dex/lido/lido-e2e.test.ts +71 -0
- package/src/dex/{lido.ts → lido/lido.ts} +34 -16
- package/src/dex/lido/types.ts +5 -0
- package/src/dex/maker-psm/maker-psm-e2e.test.ts +37 -7
- package/src/dex/maker-psm/maker-psm.ts +52 -0
- package/src/dex/maverick-v1/maverick-v1-e2e.test.ts +108 -0
- package/src/dex/maverick-v1/maverick-v1.ts +51 -0
- package/src/dex/nerve/nerve-e2e.test.ts +114 -57
- package/src/dex/nerve/nerve.ts +36 -0
- package/src/dex/{onebit.ts → onebit/onebit.ts} +43 -21
- package/src/dex/onebit/types.ts +17 -0
- package/src/dex/pancakeswap-v3/pancakeswap-v3-e2e.test.ts +19 -5
- package/src/dex/pancakeswap-v3/pancakeswap-v3.ts +46 -0
- package/src/dex/paraswap-limit-orders/paraswap-limit-orders.ts +34 -0
- package/src/dex/paraswap-limit-orders/types.ts +1 -0
- package/src/dex/platypus/platypus-e2e.test.ts +5 -4
- package/src/dex/platypus/platypus.ts +43 -0
- package/src/dex/polygon-migrator/polygon-migrator-e2e.test.ts +7 -5
- package/src/dex/polygon-migrator/polygon-migrator.ts +26 -0
- package/src/dex/quick-perps/quick-perps-e2e.test.ts +4 -3
- package/src/dex/quick-perps/quick-perps.ts +28 -0
- package/src/dex/quickswap/quickswap-e2e.test.ts +7 -5
- package/src/dex/simple-exchange.ts +16 -60
- package/src/dex/smoothy/smoothy-e2e.test.ts +81 -0
- package/src/dex/{smoothy.ts → smoothy/smoothy.ts} +34 -24
- package/src/dex/smoothy/types.ts +18 -0
- package/src/dex/solidly/solidly-e2e.test.ts +122 -0
- package/src/dex/solidly/solidly.ts +49 -0
- package/src/dex/solidly-v3/contract-math/Tick.ts +1 -4
- package/src/dex/solidly-v3/contract-math/uniswap-v3-math.ts +6 -14
- package/src/dex/solidly-v3/solidly-v3-e2e.test.ts +7 -5
- package/src/dex/solidly-v3/solidly-v3-events.test.ts +9 -7
- package/src/dex/solidly-v3/solidly-v3.ts +40 -52
- package/src/dex/{stable-pool.ts → stable-pool/stable-pool.ts} +45 -32
- package/src/dex/stable-pool/stablepool-e2e.test.ts +73 -0
- package/src/dex/stable-pool/types.ts +20 -0
- package/src/dex/swaap-v1/swaap-v1-e2e.test.ts +7 -5
- package/src/dex/swaap-v1/swaap-v1.ts +32 -0
- package/src/dex/swaap-v2/rate-fetcher.ts +6 -4
- package/src/dex/swaap-v2/swaap-v2-e2e.test.ts +7 -5
- package/src/dex/swaap-v2/swaap-v2.ts +39 -2
- package/src/dex/swaap-v2/validators.ts +12 -15
- package/src/dex/swell/swell-e2e.test.ts +4 -3
- package/src/dex/swell/swell.ts +27 -2
- package/src/dex/synthetix/synthetix-e2e.test.ts +5 -4
- package/src/dex/synthetix/synthetix.ts +38 -0
- package/src/dex/trader-joe-v2.1/config.ts +9 -0
- package/src/dex/trader-joe-v2.1/trader-joe-v2.1-e2e.test.ts +101 -0
- package/src/dex/{trader-joe-v2.1.ts → trader-joe-v2.1/trader-joe-v2.1.ts} +63 -48
- package/src/dex/trader-joe-v2.1/types.ts +38 -0
- package/src/dex/uniswap-v2/config.ts +42 -0
- package/src/dex/uniswap-v2/constants.ts +8 -6
- package/src/dex/uniswap-v2/dfyn.ts +44 -3
- package/src/dex/uniswap-v2/types.ts +22 -0
- package/src/dex/uniswap-v2/uniswap-v2-e2e-avalanche.test.ts +16 -13
- package/src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts +33 -17
- package/src/dex/uniswap-v2/uniswap-v2-e2e-mainnet.test.ts +424 -5
- package/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts +145 -46
- package/src/dex/uniswap-v2/uniswap-v2-optimizer.ts +114 -0
- package/src/dex/uniswap-v2/uniswap-v2.ts +206 -2
- package/src/dex/uniswap-v3/constants.ts +5 -0
- package/src/dex/uniswap-v3/types.ts +17 -0
- package/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +460 -402
- package/src/dex/uniswap-v3/uniswap-v3.ts +217 -43
- package/src/dex/uniswap-v3.ts +52 -1
- package/src/dex/weth/weth-e2e.test.ts +69 -38
- package/src/dex/weth/weth.ts +29 -5
- package/src/dex/wombat/wombat-e2e.test.ts +5 -4
- package/src/dex/wombat/wombat.ts +32 -1
- package/src/dex/woo-fi-v2/woo-fi-v2-e2e.test.ts +5 -4
- package/src/dex/woo-fi-v2/woo-fi-v2.ts +42 -0
- package/src/dex/wsteth/wsteth-e2e.test.ts +4 -3
- package/src/dex/wsteth/wsteth.ts +24 -0
- package/src/dex/zerox/config.ts +31 -0
- package/src/dex/zerox/index.ts +63 -67
- package/src/dex/zerox/types.ts +34 -0
- package/src/dex/zerox/zerox-e2e.test.ts +110 -0
- package/src/dex-helper/dummy-dex-helper.ts +28 -1
- package/src/dex-helper/icache.ts +4 -0
- package/src/dex-helper/idex-helper.ts +2 -0
- package/src/executor/Executor01BytecodeBuilder.ts +433 -0
- package/src/executor/Executor02BytecodeBuilder.ts +1329 -0
- package/src/executor/Executor03BytecodeBuilder.ts +419 -0
- package/src/executor/ExecutorBytecodeBuilder.ts +350 -0
- package/src/executor/ExecutorDetector.ts +117 -0
- package/src/executor/__snapshots__/executor01-bytecode-builder-snapshot.test.ts.snap +35 -0
- package/src/executor/__snapshots__/executor02-bytecode-builder-snapshot.test.ts.snap +23 -0
- package/src/executor/constants.ts +59 -0
- package/src/executor/executor01-bytecode-builder-e2e.test.ts +1439 -0
- package/src/executor/executor01-bytecode-builder-snapshot.test.ts +271 -0
- package/src/executor/executor02-bytecode-builder-e2e.test.ts +1489 -0
- package/src/executor/executor02-bytecode-builder-snapshot.test.ts +188 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +16 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +16 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +16 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +16 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +16 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +16 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +16 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +16 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +9 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +9 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +9 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +9 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +9 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +9 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +9 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +9 -0
- package/src/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +9 -0
- package/src/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +12 -0
- package/src/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +7 -0
- package/src/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +7 -0
- package/src/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +7 -0
- package/src/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +7 -0
- package/src/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +12 -0
- package/src/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +7 -0
- package/src/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +7 -0
- package/src/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +78 -0
- package/src/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +81 -0
- package/src/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +78 -0
- package/src/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +78 -0
- package/src/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +81 -0
- package/src/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +81 -0
- package/src/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +81 -0
- package/src/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +81 -0
- package/src/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +64 -0
- package/src/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +85 -0
- package/src/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +64 -0
- package/src/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +52 -0
- package/src/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +52 -0
- package/src/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +52 -0
- package/src/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +55 -0
- package/src/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +55 -0
- package/src/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +55 -0
- package/src/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +23 -0
- package/src/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +37 -0
- package/src/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +23 -0
- package/src/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +23 -0
- package/src/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +51 -0
- package/src/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +58 -0
- package/src/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +23 -0
- package/src/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +23 -0
- package/src/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +9 -0
- package/src/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +16 -0
- package/src/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +23 -0
- package/src/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +12 -0
- package/src/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +7 -0
- package/src/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +12 -0
- package/src/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +12 -0
- package/src/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +7 -0
- package/src/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +7 -0
- package/src/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +7 -0
- package/src/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +7 -0
- package/src/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +7 -0
- package/src/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +7 -0
- package/src/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +130 -0
- package/src/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +136 -0
- package/src/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +100 -0
- package/src/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +100 -0
- package/src/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +166 -0
- package/src/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +190 -0
- package/src/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +114 -0
- package/src/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +114 -0
- package/src/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +55 -0
- package/src/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +73 -0
- package/src/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +82 -0
- package/src/executor/types.ts +41 -0
- package/src/generic-swap-transaction-builder.ts +679 -0
- package/src/implementations/local-paraswap-sdk.ts +70 -29
- package/src/index.ts +1 -0
- package/src/lib/curve/encoder.ts +19 -0
- package/src/transaction-builder.ts +45 -1
- package/src/types.ts +35 -1
- package/tests/augustus-approvals.test.ts +628 -0
- package/tests/constants-e2e.ts +167 -35
- package/tests/debug-price-route.json +68 -0
- package/tests/debug-price-route.test.ts +55 -0
- package/tests/tenderly-simulation.ts +54 -5
- package/tests/utils-e2e.ts +347 -53
- package/tests/v6/executors.test.ts +110 -0
- package/tests/v6/price-routes/arbitrum/sell-0.1-ETH-USDC.json +104 -0
- package/tests/v6/price-routes/arbitrum/sell-1_000-ETH-DAI.json +294 -0
- package/tests/v6/price-routes/arbitrum/sell-1_000-WETH-wstETH.json +121 -0
- package/tests/v6/price-routes/arbitrum/sell-1_000_000-ARB-DAI.json +270 -0
- package/tests/v6/price-routes/arbitrum/sell-1_000_000-ARB-ETH.json +326 -0
- package/tests/v6/price-routes/arbitrum/sell-1_000_000-DAI-ARB.json +434 -0
- package/tests/v6/price-routes/arbitrum/sell-250_000-LINK-USDC.json +182 -0
- package/tests/v6/price-routes/arbitrum/sell-3_000-BAL-UNI.json +154 -0
- package/tests/v6/price-routes/avalanche/sell-100_000-WAVAX-USDC.json +315 -0
- package/tests/v6/price-routes/avalanche/sell-40-BTC-AVAX.json +207 -0
- package/tests/v6/price-routes/fantom/test.json +161 -0
- package/tests/v6/price-routes/mainnet/buy-3200-ETH-DAI.json +228 -0
- package/tests/v6/price-routes/mainnet/buy-usdc.json +233 -0
- package/tests/v6/price-routes/mainnet/executor-01.json +93 -0
- package/tests/v6/price-routes/mainnet/executor01-test copy.json +88 -0
- package/tests/v6/price-routes/mainnet/executor01-test.json +88 -0
- package/tests/v6/price-routes/mainnet/sell-1-USDC-USDT.json +78 -0
- package/tests/v6/price-routes/mainnet/sell-1-WBTC-BAL.json +158 -0
- package/tests/v6/price-routes/mainnet/sell-100-tBTC-WBTC.json +100 -0
- package/tests/v6/price-routes/mainnet/sell-1000-eth-dai.json +340 -0
- package/tests/v6/price-routes/mainnet/sell-1000-wbtc-eth-uniswapv3-balancerv2.json +162 -0
- package/tests/v6/price-routes/mainnet/sell-100_000-USDC-USDT-2-univ2-pools.json +86 -0
- package/tests/v6/price-routes/mainnet/sell-10_000-ETH-USDC-balancer.json +383 -0
- package/tests/v6/price-routes/mainnet/sell-10_000-ETH-stETH.json +168 -0
- package/tests/v6/price-routes/mainnet/sell-10_000-USDC-USDT-BalancerV2.json +68 -0
- package/tests/v6/price-routes/mainnet/sell-10_000-eth-usdc-uniswapv3-balancerv2.json +348 -0
- package/tests/v6/price-routes/mainnet/sell-1_000-stETH-ETH.json +100 -0
- package/tests/v6/price-routes/mainnet/sell-50-eth-usdc.json +153 -0
- package/tests/v6/price-routes/polygon/sell-100-WBTC-MATIC-1.json +571 -0
- package/tests/v6/price-routes/polygon/sell-100-WBTC-MATIC.json +559 -0
- package/tests/v6/price-routes/polygon/sell-1_000_000-DAI-MATIC-2.json +447 -0
- package/tests/v6/price-routes/polygon/sell-1_000_000-DAI-MATIC-3.json +472 -0
- package/tests/v6/price-routes/polygon/sell-1_000_000-DAI-MATIC.json +628 -0
- package/tests/v6/price-routes/polygon/test.json +109 -0
- package/tests/v6/utils-e2e-v6.ts +177 -0
- package/build/abi/algebra/AlgebraPool.abi.json +0 -727
- package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
- package/build/abi/wombat/pool.json +0 -1289
- package/build/dex/algebra/algebra-pool.d.ts +0 -46
- package/build/dex/algebra/algebra-pool.js +0 -336
- package/build/dex/algebra/algebra-pool.js.map +0 -1
- package/build/dex/quickswap/camelot-v3.d.ts +0 -6
- package/build/dex/quickswap/camelot-v3.js +0 -19
- package/build/dex/quickswap/camelot-v3.js.map +0 -1
- package/build/dex/quickswap/zyberswap-v3.d.ts +0 -6
- package/build/dex/quickswap/zyberswap-v3.js +0 -19
- package/build/dex/quickswap/zyberswap-v3.js.map +0 -1
- package/build/dex/uniswap-v2/rebase-tokens.json +0 -7
package/tests/utils-e2e.ts
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
MAX_UINT,
|
|
17
17
|
Network,
|
|
18
18
|
ContractMethod,
|
|
19
|
+
NULL_ADDRESS,
|
|
19
20
|
} from '../src/constants';
|
|
20
21
|
import {
|
|
21
22
|
OptimalRate,
|
|
@@ -28,14 +29,32 @@ import {
|
|
|
28
29
|
import Erc20ABI from '../src/abi/erc20.json';
|
|
29
30
|
import AugustusABI from '../src/abi/augustus.json';
|
|
30
31
|
import { generateConfig } from '../src/config';
|
|
31
|
-
import {
|
|
32
|
-
|
|
32
|
+
import {
|
|
33
|
+
DummyDexHelper,
|
|
34
|
+
DummyLimitOrderProvider,
|
|
35
|
+
IDexHelper,
|
|
36
|
+
} from '../src/dex-helper';
|
|
37
|
+
import {
|
|
38
|
+
AddressOrSymbol,
|
|
39
|
+
constructSimpleSDK,
|
|
40
|
+
SimpleFetchSDK,
|
|
41
|
+
} from '@paraswap/sdk';
|
|
33
42
|
import axios from 'axios';
|
|
34
43
|
import { SmartToken, StateOverrides } from './smart-tokens';
|
|
35
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
GIFTER_ADDRESS,
|
|
46
|
+
Holders,
|
|
47
|
+
NativeTokenSymbols,
|
|
48
|
+
Tokens,
|
|
49
|
+
WrappedNativeTokenSymbols,
|
|
50
|
+
} from './constants-e2e';
|
|
51
|
+
import { StaticJsonRpcProvider } from '@ethersproject/providers';
|
|
36
52
|
import { generateDeployBytecode, sleep } from './utils';
|
|
37
53
|
import { assert } from 'ts-essentials';
|
|
38
54
|
import * as util from 'util';
|
|
55
|
+
import { GenericSwapTransactionBuilder } from '../src/generic-swap-transaction-builder';
|
|
56
|
+
import { DexAdapterService, PricingHelper } from '../src';
|
|
57
|
+
import { v4 as uuid } from 'uuid';
|
|
39
58
|
|
|
40
59
|
export const testingEndpoint = process.env.E2E_TEST_ENDPOINT;
|
|
41
60
|
|
|
@@ -92,13 +111,41 @@ const MULTISIG: { [nid: number]: string } = {
|
|
|
92
111
|
|
|
93
112
|
class APIParaswapSDK implements IParaSwapSDK {
|
|
94
113
|
paraSwap: SimpleFetchSDK;
|
|
95
|
-
|
|
96
|
-
|
|
114
|
+
dexKeys: string[];
|
|
115
|
+
dexHelper: IDexHelper;
|
|
116
|
+
pricingHelper: PricingHelper;
|
|
117
|
+
transactionBuilder: GenericSwapTransactionBuilder;
|
|
118
|
+
dexAdapterService: DexAdapterService;
|
|
119
|
+
|
|
120
|
+
constructor(
|
|
121
|
+
protected network: number,
|
|
122
|
+
dexKeys: string | string[],
|
|
123
|
+
rpcUrl: string,
|
|
124
|
+
) {
|
|
125
|
+
this.dexKeys = Array.isArray(dexKeys) ? dexKeys : [dexKeys];
|
|
97
126
|
this.paraSwap = constructSimpleSDK({
|
|
98
127
|
chainId: network,
|
|
99
128
|
axios,
|
|
100
129
|
apiURL: testingEndpoint,
|
|
101
130
|
});
|
|
131
|
+
this.dexHelper = new DummyDexHelper(this.network, rpcUrl);
|
|
132
|
+
|
|
133
|
+
this.dexAdapterService = new DexAdapterService(
|
|
134
|
+
this.dexHelper,
|
|
135
|
+
this.network,
|
|
136
|
+
);
|
|
137
|
+
this.transactionBuilder = new GenericSwapTransactionBuilder(
|
|
138
|
+
this.dexAdapterService,
|
|
139
|
+
);
|
|
140
|
+
this.pricingHelper = new PricingHelper(
|
|
141
|
+
this.dexAdapterService,
|
|
142
|
+
this.dexHelper.getLogger,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async initializePricing() {
|
|
147
|
+
const blockNumber = await this.dexHelper.web3Provider.eth.getBlockNumber();
|
|
148
|
+
await this.pricingHelper.initialize(blockNumber, this.dexKeys);
|
|
102
149
|
}
|
|
103
150
|
|
|
104
151
|
async getPrices(
|
|
@@ -106,25 +153,51 @@ class APIParaswapSDK implements IParaSwapSDK {
|
|
|
106
153
|
to: Token,
|
|
107
154
|
amount: bigint,
|
|
108
155
|
side: SwapSide,
|
|
109
|
-
contractMethod: ContractMethod,
|
|
110
|
-
|
|
156
|
+
// contractMethod: ContractMethod,
|
|
157
|
+
contractMethod: any,
|
|
158
|
+
_poolIdentifiers?: { [key: string]: string[] | null } | null,
|
|
159
|
+
transferFees?: TransferFeeParams,
|
|
160
|
+
forceRoute?: AddressOrSymbol[],
|
|
111
161
|
): Promise<OptimalRate> {
|
|
112
162
|
if (_poolIdentifiers)
|
|
113
163
|
throw new Error('PoolIdentifiers is not supported by the API');
|
|
114
164
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
165
|
+
let priceRoute;
|
|
166
|
+
if (forceRoute && forceRoute.length > 0) {
|
|
167
|
+
const options = {
|
|
168
|
+
route: forceRoute,
|
|
169
|
+
amount: amount.toString(),
|
|
170
|
+
side,
|
|
171
|
+
srcDecimals: from.decimals,
|
|
172
|
+
destDecimals: to.decimals,
|
|
173
|
+
options: {
|
|
174
|
+
includeDEXS: this.dexKeys,
|
|
175
|
+
includeContractMethods: [contractMethod],
|
|
176
|
+
partner: 'any',
|
|
177
|
+
maxImpact: 100,
|
|
178
|
+
},
|
|
179
|
+
...transferFees,
|
|
180
|
+
};
|
|
181
|
+
priceRoute = await this.paraSwap.swap.getRateByRoute(options);
|
|
182
|
+
} else {
|
|
183
|
+
const options = {
|
|
184
|
+
srcToken: from.address,
|
|
185
|
+
destToken: to.address,
|
|
186
|
+
side,
|
|
187
|
+
amount: amount.toString(),
|
|
188
|
+
options: {
|
|
189
|
+
includeDEXS: this.dexKeys,
|
|
190
|
+
includeContractMethods: [contractMethod],
|
|
191
|
+
partner: 'any',
|
|
192
|
+
maxImpact: 100,
|
|
193
|
+
},
|
|
194
|
+
...transferFees,
|
|
195
|
+
srcDecimals: from.decimals,
|
|
196
|
+
destDecimals: to.decimals,
|
|
197
|
+
};
|
|
198
|
+
priceRoute = await this.paraSwap.swap.getRate(options);
|
|
199
|
+
}
|
|
200
|
+
|
|
128
201
|
return priceRoute as OptimalRate;
|
|
129
202
|
}
|
|
130
203
|
|
|
@@ -134,32 +207,66 @@ class APIParaswapSDK implements IParaSwapSDK {
|
|
|
134
207
|
userAddress: Address,
|
|
135
208
|
): Promise<TxObject> {
|
|
136
209
|
const minMaxAmount = _minMaxAmount.toString();
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
priceRoute.side === SwapSide.SELL
|
|
149
|
-
? minMaxAmount
|
|
150
|
-
: priceRoute.destAmount,
|
|
151
|
-
priceRoute,
|
|
152
|
-
userAddress,
|
|
153
|
-
partner: 'paraswap.io',
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
ignoreChecks: true,
|
|
157
|
-
},
|
|
158
|
-
);
|
|
159
|
-
return swapParams as TxObject;
|
|
210
|
+
let deadline = Number((Math.floor(Date.now() / 1000) + 10 * 60).toFixed());
|
|
211
|
+
|
|
212
|
+
return await this.transactionBuilder.build({
|
|
213
|
+
priceRoute,
|
|
214
|
+
minMaxAmount: minMaxAmount.toString(),
|
|
215
|
+
userAddress,
|
|
216
|
+
partnerAddress: NULL_ADDRESS,
|
|
217
|
+
partnerFeePercent: '0',
|
|
218
|
+
deadline: deadline.toString(),
|
|
219
|
+
uuid: uuid(),
|
|
220
|
+
});
|
|
160
221
|
}
|
|
161
222
|
}
|
|
162
223
|
|
|
224
|
+
function send1WeiTo(token: Address, to: Address, network: Network) {
|
|
225
|
+
const tokens = Tokens[network];
|
|
226
|
+
|
|
227
|
+
const tokenSymbol = Object.keys(tokens).find(tokenSymbol => {
|
|
228
|
+
const curToken = tokens[tokenSymbol];
|
|
229
|
+
return curToken.address === token;
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
const holders = Holders[network];
|
|
233
|
+
const holder = holders[tokenSymbol!];
|
|
234
|
+
|
|
235
|
+
return {
|
|
236
|
+
from: holder,
|
|
237
|
+
to: token,
|
|
238
|
+
data: erc20Interface.encodeFunctionData('transfer', [to, '1']),
|
|
239
|
+
value: '0',
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function checkBalanceOf(token: Address, holder: Address) {
|
|
244
|
+
return {
|
|
245
|
+
from: NULL_ADDRESS,
|
|
246
|
+
to: token,
|
|
247
|
+
data: erc20Interface.encodeFunctionData('balanceOf', [holder]),
|
|
248
|
+
value: '0',
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function allowAugustusV6(
|
|
253
|
+
tokenAddress: Address,
|
|
254
|
+
holderAddress: Address,
|
|
255
|
+
network: Network,
|
|
256
|
+
) {
|
|
257
|
+
const augustusV6Address = generateConfig(network).augustusV6Address;
|
|
258
|
+
|
|
259
|
+
return {
|
|
260
|
+
from: holderAddress,
|
|
261
|
+
to: tokenAddress,
|
|
262
|
+
data: erc20Interface.encodeFunctionData('approve', [
|
|
263
|
+
augustusV6Address,
|
|
264
|
+
MAX_UINT,
|
|
265
|
+
]),
|
|
266
|
+
value: '0',
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
|
|
163
270
|
function allowTokenTransferProxyParams(
|
|
164
271
|
tokenAddress: Address,
|
|
165
272
|
holderAddress: Address,
|
|
@@ -264,17 +371,18 @@ export async function testE2E(
|
|
|
264
371
|
senderAddress: Address,
|
|
265
372
|
_amount: string,
|
|
266
373
|
swapSide = SwapSide.SELL,
|
|
267
|
-
|
|
374
|
+
dexKeys: string | string[],
|
|
268
375
|
contractMethod: ContractMethod,
|
|
269
376
|
network: Network = Network.MAINNET,
|
|
270
377
|
_0: Provider,
|
|
271
|
-
poolIdentifiers?: string[],
|
|
378
|
+
poolIdentifiers?: { [key: string]: string[] | null } | null,
|
|
272
379
|
limitOrderProvider?: DummyLimitOrderProvider,
|
|
273
380
|
transferFees?: TransferFeeParams,
|
|
274
381
|
// Specified in BPS: part of 10000
|
|
275
382
|
slippage?: number,
|
|
276
383
|
sleepMs?: number,
|
|
277
384
|
replaceTenderlyWithEstimateGas?: boolean,
|
|
385
|
+
forceRoute?: AddressOrSymbol[],
|
|
278
386
|
) {
|
|
279
387
|
const amount = BigInt(_amount);
|
|
280
388
|
|
|
@@ -287,8 +395,13 @@ export async function testE2E(
|
|
|
287
395
|
const allowanceTx = await ts.simulate(
|
|
288
396
|
allowTokenTransferProxyParams(srcToken.address, senderAddress, network),
|
|
289
397
|
);
|
|
398
|
+
const augustusV6Allowance = await ts.simulate(
|
|
399
|
+
allowAugustusV6(srcToken.address, senderAddress, network),
|
|
400
|
+
);
|
|
290
401
|
if (!allowanceTx.success) console.log(allowanceTx.url);
|
|
402
|
+
if (!augustusV6Allowance.success) console.log(augustusV6Allowance.url);
|
|
291
403
|
expect(allowanceTx!.success).toEqual(true);
|
|
404
|
+
expect(augustusV6Allowance!.success).toEqual(true);
|
|
292
405
|
}
|
|
293
406
|
|
|
294
407
|
if (deployedTestContractAddress) {
|
|
@@ -354,8 +467,8 @@ export async function testE2E(
|
|
|
354
467
|
const useAPI = testingEndpoint && !poolIdentifiers;
|
|
355
468
|
// The API currently doesn't allow for specifying poolIdentifiers
|
|
356
469
|
const paraswap: IParaSwapSDK = useAPI
|
|
357
|
-
? new APIParaswapSDK(network,
|
|
358
|
-
: new LocalParaswapSDK(network,
|
|
470
|
+
? new APIParaswapSDK(network, dexKeys, '')
|
|
471
|
+
: new LocalParaswapSDK(network, dexKeys, '', limitOrderProvider);
|
|
359
472
|
|
|
360
473
|
if (paraswap.initializePricing) await paraswap.initializePricing();
|
|
361
474
|
|
|
@@ -378,9 +491,66 @@ export async function testE2E(
|
|
|
378
491
|
contractMethod,
|
|
379
492
|
poolIdentifiers,
|
|
380
493
|
transferFees,
|
|
494
|
+
forceRoute,
|
|
381
495
|
);
|
|
496
|
+
|
|
497
|
+
console.log('PRICE ROUTE: ', util.inspect(priceRoute, false, null, true));
|
|
382
498
|
expect(parseFloat(priceRoute.destAmount)).toBeGreaterThan(0);
|
|
383
499
|
|
|
500
|
+
// send 1 wei of src token to AugustusV6 and Executors
|
|
501
|
+
// const config = generateConfig(network);
|
|
502
|
+
// const augustusV6Address = config.augustusV6Address!;
|
|
503
|
+
// const executorsAddresses = Object.values(config.executorsAddresses!);
|
|
504
|
+
// const addresses = [...executorsAddresses, augustusV6Address];
|
|
505
|
+
|
|
506
|
+
// for await (const a of addresses) {
|
|
507
|
+
// const src =
|
|
508
|
+
// srcToken.address.toLowerCase() === ETHER_ADDRESS
|
|
509
|
+
// ? config.wrappedNativeTokenAddress
|
|
510
|
+
// : srcToken.address.toLowerCase();
|
|
511
|
+
// const dest =
|
|
512
|
+
// destToken.address.toLowerCase() === ETHER_ADDRESS
|
|
513
|
+
// ? config.wrappedNativeTokenAddress
|
|
514
|
+
// : destToken.address.toLowerCase();
|
|
515
|
+
//
|
|
516
|
+
// if (priceRoute.bestRoute[0].swaps.length > 0) {
|
|
517
|
+
// const intermediateToken =
|
|
518
|
+
// priceRoute.bestRoute[0].swaps[0].destToken.toLowerCase() ===
|
|
519
|
+
// ETHER_ADDRESS
|
|
520
|
+
// ? config.wrappedNativeTokenAddress
|
|
521
|
+
// : priceRoute.bestRoute[0].swaps[0].destToken.toLowerCase();
|
|
522
|
+
//
|
|
523
|
+
// await ts.simulate(send1WeiTo(intermediateToken, a, network));
|
|
524
|
+
// }
|
|
525
|
+
//
|
|
526
|
+
// await ts.simulate(send1WeiTo(src, a, network));
|
|
527
|
+
// await ts.simulate(send1WeiTo(dest, a, network));
|
|
528
|
+
// }
|
|
529
|
+
//
|
|
530
|
+
// for await (const a of addresses) {
|
|
531
|
+
// const src =
|
|
532
|
+
// srcToken.address.toLowerCase() === ETHER_ADDRESS
|
|
533
|
+
// ? config.wrappedNativeTokenAddress
|
|
534
|
+
// : srcToken.address.toLowerCase();
|
|
535
|
+
// const dest =
|
|
536
|
+
// destToken.address.toLowerCase() === ETHER_ADDRESS
|
|
537
|
+
// ? config.wrappedNativeTokenAddress
|
|
538
|
+
// : destToken.address.toLowerCase();
|
|
539
|
+
//
|
|
540
|
+
// if (priceRoute.bestRoute[0].swaps.length > 0) {
|
|
541
|
+
// const intermediateToken =
|
|
542
|
+
// priceRoute.bestRoute[0].swaps[0].destToken.toLowerCase() ===
|
|
543
|
+
// ETHER_ADDRESS
|
|
544
|
+
// ? config.wrappedNativeTokenAddress
|
|
545
|
+
// : priceRoute.bestRoute[0].swaps[0].destToken.toLowerCase();
|
|
546
|
+
//
|
|
547
|
+
// await ts.simulate(checkBalanceOf(intermediateToken, a));
|
|
548
|
+
// }
|
|
549
|
+
//
|
|
550
|
+
// await ts.simulate(checkBalanceOf(src, a));
|
|
551
|
+
// await ts.simulate(checkBalanceOf(dest, a));
|
|
552
|
+
// }
|
|
553
|
+
|
|
384
554
|
// Calculate slippage. Default is 1%
|
|
385
555
|
const _slippage = slippage || 100;
|
|
386
556
|
const minMaxAmount =
|
|
@@ -403,7 +573,11 @@ export async function testE2E(
|
|
|
403
573
|
}, Difference: ${parseInt(priceRoute.gasCost) - parseInt(gasUsed)}`,
|
|
404
574
|
);
|
|
405
575
|
}
|
|
406
|
-
console.log(
|
|
576
|
+
console.log(
|
|
577
|
+
`${swapSide}: ${srcToken.address} -> ${destToken.address} (${
|
|
578
|
+
priceRoute.contractMethod
|
|
579
|
+
})\nTenderly URL: ${swapTx!.url}`,
|
|
580
|
+
);
|
|
407
581
|
expect(swapTx!.success).toEqual(true);
|
|
408
582
|
} finally {
|
|
409
583
|
if (paraswap.releaseResources) {
|
|
@@ -420,10 +594,10 @@ export type TestParamE2E = {
|
|
|
420
594
|
thirdPartyAddress?: Address;
|
|
421
595
|
_amount: string;
|
|
422
596
|
swapSide: SwapSide;
|
|
423
|
-
|
|
597
|
+
dexKeys: string | string[];
|
|
424
598
|
contractMethod: ContractMethod;
|
|
425
599
|
network: Network;
|
|
426
|
-
poolIdentifiers?: string[];
|
|
600
|
+
poolIdentifiers?: { [key: string]: string[] | null } | null;
|
|
427
601
|
limitOrderProvider?: DummyLimitOrderProvider;
|
|
428
602
|
transferFees?: TransferFeeParams;
|
|
429
603
|
srcTokenBalanceOverrides?: Record<Address, string>;
|
|
@@ -458,7 +632,7 @@ export async function newTestE2E({
|
|
|
458
632
|
thirdPartyAddress,
|
|
459
633
|
_amount,
|
|
460
634
|
swapSide,
|
|
461
|
-
|
|
635
|
+
dexKeys,
|
|
462
636
|
contractMethod,
|
|
463
637
|
network,
|
|
464
638
|
poolIdentifiers,
|
|
@@ -535,7 +709,7 @@ export async function newTestE2E({
|
|
|
535
709
|
// The API currently doesn't allow for specifying poolIdentifiers
|
|
536
710
|
const paraswap: IParaSwapSDK = new LocalParaswapSDK(
|
|
537
711
|
network,
|
|
538
|
-
|
|
712
|
+
dexKeys,
|
|
539
713
|
'',
|
|
540
714
|
limitOrderProvider,
|
|
541
715
|
);
|
|
@@ -615,7 +789,6 @@ export async function newTestE2E({
|
|
|
615
789
|
destToken.applyOverrides(stateOverrides);
|
|
616
790
|
|
|
617
791
|
const swapTx = await ts.simulate(swapParams, stateOverrides);
|
|
618
|
-
console.log(`${srcToken.address}_${destToken.address}_${dexKey!}`);
|
|
619
792
|
// Only log gas estimate if testing against API
|
|
620
793
|
if (useAPI)
|
|
621
794
|
console.log(
|
|
@@ -645,3 +818,124 @@ export const getEnv = (envName: string, optional: boolean = false): string => {
|
|
|
645
818
|
|
|
646
819
|
return process.env[envName]!;
|
|
647
820
|
};
|
|
821
|
+
|
|
822
|
+
// poolIdentifiers?: { [key: string]: string[] | null } | null,
|
|
823
|
+
// limitOrderProvider?: DummyLimitOrderProvider,
|
|
824
|
+
// transferFees?: TransferFeeParams,
|
|
825
|
+
// // Specified in BPS: part of 10000
|
|
826
|
+
// slippage?: number,
|
|
827
|
+
// sleepMs?: number,
|
|
828
|
+
// replaceTenderlyWithEstimateGas?: boolean,
|
|
829
|
+
// forceRoute?: AddressOrSymbol[],
|
|
830
|
+
export function testE2E_V6(
|
|
831
|
+
network: Network,
|
|
832
|
+
dexKey: string,
|
|
833
|
+
tokenASymbol: string,
|
|
834
|
+
tokenBSymbol: string,
|
|
835
|
+
tokenAAmount: string,
|
|
836
|
+
tokenBAmount: string,
|
|
837
|
+
nativeTokenAmount: string,
|
|
838
|
+
forceRoute: AddressOrSymbol[],
|
|
839
|
+
) {
|
|
840
|
+
const provider = new StaticJsonRpcProvider(
|
|
841
|
+
generateConfig(network).privateHttpProvider,
|
|
842
|
+
network,
|
|
843
|
+
);
|
|
844
|
+
const tokens = Tokens[network];
|
|
845
|
+
const holders = Holders[network];
|
|
846
|
+
const nativeTokenSymbol = NativeTokenSymbols[network];
|
|
847
|
+
const wrappedNativeTokenSymbol = WrappedNativeTokenSymbols[network];
|
|
848
|
+
|
|
849
|
+
const sideToContractMethods = new Map([
|
|
850
|
+
[SwapSide.SELL, [ContractMethod.swapExactAmountIn]],
|
|
851
|
+
]);
|
|
852
|
+
|
|
853
|
+
describe(`${network}`, () => {
|
|
854
|
+
sideToContractMethods.forEach((contractMethods, side) =>
|
|
855
|
+
describe(`${side}`, () => {
|
|
856
|
+
contractMethods.forEach((contractMethod: ContractMethod) => {
|
|
857
|
+
describe(`${contractMethod}`, () => {
|
|
858
|
+
it(`${nativeTokenSymbol} -> ${tokenASymbol}`, async () => {
|
|
859
|
+
await testE2E(
|
|
860
|
+
tokens[nativeTokenSymbol],
|
|
861
|
+
tokens[tokenASymbol],
|
|
862
|
+
holders[nativeTokenSymbol],
|
|
863
|
+
side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
|
|
864
|
+
side,
|
|
865
|
+
dexKey,
|
|
866
|
+
contractMethod,
|
|
867
|
+
network,
|
|
868
|
+
provider,
|
|
869
|
+
);
|
|
870
|
+
});
|
|
871
|
+
it(`${tokenASymbol} -> ${nativeTokenSymbol}`, async () => {
|
|
872
|
+
await testE2E(
|
|
873
|
+
tokens[tokenASymbol],
|
|
874
|
+
tokens[nativeTokenSymbol],
|
|
875
|
+
holders[tokenASymbol],
|
|
876
|
+
side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
|
|
877
|
+
side,
|
|
878
|
+
dexKey,
|
|
879
|
+
contractMethod,
|
|
880
|
+
network,
|
|
881
|
+
provider,
|
|
882
|
+
);
|
|
883
|
+
});
|
|
884
|
+
it(`${wrappedNativeTokenSymbol} -> ${tokenASymbol}`, async () => {
|
|
885
|
+
await testE2E(
|
|
886
|
+
tokens[wrappedNativeTokenSymbol],
|
|
887
|
+
tokens[tokenASymbol],
|
|
888
|
+
holders[wrappedNativeTokenSymbol],
|
|
889
|
+
side === SwapSide.SELL ? nativeTokenAmount : tokenAAmount,
|
|
890
|
+
side,
|
|
891
|
+
dexKey,
|
|
892
|
+
contractMethod,
|
|
893
|
+
network,
|
|
894
|
+
provider,
|
|
895
|
+
);
|
|
896
|
+
});
|
|
897
|
+
it(`${tokenASymbol} -> ${wrappedNativeTokenSymbol}`, async () => {
|
|
898
|
+
await testE2E(
|
|
899
|
+
tokens[tokenASymbol],
|
|
900
|
+
tokens[wrappedNativeTokenSymbol],
|
|
901
|
+
holders[tokenASymbol],
|
|
902
|
+
side === SwapSide.SELL ? tokenAAmount : nativeTokenAmount,
|
|
903
|
+
side,
|
|
904
|
+
dexKey,
|
|
905
|
+
contractMethod,
|
|
906
|
+
network,
|
|
907
|
+
provider,
|
|
908
|
+
);
|
|
909
|
+
});
|
|
910
|
+
it(`${tokenASymbol} -> ${tokenBSymbol}`, async () => {
|
|
911
|
+
await testE2E(
|
|
912
|
+
tokens[tokenASymbol],
|
|
913
|
+
tokens[tokenBSymbol],
|
|
914
|
+
holders[tokenASymbol],
|
|
915
|
+
side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
|
|
916
|
+
side,
|
|
917
|
+
dexKey,
|
|
918
|
+
contractMethod,
|
|
919
|
+
network,
|
|
920
|
+
provider,
|
|
921
|
+
);
|
|
922
|
+
});
|
|
923
|
+
it(`${tokenBSymbol} -> ${tokenASymbol}`, async () => {
|
|
924
|
+
await testE2E(
|
|
925
|
+
tokens[tokenBSymbol],
|
|
926
|
+
tokens[tokenASymbol],
|
|
927
|
+
holders[tokenBSymbol],
|
|
928
|
+
side === SwapSide.SELL ? tokenAAmount : tokenBAmount,
|
|
929
|
+
side,
|
|
930
|
+
dexKey,
|
|
931
|
+
contractMethod,
|
|
932
|
+
network,
|
|
933
|
+
provider,
|
|
934
|
+
);
|
|
935
|
+
});
|
|
936
|
+
});
|
|
937
|
+
});
|
|
938
|
+
}),
|
|
939
|
+
);
|
|
940
|
+
});
|
|
941
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import dotenv from 'dotenv';
|
|
2
|
+
dotenv.config();
|
|
3
|
+
|
|
4
|
+
import { OptimalRate } from '@paraswap/core';
|
|
5
|
+
import {
|
|
6
|
+
ContractsAugustusV6,
|
|
7
|
+
runE2ETest as runForkE2ETest,
|
|
8
|
+
} from './utils-e2e-v6';
|
|
9
|
+
import axios from 'axios';
|
|
10
|
+
import fs from 'fs';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import { Holders, Tokens } from '../constants-e2e';
|
|
13
|
+
|
|
14
|
+
jest.setTimeout(1000 * 120);
|
|
15
|
+
|
|
16
|
+
type ForkMetadata = {
|
|
17
|
+
forkId: string;
|
|
18
|
+
lastTx: string;
|
|
19
|
+
blockNumber: number;
|
|
20
|
+
network: number;
|
|
21
|
+
contracts: ContractsAugustusV6;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const forceNewDeployment = false;
|
|
25
|
+
// const network = 'polygon';
|
|
26
|
+
// const network = 'arbitrum';
|
|
27
|
+
// const network = 'avalanche';
|
|
28
|
+
const network = 'mainnet';
|
|
29
|
+
|
|
30
|
+
async function deployAugustusOnFork(
|
|
31
|
+
network: number,
|
|
32
|
+
blockNumber: number,
|
|
33
|
+
): Promise<ForkMetadata> {
|
|
34
|
+
console.log(
|
|
35
|
+
`Locally deploying fork for block ${blockNumber} with AugustusV6 contracts`,
|
|
36
|
+
);
|
|
37
|
+
const { data } = await axios.post<ForkMetadata>(
|
|
38
|
+
// local server from contracts-v6
|
|
39
|
+
`http://localhost:3000/deploy-fork`,
|
|
40
|
+
{
|
|
41
|
+
network,
|
|
42
|
+
blockNumber,
|
|
43
|
+
forceNewDeployment,
|
|
44
|
+
},
|
|
45
|
+
);
|
|
46
|
+
return data;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
describe('Executors: Price Route Tests', () => {
|
|
50
|
+
// Dynamically load and test each price route file in the directory
|
|
51
|
+
const routePath = `./price-routes/${network}`;
|
|
52
|
+
const priceRoutesDir = path.join(__dirname, routePath);
|
|
53
|
+
const priceRouteFiles = fs.readdirSync(priceRoutesDir);
|
|
54
|
+
|
|
55
|
+
priceRouteFiles.forEach(file => {
|
|
56
|
+
if (file === 'balancer-v2-2.test.json')
|
|
57
|
+
it(`file: ${file}`, async () => {
|
|
58
|
+
const {
|
|
59
|
+
priceRoute,
|
|
60
|
+
metadata,
|
|
61
|
+
}: {
|
|
62
|
+
priceRoute: OptimalRate;
|
|
63
|
+
metadata: ForkMetadata;
|
|
64
|
+
} = require(path.join(priceRoutesDir, file));
|
|
65
|
+
let forkMetadata: ForkMetadata = metadata;
|
|
66
|
+
if (!forkMetadata?.contracts || forceNewDeployment) {
|
|
67
|
+
forkMetadata = await deployAugustusOnFork(
|
|
68
|
+
priceRoute.network,
|
|
69
|
+
priceRoute.blockNumber,
|
|
70
|
+
);
|
|
71
|
+
saveForkMetadata(
|
|
72
|
+
forkMetadata,
|
|
73
|
+
priceRoute as OptimalRate,
|
|
74
|
+
`${routePath}/${file}`,
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const srcTokenSymbol = Object.entries(Tokens[priceRoute.network]).find(
|
|
79
|
+
([key, token]) =>
|
|
80
|
+
token.address.toLowerCase() === priceRoute.srcToken.toLowerCase(),
|
|
81
|
+
)?.[0];
|
|
82
|
+
|
|
83
|
+
if (!srcTokenSymbol) throw new Error('srcTokenSymbol not found');
|
|
84
|
+
|
|
85
|
+
await runForkE2ETest(
|
|
86
|
+
priceRoute as OptimalRate,
|
|
87
|
+
Holders[priceRoute.network][srcTokenSymbol],
|
|
88
|
+
forkMetadata.forkId,
|
|
89
|
+
forkMetadata.lastTx,
|
|
90
|
+
forkMetadata.contracts,
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
function saveForkMetadata(
|
|
97
|
+
metadata: ForkMetadata,
|
|
98
|
+
priceRoute: OptimalRate,
|
|
99
|
+
relativeFilePath: string,
|
|
100
|
+
) {
|
|
101
|
+
try {
|
|
102
|
+
const absoluteFilePath = path.join(__dirname, relativeFilePath);
|
|
103
|
+
fs.writeFileSync(
|
|
104
|
+
absoluteFilePath,
|
|
105
|
+
JSON.stringify({ metadata, priceRoute }, null, 2),
|
|
106
|
+
);
|
|
107
|
+
} catch (err) {
|
|
108
|
+
console.error(`Error writing file to disk: ${err}`);
|
|
109
|
+
}
|
|
110
|
+
}
|