@paraswap/dex-lib 4.1.4-bal-v3-hooks.0 → 4.1.4
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/Aave_GSM.json +751 -0
- package/build/abi/Balancer.json +257 -0
- package/build/abi/{balancer-v3/stableSurgeHook.json → BalancerV2.json} +732 -529
- package/build/abi/{integral/relayer.json → RamsesV2Pool.abi.json} +850 -832
- 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/{integral/oracle.json → angle-transmuter/ChainlinkEACAggregatorProxy.json} +247 -239
- 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/{integral/pool.json → curve-v1/StableSwapUSDN.json} +450 -487
- package/build/abi/curve-v1/StableSwapUSDT.json +814 -0
- package/build/abi/curve-v1/StableSwapY.json +814 -0
- package/build/abi/fluid-dex/resolver.abi.json +30 -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/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 +2 -1
- package/build/dex/aave-v1/aave-v1.js +22 -0
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/balancer-v1/balancer-pools.json +33333 -0
- package/build/dex/balancer-v3/balancer-v3-pool.d.ts +1 -4
- package/build/dex/balancer-v3/balancer-v3-pool.js +13 -20
- package/build/dex/balancer-v3/balancer-v3-pool.js.map +1 -1
- package/build/dex/balancer-v3/balancer-v3.d.ts +0 -4
- package/build/dex/balancer-v3/balancer-v3.js +3 -29
- package/build/dex/balancer-v3/balancer-v3.js.map +1 -1
- package/build/dex/balancer-v3/config.js +0 -39
- package/build/dex/balancer-v3/config.js.map +1 -1
- package/build/dex/balancer-v3/getOnChainState.d.ts +2 -1
- package/build/dex/balancer-v3/getOnChainState.js +2 -0
- package/build/dex/balancer-v3/getOnChainState.js.map +1 -1
- package/build/dex/balancer-v3/getPoolsApi.d.ts +1 -2
- package/build/dex/balancer-v3/getPoolsApi.js +10 -17
- package/build/dex/balancer-v3/getPoolsApi.js.map +1 -1
- package/build/dex/balancer-v3/getTopPoolsApi.d.ts +1 -5
- package/build/dex/balancer-v3/getTopPoolsApi.js +3 -6
- package/build/dex/balancer-v3/getTopPoolsApi.js.map +1 -1
- package/build/dex/balancer-v3/types.d.ts +1 -4
- 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/fluid-dex/config.js +2 -2
- package/build/dex/fluid-dex/constants.d.ts +1 -1
- package/build/dex/fluid-dex/constants.js +2 -1
- package/build/dex/fluid-dex/constants.js.map +1 -1
- package/build/dex/fluid-dex/fluid-dex-liquidity-proxy.js +3 -1
- package/build/dex/fluid-dex/fluid-dex-liquidity-proxy.js.map +1 -1
- package/build/dex/fluid-dex/fluid-dex.d.ts +4 -5
- package/build/dex/fluid-dex/fluid-dex.js +61 -59
- package/build/dex/fluid-dex/fluid-dex.js.map +1 -1
- package/build/dex/fluid-dex/types.d.ts +3 -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/{integral/integral.d.ts → inception/inception-native.d.ts} +21 -19
- 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/jarvis.d.ts +2 -1
- package/build/dex/jarvis.js +58 -0
- package/build/dex/jarvis.js.map +1 -1
- package/build/dex/platypus/platypus.d.ts +2 -1
- package/build/dex/platypus/platypus.js +31 -0
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/swaap-v1/swaap-v1.d.ts +2 -1
- package/build/dex/swaap-v1/swaap-v1.js +10 -0
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/zerox/index.d.ts +4 -26
- package/build/dex/zerox/index.js +50 -42
- package/build/dex/zerox/index.js.map +1 -1
- package/build/dex/zerox/types.d.ts +29 -0
- package/build/dex/zerox/types.js +8 -1
- package/build/dex/zerox/types.js.map +1 -1
- package/build/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/scripts/run-dex-integration-v3.ts +4 -4
- package/src/abi/fluid-dex/resolver.abi.json +30 -0
- package/src/dex/balancer-v3/balancer-v3-e2e.test.ts +0 -20
- package/src/dex/balancer-v3/balancer-v3-integration.test.ts +197 -2
- package/src/dex/balancer-v3/balancer-v3-pool.ts +13 -37
- package/src/dex/balancer-v3/balancer-v3.ts +1 -42
- package/src/dex/balancer-v3/config.ts +0 -39
- package/src/dex/balancer-v3/getOnChainState.ts +4 -1
- package/src/dex/balancer-v3/getPoolsApi.ts +23 -42
- package/src/dex/balancer-v3/getTopPoolsApi.ts +2 -13
- package/src/dex/balancer-v3/types.ts +2 -4
- package/src/dex/fluid-dex/config.ts +2 -2
- package/src/dex/fluid-dex/constants.ts +2 -1
- package/src/dex/fluid-dex/fluid-dex-e2e.test.ts +61 -117
- package/src/dex/fluid-dex/fluid-dex-liquidity-proxy.ts +3 -0
- package/src/dex/fluid-dex/fluid-dex.ts +96 -94
- package/src/dex/fluid-dex/types.ts +3 -0
- package/tests/constants-e2e.ts +2 -7
- package/tests/tenderly-simulation.ts +1 -0
- package/.idea/aws.xml +0 -17
- package/.idea/codeStyles/Project.xml +0 -19
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/paraswap-dex-lib.iml +0 -9
- package/.idea/prettier.xml +0 -7
- package/.idea/vcs.xml +0 -6
- package/build/abi/balancer-v3/directionalFeeHook.json +0 -684
- package/build/abi/integral/factory.json +0 -333
- package/build/dex/bProtocol.d.ts +0 -18
- package/build/dex/bProtocol.js +0 -39
- package/build/dex/bProtocol.js.map +0 -1
- package/build/dex/balancer-v3/balancer-test-helpers.d.ts +0 -5
- package/build/dex/balancer-v3/balancer-test-helpers.js +0 -122
- package/build/dex/balancer-v3/balancer-test-helpers.js.map +0 -1
- package/build/dex/balancer-v3/hooks/balancer-hook-event-subscriber.d.ts +0 -54
- package/build/dex/balancer-v3/hooks/balancer-hook-event-subscriber.js +0 -153
- package/build/dex/balancer-v3/hooks/balancer-hook-event-subscriber.js.map +0 -1
- package/build/dex/balancer-v3/hooks/directionalFeeHook.d.ts +0 -26
- package/build/dex/balancer-v3/hooks/directionalFeeHook.js +0 -41
- package/build/dex/balancer-v3/hooks/directionalFeeHook.js.map +0 -1
- package/build/dex/balancer-v3/hooks/loadHooksConfig.d.ts +0 -2
- package/build/dex/balancer-v3/hooks/loadHooksConfig.js +0 -11
- package/build/dex/balancer-v3/hooks/loadHooksConfig.js.map +0 -1
- package/build/dex/balancer-v3/hooks/stableSurgeHook.d.ts +0 -39
- package/build/dex/balancer-v3/hooks/stableSurgeHook.js +0 -99
- package/build/dex/balancer-v3/hooks/stableSurgeHook.js.map +0 -1
- package/build/dex/bancor.d.ts +0 -26
- package/build/dex/bancor.js +0 -58
- package/build/dex/bancor.js.map +0 -1
- package/build/dex/compound.d.ts +0 -18
- package/build/dex/compound.js +0 -46
- package/build/dex/compound.js.map +0 -1
- package/build/dex/curve-v2.d.ts +0 -58
- package/build/dex/curve-v2.js +0 -180
- package/build/dex/curve-v2.js.map +0 -1
- package/build/dex/dodo-v1.d.ts +0 -33
- package/build/dex/dodo-v1.js +0 -63
- package/build/dex/dodo-v1.js.map +0 -1
- package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +0 -49
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js +0 -104
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +0 -1
- package/build/dex/integral/config.d.ts +0 -4
- package/build/dex/integral/config.js +0 -20
- package/build/dex/integral/config.js.map +0 -1
- package/build/dex/integral/context.d.ts +0 -40
- package/build/dex/integral/context.js +0 -158
- package/build/dex/integral/context.js.map +0 -1
- package/build/dex/integral/integral-factory.d.ts +0 -24
- package/build/dex/integral/integral-factory.js +0 -95
- package/build/dex/integral/integral-factory.js.map +0 -1
- package/build/dex/integral/integral-pool.d.ts +0 -50
- package/build/dex/integral/integral-pool.js +0 -149
- package/build/dex/integral/integral-pool.js.map +0 -1
- package/build/dex/integral/integral-pricing.d.ts +0 -18
- package/build/dex/integral/integral-pricing.js +0 -114
- package/build/dex/integral/integral-pricing.js.map +0 -1
- package/build/dex/integral/integral-relayer.d.ts +0 -42
- package/build/dex/integral/integral-relayer.js +0 -192
- package/build/dex/integral/integral-relayer.js.map +0 -1
- package/build/dex/integral/integral-token.d.ts +0 -27
- package/build/dex/integral/integral-token.js +0 -59
- package/build/dex/integral/integral-token.js.map +0 -1
- package/build/dex/integral/integral.js +0 -376
- package/build/dex/integral/integral.js.map +0 -1
- package/build/dex/integral/types.d.ts +0 -85
- package/build/dex/integral/types.js +0 -9
- package/build/dex/integral/types.js.map +0 -1
- package/build/dex/integral/utils-e2e.d.ts +0 -9
- package/build/dex/integral/utils-e2e.js +0 -131
- package/build/dex/integral/utils-e2e.js.map +0 -1
- package/build/dex/integral/utils.d.ts +0 -17
- package/build/dex/integral/utils.js +0 -94
- package/build/dex/integral/utils.js.map +0 -1
- package/build/dex/lido.d.ts +0 -19
- package/build/dex/lido.js +0 -42
- package/build/dex/lido.js.map +0 -1
- package/build/dex/onebit.d.ts +0 -25
- package/build/dex/onebit.js +0 -42
- package/build/dex/onebit.js.map +0 -1
- package/build/dex/smoothy.d.ts +0 -26
- package/build/dex/smoothy.js +0 -48
- package/build/dex/smoothy.js.map +0 -1
- package/build/dex/stable-pool.d.ts +0 -28
- package/build/dex/stable-pool.js +0 -62
- package/build/dex/stable-pool.js.map +0 -1
- package/build/dex/trader-joe-v2.1/optimizer.d.ts +0 -2
- package/build/dex/trader-joe-v2.1/optimizer.js +0 -47
- package/build/dex/trader-joe-v2.1/optimizer.js.map +0 -1
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +0 -7
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +0 -20
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +0 -1
- package/build/dex/trader-joe-v2.1.d.ts +0 -43
- package/build/dex/trader-joe-v2.1.js +0 -79
- package/build/dex/trader-joe-v2.1.js.map +0 -1
- package/src/abi/balancer-v3/directionalFeeHook.json +0 -684
- package/src/abi/balancer-v3/stableSurgeHook.json +0 -976
- package/src/dex/balancer-v3/balancer-hooks-events.test.ts +0 -99
- package/src/dex/balancer-v3/balancer-stableSurge.test.ts +0 -110
- package/src/dex/balancer-v3/balancer-test-helpers.ts +0 -199
- package/src/dex/balancer-v3/hooks/balancer-hook-event-subscriber.ts +0 -226
- package/src/dex/balancer-v3/hooks/directionalFeeHook.ts +0 -51
- package/src/dex/balancer-v3/hooks/loadHooksConfig.ts +0 -12
- package/src/dex/balancer-v3/hooks/stableSurgeHook.ts +0 -163
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPoolsApi.js","sourceRoot":"","sources":["../../../src/dex/balancer-v3/getPoolsApi.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"getPoolsApi.js","sourceRoot":"","sources":["../../../src/dex/balancer-v3/getPoolsApi.ts"],"names":[],"mappings":";;;;;AAoGA,kCA4BC;AAhID,kDAA0B;AAC1B,qCAKkB;AAElB,4CAA8C;AAuB9C,SAAS,WAAW,CAClB,SAAiB,EACjB,SAA4B,EAC5B,SAAkB;IAElB,MAAM,eAAe,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpE,MAAM,aAAa,GAAG,yBAAgB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC;IAC5E,MAAM,qBAAqB,GAAG,wBAAe,CAAC,UAAU,CAAC,SAAS,CAAC;QACjE,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;SACnB,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,uCAAuC;IACvC,MAAM,WAAW,GAAG;QAClB,OAAO,EAAE,aAAa;QACtB,iBAAiB,EAAE,CAAC;QACpB,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,IAAI,eAAe,GAAG;QAClC,GAAG,CAAC,SAAS,IAAI,EAAE,UAAU,EAAE,QAAQ,SAAS,GAAG,EAAE,CAAC;QACtD,GAAG,CAAC,qBAAqB,IAAI,EAAE,OAAO,EAAE,IAAI,qBAAqB,GAAG,EAAE,CAAC;KACxE,CAAC;IAEF,iEAAiE;IACjE,MAAM,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC;SAC5C,GAAG,CAAC,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OAAO,EACP,MAAM,CAAC,MAAM,CAAC,wBAAe,CAAC,EAC9B,SAAS,CACV,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAC/B,eAAM,EACN;YACE,KAAK;SACN,EACD;YACE,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CACF,CAAC;QAEF,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC;QACxD,OAAO,uBAAuB,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,0DAA0D;QAC1D,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { HooksConfigMap } from './hooks/balancer-hook-event-subscriber';
|
|
2
1
|
interface PoolToken {
|
|
3
2
|
address: string;
|
|
4
3
|
decimals: number;
|
|
@@ -13,9 +12,6 @@ export interface Pool {
|
|
|
13
12
|
dynamicData: {
|
|
14
13
|
totalLiquidity: string;
|
|
15
14
|
};
|
|
16
|
-
hook: {
|
|
17
|
-
address: string;
|
|
18
|
-
} | null;
|
|
19
15
|
}
|
|
20
|
-
export declare function getTopPoolsApi(networkId: number, poolsFilter: string[], count: number
|
|
16
|
+
export declare function getTopPoolsApi(networkId: number, poolsFilter: string[], count: number): Promise<Pool[]>;
|
|
21
17
|
export {};
|
|
@@ -16,6 +16,7 @@ function createQuery(networkId, poolsFilter, count) {
|
|
|
16
16
|
const whereClause = {
|
|
17
17
|
chainIn: networkString,
|
|
18
18
|
protocolVersionIn: 3,
|
|
19
|
+
hasHook: false,
|
|
19
20
|
idIn: `[${poolIdString}]`,
|
|
20
21
|
...(disabledPoolIdsString && { idNotIn: `[${disabledPoolIdsString}]` }),
|
|
21
22
|
};
|
|
@@ -43,14 +44,11 @@ function createQuery(networkId, poolsFilter, count) {
|
|
|
43
44
|
dynamicData {
|
|
44
45
|
totalLiquidity
|
|
45
46
|
}
|
|
46
|
-
hook {
|
|
47
|
-
address
|
|
48
|
-
}
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
49
|
`;
|
|
52
50
|
}
|
|
53
|
-
async function getTopPoolsApi(networkId, poolsFilter, count
|
|
51
|
+
async function getTopPoolsApi(networkId, poolsFilter, count) {
|
|
54
52
|
try {
|
|
55
53
|
const query = createQuery(networkId, poolsFilter, count);
|
|
56
54
|
const response = await axios_1.default.post(config_1.apiUrl, {
|
|
@@ -60,8 +58,7 @@ async function getTopPoolsApi(networkId, poolsFilter, count, hooksTypeMap) {
|
|
|
60
58
|
'Content-Type': 'application/json',
|
|
61
59
|
},
|
|
62
60
|
});
|
|
63
|
-
const pools = response.data.data.poolGetAggregatorPools
|
|
64
|
-
(pool.hook && pool.hook.address.toLowerCase() in hooksTypeMap));
|
|
61
|
+
const pools = response.data.data.poolGetAggregatorPools;
|
|
65
62
|
return pools;
|
|
66
63
|
}
|
|
67
64
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTopPoolsApi.js","sourceRoot":"","sources":["../../../src/dex/balancer-v3/getTopPoolsApi.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"getTopPoolsApi.js","sourceRoot":"","sources":["../../../src/dex/balancer-v3/getTopPoolsApi.ts"],"names":[],"mappings":";;;;;AA2EA,wCAyBC;AApGD,kDAA0B;AAC1B,qCAAqE;AAyBrE,SAAS,WAAW,CAClB,SAAiB,EACjB,WAAqB,EACrB,KAAa;IAEb,MAAM,qBAAqB,GAAG,wBAAe,CAAC,UAAU,CAAC,SAAS,CAAC;QACjE,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;SACnB,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,MAAM,aAAa,GAAG,yBAAgB,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC;IAC5E,MAAM,YAAY,G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-labs/balancer-maths';
|
|
2
2
|
import { Address } from '../../types';
|
|
3
|
-
import { HookConfig } from './hooks/balancer-hook-event-subscriber';
|
|
4
3
|
export type CommonImmutablePoolState = {
|
|
5
4
|
poolAddress: string;
|
|
6
5
|
poolType: string;
|
|
7
6
|
tokens: string[];
|
|
8
7
|
tokensUnderlying: (string | null)[];
|
|
9
8
|
weights: bigint[];
|
|
10
|
-
hookAddress: string | undefined;
|
|
11
9
|
hookType: string | undefined;
|
|
12
|
-
supportsUnbalancedLiquidity: boolean;
|
|
13
10
|
};
|
|
14
11
|
export interface CommonMutableState {
|
|
15
12
|
tokenRates: bigint[];
|
|
@@ -20,6 +17,7 @@ export interface CommonMutableState {
|
|
|
20
17
|
totalSupply: bigint;
|
|
21
18
|
isPoolPaused: boolean;
|
|
22
19
|
scalingFactors: bigint[];
|
|
20
|
+
hasHook: boolean;
|
|
23
21
|
}
|
|
24
22
|
type CommonPoolState = CommonImmutablePoolState & CommonMutableState;
|
|
25
23
|
export type PoolState = CommonPoolState | (CommonPoolState & StableMutableState);
|
|
@@ -54,7 +52,6 @@ export type DexParams = {
|
|
|
54
52
|
vaultAddress: string;
|
|
55
53
|
balancerRouterAddress: string;
|
|
56
54
|
balancerBatchRouterAddress: string;
|
|
57
|
-
hooks?: HookConfig[];
|
|
58
55
|
};
|
|
59
56
|
export type TokenInfo = {
|
|
60
57
|
isBoosted: boolean;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Logger } from 'log4js';
|
|
2
|
+
import { RequestConfig, Response } from '../../dex-helper/irequest-wrapper';
|
|
3
|
+
export declare class SkippingRequest {
|
|
4
|
+
message: string;
|
|
5
|
+
constructor(message?: string);
|
|
6
|
+
}
|
|
7
|
+
export declare type RequestInfo<T> = {
|
|
8
|
+
requestFunc?: (options: RequestConfig) => Promise<Response<T> | SkippingRequest>;
|
|
9
|
+
requestOptions: RequestConfig;
|
|
10
|
+
caster: (data: unknown) => T;
|
|
11
|
+
authenticate?: (options: RequestConfig) => RequestConfig;
|
|
12
|
+
excludedFieldsCaching?: string[];
|
|
13
|
+
};
|
|
14
|
+
export declare type RequestInfoWithHandler<T> = {
|
|
15
|
+
info: RequestInfo<T>;
|
|
16
|
+
handler: (data: T) => void;
|
|
17
|
+
};
|
|
18
|
+
export declare class WebSocketFetcher<T> {
|
|
19
|
+
private logger;
|
|
20
|
+
private requests;
|
|
21
|
+
lastFetchSucceeded: boolean;
|
|
22
|
+
private stop;
|
|
23
|
+
private ws;
|
|
24
|
+
private connection;
|
|
25
|
+
constructor(requestsInfo: RequestInfoWithHandler<T>, logger: Logger);
|
|
26
|
+
private connected;
|
|
27
|
+
private connectFailed;
|
|
28
|
+
private onClose;
|
|
29
|
+
private onError;
|
|
30
|
+
private onMessage;
|
|
31
|
+
private connect;
|
|
32
|
+
startPolling(): void;
|
|
33
|
+
stopPolling(): void;
|
|
34
|
+
isPolling(): boolean;
|
|
35
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebSocketFetcher = exports.SkippingRequest = void 0;
|
|
4
|
+
const websocket_1 = require("websocket");
|
|
5
|
+
class SkippingRequest {
|
|
6
|
+
constructor(message = '') {
|
|
7
|
+
this.message = message;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.SkippingRequest = SkippingRequest;
|
|
11
|
+
class WebSocketFetcher {
|
|
12
|
+
constructor(requestsInfo, logger) {
|
|
13
|
+
this.logger = logger;
|
|
14
|
+
this.lastFetchSucceeded = false;
|
|
15
|
+
this.stop = true;
|
|
16
|
+
this.ws = new websocket_1.client();
|
|
17
|
+
this.connection = null;
|
|
18
|
+
this.requests = requestsInfo;
|
|
19
|
+
this.ws.on('connect', this.connected.bind(this));
|
|
20
|
+
this.ws.on('connectFailed', this.connectFailed.bind(this));
|
|
21
|
+
}
|
|
22
|
+
connected(connection) {
|
|
23
|
+
this.connection = connection;
|
|
24
|
+
this.logger.info(`Connected to ${this.requests.info.requestOptions.url}`);
|
|
25
|
+
this.connection.on('error', this.onError.bind(this));
|
|
26
|
+
this.connection.on('close', this.onClose.bind(this));
|
|
27
|
+
this.connection.on('message', this.onMessage.bind(this));
|
|
28
|
+
}
|
|
29
|
+
connectFailed(error) {
|
|
30
|
+
this.logger.error(`Connect Error: ${error.toString()}`);
|
|
31
|
+
}
|
|
32
|
+
onClose() {
|
|
33
|
+
this.logger.info(`Connection closed`);
|
|
34
|
+
}
|
|
35
|
+
onError(error) {
|
|
36
|
+
this.logger.error(`Connection Error: ${error.toString()}`);
|
|
37
|
+
}
|
|
38
|
+
onMessage(message) {
|
|
39
|
+
if (message.type === 'utf8') {
|
|
40
|
+
const response = JSON.parse(message.utf8Data);
|
|
41
|
+
const reqInfo = this.requests;
|
|
42
|
+
const info = reqInfo.info;
|
|
43
|
+
const options = reqInfo.info.requestOptions;
|
|
44
|
+
this.logger.debug(`(${options.url}) received new data`);
|
|
45
|
+
try {
|
|
46
|
+
const parsedData = info.caster(response);
|
|
47
|
+
reqInfo.handler(parsedData);
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
this.logger.info(e);
|
|
51
|
+
this.logger.info(`(${options.url}) received incorrect data ${JSON.stringify(response).replace(/(?:\r\n|\r|\n)/g, ' ')}`, e);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
connect() {
|
|
57
|
+
const authorization = this.requests.info.requestOptions.headers.authorization;
|
|
58
|
+
const name = this.requests.info.requestOptions.headers.name;
|
|
59
|
+
if (typeof authorization !== 'string') {
|
|
60
|
+
throw new Error('Authorization header is not a string');
|
|
61
|
+
}
|
|
62
|
+
if (typeof name !== 'string') {
|
|
63
|
+
throw new Error('Name header is not a string');
|
|
64
|
+
}
|
|
65
|
+
this.ws.connect(this.requests.info.requestOptions.url, undefined, undefined, {
|
|
66
|
+
Authorization: authorization,
|
|
67
|
+
name: name,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
startPolling() {
|
|
71
|
+
this.stop = false;
|
|
72
|
+
this.connect();
|
|
73
|
+
this.logger.info(`Connection started for ${this.requests.info.requestOptions.url}`);
|
|
74
|
+
}
|
|
75
|
+
stopPolling() {
|
|
76
|
+
if (this.connection) {
|
|
77
|
+
this.connection.close();
|
|
78
|
+
}
|
|
79
|
+
this.stop = true;
|
|
80
|
+
this.logger.info(`Connection stopped for ${this.requests.info.requestOptions.url}`);
|
|
81
|
+
}
|
|
82
|
+
isPolling() {
|
|
83
|
+
return !this.stop;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.WebSocketFetcher = WebSocketFetcher;
|
|
87
|
+
//# sourceMappingURL=websocket-fetcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-fetcher.js","sourceRoot":"","sources":["../../../src/dex/bebop/websocket-fetcher.ts"],"names":[],"mappings":";;;AAEA,yCAGmB;AAEnB,MAAa,eAAe;IAC1B,YAAmB,UAAU,EAAE;QAAZ,YAAO,GAAP,OAAO,CAAK;IAAG,CAAC;CACpC;AAFD,0CAEC;AAiBD,MAAa,gBAAgB;IAO3B,YAAY,YAAuC,EAAU,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QALpE,uBAAkB,GAAY,KAAK,CAAC;QACnC,SAAI,GAAY,IAAI,CAAC;QACrB,OAAE,GAAoB,IAAI,kBAAe,EAAE,CAAC;QAC5C,eAAU,GAA+B,IAAI,CAAC;QAGpD,IAAI,CAAC,QAAQ,GAAG,YAAY,CAAC;QAC7B,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACjD,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7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MAAM,CAAC,IAAI,CACd,0BAA0B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,CAClE,CAAC;IACJ,CAAC;IAED,WAAW;QACT,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;SACzB;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,0BAA0B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,CAClE,CAAC;IACJ,CAAC;IAED,SAAS;QACP,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;IACpB,CAAC;CACF;AAnGD,4CAmGC"}
|
|
@@ -7,14 +7,14 @@ exports.FluidDexConfig = {
|
|
|
7
7
|
[constants_1.Network.MAINNET]: {
|
|
8
8
|
commonAddresses: {
|
|
9
9
|
liquidityProxy: '0x52aa899454998be5b000ad077a46bbe360f4e497',
|
|
10
|
-
resolver: '
|
|
10
|
+
resolver: '0xb387f9C2092cF7c4943F97842887eBff7AE96EB3',
|
|
11
11
|
dexFactory: '0x91716C4EDA1Fb55e84Bf8b4c7085f84285c19085',
|
|
12
12
|
},
|
|
13
13
|
},
|
|
14
14
|
[constants_1.Network.ARBITRUM]: {
|
|
15
15
|
commonAddresses: {
|
|
16
16
|
liquidityProxy: '0x52Aa899454998Be5b000Ad077a46Bbe360F4e497',
|
|
17
|
-
resolver: '
|
|
17
|
+
resolver: '0xCe6F4E40152a1DF97ae95a7e4F60D944871A4060',
|
|
18
18
|
dexFactory: '0x91716C4EDA1Fb55e84Bf8b4c7085f84285c19085',
|
|
19
19
|
},
|
|
20
20
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MIN_SWAP_LIQUIDITY
|
|
1
|
+
export declare const MIN_SWAP_LIQUIDITY = 8500n;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MIN_SWAP_LIQUIDITY = void 0;
|
|
4
|
-
|
|
4
|
+
// on-chain we use 1e4 but use extra buffer to avoid reverts
|
|
5
|
+
exports.MIN_SWAP_LIQUIDITY = 8500n;
|
|
5
6
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dex/fluid-dex/constants.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/dex/fluid-dex/constants.ts"],"names":[],"mappings":";;;AAAA,4DAA4D;AAC/C,QAAA,kBAAkB,GAAG,KAAK,CAAC"}
|
|
@@ -88,8 +88,9 @@ class FluidDexLiquidityProxy extends stateful_event_subscriber_1.StatefulEventSu
|
|
|
88
88
|
}
|
|
89
89
|
convertToFluidDexPoolState(poolReserves) {
|
|
90
90
|
const result = poolReserves.map(poolReserve => {
|
|
91
|
-
const [pool, token0, token1, feeHex, collateralReservesHex, debtReservesHex, dexLimitsHex,] = poolReserve;
|
|
91
|
+
const [pool, token0, token1, feeHex, centerPriceHex, collateralReservesHex, debtReservesHex, dexLimitsHex,] = poolReserve;
|
|
92
92
|
const fee = Number(feeHex.toString());
|
|
93
|
+
const centerPrice = Number(centerPriceHex.toString());
|
|
93
94
|
const collateralReserves = {
|
|
94
95
|
token0RealReserves: (0, utils_1.bigIntify)(collateralReservesHex[0]),
|
|
95
96
|
token1RealReserves: (0, utils_1.bigIntify)(collateralReservesHex[1]),
|
|
@@ -135,6 +136,7 @@ class FluidDexLiquidityProxy extends stateful_event_subscriber_1.StatefulEventSu
|
|
|
135
136
|
token0,
|
|
136
137
|
token1,
|
|
137
138
|
fee,
|
|
139
|
+
centerPrice,
|
|
138
140
|
collateralReserves,
|
|
139
141
|
debtReserves,
|
|
140
142
|
dexLimits,
|
|
@@ -1 +1 @@
|
|
|
1
|
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AC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxC,SAAS,EAAE,IAAA,iBAAS,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxC,eAAe,EAAE,IAAA,iBAAS,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aAC/C,CAAC;YAEF,MAAM,gBAAgB,GAAG;gBACvB,SAAS,EAAE,IAAA,iBAAS,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxC,SAAS,EAAE,IAAA,iBAAS,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACxC,eAAe,EAAE,IAAA,iBAAS,EAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aAC/C,CAAC;YAEF,MAAM,SAAS,GAAG;gBAChB,kBAAkB;gBAClB,kBAAkB;gBAClB,gBAAgB;gBAChB,gBAAgB;aACjB,CAAC;YAEF,OAAO;gBACL,IAAI;gBACJ,MAAM;gBACN,MAAM;gBACN,GAAG;gBACH,WAAW;gBACX,kBAAkB;gBAClB,YAAY;gBACZ,SAAS;aACV,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC;IACnC,CAAC;CACF;AAhMD,wDAgMC"}
|
|
@@ -23,7 +23,6 @@ export declare class FluidDex extends SimpleExchange implements IDex<FluidDexDat
|
|
|
23
23
|
}[];
|
|
24
24
|
logger: Logger;
|
|
25
25
|
pools: FluidDexPool[];
|
|
26
|
-
restrictedIds: string[];
|
|
27
26
|
eventPools: FluidDexEventPool[];
|
|
28
27
|
readonly factory: FluidDexFactory;
|
|
29
28
|
readonly liquidityProxy: FluidDexLiquidityProxy;
|
|
@@ -52,7 +51,7 @@ export declare class FluidDex extends SimpleExchange implements IDex<FluidDexDat
|
|
|
52
51
|
* @param outDecimals - The number of decimals for the output token.
|
|
53
52
|
* @returns The calculated output amount (as a BigInt).
|
|
54
53
|
*/
|
|
55
|
-
swapIn(swap0To1: boolean, amountIn: bigint, colReserves: CollateralReserves, debtReserves: DebtReserves, inDecimals: number, outDecimals: number, fee: bigint, currentLimits: DexLimits, syncTime: number): bigint;
|
|
54
|
+
swapIn(swap0To1: boolean, amountIn: bigint, colReserves: CollateralReserves, debtReserves: DebtReserves, inDecimals: number, outDecimals: number, fee: bigint, currentLimits: DexLimits, centerPrice: bigint, syncTime: number): bigint;
|
|
56
55
|
/**
|
|
57
56
|
* Calculates the output amount for a given input amount in a swap operation.
|
|
58
57
|
* @param swap0To1 - Direction of the swap. True if swapping token0 for token1, false otherwise.
|
|
@@ -61,7 +60,7 @@ export declare class FluidDex extends SimpleExchange implements IDex<FluidDexDat
|
|
|
61
60
|
* @param debtReserves - The reserves of the debt pool.
|
|
62
61
|
* @returns The calculated output amount.
|
|
63
62
|
*/
|
|
64
|
-
swapInAdjusted(swap0To1: boolean, amountToSwap: bigint, colReserves: CollateralReserves, debtReserves: DebtReserves, fee: bigint, outDecimals: number, currentLimits: DexLimits, syncTime: number): bigint;
|
|
63
|
+
swapInAdjusted(swap0To1: boolean, amountToSwap: bigint, colReserves: CollateralReserves, debtReserves: DebtReserves, fee: bigint, outDecimals: number, currentLimits: DexLimits, centerPrice: bigint, syncTime: number): bigint;
|
|
65
64
|
/**
|
|
66
65
|
* Checks if token0 reserves are sufficient compared to token1 reserves.
|
|
67
66
|
* This helps prevent edge cases and ensures high precision in calculations.
|
|
@@ -140,7 +139,7 @@ export declare class FluidDex extends SimpleExchange implements IDex<FluidDexDat
|
|
|
140
139
|
* @param {number} fee - The fee for the swap. 1e4 = 1%
|
|
141
140
|
* @returns {bigint} amountIn - The calculated input amount required for the swap.
|
|
142
141
|
*/
|
|
143
|
-
swapOut(swap0to1: boolean, amountOut: bigint, colReserves: CollateralReserves, debtReserves: DebtReserves, inDecimals: number, outDecimals: number, fee: bigint, currentLimits: DexLimits, syncTime: number): bigint;
|
|
142
|
+
swapOut(swap0to1: boolean, amountOut: bigint, colReserves: CollateralReserves, debtReserves: DebtReserves, inDecimals: number, outDecimals: number, fee: bigint, currentLimits: DexLimits, centerPrice: bigint, syncTime: number): bigint;
|
|
144
143
|
/**
|
|
145
144
|
* Calculates the input amount for a given output amount in a swap operation.
|
|
146
145
|
* @param {boolean} swap0to1 - Direction of the swap. True if swapping token0 for token1, false otherwise.
|
|
@@ -149,7 +148,7 @@ export declare class FluidDex extends SimpleExchange implements IDex<FluidDexDat
|
|
|
149
148
|
* @param {DebtReserves} debtReserves - The reserves of the debt pool.
|
|
150
149
|
* @returns {bigint} The calculated input amount required for the swap.
|
|
151
150
|
*/
|
|
152
|
-
swapOutAdjusted(swap0to1: boolean, amountOut: bigint, colReserves: CollateralReserves, debtReserves: DebtReserves, fee: bigint, outDecimals: number, currentLimits: DexLimits, syncTime: number): bigint;
|
|
151
|
+
swapOutAdjusted(swap0to1: boolean, amountOut: bigint, colReserves: CollateralReserves, debtReserves: DebtReserves, fee: bigint, outDecimals: number, currentLimits: DexLimits, centerPrice: bigint, syncTime: number): bigint;
|
|
153
152
|
private applyFeeForBuy;
|
|
154
153
|
private applyFeeForSell;
|
|
155
154
|
private abs;
|
|
@@ -62,10 +62,6 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
62
62
|
static dexKeysWithNetwork = (0, utils_1.getDexKeysWithNetwork)(config_1.FluidDexConfig);
|
|
63
63
|
logger;
|
|
64
64
|
pools = [];
|
|
65
|
-
// temporarily limit FLUID-ETH Dex Pool.
|
|
66
|
-
restrictedIds = [
|
|
67
|
-
'FluidDex_0xc800b0e15c40a1ff0539218100c86f4c1bac8d9c',
|
|
68
|
-
];
|
|
69
65
|
eventPools = [];
|
|
70
66
|
factory;
|
|
71
67
|
liquidityProxy;
|
|
@@ -98,7 +94,7 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
98
94
|
// implement this function
|
|
99
95
|
async initializePricing(blockNumber) {
|
|
100
96
|
await this.factory.initialize(blockNumber);
|
|
101
|
-
this.pools =
|
|
97
|
+
this.pools = await this.fetchFluidDexPools(blockNumber);
|
|
102
98
|
this.eventPools = await Promise.all(this.pools.map(async (pool) => {
|
|
103
99
|
const eventPool = new fluid_dex_pool_1.FluidDexEventPool(this.dexKey, pool.address, this.network, this.dexHelper, this.logger);
|
|
104
100
|
await eventPool.initialize(blockNumber);
|
|
@@ -110,7 +106,7 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
110
106
|
return null;
|
|
111
107
|
}
|
|
112
108
|
onPoolCreatedUpdatePools(poolsFromFactory) {
|
|
113
|
-
this.pools = this.generateFluidDexPoolsFromPoolsFactory(poolsFromFactory)
|
|
109
|
+
this.pools = this.generateFluidDexPoolsFromPoolsFactory(poolsFromFactory);
|
|
114
110
|
this.logger.info(`${this.dexKey}: pools list was updated ...`);
|
|
115
111
|
}
|
|
116
112
|
decodePools = (result) => {
|
|
@@ -136,7 +132,6 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
136
132
|
// A pair must have 2 different tokens.
|
|
137
133
|
if (srcAddress === destAddress)
|
|
138
134
|
return [];
|
|
139
|
-
this.pools = this.pools.filter(pool => !this.restrictedIds.includes(pool.id));
|
|
140
135
|
const pools = this.pools.filter(pool => (srcAddress === pool.token0 && destAddress === pool.token1) ||
|
|
141
136
|
(srcAddress === pool.token1 && destAddress === pool.token0));
|
|
142
137
|
return pools;
|
|
@@ -171,10 +166,10 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
171
166
|
}
|
|
172
167
|
const prices = amounts.map(amount => {
|
|
173
168
|
if (side === constants_1.SwapSide.SELL) {
|
|
174
|
-
return this.swapIn(srcToken.address.toLowerCase() === pool.token0.toLowerCase(), amount, currentPoolReserves.collateralReserves, currentPoolReserves.debtReserves, srcToken.decimals, destToken.decimals, BigInt(currentPoolReserves.fee), currentPoolReserves.dexLimits, Math.floor(Date.now() / 1000));
|
|
169
|
+
return this.swapIn(srcToken.address.toLowerCase() === pool.token0.toLowerCase(), amount, currentPoolReserves.collateralReserves, currentPoolReserves.debtReserves, srcToken.decimals, destToken.decimals, BigInt(currentPoolReserves.fee), currentPoolReserves.dexLimits, BigInt(currentPoolReserves.centerPrice), Math.floor(Date.now() / 1000));
|
|
175
170
|
}
|
|
176
171
|
else {
|
|
177
|
-
return this.swapOut(srcToken.address.toLowerCase() === pool.token0.toLowerCase(), amount, currentPoolReserves.collateralReserves, currentPoolReserves.debtReserves, srcToken.decimals, destToken.decimals, BigInt(currentPoolReserves.fee), currentPoolReserves.dexLimits, Math.floor(Date.now() / 1000));
|
|
172
|
+
return this.swapOut(srcToken.address.toLowerCase() === pool.token0.toLowerCase(), amount, currentPoolReserves.collateralReserves, currentPoolReserves.debtReserves, srcToken.decimals, destToken.decimals, BigInt(currentPoolReserves.fee), currentPoolReserves.dexLimits, BigInt(currentPoolReserves.centerPrice), Math.floor(Date.now() / 1000));
|
|
178
173
|
}
|
|
179
174
|
});
|
|
180
175
|
return {
|
|
@@ -238,10 +233,20 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
238
233
|
}
|
|
239
234
|
else {
|
|
240
235
|
if (pool.token0.toLowerCase() !== srcToken.toLowerCase()) {
|
|
241
|
-
args = [
|
|
236
|
+
args = [
|
|
237
|
+
false,
|
|
238
|
+
(BigInt(destAmount) * 1000001n) / 1000000n, // 0.0001% increase target out amount when calling Fluid Dex as it is not 100% exact. Guarantees meeting reaching exact out amount condition
|
|
239
|
+
BigInt(srcAmount),
|
|
240
|
+
recipient,
|
|
241
|
+
];
|
|
242
242
|
}
|
|
243
243
|
else {
|
|
244
|
-
args = [
|
|
244
|
+
args = [
|
|
245
|
+
true,
|
|
246
|
+
(BigInt(destAmount) * 1000001n) / 1000000n, // 0.0001% increase target out amount when calling Fluid Dex as it is not 100% exact. Guarantees meeting reaching exact out amount condition
|
|
247
|
+
BigInt(srcAmount),
|
|
248
|
+
recipient,
|
|
249
|
+
];
|
|
245
250
|
}
|
|
246
251
|
}
|
|
247
252
|
const swapData = this.fluidDexPoolIface.encodeFunctionData(method, args);
|
|
@@ -264,7 +269,7 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
264
269
|
* @param outDecimals - The number of decimals for the output token.
|
|
265
270
|
* @returns The calculated output amount (as a BigInt).
|
|
266
271
|
*/
|
|
267
|
-
swapIn(swap0To1, amountIn, colReserves, debtReserves, inDecimals, outDecimals, fee, currentLimits, syncTime) {
|
|
272
|
+
swapIn(swap0To1, amountIn, colReserves, debtReserves, inDecimals, outDecimals, fee, currentLimits, centerPrice, syncTime) {
|
|
268
273
|
if (amountIn === 0n) {
|
|
269
274
|
return 0n; // Return 0 if input amount is 0
|
|
270
275
|
}
|
|
@@ -273,7 +278,7 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
273
278
|
return 0n;
|
|
274
279
|
}
|
|
275
280
|
const amountInAdjusted = (amountIn * BigInt(10 ** 12)) / BigInt(10 ** inDecimals);
|
|
276
|
-
const amountOut = this.swapInAdjusted(swap0To1, amountInAdjusted, colReserves, debtReserves, fee, outDecimals, currentLimits, syncTime);
|
|
281
|
+
const amountOut = this.swapInAdjusted(swap0To1, amountInAdjusted, colReserves, debtReserves, fee, outDecimals, currentLimits, centerPrice, syncTime);
|
|
277
282
|
return (amountOut * BigInt(10 ** outDecimals)) / BigInt(10 ** 12);
|
|
278
283
|
}
|
|
279
284
|
/**
|
|
@@ -284,7 +289,7 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
284
289
|
* @param debtReserves - The reserves of the debt pool.
|
|
285
290
|
* @returns The calculated output amount.
|
|
286
291
|
*/
|
|
287
|
-
swapInAdjusted(swap0To1, amountToSwap, colReserves, debtReserves, fee, outDecimals, currentLimits, syncTime) {
|
|
292
|
+
swapInAdjusted(swap0To1, amountToSwap, colReserves, debtReserves, fee, outDecimals, currentLimits, centerPrice, syncTime) {
|
|
288
293
|
const { token0RealReserves, token1RealReserves, token0ImaginaryReserves, token1ImaginaryReserves, } = colReserves;
|
|
289
294
|
const { token0RealReserves: debtToken0RealReserves, token1RealReserves: debtToken1RealReserves, token0ImaginaryReserves: debtToken0ImaginaryReserves, token1ImaginaryReserves: debtToken1ImaginaryReserves, } = debtReserves;
|
|
290
295
|
// Check if all reserves of collateral pool are greater than 0
|
|
@@ -374,6 +379,22 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
374
379
|
if (amountOutCollateral > withdrawable) {
|
|
375
380
|
return 0n;
|
|
376
381
|
}
|
|
382
|
+
if (amountInCollateral > 0) {
|
|
383
|
+
let reservesRatioValid = swap0To1
|
|
384
|
+
? this.verifyToken1Reserves(colReserveIn + amountInCollateral, colReserveOut - amountOutCollateral, centerPrice)
|
|
385
|
+
: this.verifyToken0Reserves(colReserveOut - amountOutCollateral, colReserveIn + amountInCollateral, centerPrice);
|
|
386
|
+
if (!reservesRatioValid) {
|
|
387
|
+
return 0n;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
if (amountInDebt > 0) {
|
|
391
|
+
let reservesRatioValid = swap0To1
|
|
392
|
+
? this.verifyToken1Reserves(debtReserveIn + amountInDebt, debtReserveOut - amountOutDebt, centerPrice)
|
|
393
|
+
: this.verifyToken0Reserves(debtReserveOut - amountOutDebt, debtReserveIn + amountInDebt, centerPrice);
|
|
394
|
+
if (!reservesRatioValid) {
|
|
395
|
+
return 0n;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
377
398
|
// For price calculations, we'll use a precision factor for bigint division
|
|
378
399
|
const PRECISION = 1000000000000000000000000000n; // 1e27
|
|
379
400
|
let oldPrice;
|
|
@@ -407,22 +428,6 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
407
428
|
if (priceDiff > maxAllowedDiff) {
|
|
408
429
|
return 0n;
|
|
409
430
|
}
|
|
410
|
-
if (amountInCollateral > 0) {
|
|
411
|
-
let reservesRatioValid = swap0To1
|
|
412
|
-
? this.verifyToken1Reserves(colReserveIn + amountInCollateral, colReserveOut - amountOutCollateral, oldPrice)
|
|
413
|
-
: this.verifyToken0Reserves(colReserveOut - amountOutCollateral, colReserveIn + amountInCollateral, oldPrice);
|
|
414
|
-
if (!reservesRatioValid) {
|
|
415
|
-
return 0n;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
if (amountInDebt > 0) {
|
|
419
|
-
let reservesRatioValid = swap0To1
|
|
420
|
-
? this.verifyToken1Reserves(debtReserveIn + amountInDebt, debtReserveOut - amountOutDebt, oldPrice)
|
|
421
|
-
: this.verifyToken0Reserves(debtReserveOut - amountOutDebt, debtReserveIn + amountInDebt, oldPrice);
|
|
422
|
-
if (!reservesRatioValid) {
|
|
423
|
-
return 0n;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
431
|
const totalAmountOut = amountOutCollateral + amountOutDebt;
|
|
427
432
|
return totalAmountOut;
|
|
428
433
|
}
|
|
@@ -560,12 +565,9 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
560
565
|
* @param {number} fee - The fee for the swap. 1e4 = 1%
|
|
561
566
|
* @returns {bigint} amountIn - The calculated input amount required for the swap.
|
|
562
567
|
*/
|
|
563
|
-
swapOut(swap0to1, amountOut, colReserves, debtReserves, inDecimals, outDecimals, fee, currentLimits, syncTime) {
|
|
568
|
+
swapOut(swap0to1, amountOut, colReserves, debtReserves, inDecimals, outDecimals, fee, currentLimits, centerPrice, syncTime) {
|
|
564
569
|
const amountOutAdjusted = (amountOut * BigInt(10 ** 12)) / BigInt(10 ** outDecimals);
|
|
565
|
-
const amountIn = this.swapOutAdjusted(swap0to1, amountOutAdjusted, colReserves, debtReserves, fee, outDecimals, currentLimits, syncTime);
|
|
566
|
-
if (amountIn === 2n ** 256n - 1n) {
|
|
567
|
-
return amountIn;
|
|
568
|
-
}
|
|
570
|
+
const amountIn = this.swapOutAdjusted(swap0to1, amountOutAdjusted, colReserves, debtReserves, fee, outDecimals, currentLimits, centerPrice, syncTime);
|
|
569
571
|
const ans = (amountIn * BigInt(10 ** inDecimals)) / BigInt(10 ** 12);
|
|
570
572
|
return ans;
|
|
571
573
|
}
|
|
@@ -577,7 +579,7 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
577
579
|
* @param {DebtReserves} debtReserves - The reserves of the debt pool.
|
|
578
580
|
* @returns {bigint} The calculated input amount required for the swap.
|
|
579
581
|
*/
|
|
580
|
-
swapOutAdjusted(swap0to1, amountOut, colReserves, debtReserves, fee, outDecimals, currentLimits, syncTime) {
|
|
582
|
+
swapOutAdjusted(swap0to1, amountOut, colReserves, debtReserves, fee, outDecimals, currentLimits, centerPrice, syncTime) {
|
|
581
583
|
if (amountOut === 0n) {
|
|
582
584
|
return 0n; // Return 0 if output amount is 0
|
|
583
585
|
}
|
|
@@ -647,10 +649,10 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
647
649
|
amountInDebt = this.getAmountIn(amountOut, debtIReserveIn, debtIReserveOut);
|
|
648
650
|
amountInDebt = this.applyFeeForBuy(amountInDebt, fee);
|
|
649
651
|
if (amountOut > debtReserveOut) {
|
|
650
|
-
return
|
|
652
|
+
return 0n;
|
|
651
653
|
}
|
|
652
654
|
if (amountOut > borrowable) {
|
|
653
|
-
return
|
|
655
|
+
return 0n;
|
|
654
656
|
}
|
|
655
657
|
}
|
|
656
658
|
else if (a >= amountOut) {
|
|
@@ -659,10 +661,10 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
659
661
|
amountInCollateral = this.getAmountIn(amountOut, colIReserveIn, colIReserveOut);
|
|
660
662
|
amountInCollateral = this.applyFeeForBuy(amountInCollateral, fee);
|
|
661
663
|
if (amountOut > colReserveOut) {
|
|
662
|
-
return
|
|
664
|
+
return 0n;
|
|
663
665
|
}
|
|
664
666
|
if (amountOut > withdrawable) {
|
|
665
|
-
return
|
|
667
|
+
return 0n;
|
|
666
668
|
}
|
|
667
669
|
}
|
|
668
670
|
else {
|
|
@@ -674,10 +676,26 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
674
676
|
amountInDebt = this.getAmountIn(amountOutDebtAdjusted, debtIReserveIn, debtIReserveOut);
|
|
675
677
|
amountInDebt = this.applyFeeForBuy(amountInDebt, fee);
|
|
676
678
|
if (amountOutDebt > debtReserveOut || a > colReserveOut) {
|
|
677
|
-
return
|
|
679
|
+
return 0n;
|
|
678
680
|
}
|
|
679
681
|
if (amountOutDebt > borrowable || a > withdrawable) {
|
|
680
|
-
return
|
|
682
|
+
return 0n;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
if (amountInCollateral > 0) {
|
|
686
|
+
let reservesRatioValid = swap0to1
|
|
687
|
+
? this.verifyToken1Reserves(colReserveIn + amountInCollateral, colReserveOut - amountOutCollateral, centerPrice)
|
|
688
|
+
: this.verifyToken0Reserves(colReserveOut - amountOutCollateral, colReserveIn + amountInCollateral, centerPrice);
|
|
689
|
+
if (!reservesRatioValid) {
|
|
690
|
+
return 0n;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
if (amountInDebt > 0) {
|
|
694
|
+
let reservesRatioValid = swap0to1
|
|
695
|
+
? this.verifyToken1Reserves(debtReserveIn + amountInDebt, debtReserveOut - amountOutDebt, centerPrice)
|
|
696
|
+
: this.verifyToken0Reserves(debtReserveOut - amountOutDebt, debtReserveIn + amountInDebt, centerPrice);
|
|
697
|
+
if (!reservesRatioValid) {
|
|
698
|
+
return 0n;
|
|
681
699
|
}
|
|
682
700
|
}
|
|
683
701
|
let oldPrice;
|
|
@@ -710,23 +728,7 @@ class FluidDex extends simple_exchange_1.SimpleExchange {
|
|
|
710
728
|
if (this.abs(oldPrice - newPrice) >
|
|
711
729
|
(oldPrice / BigInt(100)) * MAX_PRICE_DIFF) {
|
|
712
730
|
// if price diff is > 5% then swap would revert.
|
|
713
|
-
return
|
|
714
|
-
}
|
|
715
|
-
if (amountInCollateral > 0) {
|
|
716
|
-
let reservesRatioValid = swap0to1
|
|
717
|
-
? this.verifyToken1Reserves(colReserveIn + amountInCollateral, colReserveOut - amountOutCollateral, oldPrice)
|
|
718
|
-
: this.verifyToken0Reserves(colReserveOut - amountOutCollateral, colReserveIn + amountInCollateral, oldPrice);
|
|
719
|
-
if (!reservesRatioValid) {
|
|
720
|
-
return 0n;
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
if (amountInDebt > 0) {
|
|
724
|
-
let reservesRatioValid = swap0to1
|
|
725
|
-
? this.verifyToken1Reserves(debtReserveIn + amountInDebt, debtReserveOut - amountOutDebt, oldPrice)
|
|
726
|
-
: this.verifyToken0Reserves(debtReserveOut - amountOutDebt, debtReserveIn + amountInDebt, oldPrice);
|
|
727
|
-
if (!reservesRatioValid) {
|
|
728
|
-
return 0n;
|
|
729
|
-
}
|
|
731
|
+
return 0n;
|
|
730
732
|
}
|
|
731
733
|
const totalAmountIn = amountInCollateral + amountInDebt;
|
|
732
734
|
return totalAmountIn;
|