@paraswap/dex-lib 4.1.2-fluid.2 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/aws.xml +17 -0
- package/.idea/codeStyles/Project.xml +19 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/paraswap-dex-lib.iml +9 -0
- package/.idea/prettier.xml +7 -0
- package/.idea/vcs.xml +6 -0
- package/build/abi/fluid-dex/resolver.abi.json +0 -30
- package/build/abi/integral/factory.json +333 -0
- package/build/abi/{angle-transmuter/ChainlinkEACAggregatorProxy.json → integral/oracle.json} +239 -247
- package/build/abi/{curve-v1/StableSwapUSDN.json → integral/pool.json} +487 -450
- package/build/abi/{RamsesV2Pool.abi.json → integral/relayer.json} +833 -851
- package/build/dex/aave-v1/aave-v1.d.ts +1 -2
- package/build/dex/aave-v1/aave-v1.js +0 -22
- package/build/dex/aave-v1/aave-v1.js.map +1 -1
- package/build/dex/bProtocol.d.ts +18 -0
- package/build/dex/bProtocol.js +39 -0
- package/build/dex/bProtocol.js.map +1 -0
- package/build/dex/bancor.d.ts +26 -0
- package/build/dex/bancor.js +58 -0
- package/build/dex/bancor.js.map +1 -0
- package/build/dex/compound.d.ts +18 -0
- package/build/dex/compound.js +46 -0
- package/build/dex/compound.js.map +1 -0
- package/build/dex/curve-v2.d.ts +58 -0
- package/build/dex/curve-v2.js +180 -0
- package/build/dex/curve-v2.js.map +1 -0
- package/build/dex/dodo-v1.d.ts +33 -0
- package/build/dex/dodo-v1.js +63 -0
- package/build/dex/dodo-v1.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 +1 -2
- package/build/dex/fluid-dex/constants.js.map +1 -1
- package/build/dex/fluid-dex/fluid-dex-generate-pool.d.ts +49 -0
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js +104 -0
- package/build/dex/fluid-dex/fluid-dex-generate-pool.js.map +1 -0
- package/build/dex/fluid-dex/fluid-dex-liquidity-proxy.js +1 -3
- package/build/dex/fluid-dex/fluid-dex-liquidity-proxy.js.map +1 -1
- package/build/dex/fluid-dex/fluid-dex.d.ts +5 -4
- package/build/dex/fluid-dex/fluid-dex.js +56 -61
- package/build/dex/fluid-dex/fluid-dex.js.map +1 -1
- package/build/dex/fluid-dex/types.d.ts +0 -3
- package/build/dex/integral/config.d.ts +4 -0
- package/build/dex/integral/config.js +20 -0
- package/build/dex/integral/config.js.map +1 -0
- package/build/dex/integral/context.d.ts +40 -0
- package/build/dex/integral/context.js +158 -0
- package/build/dex/integral/context.js.map +1 -0
- package/build/dex/integral/integral-factory.d.ts +24 -0
- package/build/dex/integral/integral-factory.js +95 -0
- package/build/dex/integral/integral-factory.js.map +1 -0
- package/build/dex/integral/integral-pool.d.ts +50 -0
- package/build/dex/integral/integral-pool.js +149 -0
- package/build/dex/integral/integral-pool.js.map +1 -0
- package/build/dex/integral/integral-pricing.d.ts +18 -0
- package/build/dex/integral/integral-pricing.js +114 -0
- package/build/dex/integral/integral-pricing.js.map +1 -0
- package/build/dex/integral/integral-relayer.d.ts +42 -0
- package/build/dex/integral/integral-relayer.js +192 -0
- package/build/dex/integral/integral-relayer.js.map +1 -0
- package/build/dex/integral/integral-token.d.ts +27 -0
- package/build/dex/integral/integral-token.js +59 -0
- package/build/dex/integral/integral-token.js.map +1 -0
- package/build/dex/{inception/inception-native.d.ts → integral/integral.d.ts} +19 -21
- package/build/dex/integral/integral.js +376 -0
- package/build/dex/integral/integral.js.map +1 -0
- package/build/dex/integral/types.d.ts +85 -0
- package/build/dex/integral/types.js +9 -0
- package/build/dex/integral/types.js.map +1 -0
- package/build/dex/integral/utils-e2e.d.ts +9 -0
- package/build/dex/integral/utils-e2e.js +131 -0
- package/build/dex/integral/utils-e2e.js.map +1 -0
- package/build/dex/integral/utils.d.ts +17 -0
- package/build/dex/integral/utils.js +94 -0
- package/build/dex/integral/utils.js.map +1 -0
- package/build/dex/jarvis.d.ts +1 -2
- package/build/dex/jarvis.js +0 -58
- package/build/dex/jarvis.js.map +1 -1
- package/build/dex/lido.d.ts +19 -0
- package/build/dex/lido.js +42 -0
- package/build/dex/lido.js.map +1 -0
- package/build/dex/onebit.d.ts +25 -0
- package/build/dex/onebit.js +42 -0
- package/build/dex/onebit.js.map +1 -0
- package/build/dex/platypus/platypus.d.ts +1 -2
- package/build/dex/platypus/platypus.js +0 -31
- package/build/dex/platypus/platypus.js.map +1 -1
- package/build/dex/smoothy.d.ts +26 -0
- package/build/dex/smoothy.js +48 -0
- package/build/dex/smoothy.js.map +1 -0
- package/build/dex/stable-pool.d.ts +28 -0
- package/build/dex/stable-pool.js +62 -0
- package/build/dex/stable-pool.js.map +1 -0
- package/build/dex/swaap-v1/swaap-v1.d.ts +1 -2
- package/build/dex/swaap-v1/swaap-v1.js +0 -10
- package/build/dex/swaap-v1/swaap-v1.js.map +1 -1
- package/build/dex/trader-joe-v2.1/optimizer.d.ts +2 -0
- package/build/dex/trader-joe-v2.1/optimizer.js +47 -0
- package/build/dex/trader-joe-v2.1/optimizer.js.map +1 -0
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.d.ts +7 -0
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js +20 -0
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1-new.js.map +1 -0
- package/build/dex/trader-joe-v2.1.d.ts +43 -0
- package/build/dex/trader-joe-v2.1.js +79 -0
- package/build/dex/trader-joe-v2.1.js.map +1 -0
- package/build/dex/zerox/index.d.ts +26 -4
- package/build/dex/zerox/index.js +42 -50
- package/build/dex/zerox/index.js.map +1 -1
- package/build/dex/zerox/types.d.ts +0 -29
- package/build/dex/zerox/types.js +1 -8
- package/build/dex/zerox/types.js.map +1 -1
- package/package.json +1 -1
- package/src/abi/fluid-dex/resolver.abi.json +0 -30
- package/src/dex/fluid-dex/config.ts +2 -2
- package/src/dex/fluid-dex/constants.ts +1 -2
- package/src/dex/fluid-dex/fluid-dex-e2e.test.ts +117 -61
- package/src/dex/fluid-dex/fluid-dex-liquidity-proxy.ts +0 -3
- package/src/dex/fluid-dex/fluid-dex.ts +91 -96
- package/src/dex/fluid-dex/types.ts +0 -3
- package/tests/constants-e2e.ts +1 -1
- package/tests/tenderly-simulation.ts +0 -1
- package/build/abi/Aave_GSM.json +0 -751
- package/build/abi/Balancer.json +0 -257
- package/build/abi/BalancerV2.json +0 -1179
- package/build/abi/RamsesV2Quoter.abi.json +0 -274
- package/build/abi/USDM.json +0 -807
- package/build/abi/UniswapV2Router.json +0 -397
- package/build/abi/angle-transmuter/ChainlinkAccessControlledOffchainAggregator.json +0 -1246
- package/build/abi/curve-v1/CurveBUSDv2.abi.json +0 -1356
- package/build/abi/curve-v1/CurveTokenV1.json +0 -305
- package/build/abi/curve-v1/CurveTokenV2.json +0 -318
- package/build/abi/curve-v1/CurveV1StableNg.json +0 -1452
- package/build/abi/curve-v1/CurveV2Swap.json +0 -700
- package/build/abi/curve-v1/FactoryCryptoRegistry.json +0 -316
- package/build/abi/curve-v1/FactoryRegistry.json +0 -508
- package/build/abi/curve-v1/StableSwapAave.json +0 -1152
- package/build/abi/curve-v1/StableSwapBUSD.json +0 -814
- package/build/abi/curve-v1/StableSwapCompound.json +0 -814
- package/build/abi/curve-v1/StableSwapIDLE.json +0 -1253
- package/build/abi/curve-v1/StableSwapPax.json +0 -865
- package/build/abi/curve-v1/StableSwapSnow.json +0 -900
- package/build/abi/curve-v1/StableSwapUSDT.json +0 -814
- package/build/abi/curve-v1/StableSwapY.json +0 -814
- package/build/abi/inception/inception-ineth-pool.json +0 -1062
- package/build/abi/inception/inception-ineth.json +0 -609
- package/build/abi/inception/inception-ratio-feed.json +0 -329
- package/build/abi/inception/inception-vault.json +0 -991
- package/build/abi/kyberdmm/kyber-storage.abi.json +0 -824
- package/build/abi/kyberdmm.abi.json +0 -1148
- package/build/abi/maverick-v2/MaverickV2Quoter.json +0 -278
- package/build/abi/nerve/nerve-metapool.json +0 -790
- package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
- package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +0 -267
- package/build/dex/balancer-v1/balancer-pools.json +0 -33333
- package/build/dex/bebop/websocket-fetcher.d.ts +0 -35
- package/build/dex/bebop/websocket-fetcher.js +0 -87
- package/build/dex/bebop/websocket-fetcher.js.map +0 -1
- package/build/dex/idle-dao/idle-dao-pool.d.ts +0 -56
- package/build/dex/idle-dao/idle-dao-pool.js +0 -176
- package/build/dex/idle-dao/idle-dao-pool.js.map +0 -1
- package/build/dex/idle-dao/idle-dao-pooling-pool.d.ts +0 -16
- package/build/dex/idle-dao/idle-dao-pooling-pool.js +0 -57
- package/build/dex/idle-dao/idle-dao-pooling-pool.js.map +0 -1
- package/build/dex/idle-dao/scripts.d.ts +0 -9
- package/build/dex/idle-dao/scripts.js +0 -552
- package/build/dex/idle-dao/scripts.js.map +0 -1
- package/build/dex/inception/config.d.ts +0 -4
- package/build/dex/inception/config.js +0 -109
- package/build/dex/inception/config.js.map +0 -1
- package/build/dex/inception/inception-event-pool.d.ts +0 -16
- package/build/dex/inception/inception-event-pool.js +0 -51
- package/build/dex/inception/inception-event-pool.js.map +0 -1
- package/build/dex/inception/inception-native.js +0 -131
- package/build/dex/inception/inception-native.js.map +0 -1
- package/build/dex/inception/inception-pool.d.ts +0 -18
- package/build/dex/inception/inception-pool.js +0 -32
- package/build/dex/inception/inception-pool.js.map +0 -1
- package/build/dex/inception/inception-price-feed.d.ts +0 -19
- package/build/dex/inception/inception-price-feed.js +0 -51
- package/build/dex/inception/inception-price-feed.js.map +0 -1
- package/build/dex/inception/inception.d.ts +0 -43
- package/build/dex/inception/inception.js +0 -204
- package/build/dex/inception/inception.js.map +0 -1
- package/build/dex/inception/tokens.d.ts +0 -9
- package/build/dex/inception/tokens.js +0 -28
- package/build/dex/inception/tokens.js.map +0 -1
- package/build/dex/inception/types.d.ts +0 -22
- package/build/dex/inception/types.js +0 -3
- package/build/dex/inception/types.js.map +0 -1
- package/build/dex/inception/utils.d.ts +0 -6
- package/build/dex/inception/utils.js +0 -37
- package/build/dex/inception/utils.js.map +0 -1
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -16
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-eth-steth.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-steth-eth.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-eth-usdc.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-eth.json +0 -9
- package/build/executor/fixtures/executor01/exchange-params/price-route-simpleSwap-univ3-usdc-usdt.json +0 -9
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -12
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -7
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -7
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -7
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -7
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -12
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-eth-usdc.json +0 -7
- package/build/executor/fixtures/executor01/maybe-weth-calldata/price-route-simpleSwap-univ3-usdc-eth.json +0 -7
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-curvev1-eth-usdc-gusd.json +0 -78
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-balancerv1-sushiv3-wbtc-eth-sushi.json +0 -81
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-eth-usdc-gusd.json +0 -78
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-curvev1-gusd-usdc-eth.json +0 -78
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-dai-usdc-eth.json +0 -81
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-eth-usdc-dai.json +0 -81
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdc-eth-wbtc.json +0 -81
- package/build/executor/fixtures/executor01/routes/price-route-multiswap-sushiv3-usdt-usdc-dai.json +0 -81
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-eth-usdc.json +0 -64
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-eth.json +0 -85
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-balancerv1-usdc-wbtc.json +0 -64
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-eth-steth.json +0 -52
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-steth-eth.json +0 -52
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-curvev1-usdc-usdt.json +0 -52
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-eth-usdc.json +0 -55
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-eth.json +0 -55
- package/build/executor/fixtures/executor01/routes/price-route-simpleSwap-univ3-usdc-usdt.json +0 -55
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -23
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -37
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -23
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -23
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -51
- package/build/executor/fixtures/executor02/exchange-params/price-route-multiswap-univ3-usdt-dai-eth.json +0 -58
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -23
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -23
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -9
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -16
- package/build/executor/fixtures/executor02/exchange-params/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -23
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -12
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -12
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -12
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-multiswap-univ3-usdt-dai-eth.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -7
- package/build/executor/fixtures/executor02/maybe-weth-calldata/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -7
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-balancerv1-sushiv3-univ3-bal-eth-sushi.json +0 -130
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-maverickv1-sushiv3-univ3-eth-usdc-mav.json +0 -136
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-sushi-eth-wbtc.json +0 -100
- package/build/executor/fixtures/executor02/routes/price-route-multiSwap-univ3-sushiv3-wbtc-eth-sushi.json +0 -100
- package/build/executor/fixtures/executor02/routes/price-route-multiswap-curvev1-univ3-dai-usdc-eth.json +0 -166
- package/build/executor/fixtures/executor02/routes/price-route-multiswap-univ3-usdt-dai-eth.json +0 -190
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-eth-usdc.json +0 -114
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-balancerv1-usdc-eth.json +0 -114
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-eth-sushi.json +0 -55
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-sushiv3-univ3-sushi-eth.json +0 -73
- package/build/executor/fixtures/executor02/routes/price-route-simpleSwap-univ3-curvev1-usdt-dai.json +0 -82
|
@@ -48,6 +48,11 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
48
48
|
|
|
49
49
|
pools: FluidDexPool[] = [];
|
|
50
50
|
|
|
51
|
+
// temporarily limit FLUID-ETH Dex Pool.
|
|
52
|
+
restrictedIds: string[] = [
|
|
53
|
+
'FluidDex_0xc800b0e15c40a1ff0539218100c86f4c1bac8d9c',
|
|
54
|
+
];
|
|
55
|
+
|
|
51
56
|
eventPools: FluidDexEventPool[] = [];
|
|
52
57
|
|
|
53
58
|
readonly factory: FluidDexFactory;
|
|
@@ -110,7 +115,9 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
110
115
|
// implement this function
|
|
111
116
|
async initializePricing(blockNumber: number) {
|
|
112
117
|
await this.factory.initialize(blockNumber);
|
|
113
|
-
this.pools = await this.fetchFluidDexPools(blockNumber)
|
|
118
|
+
this.pools = (await this.fetchFluidDexPools(blockNumber)).filter(
|
|
119
|
+
pool => !this.restrictedIds.includes(pool.id),
|
|
120
|
+
);
|
|
114
121
|
this.eventPools = await Promise.all(
|
|
115
122
|
this.pools.map(async pool => {
|
|
116
123
|
const eventPool = new FluidDexEventPool(
|
|
@@ -133,7 +140,9 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
133
140
|
}
|
|
134
141
|
|
|
135
142
|
protected onPoolCreatedUpdatePools(poolsFromFactory: readonly Pool[]) {
|
|
136
|
-
this.pools = this.generateFluidDexPoolsFromPoolsFactory(
|
|
143
|
+
this.pools = this.generateFluidDexPoolsFromPoolsFactory(
|
|
144
|
+
poolsFromFactory,
|
|
145
|
+
).filter(pool => !this.restrictedIds.includes(pool.id));
|
|
137
146
|
this.logger.info(`${this.dexKey}: pools list was updated ...`);
|
|
138
147
|
}
|
|
139
148
|
|
|
@@ -173,6 +182,9 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
173
182
|
// A pair must have 2 different tokens.
|
|
174
183
|
if (srcAddress === destAddress) return [];
|
|
175
184
|
|
|
185
|
+
this.pools = this.pools.filter(
|
|
186
|
+
pool => !this.restrictedIds.includes(pool.id),
|
|
187
|
+
);
|
|
176
188
|
const pools = this.pools.filter(
|
|
177
189
|
pool =>
|
|
178
190
|
(srcAddress === pool.token0 && destAddress === pool.token1) ||
|
|
@@ -248,7 +260,6 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
248
260
|
destToken.decimals,
|
|
249
261
|
BigInt(currentPoolReserves.fee),
|
|
250
262
|
currentPoolReserves.dexLimits,
|
|
251
|
-
BigInt(currentPoolReserves.centerPrice),
|
|
252
263
|
Math.floor(Date.now() / 1000),
|
|
253
264
|
);
|
|
254
265
|
} else {
|
|
@@ -261,7 +272,6 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
261
272
|
destToken.decimals,
|
|
262
273
|
BigInt(currentPoolReserves.fee),
|
|
263
274
|
currentPoolReserves.dexLimits,
|
|
264
|
-
BigInt(currentPoolReserves.centerPrice),
|
|
265
275
|
Math.floor(Date.now() / 1000),
|
|
266
276
|
);
|
|
267
277
|
}
|
|
@@ -370,19 +380,9 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
370
380
|
}
|
|
371
381
|
} else {
|
|
372
382
|
if (pool!.token0.toLowerCase() !== srcToken.toLowerCase()) {
|
|
373
|
-
args = [
|
|
374
|
-
false,
|
|
375
|
-
(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
|
|
376
|
-
BigInt(srcAmount),
|
|
377
|
-
recipient,
|
|
378
|
-
];
|
|
383
|
+
args = [false, BigInt(destAmount), BigInt(srcAmount), recipient];
|
|
379
384
|
} else {
|
|
380
|
-
args = [
|
|
381
|
-
true,
|
|
382
|
-
(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
|
|
383
|
-
BigInt(srcAmount),
|
|
384
|
-
recipient,
|
|
385
|
-
];
|
|
385
|
+
args = [true, BigInt(destAmount), BigInt(srcAmount), recipient];
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
const swapData = this.fluidDexPoolIface.encodeFunctionData(method, args);
|
|
@@ -415,7 +415,6 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
415
415
|
outDecimals: number,
|
|
416
416
|
fee: bigint,
|
|
417
417
|
currentLimits: DexLimits,
|
|
418
|
-
centerPrice: bigint,
|
|
419
418
|
syncTime: number,
|
|
420
419
|
): bigint {
|
|
421
420
|
if (amountIn === 0n) {
|
|
@@ -439,7 +438,6 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
439
438
|
fee,
|
|
440
439
|
outDecimals,
|
|
441
440
|
currentLimits,
|
|
442
|
-
centerPrice,
|
|
443
441
|
syncTime,
|
|
444
442
|
);
|
|
445
443
|
return (amountOut * BigInt(10 ** outDecimals)) / BigInt(10 ** 12);
|
|
@@ -461,7 +459,6 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
461
459
|
fee: bigint,
|
|
462
460
|
outDecimals: number,
|
|
463
461
|
currentLimits: DexLimits,
|
|
464
|
-
centerPrice: bigint,
|
|
465
462
|
syncTime: number,
|
|
466
463
|
): bigint {
|
|
467
464
|
const {
|
|
@@ -606,40 +603,6 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
606
603
|
return 0n;
|
|
607
604
|
}
|
|
608
605
|
|
|
609
|
-
if (amountInCollateral > 0) {
|
|
610
|
-
let reservesRatioValid = swap0To1
|
|
611
|
-
? this.verifyToken1Reserves(
|
|
612
|
-
colReserveIn + amountInCollateral,
|
|
613
|
-
colReserveOut - amountOutCollateral,
|
|
614
|
-
centerPrice,
|
|
615
|
-
)
|
|
616
|
-
: this.verifyToken0Reserves(
|
|
617
|
-
colReserveOut - amountOutCollateral,
|
|
618
|
-
colReserveIn + amountInCollateral,
|
|
619
|
-
centerPrice,
|
|
620
|
-
);
|
|
621
|
-
if (!reservesRatioValid) {
|
|
622
|
-
return 0n;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
if (amountInDebt > 0) {
|
|
627
|
-
let reservesRatioValid = swap0To1
|
|
628
|
-
? this.verifyToken1Reserves(
|
|
629
|
-
debtReserveIn + amountInDebt,
|
|
630
|
-
debtReserveOut - amountOutDebt,
|
|
631
|
-
centerPrice,
|
|
632
|
-
)
|
|
633
|
-
: this.verifyToken0Reserves(
|
|
634
|
-
debtReserveOut - amountOutDebt,
|
|
635
|
-
debtReserveIn + amountInDebt,
|
|
636
|
-
centerPrice,
|
|
637
|
-
);
|
|
638
|
-
if (!reservesRatioValid) {
|
|
639
|
-
return 0n;
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
|
|
643
606
|
// For price calculations, we'll use a precision factor for bigint division
|
|
644
607
|
const PRECISION = 1000000000000000000000000000n; // 1e27
|
|
645
608
|
|
|
@@ -679,6 +642,40 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
679
642
|
return 0n;
|
|
680
643
|
}
|
|
681
644
|
|
|
645
|
+
if (amountInCollateral > 0) {
|
|
646
|
+
let reservesRatioValid = swap0To1
|
|
647
|
+
? this.verifyToken1Reserves(
|
|
648
|
+
colReserveIn + amountInCollateral,
|
|
649
|
+
colReserveOut - amountOutCollateral,
|
|
650
|
+
oldPrice,
|
|
651
|
+
)
|
|
652
|
+
: this.verifyToken0Reserves(
|
|
653
|
+
colReserveOut - amountOutCollateral,
|
|
654
|
+
colReserveIn + amountInCollateral,
|
|
655
|
+
oldPrice,
|
|
656
|
+
);
|
|
657
|
+
if (!reservesRatioValid) {
|
|
658
|
+
return 0n;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
if (amountInDebt > 0) {
|
|
663
|
+
let reservesRatioValid = swap0To1
|
|
664
|
+
? this.verifyToken1Reserves(
|
|
665
|
+
debtReserveIn + amountInDebt,
|
|
666
|
+
debtReserveOut - amountOutDebt,
|
|
667
|
+
oldPrice,
|
|
668
|
+
)
|
|
669
|
+
: this.verifyToken0Reserves(
|
|
670
|
+
debtReserveOut - amountOutDebt,
|
|
671
|
+
debtReserveIn + amountInDebt,
|
|
672
|
+
oldPrice,
|
|
673
|
+
);
|
|
674
|
+
if (!reservesRatioValid) {
|
|
675
|
+
return 0n;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
|
|
682
679
|
const totalAmountOut = amountOutCollateral + amountOutDebt;
|
|
683
680
|
|
|
684
681
|
return totalAmountOut;
|
|
@@ -882,7 +879,6 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
882
879
|
outDecimals: number,
|
|
883
880
|
fee: bigint,
|
|
884
881
|
currentLimits: DexLimits,
|
|
885
|
-
centerPrice: bigint,
|
|
886
882
|
syncTime: number,
|
|
887
883
|
): bigint {
|
|
888
884
|
const amountOutAdjusted =
|
|
@@ -896,7 +892,6 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
896
892
|
fee,
|
|
897
893
|
outDecimals,
|
|
898
894
|
currentLimits,
|
|
899
|
-
centerPrice,
|
|
900
895
|
syncTime,
|
|
901
896
|
);
|
|
902
897
|
|
|
@@ -904,6 +899,7 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
904
899
|
return amountIn;
|
|
905
900
|
}
|
|
906
901
|
const ans = (amountIn * BigInt(10 ** inDecimals)) / BigInt(10 ** 12);
|
|
902
|
+
|
|
907
903
|
return ans;
|
|
908
904
|
}
|
|
909
905
|
|
|
@@ -923,7 +919,6 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
923
919
|
fee: bigint,
|
|
924
920
|
outDecimals: number,
|
|
925
921
|
currentLimits: DexLimits,
|
|
926
|
-
centerPrice: bigint,
|
|
927
922
|
syncTime: number,
|
|
928
923
|
): bigint {
|
|
929
924
|
if (amountOut === 0n) {
|
|
@@ -1041,10 +1036,10 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
1041
1036
|
);
|
|
1042
1037
|
amountInDebt = this.applyFeeForBuy(amountInDebt, fee);
|
|
1043
1038
|
if (amountOut > debtReserveOut) {
|
|
1044
|
-
return
|
|
1039
|
+
return 2n ** 256n - 1n;
|
|
1045
1040
|
}
|
|
1046
1041
|
if (amountOut > borrowable) {
|
|
1047
|
-
return
|
|
1042
|
+
return 2n ** 256n - 1n;
|
|
1048
1043
|
}
|
|
1049
1044
|
} else if (a >= amountOut) {
|
|
1050
1045
|
// Entire trade routes through collateral pool
|
|
@@ -1056,10 +1051,10 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
1056
1051
|
);
|
|
1057
1052
|
amountInCollateral = this.applyFeeForBuy(amountInCollateral, fee);
|
|
1058
1053
|
if (amountOut > colReserveOut) {
|
|
1059
|
-
return
|
|
1054
|
+
return 2n ** 256n - 1n;
|
|
1060
1055
|
}
|
|
1061
1056
|
if (amountOut > withdrawable) {
|
|
1062
|
-
return
|
|
1057
|
+
return 2n ** 256n - 1n;
|
|
1063
1058
|
}
|
|
1064
1059
|
} else {
|
|
1065
1060
|
// Trade routes through both pools
|
|
@@ -1077,43 +1072,10 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
1077
1072
|
|
|
1078
1073
|
amountInDebt = this.applyFeeForBuy(amountInDebt, fee);
|
|
1079
1074
|
if (amountOutDebt > debtReserveOut || a > colReserveOut) {
|
|
1080
|
-
return
|
|
1075
|
+
return 2n ** 256n - 1n;
|
|
1081
1076
|
}
|
|
1082
1077
|
if (amountOutDebt > borrowable || a > withdrawable) {
|
|
1083
|
-
return
|
|
1084
|
-
}
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
if (amountInCollateral > 0) {
|
|
1088
|
-
let reservesRatioValid = swap0to1
|
|
1089
|
-
? this.verifyToken1Reserves(
|
|
1090
|
-
colReserveIn + amountInCollateral,
|
|
1091
|
-
colReserveOut - amountOutCollateral,
|
|
1092
|
-
centerPrice,
|
|
1093
|
-
)
|
|
1094
|
-
: this.verifyToken0Reserves(
|
|
1095
|
-
colReserveOut - amountOutCollateral,
|
|
1096
|
-
colReserveIn + amountInCollateral,
|
|
1097
|
-
centerPrice,
|
|
1098
|
-
);
|
|
1099
|
-
if (!reservesRatioValid) {
|
|
1100
|
-
return 0n;
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
if (amountInDebt > 0) {
|
|
1104
|
-
let reservesRatioValid = swap0to1
|
|
1105
|
-
? this.verifyToken1Reserves(
|
|
1106
|
-
debtReserveIn + amountInDebt,
|
|
1107
|
-
debtReserveOut - amountOutDebt,
|
|
1108
|
-
centerPrice,
|
|
1109
|
-
)
|
|
1110
|
-
: this.verifyToken0Reserves(
|
|
1111
|
-
debtReserveOut - amountOutDebt,
|
|
1112
|
-
debtReserveIn + amountInDebt,
|
|
1113
|
-
centerPrice,
|
|
1114
|
-
);
|
|
1115
|
-
if (!reservesRatioValid) {
|
|
1116
|
-
return 0n;
|
|
1078
|
+
return 2n ** 256n - 1n;
|
|
1117
1079
|
}
|
|
1118
1080
|
}
|
|
1119
1081
|
|
|
@@ -1150,7 +1112,40 @@ export class FluidDex extends SimpleExchange implements IDex<FluidDexData> {
|
|
|
1150
1112
|
(oldPrice / BigInt(100)) * MAX_PRICE_DIFF
|
|
1151
1113
|
) {
|
|
1152
1114
|
// if price diff is > 5% then swap would revert.
|
|
1153
|
-
return
|
|
1115
|
+
return 2n ** 256n - 1n;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
if (amountInCollateral > 0) {
|
|
1119
|
+
let reservesRatioValid = swap0to1
|
|
1120
|
+
? this.verifyToken1Reserves(
|
|
1121
|
+
colReserveIn + amountInCollateral,
|
|
1122
|
+
colReserveOut - amountOutCollateral,
|
|
1123
|
+
oldPrice,
|
|
1124
|
+
)
|
|
1125
|
+
: this.verifyToken0Reserves(
|
|
1126
|
+
colReserveOut - amountOutCollateral,
|
|
1127
|
+
colReserveIn + amountInCollateral,
|
|
1128
|
+
oldPrice,
|
|
1129
|
+
);
|
|
1130
|
+
if (!reservesRatioValid) {
|
|
1131
|
+
return 0n;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
if (amountInDebt > 0) {
|
|
1135
|
+
let reservesRatioValid = swap0to1
|
|
1136
|
+
? this.verifyToken1Reserves(
|
|
1137
|
+
debtReserveIn + amountInDebt,
|
|
1138
|
+
debtReserveOut - amountOutDebt,
|
|
1139
|
+
oldPrice,
|
|
1140
|
+
)
|
|
1141
|
+
: this.verifyToken0Reserves(
|
|
1142
|
+
debtReserveOut - amountOutDebt,
|
|
1143
|
+
debtReserveIn + amountInDebt,
|
|
1144
|
+
oldPrice,
|
|
1145
|
+
);
|
|
1146
|
+
if (!reservesRatioValid) {
|
|
1147
|
+
return 0n;
|
|
1148
|
+
}
|
|
1154
1149
|
}
|
|
1155
1150
|
|
|
1156
1151
|
const totalAmountIn = amountInCollateral + amountInDebt;
|
|
@@ -6,7 +6,6 @@ export type PoolReserve = {
|
|
|
6
6
|
token0: string;
|
|
7
7
|
token1: string;
|
|
8
8
|
fee: number;
|
|
9
|
-
centerPrice: number;
|
|
10
9
|
collateralReserves: CollateralReserves;
|
|
11
10
|
debtReserves: DebtReserves;
|
|
12
11
|
dexLimits: DexLimits;
|
|
@@ -17,7 +16,6 @@ export type PoolReserveResponse = [
|
|
|
17
16
|
string,
|
|
18
17
|
string,
|
|
19
18
|
BigNumber,
|
|
20
|
-
BigNumber,
|
|
21
19
|
BigNumber[],
|
|
22
20
|
BigNumber[],
|
|
23
21
|
DexLimitResponse,
|
|
@@ -70,7 +68,6 @@ export interface PoolWithReserves {
|
|
|
70
68
|
token0: string;
|
|
71
69
|
token1: string;
|
|
72
70
|
fee: number;
|
|
73
|
-
centerPrice: number;
|
|
74
71
|
collateralReserves: CollateralReserves;
|
|
75
72
|
debtReserves: DebtReserves;
|
|
76
73
|
}
|
package/tests/constants-e2e.ts
CHANGED
|
@@ -1773,7 +1773,7 @@ export const Holders: {
|
|
|
1773
1773
|
BB_sUSDe: '0xaFeb95DEF3B2A3D532D74DaBd51E62048d6c07A4',
|
|
1774
1774
|
AA_iETHv2: '0xA118aD79E2152b9a3c7Df8B8791887762b0f1D49',
|
|
1775
1775
|
BB_iETHv2: '0x15079cBAa74C1df2a602fAc88Bd5b98B08FfE6A4',
|
|
1776
|
-
ETH: '
|
|
1776
|
+
ETH: '0x176F3DAb24a159341c0509bB36B833E7fdd0a132',
|
|
1777
1777
|
USDC: '0x7713974908be4bed47172370115e8b1219f4a5f0',
|
|
1778
1778
|
USDE: '0x8707f238936c12c309bfc2B9959C35828AcFc512',
|
|
1779
1779
|
AMPL: '0x223592a191ECfC7FDC38a9256c3BD96E771539A9',
|