@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
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GenericSwapTransactionBuilder = void 0;
|
|
7
|
+
const ethers_1 = require("ethers");
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
const abi_1 = require("@ethersproject/abi");
|
|
10
|
+
const ethers_2 = require("ethers");
|
|
11
|
+
const ABI_json_1 = __importDefault(require("./abi/augustus-v6/ABI.json"));
|
|
12
|
+
const utils_1 = require("./utils");
|
|
13
|
+
const weth_1 = require("./dex/weth/weth");
|
|
14
|
+
const erc20_json_1 = __importDefault(require("./abi/erc20.json"));
|
|
15
|
+
const ExecutorDetector_1 = require("./executor/ExecutorDetector");
|
|
16
|
+
const { utils: { hexlify, hexConcat, hexZeroPad }, } = ethers_2.ethers;
|
|
17
|
+
class GenericSwapTransactionBuilder {
|
|
18
|
+
constructor(dexAdapterService, wExchangeNetworkToKey = weth_1.Weth.dexKeysWithNetwork.reduce((prev, current) => {
|
|
19
|
+
for (const network of current.networks) {
|
|
20
|
+
prev[network] = current.key;
|
|
21
|
+
}
|
|
22
|
+
return prev;
|
|
23
|
+
}, {})) {
|
|
24
|
+
this.dexAdapterService = dexAdapterService;
|
|
25
|
+
this.wExchangeNetworkToKey = wExchangeNetworkToKey;
|
|
26
|
+
this.abiCoder = new abi_1.AbiCoder();
|
|
27
|
+
this.erc20Interface = new abi_1.Interface(erc20_json_1.default);
|
|
28
|
+
this.augustusV6Interface = new abi_1.Interface(ABI_json_1.default);
|
|
29
|
+
this.augustusV6Address =
|
|
30
|
+
this.dexAdapterService.dexHelper.config.data.augustusV6Address;
|
|
31
|
+
this.executorDetector = new ExecutorDetector_1.ExecutorDetector(this.dexAdapterService.dexHelper);
|
|
32
|
+
}
|
|
33
|
+
getDepositWithdrawWethCallData(srcAmountWeth, destAmountWeth, side) {
|
|
34
|
+
if (srcAmountWeth === 0n && destAmountWeth === 0n)
|
|
35
|
+
return;
|
|
36
|
+
return this.dexAdapterService.getTxBuilderDexByKey(this.wExchangeNetworkToKey[this.dexAdapterService.network]).getDepositWithdrawParam(srcAmountWeth.toString(), destAmountWeth.toString(), side);
|
|
37
|
+
}
|
|
38
|
+
async buildCalls(priceRoute, minMaxAmount, bytecodeBuilder, userAddress) {
|
|
39
|
+
const side = priceRoute.side;
|
|
40
|
+
const rawDexParams = await Promise.all(priceRoute.bestRoute.flatMap((route, routeIndex) => route.swaps.flatMap((swap, swapIndex) => swap.swapExchanges.map(async (se) => {
|
|
41
|
+
const dex = this.dexAdapterService.getTxBuilderDexByKey(se.exchange);
|
|
42
|
+
const { srcToken, destToken, srcAmount, destAmount, recipient, wethDeposit, wethWithdraw, } = this.getDexCallsParams(priceRoute, routeIndex, swap, swapIndex, se, minMaxAmount, dex, bytecodeBuilder.getAddress());
|
|
43
|
+
const dexParams = await dex.getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, se.data, side, {
|
|
44
|
+
isGlobalSrcToken: priceRoute.srcToken.toLowerCase() === srcToken.toLowerCase(),
|
|
45
|
+
isGlobalDestToken: priceRoute.destToken.toLowerCase() ===
|
|
46
|
+
destToken.toLowerCase(),
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
dexParams,
|
|
50
|
+
wethDeposit,
|
|
51
|
+
wethWithdraw,
|
|
52
|
+
};
|
|
53
|
+
}))));
|
|
54
|
+
const { exchangeParams, srcAmountWethToDeposit, destAmountWethToWithdraw } = await rawDexParams.reduce((acc, se) => {
|
|
55
|
+
acc.srcAmountWethToDeposit += BigInt(se.wethDeposit);
|
|
56
|
+
acc.destAmountWethToWithdraw += BigInt(se.wethWithdraw);
|
|
57
|
+
acc.exchangeParams.push(se.dexParams);
|
|
58
|
+
return acc;
|
|
59
|
+
}, {
|
|
60
|
+
exchangeParams: [],
|
|
61
|
+
srcAmountWethToDeposit: 0n,
|
|
62
|
+
destAmountWethToWithdraw: 0n,
|
|
63
|
+
});
|
|
64
|
+
const maybeWethCallData = this.getDepositWithdrawWethCallData(srcAmountWethToDeposit, destAmountWethToWithdraw, side);
|
|
65
|
+
const buildExchangeParams = await this.addDexExchangeApproveParams(bytecodeBuilder, priceRoute, exchangeParams, maybeWethCallData);
|
|
66
|
+
return bytecodeBuilder.buildByteCode(priceRoute, buildExchangeParams, userAddress, maybeWethCallData);
|
|
67
|
+
}
|
|
68
|
+
async _build(priceRoute, minMaxAmount, userAddress, referrerAddress, partnerAddress, partnerFeePercent, takeSurplus, isCapSurplus, beneficiary, permit, deadline, uuid) {
|
|
69
|
+
const executorName = this.executorDetector.getExecutorByPriceRoute(priceRoute);
|
|
70
|
+
const bytecodeBuilder = this.executorDetector.getBytecodeBuilder(executorName);
|
|
71
|
+
const bytecode = await this.buildCalls(priceRoute, minMaxAmount, bytecodeBuilder, userAddress);
|
|
72
|
+
const side = priceRoute.side;
|
|
73
|
+
const isSell = side === constants_1.SwapSide.SELL;
|
|
74
|
+
const partnerAndFee = this.buildFeesV6({
|
|
75
|
+
referrerAddress,
|
|
76
|
+
partnerAddress,
|
|
77
|
+
partnerFeePercent,
|
|
78
|
+
takeSurplus,
|
|
79
|
+
isCapSurplus,
|
|
80
|
+
priceRoute,
|
|
81
|
+
});
|
|
82
|
+
const swapParams = [
|
|
83
|
+
bytecodeBuilder.getAddress(),
|
|
84
|
+
[
|
|
85
|
+
priceRoute.srcToken,
|
|
86
|
+
priceRoute.destToken,
|
|
87
|
+
isSell ? priceRoute.srcAmount : minMaxAmount,
|
|
88
|
+
isSell ? minMaxAmount : priceRoute.destAmount,
|
|
89
|
+
isSell ? priceRoute.destAmount : priceRoute.srcAmount,
|
|
90
|
+
hexConcat([
|
|
91
|
+
hexZeroPad((0, utils_1.uuidToBytes16)(uuid), 16),
|
|
92
|
+
hexZeroPad(hexlify(priceRoute.blockNumber), 16),
|
|
93
|
+
]),
|
|
94
|
+
beneficiary,
|
|
95
|
+
],
|
|
96
|
+
partnerAndFee,
|
|
97
|
+
permit,
|
|
98
|
+
bytecode,
|
|
99
|
+
];
|
|
100
|
+
const encoder = (...params) => this.augustusV6Interface.encodeFunctionData(isSell ? 'swapExactAmountIn' : 'swapExactAmountOut', params);
|
|
101
|
+
return {
|
|
102
|
+
encoder,
|
|
103
|
+
params: swapParams,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
// TODO: Improve
|
|
107
|
+
async _buildDirect(priceRoute, minMaxAmount, referrerAddress, partnerAddress, partnerFeePercent, takeSurplus, isCapSurplus, permit, uuid, beneficiary) {
|
|
108
|
+
if (priceRoute.bestRoute.length !== 1 ||
|
|
109
|
+
priceRoute.bestRoute[0].percent !== 100 ||
|
|
110
|
+
priceRoute.bestRoute[0].swaps.length !== 1 ||
|
|
111
|
+
priceRoute.bestRoute[0].swaps[0].swapExchanges.length !== 1 ||
|
|
112
|
+
priceRoute.bestRoute[0].swaps[0].swapExchanges[0].percent !== 100)
|
|
113
|
+
throw new Error(`DirectSwap invalid bestRoute`);
|
|
114
|
+
const dexName = priceRoute.bestRoute[0].swaps[0].swapExchanges[0].exchange;
|
|
115
|
+
if (!dexName)
|
|
116
|
+
throw new Error(`Invalid dex name`);
|
|
117
|
+
const dex = this.dexAdapterService.getTxBuilderDexByKey(dexName);
|
|
118
|
+
if (!dex)
|
|
119
|
+
throw new Error(`Failed to find dex : ${dexName}`);
|
|
120
|
+
if (!dex.getDirectParamV6)
|
|
121
|
+
throw new Error(`Invalid DEX: dex should have getDirectParamV6: ${dexName}`);
|
|
122
|
+
const swapExchange = priceRoute.bestRoute[0].swaps[0].swapExchanges[0];
|
|
123
|
+
const srcAmount = priceRoute.side === constants_1.SwapSide.SELL ? swapExchange.srcAmount : minMaxAmount;
|
|
124
|
+
const destAmount = priceRoute.side === constants_1.SwapSide.SELL
|
|
125
|
+
? minMaxAmount
|
|
126
|
+
: swapExchange.destAmount;
|
|
127
|
+
const expectedAmount = priceRoute.side === constants_1.SwapSide.SELL
|
|
128
|
+
? priceRoute.destAmount
|
|
129
|
+
: priceRoute.srcAmount;
|
|
130
|
+
const partnerAndFee = this.buildFeesV6({
|
|
131
|
+
referrerAddress,
|
|
132
|
+
partnerAddress,
|
|
133
|
+
partnerFeePercent,
|
|
134
|
+
takeSurplus,
|
|
135
|
+
isCapSurplus,
|
|
136
|
+
priceRoute,
|
|
137
|
+
});
|
|
138
|
+
return dex.getDirectParamV6(priceRoute.srcToken, priceRoute.destToken, srcAmount, destAmount, expectedAmount, swapExchange.data, priceRoute.side, permit, uuid, partnerAndFee, beneficiary, priceRoute.blockNumber, priceRoute.contractMethod);
|
|
139
|
+
}
|
|
140
|
+
buildFeesV6({ referrerAddress, priceRoute, takeSurplus, isCapSurplus, partnerAddress, partnerFeePercent, skipBlacklist = false, }) {
|
|
141
|
+
const partnerAndFee = referrerAddress
|
|
142
|
+
? this.packPartnerAndFeeData({
|
|
143
|
+
partner: referrerAddress,
|
|
144
|
+
feePercent: '0',
|
|
145
|
+
isTakeSurplus: takeSurplus,
|
|
146
|
+
isCapSurplus,
|
|
147
|
+
isReferral: true,
|
|
148
|
+
isSkipBlacklist: skipBlacklist,
|
|
149
|
+
})
|
|
150
|
+
: this.packPartnerAndFeeData({
|
|
151
|
+
partner: partnerAddress,
|
|
152
|
+
feePercent: partnerFeePercent,
|
|
153
|
+
isTakeSurplus: takeSurplus,
|
|
154
|
+
isCapSurplus,
|
|
155
|
+
isSkipBlacklist: skipBlacklist,
|
|
156
|
+
isReferral: false,
|
|
157
|
+
});
|
|
158
|
+
return partnerAndFee;
|
|
159
|
+
}
|
|
160
|
+
async build({ priceRoute, minMaxAmount, userAddress, referrerAddress, partnerAddress, partnerFeePercent, takeSurplus, isCapSurplus, gasPrice, maxFeePerGas, maxPriorityFeePerGas, permit, deadline, uuid, beneficiary, onlyParams = false, }) {
|
|
161
|
+
const _beneficiary = beneficiary && beneficiary !== constants_1.NULL_ADDRESS ? beneficiary : userAddress;
|
|
162
|
+
let encoder;
|
|
163
|
+
let params;
|
|
164
|
+
if (this.dexAdapterService.isDirectFunctionNameV6(priceRoute.contractMethod)) {
|
|
165
|
+
({ encoder, params } = await this._buildDirect(priceRoute, minMaxAmount, referrerAddress, partnerAddress, partnerFeePercent, takeSurplus ?? false, isCapSurplus ?? true, permit || '0x', uuid, _beneficiary));
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
({ encoder, params } = await this._build(priceRoute, minMaxAmount, userAddress, referrerAddress, partnerAddress, partnerFeePercent, takeSurplus ?? false, isCapSurplus ?? true, _beneficiary, permit || '0x', deadline, uuid));
|
|
169
|
+
}
|
|
170
|
+
const value = (priceRoute.srcToken.toLowerCase() === constants_1.ETHER_ADDRESS.toLowerCase()
|
|
171
|
+
? BigInt(priceRoute.side === constants_1.SwapSide.SELL
|
|
172
|
+
? priceRoute.srcAmount
|
|
173
|
+
: minMaxAmount)
|
|
174
|
+
: BigInt(0)).toString();
|
|
175
|
+
return {
|
|
176
|
+
from: userAddress,
|
|
177
|
+
to: this.dexAdapterService.dexHelper.config.data.augustusV6Address,
|
|
178
|
+
value,
|
|
179
|
+
data: encoder.apply(null, params),
|
|
180
|
+
gasPrice,
|
|
181
|
+
maxFeePerGas,
|
|
182
|
+
maxPriorityFeePerGas,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
packPartnerAndFeeData({ partner, feePercent, isTakeSurplus, isCapSurplus, isReferral, isSkipBlacklist, }) {
|
|
186
|
+
// Partner address shifted left to make room for flags and fee percent
|
|
187
|
+
const partialFeeCodeWithPartnerAddress = ethers_1.BigNumber.from(partner).shl(96);
|
|
188
|
+
let partialFeeCodeWithBitFlags = ethers_1.BigNumber.from(0); // default 0 is safe if none the conditions pass
|
|
189
|
+
const isFixedFees = !ethers_1.BigNumber.from(feePercent).isZero();
|
|
190
|
+
if (isFixedFees) {
|
|
191
|
+
// Ensure feePercent fits within the FEE_PERCENT_IN_BASIS_POINTS_MASK range
|
|
192
|
+
partialFeeCodeWithBitFlags = ethers_1.BigNumber.from(feePercent).and(constants_1.FEE_PERCENT_IN_BASIS_POINTS_MASK);
|
|
193
|
+
// Apply flags using bitwise OR with the appropriate masks
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
if (isTakeSurplus) {
|
|
197
|
+
partialFeeCodeWithBitFlags =
|
|
198
|
+
partialFeeCodeWithBitFlags.or(constants_1.IS_TAKE_SURPLUS_MASK);
|
|
199
|
+
}
|
|
200
|
+
else if (isReferral) {
|
|
201
|
+
partialFeeCodeWithBitFlags =
|
|
202
|
+
partialFeeCodeWithBitFlags.or(constants_1.IS_REFERRAL_MASK);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
if (isSkipBlacklist) {
|
|
206
|
+
partialFeeCodeWithBitFlags = partialFeeCodeWithBitFlags.or(constants_1.IS_SKIP_BLACKLIST_MASK);
|
|
207
|
+
}
|
|
208
|
+
if (isCapSurplus) {
|
|
209
|
+
partialFeeCodeWithBitFlags =
|
|
210
|
+
partialFeeCodeWithBitFlags.or(constants_1.IS_CAP_SURPLUS_MASK);
|
|
211
|
+
}
|
|
212
|
+
// Combine partnerBigInt and feePercentBigInt
|
|
213
|
+
const feeCode = partialFeeCodeWithPartnerAddress.or(partialFeeCodeWithBitFlags);
|
|
214
|
+
return feeCode.toString();
|
|
215
|
+
}
|
|
216
|
+
getExecutionContractAddress(priceRoute) {
|
|
217
|
+
const isDirectMethod = this.dexAdapterService.isDirectFunctionNameV6(priceRoute.contractMethod);
|
|
218
|
+
if (isDirectMethod)
|
|
219
|
+
return this.augustusV6Address;
|
|
220
|
+
const executorName = this.executorDetector.getExecutorByPriceRoute(priceRoute);
|
|
221
|
+
const bytecodeBuilder = this.executorDetector.getBytecodeBuilder(executorName);
|
|
222
|
+
return bytecodeBuilder.getAddress();
|
|
223
|
+
}
|
|
224
|
+
getDexCallsParams(priceRoute, routeIndex, swap, swapIndex, se, minMaxAmount, dex, executionContractAddress) {
|
|
225
|
+
const wethAddress = this.dexAdapterService.dexHelper.config.data.wrappedNativeTokenAddress;
|
|
226
|
+
const side = priceRoute.side;
|
|
227
|
+
const isMegaSwap = priceRoute.bestRoute.length > 1;
|
|
228
|
+
const isMultiSwap = !isMegaSwap && priceRoute.bestRoute[0].swaps.length > 1;
|
|
229
|
+
const isLastSwap = swapIndex === priceRoute.bestRoute[routeIndex].swaps.length - 1;
|
|
230
|
+
let _src = swap.srcToken;
|
|
231
|
+
let wethDeposit = 0n;
|
|
232
|
+
let _dest = swap.destToken;
|
|
233
|
+
let wethWithdraw = 0n;
|
|
234
|
+
// For case of buy apply slippage is applied to srcAmount in equal proportion as the complete swap
|
|
235
|
+
// This assumes that the sum of all swaps srcAmount would sum to priceRoute.srcAmount
|
|
236
|
+
// Also that it is a direct swap.
|
|
237
|
+
const _srcAmount = swapIndex > 0 ||
|
|
238
|
+
side === constants_1.SwapSide.SELL ||
|
|
239
|
+
this.dexAdapterService.getDexKeySpecial(se.exchange) === 'zerox'
|
|
240
|
+
? se.srcAmount
|
|
241
|
+
: ((BigInt(se.srcAmount) * BigInt(minMaxAmount)) /
|
|
242
|
+
BigInt(priceRoute.srcAmount)).toString();
|
|
243
|
+
// In case of sell the destAmount is set to minimum (1) as
|
|
244
|
+
// even if the individual dex is rekt by slippage the swap
|
|
245
|
+
// should work if the final slippage check passes.
|
|
246
|
+
const _destAmount = side === constants_1.SwapSide.SELL ? '1' : se.destAmount;
|
|
247
|
+
if ((0, utils_1.isETHAddress)(swap.srcToken) && dex.needWrapNative) {
|
|
248
|
+
_src = wethAddress;
|
|
249
|
+
wethDeposit = BigInt(_srcAmount);
|
|
250
|
+
}
|
|
251
|
+
const forceUnwrap = (0, utils_1.isETHAddress)(swap.destToken) &&
|
|
252
|
+
(isMultiSwap || isMegaSwap) &&
|
|
253
|
+
!dex.needWrapNative &&
|
|
254
|
+
!isLastSwap;
|
|
255
|
+
if (((0, utils_1.isETHAddress)(swap.destToken) && dex.needWrapNative) || forceUnwrap) {
|
|
256
|
+
_dest = forceUnwrap && !dex.needWrapNative ? _dest : wethAddress;
|
|
257
|
+
wethWithdraw = BigInt(se.destAmount);
|
|
258
|
+
}
|
|
259
|
+
const needToWithdrawAfterSwap = _dest === wethAddress && wethWithdraw;
|
|
260
|
+
return {
|
|
261
|
+
srcToken: _src,
|
|
262
|
+
destToken: _dest,
|
|
263
|
+
recipient: needToWithdrawAfterSwap || !isLastSwap
|
|
264
|
+
? executionContractAddress
|
|
265
|
+
: this.dexAdapterService.dexHelper.config.data.augustusV6Address,
|
|
266
|
+
srcAmount: _srcAmount,
|
|
267
|
+
destAmount: _destAmount,
|
|
268
|
+
wethDeposit,
|
|
269
|
+
wethWithdraw,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
async addDexExchangeApproveParams(bytecodeBuilder, priceRoute, dexExchangeParams, maybeWethCallData) {
|
|
273
|
+
const spender = bytecodeBuilder.getAddress();
|
|
274
|
+
const tokenTargetMapping = [];
|
|
275
|
+
let currentExchangeParamIndex = 0;
|
|
276
|
+
priceRoute.bestRoute.flatMap(route => route.swaps.flatMap(swap => swap.swapExchanges.map(async (se) => {
|
|
277
|
+
const curExchangeParam = dexExchangeParams[currentExchangeParamIndex];
|
|
278
|
+
const approveParams = bytecodeBuilder.getApprovalTokenAndTarget(swap, curExchangeParam);
|
|
279
|
+
if (approveParams) {
|
|
280
|
+
tokenTargetMapping.push({
|
|
281
|
+
params: [approveParams.token, approveParams?.target],
|
|
282
|
+
exchangeParamIndex: currentExchangeParamIndex,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
currentExchangeParamIndex++;
|
|
286
|
+
})));
|
|
287
|
+
const approvals = await this.dexAdapterService.dexHelper.augustusApprovals.hasApprovals(spender, tokenTargetMapping.map(t => t.params));
|
|
288
|
+
const dexExchangeBuildParams = [
|
|
289
|
+
...dexExchangeParams,
|
|
290
|
+
];
|
|
291
|
+
approvals.forEach((alreadyApproved, index) => {
|
|
292
|
+
if (!alreadyApproved) {
|
|
293
|
+
const [token, target] = tokenTargetMapping[index].params;
|
|
294
|
+
const exchangeParamIndex = tokenTargetMapping[index].exchangeParamIndex;
|
|
295
|
+
const curExchangeParam = dexExchangeParams[exchangeParamIndex];
|
|
296
|
+
dexExchangeBuildParams[exchangeParamIndex] = {
|
|
297
|
+
...curExchangeParam,
|
|
298
|
+
approveData: { token, target },
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
return dexExchangeBuildParams;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
exports.GenericSwapTransactionBuilder = GenericSwapTransactionBuilder;
|
|
306
|
+
//# sourceMappingURL=generic-swap-transaction-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generic-swap-transaction-builder.js","sourceRoot":"","sources":["../src/generic-swap-transaction-builder.ts"],"names":[],"mappings":";;;;;;AASA,mCAAmC;AACnC,2CASqB;AACrB,4CAAyD;AACzD,mCAAgC;AAChC,0EAAuD;AACvD,mCAAsD;AAMtD,0CAAuC;AACvC,kEAAwC;AACxC,kEAA+D;AAI/D,MAAM,EACJ,KAAK,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,GAC1C,GAAG,eAAM,CAAC;AAWX,MAAa,6BAA6B;IAUxC,YACY,iBAAoC,EACpC,wBAAwB,WAAI,CAAC,kBAAkB,CAAC,MAAM,CAE9D,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;QAClB,KAAK,MAAM,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE;YACtC,IAAI,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;SAC7B;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,EAAE,CAAC;QARI,sBAAiB,GAAjB,iBAAiB,CAAmB;QACpC,0BAAqB,GAArB,qBAAqB,CAOzB;QAEN,IAAI,CAAC,QAAQ,GAAG,IAAI,cAAQ,EAAE,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,IAAI,eAAS,CAAC,oBAAQ,CAAC,CAAC;QAC9C,IAAI,CAAC,mBAAmB,GAAG,IAAI,eAAS,CAAC,kBAAa,CAAC,CAAC;QACxD,IAAI,CAAC,iBAAiB;YACpB,IAAI,CAAC,iBAAiB,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAkB,CAAC;QAClE,IAAI,CAAC,gBAAgB,GAAG,IAAI,mCAA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/B,CAAC;aACH;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,sBAAsB,CAAC;IAChC,CAAC;CACF;AAtnBD,sEAsnBC"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { DummyLimitOrderProvider, IDexHelper } from '../dex-helper';
|
|
2
|
-
import { TransactionBuilder } from '../transaction-builder';
|
|
3
2
|
import { PricingHelper } from '../pricing-helper';
|
|
4
3
|
import { DexAdapterService } from '../dex';
|
|
5
|
-
import { Address, Token,
|
|
6
|
-
import {
|
|
4
|
+
import { Address, OptimalRate, Token, TransferFeeParams, TxObject } from '../types';
|
|
5
|
+
import { ContractMethod } from '../constants';
|
|
6
|
+
import { SwapSide } from '@paraswap/core/build/constants';
|
|
7
|
+
import { GenericSwapTransactionBuilder } from '../generic-swap-transaction-builder';
|
|
8
|
+
import { AddressOrSymbol } from '@paraswap/sdk';
|
|
7
9
|
export interface IParaSwapSDK {
|
|
8
|
-
getPrices(from: Token, to: Token, amount: bigint, side: SwapSide, contractMethod: ContractMethod, _poolIdentifiers?:
|
|
10
|
+
getPrices(from: Token, to: Token, amount: bigint, side: SwapSide, contractMethod: ContractMethod, _poolIdentifiers?: {
|
|
11
|
+
[key: string]: string[] | null;
|
|
12
|
+
} | null, transferFees?: TransferFeeParams, forceRoute?: AddressOrSymbol[]): Promise<OptimalRate>;
|
|
9
13
|
buildTransaction(priceRoute: OptimalRate, minMaxAmount: BigInt, userAddress: Address): Promise<TxObject>;
|
|
10
14
|
initializePricing?(): Promise<void>;
|
|
11
15
|
releaseResources?(): Promise<void>;
|
|
@@ -15,14 +19,16 @@ export interface IParaSwapSDK {
|
|
|
15
19
|
}
|
|
16
20
|
export declare class LocalParaswapSDK implements IParaSwapSDK {
|
|
17
21
|
protected network: number;
|
|
18
|
-
protected dexKey: string;
|
|
19
22
|
dexHelper: IDexHelper;
|
|
20
23
|
dexAdapterService: DexAdapterService;
|
|
21
24
|
pricingHelper: PricingHelper;
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
dexKeys: string[];
|
|
26
|
+
transactionBuilder: GenericSwapTransactionBuilder;
|
|
27
|
+
constructor(network: number, dexKeys: string | string[], rpcUrl: string, limitOrderProvider?: DummyLimitOrderProvider);
|
|
24
28
|
initializePricing(): Promise<void>;
|
|
25
29
|
releaseResources(): Promise<void>;
|
|
26
|
-
getPrices(from: Token, to: Token, amount: bigint, side: SwapSide, contractMethod: ContractMethod, _poolIdentifiers?:
|
|
27
|
-
|
|
30
|
+
getPrices(from: Token, to: Token, amount: bigint, side: SwapSide, contractMethod: ContractMethod, _poolIdentifiers?: {
|
|
31
|
+
[key: string]: string[] | null;
|
|
32
|
+
} | null, transferFees?: TransferFeeParams, forceRoute?: AddressOrSymbol[]): Promise<OptimalRate>;
|
|
33
|
+
buildTransaction(priceRoute: OptimalRate, minMaxAmount: BigInt, userAddress: Address): Promise<TxObject>;
|
|
28
34
|
}
|
|
@@ -30,48 +30,57 @@ exports.LocalParaswapSDK = void 0;
|
|
|
30
30
|
const _ = __importStar(require("lodash"));
|
|
31
31
|
const dex_helper_1 = require("../dex-helper");
|
|
32
32
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
33
|
-
const transaction_builder_1 = require("../transaction-builder");
|
|
34
33
|
const pricing_helper_1 = require("../pricing-helper");
|
|
35
34
|
const dex_1 = require("../dex");
|
|
36
35
|
const constants_1 = require("../constants");
|
|
37
36
|
const limit_order_exchange_1 = require("../dex/limit-order-exchange");
|
|
38
37
|
const uuid_1 = require("uuid");
|
|
39
38
|
const constants_2 = require("@paraswap/core/build/constants");
|
|
39
|
+
const generic_swap_transaction_builder_1 = require("../generic-swap-transaction-builder");
|
|
40
|
+
const core_1 = require("@paraswap/core");
|
|
40
41
|
const chunks = 10;
|
|
41
42
|
class LocalParaswapSDK {
|
|
42
|
-
constructor(network,
|
|
43
|
+
constructor(network, dexKeys, rpcUrl, limitOrderProvider) {
|
|
43
44
|
this.network = network;
|
|
44
|
-
this.dexKey = dexKey;
|
|
45
45
|
this.dexHelper = new dex_helper_1.DummyDexHelper(this.network, rpcUrl);
|
|
46
46
|
this.dexAdapterService = new dex_1.DexAdapterService(this.dexHelper, this.network);
|
|
47
47
|
this.pricingHelper = new pricing_helper_1.PricingHelper(this.dexAdapterService, this.dexHelper.getLogger);
|
|
48
|
-
this.transactionBuilder = new
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
this.transactionBuilder = new generic_swap_transaction_builder_1.GenericSwapTransactionBuilder(this.dexAdapterService);
|
|
49
|
+
this.dexKeys = Array.isArray(dexKeys) ? dexKeys : [dexKeys];
|
|
50
|
+
this.dexKeys.map(dexKey => {
|
|
51
|
+
try {
|
|
52
|
+
const dex = this.dexAdapterService.getDexByKey(dexKey);
|
|
53
|
+
if (limitOrderProvider && dex instanceof limit_order_exchange_1.LimitOrderExchange) {
|
|
54
|
+
dex.limitOrderProvider = limitOrderProvider;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
// only for testing
|
|
59
|
+
delete this.dexKeys[this.dexKeys.indexOf(dexKey)];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
53
62
|
}
|
|
54
63
|
async initializePricing() {
|
|
55
64
|
const blockNumber = await this.dexHelper.web3Provider.eth.getBlockNumber();
|
|
56
|
-
await this.pricingHelper.initialize(blockNumber,
|
|
65
|
+
await this.pricingHelper.initialize(blockNumber, this.dexKeys);
|
|
57
66
|
}
|
|
58
67
|
async releaseResources() {
|
|
59
|
-
await this.pricingHelper.releaseResources(
|
|
68
|
+
await this.pricingHelper.releaseResources(this.dexKeys);
|
|
60
69
|
}
|
|
61
|
-
async getPrices(from, to, amount, side, contractMethod, _poolIdentifiers, transferFees) {
|
|
70
|
+
async getPrices(from, to, amount, side, contractMethod, _poolIdentifiers, transferFees, forceRoute) {
|
|
62
71
|
const blockNumber = await this.dexHelper.web3Provider.eth.getBlockNumber();
|
|
63
|
-
const poolIdentifiers =
|
|
64
|
-
(await this.pricingHelper.getPoolIdentifiers(from, to, side, blockNumber,
|
|
72
|
+
const poolIdentifiers = _poolIdentifiers ||
|
|
73
|
+
(await this.pricingHelper.getPoolIdentifiers(from, to, side, blockNumber, this.dexKeys));
|
|
65
74
|
const amounts = _.range(0, chunks + 1).map(i => (amount * BigInt(i)) / BigInt(chunks));
|
|
66
|
-
const poolPrices = await this.pricingHelper.getPoolPrices(from, to, amounts, side, blockNumber,
|
|
75
|
+
const poolPrices = await this.pricingHelper.getPoolPrices(from, to, amounts, side, blockNumber, this.dexKeys, poolIdentifiers, transferFees);
|
|
67
76
|
if (!poolPrices || poolPrices.length == 0)
|
|
68
|
-
throw new Error('Fail to get price for ' + this.
|
|
77
|
+
throw new Error('Fail to get price for ' + this.dexKeys);
|
|
69
78
|
const finalPrice = poolPrices[0];
|
|
70
79
|
const quoteAmount = finalPrice.prices[chunks];
|
|
71
|
-
const srcAmount = (side ===
|
|
72
|
-
const destAmount = (side ===
|
|
80
|
+
const srcAmount = (side === constants_2.SwapSide.SELL ? amount : quoteAmount).toString();
|
|
81
|
+
const destAmount = (side === constants_2.SwapSide.SELL ? quoteAmount : amount).toString();
|
|
73
82
|
// eslint-disable-next-line no-console
|
|
74
|
-
console.log(`Estimated gas cost for ${this.
|
|
83
|
+
console.log(`Estimated gas cost for ${this.dexKeys}: ${Array.isArray(finalPrice.gasCost)
|
|
75
84
|
? finalPrice.gasCost[finalPrice.gasCost.length - 1]
|
|
76
85
|
: finalPrice.gasCost}`);
|
|
77
86
|
const unoptimizedRate = {
|
|
@@ -110,8 +119,9 @@ class LocalParaswapSDK {
|
|
|
110
119
|
gasCost: '0',
|
|
111
120
|
others: [],
|
|
112
121
|
side,
|
|
113
|
-
|
|
114
|
-
|
|
122
|
+
contractAddress: '',
|
|
123
|
+
tokenTransferProxy: '',
|
|
124
|
+
version: core_1.ParaSwapVersion.V6,
|
|
115
125
|
};
|
|
116
126
|
const optimizedRate = this.pricingHelper.optimizeRate(unoptimizedRate);
|
|
117
127
|
return {
|
|
@@ -126,25 +136,31 @@ class LocalParaswapSDK {
|
|
|
126
136
|
async buildTransaction(priceRoute, minMaxAmount, userAddress) {
|
|
127
137
|
// Set deadline to be 10 min from now
|
|
128
138
|
let deadline = Number((Math.floor(Date.now() / 1000) + 10 * 60).toFixed());
|
|
129
|
-
const slippageFactor = new bignumber_js_1.default(minMaxAmount.toString()).div(priceRoute.side ===
|
|
139
|
+
const slippageFactor = new bignumber_js_1.default(minMaxAmount.toString()).div(priceRoute.side === constants_2.SwapSide.SELL
|
|
130
140
|
? priceRoute.destAmount
|
|
131
141
|
: priceRoute.srcAmount);
|
|
132
142
|
const contractMethod = priceRoute.contractMethod;
|
|
143
|
+
const executionContractAddress = this.transactionBuilder.getExecutionContractAddress(priceRoute);
|
|
133
144
|
// Call preprocessTransaction for each exchange before we build transaction
|
|
134
145
|
try {
|
|
135
|
-
priceRoute.bestRoute = await Promise.all(priceRoute.bestRoute.map(async (route) => {
|
|
136
|
-
route.swaps = await Promise.all(route.swaps.map(async (swap) => {
|
|
137
|
-
swap.swapExchanges = await Promise.all(swap.swapExchanges.map(async (
|
|
146
|
+
priceRoute.bestRoute = await Promise.all(priceRoute.bestRoute.map(async (route, routeIndex) => {
|
|
147
|
+
route.swaps = await Promise.all(route.swaps.map(async (swap, swapIndex) => {
|
|
148
|
+
swap.swapExchanges = await Promise.all(swap.swapExchanges.map(async (se) => {
|
|
138
149
|
// Search in dexLib dexes
|
|
139
|
-
const dexLibExchange = this.pricingHelper.getDexByKey(
|
|
150
|
+
const dexLibExchange = this.pricingHelper.getDexByKey(se.exchange);
|
|
151
|
+
const dex = this.dexAdapterService.getTxBuilderDexByKey(se.exchange);
|
|
140
152
|
if (dexLibExchange && dexLibExchange.preProcessTransaction) {
|
|
141
153
|
if (!dexLibExchange.getTokenFromAddress) {
|
|
142
154
|
throw new Error('If you want to test preProcessTransaction, first need to implement getTokenFromAddress function');
|
|
143
155
|
}
|
|
144
|
-
const
|
|
156
|
+
const { recipient } = this.transactionBuilder.getDexCallsParams(priceRoute, routeIndex, swap, swapIndex, se, minMaxAmount.toString(), dex, executionContractAddress);
|
|
157
|
+
const [preprocessedRoute, txInfo] = await dexLibExchange.preProcessTransaction(se, dexLibExchange.getTokenFromAddress(swap.srcToken), dexLibExchange.getTokenFromAddress(swap.destToken), priceRoute.side, {
|
|
145
158
|
slippageFactor,
|
|
146
159
|
txOrigin: userAddress,
|
|
160
|
+
executionContractAddress,
|
|
147
161
|
isDirectMethod: constants_2.DirectContractMethods.includes(contractMethod),
|
|
162
|
+
version: priceRoute.version,
|
|
163
|
+
recipient,
|
|
148
164
|
});
|
|
149
165
|
deadline =
|
|
150
166
|
txInfo.deadline && Number(txInfo.deadline) < deadline
|
|
@@ -152,7 +168,7 @@ class LocalParaswapSDK {
|
|
|
152
168
|
: deadline;
|
|
153
169
|
return preprocessedRoute;
|
|
154
170
|
}
|
|
155
|
-
return
|
|
171
|
+
return se;
|
|
156
172
|
}));
|
|
157
173
|
return swap;
|
|
158
174
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-paraswap-sdk.js","sourceRoot":"","sources":["../../src/implementations/local-paraswap-sdk.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA4B;AAC5B,8CAIuB;AACvB,gEAAqC;AACrC,
|
|
1
|
+
{"version":3,"file":"local-paraswap-sdk.js","sourceRoot":"","sources":["../../src/implementations/local-paraswap-sdk.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA4B;AAC5B,8CAIuB;AACvB,gEAAqC;AACrC,sDAAkD;AAClD,gCAA2C;AAQ3C,4CAA4D;AAC5D,sEAAiE;AACjE,+BAAkC;AAClC,8DAGwC;AACxC,0FAAoF;AAEpF,yCAAiD;AA6BjD,MAAM,MAAM,GAAG,EAAE,CAAC;AAElB,MAAa,gBAAgB;IAO3B,YACY,OAAe,EACzB,OAA0B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C,MAAM,CAAC,QAAQ,CAAC,GAAG,QAAQ;oCACnD,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;oCACzB,CAAC,CAAC,QAAQ,CAAC;4BAEf,OAAO,iBAAiB,CAAC;yBAC1B;wBACD,OAAO,EAAE,CAAC;oBACZ,CAAC,CAAC,CACH,CAAC;oBACF,OAAO,IAAI,CAAC;gBACd,CAAC,CAAC,CACH,CAAC;gBACF,OAAO,KAAK,CAAC;YACf,CAAC,CAAC,CACH,CAAC;SACH;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,CAAC;SACT;QAED,OAAO,MAAM,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC;YACzC,UAAU;YACV,YAAY,EAAE,YAAY,CAAC,QAAQ,EAAE;YACrC,WAAW;YACX,cAAc,EAAE,wBAAY;YAC5B,iBAAiB,EAAE,GAAG;YACtB,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE;YAC7B,IAAI,EAAE,IAAA,SAAI,GAAE;SACb,CAAC,CAAC;IACL,CAAC;CACF;AArQD,4CAqQC"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { TransactionBuilder } from './transaction-builder';
|
|
2
|
+
export { GenericSwapTransactionBuilder } from './generic-swap-transaction-builder';
|
|
2
3
|
export { PricingHelper } from './pricing-helper';
|
|
3
4
|
export { PoolsHelper } from './pools-helper';
|
|
4
5
|
export { DexAdapterService } from './dex';
|
package/build/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SlippageCheckError = exports.ConfigHelper = exports.StatefulEventSubscriber = exports.DexAdapterService = exports.PoolsHelper = exports.PricingHelper = exports.TransactionBuilder = void 0;
|
|
3
|
+
exports.SlippageCheckError = exports.ConfigHelper = exports.StatefulEventSubscriber = exports.DexAdapterService = exports.PoolsHelper = exports.PricingHelper = exports.GenericSwapTransactionBuilder = exports.TransactionBuilder = void 0;
|
|
4
4
|
var transaction_builder_1 = require("./transaction-builder");
|
|
5
5
|
Object.defineProperty(exports, "TransactionBuilder", { enumerable: true, get: function () { return transaction_builder_1.TransactionBuilder; } });
|
|
6
|
+
var generic_swap_transaction_builder_1 = require("./generic-swap-transaction-builder");
|
|
7
|
+
Object.defineProperty(exports, "GenericSwapTransactionBuilder", { enumerable: true, get: function () { return generic_swap_transaction_builder_1.GenericSwapTransactionBuilder; } });
|
|
6
8
|
var pricing_helper_1 = require("./pricing-helper");
|
|
7
9
|
Object.defineProperty(exports, "PricingHelper", { enumerable: true, get: function () { return pricing_helper_1.PricingHelper; } });
|
|
8
10
|
var pools_helper_1 = require("./pools-helper");
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAA2D;AAAlD,yHAAA,kBAAkB,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6DAA2D;AAAlD,yHAAA,kBAAkB,OAAA;AAC3B,uFAAmF;AAA1E,iJAAA,6BAA6B,OAAA;AAEtC,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AAEpB,6BAA0C;AAAjC,wGAAA,iBAAiB,OAAA;AAa1B,yEAAsE;AAA7D,oIAAA,uBAAuB,OAAA;AAgBhC,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AAErB,iDAA6D;AAApD,2GAAA,kBAAkB,OAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Address } from '@paraswap/core';
|
|
2
|
+
import { BigNumber } from 'ethers';
|
|
3
|
+
import { CurveV1SwapType } from '../../dex/curve-v1/types';
|
|
4
|
+
import { CurveV2SwapType } from '../../dex/curve-v2/types';
|
|
5
|
+
export declare const packCurveData: (address: Address, approve: boolean, wrapFlag: number, swapType: CurveV2SwapType | CurveV1SwapType) => BigNumber;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.packCurveData = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const packCurveData = (address, approve, wrapFlag, swapType) => {
|
|
6
|
+
let packedData = ethers_1.BigNumber.from(address);
|
|
7
|
+
packedData = packedData.or(ethers_1.BigNumber.from(approve ? 1 : 0).shl(160));
|
|
8
|
+
packedData = packedData.or(ethers_1.BigNumber.from(wrapFlag).shl(161));
|
|
9
|
+
packedData = packedData.or(ethers_1.BigNumber.from(swapType).shl(163));
|
|
10
|
+
return packedData;
|
|
11
|
+
};
|
|
12
|
+
exports.packCurveData = packCurveData;
|
|
13
|
+
//# sourceMappingURL=encoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encoder.js","sourceRoot":"","sources":["../../../src/lib/curve/encoder.ts"],"names":[],"mappings":";;;AACA,mCAAmC;AAI5B,MAAM,aAAa,GAAG,CAC3B,OAAgB,EAChB,OAAgB,EAChB,QAAgB,EAChB,QAA2C,EAChC,EAAE;IACb,IAAI,UAAU,GAAG,kBAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEzC,UAAU,GAAG,UAAU,CAAC,EAAE,CAAC,kBAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACrE,UAAU,GAAG,UAAU,CAAC,EAAE,CAAC,kBAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9D,UAAU,GAAG,UAAU,CAAC,EAAE,CAAC,kBAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAE9D,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAbW,QAAA,aAAa,iBAaxB"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { OptimalRate, Address } from './types';
|
|
1
|
+
import { OptimalRate, Address, OptimalSwap, OptimalSwapExchange } from './types';
|
|
2
2
|
import { RouterService } from './router';
|
|
3
3
|
import { DexAdapterService } from './dex';
|
|
4
|
+
import { IDexTxBuilder } from './dex/idex';
|
|
4
5
|
export declare class TransactionBuilder {
|
|
5
6
|
protected dexAdapterService: DexAdapterService;
|
|
6
7
|
routerService: RouterService;
|
|
8
|
+
augustusAddress: Address;
|
|
7
9
|
constructor(dexAdapterService: DexAdapterService);
|
|
8
10
|
build({ priceRoute, minMaxAmount, userAddress, referrerAddress, partnerAddress, partnerFeePercent, takeSurplus, gasPrice, maxFeePerGas, maxPriorityFeePerGas, permit, deadline, uuid, beneficiary, onlyParams, }: {
|
|
9
11
|
priceRoute: OptimalRate;
|
|
@@ -22,4 +24,14 @@ export declare class TransactionBuilder {
|
|
|
22
24
|
beneficiary?: Address;
|
|
23
25
|
onlyParams?: boolean;
|
|
24
26
|
}): Promise<any>;
|
|
27
|
+
getExecutionContractAddress(): Address;
|
|
28
|
+
getDexCallsParams(priceRoute: OptimalRate, routeIndex: number, swap: OptimalSwap, swapIndex: number, se: OptimalSwapExchange<any>, minMaxAmount: string, dex: IDexTxBuilder<any, any>, executionContractAddress: string): {
|
|
29
|
+
srcToken: Address;
|
|
30
|
+
destToken: Address;
|
|
31
|
+
recipient: Address;
|
|
32
|
+
srcAmount: string;
|
|
33
|
+
destAmount: string;
|
|
34
|
+
wethDeposit: bigint;
|
|
35
|
+
wethWithdraw: bigint;
|
|
36
|
+
};
|
|
25
37
|
}
|