@paraswap/dex-lib 2.42.23 → 2.42.24
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/.idea/aws.xml +17 -0
- package/.idea/codeStyles/Project.xml +19 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/paraswap-dex-lib.iml +9 -0
- package/.idea/prettier.xml +7 -0
- package/.idea/vcs.xml +6 -0
- package/build/abi/AugustusV6.abi.json +395 -0
- package/build/abi/algebra/AlgebraPool.abi.json +727 -0
- package/build/abi/curve-v1/StableSwapFRXETH.json +889 -0
- package/build/abi/curve-v1/StableSwapWBETH.json +1223 -0
- package/build/abi/sushiswap-v3/QuoterV2.json +267 -0
- package/build/abi/sushiswap-v3/RouterProcessor3.json +289 -0
- package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +193 -0
- package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3QuoterV2.abi.json +285 -0
- package/build/abi/uniswap-v3/pancakeswap-v3/PancakeswapV3Router.abi.json +583 -0
- package/build/abi/wBETH.json +1527 -0
- package/build/abi/woo-fi/WooFeeManager.abi.json +318 -0
- package/build/abi/woo-fi/WooPP.abi.json +548 -0
- package/build/abi/woo-fi/Wooracle.abi.json +260 -0
- package/build/dex/aave-v3/tokens/arbitrum.json +50 -0
- package/build/dex/aave-v3/tokens/avalanche.json +74 -0
- package/build/dex/aave-v3/tokens/fantom.json +62 -0
- package/build/dex/aave-v3/tokens/optimism.json +50 -0
- package/build/dex/aave-v3/tokens/polygon.json +116 -0
- package/build/dex/algebra/algebra-pool.d.ts +114 -0
- package/build/dex/algebra/algebra-pool.js +448 -0
- package/build/dex/algebra/algebra-pool.js.map +1 -0
- package/build/dex/balancer-v2/Gyro3Pool.d.ts +43 -0
- package/build/dex/balancer-v2/Gyro3Pool.js +160 -0
- package/build/dex/balancer-v2/Gyro3Pool.js.map +1 -0
- package/build/dex/balancer-v2/LinearMath.d.ts +88 -0
- package/build/dex/balancer-v2/LinearMath.js +285 -0
- package/build/dex/balancer-v2/LinearMath.js.map +1 -0
- package/build/dex/balancer-v2/LinearPool.d.ts +81 -0
- package/build/dex/balancer-v2/LinearPool.js +444 -0
- package/build/dex/balancer-v2/LinearPool.js.map +1 -0
- package/build/dex/balancer-v2/PhantomStablePool.d.ts +90 -0
- package/build/dex/balancer-v2/PhantomStablePool.js +418 -0
- package/build/dex/balancer-v2/PhantomStablePool.js.map +1 -0
- package/build/dex/balancer-v2/StableMath.d.ts +9 -0
- package/build/dex/balancer-v2/StableMath.js +272 -0
- package/build/dex/balancer-v2/StableMath.js.map +1 -0
- package/build/dex/balancer-v2/balancer-v2-pool.d.ts +140 -0
- package/build/dex/balancer-v2/balancer-v2-pool.js +647 -0
- package/build/dex/balancer-v2/balancer-v2-pool.js.map +1 -0
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.d.ts +33 -0
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.js +128 -0
- package/build/dex/balancer-v2/pools/gyro/Gyro3Pool.js.map +1 -0
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.d.ts +34 -0
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.js +151 -0
- package/build/dex/balancer-v2/pools/gyro/GyroEPool.js.map +1 -0
- package/build/dex/curve-v1/pools/frxETHpool.d.ts +7 -0
- package/build/dex/curve-v1/pools/frxETHpool.js +27 -0
- package/build/dex/curve-v1/pools/frxETHpool.js.map +1 -0
- package/build/dex/curve-v1/pools/wbETHpool.d.ts +29 -0
- package/build/dex/curve-v1/pools/wbETHpool.js +408 -0
- package/build/dex/curve-v1/pools/wbETHpool.js.map +1 -0
- package/build/dex/dexalot/constants.js +1 -1
- package/build/dex/lighter-v1/abi/erc20.json +222 -0
- package/build/dex/lighter-v1/abi/factory.json +291 -0
- package/build/dex/lighter-v1/abi/order_book.json +594 -0
- package/build/dex/lighter-v1/abi/order_book_helper.json +176 -0
- package/build/dex/lighter-v1/abi/router.json +488 -0
- package/build/dex/{my-test-dex → lighter-v1}/config.d.ts +1 -1
- package/build/dex/lighter-v1/config.js +17 -0
- package/build/dex/lighter-v1/config.js.map +1 -0
- package/build/dex/lighter-v1/constants.d.ts +2 -0
- package/build/dex/lighter-v1/constants.js +13 -0
- package/build/dex/lighter-v1/constants.js.map +1 -0
- package/build/dex/{my-test-dex/my-test-dex-pool.d.ts → lighter-v1/lighter-v1-pool.d.ts} +24 -6
- package/build/dex/lighter-v1/lighter-v1-pool.js +310 -0
- package/build/dex/lighter-v1/lighter-v1-pool.js.map +1 -0
- package/build/dex/{my-test-dex/my-test-dex.d.ts → lighter-v1/lighter-v1.d.ts} +18 -10
- package/build/dex/lighter-v1/lighter-v1.js +331 -0
- package/build/dex/lighter-v1/lighter-v1.js.map +1 -0
- package/build/dex/lighter-v1/types.d.ts +40 -0
- package/build/dex/{hello → lighter-v1}/types.js.map +1 -1
- package/build/dex/pancakeswap-v3/types.d.ts +14 -0
- package/build/dex/{my-test-dex → pancakeswap-v3}/types.js.map +1 -1
- package/build/dex/quickswap/camelot-v3.d.ts +6 -0
- package/build/dex/quickswap/camelot-v3.js +19 -0
- package/build/dex/quickswap/camelot-v3.js.map +1 -0
- package/build/dex/quickswap/zyberswap-v3.d.ts +6 -0
- package/build/dex/quickswap/zyberswap-v3.js +19 -0
- package/build/dex/quickswap/zyberswap-v3.js.map +1 -0
- package/build/dex/quickswap-v3.d.ts +21 -0
- package/build/dex/quickswap-v3.js +40 -0
- package/build/dex/quickswap-v3.js.map +1 -0
- package/build/dex/{wombat → ramses-v2}/config.d.ts +1 -1
- package/build/dex/ramses-v2/config.js +28 -0
- package/build/dex/ramses-v2/config.js.map +1 -0
- package/build/dex/{baseswap-v3 → ramses-v2}/constants.d.ts +1 -1
- package/build/dex/{baseswap-v3 → ramses-v2}/constants.js +1 -1
- package/build/dex/ramses-v2/constants.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/BitMath.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/FixedPoint128.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/FixedPoint96.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/FullMath.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/LiquidityMath.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/Oracle.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/SqrtPriceMath.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/SwapMath.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/Tick.d.ts +7 -0
- package/build/dex/ramses-v2/contract-math/Tick.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/TickBitMap.d.ts +8 -0
- package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/TickBitMap.js +3 -0
- package/build/dex/ramses-v2/contract-math/TickBitMap.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/TickMath.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/UnsafeMath.js.map +1 -0
- package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/uniswap-v3-math.d.ts +0 -19
- package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/uniswap-v3-math.js +1 -2
- package/build/dex/ramses-v2/contract-math/uniswap-v3-math.js.map +1 -0
- package/build/dex/ramses-v2/contract-math/utils.js.map +1 -0
- package/build/dex/{baseswap-v3/baseswap-v3-pool.d.ts → ramses-v2/ramses-v2-pool.d.ts} +7 -11
- package/build/dex/{baseswap-v3/baseswap-v3-pool.js → ramses-v2/ramses-v2-pool.js} +7 -12
- package/build/dex/ramses-v2/ramses-v2-pool.js.map +1 -0
- package/build/dex/{baseswap-v3/baseswap-v3.d.ts → ramses-v2/ramses-v2.d.ts} +16 -26
- package/build/dex/{baseswap-v3/baseswap-v3.js → ramses-v2/ramses-v2.js} +82 -144
- package/build/dex/ramses-v2/ramses-v2.js.map +1 -0
- package/build/dex/{baseswap-v3 → ramses-v2}/types.d.ts +7 -17
- package/build/dex/ramses-v2/types.js +9 -0
- package/build/dex/ramses-v2/types.js.map +1 -0
- package/build/dex/{baseswap-v3 → ramses-v2}/utils.js +7 -1
- package/build/dex/ramses-v2/utils.js.map +1 -0
- package/build/dex/{kyberswap-elastic → sushiswap-v3}/config.d.ts +2 -2
- package/build/dex/sushiswap-v3/config.js +132 -0
- package/build/dex/sushiswap-v3/config.js.map +1 -0
- package/build/dex/sushiswap-v3/constants.d.ts +4 -0
- package/build/dex/sushiswap-v3/constants.js +32 -0
- package/build/dex/sushiswap-v3/constants.js.map +1 -0
- package/build/dex/{kyberswap-elastic/kyberswap-elastic.d.ts → sushiswap-v3/sushiswap-v3-original.d.ts} +31 -28
- package/build/dex/{kyberswap-elastic/kyberswap-elastic.js → sushiswap-v3/sushiswap-v3-original.js} +257 -269
- package/build/dex/sushiswap-v3/sushiswap-v3-original.js.map +1 -0
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.d.ts +1 -0
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.js +6 -0
- package/build/dex/sushiswap-v3/sushiswap-v3-pool.js.map +1 -0
- package/build/dex/sushiswap-v3/sushiswap-v3.d.ts +21 -0
- package/build/dex/sushiswap-v3/sushiswap-v3.js +58 -0
- package/build/dex/sushiswap-v3/sushiswap-v3.js.map +1 -0
- package/build/dex/sushiswap-v3/token.d.ts +6 -0
- package/build/dex/sushiswap-v3/token.js +23 -0
- package/build/dex/sushiswap-v3/token.js.map +1 -0
- package/build/dex/sushiswap-v3/types.d.ts +15 -0
- package/build/dex/sushiswap-v3/types.js +18 -0
- package/build/dex/sushiswap-v3/types.js.map +1 -0
- package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.d.ts +12 -0
- package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js +23 -0
- package/build/dex/uniswap-v3/forks/pancakeswap-v3/pancakeswap-v3.js.map +1 -0
- package/build/dex/{hello → woo-fi}/config.d.ts +1 -1
- package/build/dex/woo-fi/config.js +141 -0
- package/build/dex/woo-fi/config.js.map +1 -0
- package/build/dex/woo-fi/constants.d.ts +5 -0
- package/build/dex/woo-fi/constants.js +20 -0
- package/build/dex/woo-fi/constants.js.map +1 -0
- package/build/dex/woo-fi/types.d.ts +48 -0
- package/build/dex/{wombat → woo-fi}/types.js.map +1 -1
- package/build/dex/woo-fi/woo-fi-decimal-math.d.ts +14 -0
- package/build/dex/woo-fi/woo-fi-decimal-math.js +42 -0
- package/build/dex/woo-fi/woo-fi-decimal-math.js.map +1 -0
- package/build/dex/woo-fi/woo-fi-math.d.ts +31 -0
- package/build/dex/woo-fi/woo-fi-math.js +300 -0
- package/build/dex/woo-fi/woo-fi-math.js.map +1 -0
- package/build/dex/woo-fi/woo-fi.d.ts +65 -0
- package/build/dex/woo-fi/woo-fi.js +480 -0
- package/build/dex/woo-fi/woo-fi.js.map +1 -0
- package/build/executor/Executor01BytecodeBuilder.d.ts +77 -0
- package/build/executor/Executor01BytecodeBuilder.js +359 -0
- package/build/executor/Executor01BytecodeBuilder.js.map +1 -0
- package/build/executor/Executor02BytecodeBuilder.d.ts +12 -0
- package/build/executor/Executor02BytecodeBuilder.js +14 -0
- package/build/executor/Executor02BytecodeBuilder.js.map +1 -0
- package/build/executor/ExecutorDetector.d.ts +28 -0
- package/build/executor/ExecutorDetector.js +89 -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/generic-swap-transaction-builder.d.ts +39 -0
- package/build/generic-swap-transaction-builder.js +156 -0
- package/build/generic-swap-transaction-builder.js.map +1 -0
- package/package.json +1 -1
- package/src/dex/dexalot/constants.ts +1 -1
- package/build/abi/kyberswap-elastic/IAntiSnipAttackPositionManager.json +0 -1276
- package/build/abi/kyberswap-elastic/IFactory.json +0 -550
- package/build/abi/kyberswap-elastic/IPool.json +0 -1042
- package/build/abi/kyberswap-elastic/IQuoterV2.json +0 -226
- package/build/abi/kyberswap-elastic/IRouter.json +0 -239
- package/build/abi/kyberswap-elastic/TicksFeesReader.json +0 -142
- package/build/abi/wombat/asset.json +0 -769
- package/build/abi/wombat/bmw.json +0 -1247
- package/build/abi/wombat/pool.json +0 -1364
- package/build/dex/baseswap-v3/baseswap-v3-factory.d.ts +0 -26
- package/build/dex/baseswap-v3/baseswap-v3-factory.js +0 -44
- package/build/dex/baseswap-v3/baseswap-v3-factory.js.map +0 -1
- package/build/dex/baseswap-v3/baseswap-v3-pool.js.map +0 -1
- package/build/dex/baseswap-v3/baseswap-v3.js.map +0 -1
- package/build/dex/baseswap-v3/config.d.ts +0 -9
- package/build/dex/baseswap-v3/config.js +0 -48
- package/build/dex/baseswap-v3/config.js.map +0 -1
- package/build/dex/baseswap-v3/constants.js.map +0 -1
- package/build/dex/baseswap-v3/contract-math/BitMath.js.map +0 -1
- package/build/dex/baseswap-v3/contract-math/FixedPoint128.js.map +0 -1
- package/build/dex/baseswap-v3/contract-math/FixedPoint96.js.map +0 -1
- package/build/dex/baseswap-v3/contract-math/FullMath.js.map +0 -1
- package/build/dex/baseswap-v3/contract-math/LiquidityMath.js.map +0 -1
- package/build/dex/baseswap-v3/contract-math/Oracle.js.map +0 -1
- package/build/dex/baseswap-v3/contract-math/SqrtPriceMath.js.map +0 -1
- package/build/dex/baseswap-v3/contract-math/SwapMath.js.map +0 -1
- package/build/dex/baseswap-v3/contract-math/Tick.d.ts +0 -7
- package/build/dex/baseswap-v3/contract-math/Tick.js.map +0 -1
- package/build/dex/baseswap-v3/contract-math/TickBitMap.d.ts +0 -7
- package/build/dex/baseswap-v3/contract-math/TickBitMap.js.map +0 -1
- package/build/dex/baseswap-v3/contract-math/TickMath.js.map +0 -1
- package/build/dex/baseswap-v3/contract-math/UnsafeMath.js.map +0 -1
- package/build/dex/baseswap-v3/contract-math/uniswap-v3-math.js.map +0 -1
- package/build/dex/baseswap-v3/contract-math/utils.d.ts +0 -7
- package/build/dex/baseswap-v3/contract-math/utils.js +0 -42
- package/build/dex/baseswap-v3/contract-math/utils.js.map +0 -1
- package/build/dex/baseswap-v3/types.js +0 -9
- package/build/dex/baseswap-v3/types.js.map +0 -1
- package/build/dex/baseswap-v3/utils.js.map +0 -1
- package/build/dex/hello/config.js +0 -15
- package/build/dex/hello/config.js.map +0 -1
- package/build/dex/hello/hello-pool.d.ts +0 -39
- package/build/dex/hello/hello-pool.js +0 -64
- package/build/dex/hello/hello-pool.js.map +0 -1
- package/build/dex/hello/hello.d.ts +0 -37
- package/build/dex/hello/hello.js +0 -126
- package/build/dex/hello/hello.js.map +0 -1
- package/build/dex/hello/types.d.ts +0 -6
- package/build/dex/kyberswap-elastic/config.js +0 -80
- package/build/dex/kyberswap-elastic/config.js.map +0 -1
- package/build/dex/kyberswap-elastic/constants.d.ts +0 -17
- package/build/dex/kyberswap-elastic/constants.js +0 -42
- package/build/dex/kyberswap-elastic/constants.js.map +0 -1
- package/build/dex/kyberswap-elastic/contract-math/FixedPoint96.d.ts +0 -4
- package/build/dex/kyberswap-elastic/contract-math/FixedPoint96.js +0 -9
- package/build/dex/kyberswap-elastic/contract-math/FixedPoint96.js.map +0 -1
- package/build/dex/kyberswap-elastic/contract-math/FullMath.d.ts +0 -5
- package/build/dex/kyberswap-elastic/contract-math/FullMath.js +0 -22
- package/build/dex/kyberswap-elastic/contract-math/FullMath.js.map +0 -1
- package/build/dex/kyberswap-elastic/contract-math/LiqDeltaMath.d.ts +0 -3
- package/build/dex/kyberswap-elastic/contract-math/LiqDeltaMath.js +0 -12
- package/build/dex/kyberswap-elastic/contract-math/LiqDeltaMath.js.map +0 -1
- package/build/dex/kyberswap-elastic/contract-math/LiquidityMath.d.ts +0 -3
- package/build/dex/kyberswap-elastic/contract-math/LiquidityMath.js +0 -22
- package/build/dex/kyberswap-elastic/contract-math/LiquidityMath.js.map +0 -1
- package/build/dex/kyberswap-elastic/contract-math/QtyDeltaMath.d.ts +0 -5
- package/build/dex/kyberswap-elastic/contract-math/QtyDeltaMath.js +0 -25
- package/build/dex/kyberswap-elastic/contract-math/QtyDeltaMath.js.map +0 -1
- package/build/dex/kyberswap-elastic/contract-math/QuadMath.d.ts +0 -4
- package/build/dex/kyberswap-elastic/contract-math/QuadMath.js +0 -27
- package/build/dex/kyberswap-elastic/contract-math/QuadMath.js.map +0 -1
- package/build/dex/kyberswap-elastic/contract-math/ReinvestmentMath.d.ts +0 -3
- package/build/dex/kyberswap-elastic/contract-math/ReinvestmentMath.js +0 -14
- package/build/dex/kyberswap-elastic/contract-math/ReinvestmentMath.js.map +0 -1
- package/build/dex/kyberswap-elastic/contract-math/SafeCast.d.ts +0 -8
- package/build/dex/kyberswap-elastic/contract-math/SafeCast.js +0 -30
- package/build/dex/kyberswap-elastic/contract-math/SafeCast.js.map +0 -1
- package/build/dex/kyberswap-elastic/contract-math/SqrtPriceMath.d.ts +0 -10
- package/build/dex/kyberswap-elastic/contract-math/SqrtPriceMath.js +0 -91
- package/build/dex/kyberswap-elastic/contract-math/SqrtPriceMath.js.map +0 -1
- package/build/dex/kyberswap-elastic/contract-math/SwapMath.d.ts +0 -13
- package/build/dex/kyberswap-elastic/contract-math/SwapMath.js +0 -188
- package/build/dex/kyberswap-elastic/contract-math/SwapMath.js.map +0 -1
- package/build/dex/kyberswap-elastic/contract-math/TickLinkedList.d.ts +0 -6
- package/build/dex/kyberswap-elastic/contract-math/TickLinkedList.js +0 -41
- package/build/dex/kyberswap-elastic/contract-math/TickLinkedList.js.map +0 -1
- package/build/dex/kyberswap-elastic/contract-math/TickMath.d.ts +0 -9
- package/build/dex/kyberswap-elastic/contract-math/TickMath.js +0 -165
- package/build/dex/kyberswap-elastic/contract-math/TickMath.js.map +0 -1
- package/build/dex/kyberswap-elastic/contract-math/UnsafeMath.d.ts +0 -3
- package/build/dex/kyberswap-elastic/contract-math/UnsafeMath.js +0 -10
- package/build/dex/kyberswap-elastic/contract-math/UnsafeMath.js.map +0 -1
- package/build/dex/kyberswap-elastic/contract-math/kyberswap-elastic-math.d.ts +0 -28
- package/build/dex/kyberswap-elastic/contract-math/kyberswap-elastic-math.js +0 -502
- package/build/dex/kyberswap-elastic/contract-math/kyberswap-elastic-math.js.map +0 -1
- package/build/dex/kyberswap-elastic/contract-math/utils.js.map +0 -1
- package/build/dex/kyberswap-elastic/errors.d.ts +0 -2
- package/build/dex/kyberswap-elastic/errors.js +0 -6
- package/build/dex/kyberswap-elastic/errors.js.map +0 -1
- package/build/dex/kyberswap-elastic/kyberswap-elastic-pool.d.ts +0 -80
- package/build/dex/kyberswap-elastic/kyberswap-elastic-pool.js +0 -458
- package/build/dex/kyberswap-elastic/kyberswap-elastic-pool.js.map +0 -1
- package/build/dex/kyberswap-elastic/kyberswap-elastic.js.map +0 -1
- package/build/dex/kyberswap-elastic/types.d.ts +0 -134
- package/build/dex/kyberswap-elastic/types.js +0 -9
- package/build/dex/kyberswap-elastic/types.js.map +0 -1
- package/build/dex/kyberswap-elastic/utils/decoders.d.ts +0 -9
- package/build/dex/kyberswap-elastic/utils/decoders.js +0 -78
- package/build/dex/kyberswap-elastic/utils/decoders.js.map +0 -1
- package/build/dex/morphex/config.d.ts +0 -11
- package/build/dex/morphex/config.js +0 -43
- package/build/dex/morphex/config.js.map +0 -1
- package/build/dex/morphex/morphex.d.ts +0 -25
- package/build/dex/morphex/morphex.js +0 -19
- package/build/dex/morphex/morphex.js.map +0 -1
- package/build/dex/my-test-dex/config.js +0 -15
- package/build/dex/my-test-dex/config.js.map +0 -1
- package/build/dex/my-test-dex/my-test-dex-pool.js +0 -64
- package/build/dex/my-test-dex/my-test-dex-pool.js.map +0 -1
- package/build/dex/my-test-dex/my-test-dex.js +0 -126
- package/build/dex/my-test-dex/my-test-dex.js.map +0 -1
- package/build/dex/my-test-dex/types.d.ts +0 -6
- package/build/dex/wombat/config.js +0 -99
- package/build/dex/wombat/config.js.map +0 -1
- package/build/dex/wombat/types.d.ts +0 -33
- package/build/dex/wombat/utils.d.ts +0 -9
- package/build/dex/wombat/utils.js +0 -66
- package/build/dex/wombat/utils.js.map +0 -1
- package/build/dex/wombat/wombat-bmw.d.ts +0 -40
- package/build/dex/wombat/wombat-bmw.js +0 -147
- package/build/dex/wombat/wombat-bmw.js.map +0 -1
- package/build/dex/wombat/wombat-pool.d.ts +0 -22
- package/build/dex/wombat/wombat-pool.js +0 -161
- package/build/dex/wombat/wombat-pool.js.map +0 -1
- package/build/dex/wombat/wombat-quoter.d.ts +0 -16
- package/build/dex/wombat/wombat-quoter.js +0 -176
- package/build/dex/wombat/wombat-quoter.js.map +0 -1
- package/build/dex/wombat/wombat.d.ts +0 -55
- package/build/dex/wombat/wombat.js +0 -290
- package/build/dex/wombat/wombat.js.map +0 -1
- /package/build/dex/{hello → lighter-v1}/types.js +0 -0
- /package/build/dex/{my-test-dex → pancakeswap-v3}/types.js +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/BitMath.d.ts +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/BitMath.js +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/FixedPoint128.d.ts +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/FixedPoint128.js +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/FixedPoint96.d.ts +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/FixedPoint96.js +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/FullMath.d.ts +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/FullMath.js +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/LiquidityMath.d.ts +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/LiquidityMath.js +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/Oracle.d.ts +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/Oracle.js +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/SqrtPriceMath.d.ts +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/SqrtPriceMath.js +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/SwapMath.d.ts +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/SwapMath.js +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/Tick.js +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/TickMath.d.ts +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/TickMath.js +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/UnsafeMath.d.ts +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/contract-math/UnsafeMath.js +0 -0
- /package/build/dex/{kyberswap-elastic → ramses-v2}/contract-math/utils.d.ts +0 -0
- /package/build/dex/{kyberswap-elastic → ramses-v2}/contract-math/utils.js +0 -0
- /package/build/dex/{baseswap-v3 → ramses-v2}/utils.d.ts +0 -0
- /package/build/dex/{wombat → woo-fi}/types.js +0 -0
package/build/dex/{kyberswap-elastic/kyberswap-elastic.js → sushiswap-v3/sushiswap-v3-original.js}
RENAMED
|
@@ -26,53 +26,57 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
30
|
-
const abi_1 = require("@ethersproject/abi");
|
|
31
|
-
const solidity_1 = require("@ethersproject/solidity");
|
|
32
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
33
|
-
const types_1 = require("../../lib/tokens/types");
|
|
29
|
+
exports.SushiswapV3 = void 0;
|
|
34
30
|
const constants_1 = require("../../constants");
|
|
35
31
|
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
36
32
|
const utils_1 = require("../../utils");
|
|
37
|
-
const balancer_fetcher_1 = require("../../lib/tokens/balancer-fetcher");
|
|
38
33
|
const simple_exchange_1 = require("../simple-exchange");
|
|
39
|
-
const multi_v2_json_1 = __importDefault(require("../../abi/multi-v2.json"));
|
|
40
|
-
const IRouter_json_1 = __importDefault(require("../../abi/kyberswap-elastic/IRouter.json"));
|
|
41
|
-
const IQuoterV2_json_1 = __importDefault(require("../../abi/kyberswap-elastic/IQuoterV2.json"));
|
|
42
|
-
const types_2 = require("./types");
|
|
43
34
|
const config_1 = require("./config");
|
|
35
|
+
const sushiswap_v3_pool_1 = require("./sushiswap-v3-pool");
|
|
36
|
+
const utils_2 = require("ethers/lib/utils");
|
|
37
|
+
const solidity_1 = require("@ethersproject/solidity");
|
|
44
38
|
const constants_2 = require("./constants");
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
39
|
+
const uniswap_v3_math_1 = require("../uniswap-v3/contract-math/uniswap-v3-math");
|
|
40
|
+
const balancer_fetcher_1 = require("../../lib/tokens/balancer-fetcher");
|
|
41
|
+
const types_1 = require("../../lib/tokens/types");
|
|
42
|
+
const router_1 = require("@sushiswap/router");
|
|
43
|
+
const viem_1 = require("viem");
|
|
44
|
+
const RouterProcessor3_json_1 = __importDefault(require("../../abi/sushiswap-v3/RouterProcessor3.json"));
|
|
45
|
+
const QuoterV2_json_1 = __importDefault(require("../../abi/sushiswap-v3/QuoterV2.json"));
|
|
46
|
+
const UniswapMulti_abi_json_1 = __importDefault(require("../../abi/uniswap-v3/UniswapMulti.abi.json"));
|
|
47
|
+
const UniswapV3StateMulticall_abi_json_1 = __importDefault(require("../../abi/uniswap-v3/UniswapV3StateMulticall.abi.json"));
|
|
48
|
+
const config_2 = require("../../config");
|
|
49
|
+
const ethers_1 = require("ethers");
|
|
50
|
+
const token_1 = require("./token");
|
|
51
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
52
|
+
const config_3 = require("../uniswap-v3/config");
|
|
53
|
+
const UNISWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS = 60 * 60 * 24 * 1000; // 24 hours
|
|
54
|
+
const UNISWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS = 30 * 60 * 1000; // Once in 30 minutes
|
|
55
|
+
const UNISWAPV3_QUOTE_GASLIMIT = 200000;
|
|
56
|
+
class SushiswapV3 extends simple_exchange_1.SimpleExchange {
|
|
57
|
+
constructor(network, dexKey, dexHelper, adapters = config_1.Adapters[network] || {}, routerIface = new utils_2.Interface(RouterProcessor3_json_1.default), quoterIface = new utils_2.Interface(QuoterV2_json_1.default), config = config_1.SushiswapV3Config[dexKey][network]) {
|
|
52
58
|
super(dexHelper, dexKey);
|
|
53
59
|
this.network = network;
|
|
54
60
|
this.dexKey = dexKey;
|
|
55
61
|
this.dexHelper = dexHelper;
|
|
56
62
|
this.adapters = adapters;
|
|
63
|
+
this.routerIface = routerIface;
|
|
64
|
+
this.quoterIface = quoterIface;
|
|
57
65
|
this.config = config;
|
|
58
66
|
this.eventPools = {};
|
|
59
67
|
this.hasConstantPriceLargeAmounts = false;
|
|
60
68
|
this.needWrapNative = true;
|
|
61
69
|
this.isFeeOnTransferSupported = false;
|
|
62
|
-
this.routerIface = new abi_1.Interface(IRouter_json_1.default);
|
|
63
|
-
this.quoterIface = new abi_1.Interface(IQuoterV2_json_1.default);
|
|
64
70
|
this.logger = dexHelper.getLogger(dexKey + '-' + network);
|
|
71
|
+
this.uniswapMulti = new this.dexHelper.web3Provider.eth.Contract(UniswapMulti_abi_json_1.default, this.config.uniswapMulticall);
|
|
72
|
+
this.stateMultiContract = new this.dexHelper.web3Provider.eth.Contract(UniswapV3StateMulticall_abi_json_1.default, this.config.stateMulticall);
|
|
65
73
|
// To receive revert reasons
|
|
66
74
|
this.dexHelper.web3Provider.eth.handleRevert = false;
|
|
67
75
|
// Normalise once all config addresses and use across all scenarios
|
|
68
76
|
this.config = this._toLowerForAllConfigAddresses();
|
|
69
|
-
this.multicall = new this.dexHelper.web3Provider.eth.Contract(multi_v2_json_1.default, this.dexHelper.config.data.multicallV2Address);
|
|
70
77
|
this.notExistingPoolSetKey =
|
|
71
78
|
`${constants_1.CACHE_PREFIX}_${network}_${dexKey}_not_existings_pool_set`.toLowerCase();
|
|
72
79
|
}
|
|
73
|
-
get supportedFees() {
|
|
74
|
-
return this.config.supportedFees;
|
|
75
|
-
}
|
|
76
80
|
// Initialize pricing is called once in the start of
|
|
77
81
|
// pricing service. It is intended to setup the integration
|
|
78
82
|
// for pricing requests. It is optional for a DEX to
|
|
@@ -80,46 +84,23 @@ class KyberswapElastic extends simple_exchange_1.SimpleExchange {
|
|
|
80
84
|
async initializePricing(blockNumber) {
|
|
81
85
|
if (!this.dexHelper.config.isSlave) {
|
|
82
86
|
const cleanExpiredNotExistingPoolsKeys = async () => {
|
|
83
|
-
const maxTimestamp = Date.now() -
|
|
87
|
+
const maxTimestamp = Date.now() - UNISWAPV3_CLEAN_NOT_EXISTING_POOL_TTL_MS;
|
|
84
88
|
await this.dexHelper.cache.zremrangebyscore(this.notExistingPoolSetKey, 0, maxTimestamp);
|
|
85
89
|
};
|
|
86
|
-
this.
|
|
90
|
+
this.intervalTask = setInterval(cleanExpiredNotExistingPoolsKeys.bind(this), UNISWAPV3_CLEAN_NOT_EXISTING_POOL_INTERVAL_MS);
|
|
87
91
|
}
|
|
88
92
|
}
|
|
93
|
+
get supportedFees() {
|
|
94
|
+
return this.config.supportedFees;
|
|
95
|
+
}
|
|
89
96
|
// Returns the list of contract adapters (name and index)
|
|
90
97
|
// for a buy/sell. Return null if there are no adapters.
|
|
91
98
|
getAdapters(side) {
|
|
92
99
|
return this.adapters[side] ? this.adapters[side] : null;
|
|
93
100
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const _pairs = await this.dexHelper.cache.hget(this.dexmapKey, poolKey);
|
|
98
|
-
if (!_pairs) {
|
|
99
|
-
this.logger.warn(`did not find poolConfig in for key ${this.dexmapKey} ${poolKey}`);
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
const poolInfo = JSON.parse(_pairs);
|
|
103
|
-
const pool = await this._getPool(poolInfo.token0, poolInfo.token1, BigInt(poolInfo.swapFeeUnits), blockNumber);
|
|
104
|
-
if (!pool) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
// Returns list of pool identifiers that can be used
|
|
110
|
-
// for a given swap. poolIdentifiers must be unique
|
|
111
|
-
// across DEXes. It is recommended to use
|
|
112
|
-
// ${dexKey}_${poolAddress} as a poolIdentifier
|
|
113
|
-
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
114
|
-
const _srcToken = this.dexHelper.config.wrapETH(srcToken);
|
|
115
|
-
const _destToken = this.dexHelper.config.wrapETH(destToken);
|
|
116
|
-
const [_srcAddress, _destAddress] = this._getLoweredAddresses(_srcToken, _destToken);
|
|
117
|
-
if (_srcAddress === _destAddress)
|
|
118
|
-
return [];
|
|
119
|
-
const pools = (await Promise.all(this.supportedFees.map(async (swapFeeUnits) => this._getPool(_srcAddress, _destAddress, swapFeeUnits, blockNumber)))).filter(pool => pool);
|
|
120
|
-
if (pools.length === 0)
|
|
121
|
-
return [];
|
|
122
|
-
return pools.map(pool => this._getPoolIdentifier(_srcAddress, _destAddress, pool.swapFeeUnits));
|
|
101
|
+
getPoolIdentifier(srcAddress, destAddress, fee) {
|
|
102
|
+
const tokenAddresses = this._sortTokens(srcAddress, destAddress).join('_');
|
|
103
|
+
return `${this.dexKey}_${tokenAddresses}_${fee}`;
|
|
123
104
|
}
|
|
124
105
|
// Returns pool prices for amounts.
|
|
125
106
|
// If limitPools is defined only pools in limitPools
|
|
@@ -134,23 +115,23 @@ class KyberswapElastic extends simple_exchange_1.SimpleExchange {
|
|
|
134
115
|
return null;
|
|
135
116
|
let selectedPools = [];
|
|
136
117
|
if (!limitPools) {
|
|
137
|
-
selectedPools = (await Promise.all(this.supportedFees.map(async (
|
|
138
|
-
const locallyFoundPool = this.eventPools[this.
|
|
118
|
+
selectedPools = (await Promise.all(this.supportedFees.map(async (fee) => {
|
|
119
|
+
const locallyFoundPool = this.eventPools[this.getPoolIdentifier(_srcAddress, _destAddress, fee)];
|
|
139
120
|
if (locallyFoundPool)
|
|
140
121
|
return locallyFoundPool;
|
|
141
|
-
const newlyFetchedPool = await this.
|
|
122
|
+
const newlyFetchedPool = await this.getPool(_srcAddress, _destAddress, fee, blockNumber);
|
|
142
123
|
return newlyFetchedPool;
|
|
143
124
|
}))).filter(utils_1.isTruthy);
|
|
144
125
|
}
|
|
145
126
|
else {
|
|
146
|
-
const pairIdentifierWithoutFee = this.
|
|
127
|
+
const pairIdentifierWithoutFee = this.getPoolIdentifier(_srcAddress, _destAddress, 0n).slice(0, -1);
|
|
147
128
|
const poolIdentifiers = limitPools.filter(identifier => identifier.startsWith(pairIdentifierWithoutFee));
|
|
148
129
|
selectedPools = (await Promise.all(poolIdentifiers.map(async (identifier) => {
|
|
149
130
|
let locallyFoundPool = this.eventPools[identifier];
|
|
150
131
|
if (locallyFoundPool)
|
|
151
132
|
return locallyFoundPool;
|
|
152
|
-
const [, srcAddress, destAddress,
|
|
153
|
-
const newlyFetchedPool = await this.
|
|
133
|
+
const [, srcAddress, destAddress, fee] = identifier.split('_');
|
|
134
|
+
const newlyFetchedPool = await this.getPool(srcAddress, destAddress, BigInt(fee), blockNumber);
|
|
154
135
|
return newlyFetchedPool;
|
|
155
136
|
}))).filter(utils_1.isTruthy);
|
|
156
137
|
}
|
|
@@ -170,21 +151,21 @@ class KyberswapElastic extends simple_exchange_1.SimpleExchange {
|
|
|
170
151
|
poolWithState: [],
|
|
171
152
|
poolWithoutState: [],
|
|
172
153
|
});
|
|
173
|
-
const rpcResultsPromise = this.
|
|
154
|
+
const rpcResultsPromise = this.getPricingFromRpc(_srcToken, _destToken, amounts, side, poolsToUse.poolWithoutState);
|
|
174
155
|
const states = poolsToUse.poolWithState.map(p => p.getState(blockNumber));
|
|
175
156
|
const unitAmount = (0, utils_1.getBigIntPow)(side == constants_1.SwapSide.SELL ? _srcToken.decimals : _destToken.decimals);
|
|
176
157
|
const _amounts = [...amounts.slice(1)];
|
|
177
158
|
const [token0] = this._sortTokens(_srcAddress, _destAddress);
|
|
178
|
-
const
|
|
159
|
+
const zeroForOne = token0 === _srcAddress ? true : false;
|
|
179
160
|
const result = await Promise.all(poolsToUse.poolWithState.map(async (pool, i) => {
|
|
180
161
|
const state = states[i];
|
|
181
|
-
if (state.
|
|
162
|
+
if (state.liquidity <= 0n) {
|
|
182
163
|
this.logger.trace(`pool have 0 liquidity`);
|
|
183
164
|
return null;
|
|
184
165
|
}
|
|
185
166
|
const balanceDestToken = _destAddress === pool.token0 ? state.balance0 : state.balance1;
|
|
186
|
-
const unitResult = this._getOutputs(state, [unitAmount],
|
|
187
|
-
const pricesResult = this._getOutputs(state, _amounts,
|
|
167
|
+
const unitResult = this._getOutputs(state, [unitAmount], zeroForOne, side, balanceDestToken);
|
|
168
|
+
const pricesResult = this._getOutputs(state, _amounts, zeroForOne, side, balanceDestToken);
|
|
188
169
|
if (!unitResult || !pricesResult) {
|
|
189
170
|
this.logger.debug('Prices or unit is not calculated');
|
|
190
171
|
return null;
|
|
@@ -197,9 +178,9 @@ class KyberswapElastic extends simple_exchange_1.SimpleExchange {
|
|
|
197
178
|
return 0;
|
|
198
179
|
}
|
|
199
180
|
else {
|
|
200
|
-
return (constants_2.
|
|
201
|
-
constants_2.
|
|
202
|
-
pricesResult.tickCounts[index] * constants_2.
|
|
181
|
+
return (constants_2.UNISWAPV3_POOL_SEARCH_OVERHEAD +
|
|
182
|
+
constants_2.UNISWAPV3_TICK_BASE_OVERHEAD +
|
|
183
|
+
pricesResult.tickCounts[index] * constants_2.UNISWAPV3_TICK_GAS_COST);
|
|
203
184
|
}
|
|
204
185
|
}),
|
|
205
186
|
];
|
|
@@ -211,11 +192,11 @@ class KyberswapElastic extends simple_exchange_1.SimpleExchange {
|
|
|
211
192
|
{
|
|
212
193
|
tokenIn: _srcAddress,
|
|
213
194
|
tokenOut: _destAddress,
|
|
214
|
-
|
|
195
|
+
fee: pool.feeCode.toString(),
|
|
215
196
|
},
|
|
216
197
|
],
|
|
217
198
|
},
|
|
218
|
-
poolIdentifier: this.
|
|
199
|
+
poolIdentifier: this.getPoolIdentifier(pool.token0, pool.token1, pool.feeCode),
|
|
219
200
|
exchange: this.dexKey,
|
|
220
201
|
gasCost: gasCost,
|
|
221
202
|
poolAddresses: [pool.poolAddress],
|
|
@@ -237,21 +218,115 @@ class KyberswapElastic extends simple_exchange_1.SimpleExchange {
|
|
|
237
218
|
return null;
|
|
238
219
|
}
|
|
239
220
|
}
|
|
221
|
+
getQuoterV2CallData(funcName, tokenIn, tokenOut, amount, fee) {
|
|
222
|
+
return funcName === 'quoteExactInputSingle'
|
|
223
|
+
? { tokenIn, tokenOut, fee, sqrtPriceLimitX96: 0n, amountIn: amount }
|
|
224
|
+
: { tokenIn, tokenOut, fee, sqrtPriceLimitX96: 0n, amount };
|
|
225
|
+
}
|
|
226
|
+
async getPricingFromRpc(from, to, amounts, side, pools) {
|
|
227
|
+
if (pools.length === 0) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
this.logger.warn(`fallback to rpc for ${pools.length} pool(s)`);
|
|
231
|
+
const requests = pools.map(pool => ({
|
|
232
|
+
owner: pool.poolAddress,
|
|
233
|
+
asset: side == constants_1.SwapSide.SELL ? from.address : to.address,
|
|
234
|
+
assetType: types_1.AssetType.ERC20,
|
|
235
|
+
ids: [
|
|
236
|
+
{
|
|
237
|
+
id: types_1.DEFAULT_ID_ERC20,
|
|
238
|
+
spenders: [],
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
}), []);
|
|
242
|
+
const balances = await (0, balancer_fetcher_1.getBalances)(this.dexHelper.multiWrapper, requests);
|
|
243
|
+
pools = pools.filter((pool, index) => {
|
|
244
|
+
const balance = balances[index].amounts[types_1.DEFAULT_ID_ERC20_AS_STRING];
|
|
245
|
+
if (balance >= amounts[amounts.length - 1]) {
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
this.logger.warn(`[${this.network}][${pool.parentName}] have no balance ${pool.poolAddress} ${from.address} ${to.address}. (Balance: ${balance})`);
|
|
249
|
+
return false;
|
|
250
|
+
});
|
|
251
|
+
pools.forEach(pool => {
|
|
252
|
+
this.logger.warn(`[${this.network}][${pool.parentName}] fallback to rpc for ${pool.name}`);
|
|
253
|
+
});
|
|
254
|
+
const unitVolume = (0, utils_1.getBigIntPow)((side === constants_1.SwapSide.SELL ? from : to).decimals);
|
|
255
|
+
const chunks = amounts.length - 1;
|
|
256
|
+
const _width = Math.floor(chunks / this.config.chunksCount);
|
|
257
|
+
const _amounts = [unitVolume].concat(Array.from(Array(this.config.chunksCount).keys()).map(i => amounts[(i + 1) * _width]));
|
|
258
|
+
const funcName = side === constants_1.SwapSide.SELL
|
|
259
|
+
? 'quoteExactInputSingle'
|
|
260
|
+
: 'quoteExactOutputSingle';
|
|
261
|
+
const calldata = pools.map(pool => _amounts.map(_amount => ({
|
|
262
|
+
target: this.config.quoter,
|
|
263
|
+
gasLimit: UNISWAPV3_QUOTE_GASLIMIT,
|
|
264
|
+
callData: this.quoterIface.encodeFunctionData(funcName, [
|
|
265
|
+
this.getQuoterV2CallData(funcName, from.address, to.address, _amount, pool.feeCode),
|
|
266
|
+
]),
|
|
267
|
+
})));
|
|
268
|
+
const data = await new this.dexHelper.web3Provider.eth.Contract(UniswapMulti_abi_json_1.default, this.config.uniswapMulticall).methods
|
|
269
|
+
.multicall(calldata.flat())
|
|
270
|
+
.call();
|
|
271
|
+
const decode = (j) => {
|
|
272
|
+
if (!data.returnData[j].success) {
|
|
273
|
+
return 0n;
|
|
274
|
+
}
|
|
275
|
+
const decoded = utils_2.defaultAbiCoder.decode(['uint256'], data.returnData[j].returnData);
|
|
276
|
+
return BigInt(decoded[0].toString());
|
|
277
|
+
};
|
|
278
|
+
let i = 0;
|
|
279
|
+
const result = pools.map(pool => {
|
|
280
|
+
const _rates = _amounts.map(() => decode(i++));
|
|
281
|
+
const unit = _rates[0];
|
|
282
|
+
const prices = (0, utils_1.interpolate)(_amounts.slice(1), _rates.slice(1), amounts, side);
|
|
283
|
+
return {
|
|
284
|
+
prices,
|
|
285
|
+
unit,
|
|
286
|
+
data: {
|
|
287
|
+
path: [
|
|
288
|
+
{
|
|
289
|
+
tokenIn: from.address,
|
|
290
|
+
tokenOut: to.address,
|
|
291
|
+
fee: pool.feeCodeAsString,
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
},
|
|
295
|
+
poolIdentifier: this.getPoolIdentifier(pool.token0, pool.token1, pool.feeCode),
|
|
296
|
+
exchange: this.dexKey,
|
|
297
|
+
gasCost: prices.map(p => (p === 0n ? 0 : UNISWAPV3_QUOTE_GASLIMIT)),
|
|
298
|
+
poolAddresses: [pool.poolAddress],
|
|
299
|
+
};
|
|
300
|
+
});
|
|
301
|
+
return result;
|
|
302
|
+
}
|
|
240
303
|
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
241
304
|
getCalldataGasCost(poolPrices) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
305
|
+
const gasCost = CALLDATA_GAS_COST.DEX_OVERHEAD +
|
|
306
|
+
CALLDATA_GAS_COST.LENGTH_SMALL +
|
|
307
|
+
// ParentStruct header
|
|
308
|
+
CALLDATA_GAS_COST.OFFSET_SMALL +
|
|
309
|
+
// ParentStruct -> path header
|
|
310
|
+
CALLDATA_GAS_COST.OFFSET_SMALL +
|
|
311
|
+
// ParentStruct -> deadline
|
|
312
|
+
CALLDATA_GAS_COST.TIMESTAMP +
|
|
313
|
+
// ParentStruct -> path (20+3+20 = 43 = 32+11 bytes)
|
|
314
|
+
CALLDATA_GAS_COST.LENGTH_SMALL +
|
|
315
|
+
CALLDATA_GAS_COST.FULL_WORD +
|
|
316
|
+
CALLDATA_GAS_COST.wordNonZeroBytes(11);
|
|
317
|
+
const arr = new Array(poolPrices.prices.length);
|
|
318
|
+
poolPrices.prices.forEach((p, index) => {
|
|
319
|
+
if (p == 0n) {
|
|
320
|
+
arr[index] = 0;
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
arr[index] = gasCost;
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
return arr;
|
|
251
327
|
}
|
|
252
328
|
// Encode params required by the exchange adapter
|
|
253
329
|
// Used for multiSwap, buy & megaSwap
|
|
254
|
-
// Hint: abiCoder.encodeParameter() could be useful
|
|
255
330
|
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
256
331
|
const { path: rawPath } = data;
|
|
257
332
|
const path = this._encodePath(rawPath, side);
|
|
@@ -262,45 +337,40 @@ class KyberswapElastic extends simple_exchange_1.SimpleExchange {
|
|
|
262
337
|
},
|
|
263
338
|
}, {
|
|
264
339
|
path,
|
|
265
|
-
deadline: (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(),
|
|
340
|
+
deadline: (0, simple_exchange_1.getLocalDeadlineAsFriendlyPlaceholder)(), // FIXME: more gas efficient to pass block.timestamp in adapter
|
|
266
341
|
});
|
|
267
342
|
return {
|
|
268
|
-
targetExchange: this.
|
|
343
|
+
targetExchange: config_3.UniswapV3Config['UniswapV3'][this.network].router,
|
|
269
344
|
payload,
|
|
270
345
|
networkFee: '0',
|
|
271
346
|
};
|
|
272
347
|
}
|
|
273
348
|
// Encode call data used by simpleSwap like routers
|
|
274
349
|
// Used for simpleSwap & simpleBuy
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
path,
|
|
296
|
-
};
|
|
297
|
-
const swapData = this.routerIface.encodeFunctionData(swapFunction, [
|
|
298
|
-
swapFunctionParams,
|
|
350
|
+
async getSimpleParam(srcToken, destToken, srcAmount, destAmount, data) {
|
|
351
|
+
const web3Client = (0, viem_1.createPublicClient)({
|
|
352
|
+
chain: constants_2.ViemChain[this.network],
|
|
353
|
+
transport: (0, viem_1.http)((0, config_2.generateConfig)(this.network).privateHttpProvider),
|
|
354
|
+
});
|
|
355
|
+
const dataFetcher = new router_1.DataFetcher(web3Client.chain.id, web3Client);
|
|
356
|
+
dataFetcher.startDataFetching([router_1.LiquidityProviders.SushiSwapV3]);
|
|
357
|
+
const fromToken = await (0, token_1.getToken)({ web3Client, address: srcToken });
|
|
358
|
+
const toToken = await (0, token_1.getToken)({ web3Client, address: destToken });
|
|
359
|
+
await dataFetcher.fetchPoolsForToken(fromToken, toToken);
|
|
360
|
+
const pcMap = dataFetcher.getCurrentPoolCodeMap(fromToken, toToken);
|
|
361
|
+
const route = router_1.Router.findBestRoute(pcMap, this.network, fromToken, ethers_1.BigNumber.from(srcAmount), toToken, 50e9, [router_1.LiquidityProviders.SushiSwapV3]);
|
|
362
|
+
const rpParams = router_1.Router.routeProcessor2Params(pcMap, route, fromToken, toToken, this.augustusAddress, this.config.router);
|
|
363
|
+
const swapData = this.routerIface.encodeFunctionData('processRoute', [
|
|
364
|
+
rpParams.tokenIn,
|
|
365
|
+
rpParams.amountIn,
|
|
366
|
+
rpParams.tokenOut,
|
|
367
|
+
rpParams.amountOutMin,
|
|
368
|
+
rpParams.to,
|
|
369
|
+
rpParams.routeCode,
|
|
299
370
|
]);
|
|
371
|
+
dataFetcher.stopDataFetching();
|
|
300
372
|
return this.buildSimpleParamWithoutWETHConversion(srcToken, srcAmount, destToken, destAmount, swapData, this.config.router);
|
|
301
373
|
}
|
|
302
|
-
// Returns list of top pools based on liquidity. Max
|
|
303
|
-
// limit number pools should be returned.
|
|
304
374
|
async getTopPoolsForToken(tokenAddress, limit) {
|
|
305
375
|
const _tokenAddress = tokenAddress.toLowerCase();
|
|
306
376
|
const res = await this._querySubgraph(`query ($token: Bytes!, $count: Int) {
|
|
@@ -345,7 +415,7 @@ class KyberswapElastic extends simple_exchange_1.SimpleExchange {
|
|
|
345
415
|
decimals: parseInt(pool.token1.decimals),
|
|
346
416
|
},
|
|
347
417
|
],
|
|
348
|
-
liquidityUSD: parseFloat(pool.totalValueLockedUSD) * constants_2.
|
|
418
|
+
liquidityUSD: parseFloat(pool.totalValueLockedUSD) * constants_2.UNISWAPV3_EFFICIENCY_FACTOR,
|
|
349
419
|
}));
|
|
350
420
|
const pools1 = lodash_1.default.map(res.pools1, pool => ({
|
|
351
421
|
exchange: this.dexKey,
|
|
@@ -356,222 +426,134 @@ class KyberswapElastic extends simple_exchange_1.SimpleExchange {
|
|
|
356
426
|
decimals: parseInt(pool.token0.decimals),
|
|
357
427
|
},
|
|
358
428
|
],
|
|
359
|
-
liquidityUSD: parseFloat(pool.totalValueLockedUSD) * constants_2.
|
|
429
|
+
liquidityUSD: parseFloat(pool.totalValueLockedUSD) * constants_2.UNISWAPV3_EFFICIENCY_FACTOR,
|
|
360
430
|
}));
|
|
361
431
|
const pools = lodash_1.default.slice(lodash_1.default.sortBy(lodash_1.default.concat(pools0, pools1), [pool => -1 * pool.liquidityUSD]), 0, limit);
|
|
362
432
|
return pools;
|
|
363
433
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
return
|
|
368
|
-
}
|
|
369
|
-
catch (e) {
|
|
370
|
-
this.logger.error(`${this.dexKey}: can not query subgraph: `, e);
|
|
371
|
-
return {};
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
releaseResources() {
|
|
375
|
-
if (this._intervalTask !== undefined) {
|
|
376
|
-
clearInterval(this._intervalTask);
|
|
377
|
-
this._intervalTask = undefined;
|
|
434
|
+
_encodePath(path, side) {
|
|
435
|
+
if (path.length === 0) {
|
|
436
|
+
this.logger.error(`${this.dexKey}: Received invalid path=${path} for side=${side} to encode`);
|
|
437
|
+
return '0x';
|
|
378
438
|
}
|
|
439
|
+
const { _path, types } = path.reduce(({ _path, types }, curr, index) => {
|
|
440
|
+
if (index === 0) {
|
|
441
|
+
return {
|
|
442
|
+
types: ['address', 'uint24', 'address'],
|
|
443
|
+
_path: [curr.tokenIn, curr.fee, curr.tokenOut],
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
return {
|
|
448
|
+
types: [...types, 'uint24', 'address'],
|
|
449
|
+
_path: [..._path, curr.fee, curr.tokenOut],
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
}, { _path: [], types: [] });
|
|
453
|
+
return side === constants_1.SwapSide.BUY
|
|
454
|
+
? (0, solidity_1.pack)(types.reverse(), _path.reverse())
|
|
455
|
+
: (0, solidity_1.pack)(types, _path);
|
|
379
456
|
}
|
|
380
|
-
|
|
381
|
-
|
|
457
|
+
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
458
|
+
const _srcToken = this.dexHelper.config.wrapETH(srcToken);
|
|
459
|
+
const _destToken = this.dexHelper.config.wrapETH(destToken);
|
|
460
|
+
const [_srcAddress, _destAddress] = this._getLoweredAddresses(_srcToken, _destToken);
|
|
461
|
+
if (_srcAddress === _destAddress)
|
|
462
|
+
return [];
|
|
463
|
+
const pools = (await Promise.all(this.supportedFees.map(async (fee) => this.getPool(_srcAddress, _destAddress, fee, blockNumber)))).filter(pool => pool);
|
|
464
|
+
if (pools.length === 0)
|
|
465
|
+
return [];
|
|
466
|
+
return pools.map(pool => this.getPoolIdentifier(_srcAddress, _destAddress, pool.feeCode));
|
|
382
467
|
}
|
|
383
|
-
async
|
|
384
|
-
let pool = this.eventPools[this.
|
|
468
|
+
async getPool(srcAddress, destAddress, fee, blockNumber) {
|
|
469
|
+
let pool = this.eventPools[this.getPoolIdentifier(srcAddress, destAddress, fee)];
|
|
385
470
|
if (pool === undefined) {
|
|
386
471
|
const [token0, token1] = this._sortTokens(srcAddress, destAddress);
|
|
387
|
-
const key = `${token0}_${token1}_${
|
|
388
|
-
// Check if the pool key is in the notExistingPool set,
|
|
389
|
-
// if yes, return null without initialize a new pool instance.
|
|
472
|
+
const key = `${token0}_${token1}_${fee}`.toLowerCase();
|
|
390
473
|
const notExistingPoolScore = await this.dexHelper.cache.zscore(this.notExistingPoolSetKey, key);
|
|
391
474
|
const poolDoesNotExist = notExistingPoolScore !== null;
|
|
392
475
|
if (poolDoesNotExist) {
|
|
393
|
-
this.eventPools[this.
|
|
476
|
+
this.eventPools[this.getPoolIdentifier(srcAddress, destAddress, fee)] =
|
|
477
|
+
null;
|
|
394
478
|
return null;
|
|
395
479
|
}
|
|
396
|
-
// Store this pool
|
|
397
480
|
await this.dexHelper.cache.hset(this.dexmapKey, key, JSON.stringify({
|
|
398
481
|
token0,
|
|
399
482
|
token1,
|
|
400
|
-
|
|
483
|
+
fee: fee.toString(),
|
|
401
484
|
}));
|
|
402
|
-
this.logger.trace(`
|
|
403
|
-
pool = new
|
|
485
|
+
this.logger.trace(`starting to listen to new pool: ${key}`);
|
|
486
|
+
pool = new sushiswap_v3_pool_1.SushiswapV3EventPool(this.dexHelper, this.dexKey, this.stateMultiContract, this.erc20Interface, this.config.factory, fee, token0, token1, this.logger, this.cacheStateKey, this.config.initHash);
|
|
404
487
|
try {
|
|
405
488
|
await pool.initialize(blockNumber, {
|
|
406
489
|
initCallback: (state) => {
|
|
407
|
-
//
|
|
490
|
+
//really hacky, we need to push poolAddress so that we subscribeToLogs in StatefulEventSubscriber
|
|
408
491
|
pool.addressesSubscribed[0] = state.pool;
|
|
409
492
|
pool.poolAddress = state.pool;
|
|
410
493
|
},
|
|
411
494
|
});
|
|
412
495
|
}
|
|
413
496
|
catch (e) {
|
|
414
|
-
if (e instanceof Error &&
|
|
415
|
-
|
|
416
|
-
e.message.search(errors_1.ERR_DECODE) != -1)) {
|
|
417
|
-
// No need to await here, we push the pool into the notExistingPool set without blocking
|
|
497
|
+
if (e instanceof Error && e.message.endsWith('Pool does not exist')) {
|
|
498
|
+
// no need to await we want the set to have the pool key but it's not blocking
|
|
418
499
|
this.dexHelper.cache.zadd(this.notExistingPoolSetKey, [Date.now(), key], 'NX');
|
|
419
|
-
// Pool does not exist for this
|
|
500
|
+
// Pool does not exist for this feeCode, so we can set it to null
|
|
420
501
|
// to prevent more requests for this pool
|
|
421
502
|
pool = null;
|
|
422
|
-
this.logger.trace(`${this.dexHelper}: Pool: srcAddress=${srcAddress}, destAddress=${destAddress},
|
|
503
|
+
this.logger.trace(`${this.dexHelper}: Pool: srcAddress=${srcAddress}, destAddress=${destAddress}, fee=${fee} not found`, e);
|
|
423
504
|
}
|
|
424
505
|
else {
|
|
425
506
|
// Unexpected Error. Break execution. Do not save the pool in this.eventPools
|
|
426
|
-
this.logger.error(`${this.dexKey}: Can not generate pool state for srcAddress=${srcAddress}, destAddress=${destAddress},
|
|
507
|
+
this.logger.error(`${this.dexKey}: Can not generate pool state for srcAddress=${srcAddress}, destAddress=${destAddress}, fee=${fee} pool`, e);
|
|
427
508
|
throw new Error('Cannot generate pool state');
|
|
428
509
|
}
|
|
429
510
|
}
|
|
430
511
|
if (pool !== null) {
|
|
431
512
|
const allEventPools = Object.values(this.eventPools);
|
|
432
|
-
this.logger.info(`
|
|
513
|
+
this.logger.info(`starting to listen to new non-null pool: ${key}. Already following ${allEventPools
|
|
433
514
|
// Not that I like this reduce, but since it is done only on initialization, expect this to be ok
|
|
434
515
|
.reduce((acc, curr) => (curr !== null ? ++acc : acc), 0)} non-null pools or ${allEventPools.length} total pools`);
|
|
435
516
|
}
|
|
436
|
-
this.eventPools[this.
|
|
517
|
+
this.eventPools[this.getPoolIdentifier(srcAddress, destAddress, fee)] =
|
|
518
|
+
pool;
|
|
437
519
|
}
|
|
438
520
|
return pool;
|
|
439
521
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
const requests = pools.map(pool => ({
|
|
446
|
-
owner: pool.poolAddress,
|
|
447
|
-
asset: side == constants_1.SwapSide.SELL ? from.address : to.address,
|
|
448
|
-
assetType: types_1.AssetType.ERC20,
|
|
449
|
-
ids: [
|
|
450
|
-
{
|
|
451
|
-
id: types_1.DEFAULT_ID_ERC20,
|
|
452
|
-
spenders: [],
|
|
453
|
-
},
|
|
454
|
-
],
|
|
455
|
-
}), []);
|
|
456
|
-
const balances = await (0, balancer_fetcher_1.getBalances)(this.dexHelper.multiWrapper, requests);
|
|
457
|
-
pools = pools.filter((pool, index) => {
|
|
458
|
-
const balance = balances[index].amounts[types_1.DEFAULT_ID_ERC20_AS_STRING];
|
|
459
|
-
if (balance >= amounts[amounts.length - 1]) {
|
|
460
|
-
return true;
|
|
461
|
-
}
|
|
462
|
-
this.logger.warn(`[${this.network}][${pool.parentName}] have no balance ${pool.poolAddress} ${from.address} ${to.address}. (Balance: ${balance})`);
|
|
463
|
-
return false;
|
|
464
|
-
});
|
|
465
|
-
pools.forEach(pool => {
|
|
466
|
-
this.logger.warn(`[${this.network}][${pool.parentName}] fallback to rpc for ${pool.name}`);
|
|
467
|
-
});
|
|
468
|
-
const unitVolume = (0, utils_1.getBigIntPow)((side === constants_1.SwapSide.SELL ? from : to).decimals);
|
|
469
|
-
const chunks = amounts.length - 1;
|
|
470
|
-
const _width = Math.floor(chunks / this.config.chunksCount);
|
|
471
|
-
const _amounts = [unitVolume].concat(Array.from(Array(this.config.chunksCount).keys()).map(i => amounts[(i + 1) * _width]));
|
|
472
|
-
const calldata = pools.map(pool => _amounts.map(_amount => ({
|
|
473
|
-
target: this.config.quoter,
|
|
474
|
-
gasLimit: constants_2.KS_ELASTIC_QUOTE_GASLIMIT,
|
|
475
|
-
callData: side === constants_1.SwapSide.SELL
|
|
476
|
-
? this.quoterIface.encodeFunctionData(types_2.KyberElasticFunctions.quoteExactInputSingle, [
|
|
477
|
-
{
|
|
478
|
-
tokenIn: from.address,
|
|
479
|
-
tokenOut: to.address,
|
|
480
|
-
amountIn: _amount,
|
|
481
|
-
feeUnits: pool.swapFeeUnits,
|
|
482
|
-
limitSqrtP: 0n,
|
|
483
|
-
},
|
|
484
|
-
])
|
|
485
|
-
: this.quoterIface.encodeFunctionData(types_2.KyberElasticFunctions.quoteExactOutputSingle, [
|
|
486
|
-
{
|
|
487
|
-
tokenIn: from.address,
|
|
488
|
-
tokenOut: to.address,
|
|
489
|
-
amount: _amount,
|
|
490
|
-
feeUnits: pool.swapFeeUnits,
|
|
491
|
-
limitSqrtP: 0n,
|
|
492
|
-
},
|
|
493
|
-
]),
|
|
494
|
-
})));
|
|
495
|
-
const data = await this.multicall.methods.multicall(calldata.flat()).call();
|
|
496
|
-
const decode = (j) => {
|
|
497
|
-
if (!data.returnData[j].success) {
|
|
498
|
-
return 0n;
|
|
499
|
-
}
|
|
500
|
-
const decoded = abi_1.defaultAbiCoder.decode(['uint256'], data.returnData[j].returnData);
|
|
501
|
-
return BigInt(decoded[0][1].toString());
|
|
502
|
-
};
|
|
503
|
-
let i = 0;
|
|
504
|
-
const result = pools.map(pool => {
|
|
505
|
-
const _rates = _amounts.map(() => decode(i++));
|
|
506
|
-
const unit = _rates[0];
|
|
507
|
-
const prices = (0, utils_1.interpolate)(_amounts.slice(1), _rates.slice(1), amounts, side);
|
|
508
|
-
return {
|
|
509
|
-
prices,
|
|
510
|
-
unit,
|
|
511
|
-
data: {
|
|
512
|
-
path: [
|
|
513
|
-
{
|
|
514
|
-
tokenIn: from.address,
|
|
515
|
-
tokenOut: to.address,
|
|
516
|
-
swapFeeUnits: pool.swapFeeUnits.toString(),
|
|
517
|
-
},
|
|
518
|
-
],
|
|
519
|
-
},
|
|
520
|
-
poolIdentifier: this._getPoolIdentifier(pool.token0, pool.token1, pool.swapFeeUnits),
|
|
521
|
-
exchange: this.dexKey,
|
|
522
|
-
gasCost: prices.map(p => (p === 0n ? 0 : constants_2.KS_ELASTIC_QUOTE_GASLIMIT)),
|
|
523
|
-
poolAddresses: [pool.poolAddress],
|
|
524
|
-
};
|
|
525
|
-
});
|
|
526
|
-
return result;
|
|
522
|
+
_getLoweredAddresses(srcToken, destToken) {
|
|
523
|
+
return [srcToken.address.toLowerCase(), destToken.address.toLowerCase()];
|
|
524
|
+
}
|
|
525
|
+
_sortTokens(srcAddress, destAddress) {
|
|
526
|
+
return [srcAddress, destAddress].sort((a, b) => (a < b ? -1 : 1));
|
|
527
527
|
}
|
|
528
|
-
// Normalise KyberswapElasticConfig
|
|
529
528
|
_toLowerForAllConfigAddresses() {
|
|
529
|
+
// If new config property will be added, the TS will throw compile error
|
|
530
530
|
const newConfig = {
|
|
531
531
|
router: this.config.router.toLowerCase(),
|
|
532
532
|
quoter: this.config.quoter.toLowerCase(),
|
|
533
533
|
factory: this.config.factory.toLowerCase(),
|
|
534
|
-
positionManager: this.config.positionManager.toLowerCase(),
|
|
535
|
-
ticksFeesReader: this.config.ticksFeesReader.toLowerCase(),
|
|
536
|
-
tokenPositionDescriptor: this.config.tokenPositionDescriptor.toLowerCase(),
|
|
537
534
|
supportedFees: this.config.supportedFees,
|
|
535
|
+
stateMulticall: this.config.stateMulticall.toLowerCase(),
|
|
538
536
|
chunksCount: this.config.chunksCount,
|
|
539
|
-
|
|
537
|
+
uniswapMulticall: this.config.uniswapMulticall,
|
|
538
|
+
deployer: this.config.deployer?.toLowerCase(),
|
|
539
|
+
initHash: this.config.initHash,
|
|
540
540
|
subgraphURL: this.config.subgraphURL,
|
|
541
541
|
};
|
|
542
542
|
return newConfig;
|
|
543
543
|
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
return '0x';
|
|
544
|
+
async _querySubgraph(query, variables, timeout = 30000) {
|
|
545
|
+
try {
|
|
546
|
+
const res = await this.dexHelper.httpRequest.post(this.config.subgraphURL, { query, variables }, undefined, { timeout: timeout });
|
|
547
|
+
return res.data;
|
|
548
|
+
}
|
|
549
|
+
catch (e) {
|
|
550
|
+
this.logger.error(`${this.dexKey}: can not query subgraph: `, e);
|
|
551
|
+
return {};
|
|
553
552
|
}
|
|
554
|
-
const { _path, types } = path.reduce(({ _path, types }, curr, index) => {
|
|
555
|
-
if (index === 0) {
|
|
556
|
-
return {
|
|
557
|
-
types: ['address', 'uint24', 'address'],
|
|
558
|
-
_path: [curr.tokenIn, curr.swapFeeUnits, curr.tokenOut],
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
else {
|
|
562
|
-
return {
|
|
563
|
-
types: [...types, 'uint24', 'address'],
|
|
564
|
-
_path: [..._path, curr.swapFeeUnits, curr.tokenOut],
|
|
565
|
-
};
|
|
566
|
-
}
|
|
567
|
-
}, { _path: [], types: [] });
|
|
568
|
-
return side === constants_1.SwapSide.BUY
|
|
569
|
-
? (0, solidity_1.pack)(types.reverse(), _path.reverse())
|
|
570
|
-
: (0, solidity_1.pack)(types, _path);
|
|
571
553
|
}
|
|
572
|
-
_getOutputs(state, amounts,
|
|
554
|
+
_getOutputs(state, amounts, zeroForOne, side, destTokenBalance) {
|
|
573
555
|
try {
|
|
574
|
-
const outputsResult =
|
|
556
|
+
const outputsResult = uniswap_v3_math_1.uniswapV3Math.queryOutputs(state, amounts, zeroForOne, side);
|
|
575
557
|
if (side === constants_1.SwapSide.SELL) {
|
|
576
558
|
if (outputsResult.outputs[0] > destTokenBalance) {
|
|
577
559
|
return null;
|
|
@@ -604,7 +586,13 @@ class KyberswapElastic extends simple_exchange_1.SimpleExchange {
|
|
|
604
586
|
return null;
|
|
605
587
|
}
|
|
606
588
|
}
|
|
589
|
+
releaseResources() {
|
|
590
|
+
if (this.intervalTask !== undefined) {
|
|
591
|
+
clearInterval(this.intervalTask);
|
|
592
|
+
this.intervalTask = undefined;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
607
595
|
}
|
|
608
|
-
exports.
|
|
609
|
-
|
|
610
|
-
//# sourceMappingURL=
|
|
596
|
+
exports.SushiswapV3 = SushiswapV3;
|
|
597
|
+
SushiswapV3.dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.SushiswapV3Config);
|
|
598
|
+
//# sourceMappingURL=sushiswap-v3-original.js.map
|