@paraswap/dex-lib 4.1.21 → 4.1.22
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/dex/angle-transmuter/angle-transmuter.d.ts +3 -4
- package/build/dex/angle-transmuter/angle-transmuter.js +7 -5
- package/build/dex/angle-transmuter/angle-transmuter.js.map +1 -1
- package/build/dex/cables/cables.js +4 -0
- package/build/dex/cables/cables.js.map +1 -1
- package/build/dex/uniswap-v3/uniswap-v3-new.d.ts +94 -0
- package/build/dex/uniswap-v3/uniswap-v3-new.js +923 -0
- package/build/dex/uniswap-v3/uniswap-v3-new.js.map +1 -0
- package/build/dex/zerox/index.d.ts +1 -1
- package/build/dex/zerox/index.js.map +1 -1
- package/package.json +1 -1
- package/build/abi/AaveV1_lending_pool.json +0 -27
- 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/RamsesV2Pool.abi.json +0 -1554
- 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/angle-transmuter/ChainlinkEACAggregatorProxy.json +0 -509
- 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/StableSwapUSDN.json +0 -1004
- 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/platypus/asset.json +0 -490
- package/build/abi/platypus/avax-pool.json +0 -820
- package/build/abi/platypus/oracle.json +0 -119
- package/build/abi/platypus/pool.json +0 -677
- package/build/abi/smardex/all/smardex-router.json +0 -648
- package/build/abi/smardex/layer-1/smardex-factory.json +0 -242
- package/build/abi/smardex/layer-1/smardex-pool.json +0 -506
- package/build/abi/smardex/layer-2/smardex-factory.json +0 -185
- package/build/abi/smardex/layer-2/smardex-pool.json +0 -578
- package/build/abi/swaap-v1/pool.json +0 -1346
- package/build/abi/uniswap-v3/UniswapV3Quoter.abi.json +0 -193
- package/build/abi/velodrome-slipstream/VelodromeSlipstreamQuoterV2.abi.json +0 -267
- package/build/dex/aave-v1/aave-v1.d.ts +0 -34
- package/build/dex/aave-v1/aave-v1.js +0 -180
- package/build/dex/aave-v1/aave-v1.js.map +0 -1
- package/build/dex/aave-v1/config.d.ts +0 -11
- package/build/dex/aave-v1/config.js +0 -20
- package/build/dex/aave-v1/config.js.map +0 -1
- package/build/dex/aave-v1/tokens-mainnet.json +0 -134
- package/build/dex/aave-v1/tokens.d.ts +0 -3
- package/build/dex/aave-v1/tokens.js +0 -50
- package/build/dex/aave-v1/tokens.js.map +0 -1
- package/build/dex/aave-v1/types.d.ts +0 -12
- package/build/dex/aave-v1/types.js +0 -3
- package/build/dex/aave-v1/types.js.map +0 -1
- 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.d.ts +0 -43
- 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/dex/platypus/asset.d.ts +0 -14
- package/build/dex/platypus/asset.js +0 -97
- package/build/dex/platypus/asset.js.map +0 -1
- package/build/dex/platypus/config.d.ts +0 -11
- package/build/dex/platypus/config.js +0 -69
- package/build/dex/platypus/config.js.map +0 -1
- package/build/dex/platypus/platypus.d.ts +0 -63
- package/build/dex/platypus/platypus.js +0 -473
- package/build/dex/platypus/platypus.js.map +0 -1
- package/build/dex/platypus/pool-avax.d.ts +0 -8
- package/build/dex/platypus/pool-avax.js +0 -54
- package/build/dex/platypus/pool-avax.js.map +0 -1
- package/build/dex/platypus/pool-base.d.ts +0 -19
- package/build/dex/platypus/pool-base.js +0 -86
- package/build/dex/platypus/pool-base.js.map +0 -1
- package/build/dex/platypus/pool-pure.d.ts +0 -8
- package/build/dex/platypus/pool-pure.js +0 -37
- package/build/dex/platypus/pool-pure.js.map +0 -1
- package/build/dex/platypus/pool-subscriber.d.ts +0 -14
- package/build/dex/platypus/pool-subscriber.js +0 -167
- package/build/dex/platypus/pool-subscriber.js.map +0 -1
- package/build/dex/platypus/pool.d.ts +0 -8
- package/build/dex/platypus/pool.js +0 -58
- package/build/dex/platypus/pool.js.map +0 -1
- package/build/dex/platypus/types.d.ts +0 -92
- package/build/dex/platypus/types.js +0 -10
- package/build/dex/platypus/types.js.map +0 -1
- package/build/dex/quickswap/spiritswap-v3.d.ts +0 -6
- package/build/dex/quickswap/spiritswap-v3.js +0 -19
- package/build/dex/quickswap/spiritswap-v3.js.map +0 -1
- package/build/dex/smardex/config.d.ts +0 -4
- package/build/dex/smardex/config.js +0 -64
- package/build/dex/smardex/config.js.map +0 -1
- package/build/dex/smardex/constants.d.ts +0 -18
- package/build/dex/smardex/constants.js +0 -33
- package/build/dex/smardex/constants.js.map +0 -1
- package/build/dex/smardex/sdk/constants.d.ts +0 -6
- package/build/dex/smardex/sdk/constants.js +0 -13
- package/build/dex/smardex/sdk/constants.js.map +0 -1
- package/build/dex/smardex/sdk/core.d.ts +0 -113
- package/build/dex/smardex/sdk/core.js +0 -499
- package/build/dex/smardex/sdk/core.js.map +0 -1
- package/build/dex/smardex/sdk/errors.d.ts +0 -15
- package/build/dex/smardex/sdk/errors.js +0 -22
- package/build/dex/smardex/sdk/errors.js.map +0 -1
- package/build/dex/smardex/sdk/types.d.ts +0 -62
- package/build/dex/smardex/sdk/types.js +0 -3
- package/build/dex/smardex/sdk/types.js.map +0 -1
- package/build/dex/smardex/sdk/utils.d.ts +0 -44
- package/build/dex/smardex/sdk/utils.js +0 -133
- package/build/dex/smardex/sdk/utils.js.map +0 -1
- package/build/dex/smardex/smardex-event-pool.d.ts +0 -28
- package/build/dex/smardex/smardex-event-pool.js +0 -119
- package/build/dex/smardex/smardex-event-pool.js.map +0 -1
- package/build/dex/smardex/smardex.d.ts +0 -65
- package/build/dex/smardex/smardex.js +0 -519
- package/build/dex/smardex/smardex.js.map +0 -1
- package/build/dex/smardex/types.d.ts +0 -55
- package/build/dex/smardex/types.js +0 -3
- package/build/dex/smardex/types.js.map +0 -1
- package/build/dex/solidly/forks-override/cone.d.ts +0 -22
- package/build/dex/solidly/forks-override/cone.js +0 -53
- package/build/dex/solidly/forks-override/cone.js.map +0 -1
- package/build/dex/solidly/forks-override/solisnek.d.ts +0 -8
- package/build/dex/solidly/forks-override/solisnek.js +0 -15
- package/build/dex/solidly/forks-override/solisnek.js.map +0 -1
- package/build/dex/swaap-v1/config.d.ts +0 -17
- package/build/dex/swaap-v1/config.js +0 -56
- package/build/dex/swaap-v1/config.js.map +0 -1
- package/build/dex/swaap-v1/constants.d.ts +0 -6
- package/build/dex/swaap-v1/constants.js +0 -17
- package/build/dex/swaap-v1/constants.js.map +0 -1
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.d.ts +0 -25
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.js +0 -62
- package/build/dex/swaap-v1/libraries/ChainlinkUtils.js.map +0 -1
- package/build/dex/swaap-v1/libraries/Const.d.ts +0 -18
- package/build/dex/swaap-v1/libraries/Const.js +0 -26
- package/build/dex/swaap-v1/libraries/Const.js.map +0 -1
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.d.ts +0 -77
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js +0 -316
- package/build/dex/swaap-v1/libraries/GeometricBrownianMotion.js.map +0 -1
- package/build/dex/swaap-v1/libraries/LogExpMath.d.ts +0 -75
- package/build/dex/swaap-v1/libraries/LogExpMath.js +0 -418
- package/build/dex/swaap-v1/libraries/LogExpMath.js.map +0 -1
- package/build/dex/swaap-v1/libraries/MathMMM.d.ts +0 -185
- package/build/dex/swaap-v1/libraries/MathMMM.js +0 -453
- package/build/dex/swaap-v1/libraries/MathMMM.js.map +0 -1
- package/build/dex/swaap-v1/libraries/Num.d.ts +0 -31
- package/build/dex/swaap-v1/libraries/Num.js +0 -167
- package/build/dex/swaap-v1/libraries/Num.js.map +0 -1
- package/build/dex/swaap-v1/libraries/PoolQuotations.d.ts +0 -23
- package/build/dex/swaap-v1/libraries/PoolQuotations.js +0 -131
- package/build/dex/swaap-v1/libraries/PoolQuotations.js.map +0 -1
- package/build/dex/swaap-v1/libraries/Struct.d.ts +0 -56
- package/build/dex/swaap-v1/libraries/Struct.js +0 -3
- package/build/dex/swaap-v1/libraries/Struct.js.map +0 -1
- package/build/dex/swaap-v1/swaap-v1-pool.d.ts +0 -45
- package/build/dex/swaap-v1/swaap-v1-pool.js +0 -656
- package/build/dex/swaap-v1/swaap-v1-pool.js.map +0 -1
- package/build/dex/swaap-v1/swaap-v1.d.ts +0 -62
- package/build/dex/swaap-v1/swaap-v1.js +0 -379
- package/build/dex/swaap-v1/swaap-v1.js.map +0 -1
- package/build/dex/swaap-v1/types.d.ts +0 -106
- package/build/dex/swaap-v1/types.js +0 -9
- package/build/dex/swaap-v1/types.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
|
@@ -1,453 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MathMMM = void 0;
|
|
4
|
-
const Const_1 = require("./Const");
|
|
5
|
-
const Num_1 = require("./Num");
|
|
6
|
-
const LogExpMath_1 = require("./LogExpMath");
|
|
7
|
-
const GeometricBrownianMotion_1 = require("./GeometricBrownianMotion");
|
|
8
|
-
class MathMMM {
|
|
9
|
-
/**********************************************************************************************
|
|
10
|
-
// calcSpotPrice //
|
|
11
|
-
// sP = spotPrice //
|
|
12
|
-
// bI = tokenBalanceIn ( bI * w0 ) //
|
|
13
|
-
// bO = tokenBalanceOut sP = ------------------------ //
|
|
14
|
-
// wI = tokenWeightIn ( bO * wI ) * ( 1 - sF ) //
|
|
15
|
-
// wO = tokenWeightOut //
|
|
16
|
-
// sF = swapFee //
|
|
17
|
-
**********************************************************************************************/
|
|
18
|
-
static calcSpotPrice(tokenBalanceIn, tokenWeightIn, tokenBalanceOut, tokenWeightOut, swapFee) {
|
|
19
|
-
let numer = Num_1.Num.mul(tokenBalanceIn, tokenWeightOut);
|
|
20
|
-
let denom = Num_1.Num.mul(Num_1.Num.mul(tokenBalanceOut, tokenWeightIn), Const_1.Const.ONE - swapFee);
|
|
21
|
-
return Num_1.Num.div(numer, denom);
|
|
22
|
-
}
|
|
23
|
-
/**********************************************************************************************
|
|
24
|
-
// calcOutGivenIn //
|
|
25
|
-
// aO = tokenAmountOut //
|
|
26
|
-
// bO = tokenBalanceOut //
|
|
27
|
-
// bI = tokenBalanceIn / / bI \ (wI / wO) \ //
|
|
28
|
-
// aI = tokenAmountIn aO = bO * | 1 - | -------------------------- | ^ | //
|
|
29
|
-
// wI = tokenWeightIn \ \ ( bI + ( aI * ( 1 - sF )) / / //
|
|
30
|
-
// wO = tokenWeightOut //
|
|
31
|
-
// sF = swapFee //
|
|
32
|
-
**********************************************************************************************/
|
|
33
|
-
static calcOutGivenIn(tokenBalanceIn, tokenWeightIn, tokenBalanceOut, tokenWeightOut, tokenAmountIn, swapFee) {
|
|
34
|
-
const weightRatio = Num_1.Num.div(tokenWeightIn, tokenWeightOut);
|
|
35
|
-
let adjustedIn = Const_1.Const.ONE - swapFee;
|
|
36
|
-
adjustedIn = Num_1.Num.mul(tokenAmountIn, adjustedIn);
|
|
37
|
-
const y = Num_1.Num.div(tokenBalanceIn, tokenBalanceIn + adjustedIn);
|
|
38
|
-
const foo = Num_1.Num.pow(y, weightRatio);
|
|
39
|
-
const bar = Const_1.Const.ONE - foo;
|
|
40
|
-
const tokenAmountOut = Num_1.Num.mul(tokenBalanceOut, bar);
|
|
41
|
-
return tokenAmountOut;
|
|
42
|
-
}
|
|
43
|
-
/**********************************************************************************************
|
|
44
|
-
// calcInGivenOut //
|
|
45
|
-
// aI = tokenAmountIn //
|
|
46
|
-
// bO = tokenBalanceOut / / bO \ (wO / wI) \ //
|
|
47
|
-
// bI = tokenBalanceIn bI * | | ------------ | ^ - 1 | //
|
|
48
|
-
// aO = tokenAmountOut aI = \ \ ( bO - aO ) / / //
|
|
49
|
-
// wI = tokenWeightIn -------------------------------------------- //
|
|
50
|
-
// wO = tokenWeightOut ( 1 - sF ) //
|
|
51
|
-
// sF = swapFee //
|
|
52
|
-
**********************************************************************************************/
|
|
53
|
-
static calcInGivenOut(tokenBalanceIn, tokenWeightIn, tokenBalanceOut, tokenWeightOut, tokenAmountOut, swapFee) {
|
|
54
|
-
const weightRatio = Num_1.Num.div(tokenWeightOut, tokenWeightIn);
|
|
55
|
-
const diff = tokenBalanceOut - tokenAmountOut;
|
|
56
|
-
const y = Num_1.Num.div(tokenBalanceOut, diff);
|
|
57
|
-
let foo = Num_1.Num.pow(y, weightRatio);
|
|
58
|
-
foo = foo - Const_1.Const.ONE;
|
|
59
|
-
let tokenAmountIn = Const_1.Const.ONE - swapFee;
|
|
60
|
-
tokenAmountIn = Num_1.Num.div(Num_1.Num.mul(tokenBalanceIn, foo), tokenAmountIn);
|
|
61
|
-
return tokenAmountIn;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* @notice Computes the amount of tokenIn needed in order to receive a given amount of tokenOut
|
|
65
|
-
* @dev A spread is applied as soon as entering a "shortage of tokenOut" phase
|
|
66
|
-
* cf whitepaper: https://www.swaap.finance/whitepaper.pdf
|
|
67
|
-
* @param tokenGlobalIn The pool global information on tokenIn
|
|
68
|
-
* @param tokenGlobalOut The pool global information on tokenOut
|
|
69
|
-
* @param relativePrice The price of tokenOut in tokenIn terms
|
|
70
|
-
* @param swapParameters Amount of token out and swap fee
|
|
71
|
-
* @param gbmParameters The GBM forecast parameters (Z, horizon)
|
|
72
|
-
* @param hpParameters The parameters for historical prices retrieval
|
|
73
|
-
* @return swapResult The swap result (amount in, spread and tax base in)
|
|
74
|
-
*/
|
|
75
|
-
static calcInGivenOutMMM(tokenGlobalIn, tokenGlobalOut, relativePrice, swapParameters, gbmParameters, hpParameters, historicalPricesIn, historicalPricesOut, currentTimestamp) {
|
|
76
|
-
// determines the balance of tokenOut at equilibrium (cf definitions)
|
|
77
|
-
const balanceOutAtEquilibrium = MathMMM.getTokenBalanceAtEquilibrium(tokenGlobalOut.info.balance, tokenGlobalOut.info.weight, tokenGlobalIn.info.balance, tokenGlobalIn.info.weight, Num_1.Num.div(Const_1.Const.ONE, relativePrice));
|
|
78
|
-
// from abundance of tokenOut to abundance of tokenOut --> no spread
|
|
79
|
-
if (tokenGlobalOut.info.balance > balanceOutAtEquilibrium &&
|
|
80
|
-
swapParameters.amount <
|
|
81
|
-
tokenGlobalOut.info.balance - balanceOutAtEquilibrium) {
|
|
82
|
-
return {
|
|
83
|
-
amount: MathMMM._calcInGivenOutMMMAbundance(tokenGlobalIn, tokenGlobalOut,
|
|
84
|
-
// relativePrice,
|
|
85
|
-
swapParameters.amount, swapParameters.fee),
|
|
86
|
-
spread: 0n,
|
|
87
|
-
taxBaseIn: 0n,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
{
|
|
91
|
-
const gbmEstimation = GeometricBrownianMotion_1.GeometricBrownianMotion.getParametersEstimation(tokenGlobalIn.latestRound, tokenGlobalOut.latestRound, hpParameters, historicalPricesIn, historicalPricesOut);
|
|
92
|
-
const [adjustedTokenOutWeight, spread] = MathMMM.getMMMWeight(true, swapParameters.fallbackSpread, tokenGlobalOut.info.weight, gbmEstimation, gbmParameters);
|
|
93
|
-
if (tokenGlobalOut.info.balance <= balanceOutAtEquilibrium) {
|
|
94
|
-
// shortage to shortage
|
|
95
|
-
return {
|
|
96
|
-
amount: MathMMM.calcInGivenOut(tokenGlobalIn.info.balance, tokenGlobalIn.info.weight, tokenGlobalOut.info.balance, adjustedTokenOutWeight, swapParameters.amount, swapParameters.fee),
|
|
97
|
-
spread: spread,
|
|
98
|
-
taxBaseIn: swapParameters.amount,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
// abundance to shortage
|
|
103
|
-
const [amount, taxBaseIn] = MathMMM._calcInGivenOutMMMMixed(tokenGlobalIn, tokenGlobalOut, swapParameters, relativePrice, adjustedTokenOutWeight, balanceOutAtEquilibrium, currentTimestamp);
|
|
104
|
-
return {
|
|
105
|
-
amount: amount,
|
|
106
|
-
spread: spread,
|
|
107
|
-
taxBaseIn: taxBaseIn,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* @notice Implements 'calcInGivenOutMMM' in the case of abundance of tokenOut
|
|
114
|
-
* @dev Two cases to consider:
|
|
115
|
-
* 1) amount of tokenIn won't drive the pool from abundance of tokenOut to shortage ==> 1 pricing (no spread)
|
|
116
|
-
* 2) amount of tokenIn will drive the pool from abundance of tokenOut to shortage ==> 2 pricing, one for each phase
|
|
117
|
-
* @param tokenGlobalIn The pool global information on tokenIn
|
|
118
|
-
* @param tokenGlobalOut The pool global information on tokenOut
|
|
119
|
-
* @param swapParameters The parameters of the swap
|
|
120
|
-
* @param relativePrice The price of tokenOut in tokenIn terms
|
|
121
|
-
* @param adjustedTokenWeightOut The spread-augmented tokenOut's weight
|
|
122
|
-
* @return tokenAmountIn The total amount of tokenIn needed for the swap
|
|
123
|
-
* @return taxBaseIn The amount of tokenIn swapped when in shortage of tokenOut
|
|
124
|
-
*/
|
|
125
|
-
static _calcInGivenOutMMMMixed(tokenGlobalIn, tokenGlobalOut, swapParameters, relativePrice, adjustedTokenWeightOut, balanceOutAtEquilibrium, currentTimestamp) {
|
|
126
|
-
const tokenOutBuyAmountForEquilibrium = tokenGlobalOut.info.balance - balanceOutAtEquilibrium;
|
|
127
|
-
// 'abundance of tokenOut' phase --> no spread
|
|
128
|
-
const tokenAmountInPart1 = MathMMM._calcInGivenOutMMMAbundance(tokenGlobalIn, tokenGlobalOut,
|
|
129
|
-
// relativePrice,
|
|
130
|
-
tokenOutBuyAmountForEquilibrium, swapParameters.fee);
|
|
131
|
-
// 'shortage of tokenOut phase' --> apply spread
|
|
132
|
-
const tokenAmountInPart2 = MathMMM.calcInGivenOut(tokenGlobalIn.info.balance + tokenAmountInPart1, tokenGlobalIn.info.weight, tokenGlobalOut.info.balance - tokenOutBuyAmountForEquilibrium, adjustedTokenWeightOut, swapParameters.amount - tokenOutBuyAmountForEquilibrium, // tokenAmountOut > tokenOutBuyAmountForEquilibrium
|
|
133
|
-
swapParameters.fee);
|
|
134
|
-
return [
|
|
135
|
-
Num_1.Num.add(tokenAmountInPart1, tokenAmountInPart2),
|
|
136
|
-
tokenAmountInPart2,
|
|
137
|
-
];
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* @notice Implements calcOutGivenInMMM in the case of abundance of tokenOut
|
|
141
|
-
* @dev A spread is applied as soon as entering a "shortage of tokenOut" phase
|
|
142
|
-
* cf whitepaper: https://www.swaap.finance/whitepaper.pdf
|
|
143
|
-
* @param tokenGlobalIn The pool global information on tokenIn
|
|
144
|
-
* @param tokenGlobalOut The pool global information on tokenOut
|
|
145
|
-
* @param relativePrice The price of tokenOut in tokenIn terms
|
|
146
|
-
* @param tokenAmountOut The amount of tokenOut that will be received
|
|
147
|
-
* @param baseFee The base fee
|
|
148
|
-
* @param fallbackSpread The default spread in case the it couldn't be calculated using oracle prices
|
|
149
|
-
* @return tokenAmountIn The amount of tokenIn needed for the swap
|
|
150
|
-
*/
|
|
151
|
-
static _calcInGivenOutMMMAbundance(tokenGlobalIn, tokenGlobalOut,
|
|
152
|
-
// relativePrice: bigint,
|
|
153
|
-
tokenAmountOut, baseFee) {
|
|
154
|
-
const adaptiveFees = baseFee; /*MathMMM.getAdaptiveFees(
|
|
155
|
-
tokenGlobalIn,
|
|
156
|
-
Num.mul(tokenAmountOut, relativePrice),
|
|
157
|
-
tokenGlobalOut,
|
|
158
|
-
tokenAmountOut,
|
|
159
|
-
relativePrice,
|
|
160
|
-
baseFee,
|
|
161
|
-
fallbackSpread,
|
|
162
|
-
currentTimestamp,
|
|
163
|
-
);*/
|
|
164
|
-
return MathMMM.calcInGivenOut(tokenGlobalIn.info.balance, tokenGlobalIn.info.weight, tokenGlobalOut.info.balance, tokenGlobalOut.info.weight, tokenAmountOut, adaptiveFees);
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* @notice Computes the net value of a given tokenIn amount in tokenOut terms
|
|
168
|
-
* @dev A spread is applied as soon as entering a "shortage of tokenOut" phase
|
|
169
|
-
* cf whitepaper: https://www.swaap.finance/whitepaper.pdf
|
|
170
|
-
* @param tokenGlobalIn The pool global information on tokenIn
|
|
171
|
-
* @param tokenGlobalOut The pool global information on tokenOut
|
|
172
|
-
* @param relativePrice The price of tokenOut in tokenIn terms
|
|
173
|
-
* @param swapParameters Amount of token in and swap fee
|
|
174
|
-
* @param gbmParameters The GBM forecast parameters (Z, horizon)
|
|
175
|
-
* @param hpParameters The parameters for historical prices retrieval
|
|
176
|
-
* @return swapResult The swap result (amount out, spread and tax base in)
|
|
177
|
-
*/
|
|
178
|
-
static calcOutGivenInMMM(tokenGlobalIn, tokenGlobalOut, relativePrice, swapParameters, gbmParameters, hpParameters, historicalPricesIn, historicalPricesOut, currentTimestamp) {
|
|
179
|
-
// determines the balance of tokenIn at equilibrium (cf definitions)
|
|
180
|
-
const balanceInAtEquilibrium = MathMMM.getTokenBalanceAtEquilibrium(tokenGlobalIn.info.balance, tokenGlobalIn.info.weight, tokenGlobalOut.info.balance, tokenGlobalOut.info.weight, relativePrice);
|
|
181
|
-
// from abundance of tokenOut to abundance of tokenOut --> no spread
|
|
182
|
-
{
|
|
183
|
-
if (tokenGlobalIn.info.balance < balanceInAtEquilibrium &&
|
|
184
|
-
swapParameters.amount <
|
|
185
|
-
balanceInAtEquilibrium - tokenGlobalIn.info.balance) {
|
|
186
|
-
return {
|
|
187
|
-
amount: MathMMM._calcOutGivenInMMMAbundance(tokenGlobalIn, tokenGlobalOut, relativePrice, swapParameters.amount, swapParameters.fee, swapParameters.fallbackSpread, currentTimestamp),
|
|
188
|
-
spread: 0n,
|
|
189
|
-
taxBaseIn: 0n,
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
{
|
|
194
|
-
const gbmEstimation = GeometricBrownianMotion_1.GeometricBrownianMotion.getParametersEstimation(tokenGlobalIn.latestRound, tokenGlobalOut.latestRound, hpParameters, historicalPricesIn, historicalPricesOut);
|
|
195
|
-
const [adjustedTokenOutWeight, spread] = MathMMM.getMMMWeight(true, swapParameters.fallbackSpread, tokenGlobalOut.info.weight, gbmEstimation, gbmParameters);
|
|
196
|
-
if (tokenGlobalIn.info.balance >= balanceInAtEquilibrium) {
|
|
197
|
-
// shortage to shortage
|
|
198
|
-
return {
|
|
199
|
-
amount: MathMMM.calcOutGivenIn(tokenGlobalIn.info.balance, tokenGlobalIn.info.weight, tokenGlobalOut.info.balance, adjustedTokenOutWeight, swapParameters.amount, swapParameters.fee),
|
|
200
|
-
spread: spread,
|
|
201
|
-
taxBaseIn: swapParameters.amount,
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
// abundance to shortage
|
|
206
|
-
const [amount, taxBaseIn] = MathMMM._calcOutGivenInMMMMixed(tokenGlobalIn, tokenGlobalOut, swapParameters, relativePrice, adjustedTokenOutWeight, balanceInAtEquilibrium, currentTimestamp);
|
|
207
|
-
return {
|
|
208
|
-
amount: amount,
|
|
209
|
-
spread: spread,
|
|
210
|
-
taxBaseIn: taxBaseIn,
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* @notice Implements 'calcOutGivenInMMM' in the case of mixed regime of tokenOut (abundance then shortage)
|
|
217
|
-
* @param tokenGlobalIn The pool global information on tokenIn
|
|
218
|
-
* @param tokenGlobalOut The pool global information on tokenOut
|
|
219
|
-
* @param swapParameters The parameters of the swap
|
|
220
|
-
* @param relativePrice The price of tokenOut in tokenIn terms
|
|
221
|
-
* @param adjustedTokenWeightOut The spread-augmented tokenOut's weight
|
|
222
|
-
* @param balanceInAtEquilibrium TokenIn balance at equilibrium
|
|
223
|
-
* @return tokenAmountOut The total amount of token out
|
|
224
|
-
* @return taxBaseIn The amount of tokenIn swapped when in shortage of tokenOut
|
|
225
|
-
*/
|
|
226
|
-
static _calcOutGivenInMMMMixed(tokenGlobalIn, tokenGlobalOut, swapParameters, relativePrice, adjustedTokenWeightOut, balanceInAtEquilibrium, currentTimestamp) {
|
|
227
|
-
const tokenInSellAmountForEquilibrium = balanceInAtEquilibrium - tokenGlobalIn.info.balance;
|
|
228
|
-
const taxBaseIn = swapParameters.amount - tokenInSellAmountForEquilibrium;
|
|
229
|
-
// 'abundance of tokenOut' phase --> no spread
|
|
230
|
-
const tokenAmountOutPart1 = MathMMM._calcOutGivenInMMMAbundance(tokenGlobalIn, tokenGlobalOut, relativePrice, tokenInSellAmountForEquilibrium, swapParameters.fee, swapParameters.fallbackSpread, currentTimestamp);
|
|
231
|
-
// 'shortage of tokenOut phase' --> apply spread
|
|
232
|
-
const tokenAmountOutPart2 = MathMMM.calcOutGivenIn(Num_1.Num.add(tokenGlobalIn.info.balance, tokenInSellAmountForEquilibrium), tokenGlobalIn.info.weight, Num_1.Num.sub(tokenGlobalOut.info.balance, tokenAmountOutPart1), adjustedTokenWeightOut, taxBaseIn, // tokenAmountIn > tokenInSellAmountForEquilibrium
|
|
233
|
-
swapParameters.fee);
|
|
234
|
-
return [Num_1.Num.add(tokenAmountOutPart1, tokenAmountOutPart2), taxBaseIn];
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* @notice Implements calcOutGivenInMMM in the case of abundance of tokenOut
|
|
238
|
-
* @dev A spread is applied as soon as entering a "shortage of tokenOut" phase
|
|
239
|
-
* cf whitepaper: https://www.swaap.finance/whitepaper.pdf
|
|
240
|
-
* @param tokenGlobalIn The pool global information on tokenIn
|
|
241
|
-
* @param tokenGlobalOut The pool global information on tokenOut
|
|
242
|
-
* @param relativePrice The price of tokenOut in tokenIn terms
|
|
243
|
-
* @param tokenAmountIn The amount of tokenIn that will be swaped
|
|
244
|
-
* @param baseFee The base fee
|
|
245
|
-
* @param fallbackSpread The default spread in case the it couldn't be calculated using oracle prices
|
|
246
|
-
* @return tokenAmountOut The tokenAmountOut when the tokenOut is in abundance
|
|
247
|
-
*/
|
|
248
|
-
static _calcOutGivenInMMMAbundance(tokenGlobalIn, tokenGlobalOut, relativePrice, tokenAmountIn, baseFee, fallbackSpread, currentTimestamp) {
|
|
249
|
-
const adaptiveFees = baseFee; /*MathMMM.getAdaptiveFees(
|
|
250
|
-
tokenGlobalIn,
|
|
251
|
-
tokenAmountIn,
|
|
252
|
-
tokenGlobalOut,
|
|
253
|
-
Num.div(tokenAmountIn, relativePrice),
|
|
254
|
-
relativePrice,
|
|
255
|
-
baseFee,
|
|
256
|
-
fallbackSpread,
|
|
257
|
-
currentTimestamp,
|
|
258
|
-
);*/
|
|
259
|
-
return MathMMM.calcOutGivenIn(tokenGlobalIn.info.balance, tokenGlobalIn.info.weight, tokenGlobalOut.info.balance, tokenGlobalOut.info.weight, tokenAmountIn, adaptiveFees);
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* @notice Computes the log spread factor
|
|
263
|
-
* @dev We define it as the log of the p-quantile of a GBM process (log-normal distribution),
|
|
264
|
-
* which is given by the following:
|
|
265
|
-
* mean * horizon + z * sqrt(2 * variance * horizon)
|
|
266
|
-
* where z = ierf(2p - 1), with ierf being the inverse error function.
|
|
267
|
-
* GBM: https://en.wikipedia.org/wiki/Geometric_Brownian_motion
|
|
268
|
-
* Log-normal distribution: https://en.wikipedia.org/wiki/Log-normal_distribution
|
|
269
|
-
* erf: https://en.wikipedia.org/wiki/Error_function
|
|
270
|
-
* @param mean The percentage drift
|
|
271
|
-
* @param variance The percentage volatility
|
|
272
|
-
* @param horizon The GBM forecast horizon parameter
|
|
273
|
-
* @param z The GBM forecast z parameter
|
|
274
|
-
* @return x The log spread factor
|
|
275
|
-
*/
|
|
276
|
-
static getLogSpreadFactor(mean, variance, horizon, z) {
|
|
277
|
-
if (mean == 0n && variance == 0n) {
|
|
278
|
-
return 0n;
|
|
279
|
-
}
|
|
280
|
-
if (mean < 0) {
|
|
281
|
-
mean = -Num_1.Num.mul(-mean, horizon);
|
|
282
|
-
}
|
|
283
|
-
else {
|
|
284
|
-
mean = Num_1.Num.mul(mean, horizon);
|
|
285
|
-
}
|
|
286
|
-
let diffusion = 0n;
|
|
287
|
-
if (variance > 0) {
|
|
288
|
-
diffusion = Num_1.Num.mul(z, LogExpMath_1.LogExpMath.pow(Num_1.Num.mul(variance, 2n * horizon), Const_1.Const.ONE / 2n));
|
|
289
|
-
}
|
|
290
|
-
return diffusion + mean;
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* @notice Apply to the tokenWeight a 'spread' factor
|
|
294
|
-
* @dev The spread factor is defined as the maximum between:
|
|
295
|
-
a) the expected relative tokenOut increase in tokenIn terms
|
|
296
|
-
b) 1
|
|
297
|
-
* The function multiplies the tokenWeight by the spread factor if
|
|
298
|
-
* the token is in shortage, or divides it by the spread factor if it is in abundance
|
|
299
|
-
* @param shortage true when the token is in shortage, false if in abundance
|
|
300
|
-
* @param fallbackSpread The default spread in case the it couldn't be calculated using oracle prices
|
|
301
|
-
* @param tokenWeight The token's weight
|
|
302
|
-
* @param gbmEstimation The GBM's 2 first moments estimation
|
|
303
|
-
* @param gbmParameters The GBM forecast parameters (Z, horizon)
|
|
304
|
-
* @return adjustedWeight The adjusted weight based on spread
|
|
305
|
-
* @return spread The spread
|
|
306
|
-
*/
|
|
307
|
-
static getMMMWeight(shortage, fallbackSpread, tokenWeight, gbmEstimation, gbmParameters) {
|
|
308
|
-
if (!gbmEstimation.success) {
|
|
309
|
-
if (shortage) {
|
|
310
|
-
return [
|
|
311
|
-
Num_1.Num.mul(tokenWeight, Const_1.Const.ONE + fallbackSpread),
|
|
312
|
-
fallbackSpread,
|
|
313
|
-
];
|
|
314
|
-
}
|
|
315
|
-
else {
|
|
316
|
-
return [
|
|
317
|
-
Num_1.Num.div(tokenWeight, Const_1.Const.ONE + fallbackSpread),
|
|
318
|
-
fallbackSpread,
|
|
319
|
-
];
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
if (gbmParameters.horizon == 0n) {
|
|
323
|
-
return [tokenWeight, 0n];
|
|
324
|
-
}
|
|
325
|
-
const logSpreadFactor = MathMMM.getLogSpreadFactor(gbmEstimation.mean, gbmEstimation.variance, gbmParameters.horizon, gbmParameters.z);
|
|
326
|
-
if (logSpreadFactor <= 0) {
|
|
327
|
-
return [tokenWeight, 0n];
|
|
328
|
-
}
|
|
329
|
-
const spreadFactor = LogExpMath_1.LogExpMath.exp(logSpreadFactor);
|
|
330
|
-
// if spread < 1 --> rounding error --> set to 1
|
|
331
|
-
if (spreadFactor <= Const_1.Const.ONE) {
|
|
332
|
-
return [tokenWeight, 0n];
|
|
333
|
-
}
|
|
334
|
-
let spread = spreadFactor - Const_1.Const.ONE;
|
|
335
|
-
if (shortage) {
|
|
336
|
-
return [Num_1.Num.mul(tokenWeight, spreadFactor), spread];
|
|
337
|
-
}
|
|
338
|
-
else {
|
|
339
|
-
return [Num_1.Num.div(tokenWeight, spreadFactor), spread];
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
/**
|
|
343
|
-
* @notice Computes the fee amount that will ensure we maintain the pool's value, according to oracle prices.
|
|
344
|
-
* @dev We apply this fee regime only if Out-In price increased in the same block as now.
|
|
345
|
-
* @param tokenGlobalIn The pool global information on tokenIn
|
|
346
|
-
* @param tokenAmountIn The swap desired amount for tokenIn
|
|
347
|
-
* @param tokenGlobalOut The pool global information on tokenOut
|
|
348
|
-
* @param tokenAmountOut The swap desired amount for tokenOut
|
|
349
|
-
* @param relativePrice The price of tokenOut in tokenIn terms
|
|
350
|
-
* @param baseFee The base fee amount
|
|
351
|
-
* @param fallbackSpread The default spread in case the it couldn't be calculated using oracle prices
|
|
352
|
-
* @return alpha The potentially augmented fee amount
|
|
353
|
-
*/
|
|
354
|
-
/* static getAdaptiveFees(
|
|
355
|
-
tokenGlobalIn: Struct.TokenGlobal,
|
|
356
|
-
tokenAmountIn: bigint,
|
|
357
|
-
tokenGlobalOut: Struct.TokenGlobal,
|
|
358
|
-
tokenAmountOut: bigint,
|
|
359
|
-
relativePrice: bigint,
|
|
360
|
-
baseFee: bigint,
|
|
361
|
-
fallbackSpread: bigint,
|
|
362
|
-
currentTimestamp: bigint,
|
|
363
|
-
): bigint {
|
|
364
|
-
let blockTimestamp = currentTimestamp;
|
|
365
|
-
|
|
366
|
-
// we only consider same block as last price update
|
|
367
|
-
if (
|
|
368
|
-
blockTimestamp != tokenGlobalIn.latestRound.timestamp &&
|
|
369
|
-
blockTimestamp != tokenGlobalOut.latestRound.timestamp
|
|
370
|
-
) {
|
|
371
|
-
// no additional fees
|
|
372
|
-
return baseFee;
|
|
373
|
-
}
|
|
374
|
-
let recentPriceUpperBound = ChainlinkUtils.getMaxRelativePriceInLastBlock(
|
|
375
|
-
tokenGlobalIn.latestRound,
|
|
376
|
-
tokenGlobalIn.info.decimals,
|
|
377
|
-
tokenGlobalOut.latestRound,
|
|
378
|
-
tokenGlobalOut.info.decimals,
|
|
379
|
-
// historicalPricesIn,
|
|
380
|
-
// historicalPricesOut
|
|
381
|
-
);
|
|
382
|
-
if (recentPriceUpperBound == 0n) {
|
|
383
|
-
// we were not able to retrieve the previous price
|
|
384
|
-
return fallbackSpread;
|
|
385
|
-
} else if (recentPriceUpperBound <= relativePrice) {
|
|
386
|
-
// no additional fees
|
|
387
|
-
return baseFee;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
return (
|
|
391
|
-
// additional fees indexed on price increase and imbalance
|
|
392
|
-
Num.min(
|
|
393
|
-
Const.ONE,
|
|
394
|
-
baseFee +
|
|
395
|
-
MathMMM.calcAdaptiveFeeGivenInAndOut(
|
|
396
|
-
tokenGlobalIn.info.balance,
|
|
397
|
-
tokenAmountIn,
|
|
398
|
-
tokenGlobalIn.info.weight,
|
|
399
|
-
tokenGlobalOut.info.balance,
|
|
400
|
-
tokenAmountOut,
|
|
401
|
-
tokenGlobalOut.info.weight,
|
|
402
|
-
),
|
|
403
|
-
)
|
|
404
|
-
);
|
|
405
|
-
}
|
|
406
|
-
*/
|
|
407
|
-
/**
|
|
408
|
-
* @notice Computes the balance of token1 the pool must have in order to have token1/token2 at equilibrium
|
|
409
|
-
* while satisfying the pricing curve prod^k balance_k^w_k = K
|
|
410
|
-
* @dev We only rely on the following equations:
|
|
411
|
-
* a) priceTokenOutOutInTokenIn = balance_in / balance_out * w_out / w_in
|
|
412
|
-
* b) tokenBalanceOut = (K / prod_k!=in balance_k^w_k)^(1/w_out) = (localInvariant / balance_in^w_in)^(1/w_out)
|
|
413
|
-
* with localInvariant = balance_in^w_in * balance_out^w_out which can be computed with only In/Out
|
|
414
|
-
* @param tokenBalance1 The balance of token1 initially
|
|
415
|
-
* @param tokenWeight1 The weight of token1
|
|
416
|
-
* @param tokenBalance2 The balance of token2 initially
|
|
417
|
-
* @param tokenWeight2 The weight of token2
|
|
418
|
-
* @param relativePrice The price of tokenOut in tokenIn terms
|
|
419
|
-
* @return balance1AtEquilibrium The balance of token1 in order to have a token1/token2 at equilibrium
|
|
420
|
-
*/
|
|
421
|
-
static getTokenBalanceAtEquilibrium(tokenBalance1, tokenWeight1, tokenBalance2, tokenWeight2, relativePrice) {
|
|
422
|
-
const weightSum = tokenWeight1 + tokenWeight2;
|
|
423
|
-
// relativePrice * weight1/weight2
|
|
424
|
-
let foo = Num_1.Num.mul(relativePrice, Num_1.Num.div(tokenWeight1, tokenWeight2));
|
|
425
|
-
// relativePrice * balance2 * (weight1/weight2)
|
|
426
|
-
foo = Num_1.Num.mul(foo, tokenBalance2);
|
|
427
|
-
const balance1AtEquilibrium = Num_1.Num.mul(LogExpMath_1.LogExpMath.pow(foo, Num_1.Num.div(tokenWeight2, weightSum)), LogExpMath_1.LogExpMath.pow(tokenBalance1, Num_1.Num.div(tokenWeight1, weightSum)));
|
|
428
|
-
return balance1AtEquilibrium;
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* @notice Computes the fee needed to maintain the pool's value constant
|
|
432
|
-
* @dev We use oracle to evaluate pool's value
|
|
433
|
-
* @param tokenBalanceIn The balance of tokenIn initially
|
|
434
|
-
* @param tokenAmountIn The amount of tokenIn to be added
|
|
435
|
-
* @param tokenWeightIn The weight of tokenIn
|
|
436
|
-
* @param tokenBalanceOut The balance of tokenOut initially
|
|
437
|
-
* @param tokenAmountOut The amount of tokenOut to be removed from the pool
|
|
438
|
-
* @param tokenWeightOut The weight of tokenOut
|
|
439
|
-
* @return adaptiveFee The computed adaptive fee to be added to the base fees
|
|
440
|
-
*/
|
|
441
|
-
static calcAdaptiveFeeGivenInAndOut(tokenBalanceIn, tokenAmountIn, tokenWeightIn, tokenBalanceOut, tokenAmountOut, tokenWeightOut) {
|
|
442
|
-
const weightRatio = Num_1.Num.div(tokenWeightOut, tokenWeightIn);
|
|
443
|
-
const y = Num_1.Num.div(tokenBalanceOut, tokenBalanceOut - tokenAmountOut);
|
|
444
|
-
const foo = Num_1.Num.mul(tokenBalanceIn, Num_1.Num.pow(y, weightRatio));
|
|
445
|
-
const afterSwapTokenInBalance = tokenBalanceIn + tokenAmountIn;
|
|
446
|
-
if (foo > afterSwapTokenInBalance) {
|
|
447
|
-
return 0n;
|
|
448
|
-
}
|
|
449
|
-
return Num_1.Num.div(afterSwapTokenInBalance - foo, tokenAmountIn);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
exports.MathMMM = MathMMM;
|
|
453
|
-
//# sourceMappingURL=MathMMM.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MathMMM.js","sourceRoot":"","sources":["../../../../src/dex/swaap-v1/libraries/MathMMM.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAChC,+BAA4B;AAC5B,6CAA0C;AAE1C,uEAAoE;AAGpE,MAAa,OAAO;IAClB;;;;;;;;qGAQiG;IACjG,MAAM,CAAC,aAAa,CAClB,cAAsB,EACtB,aAAqB,EACrB,eAAuB,EACvB,cAAsB,EACtB,OAAe;QAEf,IAAI,KAAK,GAAG,SAAG,CAAC,GAAG,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;QACpD,IAAI,KAAK,GAAG,SAAG,CAAC,GAAG,CACjB,SAAG,CAAC,GAAG,CAAC,eAAe,EAAE,aAAa,CAAC,EACvC,aAAK,CAAC,GAAG,GAAG,OAAO,CACpB,CAAC;QACF,OAAO,SAAG,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED;;;;;;;;;qGASiG;IACjG,MAAM,CAAC,cAAc,CACnB,c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YAAY,EAAE,YAAY,CAAC,CAAC,CAAC;QACtE,+CAA+C;QAC/C,GAAG,GAAG,SAAG,CAAC,GAAG,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;QAElC,MAAM,qBAAqB,GAAG,SAAG,CAAC,GAAG,CACnC,uBAAU,CAAC,GAAG,CAAC,GAAG,EAAE,SAAG,CAAC,GAAG,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,EACrD,uBAAU,CAAC,GAAG,CAAC,aAAa,EAAE,SAAG,CAAC,GAAG,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAChE,CAAC;QAEF,OAAO,qBAAqB,CAAC;IAC/B,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,4BAA4B,CACjC,cAAsB,EACtB,aAAqB,EACrB,aAAqB,EACrB,eAAuB,EACvB,cAAsB,EACtB,cAAsB;QAEtB,MAAM,WAAW,GAAG,SAAG,CAAC,GAAG,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC;QAC3D,MAAM,CAAC,GAAG,SAAG,CAAC,GAAG,CAAC,eAAe,EAAE,eAAe,GAAG,cAAc,CAAC,CAAC;QACrE,MAAM,GAAG,GAAG,SAAG,CAAC,GAAG,CAAC,cAAc,EAAE,SAAG,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;QAE7D,MAAM,uBAAuB,GAAG,cAAc,GAAG,aAAa,CAAC;QAE/D,IAAI,GAAG,GAAG,uBAAuB,EAAE;YACjC,OAAO,EAAE,CAAC;SACX;QACD,OAAO,SAAG,CAAC,GAAG,CAAC,uBAAuB,GAAG,GAAG,EAAE,aAAa,CAAC,CAAC;IAC/D,CAAC;CACF;AArsBD,0BAqsBC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export declare class Num {
|
|
2
|
-
/**
|
|
3
|
-
* @dev Returns the addition of two signed integers, reverting on overflow.
|
|
4
|
-
*/
|
|
5
|
-
static add(a: bigint, b: bigint): bigint;
|
|
6
|
-
/**
|
|
7
|
-
* @dev Returns the subtraction of two unsigned integers of 256 bits, reverting on overflow.
|
|
8
|
-
*/
|
|
9
|
-
static sub(a: bigint, b: bigint): bigint;
|
|
10
|
-
static toi(a: bigint): bigint;
|
|
11
|
-
static floor(a: bigint): bigint;
|
|
12
|
-
static subSign(a: bigint, b: bigint): [bigint, boolean];
|
|
13
|
-
static mul(a: bigint, b: bigint): bigint;
|
|
14
|
-
static mulTruncated(a: bigint, b: bigint): bigint;
|
|
15
|
-
static div(a: bigint, b: bigint): bigint;
|
|
16
|
-
static divTruncated(a: bigint, b: bigint): bigint;
|
|
17
|
-
static powi(a: bigint, n: bigint): bigint;
|
|
18
|
-
static pow(base: bigint, exp: bigint): bigint;
|
|
19
|
-
static powApprox(base: bigint, exp: bigint, precision: bigint): bigint;
|
|
20
|
-
/**
|
|
21
|
-
* @notice Computes the division of 2 int256 with ONE precision
|
|
22
|
-
* @dev Converts inputs to uint256 if needed, and then uses div(uint256, uint256)
|
|
23
|
-
* @param a The int256 representation of a floating point number with ONE precision
|
|
24
|
-
* @param b The int256 representation of a floating point number with ONE precision
|
|
25
|
-
* @return b The division of 2 int256 with ONE precision
|
|
26
|
-
*/
|
|
27
|
-
static divInt256(a: bigint, b: bigint): bigint;
|
|
28
|
-
static positivePart(value: bigint): bigint;
|
|
29
|
-
static max(a: bigint, b: bigint): bigint;
|
|
30
|
-
static min(a: bigint, b: bigint): bigint;
|
|
31
|
-
}
|