@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
|
@@ -4,6 +4,7 @@ import { pack } from '@ethersproject/solidity';
|
|
|
4
4
|
import {
|
|
5
5
|
AdapterExchangeParam,
|
|
6
6
|
Address,
|
|
7
|
+
DexExchangeParam,
|
|
7
8
|
ExchangePrices,
|
|
8
9
|
ExchangeTxInfo,
|
|
9
10
|
Logger,
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
getBigIntPow,
|
|
22
23
|
getDexKeysWithNetwork,
|
|
23
24
|
interpolate,
|
|
25
|
+
isETHAddress,
|
|
24
26
|
isTruthy,
|
|
25
27
|
uuidToBytes16,
|
|
26
28
|
} from '../../utils';
|
|
@@ -33,6 +35,8 @@ import {
|
|
|
33
35
|
UniswapV3Data,
|
|
34
36
|
UniswapV3Functions,
|
|
35
37
|
UniswapV3Param,
|
|
38
|
+
UniswapV3ParamsDirect,
|
|
39
|
+
UniswapV3ParamsDirectBase,
|
|
36
40
|
UniswapV3SimpleSwapParams,
|
|
37
41
|
} from './types';
|
|
38
42
|
import {
|
|
@@ -48,6 +52,7 @@ import DirectSwapABI from '../../abi/DirectSwap.json';
|
|
|
48
52
|
import UniswapV3StateMulticallABI from '../../abi/uniswap-v3/UniswapV3StateMulticall.abi.json';
|
|
49
53
|
import {
|
|
50
54
|
DirectMethods,
|
|
55
|
+
DirectMethodsV6,
|
|
51
56
|
UNISWAPV3_EFFICIENCY_FACTOR,
|
|
52
57
|
UNISWAPV3_POOL_SEARCH_OVERHEAD,
|
|
53
58
|
UNISWAPV3_TICK_BASE_OVERHEAD,
|
|
@@ -65,6 +70,7 @@ import {
|
|
|
65
70
|
} from '../../lib/tokens/types';
|
|
66
71
|
import { OptimalSwapExchange } from '@paraswap/core';
|
|
67
72
|
import { OnPoolCreatedCallback, UniswapV3Factory } from './uniswap-v3-factory';
|
|
73
|
+
import { hexConcat, hexlify, hexZeroPad, hexValue } from 'ethers/lib/utils';
|
|
68
74
|
|
|
69
75
|
type PoolPairsInfo = {
|
|
70
76
|
token0: Address;
|
|
@@ -78,7 +84,7 @@ const UNISWAPV3_QUOTE_GASLIMIT = 200_000;
|
|
|
78
84
|
|
|
79
85
|
export class UniswapV3
|
|
80
86
|
extends SimpleExchange
|
|
81
|
-
implements IDex<UniswapV3Data, UniswapV3Param>
|
|
87
|
+
implements IDex<UniswapV3Data, UniswapV3Param | UniswapV3ParamsDirect>
|
|
82
88
|
{
|
|
83
89
|
private readonly factory: UniswapV3Factory;
|
|
84
90
|
readonly isFeeOnTransferSupported: boolean = false;
|
|
@@ -688,6 +694,20 @@ export class UniswapV3
|
|
|
688
694
|
|
|
689
695
|
const zeroForOne = token0 === _srcAddress ? true : false;
|
|
690
696
|
|
|
697
|
+
this.logger.log(
|
|
698
|
+
'UNI_POOLS',
|
|
699
|
+
JSON.stringify(
|
|
700
|
+
poolsToUse.poolWithState.map(el => ({
|
|
701
|
+
address: el.poolAddress,
|
|
702
|
+
token0: el.token0,
|
|
703
|
+
token1: el.token1,
|
|
704
|
+
fee: el.feeCode,
|
|
705
|
+
})),
|
|
706
|
+
null,
|
|
707
|
+
2,
|
|
708
|
+
),
|
|
709
|
+
);
|
|
710
|
+
|
|
691
711
|
const result = await Promise.all(
|
|
692
712
|
poolsToUse.poolWithState.map(async (pool, i) => {
|
|
693
713
|
const state = states[i];
|
|
@@ -790,37 +810,6 @@ export class UniswapV3
|
|
|
790
810
|
}
|
|
791
811
|
}
|
|
792
812
|
|
|
793
|
-
getAdapterParam(
|
|
794
|
-
srcToken: string,
|
|
795
|
-
destToken: string,
|
|
796
|
-
srcAmount: string,
|
|
797
|
-
destAmount: string,
|
|
798
|
-
data: UniswapV3Data,
|
|
799
|
-
side: SwapSide,
|
|
800
|
-
): AdapterExchangeParam {
|
|
801
|
-
const { path: rawPath } = data;
|
|
802
|
-
const path = this._encodePath(rawPath, side);
|
|
803
|
-
|
|
804
|
-
const payload = this.abiCoder.encodeParameter(
|
|
805
|
-
{
|
|
806
|
-
ParentStruct: {
|
|
807
|
-
path: 'bytes',
|
|
808
|
-
deadline: 'uint256',
|
|
809
|
-
},
|
|
810
|
-
},
|
|
811
|
-
{
|
|
812
|
-
path,
|
|
813
|
-
deadline: getLocalDeadlineAsFriendlyPlaceholder(), // FIXME: more gas efficient to pass block.timestamp in adapter
|
|
814
|
-
},
|
|
815
|
-
);
|
|
816
|
-
|
|
817
|
-
return {
|
|
818
|
-
targetExchange: this.config.router,
|
|
819
|
-
payload,
|
|
820
|
-
networkFee: '0',
|
|
821
|
-
};
|
|
822
|
-
}
|
|
823
|
-
|
|
824
813
|
getCalldataGasCost(poolPrices: PoolPrices<UniswapV3Data>): number | number[] {
|
|
825
814
|
const gasCost =
|
|
826
815
|
CALLDATA_GAS_COST.DEX_OVERHEAD +
|
|
@@ -875,13 +864,11 @@ export class UniswapV3
|
|
|
875
864
|
let isApproved: boolean | undefined;
|
|
876
865
|
|
|
877
866
|
try {
|
|
878
|
-
this.
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
isApproved =
|
|
884
|
-
BigInt(allowance.toString()) >= BigInt(optimalSwapExchange.srcAmount);
|
|
867
|
+
isApproved = await this.dexHelper.augustusApprovals.hasApproval(
|
|
868
|
+
options.executionContractAddress,
|
|
869
|
+
this.dexHelper.config.wrapETH(srcToken).address,
|
|
870
|
+
this.config.router,
|
|
871
|
+
);
|
|
885
872
|
} catch (e) {
|
|
886
873
|
this.logger.error(
|
|
887
874
|
`preProcessTransaction failed to retrieve allowance info: `,
|
|
@@ -919,10 +906,7 @@ export class UniswapV3
|
|
|
919
906
|
beneficiary: string,
|
|
920
907
|
contractMethod?: string,
|
|
921
908
|
): TxInfo<UniswapV3Param> {
|
|
922
|
-
if (
|
|
923
|
-
contractMethod !== DirectMethods.directSell &&
|
|
924
|
-
contractMethod !== DirectMethods.directBuy
|
|
925
|
-
) {
|
|
909
|
+
if (!UniswapV3.getDirectFunctionName().includes(contractMethod!)) {
|
|
926
910
|
throw new Error(`Invalid contract method ${contractMethod}`);
|
|
927
911
|
}
|
|
928
912
|
|
|
@@ -970,6 +954,141 @@ export class UniswapV3
|
|
|
970
954
|
return [DirectMethods.directSell, DirectMethods.directBuy];
|
|
971
955
|
}
|
|
972
956
|
|
|
957
|
+
getDirectParamV6(
|
|
958
|
+
srcToken: Address,
|
|
959
|
+
destToken: Address,
|
|
960
|
+
fromAmount: NumberAsString,
|
|
961
|
+
toAmount: NumberAsString,
|
|
962
|
+
quotedAmount: NumberAsString,
|
|
963
|
+
data: UniswapV3Data,
|
|
964
|
+
side: SwapSide,
|
|
965
|
+
permit: string,
|
|
966
|
+
uuid: string,
|
|
967
|
+
partnerAndFee: string,
|
|
968
|
+
beneficiary: string,
|
|
969
|
+
blockNumber: number,
|
|
970
|
+
contractMethod?: string,
|
|
971
|
+
) {
|
|
972
|
+
if (!UniswapV3.getDirectFunctionNameV6().includes(contractMethod!)) {
|
|
973
|
+
throw new Error(`Invalid contract method ${contractMethod}`);
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
const path = this._encodePathV6(data.path, side);
|
|
977
|
+
|
|
978
|
+
const metadata = hexConcat([
|
|
979
|
+
hexZeroPad(uuidToBytes16(uuid), 16),
|
|
980
|
+
hexZeroPad(hexlify(blockNumber), 16),
|
|
981
|
+
]);
|
|
982
|
+
const uniData: UniswapV3ParamsDirectBase = [
|
|
983
|
+
srcToken,
|
|
984
|
+
destToken,
|
|
985
|
+
fromAmount,
|
|
986
|
+
quotedAmount,
|
|
987
|
+
toAmount,
|
|
988
|
+
metadata,
|
|
989
|
+
// uuidToBytes16(uuid),
|
|
990
|
+
beneficiary,
|
|
991
|
+
path,
|
|
992
|
+
];
|
|
993
|
+
|
|
994
|
+
const swapParams: UniswapV3ParamsDirect = [uniData, partnerAndFee, permit];
|
|
995
|
+
|
|
996
|
+
const encoder = (...params: (string | UniswapV3ParamsDirect)[]) => {
|
|
997
|
+
return this.augustusV6Interface.encodeFunctionData(
|
|
998
|
+
side === SwapSide.SELL
|
|
999
|
+
? DirectMethodsV6.directSell
|
|
1000
|
+
: DirectMethodsV6.directBuy,
|
|
1001
|
+
[...params],
|
|
1002
|
+
);
|
|
1003
|
+
};
|
|
1004
|
+
|
|
1005
|
+
return {
|
|
1006
|
+
params: swapParams,
|
|
1007
|
+
encoder,
|
|
1008
|
+
networkFee: '0',
|
|
1009
|
+
};
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
static getDirectFunctionNameV6(): string[] {
|
|
1013
|
+
return [DirectMethodsV6.directSell, DirectMethodsV6.directBuy];
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
getAdapterParam(
|
|
1017
|
+
srcToken: string,
|
|
1018
|
+
destToken: string,
|
|
1019
|
+
srcAmount: string,
|
|
1020
|
+
destAmount: string,
|
|
1021
|
+
data: UniswapV3Data,
|
|
1022
|
+
side: SwapSide,
|
|
1023
|
+
): AdapterExchangeParam {
|
|
1024
|
+
const { path: rawPath } = data;
|
|
1025
|
+
const path = this._encodePath(rawPath, side);
|
|
1026
|
+
|
|
1027
|
+
const payload = this.abiCoder.encodeParameter(
|
|
1028
|
+
{
|
|
1029
|
+
ParentStruct: {
|
|
1030
|
+
path: 'bytes',
|
|
1031
|
+
deadline: 'uint256',
|
|
1032
|
+
},
|
|
1033
|
+
},
|
|
1034
|
+
{
|
|
1035
|
+
path,
|
|
1036
|
+
deadline: getLocalDeadlineAsFriendlyPlaceholder(), // FIXME: more gas efficient to pass block.timestamp in adapter
|
|
1037
|
+
},
|
|
1038
|
+
);
|
|
1039
|
+
|
|
1040
|
+
return {
|
|
1041
|
+
targetExchange: this.config.router,
|
|
1042
|
+
payload,
|
|
1043
|
+
networkFee: '0',
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
getDexParam(
|
|
1048
|
+
srcToken: Address,
|
|
1049
|
+
destToken: Address,
|
|
1050
|
+
srcAmount: NumberAsString,
|
|
1051
|
+
destAmount: NumberAsString,
|
|
1052
|
+
recipient: Address,
|
|
1053
|
+
data: UniswapV3Data,
|
|
1054
|
+
side: SwapSide,
|
|
1055
|
+
): DexExchangeParam {
|
|
1056
|
+
const swapFunction =
|
|
1057
|
+
side === SwapSide.SELL
|
|
1058
|
+
? UniswapV3Functions.exactInput
|
|
1059
|
+
: UniswapV3Functions.exactOutput;
|
|
1060
|
+
|
|
1061
|
+
const path = this._encodePath(data.path, side);
|
|
1062
|
+
|
|
1063
|
+
const swapFunctionParams: UniswapV3SimpleSwapParams =
|
|
1064
|
+
side === SwapSide.SELL
|
|
1065
|
+
? {
|
|
1066
|
+
recipient,
|
|
1067
|
+
deadline: getLocalDeadlineAsFriendlyPlaceholder(),
|
|
1068
|
+
amountIn: srcAmount,
|
|
1069
|
+
amountOutMinimum: destAmount,
|
|
1070
|
+
path,
|
|
1071
|
+
}
|
|
1072
|
+
: {
|
|
1073
|
+
recipient,
|
|
1074
|
+
deadline: getLocalDeadlineAsFriendlyPlaceholder(),
|
|
1075
|
+
amountOut: destAmount,
|
|
1076
|
+
amountInMaximum: srcAmount,
|
|
1077
|
+
path,
|
|
1078
|
+
};
|
|
1079
|
+
|
|
1080
|
+
const exchangeData = this.routerIface.encodeFunctionData(swapFunction, [
|
|
1081
|
+
swapFunctionParams,
|
|
1082
|
+
]);
|
|
1083
|
+
|
|
1084
|
+
return {
|
|
1085
|
+
needWrapNative: this.needWrapNative,
|
|
1086
|
+
dexFuncHasRecipient: true,
|
|
1087
|
+
exchangeData,
|
|
1088
|
+
targetExchange: this.config.router,
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
|
|
973
1092
|
async getSimpleParam(
|
|
974
1093
|
srcToken: string,
|
|
975
1094
|
destToken: string,
|
|
@@ -1249,6 +1368,61 @@ export class UniswapV3
|
|
|
1249
1368
|
: pack(types, _path);
|
|
1250
1369
|
}
|
|
1251
1370
|
|
|
1371
|
+
private _encodePathV6(
|
|
1372
|
+
path: {
|
|
1373
|
+
tokenIn: Address;
|
|
1374
|
+
tokenOut: Address;
|
|
1375
|
+
fee: NumberAsString;
|
|
1376
|
+
}[],
|
|
1377
|
+
side: SwapSide,
|
|
1378
|
+
) {
|
|
1379
|
+
let result = '0x';
|
|
1380
|
+
if (path.length === 0) {
|
|
1381
|
+
this.logger.error(
|
|
1382
|
+
`${this.dexKey}: Received invalid path=${path} for side=${side} to encode`,
|
|
1383
|
+
);
|
|
1384
|
+
return result;
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
if (side === SwapSide.SELL) {
|
|
1388
|
+
for (const p of path) {
|
|
1389
|
+
const poolEncoded = this._encodePool(p.tokenIn, p.tokenOut, p.fee);
|
|
1390
|
+
result += poolEncoded;
|
|
1391
|
+
}
|
|
1392
|
+
} else {
|
|
1393
|
+
// For buy order of pools should be reversed
|
|
1394
|
+
for (let i = path.length - 1; i >= 0; i--) {
|
|
1395
|
+
const p = path[i];
|
|
1396
|
+
const poolEncoded = this._encodePool(p.tokenIn, p.tokenOut, p.fee);
|
|
1397
|
+
result += poolEncoded;
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1401
|
+
return result;
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
private _encodePool(t0: Address, t1: Address, fee: NumberAsString) {
|
|
1405
|
+
// v6 expects weth for eth in pools
|
|
1406
|
+
if (isETHAddress(t0)) {
|
|
1407
|
+
t0 = this.dexHelper.config.data.wrappedNativeTokenAddress;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
if (isETHAddress(t1)) {
|
|
1411
|
+
t1 = this.dexHelper.config.data.wrappedNativeTokenAddress;
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1414
|
+
// contract expects tokens to be sorted, and direction switched in case sorting changes src/dest order
|
|
1415
|
+
const [tokenInSorted, tokenOutSorted] =
|
|
1416
|
+
BigInt(t0) > BigInt(t1) ? [t1, t0] : [t0, t1];
|
|
1417
|
+
|
|
1418
|
+
const directionEncoded = (tokenInSorted === t0 ? '8' : '0').padEnd(24, '0');
|
|
1419
|
+
const token0Encoded = tokenInSorted.slice(2).padEnd(64, '0');
|
|
1420
|
+
const token1Encoded = tokenOutSorted.slice(2).padEnd(64, '0');
|
|
1421
|
+
const feeEncoded = hexZeroPad(hexValue(parseInt(fee)), 20).slice(2);
|
|
1422
|
+
|
|
1423
|
+
return directionEncoded + token0Encoded + token1Encoded + feeEncoded;
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1252
1426
|
releaseResources() {
|
|
1253
1427
|
if (this.intervalTask !== undefined) {
|
|
1254
1428
|
clearInterval(this.intervalTask);
|
package/src/dex/uniswap-v3.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { Interface, JsonFragment } from '@ethersproject/abi';
|
|
2
2
|
import { pack } from '@ethersproject/solidity';
|
|
3
3
|
import { Network, SwapSide } from '../constants';
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
AdapterExchangeParam,
|
|
6
|
+
Address,
|
|
7
|
+
DexExchangeParam,
|
|
8
|
+
SimpleExchangeParam,
|
|
9
|
+
} from '../types';
|
|
5
10
|
import { IDexTxBuilder } from './idex';
|
|
6
11
|
import {
|
|
7
12
|
getLocalDeadlineAsFriendlyPlaceholder,
|
|
@@ -179,4 +184,50 @@ export class UniswapV3
|
|
|
179
184
|
this.routerAddress,
|
|
180
185
|
);
|
|
181
186
|
}
|
|
187
|
+
|
|
188
|
+
getDexParam(
|
|
189
|
+
srcToken: Address,
|
|
190
|
+
destToken: Address,
|
|
191
|
+
srcAmount: NumberAsString,
|
|
192
|
+
destAmount: NumberAsString,
|
|
193
|
+
recipient: Address,
|
|
194
|
+
data: UniswapV3Data,
|
|
195
|
+
side: SwapSide,
|
|
196
|
+
): DexExchangeParam {
|
|
197
|
+
const swapFunction =
|
|
198
|
+
side === SwapSide.SELL
|
|
199
|
+
? UniswapV3Functions.exactInput
|
|
200
|
+
: UniswapV3Functions.exactOutput;
|
|
201
|
+
|
|
202
|
+
const path = this.encodePath(data.path, side);
|
|
203
|
+
|
|
204
|
+
const swapFunctionParams: UniswapV3Param =
|
|
205
|
+
side === SwapSide.SELL
|
|
206
|
+
? {
|
|
207
|
+
recipient,
|
|
208
|
+
deadline: getLocalDeadlineAsFriendlyPlaceholder(),
|
|
209
|
+
amountIn: srcAmount,
|
|
210
|
+
amountOutMinimum: destAmount,
|
|
211
|
+
path,
|
|
212
|
+
}
|
|
213
|
+
: {
|
|
214
|
+
recipient,
|
|
215
|
+
deadline: getLocalDeadlineAsFriendlyPlaceholder(),
|
|
216
|
+
amountOut: destAmount,
|
|
217
|
+
amountInMaximum: srcAmount,
|
|
218
|
+
path,
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const exchangeData = this.exchangeRouterInterface.encodeFunctionData(
|
|
222
|
+
swapFunction,
|
|
223
|
+
[swapFunctionParams],
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
needWrapNative: this.needWrapNative,
|
|
228
|
+
dexFuncHasRecipient: true,
|
|
229
|
+
exchangeData,
|
|
230
|
+
targetExchange: this.routerAddress,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
182
233
|
}
|
|
@@ -246,7 +246,7 @@ describe('Weth E2E', () => {
|
|
|
246
246
|
});
|
|
247
247
|
});
|
|
248
248
|
|
|
249
|
-
describe('Wmatic
|
|
249
|
+
describe('Wmatic Polygon_V6', () => {
|
|
250
250
|
const dexKey = 'Wmatic';
|
|
251
251
|
const network = Network.POLYGON;
|
|
252
252
|
|
|
@@ -269,8 +269,8 @@ describe('Weth E2E', () => {
|
|
|
269
269
|
const nativeHolder = holders[nativeTokenSymbol];
|
|
270
270
|
const wrappedHolder = holders[wrappedTokenSymbol];
|
|
271
271
|
|
|
272
|
-
describe('
|
|
273
|
-
const contractMethod = ContractMethod.
|
|
272
|
+
describe('SELL', () => {
|
|
273
|
+
const contractMethod = ContractMethod.swapExactAmountIn;
|
|
274
274
|
const side = SwapSide.SELL;
|
|
275
275
|
|
|
276
276
|
it('native -> wrapped', async () => {
|
|
@@ -300,41 +300,9 @@ describe('Weth E2E', () => {
|
|
|
300
300
|
);
|
|
301
301
|
});
|
|
302
302
|
});
|
|
303
|
-
describe('
|
|
304
|
-
const contractMethod = ContractMethod.
|
|
305
|
-
const side = SwapSide.
|
|
306
|
-
|
|
307
|
-
it('native -> wrapped', async () => {
|
|
308
|
-
await testE2E(
|
|
309
|
-
nativeToken,
|
|
310
|
-
wrappedToken,
|
|
311
|
-
nativeHolder,
|
|
312
|
-
nativeAmount,
|
|
313
|
-
side,
|
|
314
|
-
dexKey,
|
|
315
|
-
contractMethod,
|
|
316
|
-
network,
|
|
317
|
-
provider,
|
|
318
|
-
);
|
|
319
|
-
});
|
|
320
|
-
it('wrapped -> native', async () => {
|
|
321
|
-
await testE2E(
|
|
322
|
-
wrappedToken,
|
|
323
|
-
nativeToken,
|
|
324
|
-
wrappedHolder,
|
|
325
|
-
wrappedAmount,
|
|
326
|
-
side,
|
|
327
|
-
dexKey,
|
|
328
|
-
contractMethod,
|
|
329
|
-
network,
|
|
330
|
-
provider,
|
|
331
|
-
);
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
describe('MegaSwap SELL', () => {
|
|
336
|
-
const contractMethod = ContractMethod.megaSwap;
|
|
337
|
-
const side = SwapSide.SELL;
|
|
303
|
+
describe('BUY', () => {
|
|
304
|
+
const contractMethod = ContractMethod.swapExactAmountOut;
|
|
305
|
+
const side = SwapSide.BUY;
|
|
338
306
|
|
|
339
307
|
it('native -> wrapped', async () => {
|
|
340
308
|
await testE2E(
|
|
@@ -363,6 +331,69 @@ describe('Weth E2E', () => {
|
|
|
363
331
|
);
|
|
364
332
|
});
|
|
365
333
|
});
|
|
334
|
+
// describe('MultiSwap SELL', () => {
|
|
335
|
+
// const contractMethod = ContractMethod.multiSwap;
|
|
336
|
+
// const side = SwapSide.SELL;
|
|
337
|
+
|
|
338
|
+
// it('native -> wrapped', async () => {
|
|
339
|
+
// await testE2E(
|
|
340
|
+
// nativeToken,
|
|
341
|
+
// wrappedToken,
|
|
342
|
+
// nativeHolder,
|
|
343
|
+
// nativeAmount,
|
|
344
|
+
// side,
|
|
345
|
+
// dexKey,
|
|
346
|
+
// contractMethod,
|
|
347
|
+
// network,
|
|
348
|
+
// provider,
|
|
349
|
+
// );
|
|
350
|
+
// });
|
|
351
|
+
// it('wrapped -> native', async () => {
|
|
352
|
+
// await testE2E(
|
|
353
|
+
// wrappedToken,
|
|
354
|
+
// nativeToken,
|
|
355
|
+
// wrappedHolder,
|
|
356
|
+
// wrappedAmount,
|
|
357
|
+
// side,
|
|
358
|
+
// dexKey,
|
|
359
|
+
// contractMethod,
|
|
360
|
+
// network,
|
|
361
|
+
// provider,
|
|
362
|
+
// );
|
|
363
|
+
// });
|
|
364
|
+
// });
|
|
365
|
+
|
|
366
|
+
// describe('MegaSwap SELL', () => {
|
|
367
|
+
// const contractMethod = ContractMethod.megaSwap;
|
|
368
|
+
// const side = SwapSide.SELL;
|
|
369
|
+
|
|
370
|
+
// it('native -> wrapped', async () => {
|
|
371
|
+
// await testE2E(
|
|
372
|
+
// nativeToken,
|
|
373
|
+
// wrappedToken,
|
|
374
|
+
// nativeHolder,
|
|
375
|
+
// nativeAmount,
|
|
376
|
+
// side,
|
|
377
|
+
// dexKey,
|
|
378
|
+
// contractMethod,
|
|
379
|
+
// network,
|
|
380
|
+
// provider,
|
|
381
|
+
// );
|
|
382
|
+
// });
|
|
383
|
+
// it('wrapped -> native', async () => {
|
|
384
|
+
// await testE2E(
|
|
385
|
+
// wrappedToken,
|
|
386
|
+
// nativeToken,
|
|
387
|
+
// wrappedHolder,
|
|
388
|
+
// wrappedAmount,
|
|
389
|
+
// side,
|
|
390
|
+
// dexKey,
|
|
391
|
+
// contractMethod,
|
|
392
|
+
// network,
|
|
393
|
+
// provider,
|
|
394
|
+
// );
|
|
395
|
+
// });
|
|
396
|
+
// });
|
|
366
397
|
});
|
|
367
398
|
|
|
368
399
|
describe('Wftm Fantom', () => {
|
package/src/dex/weth/weth.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
SimpleExchangeParam,
|
|
8
8
|
PoolLiquidity,
|
|
9
9
|
Logger,
|
|
10
|
+
DexExchangeParam,
|
|
10
11
|
} from '../../types';
|
|
11
12
|
import { SwapSide, Network } from '../../constants';
|
|
12
13
|
import * as CALLDATA_GAS_COST from '../../calldata-gas-cost';
|
|
@@ -24,6 +25,7 @@ import {
|
|
|
24
25
|
import { SimpleExchange } from '../simple-exchange';
|
|
25
26
|
import { Adapters, WethConfig } from './config';
|
|
26
27
|
import { BI_POWS } from '../../bigint-constants';
|
|
28
|
+
import { NumberAsString } from '@paraswap/core';
|
|
27
29
|
|
|
28
30
|
export class Weth
|
|
29
31
|
extends SimpleExchange
|
|
@@ -148,6 +150,29 @@ export class Weth
|
|
|
148
150
|
);
|
|
149
151
|
}
|
|
150
152
|
|
|
153
|
+
getDexParam(
|
|
154
|
+
srcToken: Address,
|
|
155
|
+
destToken: Address,
|
|
156
|
+
srcAmount: NumberAsString,
|
|
157
|
+
destAmount: NumberAsString,
|
|
158
|
+
recipient: Address,
|
|
159
|
+
data: WethData,
|
|
160
|
+
side: SwapSide,
|
|
161
|
+
): DexExchangeParam {
|
|
162
|
+
const swapData = isETHAddress(srcToken)
|
|
163
|
+
? this.erc20Interface.encodeFunctionData(WethFunctions.deposit)
|
|
164
|
+
: this.erc20Interface.encodeFunctionData(WethFunctions.withdraw, [
|
|
165
|
+
srcAmount,
|
|
166
|
+
]);
|
|
167
|
+
|
|
168
|
+
return {
|
|
169
|
+
needWrapNative: this.needWrapNative,
|
|
170
|
+
dexFuncHasRecipient: false,
|
|
171
|
+
exchangeData: swapData,
|
|
172
|
+
targetExchange: this.address,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
151
176
|
async getTopPoolsForToken(
|
|
152
177
|
tokenAddress: Address,
|
|
153
178
|
limit: number,
|
|
@@ -181,11 +206,10 @@ export class Weth
|
|
|
181
206
|
}
|
|
182
207
|
|
|
183
208
|
if (needWithdraw || destAmount !== '0') {
|
|
184
|
-
const opType = WethFunctions.
|
|
185
|
-
const withdrawWethData = this.
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
);
|
|
209
|
+
const opType = WethFunctions.withdraw;
|
|
210
|
+
const withdrawWethData = this.erc20Interface.encodeFunctionData(opType, [
|
|
211
|
+
destAmount,
|
|
212
|
+
]);
|
|
189
213
|
|
|
190
214
|
withdraw = {
|
|
191
215
|
callee: this.augustusAddress,
|
|
@@ -26,9 +26,10 @@ function testForNetwork(
|
|
|
26
26
|
[
|
|
27
27
|
SwapSide.SELL,
|
|
28
28
|
[
|
|
29
|
-
ContractMethod.
|
|
30
|
-
ContractMethod.
|
|
31
|
-
ContractMethod.
|
|
29
|
+
ContractMethod.swapExactAmountIn,
|
|
30
|
+
// ContractMethod.simpleSwap,
|
|
31
|
+
// ContractMethod.multiSwap,
|
|
32
|
+
// ContractMethod.megaSwap,
|
|
32
33
|
],
|
|
33
34
|
],
|
|
34
35
|
]);
|
|
@@ -116,7 +117,7 @@ describe('Wombat E2E', () => {
|
|
|
116
117
|
testForNetwork(network, dexKey, pairs);
|
|
117
118
|
});
|
|
118
119
|
|
|
119
|
-
describe('
|
|
120
|
+
describe('Arbitrum_V6', () => {
|
|
120
121
|
const network = Network.ARBITRUM;
|
|
121
122
|
|
|
122
123
|
const pairs: Pairs = [
|
package/src/dex/wombat/wombat.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { AsyncOrSync, DeepReadonly } from 'ts-essentials';
|
|
2
2
|
import { Interface } from '@ethersproject/abi';
|
|
3
|
-
import { SwapSide } from '@paraswap/core';
|
|
3
|
+
import { NumberAsString, SwapSide } from '@paraswap/core';
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
AdapterExchangeParam,
|
|
7
7
|
Address,
|
|
8
|
+
DexExchangeParam,
|
|
8
9
|
ExchangePrices,
|
|
9
10
|
Logger,
|
|
10
11
|
PoolLiquidity,
|
|
@@ -311,6 +312,36 @@ export class Wombat extends SimpleExchange implements IDex<WombatData> {
|
|
|
311
312
|
);
|
|
312
313
|
}
|
|
313
314
|
|
|
315
|
+
getDexParam(
|
|
316
|
+
srcToken: Address,
|
|
317
|
+
destToken: Address,
|
|
318
|
+
srcAmount: NumberAsString,
|
|
319
|
+
destAmount: NumberAsString,
|
|
320
|
+
recipient: Address,
|
|
321
|
+
data: WombatData,
|
|
322
|
+
side: SwapSide,
|
|
323
|
+
): DexExchangeParam {
|
|
324
|
+
if (side === SwapSide.BUY) throw new Error(`Buy not supported`);
|
|
325
|
+
const { exchange } = data;
|
|
326
|
+
|
|
327
|
+
// Encode here the transaction arguments
|
|
328
|
+
const swapData = Wombat.poolInterface.encodeFunctionData('swap', [
|
|
329
|
+
srcToken,
|
|
330
|
+
destToken,
|
|
331
|
+
srcAmount,
|
|
332
|
+
destAmount,
|
|
333
|
+
recipient,
|
|
334
|
+
getLocalDeadlineAsFriendlyPlaceholder(),
|
|
335
|
+
]);
|
|
336
|
+
|
|
337
|
+
return {
|
|
338
|
+
needWrapNative: this.needWrapNative,
|
|
339
|
+
dexFuncHasRecipient: true,
|
|
340
|
+
exchangeData: swapData,
|
|
341
|
+
targetExchange: exchange,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
|
|
314
345
|
// This is called once before getTopPoolsForToken is
|
|
315
346
|
// called for multiple tokens. This can be helpful to
|
|
316
347
|
// update common state required for calculating
|
|
@@ -27,9 +27,10 @@ function testForNetwork(
|
|
|
27
27
|
[
|
|
28
28
|
SwapSide.SELL,
|
|
29
29
|
[
|
|
30
|
-
ContractMethod.
|
|
31
|
-
ContractMethod.
|
|
32
|
-
ContractMethod.
|
|
30
|
+
ContractMethod.swapExactAmountIn,
|
|
31
|
+
// ContractMethod.simpleSwap,
|
|
32
|
+
// ContractMethod.multiSwap,
|
|
33
|
+
// ContractMethod.megaSwap,
|
|
33
34
|
],
|
|
34
35
|
],
|
|
35
36
|
]);
|
|
@@ -130,7 +131,7 @@ describe('WooFiV2 E2E', () => {
|
|
|
130
131
|
);
|
|
131
132
|
});
|
|
132
133
|
|
|
133
|
-
describe('
|
|
134
|
+
describe('Polygon_V6', () => {
|
|
134
135
|
const network = Network.POLYGON;
|
|
135
136
|
|
|
136
137
|
const baseATokenSymbol = 'WMATIC';
|