@paraswap/dex-lib 4.8.23 → 4.8.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/abi/pancakeswap-infinity/cl-pool-manager.abi.json +136 -0
- package/build/abi/pancakeswap-infinity/cl-quoter.abi.json +66 -0
- package/build/abi/pancakeswap-infinity/router.abi.json +23 -0
- package/build/dex/dexalot/config.js +4 -4
- package/build/dex/native/constants.d.ts +1 -0
- package/build/dex/native/constants.js +2 -1
- package/build/dex/native/constants.js.map +1 -1
- package/build/dex/native/rate-fetcher.d.ts +1 -0
- package/build/dex/native/rate-fetcher.js +40 -0
- package/build/dex/native/rate-fetcher.js.map +1 -1
- package/build/dex/native/types.d.ts +1 -0
- package/build/dex/native/validators.js +1 -0
- package/build/dex/native/validators.js.map +1 -1
- package/build/dex/pancakeswap-infinity/config.d.ts +4 -0
- package/build/dex/pancakeswap-infinity/config.js +30 -0
- package/build/dex/pancakeswap-infinity/config.js.map +1 -0
- package/build/dex/pancakeswap-infinity/constants.d.ts +11 -0
- package/build/dex/pancakeswap-infinity/constants.js +15 -0
- package/build/dex/pancakeswap-infinity/constants.js.map +1 -0
- package/build/dex/pancakeswap-infinity/encoder.d.ts +16 -0
- package/build/dex/{bunni-v2 → pancakeswap-infinity}/encoder.js +88 -199
- package/build/dex/pancakeswap-infinity/encoder.js.map +1 -0
- package/build/dex/pancakeswap-infinity/liquidity.d.ts +1 -0
- package/build/dex/pancakeswap-infinity/liquidity.js +7 -0
- package/build/dex/pancakeswap-infinity/liquidity.js.map +1 -0
- package/build/dex/pancakeswap-infinity/optimizer.d.ts +2 -0
- package/build/dex/pancakeswap-infinity/optimizer.js +48 -0
- package/build/dex/pancakeswap-infinity/optimizer.js.map +1 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity-pool-manager.d.ts +36 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity-pool-manager.js +393 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity-pool-manager.js.map +1 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity-pool.d.ts +37 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity-pool.js +289 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity-pool.js.map +1 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity.d.ts +42 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity.js +350 -0
- package/build/dex/pancakeswap-infinity/pancakeswap-infinity.js.map +1 -0
- package/build/dex/pancakeswap-infinity/subgraph.d.ts +8 -0
- package/build/dex/pancakeswap-infinity/subgraph.js +122 -0
- package/build/dex/pancakeswap-infinity/subgraph.js.map +1 -0
- package/build/dex/pancakeswap-infinity/types.d.ts +101 -0
- package/build/dex/pancakeswap-infinity/types.js.map +1 -0
- package/build/dex/pancakeswap-infinity/utils.d.ts +5 -0
- package/build/dex/pancakeswap-infinity/utils.js +45 -0
- package/build/dex/pancakeswap-infinity/utils.js.map +1 -0
- package/build/dex/renegade/api/auth.d.ts +1 -0
- package/build/dex/renegade/api/auth.js +63 -0
- package/build/dex/renegade/api/auth.js.map +1 -0
- package/build/dex/renegade/api/renegade-client.d.ts +18 -0
- package/build/dex/renegade/api/renegade-client.js +82 -0
- package/build/dex/renegade/api/renegade-client.js.map +1 -0
- package/build/dex/renegade/api/types.d.ts +110 -0
- package/build/dex/{maker-psm → renegade/api}/types.js.map +1 -1
- package/build/dex/{se-vlr → renegade}/config.d.ts +1 -1
- package/build/dex/renegade/config.js +16 -0
- package/build/dex/renegade/config.js.map +1 -0
- package/build/dex/renegade/constants.d.ts +25 -0
- package/build/dex/renegade/constants.js +47 -0
- package/build/dex/renegade/constants.js.map +1 -0
- package/build/dex/renegade/rate-fetcher.d.ts +23 -0
- package/build/dex/renegade/rate-fetcher.js +135 -0
- package/build/dex/renegade/rate-fetcher.js.map +1 -0
- package/build/dex/renegade/renegade-levels-response.d.ts +22 -0
- package/build/dex/renegade/renegade-levels-response.js +99 -0
- package/build/dex/renegade/renegade-levels-response.js.map +1 -0
- package/build/dex/renegade/renegade.d.ts +57 -0
- package/build/dex/renegade/renegade.js +499 -0
- package/build/dex/renegade/renegade.js.map +1 -0
- package/build/dex/renegade/types.d.ts +38 -0
- package/build/dex/renegade/types.js +4 -0
- package/build/dex/renegade/types.js.map +1 -0
- package/package.json +1 -1
- package/build/abi/AaveV2_lending_pool.json +0 -53
- package/build/abi/BProtocol.json +0 -1155
- package/build/abi/Bancor.json +0 -392
- package/build/abi/Compound_CETH.json +0 -12
- package/build/abi/Jarvis.json +0 -1172
- package/build/abi/MStableAsset.json +0 -1545
- package/build/abi/OneInchLp.json +0 -1304
- package/build/abi/Onebit.json +0 -736
- package/build/abi/SSPM.json +0 -829
- package/build/abi/Shell.json +0 -1294
- package/build/abi/Smoothy.json +0 -1049
- package/build/abi/StaderOracle.json +0 -2170
- package/build/abi/TraderJoeV2Router.json +0 -50
- package/build/abi/aave-weth-gateway-avalanche.json +0 -242
- package/build/abi/aave-weth-gateway-polygon.json +0 -242
- package/build/abi/aave-weth-gateway.json +0 -24
- package/build/abi/bunni-v2/BunniHook.abi.json +0 -1921
- package/build/abi/bunni-v2/BunniHub.abi.json +0 -1598
- package/build/abi/bunni-v2/BunniToken.abi.json +0 -833
- package/build/abi/bunni-v2/FeeOverrideHooklet.abi.json +0 -1947
- package/build/abi/bunni-v2/FloodPlain.abi.json +0 -1195
- package/build/abi/bunni-v2/PoolManager.abi.json +0 -1366
- package/build/abi/bunni-v2/V4Quoter.abi.json +0 -637
- package/build/abi/concentrator/arUSD.json +0 -568
- package/build/abi/concentrator/arUSD5115.json +0 -1746
- package/build/abi/gmx/fast-price-events.json +0 -70
- package/build/abi/gmx/fast-price-feed.json +0 -748
- package/build/abi/gmx/reader.json +0 -337
- package/build/abi/gmx/vault-price-feed.json +0 -477
- package/build/abi/gmx/vault.json +0 -2002
- package/build/abi/idle-dao/idle-cdo-factory.json +0 -38
- package/build/abi/idle-dao/idle-cdo.json +0 -1245
- package/build/abi/infusion/InfusionFactory.json +0 -147
- package/build/abi/infusion/InfusionPair.json +0 -658
- package/build/abi/infusion/InfusionRouter.json +0 -442
- package/build/abi/jarvis/ChainlinkAccessControlledOffchainAggregator.json +0 -1009
- package/build/abi/jarvis/SynthereumPriceFeed.json +0 -381
- package/build/abi/jarvis/jarvis-v6-pool.json +0 -1041
- package/build/abi/kyberdmm/kyber-dmm-exchange-router.abi.json +0 -1148
- package/build/abi/kyberdmm/kyber-dmm-factory.abi.json +0 -335
- package/build/abi/kyberdmm/kyber-dmm-pool.abi.json +0 -803
- package/build/abi/maker-psm/pot.json +0 -322
- package/build/abi/maker-psm/psm.json +0 -243
- package/build/abi/maker-psm/vat.json +0 -363
- package/build/abi/nomiswap-v2/nomiswap-v2-pool.json +0 -773
- package/build/abi/quick-perps/fast-price-events.json +0 -70
- package/build/abi/quick-perps/fast-price-feed.json +0 -741
- package/build/abi/quick-perps/reader.json +0 -313
- package/build/abi/quick-perps/vault-price-feed.json +0 -323
- package/build/abi/quick-perps/vault.json +0 -1953
- package/build/abi/synthetix/CombinedSynthetix.abi.json +0 -442
- package/build/abi/uniswap-v2/excalibur-pool.json +0 -881
- package/build/abi/uniswap-v2/mdex-factory.json +0 -759
- package/build/abi/wUSDM.json +0 -757
- package/build/abi/wombat/asset.json +0 -743
- package/build/abi/wombat/bmw.json +0 -1247
- package/build/abi/wombat/pool-v2.json +0 -1289
- package/build/abi/wombat/pool-v3.json +0 -2013
- package/build/abi/zrx.v2.json +0 -1967
- package/build/abi/zrx.v3.json +0 -3454
- package/build/abi/zrx.v4.json +0 -2193
- package/build/dex/OneInchLp.d.ts +0 -24
- package/build/dex/OneInchLp.js +0 -43
- package/build/dex/OneInchLp.js.map +0 -1
- package/build/dex/aave-v2/aave-v2.d.ts +0 -33
- package/build/dex/aave-v2/aave-v2.js +0 -328
- package/build/dex/aave-v2/aave-v2.js.map +0 -1
- package/build/dex/aave-v2/config.d.ts +0 -14
- package/build/dex/aave-v2/config.js +0 -49
- package/build/dex/aave-v2/config.js.map +0 -1
- package/build/dex/aave-v2/tokenlist.json +0 -904
- package/build/dex/aave-v2/tokens.d.ts +0 -8
- package/build/dex/aave-v2/tokens.js +0 -65
- package/build/dex/aave-v2/tokens.js.map +0 -1
- package/build/dex/aave-v2/types.d.ts +0 -33
- package/build/dex/aave-v2/types.js +0 -11
- package/build/dex/aave-v2/types.js.map +0 -1
- package/build/dex/bProtocol/bProtocol.d.ts +0 -15
- package/build/dex/bProtocol/bProtocol.js +0 -56
- package/build/dex/bProtocol/bProtocol.js.map +0 -1
- package/build/dex/bProtocol/types.d.ts +0 -11
- package/build/dex/bProtocol/types.js +0 -8
- package/build/dex/bProtocol/types.js.map +0 -1
- package/build/dex/bancor/bancor.d.ts +0 -15
- package/build/dex/bancor/bancor.js +0 -74
- package/build/dex/bancor/bancor.js.map +0 -1
- package/build/dex/bancor/config.d.ts +0 -6
- package/build/dex/bancor/config.js +0 -11
- package/build/dex/bancor/config.js.map +0 -1
- package/build/dex/bancor/types.d.ts +0 -16
- package/build/dex/bancor/types.js +0 -8
- package/build/dex/bancor/types.js.map +0 -1
- package/build/dex/bunni-v2/bunni-v2-pool.d.ts +0 -62
- package/build/dex/bunni-v2/bunni-v2-pool.js +0 -505
- package/build/dex/bunni-v2/bunni-v2-pool.js.map +0 -1
- package/build/dex/bunni-v2/bunni-v2.d.ts +0 -51
- package/build/dex/bunni-v2/bunni-v2.js +0 -460
- package/build/dex/bunni-v2/bunni-v2.js.map +0 -1
- package/build/dex/bunni-v2/config.d.ts +0 -3
- package/build/dex/bunni-v2/config.js +0 -130
- package/build/dex/bunni-v2/config.js.map +0 -1
- package/build/dex/bunni-v2/encoder.d.ts +0 -19
- package/build/dex/bunni-v2/encoder.js.map +0 -1
- package/build/dex/bunni-v2/getOnChainState.d.ts +0 -26
- package/build/dex/bunni-v2/getOnChainState.js +0 -493
- package/build/dex/bunni-v2/getOnChainState.js.map +0 -1
- package/build/dex/bunni-v2/hook/BunniSwapMath.d.ts +0 -7
- package/build/dex/bunni-v2/hook/BunniSwapMath.js +0 -198
- package/build/dex/bunni-v2/hook/BunniSwapMath.js.map +0 -1
- package/build/dex/bunni-v2/hook/SwapMath.d.ts +0 -8
- package/build/dex/bunni-v2/hook/SwapMath.js +0 -65
- package/build/dex/bunni-v2/hook/SwapMath.js.map +0 -1
- package/build/dex/bunni-v2/hooklet/FeeOverrideHooklet.d.ts +0 -33
- package/build/dex/bunni-v2/hooklet/FeeOverrideHooklet.js +0 -33
- package/build/dex/bunni-v2/hooklet/FeeOverrideHooklet.js.map +0 -1
- package/build/dex/bunni-v2/hooklet/index.d.ts +0 -21
- package/build/dex/bunni-v2/hooklet/index.js +0 -64
- package/build/dex/bunni-v2/hooklet/index.js.map +0 -1
- package/build/dex/bunni-v2/ldf/CarpetedDoubleGeometricDistribution.d.ts +0 -70
- package/build/dex/bunni-v2/ldf/CarpetedDoubleGeometricDistribution.js +0 -277
- package/build/dex/bunni-v2/ldf/CarpetedDoubleGeometricDistribution.js.map +0 -1
- package/build/dex/bunni-v2/ldf/CarpetedGeometricDistribution.d.ts +0 -64
- package/build/dex/bunni-v2/ldf/CarpetedGeometricDistribution.js +0 -262
- package/build/dex/bunni-v2/ldf/CarpetedGeometricDistribution.js.map +0 -1
- package/build/dex/bunni-v2/ldf/DoubleGeometricDistribution.d.ts +0 -60
- package/build/dex/bunni-v2/ldf/DoubleGeometricDistribution.js +0 -224
- package/build/dex/bunni-v2/ldf/DoubleGeometricDistribution.js.map +0 -1
- package/build/dex/bunni-v2/ldf/GeometricDistribution.d.ts +0 -56
- package/build/dex/bunni-v2/ldf/GeometricDistribution.js +0 -489
- package/build/dex/bunni-v2/ldf/GeometricDistribution.js.map +0 -1
- package/build/dex/bunni-v2/ldf/LDFType.d.ts +0 -5
- package/build/dex/bunni-v2/ldf/LDFType.js +0 -10
- package/build/dex/bunni-v2/ldf/LDFType.js.map +0 -1
- package/build/dex/bunni-v2/ldf/ShiftMode.d.ts +0 -7
- package/build/dex/bunni-v2/ldf/ShiftMode.js +0 -19
- package/build/dex/bunni-v2/ldf/ShiftMode.js.map +0 -1
- package/build/dex/bunni-v2/ldf/UniformDistribution.d.ts +0 -55
- package/build/dex/bunni-v2/ldf/UniformDistribution.js +0 -291
- package/build/dex/bunni-v2/ldf/UniformDistribution.js.map +0 -1
- package/build/dex/bunni-v2/ldf/index.d.ts +0 -15
- package/build/dex/bunni-v2/ldf/index.js +0 -21
- package/build/dex/bunni-v2/ldf/index.js.map +0 -1
- package/build/dex/bunni-v2/lib/AmAmmPayload.d.ts +0 -4
- package/build/dex/bunni-v2/lib/AmAmmPayload.js +0 -10
- package/build/dex/bunni-v2/lib/AmAmmPayload.js.map +0 -1
- package/build/dex/bunni-v2/lib/BitMath.d.ts +0 -4
- package/build/dex/bunni-v2/lib/BitMath.js +0 -24
- package/build/dex/bunni-v2/lib/BitMath.js.map +0 -1
- package/build/dex/bunni-v2/lib/Constants.d.ts +0 -15
- package/build/dex/bunni-v2/lib/Constants.js +0 -19
- package/build/dex/bunni-v2/lib/Constants.js.map +0 -1
- package/build/dex/bunni-v2/lib/ExpMath.d.ts +0 -5
- package/build/dex/bunni-v2/lib/ExpMath.js +0 -121
- package/build/dex/bunni-v2/lib/ExpMath.js.map +0 -1
- package/build/dex/bunni-v2/lib/FeeMath.d.ts +0 -2
- package/build/dex/bunni-v2/lib/FeeMath.js +0 -27
- package/build/dex/bunni-v2/lib/FeeMath.js.map +0 -1
- package/build/dex/bunni-v2/lib/FixedPointMath.d.ts +0 -3
- package/build/dex/bunni-v2/lib/FixedPointMath.js +0 -15
- package/build/dex/bunni-v2/lib/FixedPointMath.js.map +0 -1
- package/build/dex/bunni-v2/lib/FullMathX96.d.ts +0 -4
- package/build/dex/bunni-v2/lib/FullMathX96.js +0 -21
- package/build/dex/bunni-v2/lib/FullMathX96.js.map +0 -1
- package/build/dex/bunni-v2/lib/IdleBalance.d.ts +0 -11
- package/build/dex/bunni-v2/lib/IdleBalance.js +0 -33
- package/build/dex/bunni-v2/lib/IdleBalance.js.map +0 -1
- package/build/dex/bunni-v2/lib/LiquidityAmounts.d.ts +0 -6
- package/build/dex/bunni-v2/lib/LiquidityAmounts.js +0 -25
- package/build/dex/bunni-v2/lib/LiquidityAmounts.js.map +0 -1
- package/build/dex/bunni-v2/lib/Math.d.ts +0 -28
- package/build/dex/bunni-v2/lib/Math.js +0 -169
- package/build/dex/bunni-v2/lib/Math.js.map +0 -1
- package/build/dex/bunni-v2/lib/Oracle.d.ts +0 -27
- package/build/dex/bunni-v2/lib/Oracle.js +0 -180
- package/build/dex/bunni-v2/lib/Oracle.js.map +0 -1
- package/build/dex/bunni-v2/lib/QueryLDF.d.ts +0 -12
- package/build/dex/bunni-v2/lib/QueryLDF.js +0 -90
- package/build/dex/bunni-v2/lib/QueryLDF.js.map +0 -1
- package/build/dex/bunni-v2/lib/QueryTwap.d.ts +0 -2
- package/build/dex/bunni-v2/lib/QueryTwap.js +0 -13
- package/build/dex/bunni-v2/lib/QueryTwap.js.map +0 -1
- package/build/dex/bunni-v2/lib/SqrtPriceMath.d.ts +0 -8
- package/build/dex/bunni-v2/lib/SqrtPriceMath.js +0 -84
- package/build/dex/bunni-v2/lib/SqrtPriceMath.js.map +0 -1
- package/build/dex/bunni-v2/lib/TickMath.d.ts +0 -11
- package/build/dex/bunni-v2/lib/TickMath.js +0 -100
- package/build/dex/bunni-v2/lib/TickMath.js.map +0 -1
- package/build/dex/bunni-v2/lib/VaultMath.d.ts +0 -2
- package/build/dex/bunni-v2/lib/VaultMath.js +0 -11
- package/build/dex/bunni-v2/lib/VaultMath.js.map +0 -1
- package/build/dex/bunni-v2/logic/AmAmm.d.ts +0 -11
- package/build/dex/bunni-v2/logic/AmAmm.js +0 -156
- package/build/dex/bunni-v2/logic/AmAmm.js.map +0 -1
- package/build/dex/bunni-v2/logic/BunniHookLogic.d.ts +0 -10
- package/build/dex/bunni-v2/logic/BunniHookLogic.js +0 -298
- package/build/dex/bunni-v2/logic/BunniHookLogic.js.map +0 -1
- package/build/dex/bunni-v2/logic/BunniHubLogic.d.ts +0 -5
- package/build/dex/bunni-v2/logic/BunniHubLogic.js +0 -245
- package/build/dex/bunni-v2/logic/BunniHubLogic.js.map +0 -1
- package/build/dex/bunni-v2/logic/BunniQuoter.d.ts +0 -12
- package/build/dex/bunni-v2/logic/BunniQuoter.js +0 -201
- package/build/dex/bunni-v2/logic/BunniQuoter.js.map +0 -1
- package/build/dex/bunni-v2/subgraph.d.ts +0 -7
- package/build/dex/bunni-v2/subgraph.js +0 -184
- package/build/dex/bunni-v2/subgraph.js.map +0 -1
- package/build/dex/bunni-v2/types.d.ts +0 -257
- package/build/dex/bunni-v2/types.js.map +0 -1
- package/build/dex/bunni-v2/utils.d.ts +0 -12
- package/build/dex/bunni-v2/utils.js +0 -182
- package/build/dex/bunni-v2/utils.js.map +0 -1
- package/build/dex/compound/compound.d.ts +0 -15
- package/build/dex/compound/compound.js +0 -57
- package/build/dex/compound/compound.js.map +0 -1
- package/build/dex/compound/types.d.ts +0 -8
- package/build/dex/compound/types.js +0 -9
- package/build/dex/compound/types.js.map +0 -1
- package/build/dex/concentrator-arusd/concentrator-arusd-event.d.ts +0 -17
- package/build/dex/concentrator-arusd/concentrator-arusd-event.js +0 -69
- package/build/dex/concentrator-arusd/concentrator-arusd-event.js.map +0 -1
- package/build/dex/concentrator-arusd/concentrator-arusd.d.ts +0 -41
- package/build/dex/concentrator-arusd/concentrator-arusd.js +0 -202
- package/build/dex/concentrator-arusd/concentrator-arusd.js.map +0 -1
- package/build/dex/concentrator-arusd/config.d.ts +0 -3
- package/build/dex/concentrator-arusd/config.js +0 -14
- package/build/dex/concentrator-arusd/config.js.map +0 -1
- package/build/dex/concentrator-arusd/types.d.ts +0 -14
- package/build/dex/concentrator-arusd/types.js.map +0 -1
- package/build/dex/concentrator-arusd/utils.d.ts +0 -4
- package/build/dex/concentrator-arusd/utils.js +0 -26
- package/build/dex/concentrator-arusd/utils.js.map +0 -1
- package/build/dex/curve-v1/forks/swerve/config.d.ts +0 -4
- package/build/dex/curve-v1/forks/swerve/config.js +0 -47
- package/build/dex/curve-v1/forks/swerve/config.js.map +0 -1
- package/build/dex/curve-v1/forks/swerve/swerve.d.ts +0 -16
- package/build/dex/curve-v1/forks/swerve/swerve.js +0 -46
- package/build/dex/curve-v1/forks/swerve/swerve.js.map +0 -1
- package/build/dex/ekubo/pools/base-pool.d.ts +0 -47
- package/build/dex/ekubo/pools/base-pool.js +0 -184
- package/build/dex/ekubo/pools/base-pool.js.map +0 -1
- package/build/dex/ekubo/pools/iface.d.ts +0 -46
- package/build/dex/ekubo/pools/iface.js +0 -75
- package/build/dex/ekubo/pools/iface.js.map +0 -1
- package/build/dex/ekubo/pools/math/price.d.ts +0 -7
- package/build/dex/ekubo/pools/math/price.js +0 -112
- package/build/dex/ekubo/pools/math/price.js.map +0 -1
- package/build/dex/ekubo/pools/oracle-pool.d.ts +0 -10
- package/build/dex/ekubo/pools/oracle-pool.js +0 -19
- package/build/dex/ekubo/pools/oracle-pool.js.map +0 -1
- package/build/dex/ekubo/pools/pool-utils.d.ts +0 -44
- package/build/dex/ekubo/pools/pool-utils.js +0 -240
- package/build/dex/ekubo/pools/pool-utils.js.map +0 -1
- package/build/dex/gmx/config.d.ts +0 -11
- package/build/dex/gmx/config.js +0 -61
- package/build/dex/gmx/config.js.map +0 -1
- package/build/dex/gmx/fast-price-feed.d.ts +0 -26
- package/build/dex/gmx/fast-price-feed.js +0 -184
- package/build/dex/gmx/fast-price-feed.js.map +0 -1
- package/build/dex/gmx/gmx.d.ts +0 -54
- package/build/dex/gmx/gmx.js +0 -247
- package/build/dex/gmx/gmx.js.map +0 -1
- package/build/dex/gmx/pool.d.ts +0 -21
- package/build/dex/gmx/pool.js +0 -212
- package/build/dex/gmx/pool.js.map +0 -1
- package/build/dex/gmx/types.d.ts +0 -100
- package/build/dex/gmx/types.js +0 -3
- package/build/dex/gmx/types.js.map +0 -1
- package/build/dex/gmx/usdg.d.ts +0 -15
- package/build/dex/gmx/usdg.js +0 -62
- package/build/dex/gmx/usdg.js.map +0 -1
- package/build/dex/gmx/vault-price-feed.d.ts +0 -47
- package/build/dex/gmx/vault-price-feed.js +0 -245
- package/build/dex/gmx/vault-price-feed.js.map +0 -1
- package/build/dex/gmx/vault-utils.d.ts +0 -8
- package/build/dex/gmx/vault-utils.js +0 -42
- package/build/dex/gmx/vault-utils.js.map +0 -1
- package/build/dex/gmx/vault.d.ts +0 -46
- package/build/dex/gmx/vault.js +0 -182
- package/build/dex/gmx/vault.js.map +0 -1
- package/build/dex/idle-dao/config.d.ts +0 -5
- package/build/dex/idle-dao/config.js +0 -24
- package/build/dex/idle-dao/config.js.map +0 -1
- package/build/dex/idle-dao/idle-dao.d.ts +0 -42
- package/build/dex/idle-dao/idle-dao.js +0 -279
- package/build/dex/idle-dao/idle-dao.js.map +0 -1
- package/build/dex/idle-dao/token_list.d.ts +0 -4
- package/build/dex/idle-dao/token_list.js +0 -289
- package/build/dex/idle-dao/token_list.js.map +0 -1
- package/build/dex/idle-dao/tokens.d.ts +0 -9
- package/build/dex/idle-dao/tokens.js +0 -68
- package/build/dex/idle-dao/tokens.js.map +0 -1
- package/build/dex/idle-dao/types.d.ts +0 -35
- package/build/dex/idle-dao/types.js +0 -11
- package/build/dex/idle-dao/types.js.map +0 -1
- package/build/dex/idle-dao/utils.d.ts +0 -8
- package/build/dex/idle-dao/utils.js +0 -149
- package/build/dex/idle-dao/utils.js.map +0 -1
- package/build/dex/infusion/config.d.ts +0 -3
- package/build/dex/infusion/config.js +0 -20
- package/build/dex/infusion/config.js.map +0 -1
- package/build/dex/infusion/infusion-stable-pool.d.ts +0 -4
- package/build/dex/infusion/infusion-stable-pool.js +0 -74
- package/build/dex/infusion/infusion-stable-pool.js.map +0 -1
- package/build/dex/infusion/infusion.d.ts +0 -51
- package/build/dex/infusion/infusion.js +0 -500
- package/build/dex/infusion/infusion.js.map +0 -1
- package/build/dex/infusion/types.d.ts +0 -45
- package/build/dex/infusion/types.js +0 -3
- package/build/dex/infusion/types.js.map +0 -1
- package/build/dex/infusion/utils/isStablePair.d.ts +0 -2
- package/build/dex/infusion/utils/isStablePair.js +0 -18
- package/build/dex/infusion/utils/isStablePair.js.map +0 -1
- package/build/dex/jarvis-v6/chainLinkpriceFeed-event.d.ts +0 -15
- package/build/dex/jarvis-v6/chainLinkpriceFeed-event.js +0 -51
- package/build/dex/jarvis-v6/chainLinkpriceFeed-event.js.map +0 -1
- package/build/dex/jarvis-v6/config.d.ts +0 -4
- package/build/dex/jarvis-v6/config.js +0 -244
- package/build/dex/jarvis-v6/config.js.map +0 -1
- package/build/dex/jarvis-v6/jarvis-v6-events.d.ts +0 -27
- package/build/dex/jarvis-v6/jarvis-v6-events.js +0 -54
- package/build/dex/jarvis-v6/jarvis-v6-events.js.map +0 -1
- package/build/dex/jarvis-v6/jarvis-v6.d.ts +0 -49
- package/build/dex/jarvis-v6/jarvis-v6.js +0 -321
- package/build/dex/jarvis-v6/jarvis-v6.js.map +0 -1
- package/build/dex/jarvis-v6/syntheteumPool-event.d.ts +0 -15
- package/build/dex/jarvis-v6/syntheteumPool-event.js +0 -49
- package/build/dex/jarvis-v6/syntheteumPool-event.js.map +0 -1
- package/build/dex/jarvis-v6/types.d.ts +0 -48
- package/build/dex/jarvis-v6/types.js +0 -9
- package/build/dex/jarvis-v6/types.js.map +0 -1
- package/build/dex/jarvis-v6/utils.d.ts +0 -13
- package/build/dex/jarvis-v6/utils.js +0 -75
- package/build/dex/jarvis-v6/utils.js.map +0 -1
- package/build/dex/jarvis.d.ts +0 -56
- package/build/dex/jarvis.js +0 -163
- package/build/dex/jarvis.js.map +0 -1
- package/build/dex/kyberdmm/config.d.ts +0 -9
- package/build/dex/kyberdmm/config.js +0 -59
- package/build/dex/kyberdmm/config.js.map +0 -1
- package/build/dex/kyberdmm/fee-formula.d.ts +0 -15
- package/build/dex/kyberdmm/fee-formula.js +0 -88
- package/build/dex/kyberdmm/fee-formula.js.map +0 -1
- package/build/dex/kyberdmm/kyberdmm.d.ts +0 -55
- package/build/dex/kyberdmm/kyberdmm.js +0 -447
- package/build/dex/kyberdmm/kyberdmm.js.map +0 -1
- package/build/dex/kyberdmm/math-ext.d.ts +0 -2
- package/build/dex/kyberdmm/math-ext.js +0 -27
- package/build/dex/kyberdmm/math-ext.js.map +0 -1
- package/build/dex/kyberdmm/pool.d.ts +0 -50
- package/build/dex/kyberdmm/pool.js +0 -157
- package/build/dex/kyberdmm/pool.js.map +0 -1
- package/build/dex/kyberdmm/types.d.ts +0 -81
- package/build/dex/kyberdmm/types.js +0 -9
- package/build/dex/kyberdmm/types.js.map +0 -1
- package/build/dex/mStable.d.ts +0 -44
- package/build/dex/mStable.js +0 -75
- package/build/dex/mStable.js.map +0 -1
- package/build/dex/maker-psm/config.d.ts +0 -11
- package/build/dex/maker-psm/config.js +0 -53
- package/build/dex/maker-psm/config.js.map +0 -1
- package/build/dex/maker-psm/maker-psm.d.ts +0 -103
- package/build/dex/maker-psm/maker-psm.js +0 -493
- package/build/dex/maker-psm/maker-psm.js.map +0 -1
- package/build/dex/maker-psm/types.d.ts +0 -39
- package/build/dex/maker-psm/types.js +0 -3
- package/build/dex/onebit/onebit.d.ts +0 -16
- package/build/dex/onebit/onebit.js +0 -61
- package/build/dex/onebit/onebit.js.map +0 -1
- package/build/dex/onebit/types.d.ts +0 -14
- package/build/dex/onebit/types.js +0 -8
- package/build/dex/onebit/types.js.map +0 -1
- package/build/dex/quick-perps/config.d.ts +0 -11
- package/build/dex/quick-perps/config.js +0 -27
- package/build/dex/quick-perps/config.js.map +0 -1
- package/build/dex/quick-perps/fast-price-feed.d.ts +0 -26
- package/build/dex/quick-perps/fast-price-feed.js +0 -184
- package/build/dex/quick-perps/fast-price-feed.js.map +0 -1
- package/build/dex/quick-perps/pool.d.ts +0 -21
- package/build/dex/quick-perps/pool.js +0 -229
- package/build/dex/quick-perps/pool.js.map +0 -1
- package/build/dex/quick-perps/quick-perps.d.ts +0 -53
- package/build/dex/quick-perps/quick-perps.js +0 -247
- package/build/dex/quick-perps/quick-perps.js.map +0 -1
- package/build/dex/quick-perps/types.d.ts +0 -98
- package/build/dex/quick-perps/types.js +0 -3
- package/build/dex/quick-perps/types.js.map +0 -1
- package/build/dex/quick-perps/usdq.d.ts +0 -15
- package/build/dex/quick-perps/usdq.js +0 -62
- package/build/dex/quick-perps/usdq.js.map +0 -1
- package/build/dex/quick-perps/vault-price-feed.d.ts +0 -43
- package/build/dex/quick-perps/vault-price-feed.js +0 -203
- package/build/dex/quick-perps/vault-price-feed.js.map +0 -1
- package/build/dex/quick-perps/vault-utils.d.ts +0 -8
- package/build/dex/quick-perps/vault-utils.js +0 -42
- package/build/dex/quick-perps/vault-utils.js.map +0 -1
- package/build/dex/quick-perps/vault.d.ts +0 -46
- package/build/dex/quick-perps/vault.js +0 -182
- package/build/dex/quick-perps/vault.js.map +0 -1
- package/build/dex/quickswap/thena-fusion.d.ts +0 -6
- package/build/dex/quickswap/thena-fusion.js +0 -19
- package/build/dex/quickswap/thena-fusion.js.map +0 -1
- package/build/dex/se-vlr/config.js +0 -24
- package/build/dex/se-vlr/config.js.map +0 -1
- package/build/dex/se-vlr/se-vlr-pool.d.ts +0 -39
- package/build/dex/se-vlr/se-vlr-pool.js +0 -70
- package/build/dex/se-vlr/se-vlr-pool.js.map +0 -1
- package/build/dex/se-vlr/se-vlr.d.ts +0 -35
- package/build/dex/se-vlr/se-vlr.js +0 -131
- package/build/dex/se-vlr/se-vlr.js.map +0 -1
- package/build/dex/se-vlr/types.d.ts +0 -6
- package/build/dex/se-vlr/types.js +0 -3
- package/build/dex/se-vlr/types.js.map +0 -1
- package/build/dex/shell.d.ts +0 -25
- package/build/dex/shell.js +0 -41
- package/build/dex/shell.js.map +0 -1
- package/build/dex/smoothy/smoothy.d.ts +0 -16
- package/build/dex/smoothy/smoothy.js +0 -60
- package/build/dex/smoothy/smoothy.js.map +0 -1
- package/build/dex/smoothy/types.d.ts +0 -15
- package/build/dex/smoothy/types.js +0 -8
- package/build/dex/smoothy/types.js.map +0 -1
- package/build/dex/solidly/forks-override/aerodrome.d.ts +0 -14
- package/build/dex/solidly/forks-override/aerodrome.js +0 -46
- package/build/dex/solidly/forks-override/aerodrome.js.map +0 -1
- package/build/dex/solidly/forks-override/chronos.d.ts +0 -23
- package/build/dex/solidly/forks-override/chronos.js +0 -141
- package/build/dex/solidly/forks-override/chronos.js.map +0 -1
- package/build/dex/solidly/forks-override/usdfi.d.ts +0 -8
- package/build/dex/solidly/forks-override/usdfi.js +0 -15
- package/build/dex/solidly/forks-override/usdfi.js.map +0 -1
- package/build/dex/solidly/forks-override/velocimeter.d.ts +0 -23
- package/build/dex/solidly/forks-override/velocimeter.js +0 -77
- package/build/dex/solidly/forks-override/velocimeter.js.map +0 -1
- package/build/dex/stader/config.d.ts +0 -3
- package/build/dex/stader/config.js +0 -14
- package/build/dex/stader/config.js.map +0 -1
- package/build/dex/stader/stader-pool.d.ts +0 -19
- package/build/dex/stader/stader-pool.js +0 -56
- package/build/dex/stader/stader-pool.js.map +0 -1
- package/build/dex/stader/stader.d.ts +0 -42
- package/build/dex/stader/stader.js +0 -195
- package/build/dex/stader/stader.js.map +0 -1
- package/build/dex/stader/types.d.ts +0 -13
- package/build/dex/stader/types.js +0 -8
- package/build/dex/stader/types.js.map +0 -1
- package/build/dex/stader/utils.d.ts +0 -4
- package/build/dex/stader/utils.js +0 -23
- package/build/dex/stader/utils.js.map +0 -1
- package/build/dex/synthetix/config.d.ts +0 -4
- package/build/dex/synthetix/config.js +0 -53
- package/build/dex/synthetix/config.js.map +0 -1
- package/build/dex/synthetix/constants.d.ts +0 -23
- package/build/dex/synthetix/constants.js +0 -32
- package/build/dex/synthetix/constants.js.map +0 -1
- package/build/dex/synthetix/contract-math/DexPriceAggregatorUniswapV3.d.ts +0 -17
- package/build/dex/synthetix/contract-math/DexPriceAggregatorUniswapV3.js +0 -102
- package/build/dex/synthetix/contract-math/DexPriceAggregatorUniswapV3.js.map +0 -1
- package/build/dex/synthetix/contract-math/ExchangeRates.d.ts +0 -8
- package/build/dex/synthetix/contract-math/ExchangeRates.js +0 -77
- package/build/dex/synthetix/contract-math/ExchangeRates.js.map +0 -1
- package/build/dex/synthetix/contract-math/ExchangeRatesWithDexPricing.d.ts +0 -17
- package/build/dex/synthetix/contract-math/ExchangeRatesWithDexPricing.js +0 -126
- package/build/dex/synthetix/contract-math/ExchangeRatesWithDexPricing.js.map +0 -1
- package/build/dex/synthetix/contract-math/FullMath.d.ts +0 -3
- package/build/dex/synthetix/contract-math/FullMath.js +0 -14
- package/build/dex/synthetix/contract-math/FullMath.js.map +0 -1
- package/build/dex/synthetix/contract-math/OracleLibrary.d.ts +0 -8
- package/build/dex/synthetix/contract-math/OracleLibrary.js +0 -60
- package/build/dex/synthetix/contract-math/OracleLibrary.js.map +0 -1
- package/build/dex/synthetix/contract-math/SafeDecimalMath.d.ts +0 -9
- package/build/dex/synthetix/contract-math/SafeDecimalMath.js +0 -41
- package/build/dex/synthetix/contract-math/SafeDecimalMath.js.map +0 -1
- package/build/dex/synthetix/contract-math/TickMath.d.ts +0 -7
- package/build/dex/synthetix/contract-math/TickMath.js +0 -63
- package/build/dex/synthetix/contract-math/TickMath.js.map +0 -1
- package/build/dex/synthetix/contract-math/synthetix-math.d.ts +0 -17
- package/build/dex/synthetix/contract-math/synthetix-math.js +0 -127
- package/build/dex/synthetix/contract-math/synthetix-math.js.map +0 -1
- package/build/dex/synthetix/synthetix-state.d.ts +0 -36
- package/build/dex/synthetix/synthetix-state.js +0 -615
- package/build/dex/synthetix/synthetix-state.js.map +0 -1
- package/build/dex/synthetix/synthetix.d.ts +0 -45
- package/build/dex/synthetix/synthetix.js +0 -304
- package/build/dex/synthetix/synthetix.js.map +0 -1
- package/build/dex/synthetix/types.d.ts +0 -90
- package/build/dex/synthetix/types.js +0 -3
- package/build/dex/synthetix/types.js.map +0 -1
- package/build/dex/synthetix/utils.d.ts +0 -10
- package/build/dex/synthetix/utils.js +0 -91
- package/build/dex/synthetix/utils.js.map +0 -1
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1.d.ts +0 -7
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1.js +0 -20
- package/build/dex/trader-joe-v2.1/trader-joe-v2.1.js.map +0 -1
- package/build/dex/trader-joe-v2.d.ts +0 -40
- package/build/dex/trader-joe-v2.js +0 -74
- package/build/dex/trader-joe-v2.js.map +0 -1
- package/build/dex/uniswap-v2/dfyn.d.ts +0 -19
- package/build/dex/uniswap-v2/dfyn.js +0 -61
- package/build/dex/uniswap-v2/dfyn.js.map +0 -1
- package/build/dex/uniswap-v2/excalibur.d.ts +0 -24
- package/build/dex/uniswap-v2/excalibur.js +0 -47
- package/build/dex/uniswap-v2/excalibur.js.map +0 -1
- package/build/dex/uniswap-v2/mdex.d.ts +0 -24
- package/build/dex/uniswap-v2/mdex.js +0 -50
- package/build/dex/uniswap-v2/mdex.js.map +0 -1
- package/build/dex/uniswap-v2/nomiswap-v2.d.ts +0 -24
- package/build/dex/uniswap-v2/nomiswap-v2.js +0 -57
- package/build/dex/uniswap-v2/nomiswap-v2.js.map +0 -1
- package/build/dex/uniswap-v3/uniswap-v3-new.d.ts +0 -94
- package/build/dex/uniswap-v3/uniswap-v3-new.js +0 -923
- package/build/dex/uniswap-v3/uniswap-v3-new.js.map +0 -1
- package/build/dex/uniswap-v4/contract-math/Position.d.ts +0 -3
- package/build/dex/uniswap-v4/contract-math/Position.js +0 -10
- package/build/dex/uniswap-v4/contract-math/Position.js.map +0 -1
- package/build/dex/usual-bond/config.d.ts +0 -3
- package/build/dex/usual-bond/config.js +0 -13
- package/build/dex/usual-bond/config.js.map +0 -1
- package/build/dex/usual-bond/types.d.ts +0 -7
- package/build/dex/usual-bond/types.js +0 -3
- package/build/dex/usual-bond/types.js.map +0 -1
- package/build/dex/usual-bond/usual-bond.d.ts +0 -35
- package/build/dex/usual-bond/usual-bond.js +0 -176
- package/build/dex/usual-bond/usual-bond.js.map +0 -1
- package/build/dex/wombat/config.d.ts +0 -4
- package/build/dex/wombat/config.js +0 -77
- package/build/dex/wombat/config.js.map +0 -1
- package/build/dex/wombat/types.d.ts +0 -34
- package/build/dex/wombat/types.js +0 -3
- package/build/dex/wombat/types.js.map +0 -1
- package/build/dex/wombat/utils.d.ts +0 -10
- package/build/dex/wombat/utils.js +0 -79
- package/build/dex/wombat/utils.js.map +0 -1
- package/build/dex/wombat/wombat-bmw.d.ts +0 -40
- package/build/dex/wombat/wombat-bmw.js +0 -136
- package/build/dex/wombat/wombat-bmw.js.map +0 -1
- package/build/dex/wombat/wombat-pool.d.ts +0 -60
- package/build/dex/wombat/wombat-pool.js +0 -488
- package/build/dex/wombat/wombat-pool.js.map +0 -1
- package/build/dex/wombat/wombat-quoter.d.ts +0 -17
- package/build/dex/wombat/wombat-quoter.js +0 -192
- package/build/dex/wombat/wombat-quoter.js.map +0 -1
- package/build/dex/wombat/wombat.d.ts +0 -58
- package/build/dex/wombat/wombat.js +0 -298
- package/build/dex/wombat/wombat.js.map +0 -1
- package/build/dex/wusdm/config.d.ts +0 -3
- package/build/dex/wusdm/config.js +0 -43
- package/build/dex/wusdm/config.js.map +0 -1
- package/build/dex/wusdm/constants.d.ts +0 -2
- package/build/dex/wusdm/constants.js +0 -6
- package/build/dex/wusdm/constants.js.map +0 -1
- package/build/dex/wusdm/types.d.ts +0 -18
- package/build/dex/wusdm/types.js +0 -11
- package/build/dex/wusdm/types.js.map +0 -1
- package/build/dex/wusdm/wusdm-pool.d.ts +0 -21
- package/build/dex/wusdm/wusdm-pool.js +0 -74
- package/build/dex/wusdm/wusdm-pool.js.map +0 -1
- package/build/dex/wusdm/wusdm.d.ts +0 -46
- package/build/dex/wusdm/wusdm.js +0 -243
- package/build/dex/wusdm/wusdm.js.map +0 -1
- package/build/dex/zerox/config.d.ts +0 -2
- package/build/dex/zerox/config.js +0 -33
- package/build/dex/zerox/config.js.map +0 -1
- package/build/dex/zerox/index.d.ts +0 -22
- package/build/dex/zerox/index.js +0 -225
- package/build/dex/zerox/index.js.map +0 -1
- package/build/dex/zerox/order.d.ts +0 -88
- package/build/dex/zerox/order.js +0 -53
- package/build/dex/zerox/order.js.map +0 -1
- package/build/dex/zerox/types.d.ts +0 -73
- package/build/dex/zerox/types.js +0 -21
- package/build/dex/zerox/types.js.map +0 -1
- /package/build/dex/{bunni-v2 → pancakeswap-infinity}/types.js +0 -0
- /package/build/dex/{concentrator-arusd → renegade/api}/types.js +0 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RenegadeLevelsResponse = void 0;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
// Depth response from Renegade API.
|
|
6
|
+
class RenegadeLevelsResponse {
|
|
7
|
+
levels;
|
|
8
|
+
poolLiquidity;
|
|
9
|
+
constructor(data) {
|
|
10
|
+
this.levels = data;
|
|
11
|
+
if (!this.levels || typeof this.levels !== 'object') {
|
|
12
|
+
throw new Error('Invalid Renegade levels response: expected object');
|
|
13
|
+
}
|
|
14
|
+
this.poolLiquidity = {};
|
|
15
|
+
for (const [pairIdentifier, pairData] of Object.entries(this.levels)) {
|
|
16
|
+
const askLiquidityUSD = pairData.asks.reduce((acc, [price, size]) => {
|
|
17
|
+
return acc + parseFloat(size) * parseFloat(price);
|
|
18
|
+
}, 0);
|
|
19
|
+
const bidLiquidityUSD = pairData.bids.reduce((acc, [price, size]) => {
|
|
20
|
+
return acc + parseFloat(size) * parseFloat(price);
|
|
21
|
+
}, 0);
|
|
22
|
+
const liquidityUSD = askLiquidityUSD + bidLiquidityUSD;
|
|
23
|
+
this.poolLiquidity[pairIdentifier] = {
|
|
24
|
+
poolIdentifier: pairIdentifier,
|
|
25
|
+
exchange: constants_1.RENEGADE_NAME,
|
|
26
|
+
address: pairIdentifier.split('/')[0],
|
|
27
|
+
connectorTokens: [],
|
|
28
|
+
liquidityUSD,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Returns the raw levels data.
|
|
33
|
+
getRawData() {
|
|
34
|
+
return this.levels;
|
|
35
|
+
}
|
|
36
|
+
// Returns the pool liquidity for the given base token.
|
|
37
|
+
getPoolLiquidity(tokenAddress) {
|
|
38
|
+
const pools = [];
|
|
39
|
+
for (const [pair, pool] of Object.entries(this.poolLiquidity)) {
|
|
40
|
+
if (pair.toLowerCase().indexOf(tokenAddress.toLowerCase()) !== -1) {
|
|
41
|
+
pools.push(pool);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return pools;
|
|
45
|
+
}
|
|
46
|
+
// Returns directional liquidity data for a token across all relevant pairs.
|
|
47
|
+
getDirectionalLiquidityForToken(tokenAddress, usdcAddress) {
|
|
48
|
+
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
|
49
|
+
const normalizedUsdcAddress = usdcAddress.toLowerCase();
|
|
50
|
+
const results = [];
|
|
51
|
+
for (const [pairIdentifier, pairDepth] of Object.entries(this.levels)) {
|
|
52
|
+
const parsedPair = this.parsePairIdentifier(pairIdentifier);
|
|
53
|
+
if (!parsedPair)
|
|
54
|
+
continue;
|
|
55
|
+
const [baseToken, quoteToken] = parsedPair;
|
|
56
|
+
if (quoteToken !== normalizedUsdcAddress)
|
|
57
|
+
continue; // quote token should always be USDC
|
|
58
|
+
const isTokenBase = normalizedTokenAddress === baseToken;
|
|
59
|
+
const isTokenQuote = normalizedTokenAddress === quoteToken;
|
|
60
|
+
if (!isTokenBase && !isTokenQuote)
|
|
61
|
+
continue;
|
|
62
|
+
// Calculate directional liquidity
|
|
63
|
+
// If token is base: outbound = bids (sell base), reverse = asks (buy base)
|
|
64
|
+
// If token is quote: outbound = asks (sell quote), reverse = bids (buy quote)
|
|
65
|
+
const outboundLiquidityUSD = isTokenBase
|
|
66
|
+
? this.calculateLiquidityUSD(pairDepth.bids)
|
|
67
|
+
: this.calculateLiquidityUSD(pairDepth.asks);
|
|
68
|
+
const reverseLiquidityUSD = isTokenBase
|
|
69
|
+
? this.calculateLiquidityUSD(pairDepth.asks)
|
|
70
|
+
: this.calculateLiquidityUSD(pairDepth.bids);
|
|
71
|
+
if (outboundLiquidityUSD <= 0)
|
|
72
|
+
continue;
|
|
73
|
+
results.push({
|
|
74
|
+
baseToken,
|
|
75
|
+
quoteToken,
|
|
76
|
+
outboundLiquidityUSD,
|
|
77
|
+
reverseLiquidityUSD,
|
|
78
|
+
isTokenBase,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return results;
|
|
82
|
+
}
|
|
83
|
+
// Internal helper: parse pair identifier into [base, quote] tuple.
|
|
84
|
+
// Pair identifiers are formatted as [base]/[quote], where quote is always USDC.
|
|
85
|
+
parsePairIdentifier(pairIdentifier) {
|
|
86
|
+
const parts = pairIdentifier.split('/').map(s => s.toLowerCase());
|
|
87
|
+
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
return [parts[0], parts[1]];
|
|
91
|
+
}
|
|
92
|
+
// Internal helper: calculate USD liquidity from price levels.
|
|
93
|
+
// Sums price * size across all levels (both are strings).
|
|
94
|
+
calculateLiquidityUSD(levels) {
|
|
95
|
+
return levels.reduce((acc, [price, size]) => acc + parseFloat(size) * parseFloat(price), 0);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.RenegadeLevelsResponse = RenegadeLevelsResponse;
|
|
99
|
+
//# sourceMappingURL=renegade-levels-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renegade-levels-response.js","sourceRoot":"","sources":["../../../src/dex/renegade/renegade-levels-response.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Network, SwapSide } from '../../constants';
|
|
2
|
+
import { IDexHelper } from '../../dex-helper/idex-helper';
|
|
3
|
+
import { IDex } from '../../dex/idex';
|
|
4
|
+
import { AdapterExchangeParam, Address, DexExchangeParam, ExchangePrices, ExchangeTxInfo, Logger, NumberAsString, OptimalSwapExchange, PoolLiquidity, PoolPrices, PreprocessTransactionOptions, Token, TransferFeeParams } from '../../types';
|
|
5
|
+
import { SimpleExchange } from '../simple-exchange';
|
|
6
|
+
import { SignedExternalQuote } from './api/types';
|
|
7
|
+
import { RenegadeLevelsResponse } from './renegade-levels-response';
|
|
8
|
+
import { RenegadeData } from './types';
|
|
9
|
+
export declare class Renegade extends SimpleExchange implements IDex<RenegadeData> {
|
|
10
|
+
readonly network: Network;
|
|
11
|
+
readonly dexKey: string;
|
|
12
|
+
readonly dexHelper: IDexHelper;
|
|
13
|
+
readonly hasConstantPriceLargeAmounts = false;
|
|
14
|
+
readonly needWrapNative = true;
|
|
15
|
+
readonly isFeeOnTransferSupported = false;
|
|
16
|
+
readonly isStatePollingDex = true;
|
|
17
|
+
static dexKeysWithNetwork: {
|
|
18
|
+
key: string;
|
|
19
|
+
networks: Network[];
|
|
20
|
+
}[];
|
|
21
|
+
private rateFetcher;
|
|
22
|
+
private renegadeClient;
|
|
23
|
+
private tokensMap;
|
|
24
|
+
private readonly apiKey;
|
|
25
|
+
private readonly apiSecret;
|
|
26
|
+
private usdcAddress;
|
|
27
|
+
logger: Logger;
|
|
28
|
+
constructor(network: Network, dexKey: string, dexHelper: IDexHelper);
|
|
29
|
+
initializePricing(blockNumber: number): Promise<void>;
|
|
30
|
+
getAdapters(side: SwapSide): {
|
|
31
|
+
name: string;
|
|
32
|
+
index: number;
|
|
33
|
+
}[] | null;
|
|
34
|
+
private getPoolIdentifier;
|
|
35
|
+
getPoolIdentifiers(srcToken: Token, destToken: Token, side: SwapSide, blockNumber: number): Promise<string[]>;
|
|
36
|
+
getPricesVolume(srcToken: Token, destToken: Token, amounts: bigint[], side: SwapSide, blockNumber: number, limitPools?: string[], transferFees?: TransferFeeParams, isFirstSwap?: boolean): Promise<ExchangePrices<RenegadeData> | null>;
|
|
37
|
+
private getRateForAmount;
|
|
38
|
+
getCalldataGasCost(_poolPrices: PoolPrices<RenegadeData>): number | number[];
|
|
39
|
+
getAdapterParam(srcToken: string, destToken: string, srcAmount: string, destAmount: string, data: RenegadeData, side: SwapSide): AdapterExchangeParam;
|
|
40
|
+
updatePoolState(): Promise<void>;
|
|
41
|
+
setTokensMap(): Promise<void>;
|
|
42
|
+
getTopPoolsForToken(tokenAddress: Address, limit: number): Promise<PoolLiquidity[]>;
|
|
43
|
+
getDexParam(srcToken: Address, destToken: Address, srcAmount: NumberAsString, destAmount: NumberAsString, recipient: Address, data: RenegadeData, side: SwapSide): DexExchangeParam;
|
|
44
|
+
preProcessTransaction(optimalSwapExchange: OptimalSwapExchange<RenegadeData>, srcToken: Token, destToken: Token, side: SwapSide, options: PreprocessTransactionOptions): Promise<[OptimalSwapExchange<RenegadeData>, ExchangeTxInfo]>;
|
|
45
|
+
releaseResources(): Promise<void>;
|
|
46
|
+
getCachedSignedQuote(srcToken: Token, destToken: Token): Promise<SignedExternalQuote | null>;
|
|
47
|
+
getCachedLevels(): Promise<RenegadeLevelsResponse | null>;
|
|
48
|
+
getCachedTokens(): Promise<Record<string, Token> | null>;
|
|
49
|
+
private getQuoteCacheKey;
|
|
50
|
+
private createExternalOrderWithInputAmount;
|
|
51
|
+
private createExternalOrderWithExactOutputAmount;
|
|
52
|
+
private areTokensSupported;
|
|
53
|
+
private isRenegadeSell;
|
|
54
|
+
getTokenFromAddress(address: Address): Token;
|
|
55
|
+
isUSDC(tokenAddress: Address): boolean;
|
|
56
|
+
private _sortTokens;
|
|
57
|
+
}
|
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Renegade = void 0;
|
|
40
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
41
|
+
const ts_essentials_1 = require("ts-essentials");
|
|
42
|
+
const CALLDATA_GAS_COST = __importStar(require("../../calldata-gas-cost"));
|
|
43
|
+
const constants_1 = require("../../constants");
|
|
44
|
+
const simple_exchange_1 = require("../simple-exchange");
|
|
45
|
+
const utils_1 = require("../../utils");
|
|
46
|
+
const renegade_client_1 = require("./api/renegade-client");
|
|
47
|
+
const config_1 = require("./config");
|
|
48
|
+
const constants_2 = require("./constants");
|
|
49
|
+
const rate_fetcher_1 = require("./rate-fetcher");
|
|
50
|
+
const renegade_levels_response_1 = require("./renegade-levels-response");
|
|
51
|
+
class Renegade extends simple_exchange_1.SimpleExchange {
|
|
52
|
+
network;
|
|
53
|
+
dexKey;
|
|
54
|
+
dexHelper;
|
|
55
|
+
hasConstantPriceLargeAmounts = false;
|
|
56
|
+
needWrapNative = true;
|
|
57
|
+
isFeeOnTransferSupported = false;
|
|
58
|
+
isStatePollingDex = true;
|
|
59
|
+
static dexKeysWithNetwork = [
|
|
60
|
+
{ key: constants_2.RENEGADE_NAME, networks: [constants_1.Network.ARBITRUM, constants_1.Network.BASE] },
|
|
61
|
+
];
|
|
62
|
+
rateFetcher;
|
|
63
|
+
renegadeClient;
|
|
64
|
+
tokensMap = {};
|
|
65
|
+
apiKey;
|
|
66
|
+
apiSecret;
|
|
67
|
+
usdcAddress;
|
|
68
|
+
logger;
|
|
69
|
+
constructor(network, dexKey, dexHelper) {
|
|
70
|
+
super(dexHelper, dexKey);
|
|
71
|
+
this.network = network;
|
|
72
|
+
this.dexKey = dexKey;
|
|
73
|
+
this.dexHelper = dexHelper;
|
|
74
|
+
this.logger = dexHelper.getLogger(dexKey);
|
|
75
|
+
// Ensure API credentials are set
|
|
76
|
+
const apiKey = this.dexHelper.config.data.renegadeAuthApiKey;
|
|
77
|
+
const apiSecret = this.dexHelper.config.data.renegadeAuthApiSecret;
|
|
78
|
+
(0, ts_essentials_1.assert)(apiKey !== undefined, 'Renegade API key is not specified with env variable API_KEY_RENEGADE_AUTH_API_KEY');
|
|
79
|
+
(0, ts_essentials_1.assert)(apiSecret !== undefined, 'Renegade API secret is not specified with env variable API_KEY_RENEGADE_AUTH_API_SECRET');
|
|
80
|
+
// Initialize rate fetcher with credentials and caching config
|
|
81
|
+
this.apiKey = apiKey;
|
|
82
|
+
this.apiSecret = apiSecret;
|
|
83
|
+
const rateFetcherConfig = {
|
|
84
|
+
apiKey,
|
|
85
|
+
apiSecret,
|
|
86
|
+
levelsCacheKey: constants_2.RENEGADE_LEVELS_CACHE_KEY,
|
|
87
|
+
levelsCacheTTL: constants_2.RENEGADE_LEVELS_CACHE_TTL_SECONDS,
|
|
88
|
+
tokenMetadataCacheKey: constants_2.RENEGADE_TOKEN_METADATA_CACHE_KEY,
|
|
89
|
+
tokenMetadataCacheTTL: constants_2.RENEGADE_TOKEN_METADATA_CACHE_TTL_SECONDS,
|
|
90
|
+
};
|
|
91
|
+
this.rateFetcher = new rate_fetcher_1.RateFetcher(this.dexHelper, this.dexKey, this.network, this.logger, rateFetcherConfig);
|
|
92
|
+
this.renegadeClient = new renegade_client_1.RenegadeClient(this.dexHelper, this.network, this.apiKey, this.apiSecret, this.logger);
|
|
93
|
+
this.usdcAddress = config_1.RenegadeConfig[constants_2.RENEGADE_NAME][this.network].usdcAddress;
|
|
94
|
+
}
|
|
95
|
+
async initializePricing(blockNumber) {
|
|
96
|
+
if (!this.dexHelper.config.isSlave) {
|
|
97
|
+
this.rateFetcher.start();
|
|
98
|
+
await sleep(constants_2.RENEGADE_INIT_TIMEOUT_MS);
|
|
99
|
+
}
|
|
100
|
+
await this.setTokensMap();
|
|
101
|
+
}
|
|
102
|
+
// Legacy: was only used for V5
|
|
103
|
+
// Returns the list of contract adapters (name and index)
|
|
104
|
+
// for a buy/sell. Return null if there are no adapters.
|
|
105
|
+
getAdapters(side) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
// Returns pool identifier as the Renegade API expects it.
|
|
109
|
+
getPoolIdentifier(tokenA, tokenB) {
|
|
110
|
+
const srcIsUSDC = this.isUSDC(tokenA);
|
|
111
|
+
const baseToken = srcIsUSDC ? tokenB : tokenA;
|
|
112
|
+
const quoteToken = srcIsUSDC ? tokenA : tokenB;
|
|
113
|
+
return `${this.dexKey}_${baseToken.toLowerCase()}_${quoteToken.toLowerCase()}`;
|
|
114
|
+
}
|
|
115
|
+
// Returns list of pool identifiers that can be used
|
|
116
|
+
// for a given swap.
|
|
117
|
+
async getPoolIdentifiers(srcToken, destToken, side, blockNumber) {
|
|
118
|
+
if (!this.areTokensSupported(srcToken.address, destToken.address)) {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
return [this.getPoolIdentifier(srcToken.address, destToken.address)];
|
|
122
|
+
}
|
|
123
|
+
// Returns pool prices for amounts.
|
|
124
|
+
async getPricesVolume(srcToken, destToken, amounts, side, blockNumber, limitPools, transferFees, isFirstSwap) {
|
|
125
|
+
try {
|
|
126
|
+
if (amounts.length === 0) {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
if (!this.areTokensSupported(srcToken.address, destToken.address)) {
|
|
130
|
+
this.logger.debug('Tokens not supported by Renegade API', {
|
|
131
|
+
srcToken: srcToken.address,
|
|
132
|
+
destToken: destToken.address,
|
|
133
|
+
});
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
// Use the last amount as reference for the quote
|
|
137
|
+
const referenceAmount = amounts[amounts.length - 1].toString();
|
|
138
|
+
this.logger.debug('Getting rate for amount', {
|
|
139
|
+
srcToken,
|
|
140
|
+
destToken,
|
|
141
|
+
referenceAmount,
|
|
142
|
+
side,
|
|
143
|
+
});
|
|
144
|
+
// Get rate from helper method
|
|
145
|
+
const rate = await this.getRateForAmount(srcToken, destToken, referenceAmount, side);
|
|
146
|
+
// Apply rate to all amounts
|
|
147
|
+
const prices = amounts.map(amount => {
|
|
148
|
+
const output = new bignumber_js_1.default(amount.toString()).multipliedBy(rate);
|
|
149
|
+
return BigInt(output.decimalPlaces(0, bignumber_js_1.default.ROUND_FLOOR).toFixed(0));
|
|
150
|
+
});
|
|
151
|
+
const poolIdentifier = this.getPoolIdentifier(srcToken.address, destToken.address);
|
|
152
|
+
const outputDecimals = side === constants_1.SwapSide.SELL ? destToken.decimals : srcToken.decimals;
|
|
153
|
+
return [
|
|
154
|
+
{
|
|
155
|
+
prices,
|
|
156
|
+
unit: (0, utils_1.getBigIntPow)(outputDecimals),
|
|
157
|
+
data: {},
|
|
158
|
+
poolIdentifiers: [poolIdentifier],
|
|
159
|
+
exchange: this.dexKey,
|
|
160
|
+
gasCost: constants_2.RENEGADE_GAS_COST,
|
|
161
|
+
},
|
|
162
|
+
];
|
|
163
|
+
}
|
|
164
|
+
catch (e) {
|
|
165
|
+
this.logger.error(`Error_getPricesVolume ${srcToken.address || srcToken.symbol}, ${destToken.address || destToken.symbol}, ${side}:`, e);
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// Helper method to construct external order, request quote, cache response, and return rate.
|
|
170
|
+
async getRateForAmount(srcToken, destToken, referenceAmount, side) {
|
|
171
|
+
// Determine tokens and Renegade side
|
|
172
|
+
const isRenegadeSell = this.isRenegadeSell(srcToken, destToken);
|
|
173
|
+
// Determine base and quote mints (quote is always USDC)
|
|
174
|
+
const isDestUSDC = this.isUSDC(destToken.address);
|
|
175
|
+
const baseMint = isDestUSDC ? srcToken.address : destToken.address;
|
|
176
|
+
const quoteMint = this.usdcAddress;
|
|
177
|
+
const renegadeSide = isRenegadeSell ? 'Sell' : 'Buy';
|
|
178
|
+
const externalOrder = side === constants_1.SwapSide.SELL
|
|
179
|
+
? this.createExternalOrderWithInputAmount(quoteMint, baseMint, renegadeSide, referenceAmount)
|
|
180
|
+
: this.createExternalOrderWithExactOutputAmount(quoteMint, baseMint, renegadeSide, referenceAmount);
|
|
181
|
+
// Fetch quote from Renegade API
|
|
182
|
+
const quoteResponse = await this.renegadeClient.requestQuote(externalOrder);
|
|
183
|
+
// Cache the signed quote for later use in preProcessTransaction
|
|
184
|
+
const cacheKey = this.getQuoteCacheKey(srcToken, destToken);
|
|
185
|
+
// Extract send/receive from quote
|
|
186
|
+
const send = quoteResponse.signed_quote.quote.send;
|
|
187
|
+
const receive = quoteResponse.signed_quote.quote.receive;
|
|
188
|
+
// Determine input and output tokens for rate calculation
|
|
189
|
+
const inputToken = side === constants_1.SwapSide.SELL ? srcToken : destToken;
|
|
190
|
+
// Identify which is input and which is output in send/receive
|
|
191
|
+
const isSendInput = send.mint.toLowerCase() === inputToken.address.toLowerCase();
|
|
192
|
+
const inputAmount = isSendInput ? send.amount : receive.amount;
|
|
193
|
+
const outputAmount = isSendInput ? receive.amount : send.amount;
|
|
194
|
+
// Protect against division by zero
|
|
195
|
+
if (new bignumber_js_1.default(inputAmount).isZero()) {
|
|
196
|
+
throw new Error('Division by zero: inputAmount is zero');
|
|
197
|
+
}
|
|
198
|
+
// Calculate rate: output per input (in atomic units)
|
|
199
|
+
const rate = new bignumber_js_1.default(outputAmount).dividedBy(inputAmount);
|
|
200
|
+
// Store the signed quote response directly in cache
|
|
201
|
+
await this.dexHelper.cache.setex(this.dexKey, this.network, cacheKey, constants_2.RENEGADE_QUOTE_CACHE_TTL_SECONDS, JSON.stringify(quoteResponse));
|
|
202
|
+
return rate;
|
|
203
|
+
}
|
|
204
|
+
// Returns estimated gas cost of calldata for this DEX in multiSwap
|
|
205
|
+
//
|
|
206
|
+
// Estimates calldata gas cost for [function sponsorAtomicMatchSettle()](https://github.com/renegade-fi/renegade-contracts/blob/c1df0e58a6fc665133540c79ef2f0c6226fa670f/src/darkpool/v1/contracts/GasSponsor.sol#L174-L189)
|
|
207
|
+
getCalldataGasCost(_poolPrices) {
|
|
208
|
+
// Assumptions
|
|
209
|
+
const INTERNAL_PARTY_MODIFIED_SHARES_LEN = 70;
|
|
210
|
+
const PLONK_PROOF_WORDS = 36;
|
|
211
|
+
const LINKING_PROOF_WORDS = 4;
|
|
212
|
+
const { ADDRESS, AMOUNT, BOOL, BPS, DEX_OVERHEAD, FULL_WORD, FUNCTION_SELECTOR, INDEX, LENGTH_SMALL, OFFSET_LARGE, UUID, } = CALLDATA_GAS_COST;
|
|
213
|
+
const PARTY_MATCH_PAYLOAD = 3 * INDEX + // OrderSettlementIndices
|
|
214
|
+
3 * FULL_WORD; // ValidReblindStatement (3 scalars)
|
|
215
|
+
const EXTERNAL_MATCH_RESULT = ADDRESS + ADDRESS + AMOUNT + AMOUNT + INDEX; // direction ~ small enum
|
|
216
|
+
const FEE_TAKE = AMOUNT + AMOUNT;
|
|
217
|
+
const INTERNAL_PARTY_SETTLEMENT_INDICES = 3 * INDEX;
|
|
218
|
+
const VMSA_HEAD = EXTERNAL_MATCH_RESULT +
|
|
219
|
+
FEE_TAKE +
|
|
220
|
+
OFFSET_LARGE + // internal array offset
|
|
221
|
+
INTERNAL_PARTY_SETTLEMENT_INDICES +
|
|
222
|
+
BPS + // protocolFeeRate (approx small)
|
|
223
|
+
ADDRESS; // relayerFeeAddress
|
|
224
|
+
const VMSA_TAIL = LENGTH_SMALL + INTERNAL_PARTY_MODIFIED_SHARES_LEN * FULL_WORD;
|
|
225
|
+
const VALID_MATCH_SETTLE_ATOMIC_STATEMENT = OFFSET_LARGE + // top-level struct offset
|
|
226
|
+
VMSA_HEAD +
|
|
227
|
+
VMSA_TAIL;
|
|
228
|
+
const MATCH_ATOMIC_PROOFS = 3 * PLONK_PROOF_WORDS * FULL_WORD;
|
|
229
|
+
const MATCH_ATOMIC_LINKING_PROOFS = 2 * LINKING_PROOF_WORDS * FULL_WORD;
|
|
230
|
+
const FOOTER = ADDRESS + // refundAddress
|
|
231
|
+
BOOL + // refundNativeEth
|
|
232
|
+
AMOUNT + // refundAmount
|
|
233
|
+
UUID; // nonce (approx)
|
|
234
|
+
const SIGNATURE = OFFSET_LARGE + // bytes offset
|
|
235
|
+
LENGTH_SMALL + // length (65)
|
|
236
|
+
2 * FULL_WORD + // r, s
|
|
237
|
+
BOOL; // v
|
|
238
|
+
const total = DEX_OVERHEAD +
|
|
239
|
+
FUNCTION_SELECTOR +
|
|
240
|
+
PARTY_MATCH_PAYLOAD +
|
|
241
|
+
VALID_MATCH_SETTLE_ATOMIC_STATEMENT +
|
|
242
|
+
MATCH_ATOMIC_PROOFS +
|
|
243
|
+
MATCH_ATOMIC_LINKING_PROOFS +
|
|
244
|
+
FOOTER +
|
|
245
|
+
SIGNATURE;
|
|
246
|
+
return total; // ~103000 L1 gas
|
|
247
|
+
}
|
|
248
|
+
// Encode params required by the exchange adapter
|
|
249
|
+
// V5: Used for multiSwap, buy & megaSwap
|
|
250
|
+
// V6: Not used, can be left blank
|
|
251
|
+
getAdapterParam(srcToken, destToken, srcAmount, destAmount, data, side) {
|
|
252
|
+
const settlementTx = data?.settlementTx;
|
|
253
|
+
if (!settlementTx) {
|
|
254
|
+
throw new Error(`${this.dexKey}-${this.network}: settlementTx missing from data`);
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
targetExchange: settlementTx.to,
|
|
258
|
+
payload: settlementTx.data,
|
|
259
|
+
networkFee: settlementTx.value,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
async updatePoolState() {
|
|
263
|
+
await this.setTokensMap();
|
|
264
|
+
}
|
|
265
|
+
async setTokensMap() {
|
|
266
|
+
const metadata = await this.getCachedTokens();
|
|
267
|
+
if (metadata) {
|
|
268
|
+
this.tokensMap = metadata;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
// Returns list of top pools based on liquidity. Max
|
|
272
|
+
// limit number pools should be returned.
|
|
273
|
+
async getTopPoolsForToken(tokenAddress, limit) {
|
|
274
|
+
// Ensure we have cached levels and token metadata available
|
|
275
|
+
const levels = await this.getCachedLevels();
|
|
276
|
+
if (!levels)
|
|
277
|
+
return [];
|
|
278
|
+
await this.setTokensMap();
|
|
279
|
+
const normalizedTokenAddress = tokenAddress.toLowerCase();
|
|
280
|
+
const normalizedUsdcAddress = this.usdcAddress.toLowerCase();
|
|
281
|
+
const directionalLiquidity = levels.getDirectionalLiquidityForToken(normalizedTokenAddress, normalizedUsdcAddress);
|
|
282
|
+
const results = [];
|
|
283
|
+
for (const liquidityData of directionalLiquidity) {
|
|
284
|
+
const { baseToken, outboundLiquidityUSD, reverseLiquidityUSD, isTokenBase, } = liquidityData;
|
|
285
|
+
// Determine connector token: USDC if token is base, base token if token is quote
|
|
286
|
+
const connectorAddress = isTokenBase ? normalizedUsdcAddress : baseToken;
|
|
287
|
+
const connectorMeta = this.tokensMap[connectorAddress];
|
|
288
|
+
if (!connectorMeta) {
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
results.push({
|
|
292
|
+
exchange: this.dexKey,
|
|
293
|
+
address: baseToken,
|
|
294
|
+
connectorTokens: [
|
|
295
|
+
{
|
|
296
|
+
address: connectorAddress,
|
|
297
|
+
decimals: connectorMeta.decimals,
|
|
298
|
+
symbol: connectorMeta.symbol,
|
|
299
|
+
liquidityUSD: reverseLiquidityUSD,
|
|
300
|
+
},
|
|
301
|
+
],
|
|
302
|
+
liquidityUSD: outboundLiquidityUSD,
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
return results
|
|
306
|
+
.sort((a, b) => b.liquidityUSD - a.liquidityUSD)
|
|
307
|
+
.slice(0, limit);
|
|
308
|
+
}
|
|
309
|
+
getDexParam(srcToken, destToken, srcAmount, destAmount, recipient, data, side) {
|
|
310
|
+
const settlementTx = data?.settlementTx;
|
|
311
|
+
if (!settlementTx) {
|
|
312
|
+
throw new Error(`${this.dexKey}-${this.network}: settlementTx missing from data`);
|
|
313
|
+
}
|
|
314
|
+
return {
|
|
315
|
+
needWrapNative: this.needWrapNative,
|
|
316
|
+
dexFuncHasRecipient: false,
|
|
317
|
+
exchangeData: settlementTx.data,
|
|
318
|
+
targetExchange: settlementTx.to,
|
|
319
|
+
returnAmountPos: undefined,
|
|
320
|
+
specialDexSupportsInsertFromAmount: false,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
// Called before getAdapterParam to use async calls and receive data if needed
|
|
324
|
+
async preProcessTransaction(optimalSwapExchange, srcToken, destToken, side, options) {
|
|
325
|
+
try {
|
|
326
|
+
if (!this.areTokensSupported(srcToken.address, destToken.address)) {
|
|
327
|
+
throw new Error(`${this.dexKey}-${this.network}: Tokens not supported by Renegade API: ${srcToken.address}, ${destToken.address}`);
|
|
328
|
+
}
|
|
329
|
+
// 1. Retrieve cached fixed signed quote for the pair (now side-specific)
|
|
330
|
+
const cachedSignedQuote = await this.getCachedSignedQuote(srcToken, destToken);
|
|
331
|
+
if (!cachedSignedQuote) {
|
|
332
|
+
throw new Error(`${this.dexKey}-${this.network}: No cached quote available for pair ${srcToken.address}-${destToken.address}`);
|
|
333
|
+
}
|
|
334
|
+
// 2. Extract base_mint, quote_mint, and side from cached quote
|
|
335
|
+
const cachedOrder = cachedSignedQuote.quote.order;
|
|
336
|
+
const baseMint = cachedOrder.base_mint;
|
|
337
|
+
const quoteMint = cachedOrder.quote_mint;
|
|
338
|
+
const renegadeSide = cachedOrder.side;
|
|
339
|
+
// 3. Create updated order with actual transaction amount
|
|
340
|
+
const updatedOrder = side === constants_1.SwapSide.SELL
|
|
341
|
+
? this.createExternalOrderWithInputAmount(quoteMint, baseMint, renegadeSide, optimalSwapExchange.srcAmount)
|
|
342
|
+
: this.createExternalOrderWithExactOutputAmount(quoteMint, baseMint, renegadeSide, optimalSwapExchange.destAmount);
|
|
343
|
+
// 4. Request calldata from Renegade API with updated order
|
|
344
|
+
const response = await this.renegadeClient.assembleExternalMatch(cachedSignedQuote, { updated_order: updatedOrder });
|
|
345
|
+
const settlementTxRequest = response?.match_bundle?.settlement_tx;
|
|
346
|
+
(0, ts_essentials_1.assert)(settlementTxRequest !== undefined, `${this.dexKey}-${this.network}: Invalid match response`);
|
|
347
|
+
const settlementTx = {
|
|
348
|
+
to: settlementTxRequest.to || '',
|
|
349
|
+
data: settlementTxRequest.data || settlementTxRequest.input || '',
|
|
350
|
+
value: settlementTxRequest.value || '0',
|
|
351
|
+
};
|
|
352
|
+
const exchangeWithData = {
|
|
353
|
+
...optimalSwapExchange,
|
|
354
|
+
data: {
|
|
355
|
+
settlementTx,
|
|
356
|
+
rawResponse: response,
|
|
357
|
+
},
|
|
358
|
+
};
|
|
359
|
+
return [exchangeWithData, {}];
|
|
360
|
+
}
|
|
361
|
+
catch (e) {
|
|
362
|
+
const message = `${this.dexKey}-${this.network}: ${e}`;
|
|
363
|
+
this.logger.error(message);
|
|
364
|
+
throw new Error(message);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
// Cleans up any resources used by the DEX.
|
|
368
|
+
async releaseResources() {
|
|
369
|
+
if (!this.dexHelper.config.isSlave) {
|
|
370
|
+
this.rateFetcher.stop();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
// Cache
|
|
374
|
+
// Get cached signed quote for a token pair and side.
|
|
375
|
+
async getCachedSignedQuote(srcToken, destToken) {
|
|
376
|
+
try {
|
|
377
|
+
// Build cache key using helper method
|
|
378
|
+
const cacheKey = this.getQuoteCacheKey(srcToken, destToken);
|
|
379
|
+
// Check cache for existing quote
|
|
380
|
+
const cachedQuote = await this.dexHelper.cache.getAndCacheLocally(this.dexKey, this.network, cacheKey, constants_2.RENEGADE_QUOTE_CACHE_TTL_SECONDS);
|
|
381
|
+
if (cachedQuote) {
|
|
382
|
+
const quoteResponse = JSON.parse(cachedQuote);
|
|
383
|
+
return quoteResponse.signed_quote;
|
|
384
|
+
}
|
|
385
|
+
return null;
|
|
386
|
+
}
|
|
387
|
+
catch (e) {
|
|
388
|
+
this.logger.error(`Error retrieving cached quote for ${srcToken.address}-${destToken.address}:`, e);
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
// Get cached price levels from persistent cache.
|
|
393
|
+
async getCachedLevels() {
|
|
394
|
+
const cachedLevels = await this.dexHelper.cache.getAndCacheLocally(this.dexKey, this.network, constants_2.RENEGADE_LEVELS_CACHE_KEY, constants_2.RENEGADE_LEVELS_CACHE_TTL_SECONDS);
|
|
395
|
+
if (cachedLevels) {
|
|
396
|
+
const rawData = JSON.parse(cachedLevels);
|
|
397
|
+
return new renegade_levels_response_1.RenegadeLevelsResponse(rawData);
|
|
398
|
+
}
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
// Get cached token metadata from persistent cache.
|
|
402
|
+
async getCachedTokens() {
|
|
403
|
+
const cachedTokens = await this.dexHelper.cache.getAndCacheLocally(this.dexKey, this.network, constants_2.RENEGADE_TOKEN_METADATA_CACHE_KEY, constants_2.RENEGADE_TOKEN_METADATA_CACHE_TTL_SECONDS);
|
|
404
|
+
if (cachedTokens) {
|
|
405
|
+
return JSON.parse(cachedTokens);
|
|
406
|
+
}
|
|
407
|
+
return null;
|
|
408
|
+
}
|
|
409
|
+
// Generate cache key for quote storage and retrieval.
|
|
410
|
+
getQuoteCacheKey(srcToken, destToken) {
|
|
411
|
+
// Determine Renegade side based on which token is USDC
|
|
412
|
+
const isRenegadeSell = this.isRenegadeSell(srcToken, destToken);
|
|
413
|
+
// Build cache key from alphabetically sorted token addresses and side
|
|
414
|
+
const sortedAddresses = this._sortTokens(srcToken.address, destToken.address);
|
|
415
|
+
return `${constants_2.RENEGADE_QUOTE_CACHE_KEY}_${sortedAddresses[0]}_${sortedAddresses[1]}_${isRenegadeSell ? 'Sell' : 'Buy'}`;
|
|
416
|
+
}
|
|
417
|
+
// Helpers
|
|
418
|
+
// Create updated order for exact input (ParaSwap SELL side).
|
|
419
|
+
// Preserves token pair and side from cached quote, updates amounts only.
|
|
420
|
+
createExternalOrderWithInputAmount(quoteMint, baseMint, side, srcAmount) {
|
|
421
|
+
// Determine which amount field to set based on Renegade side
|
|
422
|
+
// Rule: Exactly ONE sizing parameter must be non-zero
|
|
423
|
+
const isRenegadeSell = side === 'Sell';
|
|
424
|
+
// For exact input, we specify the input amount
|
|
425
|
+
// If Renegade Sell: base is input (base_amount)
|
|
426
|
+
// If Renegade Buy: quote is input (quote_amount)
|
|
427
|
+
const baseAmount = isRenegadeSell ? srcAmount : '0';
|
|
428
|
+
const quoteAmount = isRenegadeSell ? '0' : srcAmount;
|
|
429
|
+
return {
|
|
430
|
+
quote_mint: quoteMint,
|
|
431
|
+
base_mint: baseMint,
|
|
432
|
+
side: side,
|
|
433
|
+
base_amount: baseAmount,
|
|
434
|
+
quote_amount: quoteAmount,
|
|
435
|
+
min_fill_size: srcAmount,
|
|
436
|
+
exact_base_output: '0',
|
|
437
|
+
exact_quote_output: '0',
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
// Create updated order for exact output (ParaSwap BUY side).
|
|
441
|
+
// Preserves token pair and side from cached quote, updates amounts only.
|
|
442
|
+
createExternalOrderWithExactOutputAmount(quoteMint, baseMint, side, destAmount) {
|
|
443
|
+
// Determine which exact output field to set based on Renegade side
|
|
444
|
+
// Rule: Exactly ONE sizing parameter must be non-zero
|
|
445
|
+
// Rule: When using exact outputs, min_fill_size MUST be 0
|
|
446
|
+
const isRenegadeSell = side === 'Sell';
|
|
447
|
+
// For exact output, we specify the output amount
|
|
448
|
+
// If Renegade Sell: quote is output (exact_quote_output)
|
|
449
|
+
// If Renegade Buy: base is output (exact_base_output)
|
|
450
|
+
const exactQuoteOutput = isRenegadeSell ? destAmount : '0';
|
|
451
|
+
const exactBaseOutput = isRenegadeSell ? '0' : destAmount;
|
|
452
|
+
return {
|
|
453
|
+
quote_mint: quoteMint,
|
|
454
|
+
base_mint: baseMint,
|
|
455
|
+
side: side,
|
|
456
|
+
base_amount: '0',
|
|
457
|
+
quote_amount: '0',
|
|
458
|
+
min_fill_size: '0', // MUST be 0 with exact outputs
|
|
459
|
+
exact_base_output: exactBaseOutput,
|
|
460
|
+
exact_quote_output: exactQuoteOutput,
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
// Ensures both tokens are supported by Renegade API and exactly one of them is USDC.
|
|
464
|
+
areTokensSupported(srcTokenAddress, destTokenAddress) {
|
|
465
|
+
const srcTokenLower = srcTokenAddress.toLowerCase();
|
|
466
|
+
const destTokenLower = destTokenAddress.toLowerCase();
|
|
467
|
+
const srcTokenExists = this.tokensMap[srcTokenLower] !== undefined;
|
|
468
|
+
const destTokenExists = this.tokensMap[destTokenLower] !== undefined;
|
|
469
|
+
if (!srcTokenExists || !destTokenExists) {
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
const srcIsUSDC = this.isUSDC(srcTokenAddress);
|
|
473
|
+
const destIsUSDC = this.isUSDC(destTokenAddress);
|
|
474
|
+
const exactlyOneIsUSDC = srcIsUSDC !== destIsUSDC;
|
|
475
|
+
return exactlyOneIsUSDC;
|
|
476
|
+
}
|
|
477
|
+
// Determine if this is a Renegade Sell operation (base → USDC).
|
|
478
|
+
isRenegadeSell(srcToken, destToken) {
|
|
479
|
+
return this.isUSDC(destToken.address);
|
|
480
|
+
}
|
|
481
|
+
// Returns the token metadata for a given address.
|
|
482
|
+
getTokenFromAddress(address) {
|
|
483
|
+
return this.tokensMap[address.toLowerCase()];
|
|
484
|
+
}
|
|
485
|
+
// Check if a token address is USDC for the current network.
|
|
486
|
+
isUSDC(tokenAddress) {
|
|
487
|
+
return tokenAddress.toLowerCase() === this.usdcAddress.toLowerCase();
|
|
488
|
+
}
|
|
489
|
+
// Sort token addresses alphabetically.
|
|
490
|
+
_sortTokens(srcAddress, destAddress) {
|
|
491
|
+
return [srcAddress, destAddress].sort((a, b) => (a < b ? -1 : 1));
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
exports.Renegade = Renegade;
|
|
495
|
+
// Helper function to sleep for a given time
|
|
496
|
+
const sleep = (time) => new Promise(resolve => {
|
|
497
|
+
setTimeout(resolve, time);
|
|
498
|
+
});
|
|
499
|
+
//# sourceMappingURL=renegade.js.map
|