@paraswap/dex-lib 4.1.19 → 4.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/abi/AaveV1_lending_pool.json +27 -0
- package/build/abi/Aave_GSM.json +751 -0
- package/build/abi/Balancer.json +257 -0
- package/build/abi/BalancerV2.json +1179 -0
- package/build/abi/RamsesV2Pool.abi.json +1554 -0
- package/build/abi/RamsesV2Quoter.abi.json +274 -0
- package/build/abi/USDM.json +807 -0
- package/build/abi/UniswapV2Router.json +397 -0
- package/build/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +1246 -0
- package/build/abi/angle-transmuter/ChainlinkEACAggregatorProxy.json +509 -0
- package/build/abi/curve-v1/CurveBUSDv2.abi.json +1356 -0
- package/build/abi/curve-v1/CurveTokenV1.json +305 -0
- package/build/abi/curve-v1/CurveTokenV2.json +318 -0
- package/build/abi/curve-v1/CurveV1StableNg.json +1452 -0
- package/build/abi/curve-v1/CurveV2Swap.json +700 -0
- package/build/abi/curve-v1/FactoryCryptoRegistry.json +316 -0
- package/build/abi/curve-v1/FactoryRegistry.json +508 -0
- package/build/abi/curve-v1/StableSwapAave.json +1152 -0
- package/build/abi/curve-v1/StableSwapBUSD.json +814 -0
- package/build/abi/curve-v1/StableSwapCompound.json +814 -0
- package/build/abi/curve-v1/StableSwapIDLE.json +1253 -0
- package/build/abi/curve-v1/StableSwapPax.json +865 -0
- package/build/abi/curve-v1/StableSwapSnow.json +900 -0
- package/build/abi/curve-v1/StableSwapUSDN.json +1004 -0
- package/build/abi/curve-v1/StableSwapUSDT.json +814 -0
- package/build/abi/curve-v1/StableSwapY.json +814 -0
- package/build/abi/inception/inception-ineth-pool.json +1062 -0
- package/build/abi/inception/inception-ineth.json +609 -0
- package/build/abi/inception/inception-ratio-feed.json +329 -0
- package/build/abi/inception/inception-vault.json +991 -0
- package/build/abi/kyberdmm/kyber-storage.abi.json +824 -0
- package/build/abi/kyberdmm.abi.json +1148 -0
- package/build/abi/maverick-v2/MaverickV2Quoter.json +278 -0
- package/build/abi/nerve/nerve-metapool.json +790 -0
- package/build/abi/platypus/asset.json +490 -0
- package/build/abi/platypus/avax-pool.json +820 -0
- package/build/abi/platypus/oracle.json +119 -0
- package/build/abi/platypus/pool.json +677 -0
- package/build/abi/smardex/all/smardex-router.json +648 -0
- package/build/abi/smardex/layer-1/smardex-factory.json +242 -0
- package/build/abi/smardex/layer-1/smardex-pool.json +506 -0
- package/build/abi/smardex/layer-2/smardex-factory.json +185 -0
- package/build/abi/smardex/layer-2/smardex-pool.json +578 -0
- package/build/abi/swaap-v1/pool.json +1346 -0
- package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +193 -0
- package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +267 -0
- package/build/dex/aave-v1/aave-v1.d.ts +34 -0
- package/build/dex/aave-v1/aave-v1.js +180 -0
- package/build/dex/aave-v1/aave-v1.js.map +1 -0
- package/build/dex/aave-v1/config.d.ts +11 -0
- package/build/dex/aave-v1/config.js +20 -0
- package/build/dex/aave-v1/config.js.map +1 -0
- package/build/dex/aave-v1/tokens-mainnet.json +134 -0
- package/build/dex/aave-v1/tokens.d.ts +3 -0
- package/build/dex/aave-v1/tokens.js +50 -0
- package/build/dex/aave-v1/tokens.js.map +1 -0
- package/build/dex/aave-v1/types.d.ts +12 -0
- package/build/dex/aave-v1/types.js +3 -0
- package/build/dex/aave-v1/types.js.map +1 -0
- package/build/dex/balancer-v1/balancer-pools.json +33333 -0
- package/build/dex/balancer-v3/balancer-test-helpers.d.ts +5 -0
- package/build/dex/balancer-v3/balancer-test-helpers.js +25 -1
- package/build/dex/balancer-v3/balancer-test-helpers.js.map +1 -1
- package/build/dex/balancer-v3/balancer-v3-pool.js +35 -7
- package/build/dex/balancer-v3/balancer-v3-pool.js.map +1 -1
- package/build/dex/balancer-v3/balancer-v3.js +9 -2
- package/build/dex/balancer-v3/balancer-v3.js.map +1 -1
- package/build/dex/balancer-v3/config.d.ts +2 -1
- package/build/dex/balancer-v3/config.js +7 -0
- package/build/dex/balancer-v3/config.js.map +1 -1
- package/build/dex/balancer-v3/getGasCost.js +3 -0
- package/build/dex/balancer-v3/getGasCost.js.map +1 -1
- package/build/dex/balancer-v3/getOnChainState.d.ts +5 -1
- package/build/dex/balancer-v3/getOnChainState.js +69 -9
- package/build/dex/balancer-v3/getOnChainState.js.map +1 -1
- package/build/dex/balancer-v3/getPoolsApi.js +45 -7
- package/build/dex/balancer-v3/getPoolsApi.js.map +1 -1
- package/build/dex/balancer-v3/getTopPoolsApi.d.ts +4 -3
- package/build/dex/balancer-v3/getTopPoolsApi.js +17 -6
- package/build/dex/balancer-v3/getTopPoolsApi.js.map +1 -1
- package/build/dex/balancer-v3/gyroECLPPool.d.ts +11 -0
- package/build/dex/balancer-v3/gyroECLPPool.js +6 -0
- package/build/dex/balancer-v3/gyroECLPPool.js.map +1 -0
- package/build/dex/balancer-v3/hooks/directionalFeeHook.d.ts +2 -0
- package/build/dex/balancer-v3/hooks/directionalFeeHook.js +1 -0
- package/build/dex/balancer-v3/hooks/directionalFeeHook.js.map +1 -1
- package/build/dex/balancer-v3/hooks/stableSurgeHook.d.ts +2 -0
- package/build/dex/balancer-v3/hooks/stableSurgeHook.js +1 -0
- package/build/dex/balancer-v3/hooks/stableSurgeHook.js.map +1 -1
- package/build/dex/balancer-v3/types.d.ts +6 -2
- package/build/dex/balancer-v3/utils.d.ts +2 -0
- package/build/dex/balancer-v3/utils.js +11 -0
- package/build/dex/balancer-v3/utils.js.map +1 -0
- package/build/dex/bebop/websocket-fetcher.d.ts +35 -0
- package/build/dex/bebop/websocket-fetcher.js +87 -0
- package/build/dex/bebop/websocket-fetcher.js.map +1 -0
- package/build/dex/idle-dao/idle-dao-pool.d.ts +56 -0
- package/build/dex/idle-dao/idle-dao-pool.js +176 -0
- package/build/dex/idle-dao/idle-dao-pool.js.map +1 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +16 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js +57 -0
- package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +1 -0
- package/build/dex/idle-dao/scripts.d.ts +9 -0
- package/build/dex/idle-dao/scripts.js +552 -0
- package/build/dex/idle-dao/scripts.js.map +1 -0
- package/build/dex/inception/config.d.ts +4 -0
- package/build/dex/inception/config.js +109 -0
- package/build/dex/inception/config.js.map +1 -0
- package/build/dex/inception/inception-event-pool.d.ts +16 -0
- package/build/dex/inception/inception-event-pool.js +51 -0
- package/build/dex/inception/inception-event-pool.js.map +1 -0
- package/build/dex/inception/inception-native.d.ts +43 -0
- package/build/dex/inception/inception-native.js +131 -0
- package/build/dex/inception/inception-native.js.map +1 -0
- package/build/dex/inception/inception-pool.d.ts +18 -0
- package/build/dex/inception/inception-pool.js +32 -0
- package/build/dex/inception/inception-pool.js.map +1 -0
- package/build/dex/inception/inception-price-feed.d.ts +19 -0
- package/build/dex/inception/inception-price-feed.js +51 -0
- package/build/dex/inception/inception-price-feed.js.map +1 -0
- package/build/dex/inception/inception.d.ts +43 -0
- package/build/dex/inception/inception.js +204 -0
- package/build/dex/inception/inception.js.map +1 -0
- package/build/dex/inception/tokens.d.ts +9 -0
- package/build/dex/inception/tokens.js +28 -0
- package/build/dex/inception/tokens.js.map +1 -0
- package/build/dex/inception/types.d.ts +22 -0
- package/build/dex/inception/types.js +3 -0
- package/build/dex/inception/types.js.map +1 -0
- package/build/dex/inception/utils.d.ts +6 -0
- package/build/dex/inception/utils.js +37 -0
- package/build/dex/inception/utils.js.map +1 -0
- package/build/dex/platypus/asset.d.ts +14 -0
- package/build/dex/platypus/asset.js +97 -0
- package/build/dex/platypus/asset.js.map +1 -0
- package/build/dex/platypus/config.d.ts +11 -0
- package/build/dex/platypus/config.js +69 -0
- package/build/dex/platypus/config.js.map +1 -0
- package/build/dex/platypus/platypus.d.ts +63 -0
- package/build/dex/platypus/platypus.js +473 -0
- package/build/dex/platypus/platypus.js.map +1 -0
- package/build/dex/platypus/pool-avax.d.ts +8 -0
- package/build/dex/platypus/pool-avax.js +54 -0
- package/build/dex/platypus/pool-avax.js.map +1 -0
- package/build/dex/platypus/pool-base.d.ts +19 -0
- package/build/dex/platypus/pool-base.js +86 -0
- package/build/dex/platypus/pool-base.js.map +1 -0
- package/build/dex/platypus/pool-pure.d.ts +8 -0
- package/build/dex/platypus/pool-pure.js +37 -0
- package/build/dex/platypus/pool-pure.js.map +1 -0
- package/build/dex/platypus/pool-subscriber.d.ts +14 -0
- package/build/dex/platypus/pool-subscriber.js +167 -0
- package/build/dex/platypus/pool-subscriber.js.map +1 -0
- package/build/dex/platypus/pool.d.ts +8 -0
- package/build/dex/platypus/pool.js +58 -0
- package/build/dex/platypus/pool.js.map +1 -0
- package/build/dex/platypus/types.d.ts +92 -0
- package/build/dex/platypus/types.js +10 -0
- package/build/dex/platypus/types.js.map +1 -0
- package/build/dex/quickswap/spiritswap-v3.d.ts +6 -0
- package/build/dex/quickswap/spiritswap-v3.js +19 -0
- package/build/dex/quickswap/spiritswap-v3.js.map +1 -0
- package/build/dex/smardex/config.d.ts +4 -0
- package/build/dex/smardex/config.js +64 -0
- package/build/dex/smardex/config.js.map +1 -0
- package/build/dex/smardex/constants.d.ts +18 -0
- package/build/dex/smardex/constants.js +33 -0
- package/build/dex/smardex/constants.js.map +1 -0
- package/build/dex/smardex/sdk/constants.d.ts +6 -0
- package/build/dex/smardex/sdk/constants.js +13 -0
- package/build/dex/smardex/sdk/constants.js.map +1 -0
- package/build/dex/smardex/sdk/core.d.ts +113 -0
- package/build/dex/smardex/sdk/core.js +499 -0
- package/build/dex/smardex/sdk/core.js.map +1 -0
- package/build/dex/smardex/sdk/errors.d.ts +15 -0
- package/build/dex/smardex/sdk/errors.js +22 -0
- package/build/dex/smardex/sdk/errors.js.map +1 -0
- package/build/dex/smardex/sdk/types.d.ts +62 -0
- package/build/dex/smardex/sdk/types.js +3 -0
- package/build/dex/smardex/sdk/types.js.map +1 -0
- package/build/dex/smardex/sdk/utils.d.ts +44 -0
- package/build/dex/smardex/sdk/utils.js +133 -0
- package/build/dex/smardex/sdk/utils.js.map +1 -0
- package/build/dex/smardex/smardex-event-pool.d.ts +28 -0
- package/build/dex/smardex/smardex-event-pool.js +119 -0
- package/build/dex/smardex/smardex-event-pool.js.map +1 -0
- package/build/dex/smardex/smardex.d.ts +65 -0
- package/build/dex/smardex/smardex.js +519 -0
- package/build/dex/smardex/smardex.js.map +1 -0
- package/build/dex/smardex/types.d.ts +55 -0
- package/build/dex/smardex/types.js +3 -0
- package/build/dex/smardex/types.js.map +1 -0
- package/build/dex/solidly/forks-override/cone.d.ts +22 -0
- package/build/dex/solidly/forks-override/cone.js +53 -0
- package/build/dex/solidly/forks-override/cone.js.map +1 -0
- package/build/dex/solidly/forks-override/solisnek.d.ts +8 -0
- package/build/dex/solidly/forks-override/solisnek.js +15 -0
- package/build/dex/solidly/forks-override/solisnek.js.map +1 -0
- package/build/dex/swaap-v1/config.d.ts +17 -0
- package/build/dex/swaap-v1/config.js +56 -0
- package/build/dex/swaap-v1/config.js.map +1 -0
- package/build/dex/swaap-v1/constants.d.ts +6 -0
- package/build/dex/swaap-v1/constants.js +17 -0
- package/build/dex/swaap-v1/constants.js.map +1 -0
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.d.ts +25 -0
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.js +62 -0
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.js.map +1 -0
- package/build/dex/swaap-v1/libraries/Const.d.ts +18 -0
- package/build/dex/swaap-v1/libraries/Const.js +26 -0
- package/build/dex/swaap-v1/libraries/Const.js.map +1 -0
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.d.ts +77 -0
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js +316 -0
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js.map +1 -0
- package/build/dex/swaap-v1/libraries/LogExpMath.d.ts +75 -0
- package/build/dex/swaap-v1/libraries/LogExpMath.js +418 -0
- package/build/dex/swaap-v1/libraries/LogExpMath.js.map +1 -0
- package/build/dex/swaap-v1/libraries/MathMMM.d.ts +185 -0
- package/build/dex/swaap-v1/libraries/MathMMM.js +453 -0
- package/build/dex/swaap-v1/libraries/MathMMM.js.map +1 -0
- package/build/dex/swaap-v1/libraries/Num.d.ts +31 -0
- package/build/dex/swaap-v1/libraries/Num.js +167 -0
- package/build/dex/swaap-v1/libraries/Num.js.map +1 -0
- package/build/dex/swaap-v1/libraries/PoolQuotations.d.ts +23 -0
- package/build/dex/swaap-v1/libraries/PoolQuotations.js +131 -0
- package/build/dex/swaap-v1/libraries/PoolQuotations.js.map +1 -0
- package/build/dex/swaap-v1/libraries/Struct.d.ts +56 -0
- package/build/dex/swaap-v1/libraries/Struct.js +3 -0
- package/build/dex/swaap-v1/libraries/Struct.js.map +1 -0
- package/build/dex/swaap-v1/swaap-v1-pool.d.ts +45 -0
- package/build/dex/swaap-v1/swaap-v1-pool.js +656 -0
- package/build/dex/swaap-v1/swaap-v1-pool.js.map +1 -0
- package/build/dex/swaap-v1/swaap-v1.d.ts +62 -0
- package/build/dex/swaap-v1/swaap-v1.js +379 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -0
- package/build/dex/swaap-v1/types.d.ts +106 -0
- package/build/dex/swaap-v1/types.js +9 -0
- package/build/dex/swaap-v1/types.js.map +1 -0
- package/build/dex/zerox/index.d.ts +1 -1
- package/build/dex/zerox/index.js.map +1 -1
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +16 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +16 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +16 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +16 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +16 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +16 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +16 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +16 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +9 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +9 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +9 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +9 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +9 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +9 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +9 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +9 -0
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +9 -0
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +12 -0
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +7 -0
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +7 -0
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +7 -0
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +7 -0
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +12 -0
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +7 -0
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +7 -0
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +78 -0
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +81 -0
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +78 -0
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +78 -0
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +81 -0
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +81 -0
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +81 -0
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +81 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +64 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +85 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +64 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +52 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +52 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +52 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +55 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +55 -0
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +55 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +23 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +37 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +23 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +23 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +51 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +58 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +23 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +23 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +9 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +16 -0
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +23 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +12 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +7 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +12 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +12 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +7 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +7 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +7 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +7 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +7 -0
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +7 -0
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +130 -0
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +136 -0
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +100 -0
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +100 -0
- package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +166 -0
- package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +190 -0
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +114 -0
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +114 -0
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +55 -0
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +73 -0
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +82 -0
- package/package.json +2 -2
- package/src/dex/balancer-v3/balancer-api.test.ts +122 -0
- package/src/dex/balancer-v3/balancer-buffer.test.ts +75 -0
- package/src/dex/balancer-v3/balancer-gyroECLP.test.ts +76 -0
- package/src/dex/balancer-v3/balancer-stableSurge.test.ts +54 -52
- package/src/dex/balancer-v3/balancer-test-helpers.ts +52 -0
- package/src/dex/balancer-v3/balancer-test-weighted.test.ts +96 -0
- package/src/dex/balancer-v3/balancer-v3-e2e.test.ts +49 -2
- package/src/dex/balancer-v3/balancer-v3-events.test.ts +162 -1
- package/src/dex/balancer-v3/balancer-v3-pool.ts +50 -15
- package/src/dex/balancer-v3/balancer-v3.ts +14 -4
- package/src/dex/balancer-v3/config.ts +7 -0
- package/src/dex/balancer-v3/getGasCost.ts +3 -0
- package/src/dex/balancer-v3/getOnChainState.ts +101 -12
- package/src/dex/balancer-v3/getPoolsApi.ts +55 -12
- package/src/dex/balancer-v3/getTopPoolsApi.ts +29 -11
- package/src/dex/balancer-v3/gyroECLPPool.ts +17 -0
- package/src/dex/balancer-v3/hooks/directionalFeeHook.ts +2 -0
- package/src/dex/balancer-v3/hooks/stableSurgeHook.ts +2 -0
- package/src/dex/balancer-v3/types.ts +6 -2
- package/src/dex/balancer-v3/utils.ts +11 -0
- package/tests/constants-e2e.ts +9 -0
- package/tests/token-storage-slots.json +40 -0
- package/.idea/codeStyles/Project.xml +0 -59
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/paraswap-dex-lib.iml +0 -12
- package/.idea/prettier.xml +0 -7
- package/.idea/vcs.xml +0 -6
- package/build/dex/uniswap-v3/uniswap-v3-new.d.ts +0 -94
- package/build/dex/uniswap-v3/uniswap-v3-new.js +0 -923
- package/build/dex/uniswap-v3/uniswap-v3-new.js.map +0 -1
- package/scripts/get-uniswap-v3-dexes.ts +0 -64
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"blockNumber": 18813323,
|
|
3
|
+
"network": 1,
|
|
4
|
+
"srcToken": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
5
|
+
"srcDecimals": 18,
|
|
6
|
+
"srcAmount": "4000000000000000000",
|
|
7
|
+
"destToken": "0x6b3595068778dd592e39a122f4f5a5cf09c90fe2",
|
|
8
|
+
"destDecimals": 18,
|
|
9
|
+
"destAmount": "7097049665124498485140",
|
|
10
|
+
"bestRoute": [
|
|
11
|
+
{
|
|
12
|
+
"percent": 100,
|
|
13
|
+
"swaps": [
|
|
14
|
+
{
|
|
15
|
+
"srcToken": "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
|
|
16
|
+
"srcDecimals": 18,
|
|
17
|
+
"destToken": "0x6b3595068778dd592e39a122f4f5a5cf09c90fe2",
|
|
18
|
+
"destDecimals": 18,
|
|
19
|
+
"swapExchanges": [
|
|
20
|
+
{
|
|
21
|
+
"exchange": "UniswapV3",
|
|
22
|
+
"srcAmount": "2080000000000000000",
|
|
23
|
+
"destAmount": "3666930750962393744865",
|
|
24
|
+
"percent": 52,
|
|
25
|
+
"poolAddresses": ["0x73a6a761fe483ba19debb8f56ac5bbf14c0cdad1"],
|
|
26
|
+
"data": {
|
|
27
|
+
"path": [
|
|
28
|
+
{
|
|
29
|
+
"tokenIn": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
|
30
|
+
"tokenOut": "0x6b3595068778dd592e39a122f4f5a5cf09c90fe2",
|
|
31
|
+
"fee": "3000",
|
|
32
|
+
"currentFee": "3000"
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"gasUSD": "93.841590"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"exchange": "SushiSwapV3",
|
|
40
|
+
"srcAmount": "1920000000000000000",
|
|
41
|
+
"destAmount": "3430118914162104740275",
|
|
42
|
+
"percent": 48,
|
|
43
|
+
"poolAddresses": ["0x87c7056bbe6084f03304196be51c6b90b6d85aa2"],
|
|
44
|
+
"data": {
|
|
45
|
+
"path": [
|
|
46
|
+
{
|
|
47
|
+
"tokenIn": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
|
48
|
+
"tokenOut": "0x6b3595068778dd592e39a122f4f5a5cf09c90fe2",
|
|
49
|
+
"fee": "3000",
|
|
50
|
+
"currentFee": "3000"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
"gasUSD": "22.090144"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"gasCostUSD": "131.145698",
|
|
62
|
+
"gasCost": "789600",
|
|
63
|
+
"side": "SELL",
|
|
64
|
+
"tokenTransferProxy": "0x216b4b4ba9f3e719726886d34a177484278bfcae",
|
|
65
|
+
"contractAddress": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",
|
|
66
|
+
"contractMethod": "simpleSwap",
|
|
67
|
+
"partnerFee": 0,
|
|
68
|
+
"srcUSD": "8628.1200000000",
|
|
69
|
+
"destUSD": "7877.7251282882",
|
|
70
|
+
"partner": "any",
|
|
71
|
+
"maxImpactReached": false,
|
|
72
|
+
"hmac": "252d803fc8ca53537c22905da85ed276ae827eb4"
|
|
73
|
+
}
|
package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"blockNumber": 18813366,
|
|
3
|
+
"network": 1,
|
|
4
|
+
"srcToken": "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
|
5
|
+
"srcDecimals": 6,
|
|
6
|
+
"srcAmount": "10000500000000",
|
|
7
|
+
"destToken": "0x6b175474e89094c44da98b954eedeac495271d0f",
|
|
8
|
+
"destDecimals": 18,
|
|
9
|
+
"destAmount": "9986733042911056529251220",
|
|
10
|
+
"bestRoute": [
|
|
11
|
+
{
|
|
12
|
+
"percent": 100,
|
|
13
|
+
"swaps": [
|
|
14
|
+
{
|
|
15
|
+
"srcToken": "0xdac17f958d2ee523a2206206994597c13d831ec7",
|
|
16
|
+
"srcDecimals": 6,
|
|
17
|
+
"destToken": "0x6b175474e89094c44da98b954eedeac495271d0f",
|
|
18
|
+
"destDecimals": 18,
|
|
19
|
+
"swapExchanges": [
|
|
20
|
+
{
|
|
21
|
+
"exchange": "CurveV1",
|
|
22
|
+
"srcAmount": "200010000000",
|
|
23
|
+
"destAmount": "199724930804948075871073",
|
|
24
|
+
"percent": 2,
|
|
25
|
+
"poolAddresses": ["0xa5407eae9ba41422680e2e00537571bcc53efbfd"],
|
|
26
|
+
"data": {
|
|
27
|
+
"exchange": "0xa5407eae9ba41422680e2e00537571bcc53efbfd",
|
|
28
|
+
"i": 2,
|
|
29
|
+
"j": 0,
|
|
30
|
+
"underlyingSwap": true,
|
|
31
|
+
"deadline": 0,
|
|
32
|
+
"gasUSD": "59.460060"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"exchange": "CurveV1",
|
|
37
|
+
"srcAmount": "8800440000000",
|
|
38
|
+
"destAmount": "8788481925522943324040552",
|
|
39
|
+
"percent": 88,
|
|
40
|
+
"poolAddresses": ["0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7"],
|
|
41
|
+
"data": {
|
|
42
|
+
"exchange": "0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7",
|
|
43
|
+
"i": 2,
|
|
44
|
+
"j": 0,
|
|
45
|
+
"underlyingSwap": false,
|
|
46
|
+
"deadline": 0,
|
|
47
|
+
"gasUSD": "59.460060"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"exchange": "CurveV1",
|
|
52
|
+
"srcAmount": "1000050000000",
|
|
53
|
+
"destAmount": "998526186583165129339595",
|
|
54
|
+
"percent": 10,
|
|
55
|
+
"poolAddresses": ["0xdebf20617708857ebe4f679508e7b7863a8a8eee"],
|
|
56
|
+
"data": {
|
|
57
|
+
"exchange": "0xdebf20617708857ebe4f679508e7b7863a8a8eee",
|
|
58
|
+
"i": 2,
|
|
59
|
+
"j": 0,
|
|
60
|
+
"underlyingSwap": true,
|
|
61
|
+
"deadline": 0,
|
|
62
|
+
"gasUSD": "101.082102"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
"gasCostUSD": "253.180935",
|
|
71
|
+
"gasCost": "851600",
|
|
72
|
+
"side": "SELL",
|
|
73
|
+
"tokenTransferProxy": "0x216b4b4ba9f3e719726886d34a177484278bfcae",
|
|
74
|
+
"contractAddress": "0xDEF171Fe48CF0115B1d80b88dc8eAB59176FEe57",
|
|
75
|
+
"contractMethod": "simpleSwap",
|
|
76
|
+
"partnerFee": 0,
|
|
77
|
+
"srcUSD": "9991539.5520000000",
|
|
78
|
+
"destUSD": "9986303.5135228809",
|
|
79
|
+
"partner": "any",
|
|
80
|
+
"maxImpactReached": false,
|
|
81
|
+
"hmac": "062b93a127ea430933d4eaf5ffc56e0106414e69"
|
|
82
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paraswap/dex-lib",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.20",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"types": "build/index.d.ts",
|
|
6
6
|
"repository": "https://github.com/paraswap/paraswap-dex-lib",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@0x/utils": "^4.5.2",
|
|
55
|
-
"@balancer-labs/balancer-maths": "^0.0.
|
|
55
|
+
"@balancer-labs/balancer-maths": "^0.0.26",
|
|
56
56
|
"@balancer-labs/sor": "4.1.3",
|
|
57
57
|
"@bgd-labs/aave-address-book": "4.15.1",
|
|
58
58
|
"@ethersproject/abi": "^5.7.0",
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// npx jest src/dex/balancer-v3/balancer-api.test.ts
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
import { getPoolsApi } from './getPoolsApi';
|
|
4
|
+
import { getTopPoolsApi, Pool } from './getTopPoolsApi';
|
|
5
|
+
import { loadHooksConfig } from './hooks/loadHooksConfig';
|
|
6
|
+
import { ImmutablePoolStateMap } from './types';
|
|
7
|
+
|
|
8
|
+
const network = 1;
|
|
9
|
+
const rstETHLidoPoolAddr = '0x121edb0badc036f5fc610d015ee14093c142313b';
|
|
10
|
+
const stableSurgePoolAddr = '0x9ed5175aecb6653c1bdaa19793c16fd74fbeeb37';
|
|
11
|
+
const hooksConfigMap = loadHooksConfig(network);
|
|
12
|
+
|
|
13
|
+
describe('Balancer API Tests', function () {
|
|
14
|
+
describe('getPoolsApi', function () {
|
|
15
|
+
let pools: ImmutablePoolStateMap;
|
|
16
|
+
|
|
17
|
+
beforeAll(async () => {
|
|
18
|
+
pools = await getPoolsApi(network, hooksConfigMap);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should handle pool with ERC4626 not suitable for swaps', function () {
|
|
22
|
+
const expectedPool = {
|
|
23
|
+
poolAddress: rstETHLidoPoolAddr,
|
|
24
|
+
tokens: [
|
|
25
|
+
'0x775f661b0bd1739349b9a2a3ef60be277c5d2d29',
|
|
26
|
+
'0x7a4effd87c2f3c55ca251080b1343b605f327e3a',
|
|
27
|
+
],
|
|
28
|
+
tokensUnderlying: ['0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0', null],
|
|
29
|
+
weights: [0n, 0n],
|
|
30
|
+
poolType: 'STABLE',
|
|
31
|
+
hookAddress: undefined,
|
|
32
|
+
hookType: undefined,
|
|
33
|
+
supportsUnbalancedLiquidity: true,
|
|
34
|
+
dSq: 0n,
|
|
35
|
+
paramsAlpha: 0n,
|
|
36
|
+
paramsBeta: 0n,
|
|
37
|
+
paramsC: 0n,
|
|
38
|
+
paramsLambda: 0n,
|
|
39
|
+
paramsS: 0n,
|
|
40
|
+
tauAlphaX: 0n,
|
|
41
|
+
tauAlphaY: 0n,
|
|
42
|
+
tauBetaX: 0n,
|
|
43
|
+
tauBetaY: 0n,
|
|
44
|
+
u: 0n,
|
|
45
|
+
v: 0n,
|
|
46
|
+
w: 0n,
|
|
47
|
+
z: 0n,
|
|
48
|
+
};
|
|
49
|
+
expect(pools[rstETHLidoPoolAddr]).toEqual(expectedPool);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should fetch pool with stableSurge hook', function () {
|
|
53
|
+
const expectedPool = {
|
|
54
|
+
poolAddress: stableSurgePoolAddr,
|
|
55
|
+
tokens: [
|
|
56
|
+
'0x775f661b0bd1739349b9a2a3ef60be277c5d2d29',
|
|
57
|
+
'0xd11c452fc99cf405034ee446803b6f6c1f6d5ed8',
|
|
58
|
+
],
|
|
59
|
+
tokensUnderlying: ['0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0', null],
|
|
60
|
+
weights: [0n, 0n],
|
|
61
|
+
poolType: 'STABLE',
|
|
62
|
+
hookAddress: '0xb18fa0cb5de8cecb8899aae6e38b1b7ed77885da',
|
|
63
|
+
hookType: 'StableSurge',
|
|
64
|
+
supportsUnbalancedLiquidity: true,
|
|
65
|
+
dSq: 0n,
|
|
66
|
+
paramsAlpha: 0n,
|
|
67
|
+
paramsBeta: 0n,
|
|
68
|
+
paramsC: 0n,
|
|
69
|
+
paramsLambda: 0n,
|
|
70
|
+
paramsS: 0n,
|
|
71
|
+
tauAlphaX: 0n,
|
|
72
|
+
tauAlphaY: 0n,
|
|
73
|
+
tauBetaX: 0n,
|
|
74
|
+
tauBetaY: 0n,
|
|
75
|
+
u: 0n,
|
|
76
|
+
v: 0n,
|
|
77
|
+
w: 0n,
|
|
78
|
+
z: 0n,
|
|
79
|
+
};
|
|
80
|
+
expect(pools[stableSurgePoolAddr]).toEqual(expectedPool);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('getTopPoolsApi', function () {
|
|
85
|
+
let pools: Pool[];
|
|
86
|
+
|
|
87
|
+
beforeAll(async () => {
|
|
88
|
+
pools = await getTopPoolsApi(
|
|
89
|
+
network,
|
|
90
|
+
[rstETHLidoPoolAddr, stableSurgePoolAddr],
|
|
91
|
+
2,
|
|
92
|
+
hooksConfigMap,
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should handle pool with ERC4626 not suitable for swaps', async function () {
|
|
97
|
+
const expectedPoolTokens = [
|
|
98
|
+
{
|
|
99
|
+
address: '0x775f661b0bd1739349b9a2a3ef60be277c5d2d29',
|
|
100
|
+
decimals: 18,
|
|
101
|
+
canUseBufferForSwaps: true,
|
|
102
|
+
underlyingToken: {
|
|
103
|
+
address: '0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0',
|
|
104
|
+
decimals: 18,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
address: '0x7a4effd87c2f3c55ca251080b1343b605f327e3a',
|
|
109
|
+
decimals: 18,
|
|
110
|
+
canUseBufferForSwaps: false,
|
|
111
|
+
underlyingToken: null,
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
const pool = pools.find(p => p.address === rstETHLidoPoolAddr);
|
|
115
|
+
expect(pool).toBeDefined();
|
|
116
|
+
expect(pool!.poolTokens).toEqual(expectedPoolTokens);
|
|
117
|
+
});
|
|
118
|
+
it('should fetch pool with stableSurge hook', async function () {
|
|
119
|
+
expect(pools.some(p => p.address === stableSurgePoolAddr)).toBe(true);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// npx jest src/dex/balancer-v3/balancer-buffer.test.ts
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
import { Tokens } from '../../../tests/constants-e2e';
|
|
5
|
+
import { Network, SwapSide } from '../../constants';
|
|
6
|
+
import { DummyDexHelper } from '../../dex-helper';
|
|
7
|
+
import { BalancerV3 } from './balancer-v3';
|
|
8
|
+
|
|
9
|
+
const dexKey = 'BalancerV3';
|
|
10
|
+
const blockNumber = 21990000;
|
|
11
|
+
let balancerV3: BalancerV3;
|
|
12
|
+
const network = Network.MAINNET;
|
|
13
|
+
const dexHelper = new DummyDexHelper(network);
|
|
14
|
+
const tokens = Tokens[network];
|
|
15
|
+
const usdc = tokens['USDC'];
|
|
16
|
+
const waEthUSDC = tokens['waEthUSDC'];
|
|
17
|
+
|
|
18
|
+
// https://balancer.fi/pools/ethereum/v3/0x85b2b559bc2d21104c4defdd6efca8a20343361d
|
|
19
|
+
const boostedStablePool = '0x85b2b559bc2d21104c4defdd6efca8a20343361d';
|
|
20
|
+
|
|
21
|
+
describe('BalancerV3 Buffer/ERC4626 tests', function () {
|
|
22
|
+
beforeAll(async () => {
|
|
23
|
+
balancerV3 = new BalancerV3(network, dexKey, dexHelper);
|
|
24
|
+
if (balancerV3.initializePricing) {
|
|
25
|
+
await balancerV3.initializePricing(blockNumber);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('boosted stable pool should be returned', function () {
|
|
30
|
+
it('getPoolIdentifiers', async function () {
|
|
31
|
+
const pools = await balancerV3.getPoolIdentifiers(
|
|
32
|
+
usdc,
|
|
33
|
+
waEthUSDC,
|
|
34
|
+
SwapSide.SELL,
|
|
35
|
+
blockNumber,
|
|
36
|
+
);
|
|
37
|
+
expect(pools.some(pool => pool === boostedStablePool)).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('getTopPoolsForToken', async function () {
|
|
41
|
+
const pools = await balancerV3.getTopPoolsForToken(waEthUSDC.address, 10);
|
|
42
|
+
expect(pools.some(pool => pool.address === boostedStablePool)).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe('should return 0 prices when amount > maxDeposit/mint', function () {
|
|
47
|
+
it('SELL (maxDeposit)', async function () {
|
|
48
|
+
const amounts = [0n, 10000000000000000n];
|
|
49
|
+
const side = SwapSide.SELL;
|
|
50
|
+
|
|
51
|
+
const prices = await balancerV3.getPricesVolume(
|
|
52
|
+
usdc,
|
|
53
|
+
waEthUSDC,
|
|
54
|
+
amounts,
|
|
55
|
+
side,
|
|
56
|
+
blockNumber,
|
|
57
|
+
[boostedStablePool],
|
|
58
|
+
);
|
|
59
|
+
prices![0].prices.forEach(p => expect(p).toEqual(0n));
|
|
60
|
+
});
|
|
61
|
+
it('BUY (maxMint)', async function () {
|
|
62
|
+
const amounts = [0n, 500000000000000000n];
|
|
63
|
+
const side = SwapSide.BUY;
|
|
64
|
+
const prices = await balancerV3.getPricesVolume(
|
|
65
|
+
usdc,
|
|
66
|
+
waEthUSDC,
|
|
67
|
+
amounts,
|
|
68
|
+
side,
|
|
69
|
+
blockNumber,
|
|
70
|
+
[boostedStablePool],
|
|
71
|
+
);
|
|
72
|
+
prices![0].prices.forEach(p => expect(p).toEqual(0n));
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// npx jest src/dex/balancer-v3/balancer-gyroECLP.test.ts
|
|
2
|
+
import dotenv from 'dotenv';
|
|
3
|
+
dotenv.config();
|
|
4
|
+
import { Tokens } from '../../../tests/constants-e2e';
|
|
5
|
+
import { Network, SwapSide } from '../../constants';
|
|
6
|
+
import { DummyDexHelper } from '../../dex-helper';
|
|
7
|
+
import { BalancerV3 } from './balancer-v3';
|
|
8
|
+
import { testPricesVsOnchain } from './balancer-test-helpers';
|
|
9
|
+
|
|
10
|
+
const dexKey = 'BalancerV3';
|
|
11
|
+
const blockNumber = 317980000;
|
|
12
|
+
let balancerV3: BalancerV3;
|
|
13
|
+
const network = Network.ARBITRUM;
|
|
14
|
+
const dexHelper = new DummyDexHelper(network);
|
|
15
|
+
const tokens = Tokens[network];
|
|
16
|
+
const eBTC = tokens['eBTC'];
|
|
17
|
+
const usdc = tokens['USDC'];
|
|
18
|
+
// https://arbiscan.io/address/0xa0e5e7728e026bde02810d255a6b94a9aa47b5f9
|
|
19
|
+
const gyroECLPPool = '0xa0e5e7728e026bde02810d255a6b94a9aa47b5f9'.toLowerCase();
|
|
20
|
+
|
|
21
|
+
describe('BalancerV3 GyroECLP tests', function () {
|
|
22
|
+
beforeAll(async () => {
|
|
23
|
+
balancerV3 = new BalancerV3(network, dexKey, dexHelper);
|
|
24
|
+
if (balancerV3.initializePricing) {
|
|
25
|
+
await balancerV3.initializePricing(blockNumber);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('GyroECLP pool should be returned', function () {
|
|
30
|
+
it('getPoolIdentifiers', async function () {
|
|
31
|
+
const pools = await balancerV3.getPoolIdentifiers(
|
|
32
|
+
eBTC,
|
|
33
|
+
usdc,
|
|
34
|
+
SwapSide.SELL,
|
|
35
|
+
blockNumber,
|
|
36
|
+
);
|
|
37
|
+
expect(pools.some(pool => pool === gyroECLPPool)).toBe(true);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('getTopPoolsForToken', async function () {
|
|
41
|
+
const pools = await balancerV3.getTopPoolsForToken(usdc.address, 10);
|
|
42
|
+
expect(pools.some(pool => pool.address === gyroECLPPool)).toBe(true);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('should match onchain pricing', function () {
|
|
46
|
+
it('SELL', async function () {
|
|
47
|
+
const amounts = [0n, 10000000n];
|
|
48
|
+
const side = SwapSide.SELL;
|
|
49
|
+
await testPricesVsOnchain(
|
|
50
|
+
balancerV3,
|
|
51
|
+
network,
|
|
52
|
+
amounts,
|
|
53
|
+
usdc,
|
|
54
|
+
eBTC,
|
|
55
|
+
side,
|
|
56
|
+
blockNumber,
|
|
57
|
+
[gyroECLPPool],
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
it('BUY', async function () {
|
|
61
|
+
const amounts = [0n, 10000000n];
|
|
62
|
+
const side = SwapSide.BUY;
|
|
63
|
+
await testPricesVsOnchain(
|
|
64
|
+
balancerV3,
|
|
65
|
+
network,
|
|
66
|
+
amounts,
|
|
67
|
+
eBTC,
|
|
68
|
+
usdc,
|
|
69
|
+
side,
|
|
70
|
+
blockNumber,
|
|
71
|
+
[gyroECLPPool],
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -5,21 +5,19 @@ import { Tokens } from '../../../tests/constants-e2e';
|
|
|
5
5
|
import { Network, SwapSide } from '../../constants';
|
|
6
6
|
import { DummyDexHelper } from '../../dex-helper';
|
|
7
7
|
import { BalancerV3 } from './balancer-v3';
|
|
8
|
-
import {
|
|
9
|
-
import { ExchangePrices, Token } from '../../types';
|
|
10
|
-
import { BalancerV3Data } from './types';
|
|
8
|
+
import { testPricesVsOnchain } from './balancer-test-helpers';
|
|
11
9
|
|
|
12
10
|
const dexKey = 'BalancerV3';
|
|
13
|
-
const blockNumber =
|
|
11
|
+
const blockNumber = 22086000;
|
|
14
12
|
let balancerV3: BalancerV3;
|
|
15
|
-
const network = Network.
|
|
13
|
+
const network = Network.MAINNET;
|
|
16
14
|
const dexHelper = new DummyDexHelper(network);
|
|
17
15
|
const tokens = Tokens[network];
|
|
18
|
-
const
|
|
16
|
+
const usdc = tokens['USDC'];
|
|
19
17
|
const weth = tokens['WETH'];
|
|
20
|
-
// https://
|
|
18
|
+
// https://etherscan.io/address/0x6b49054c350b47ca9aa1331ab156a1eedbe94e79
|
|
21
19
|
const stableSurgePool =
|
|
22
|
-
'
|
|
20
|
+
'0x6b49054c350b47ca9aa1331ab156a1eedbe94e79'.toLowerCase();
|
|
23
21
|
|
|
24
22
|
describe('BalancerV3 stableSurge hook tests', function () {
|
|
25
23
|
beforeAll(async () => {
|
|
@@ -32,7 +30,7 @@ describe('BalancerV3 stableSurge hook tests', function () {
|
|
|
32
30
|
describe('pool with stableSurge hook should be returned', function () {
|
|
33
31
|
it('getPoolIdentifiers', async function () {
|
|
34
32
|
const pools = await balancerV3.getPoolIdentifiers(
|
|
35
|
-
|
|
33
|
+
usdc,
|
|
36
34
|
weth,
|
|
37
35
|
SwapSide.SELL,
|
|
38
36
|
blockNumber,
|
|
@@ -49,62 +47,66 @@ describe('BalancerV3 stableSurge hook tests', function () {
|
|
|
49
47
|
describe('should match onchain pricing', function () {
|
|
50
48
|
describe('using staticFee', function () {
|
|
51
49
|
it('SELL', async function () {
|
|
52
|
-
const amounts = [0n,
|
|
50
|
+
const amounts = [0n, 100000000n];
|
|
53
51
|
const side = SwapSide.SELL;
|
|
54
|
-
await testPricesVsOnchain(amounts,
|
|
55
|
-
|
|
56
|
-
]);
|
|
52
|
+
// await testPricesVsOnchain(amounts, usdc, weth, side, blockNumber, [
|
|
53
|
+
// stableSurgePool,
|
|
54
|
+
// ]);
|
|
55
|
+
await testPricesVsOnchain(
|
|
56
|
+
balancerV3,
|
|
57
|
+
network,
|
|
58
|
+
amounts,
|
|
59
|
+
usdc,
|
|
60
|
+
weth,
|
|
61
|
+
side,
|
|
62
|
+
blockNumber,
|
|
63
|
+
[stableSurgePool],
|
|
64
|
+
);
|
|
57
65
|
});
|
|
58
66
|
it('BUY', async function () {
|
|
59
|
-
const amounts = [0n,
|
|
67
|
+
const amounts = [0n, 500000n];
|
|
60
68
|
const side = SwapSide.BUY;
|
|
61
|
-
await testPricesVsOnchain(
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
await testPricesVsOnchain(
|
|
70
|
+
balancerV3,
|
|
71
|
+
network,
|
|
72
|
+
amounts,
|
|
73
|
+
weth,
|
|
74
|
+
usdc,
|
|
75
|
+
side,
|
|
76
|
+
blockNumber,
|
|
77
|
+
[stableSurgePool],
|
|
78
|
+
);
|
|
64
79
|
});
|
|
65
80
|
});
|
|
66
81
|
describe('using surge fee', function () {
|
|
67
82
|
it('SELL', async function () {
|
|
68
|
-
const amounts = [0n,
|
|
83
|
+
const amounts = [0n, 1000000000000000000n];
|
|
69
84
|
const side = SwapSide.SELL;
|
|
70
|
-
await testPricesVsOnchain(
|
|
71
|
-
|
|
72
|
-
|
|
85
|
+
await testPricesVsOnchain(
|
|
86
|
+
balancerV3,
|
|
87
|
+
network,
|
|
88
|
+
amounts,
|
|
89
|
+
weth,
|
|
90
|
+
usdc,
|
|
91
|
+
side,
|
|
92
|
+
blockNumber,
|
|
93
|
+
[stableSurgePool],
|
|
94
|
+
);
|
|
73
95
|
});
|
|
74
96
|
it('BUY', async function () {
|
|
75
|
-
const amounts = [0n,
|
|
97
|
+
const amounts = [0n, 1976459205n];
|
|
76
98
|
const side = SwapSide.BUY;
|
|
77
|
-
await testPricesVsOnchain(
|
|
78
|
-
|
|
79
|
-
|
|
99
|
+
await testPricesVsOnchain(
|
|
100
|
+
balancerV3,
|
|
101
|
+
network,
|
|
102
|
+
amounts,
|
|
103
|
+
weth,
|
|
104
|
+
usdc,
|
|
105
|
+
side,
|
|
106
|
+
blockNumber,
|
|
107
|
+
[stableSurgePool],
|
|
108
|
+
);
|
|
80
109
|
});
|
|
81
110
|
});
|
|
82
111
|
});
|
|
83
112
|
});
|
|
84
|
-
|
|
85
|
-
async function testPricesVsOnchain(
|
|
86
|
-
amounts: bigint[],
|
|
87
|
-
srcToken: Token,
|
|
88
|
-
dstToken: Token,
|
|
89
|
-
side: SwapSide,
|
|
90
|
-
blockNumber: number,
|
|
91
|
-
limitPools: string[],
|
|
92
|
-
) {
|
|
93
|
-
const prices = await balancerV3.getPricesVolume(
|
|
94
|
-
srcToken,
|
|
95
|
-
dstToken,
|
|
96
|
-
amounts,
|
|
97
|
-
side,
|
|
98
|
-
blockNumber,
|
|
99
|
-
limitPools,
|
|
100
|
-
);
|
|
101
|
-
expect(prices).not.toBeNull();
|
|
102
|
-
await checkOnChainPricingNonMulti(
|
|
103
|
-
network,
|
|
104
|
-
side,
|
|
105
|
-
balancerV3,
|
|
106
|
-
blockNumber,
|
|
107
|
-
prices as ExchangePrices<BalancerV3Data>,
|
|
108
|
-
amounts,
|
|
109
|
-
);
|
|
110
|
-
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
+
import { Token } from '../../types';
|
|
3
|
+
|
|
2
4
|
// Note - this is currently needed because queries won't work with multicall but should be updated in future
|
|
3
5
|
export async function checkOnChainPricingNonMulti(
|
|
4
6
|
network: number,
|
|
@@ -197,3 +199,53 @@ function getQuerySwapMultiTokenCalldata(
|
|
|
197
199
|
};
|
|
198
200
|
});
|
|
199
201
|
}
|
|
202
|
+
|
|
203
|
+
export function allPricesAreZero(arr: { prices: bigint[] }[]): boolean {
|
|
204
|
+
// Check if the array is empty first
|
|
205
|
+
if (arr.length === 0) return false;
|
|
206
|
+
|
|
207
|
+
// Iterate through each object in the array
|
|
208
|
+
for (const obj of arr) {
|
|
209
|
+
// Check if this object has any non-zero price
|
|
210
|
+
const hasNonZeroPrice = obj.prices.some(price => price !== 0n);
|
|
211
|
+
|
|
212
|
+
// If we found even one non-zero price, return false
|
|
213
|
+
if (hasNonZeroPrice) {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// If we got here, all prices in all objects are 0n
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export async function testPricesVsOnchain(
|
|
223
|
+
balancerV3: BalancerV3,
|
|
224
|
+
network: number,
|
|
225
|
+
amounts: bigint[],
|
|
226
|
+
srcToken: Token,
|
|
227
|
+
dstToken: Token,
|
|
228
|
+
side: SwapSide,
|
|
229
|
+
blockNumber: number,
|
|
230
|
+
limitPools: string[],
|
|
231
|
+
) {
|
|
232
|
+
const prices = await balancerV3.getPricesVolume(
|
|
233
|
+
srcToken,
|
|
234
|
+
dstToken,
|
|
235
|
+
amounts,
|
|
236
|
+
side,
|
|
237
|
+
blockNumber,
|
|
238
|
+
limitPools,
|
|
239
|
+
);
|
|
240
|
+
expect(prices).not.toBeNull();
|
|
241
|
+
expect(prices?.length).toBeGreaterThan(0);
|
|
242
|
+
expect(allPricesAreZero(prices!)).toBe(false);
|
|
243
|
+
await checkOnChainPricingNonMulti(
|
|
244
|
+
network,
|
|
245
|
+
side,
|
|
246
|
+
balancerV3,
|
|
247
|
+
blockNumber,
|
|
248
|
+
prices as ExchangePrices<BalancerV3Data>,
|
|
249
|
+
amounts,
|
|
250
|
+
);
|
|
251
|
+
}
|