aftermath-ts-sdk 0.0.162 → 0.0.164
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/dist/general/api/dynamicFieldsApiHelpers.d.ts +29 -6
- package/dist/general/api/dynamicFieldsApiHelpers.d.ts.map +1 -1
- package/dist/general/api/dynamicFieldsApiHelpers.js +31 -31
- package/dist/general/api/eventsApiHelpers.d.ts +23 -8
- package/dist/general/api/eventsApiHelpers.d.ts.map +1 -1
- package/dist/general/api/eventsApiHelpers.js +38 -33
- package/dist/general/api/inspectionsApiHelpers.js +9 -9
- package/dist/general/api/objectsApiHelpers.d.ts +150 -110
- package/dist/general/api/objectsApiHelpers.d.ts.map +1 -1
- package/dist/general/api/objectsApiHelpers.js +32 -27
- package/dist/general/api/rpcApiHelpers.js +9 -9
- package/dist/general/api/transactionsApiHelpers.d.ts +9 -4
- package/dist/general/api/transactionsApiHelpers.d.ts.map +1 -1
- package/dist/general/api/transactionsApiHelpers.js +28 -19
- package/dist/general/historicalData/historicalData.js +6 -6
- package/dist/general/historicalData/historicalDataApi.js +6 -6
- package/dist/general/historicalData/historicalDataApiInterface.d.ts +2 -1
- package/dist/general/historicalData/historicalDataApiInterface.d.ts.map +1 -1
- package/dist/general/prices/coingecko/coinGeckoApiHelpers.js +24 -24
- package/dist/general/prices/coingecko/coinGeckoPricesApi.js +15 -15
- package/dist/general/prices/placeholder/placeholderPricesApi.d.ts.map +1 -1
- package/dist/general/prices/placeholder/placeholderPricesApi.js +40 -33
- package/dist/general/prices/prices.js +6 -6
- package/dist/general/prices/pyth/pythPricesApi.js +12 -12
- package/dist/general/prices/pyth/pythPricesApiHelpers.js +12 -12
- package/dist/general/providers/aftermath.d.ts +4 -2
- package/dist/general/providers/aftermath.d.ts.map +1 -1
- package/dist/general/providers/aftermath.js +22 -20
- package/dist/general/providers/aftermathApi.d.ts +4 -2
- package/dist/general/providers/aftermathApi.d.ts.map +1 -1
- package/dist/general/providers/aftermathApi.js +34 -32
- package/dist/general/types/configTypes.d.ts +94 -14
- package/dist/general/types/configTypes.d.ts.map +1 -1
- package/dist/general/types/generalTypes.d.ts +12 -1
- package/dist/general/types/generalTypes.d.ts.map +1 -1
- package/dist/general/utils/caller.d.ts.map +1 -1
- package/dist/general/utils/caller.js +11 -9
- package/dist/general/utils/casting.d.ts +4 -4
- package/dist/general/utils/casting.d.ts.map +1 -1
- package/dist/general/utils/casting.js +22 -22
- package/dist/general/utils/fixed.d.ts +5 -0
- package/dist/general/utils/fixed.d.ts.map +1 -1
- package/dist/general/utils/fixed.js +4 -0
- package/dist/general/utils/helpers.js +21 -21
- package/dist/general/wallet/wallet.js +6 -6
- package/dist/general/wallet/walletApi.js +12 -12
- package/dist/packages/capys/capy.d.ts +4 -4
- package/dist/packages/capys/capy.d.ts.map +1 -1
- package/dist/packages/capys/capy.js +15 -15
- package/dist/packages/coin/api/coinApi.d.ts +18 -5
- package/dist/packages/coin/api/coinApi.d.ts.map +1 -1
- package/dist/packages/coin/api/coinApi.js +109 -15
- package/dist/packages/coin/coin.d.ts +4 -5
- package/dist/packages/coin/coin.d.ts.map +1 -1
- package/dist/packages/coin/coin.js +28 -28
- package/dist/packages/coin/coinTypes.d.ts +4 -0
- package/dist/packages/coin/coinTypes.d.ts.map +1 -1
- package/dist/packages/{referralVault/api/referralVaultApiHelpers.d.ts → external/baySwap/baySwapApi.d.ts} +49 -77
- package/dist/packages/external/baySwap/baySwapApi.d.ts.map +1 -0
- package/dist/packages/external/baySwap/baySwapApi.js +176 -0
- package/dist/packages/external/baySwap/baySwapTypes.d.ts +29 -0
- package/dist/packages/external/baySwap/baySwapTypes.d.ts.map +1 -0
- package/dist/packages/external/baySwap/baySwapTypes.js +15 -0
- package/dist/packages/external/{deepBook/deepBookApiHelper.d.ts → blueMove/blueMoveApi.d.ts} +42 -87
- package/dist/packages/external/blueMove/blueMoveApi.d.ts.map +1 -0
- package/dist/packages/external/blueMove/blueMoveApi.js +249 -0
- package/dist/packages/external/blueMove/blueMoveTypes.d.ts +87 -0
- package/dist/packages/external/blueMove/blueMoveTypes.d.ts.map +1 -0
- package/dist/packages/external/blueMove/blueMoveTypes.js +13 -0
- package/dist/packages/external/cetus/cetusApi.d.ts +240 -11
- package/dist/packages/external/cetus/cetusApi.d.ts.map +1 -1
- package/dist/packages/external/cetus/cetusApi.js +295 -28
- package/dist/packages/external/deepBook/deepBookApi.d.ts +406 -5
- package/dist/packages/external/deepBook/deepBookApi.d.ts.map +1 -1
- package/dist/packages/external/deepBook/deepBookApi.js +332 -35
- package/dist/packages/external/deepBook/deepBookTypes.d.ts +4 -6
- package/dist/packages/external/deepBook/deepBookTypes.d.ts.map +1 -1
- package/dist/packages/external/deepBook/deepBookTypes.js +2 -2
- package/dist/packages/{faucet/api/faucetApiHelpers.d.ts → external/interest/interestApi.d.ts} +45 -19
- package/dist/packages/external/interest/interestApi.d.ts.map +1 -0
- package/dist/packages/external/interest/interestApi.js +178 -0
- package/dist/packages/external/interest/interestTypes.d.ts +37 -0
- package/dist/packages/external/interest/interestTypes.d.ts.map +1 -0
- package/dist/packages/external/interest/interestTypes.js +12 -0
- package/dist/packages/external/kriya/kriyaApi.d.ts +148 -0
- package/dist/packages/external/kriya/kriyaApi.d.ts.map +1 -0
- package/dist/packages/external/kriya/kriyaApi.js +191 -0
- package/dist/packages/external/kriya/kriyaTypes.d.ts +59 -0
- package/dist/packages/external/kriya/kriyaTypes.d.ts.map +1 -0
- package/dist/packages/external/kriya/kriyaTypes.js +16 -0
- package/dist/packages/external/suiswap/suiswapApi.d.ts +145 -0
- package/dist/packages/external/suiswap/suiswapApi.d.ts.map +1 -0
- package/dist/packages/external/suiswap/suiswapApi.js +197 -0
- package/dist/packages/external/suiswap/suiswapTypes.d.ts +75 -0
- package/dist/packages/external/suiswap/suiswapTypes.d.ts.map +1 -0
- package/dist/packages/external/suiswap/suiswapTypes.js +10 -0
- package/dist/packages/external/turbos/turbosApi.d.ts +206 -8
- package/dist/packages/external/turbos/turbosApi.d.ts.map +1 -1
- package/dist/packages/external/turbos/turbosApi.js +471 -27
- package/dist/packages/farms/farmsStakedPosition.d.ts +20 -0
- package/dist/packages/farms/farmsStakedPosition.d.ts.map +1 -0
- package/dist/packages/farms/farmsStakedPosition.js +63 -0
- package/dist/packages/farms/farmsStakingPool.d.ts +9 -0
- package/dist/packages/farms/farmsStakingPool.d.ts.map +1 -0
- package/dist/packages/farms/farmsStakingPool.js +20 -0
- package/dist/packages/farms/farmsTypes.d.ts +37 -0
- package/dist/packages/farms/farmsTypes.d.ts.map +1 -0
- package/dist/packages/farms/index.d.ts +3 -0
- package/dist/packages/farms/index.d.ts.map +1 -0
- package/dist/packages/{capys → farms}/index.js +2 -3
- package/dist/packages/faucet/api/faucetApi.d.ts +117 -8
- package/dist/packages/faucet/api/faucetApi.d.ts.map +1 -1
- package/dist/packages/faucet/api/faucetApi.js +112 -27
- package/dist/packages/faucet/api/faucetApiCasting.js +3 -3
- package/dist/packages/faucet/faucet.js +15 -15
- package/dist/packages/index.d.ts +3 -1
- package/dist/packages/index.d.ts.map +1 -1
- package/dist/packages/index.js +3 -1
- package/dist/packages/nftAmm/api/nftAmmApi.d.ts +168 -16
- package/dist/packages/nftAmm/api/nftAmmApi.d.ts.map +1 -1
- package/dist/packages/nftAmm/api/nftAmmApi.js +227 -33
- package/dist/packages/nftAmm/api/nftAmmApiCasting.js +12 -12
- package/dist/packages/nftAmm/nftAmm.js +12 -12
- package/dist/packages/nftAmm/nftAmmMarket.js +15 -15
- package/dist/packages/perpetuals/api/perpetualsApi.d.ts +650 -0
- package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +1 -0
- package/dist/packages/perpetuals/api/perpetualsApi.js +387 -0
- package/dist/packages/perpetuals/api/perpetualsCasting.d.ts +22 -0
- package/dist/packages/perpetuals/api/perpetualsCasting.d.ts.map +1 -0
- package/dist/packages/perpetuals/api/perpetualsCasting.js +201 -0
- package/dist/packages/perpetuals/index.d.ts +4 -0
- package/dist/packages/perpetuals/index.d.ts.map +1 -0
- package/dist/{external/nojo → packages/perpetuals}/index.js +3 -5
- package/dist/packages/perpetuals/perpetuals.d.ts +17 -0
- package/dist/packages/perpetuals/perpetuals.d.ts.map +1 -0
- package/dist/packages/perpetuals/perpetuals.js +50 -0
- package/dist/packages/perpetuals/perpetualsAccount.d.ts +22 -0
- package/dist/packages/perpetuals/perpetualsAccount.d.ts.map +1 -0
- package/dist/packages/perpetuals/perpetualsAccount.js +65 -0
- package/dist/packages/perpetuals/perpetualsMarket.d.ts +20 -0
- package/dist/packages/perpetuals/perpetualsMarket.d.ts.map +1 -0
- package/dist/packages/perpetuals/perpetualsMarket.js +52 -0
- package/dist/packages/perpetuals/perpetualsTypes.d.ts +184 -0
- package/dist/packages/perpetuals/perpetualsTypes.d.ts.map +1 -0
- package/dist/packages/perpetuals/utils/comparators.d.ts +4 -0
- package/dist/packages/perpetuals/utils/comparators.d.ts.map +1 -0
- package/dist/packages/perpetuals/utils/comparators.js +25 -0
- package/dist/packages/perpetuals/utils/critBitTreeUtils.d.ts +7 -0
- package/dist/packages/perpetuals/utils/critBitTreeUtils.d.ts.map +1 -0
- package/dist/packages/perpetuals/utils/critBitTreeUtils.js +40 -0
- package/dist/packages/perpetuals/utils/helpers.d.ts +5 -0
- package/dist/packages/perpetuals/utils/helpers.d.ts.map +1 -0
- package/dist/packages/perpetuals/utils/helpers.js +9 -0
- package/dist/packages/perpetuals/utils/index.d.ts +4 -0
- package/dist/packages/perpetuals/utils/index.d.ts.map +1 -0
- package/dist/packages/perpetuals/utils/index.js +19 -0
- package/dist/packages/pools/api/poolsApi.d.ts +261 -35
- package/dist/packages/pools/api/poolsApi.d.ts.map +1 -1
- package/dist/packages/pools/api/poolsApi.js +621 -130
- package/dist/packages/pools/api/poolsApiCasting.d.ts.map +1 -1
- package/dist/packages/pools/api/poolsApiCasting.js +10 -7
- package/dist/packages/pools/api/poolsApiCastingTypes.d.ts +4 -1
- package/dist/packages/pools/api/poolsApiCastingTypes.d.ts.map +1 -1
- package/dist/packages/pools/pool.d.ts.map +1 -1
- package/dist/packages/pools/pool.js +22 -19
- package/dist/packages/pools/pools.js +34 -34
- package/dist/packages/pools/poolsTypes.d.ts +9 -1
- package/dist/packages/pools/poolsTypes.d.ts.map +1 -1
- package/dist/packages/pools/utils/cmmmCalculations.d.ts.map +1 -1
- package/dist/packages/pools/utils/cmmmCalculations.js +81 -77
- package/dist/packages/referralVault/api/referralVaultApi.d.ts +166 -4
- package/dist/packages/referralVault/api/referralVaultApi.d.ts.map +1 -1
- package/dist/packages/referralVault/api/referralVaultApi.js +80 -14
- package/dist/packages/referralVault/referralVault.js +9 -9
- package/dist/packages/router/api/routerApi.d.ts +14 -5
- package/dist/packages/router/api/routerApi.d.ts.map +1 -1
- package/dist/packages/router/api/routerApi.js +40 -25
- package/dist/packages/router/api/routerApiCasting.d.ts +6 -0
- package/dist/packages/router/api/routerApiCasting.d.ts.map +1 -0
- package/dist/packages/router/api/routerApiCasting.js +22 -0
- package/dist/packages/router/api/routerApiCastingTypes.d.ts +11 -0
- package/dist/packages/router/api/routerApiCastingTypes.d.ts.map +1 -0
- package/dist/packages/router/api/routerApiHelpers.js +30 -30
- package/dist/packages/router/api/routerAsyncApiHelpers.js +18 -18
- package/dist/packages/router/api/routerSynchronousApiHelpers.d.ts +88 -3
- package/dist/packages/router/api/routerSynchronousApiHelpers.d.ts.map +1 -1
- package/dist/packages/router/api/routerSynchronousApiHelpers.js +125 -28
- package/dist/packages/router/router.d.ts +2 -1
- package/dist/packages/router/router.d.ts.map +1 -1
- package/dist/packages/router/router.js +23 -15
- package/dist/packages/router/routerTypes.d.ts +19 -5
- package/dist/packages/router/routerTypes.d.ts.map +1 -1
- package/dist/packages/router/routerTypes.js +5 -1
- package/dist/packages/router/utils/async/routerAsyncApiInterface.d.ts +1 -8
- package/dist/packages/router/utils/async/routerAsyncApiInterface.d.ts.map +1 -1
- package/dist/packages/router/utils/async/routerAsyncGraph.js +15 -15
- package/dist/packages/router/utils/synchronous/interfaces/routerPoolInterface.d.ts +5 -2
- package/dist/packages/router/utils/synchronous/interfaces/routerPoolInterface.d.ts.map +1 -1
- package/dist/packages/router/utils/synchronous/interfaces/routerPoolInterface.js +30 -14
- package/dist/packages/router/utils/synchronous/routerGraph.js +36 -36
- package/dist/packages/router/utils/synchronous/routerPools/aftermathRouterPool.d.ts +5 -2
- package/dist/packages/router/utils/synchronous/routerPools/aftermathRouterPool.d.ts.map +1 -1
- package/dist/packages/router/utils/synchronous/routerPools/aftermathRouterPool.js +18 -16
- package/dist/packages/router/utils/synchronous/routerPools/baySwapRouterPool.d.ts +102 -0
- package/dist/packages/router/utils/synchronous/routerPools/baySwapRouterPool.d.ts.map +1 -0
- package/dist/packages/router/utils/synchronous/routerPools/baySwapRouterPool.js +217 -0
- package/dist/packages/router/utils/synchronous/routerPools/blueMoveRouterPool.d.ts +102 -0
- package/dist/packages/router/utils/synchronous/routerPools/blueMoveRouterPool.d.ts.map +1 -0
- package/dist/packages/router/utils/synchronous/routerPools/blueMoveRouterPool.js +221 -0
- package/dist/packages/router/utils/synchronous/routerPools/cetusRouterPool.d.ts +5 -2
- package/dist/packages/router/utils/synchronous/routerPools/cetusRouterPool.d.ts.map +1 -1
- package/dist/packages/router/utils/synchronous/routerPools/cetusRouterPool.js +11 -11
- package/dist/packages/router/utils/synchronous/routerPools/deepBookRouterPool.d.ts +5 -2
- package/dist/packages/router/utils/synchronous/routerPools/deepBookRouterPool.d.ts.map +1 -1
- package/dist/packages/router/utils/synchronous/routerPools/deepBookRouterPool.js +16 -16
- package/dist/packages/router/utils/synchronous/routerPools/interestRouterPool.d.ts +96 -0
- package/dist/packages/router/utils/synchronous/routerPools/interestRouterPool.d.ts.map +1 -0
- package/dist/packages/router/utils/synchronous/routerPools/interestRouterPool.js +174 -0
- package/dist/packages/router/utils/synchronous/routerPools/kriyaRouterPool.d.ts +102 -0
- package/dist/packages/router/utils/synchronous/routerPools/kriyaRouterPool.d.ts.map +1 -0
- package/dist/packages/router/utils/synchronous/routerPools/kriyaRouterPool.js +216 -0
- package/dist/packages/router/utils/synchronous/routerPools/{nojoRouterPool.d.ts → suiswapRouterPool.d.ts} +35 -14
- package/dist/packages/router/utils/synchronous/routerPools/suiswapRouterPool.d.ts.map +1 -0
- package/dist/packages/router/utils/synchronous/routerPools/suiswapRouterPool.js +217 -0
- package/dist/packages/router/utils/synchronous/routerPools/turbosRouterPool.d.ts +5 -2
- package/dist/packages/router/utils/synchronous/routerPools/turbosRouterPool.d.ts.map +1 -1
- package/dist/packages/router/utils/synchronous/routerPools/turbosRouterPool.js +11 -11
- package/dist/packages/staking/api/stakingApi.d.ts +173 -10
- package/dist/packages/staking/api/stakingApi.d.ts.map +1 -1
- package/dist/packages/staking/api/stakingApi.js +373 -32
- package/dist/packages/staking/api/stakingApiCasting.d.ts.map +1 -1
- package/dist/packages/staking/api/stakingApiCasting.js +6 -6
- package/dist/packages/staking/staking.js +18 -18
- package/dist/packages/sui/api/suiApi.d.ts +0 -2
- package/dist/packages/sui/api/suiApi.d.ts.map +1 -1
- package/dist/packages/sui/api/suiApi.js +9 -9
- package/dist/packages/sui/sui.js +9 -9
- package/dist/packages/suiFrens/api/suiFrensApi.d.ts +80 -0
- package/dist/packages/suiFrens/api/suiFrensApi.d.ts.map +1 -0
- package/dist/packages/suiFrens/api/suiFrensApi.js +564 -0
- package/dist/packages/suiFrens/api/suiFrensApiCasting.d.ts +13 -0
- package/dist/packages/suiFrens/api/suiFrensApiCasting.d.ts.map +1 -0
- package/dist/packages/suiFrens/api/suiFrensApiCasting.js +108 -0
- package/dist/packages/suiFrens/api/suiFrensApiCastingTypes.d.ts +51 -0
- package/dist/packages/suiFrens/api/suiFrensApiCastingTypes.d.ts.map +1 -0
- package/dist/packages/suiFrens/api/suiFrensApiCastingTypes.js +2 -0
- package/dist/packages/suiFrens/index.d.ts +4 -0
- package/dist/packages/suiFrens/index.d.ts.map +1 -0
- package/dist/packages/suiFrens/index.js +19 -0
- package/dist/packages/suiFrens/stakedSuiFrenReceipt.d.ts +13 -0
- package/dist/packages/suiFrens/stakedSuiFrenReceipt.d.ts.map +1 -0
- package/dist/packages/{capys/stakedCapyReceipt.js → suiFrens/stakedSuiFrenReceipt.js} +21 -21
- package/dist/packages/suiFrens/suiFren.d.ts +10 -0
- package/dist/packages/suiFrens/suiFren.d.ts.map +1 -0
- package/dist/packages/suiFrens/suiFren.js +39 -0
- package/dist/packages/suiFrens/suiFrens.d.ts +32 -0
- package/dist/packages/suiFrens/suiFrens.d.ts.map +1 -0
- package/dist/packages/suiFrens/suiFrens.js +143 -0
- package/dist/packages/suiFrens/suiFrensTypes.d.ts +89 -0
- package/dist/packages/suiFrens/suiFrensTypes.d.ts.map +1 -0
- package/dist/packages/suiFrens/suiFrensTypes.js +2 -0
- package/dist/types.d.ts +3 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -2
- package/package.json +12 -5
- package/dist/external/nojo/amm/index.d.ts +0 -2
- package/dist/external/nojo/amm/index.d.ts.map +0 -1
- package/dist/external/nojo/amm/index.js +0 -4
- package/dist/external/nojo/amm/init.d.ts +0 -3
- package/dist/external/nojo/amm/init.d.ts.map +0 -1
- package/dist/external/nojo/amm/init.js +0 -31
- package/dist/external/nojo/amm/pool/errors.d.ts +0 -41
- package/dist/external/nojo/amm/pool/errors.d.ts.map +0 -1
- package/dist/external/nojo/amm/pool/errors.js +0 -75
- package/dist/external/nojo/amm/pool/functions.d.ts +0 -356
- package/dist/external/nojo/amm/pool/functions.d.ts.map +0 -1
- package/dist/external/nojo/amm/pool/functions.js +0 -173
- package/dist/external/nojo/amm/pool/structs.d.ts +0 -94
- package/dist/external/nojo/amm/pool/structs.d.ts.map +0 -1
- package/dist/external/nojo/amm/pool/structs.js +0 -278
- package/dist/external/nojo/amm/util/functions.d.ts +0 -359
- package/dist/external/nojo/amm/util/functions.d.ts.map +0 -1
- package/dist/external/nojo/amm/util/functions.js +0 -198
- package/dist/external/nojo/framework/balance.d.ts +0 -19
- package/dist/external/nojo/framework/balance.d.ts.map +0 -1
- package/dist/external/nojo/framework/balance.js +0 -44
- package/dist/external/nojo/framework/bcs.d.ts +0 -3
- package/dist/external/nojo/framework/bcs.d.ts.map +0 -1
- package/dist/external/nojo/framework/bcs.js +0 -5
- package/dist/external/nojo/framework/coin.d.ts +0 -42
- package/dist/external/nojo/framework/coin.d.ts.map +0 -1
- package/dist/external/nojo/framework/coin.js +0 -144
- package/dist/external/nojo/framework/dynamic-field.d.ts +0 -25
- package/dist/external/nojo/framework/dynamic-field.d.ts.map +0 -1
- package/dist/external/nojo/framework/dynamic-field.js +0 -89
- package/dist/external/nojo/framework/init.d.ts +0 -3
- package/dist/external/nojo/framework/init.d.ts.map +0 -1
- package/dist/external/nojo/framework/init.js +0 -41
- package/dist/external/nojo/framework/loader.d.ts +0 -12
- package/dist/external/nojo/framework/loader.d.ts.map +0 -1
- package/dist/external/nojo/framework/loader.js +0 -103
- package/dist/external/nojo/framework/object.d.ts +0 -33
- package/dist/external/nojo/framework/object.d.ts.map +0 -1
- package/dist/external/nojo/framework/object.js +0 -89
- package/dist/external/nojo/framework/table.d.ts +0 -23
- package/dist/external/nojo/framework/table.d.ts.map +0 -1
- package/dist/external/nojo/framework/table.js +0 -83
- package/dist/external/nojo/framework/type-name.d.ts +0 -15
- package/dist/external/nojo/framework/type-name.d.ts.map +0 -1
- package/dist/external/nojo/framework/type-name.js +0 -34
- package/dist/external/nojo/framework/type.d.ts +0 -24
- package/dist/external/nojo/framework/type.d.ts.map +0 -1
- package/dist/external/nojo/framework/type.js +0 -120
- package/dist/external/nojo/framework/util.d.ts +0 -31
- package/dist/external/nojo/framework/util.d.ts.map +0 -1
- package/dist/external/nojo/framework/util.js +0 -49
- package/dist/external/nojo/index.d.ts +0 -6
- package/dist/external/nojo/index.d.ts.map +0 -1
- package/dist/external/nojo/init.d.ts +0 -2
- package/dist/external/nojo/init.d.ts.map +0 -1
- package/dist/external/nojo/init.js +0 -39
- package/dist/packages/capys/api/capysApi.d.ts +0 -37
- package/dist/packages/capys/api/capysApi.d.ts.map +0 -1
- package/dist/packages/capys/api/capysApi.js +0 -200
- package/dist/packages/capys/api/capysApiCasting.d.ts +0 -13
- package/dist/packages/capys/api/capysApiCasting.d.ts.map +0 -1
- package/dist/packages/capys/api/capysApiCasting.js +0 -108
- package/dist/packages/capys/api/capysApiCastingTypes.d.ts +0 -51
- package/dist/packages/capys/api/capysApiCastingTypes.d.ts.map +0 -1
- package/dist/packages/capys/api/capysApiHelpers.d.ts +0 -48
- package/dist/packages/capys/api/capysApiHelpers.d.ts.map +0 -1
- package/dist/packages/capys/api/capysApiHelpers.js +0 -386
- package/dist/packages/capys/capys.d.ts +0 -32
- package/dist/packages/capys/capys.d.ts.map +0 -1
- package/dist/packages/capys/capys.js +0 -151
- package/dist/packages/capys/capysTypes.d.ts +0 -89
- package/dist/packages/capys/capysTypes.d.ts.map +0 -1
- package/dist/packages/capys/index.d.ts +0 -4
- package/dist/packages/capys/index.d.ts.map +0 -1
- package/dist/packages/capys/stakedCapyReceipt.d.ts +0 -14
- package/dist/packages/capys/stakedCapyReceipt.d.ts.map +0 -1
- package/dist/packages/coin/api/coinApiHelpers.d.ts +0 -23
- package/dist/packages/coin/api/coinApiHelpers.d.ts.map +0 -1
- package/dist/packages/coin/api/coinApiHelpers.js +0 -203
- package/dist/packages/external/cetus/cetusApiHelpers.d.ts +0 -247
- package/dist/packages/external/cetus/cetusApiHelpers.d.ts.map +0 -1
- package/dist/packages/external/cetus/cetusApiHelpers.js +0 -303
- package/dist/packages/external/deepBook/deepBookApiHelper.d.ts.map +0 -1
- package/dist/packages/external/deepBook/deepBookApiHelper.js +0 -193
- package/dist/packages/external/nojo/nojoAmmApi.d.ts +0 -24
- package/dist/packages/external/nojo/nojoAmmApi.d.ts.map +0 -1
- package/dist/packages/external/nojo/nojoAmmApi.js +0 -86
- package/dist/packages/external/nojo/nojoAmmApiHelpers.d.ts +0 -14
- package/dist/packages/external/nojo/nojoAmmApiHelpers.d.ts.map +0 -1
- package/dist/packages/external/nojo/nojoAmmApiHelpers.js +0 -69
- package/dist/packages/external/nojo/nojoAmmTypes.d.ts +0 -9
- package/dist/packages/external/nojo/nojoAmmTypes.d.ts.map +0 -1
- package/dist/packages/external/nojo/nojoAmmTypes.js +0 -7
- package/dist/packages/external/turbos/turbosApiHelpers.d.ts +0 -205
- package/dist/packages/external/turbos/turbosApiHelpers.d.ts.map +0 -1
- package/dist/packages/external/turbos/turbosApiHelpers.js +0 -325
- package/dist/packages/faucet/api/faucetApiHelpers.d.ts.map +0 -1
- package/dist/packages/faucet/api/faucetApiHelpers.js +0 -90
- package/dist/packages/nftAmm/api/nftAmmApiHelpers.d.ts +0 -193
- package/dist/packages/nftAmm/api/nftAmmApiHelpers.d.ts.map +0 -1
- package/dist/packages/nftAmm/api/nftAmmApiHelpers.js +0 -238
- package/dist/packages/pools/api/poolsApiHelpers.d.ts +0 -204
- package/dist/packages/pools/api/poolsApiHelpers.d.ts.map +0 -1
- package/dist/packages/pools/api/poolsApiHelpers.js +0 -523
- package/dist/packages/referralVault/api/referralVaultApiHelpers.d.ts.map +0 -1
- package/dist/packages/referralVault/api/referralVaultApiHelpers.js +0 -86
- package/dist/packages/router/utils/synchronous/routerPools/nojoRouterPool.d.ts.map +0 -1
- package/dist/packages/router/utils/synchronous/routerPools/nojoRouterPool.js +0 -99
- package/dist/packages/staking/api/stakingApiHelpers.d.ts +0 -212
- package/dist/packages/staking/api/stakingApiHelpers.d.ts.map +0 -1
- package/dist/packages/staking/api/stakingApiHelpers.js +0 -400
- package/dist/packages/sui/api/suiApiCasting.d.ts +0 -3
- package/dist/packages/sui/api/suiApiCasting.d.ts.map +0 -1
- package/dist/packages/sui/api/suiApiCasting.js +0 -6
- package/dist/packages/sui/api/suiApiCastingTypes.d.ts +0 -2
- package/dist/packages/sui/api/suiApiCastingTypes.d.ts.map +0 -1
- package/dist/packages/sui/api/suiApiHelpers.d.ts +0 -6
- package/dist/packages/sui/api/suiApiHelpers.d.ts.map +0 -1
- package/dist/packages/sui/api/suiApiHelpers.js +0 -13
- /package/dist/packages/{capys/api/capysApiCastingTypes.js → farms/farmsTypes.js} +0 -0
- /package/dist/packages/{capys/capysTypes.js → perpetuals/perpetualsTypes.js} +0 -0
- /package/dist/packages/{sui/api/suiApiCastingTypes.js → router/api/routerApiCastingTypes.js} +0 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../../../../../general/utils");
|
|
4
|
+
const baySwapApi_1 = require("../../../../external/baySwap/baySwapApi");
|
|
5
|
+
class BaySwapRouterPool {
|
|
6
|
+
// =========================================================================
|
|
7
|
+
// Constructor
|
|
8
|
+
// =========================================================================
|
|
9
|
+
constructor(pool, network) {
|
|
10
|
+
// =========================================================================
|
|
11
|
+
// Constants
|
|
12
|
+
// =========================================================================
|
|
13
|
+
this.protocolName = "BaySwap";
|
|
14
|
+
// TODO: update gas price
|
|
15
|
+
this.expectedGasCostPerHop = BigInt(50000000); // 0.05 SUI
|
|
16
|
+
this.noHopsAllowed = false;
|
|
17
|
+
// =========================================================================
|
|
18
|
+
// Public Interface
|
|
19
|
+
// =========================================================================
|
|
20
|
+
this.getSpotPrice = (inputs) => {
|
|
21
|
+
// TODO: do this calc correctly
|
|
22
|
+
let smallAmountIn = BigInt(100000);
|
|
23
|
+
while (smallAmountIn < utils_1.Casting.u64MaxBigInt) {
|
|
24
|
+
try {
|
|
25
|
+
const smallAmountOut = this.getTradeAmountOut(Object.assign(Object.assign({}, inputs), { coinInAmount: smallAmountIn }));
|
|
26
|
+
if (smallAmountOut <= BigInt(0))
|
|
27
|
+
throw new Error("0 amount out");
|
|
28
|
+
return Number(smallAmountIn) / Number(smallAmountOut);
|
|
29
|
+
}
|
|
30
|
+
catch (e) { }
|
|
31
|
+
smallAmountIn *= BigInt(10);
|
|
32
|
+
}
|
|
33
|
+
// this shouldn't be reached
|
|
34
|
+
return 1;
|
|
35
|
+
};
|
|
36
|
+
// TODO: calc by taking into account fee amount
|
|
37
|
+
this.getTradeAmountOut = (inputs) => {
|
|
38
|
+
const coinInReserve = this.getPoolBalance(inputs.coinInType);
|
|
39
|
+
const coinOutReserve = this.getPoolBalance(inputs.coinOutType);
|
|
40
|
+
if (this.pool.isStable) {
|
|
41
|
+
const isCoinInX = baySwapApi_1.BaySwapApi.isCoinX({
|
|
42
|
+
pool: this.pool,
|
|
43
|
+
coinType: inputs.coinInType,
|
|
44
|
+
});
|
|
45
|
+
const { recievedAmount } = this.getSwapAmountStable(coinInReserve, coinOutReserve, Number(isCoinInX ? this.pool.xScale : this.pool.yScale), Number(isCoinInX ? this.pool.yScale : this.pool.xScale), Number(inputs.coinInAmount));
|
|
46
|
+
return BigInt(Math.floor(recievedAmount));
|
|
47
|
+
}
|
|
48
|
+
const { recievedAmount } = this.getSwapAmountUncorrelated(coinInReserve, coinOutReserve, Number(inputs.coinInAmount));
|
|
49
|
+
return BigInt(Math.floor(recievedAmount));
|
|
50
|
+
};
|
|
51
|
+
this.tradeTx = (inputs) => {
|
|
52
|
+
return inputs.provider
|
|
53
|
+
.Router()
|
|
54
|
+
.BaySwap()
|
|
55
|
+
.tradeTx(Object.assign(Object.assign({}, inputs), { pool: this.pool, coinInId: inputs.coinIn, minAmountOut: BigInt(0) }));
|
|
56
|
+
};
|
|
57
|
+
this.getTradeAmountIn = (inputs) => {
|
|
58
|
+
throw new Error("not implemented");
|
|
59
|
+
};
|
|
60
|
+
this.getUpdatedPoolBeforeTrade = (inputs) => {
|
|
61
|
+
return this.getUpdatedPoolAfterTrade(Object.assign(Object.assign({}, inputs), { coinInAmount: -inputs.coinInAmount, coinOutAmount: -inputs.coinOutAmount }));
|
|
62
|
+
};
|
|
63
|
+
this.getUpdatedPoolAfterTrade = (inputs) => {
|
|
64
|
+
const isCoinInX = baySwapApi_1.BaySwapApi.isCoinX({
|
|
65
|
+
coinType: inputs.coinInType,
|
|
66
|
+
pool: this.pool,
|
|
67
|
+
});
|
|
68
|
+
let newPoolObject = utils_1.Helpers.deepCopy(this.pool);
|
|
69
|
+
newPoolObject.coinXReserveValue += isCoinInX
|
|
70
|
+
? inputs.coinInAmount
|
|
71
|
+
: -inputs.coinOutAmount;
|
|
72
|
+
newPoolObject.coinYReserveValue += isCoinInX
|
|
73
|
+
? -inputs.coinOutAmount
|
|
74
|
+
: inputs.coinInAmount;
|
|
75
|
+
return new BaySwapRouterPool(utils_1.Helpers.deepCopy(newPoolObject), this.network);
|
|
76
|
+
};
|
|
77
|
+
// =========================================================================
|
|
78
|
+
// Private Helpers
|
|
79
|
+
// =========================================================================
|
|
80
|
+
this.getPoolBalance = (coinType) => {
|
|
81
|
+
return Number(baySwapApi_1.BaySwapApi.isCoinX({ coinType, pool: this.pool })
|
|
82
|
+
? this.pool.coinXReserveValue
|
|
83
|
+
: this.pool.coinYReserveValue);
|
|
84
|
+
};
|
|
85
|
+
// =========================================================================
|
|
86
|
+
// Private Calculations
|
|
87
|
+
// =========================================================================
|
|
88
|
+
this.getSwapAmountStable = (reserveA, reserveB, scaleA, scaleB, amount, totalFeeRate = 0) => {
|
|
89
|
+
let amountToSwapA = amount / 2;
|
|
90
|
+
let counter = 0;
|
|
91
|
+
let left = 0, right = amount;
|
|
92
|
+
let recievedAmountB = 0;
|
|
93
|
+
// max 100 iterations for search
|
|
94
|
+
while (counter < 100) {
|
|
95
|
+
recievedAmountB = this.get_input_price_stable(amountToSwapA, reserveA, reserveB, totalFeeRate, scaleA, scaleB);
|
|
96
|
+
let userRatio = recievedAmountB / (amount - amountToSwapA);
|
|
97
|
+
// we are adding to reserveA, removing from reserveB
|
|
98
|
+
let reserveRatio = (Number(reserveB) - Number(recievedAmountB)) /
|
|
99
|
+
(Number(reserveA) + Number(amountToSwapA));
|
|
100
|
+
if (userRatio > reserveRatio) {
|
|
101
|
+
right = amountToSwapA;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
left = amountToSwapA;
|
|
105
|
+
}
|
|
106
|
+
amountToSwapA = (left + right) / 2;
|
|
107
|
+
counter += 1;
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
amountToSwap: amountToSwapA,
|
|
111
|
+
recievedAmount: recievedAmountB,
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
this.getSwapAmountUncorrelated = (reserveA, reserveB, amount, totalFeeRate = 0) => {
|
|
115
|
+
let amountToSwapA = amount / 2;
|
|
116
|
+
let counter = 0;
|
|
117
|
+
let left = 0, right = amount;
|
|
118
|
+
let recievedAmountB = 0;
|
|
119
|
+
while (counter < 100) {
|
|
120
|
+
recievedAmountB = this.get_input_price_uncorrelated(amountToSwapA, reserveA, reserveB, totalFeeRate);
|
|
121
|
+
let userRatio = recievedAmountB / (amount - amountToSwapA);
|
|
122
|
+
let reserveRatio = (Number(reserveB) - Number(recievedAmountB)) /
|
|
123
|
+
(Number(reserveA) + Number(amountToSwapA));
|
|
124
|
+
if (userRatio > reserveRatio) {
|
|
125
|
+
right = amountToSwapA;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
left = amountToSwapA;
|
|
129
|
+
}
|
|
130
|
+
amountToSwapA = (left + right) / 2;
|
|
131
|
+
counter += 1;
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
amountToSwap: amountToSwapA,
|
|
135
|
+
recievedAmount: recievedAmountB,
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
this.get_input_price_uncorrelated = (input_amount, input_reserve, output_reserve, fee_percent) => {
|
|
139
|
+
let input_amount_with_fee = input_amount * (BaySwapRouterPool.FEE_SCALING - fee_percent);
|
|
140
|
+
let numerator = input_amount_with_fee * output_reserve;
|
|
141
|
+
let denominator = input_reserve * BaySwapRouterPool.FEE_SCALING +
|
|
142
|
+
input_amount_with_fee;
|
|
143
|
+
return numerator / denominator;
|
|
144
|
+
};
|
|
145
|
+
this.get_input_price_stable = (input_amount, input_reserve, output_reserve, fee_percent, input_scale, output_scale) => {
|
|
146
|
+
let u2561e8 = BaySwapRouterPool.ONE_E_8;
|
|
147
|
+
let xy = this.lp_value(input_reserve, input_scale, output_reserve, output_scale);
|
|
148
|
+
let reserve_in_u256 = (input_reserve * u2561e8) / input_scale;
|
|
149
|
+
let reserve_out_u256 = (output_reserve * u2561e8) / output_scale;
|
|
150
|
+
let amount_in = (input_amount * u2561e8) / input_scale;
|
|
151
|
+
let amount_in_with_fees_scaling = (amount_in * (BaySwapRouterPool.FEE_SCALING - fee_percent)) /
|
|
152
|
+
BaySwapRouterPool.FEE_SCALING;
|
|
153
|
+
let total_reserve = amount_in_with_fees_scaling + reserve_in_u256;
|
|
154
|
+
let y = reserve_out_u256 - this.get_y(total_reserve, xy, reserve_out_u256);
|
|
155
|
+
let r = (y * output_scale) / u2561e8;
|
|
156
|
+
return r;
|
|
157
|
+
};
|
|
158
|
+
this.lp_value = (x_coin, x_scale, y_coin, y_scale) => {
|
|
159
|
+
let _x = (x_coin * BaySwapRouterPool.ONE_E_8) / x_scale;
|
|
160
|
+
let _y = (y_coin * BaySwapRouterPool.ONE_E_8) / y_scale;
|
|
161
|
+
let xy = _x * _y;
|
|
162
|
+
let x2_y2 = _x * _x + _y * _y;
|
|
163
|
+
return xy * x2_y2;
|
|
164
|
+
};
|
|
165
|
+
this.get_y = (x0, xy, y) => {
|
|
166
|
+
let i = 0;
|
|
167
|
+
let one_u256 = 1;
|
|
168
|
+
while (i < 255) {
|
|
169
|
+
let k = this.calcF(x0, y);
|
|
170
|
+
let _dy = 0;
|
|
171
|
+
if (xy > k) {
|
|
172
|
+
_dy = (xy - k) / this.calcD(x0, y) + one_u256; // Round up
|
|
173
|
+
y = y + _dy;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
_dy = (k - xy) / this.calcD(x0, y) + one_u256;
|
|
177
|
+
y = y - _dy;
|
|
178
|
+
}
|
|
179
|
+
if (_dy <= one_u256) {
|
|
180
|
+
return y;
|
|
181
|
+
}
|
|
182
|
+
i = i + 1;
|
|
183
|
+
}
|
|
184
|
+
return y;
|
|
185
|
+
};
|
|
186
|
+
this.calcF = (x0_u256, y_u256) => {
|
|
187
|
+
// x0*(y*y/1e18*y/1e18)/1e18
|
|
188
|
+
let yy = y_u256 * y_u256;
|
|
189
|
+
let yyy = yy * y_u256;
|
|
190
|
+
let a = x0_u256 * yyy;
|
|
191
|
+
//(x0*x0/1e18*x0/1e18)*y/1e18
|
|
192
|
+
let xx = x0_u256 * x0_u256;
|
|
193
|
+
let xxx = xx * x0_u256;
|
|
194
|
+
let b = xxx * y_u256;
|
|
195
|
+
// a + b
|
|
196
|
+
return a + b;
|
|
197
|
+
};
|
|
198
|
+
this.calcD = (x0_u256, y_u256) => {
|
|
199
|
+
let three_u256 = 3;
|
|
200
|
+
// 3 * x0 * (y * y / 1e8) / 1e8
|
|
201
|
+
let x3 = three_u256 * x0_u256;
|
|
202
|
+
let yy = y_u256 * y_u256;
|
|
203
|
+
let xyy3 = x3 * yy;
|
|
204
|
+
let xx = x0_u256 * x0_u256;
|
|
205
|
+
// x0 * x0 / 1e8 * x0 / 1e8
|
|
206
|
+
let xxx = xx * x0_u256;
|
|
207
|
+
return xyy3 + xxx;
|
|
208
|
+
};
|
|
209
|
+
this.pool = pool;
|
|
210
|
+
this.network = network;
|
|
211
|
+
this.uid = pool.objectId;
|
|
212
|
+
this.coinTypes = [pool.coinTypeX, pool.coinTypeY];
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
BaySwapRouterPool.FEE_SCALING = 1000000;
|
|
216
|
+
BaySwapRouterPool.ONE_E_8 = 100000000;
|
|
217
|
+
exports.default = BaySwapRouterPool;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { ObjectId, SuiAddress, TransactionArgument, TransactionBlock } from "@mysten/sui.js";
|
|
2
|
+
import { Balance, Slippage, SuiNetwork, UniqueId, Url } from "../../../../../types";
|
|
3
|
+
import { CoinType } from "../../../../coin/coinTypes";
|
|
4
|
+
import { RouterPoolInterface } from "../interfaces/routerPoolInterface";
|
|
5
|
+
import { AftermathApi } from "../../../../../general/providers";
|
|
6
|
+
import { BlueMovePoolObject } from "../../../../external/blueMove/blueMoveTypes";
|
|
7
|
+
declare class BlueMoveRouterPool implements RouterPoolInterface {
|
|
8
|
+
constructor(pool: BlueMovePoolObject, network: SuiNetwork | Url);
|
|
9
|
+
readonly protocolName = "BlueMove";
|
|
10
|
+
readonly expectedGasCostPerHop: bigint;
|
|
11
|
+
readonly noHopsAllowed = false;
|
|
12
|
+
readonly pool: BlueMovePoolObject;
|
|
13
|
+
readonly network: SuiNetwork | Url;
|
|
14
|
+
readonly uid: UniqueId;
|
|
15
|
+
readonly coinTypes: CoinType[];
|
|
16
|
+
private static readonly FEE_SCALING;
|
|
17
|
+
private static readonly ONE_E_8;
|
|
18
|
+
getSpotPrice: (inputs: {
|
|
19
|
+
coinInType: CoinType;
|
|
20
|
+
coinOutType: CoinType;
|
|
21
|
+
}) => number;
|
|
22
|
+
getTradeAmountOut: (inputs: {
|
|
23
|
+
coinInType: CoinType;
|
|
24
|
+
coinInAmount: Balance;
|
|
25
|
+
coinOutType: CoinType;
|
|
26
|
+
referrer?: SuiAddress;
|
|
27
|
+
}) => Balance;
|
|
28
|
+
tradeTx: (inputs: {
|
|
29
|
+
provider: AftermathApi;
|
|
30
|
+
tx: TransactionBlock;
|
|
31
|
+
coinIn: ObjectId | TransactionArgument;
|
|
32
|
+
coinInAmount: Balance;
|
|
33
|
+
coinInType: CoinType;
|
|
34
|
+
coinOutType: CoinType;
|
|
35
|
+
expectedCoinOutAmount: Balance;
|
|
36
|
+
slippage: Slippage;
|
|
37
|
+
tradePotato: TransactionArgument;
|
|
38
|
+
isFirstSwapForPath: boolean;
|
|
39
|
+
isLastSwapForPath: boolean;
|
|
40
|
+
referrer?: SuiAddress;
|
|
41
|
+
}) => ({
|
|
42
|
+
kind: "Input";
|
|
43
|
+
index: number;
|
|
44
|
+
type?: "object" | "pure" | undefined;
|
|
45
|
+
value?: any;
|
|
46
|
+
} | {
|
|
47
|
+
kind: "GasCoin";
|
|
48
|
+
} | {
|
|
49
|
+
kind: "Result";
|
|
50
|
+
index: number;
|
|
51
|
+
} | {
|
|
52
|
+
kind: "NestedResult";
|
|
53
|
+
index: number;
|
|
54
|
+
resultIndex: number;
|
|
55
|
+
}) & ({
|
|
56
|
+
kind: "Input";
|
|
57
|
+
index: number;
|
|
58
|
+
type?: "object" | "pure" | undefined;
|
|
59
|
+
value?: any;
|
|
60
|
+
} | {
|
|
61
|
+
kind: "GasCoin";
|
|
62
|
+
} | {
|
|
63
|
+
kind: "Result";
|
|
64
|
+
index: number;
|
|
65
|
+
} | {
|
|
66
|
+
kind: "NestedResult";
|
|
67
|
+
index: number;
|
|
68
|
+
resultIndex: number;
|
|
69
|
+
})[];
|
|
70
|
+
getTradeAmountIn: (inputs: {
|
|
71
|
+
coinInType: CoinType;
|
|
72
|
+
coinOutAmount: Balance;
|
|
73
|
+
coinOutType: CoinType;
|
|
74
|
+
referrer?: SuiAddress;
|
|
75
|
+
}) => Balance;
|
|
76
|
+
getUpdatedPoolBeforeTrade: (inputs: {
|
|
77
|
+
coinInType: CoinType;
|
|
78
|
+
coinInAmount: Balance;
|
|
79
|
+
coinOutType: CoinType;
|
|
80
|
+
coinOutAmount: Balance;
|
|
81
|
+
}) => RouterPoolInterface;
|
|
82
|
+
getUpdatedPoolAfterTrade: (inputs: {
|
|
83
|
+
coinInType: CoinType;
|
|
84
|
+
coinInAmount: Balance;
|
|
85
|
+
coinOutType: CoinType;
|
|
86
|
+
coinOutAmount: Balance;
|
|
87
|
+
}) => RouterPoolInterface;
|
|
88
|
+
private getPoolBalance;
|
|
89
|
+
private getSwapAmountStable;
|
|
90
|
+
getSwapAmountUncorrelated: (reserveA: number, reserveB: number, amount: number, totalFeeRate?: number) => {
|
|
91
|
+
amountToSwap: number;
|
|
92
|
+
recievedAmount: number;
|
|
93
|
+
};
|
|
94
|
+
private get_input_price_uncorrelated;
|
|
95
|
+
private get_input_price_stable;
|
|
96
|
+
private lp_value;
|
|
97
|
+
private get_y;
|
|
98
|
+
private calcF;
|
|
99
|
+
private calcD;
|
|
100
|
+
}
|
|
101
|
+
export default BlueMoveRouterPool;
|
|
102
|
+
//# sourceMappingURL=blueMoveRouterPool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blueMoveRouterPool.d.ts","sourceRoot":"","sources":["../../../../../../src/packages/router/utils/synchronous/routerPools/blueMoveRouterPool.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,OAAO,EACP,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,GAAG,EACH,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAGjF,cAAM,kBAAmB,YAAW,mBAAmB;gBAK1C,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,UAAU,GAAG,GAAG;IAW/D,QAAQ,CAAC,YAAY,cAAc;IAEnC,QAAQ,CAAC,qBAAqB,SAAsB;IACpD,QAAQ,CAAC,aAAa,SAAS;IAE/B,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,GAAG,CAAC;IACnC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC;IAE/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAW;IAC9C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,OA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CAAC;KACvB,KAAG,mBAAmB,CAmBrB;IAMF,OAAO,CAAC,cAAc,CAMpB;IAMF,OAAO,CAAC,mBAAmB,CA2CzB;IAEF,yBAAyB,aACd,MAAM,YACN,MAAM,UACR,MAAM,iBACA,MAAM;;;MAiCnB;IAEF,OAAO,CAAC,4BAA4B,CAclC;IAEF,OAAO,CAAC,sBAAsB,CA8B5B;IAEF,OAAO,CAAC,QAAQ,CAad;IAEF,OAAO,CAAC,KAAK,CAwBX;IAEF,OAAO,CAAC,KAAK,CAcX;IAEF,OAAO,CAAC,KAAK,CAaX;CACF;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../../../../../general/utils");
|
|
4
|
+
const blueMoveApi_1 = require("../../../../external/blueMove/blueMoveApi");
|
|
5
|
+
class BlueMoveRouterPool {
|
|
6
|
+
// =========================================================================
|
|
7
|
+
// Constructor
|
|
8
|
+
// =========================================================================
|
|
9
|
+
constructor(pool, network) {
|
|
10
|
+
// =========================================================================
|
|
11
|
+
// Constants
|
|
12
|
+
// =========================================================================
|
|
13
|
+
this.protocolName = "BlueMove";
|
|
14
|
+
// TODO: update gas price
|
|
15
|
+
this.expectedGasCostPerHop = BigInt(50000000); // 0.05 SUI
|
|
16
|
+
this.noHopsAllowed = false;
|
|
17
|
+
// =========================================================================
|
|
18
|
+
// Public Interface
|
|
19
|
+
// =========================================================================
|
|
20
|
+
this.getSpotPrice = (inputs) => {
|
|
21
|
+
// TODO: do this calc correctly
|
|
22
|
+
let smallAmountIn = BigInt(100000);
|
|
23
|
+
while (smallAmountIn < utils_1.Casting.u64MaxBigInt) {
|
|
24
|
+
try {
|
|
25
|
+
const smallAmountOut = this.getTradeAmountOut(Object.assign(Object.assign({}, inputs), { coinInAmount: smallAmountIn }));
|
|
26
|
+
if (smallAmountOut <= BigInt(0))
|
|
27
|
+
throw new Error("0 amount out");
|
|
28
|
+
return Number(smallAmountIn) / Number(smallAmountOut);
|
|
29
|
+
}
|
|
30
|
+
catch (e) { }
|
|
31
|
+
smallAmountIn *= BigInt(10);
|
|
32
|
+
}
|
|
33
|
+
// this shouldn't be reached
|
|
34
|
+
return 1;
|
|
35
|
+
};
|
|
36
|
+
// TODO: calc by taking into account fee amount
|
|
37
|
+
this.getTradeAmountOut = (inputs) => {
|
|
38
|
+
const coinInReserve = this.getPoolBalance(inputs.coinInType);
|
|
39
|
+
const coinOutReserve = this.getPoolBalance(inputs.coinOutType);
|
|
40
|
+
if ("stable" in this.pool) {
|
|
41
|
+
const isCoinInX = blueMoveApi_1.BlueMoveApi.isCoinX({
|
|
42
|
+
pool: this.pool,
|
|
43
|
+
coinType: inputs.coinInType,
|
|
44
|
+
});
|
|
45
|
+
const { recievedAmount } = this.getSwapAmountStable(coinInReserve, coinOutReserve, Number(isCoinInX
|
|
46
|
+
? this.pool.stable.xScale
|
|
47
|
+
: this.pool.stable.yScale), Number(isCoinInX
|
|
48
|
+
? this.pool.stable.yScale
|
|
49
|
+
: this.pool.stable.xScale), Number(inputs.coinInAmount));
|
|
50
|
+
return BigInt(Math.floor(recievedAmount));
|
|
51
|
+
}
|
|
52
|
+
const { recievedAmount } = this.getSwapAmountUncorrelated(coinInReserve, coinOutReserve, Number(inputs.coinInAmount));
|
|
53
|
+
return BigInt(Math.floor(recievedAmount));
|
|
54
|
+
};
|
|
55
|
+
this.tradeTx = (inputs) => {
|
|
56
|
+
return inputs.provider
|
|
57
|
+
.Router()
|
|
58
|
+
.BlueMove()
|
|
59
|
+
.tradeTx(Object.assign(Object.assign({}, inputs), { pool: this.pool, coinInId: inputs.coinIn, minAmountOut: BigInt(0) }));
|
|
60
|
+
};
|
|
61
|
+
this.getTradeAmountIn = (inputs) => {
|
|
62
|
+
throw new Error("not implemented");
|
|
63
|
+
};
|
|
64
|
+
this.getUpdatedPoolBeforeTrade = (inputs) => {
|
|
65
|
+
return this.getUpdatedPoolAfterTrade(Object.assign(Object.assign({}, inputs), { coinInAmount: -inputs.coinInAmount, coinOutAmount: -inputs.coinOutAmount }));
|
|
66
|
+
};
|
|
67
|
+
this.getUpdatedPoolAfterTrade = (inputs) => {
|
|
68
|
+
const isCoinInX = blueMoveApi_1.BlueMoveApi.isCoinX({
|
|
69
|
+
coinType: inputs.coinInType,
|
|
70
|
+
pool: this.pool,
|
|
71
|
+
});
|
|
72
|
+
let newPoolObject = utils_1.Helpers.deepCopy(this.pool);
|
|
73
|
+
newPoolObject.tokenXValue += isCoinInX
|
|
74
|
+
? inputs.coinInAmount
|
|
75
|
+
: -inputs.coinOutAmount;
|
|
76
|
+
newPoolObject.tokenYValue += isCoinInX
|
|
77
|
+
? -inputs.coinOutAmount
|
|
78
|
+
: inputs.coinInAmount;
|
|
79
|
+
return new BlueMoveRouterPool(utils_1.Helpers.deepCopy(newPoolObject), this.network);
|
|
80
|
+
};
|
|
81
|
+
// =========================================================================
|
|
82
|
+
// Private Helpers
|
|
83
|
+
// =========================================================================
|
|
84
|
+
this.getPoolBalance = (coinType) => {
|
|
85
|
+
return Number(blueMoveApi_1.BlueMoveApi.isCoinX({ coinType, pool: this.pool })
|
|
86
|
+
? this.pool.tokenXValue
|
|
87
|
+
: this.pool.tokenYValue);
|
|
88
|
+
};
|
|
89
|
+
// =========================================================================
|
|
90
|
+
// Private Calculations
|
|
91
|
+
// =========================================================================
|
|
92
|
+
this.getSwapAmountStable = (reserveA, reserveB, scaleA, scaleB, amount, totalFeeRate = 0) => {
|
|
93
|
+
let amountToSwapA = amount / 2;
|
|
94
|
+
let counter = 0;
|
|
95
|
+
let left = 0, right = amount;
|
|
96
|
+
let recievedAmountB = 0;
|
|
97
|
+
// max 100 iterations for search
|
|
98
|
+
while (counter < 100) {
|
|
99
|
+
recievedAmountB = this.get_input_price_stable(amountToSwapA, reserveA, reserveB, totalFeeRate, scaleA, scaleB);
|
|
100
|
+
let userRatio = recievedAmountB / (amount - amountToSwapA);
|
|
101
|
+
// we are adding to reserveA, removing from reserveB
|
|
102
|
+
let reserveRatio = (Number(reserveB) - Number(recievedAmountB)) /
|
|
103
|
+
(Number(reserveA) + Number(amountToSwapA));
|
|
104
|
+
if (userRatio > reserveRatio) {
|
|
105
|
+
right = amountToSwapA;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
left = amountToSwapA;
|
|
109
|
+
}
|
|
110
|
+
amountToSwapA = (left + right) / 2;
|
|
111
|
+
counter += 1;
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
amountToSwap: amountToSwapA,
|
|
115
|
+
recievedAmount: recievedAmountB,
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
this.getSwapAmountUncorrelated = (reserveA, reserveB, amount, totalFeeRate = 0) => {
|
|
119
|
+
let amountToSwapA = amount / 2;
|
|
120
|
+
let counter = 0;
|
|
121
|
+
let left = 0, right = amount;
|
|
122
|
+
let recievedAmountB = 0;
|
|
123
|
+
while (counter < 100) {
|
|
124
|
+
recievedAmountB = this.get_input_price_uncorrelated(amountToSwapA, reserveA, reserveB, totalFeeRate);
|
|
125
|
+
let userRatio = recievedAmountB / (amount - amountToSwapA);
|
|
126
|
+
let reserveRatio = (Number(reserveB) - Number(recievedAmountB)) /
|
|
127
|
+
(Number(reserveA) + Number(amountToSwapA));
|
|
128
|
+
if (userRatio > reserveRatio) {
|
|
129
|
+
right = amountToSwapA;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
left = amountToSwapA;
|
|
133
|
+
}
|
|
134
|
+
amountToSwapA = (left + right) / 2;
|
|
135
|
+
counter += 1;
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
amountToSwap: amountToSwapA,
|
|
139
|
+
recievedAmount: recievedAmountB,
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
this.get_input_price_uncorrelated = (input_amount, input_reserve, output_reserve, fee_percent) => {
|
|
143
|
+
let input_amount_with_fee = input_amount * (BlueMoveRouterPool.FEE_SCALING - fee_percent);
|
|
144
|
+
let numerator = input_amount_with_fee * output_reserve;
|
|
145
|
+
let denominator = input_reserve * BlueMoveRouterPool.FEE_SCALING +
|
|
146
|
+
input_amount_with_fee;
|
|
147
|
+
return numerator / denominator;
|
|
148
|
+
};
|
|
149
|
+
this.get_input_price_stable = (input_amount, input_reserve, output_reserve, fee_percent, input_scale, output_scale) => {
|
|
150
|
+
let u2561e8 = BlueMoveRouterPool.ONE_E_8;
|
|
151
|
+
let xy = this.lp_value(input_reserve, input_scale, output_reserve, output_scale);
|
|
152
|
+
let reserve_in_u256 = (input_reserve * u2561e8) / input_scale;
|
|
153
|
+
let reserve_out_u256 = (output_reserve * u2561e8) / output_scale;
|
|
154
|
+
let amount_in = (input_amount * u2561e8) / input_scale;
|
|
155
|
+
let amount_in_with_fees_scaling = (amount_in * (BlueMoveRouterPool.FEE_SCALING - fee_percent)) /
|
|
156
|
+
BlueMoveRouterPool.FEE_SCALING;
|
|
157
|
+
let total_reserve = amount_in_with_fees_scaling + reserve_in_u256;
|
|
158
|
+
let y = reserve_out_u256 - this.get_y(total_reserve, xy, reserve_out_u256);
|
|
159
|
+
let r = (y * output_scale) / u2561e8;
|
|
160
|
+
return r;
|
|
161
|
+
};
|
|
162
|
+
this.lp_value = (x_coin, x_scale, y_coin, y_scale) => {
|
|
163
|
+
let _x = (x_coin * BlueMoveRouterPool.ONE_E_8) / x_scale;
|
|
164
|
+
let _y = (y_coin * BlueMoveRouterPool.ONE_E_8) / y_scale;
|
|
165
|
+
let xy = _x * _y;
|
|
166
|
+
let x2_y2 = _x * _x + _y * _y;
|
|
167
|
+
return xy * x2_y2;
|
|
168
|
+
};
|
|
169
|
+
this.get_y = (x0, xy, y) => {
|
|
170
|
+
let i = 0;
|
|
171
|
+
let one_u256 = 1;
|
|
172
|
+
while (i < 255) {
|
|
173
|
+
let k = this.calcF(x0, y);
|
|
174
|
+
let _dy = 0;
|
|
175
|
+
if (xy > k) {
|
|
176
|
+
_dy = (xy - k) / this.calcD(x0, y) + one_u256; // Round up
|
|
177
|
+
y = y + _dy;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
_dy = (k - xy) / this.calcD(x0, y) + one_u256;
|
|
181
|
+
y = y - _dy;
|
|
182
|
+
}
|
|
183
|
+
if (_dy <= one_u256) {
|
|
184
|
+
return y;
|
|
185
|
+
}
|
|
186
|
+
i = i + 1;
|
|
187
|
+
}
|
|
188
|
+
return y;
|
|
189
|
+
};
|
|
190
|
+
this.calcF = (x0_u256, y_u256) => {
|
|
191
|
+
// x0*(y*y/1e18*y/1e18)/1e18
|
|
192
|
+
let yy = y_u256 * y_u256;
|
|
193
|
+
let yyy = yy * y_u256;
|
|
194
|
+
let a = x0_u256 * yyy;
|
|
195
|
+
//(x0*x0/1e18*x0/1e18)*y/1e18
|
|
196
|
+
let xx = x0_u256 * x0_u256;
|
|
197
|
+
let xxx = xx * x0_u256;
|
|
198
|
+
let b = xxx * y_u256;
|
|
199
|
+
// a + b
|
|
200
|
+
return a + b;
|
|
201
|
+
};
|
|
202
|
+
this.calcD = (x0_u256, y_u256) => {
|
|
203
|
+
let three_u256 = 3;
|
|
204
|
+
// 3 * x0 * (y * y / 1e8) / 1e8
|
|
205
|
+
let x3 = three_u256 * x0_u256;
|
|
206
|
+
let yy = y_u256 * y_u256;
|
|
207
|
+
let xyy3 = x3 * yy;
|
|
208
|
+
let xx = x0_u256 * x0_u256;
|
|
209
|
+
// x0 * x0 / 1e8 * x0 / 1e8
|
|
210
|
+
let xxx = xx * x0_u256;
|
|
211
|
+
return xyy3 + xxx;
|
|
212
|
+
};
|
|
213
|
+
this.pool = pool;
|
|
214
|
+
this.network = network;
|
|
215
|
+
this.uid = pool.objectId;
|
|
216
|
+
this.coinTypes = [pool.coinTypeX, pool.coinTypeY];
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
BlueMoveRouterPool.FEE_SCALING = 1000000;
|
|
220
|
+
BlueMoveRouterPool.ONE_E_8 = 100000000;
|
|
221
|
+
exports.default = BlueMoveRouterPool;
|
|
@@ -23,15 +23,18 @@ declare class CetusRouterPool implements RouterPoolInterface {
|
|
|
23
23
|
coinOutType: CoinType;
|
|
24
24
|
referrer?: SuiAddress;
|
|
25
25
|
}) => Balance;
|
|
26
|
-
|
|
26
|
+
tradeTx: (inputs: {
|
|
27
27
|
provider: AftermathApi;
|
|
28
28
|
tx: TransactionBlock;
|
|
29
29
|
coinIn: ObjectId | TransactionArgument;
|
|
30
30
|
coinInAmount: Balance;
|
|
31
31
|
coinInType: CoinType;
|
|
32
32
|
coinOutType: CoinType;
|
|
33
|
-
|
|
33
|
+
expectedCoinOutAmount: Balance;
|
|
34
34
|
slippage: Slippage;
|
|
35
|
+
tradePotato: TransactionArgument;
|
|
36
|
+
isFirstSwapForPath: boolean;
|
|
37
|
+
isLastSwapForPath: boolean;
|
|
35
38
|
referrer?: SuiAddress;
|
|
36
39
|
}) => ({
|
|
37
40
|
kind: "Input";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cetusRouterPool.d.ts","sourceRoot":"","sources":["../../../../../../src/packages/router/utils/synchronous/routerPools/cetusRouterPool.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,OAAO,EACP,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,GAAG,EACH,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,cAAM,eAAgB,YAAW,mBAAmB;gBAKvC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,UAAU,GAAG,GA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C;QACtB,WAAW,EAAE,QAAQ,CAAC;QACtB,aAAa,EAAE,OAAO,CAAC;KACvB,KAAG,mBAAmB,CAAiD;IAExE,wBAAwB,MAAO;QAC9B,UAAU,EAAE,QAAQ,CAAC;QACrB,YAAY,EAAE,OAAO,CAAC;QACtB,WAAW,EAAE,QAAQ,CAAC;QACtB,aAAa,EAAE,OAAO,CAAC;KACvB,KAAG,mBAAmB,CAAiD;CACxE;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
class CetusRouterPool {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
// =========================================================================
|
|
5
|
+
// Constructor
|
|
6
|
+
// =========================================================================
|
|
7
7
|
constructor(pool, network) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
// =========================================================================
|
|
9
|
+
// Constants
|
|
10
|
+
// =========================================================================
|
|
11
11
|
this.protocolName = "Cetus";
|
|
12
12
|
this.expectedGasCostPerHop = BigInt(9000000); // 0.009 SUI
|
|
13
13
|
this.noHopsAllowed = true;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
// =========================================================================
|
|
15
|
+
// Functions
|
|
16
|
+
// =========================================================================
|
|
17
17
|
this.getSpotPrice = (_) => {
|
|
18
18
|
throw new Error("uncallable");
|
|
19
19
|
};
|
|
20
20
|
this.getTradeAmountOut = (_) => {
|
|
21
21
|
throw new Error("uncallable");
|
|
22
22
|
};
|
|
23
|
-
this.
|
|
23
|
+
this.tradeTx = (inputs) => {
|
|
24
24
|
// PRODUCTION: handle slippage !
|
|
25
25
|
return inputs.provider
|
|
26
26
|
.Router()
|
|
27
27
|
.Cetus()
|
|
28
|
-
.
|
|
28
|
+
.tradeTx(Object.assign(Object.assign({}, inputs), { coinInId: inputs.coinIn, pool: this.pool }));
|
|
29
29
|
};
|
|
30
30
|
this.getTradeAmountIn = (_) => {
|
|
31
31
|
throw new Error("uncallable");
|
|
@@ -23,15 +23,18 @@ declare class DeepBookRouterPool implements RouterPoolInterface {
|
|
|
23
23
|
coinOutType: CoinType;
|
|
24
24
|
referrer?: SuiAddress;
|
|
25
25
|
}) => Balance;
|
|
26
|
-
|
|
26
|
+
tradeTx: (inputs: {
|
|
27
27
|
provider: AftermathApi;
|
|
28
28
|
tx: TransactionBlock;
|
|
29
29
|
coinIn: ObjectId | TransactionArgument;
|
|
30
30
|
coinInAmount: Balance;
|
|
31
31
|
coinInType: CoinType;
|
|
32
32
|
coinOutType: CoinType;
|
|
33
|
-
|
|
33
|
+
expectedCoinOutAmount: Balance;
|
|
34
34
|
slippage: Slippage;
|
|
35
|
+
tradePotato: TransactionArgument;
|
|
36
|
+
isFirstSwapForPath: boolean;
|
|
37
|
+
isLastSwapForPath: boolean;
|
|
35
38
|
referrer?: SuiAddress;
|
|
36
39
|
}) => TransactionArgument;
|
|
37
40
|
getTradeAmountIn: (inputs: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepBookRouterPool.d.ts","sourceRoot":"","sources":["../../../../../../src/packages/router/utils/synchronous/routerPools/deepBookRouterPool.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,OAAO,EACP,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,GAAG,EACH,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EACN,kBAAkB,EAElB,MAAM,6CAA6C,CAAC;AAGrD,cAAM,kBAAmB,YAAW,mBAAmB;gBAK1C,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,UAAU,GAAG,GAAG;IAW/D,QAAQ,CAAC,YAAY,cAAc;IACnC,QAAQ,CAAC,qBAAqB,SAAuB;IACrD,QAAQ,CAAC,aAAa,SAAS;IAE/B,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,GAAG,CAAC;IACnC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC;IAM/B,YAAY,WAAY;QACvB,UAAU,EAAE,QAAQ,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC;KACtB,KAAG,MAAM,CAMR;IAEF,iBAAiB,WAAY;QAC5B,UAAU,EAAE,QAAQ,CAAC;QACrB,YAAY,EAAE,OAAO,CAAC;QACtB,WAAW,EAAE,QAAQ,CAAC;QACtB,QAAQ,CAAC,EAAE,UAAU,CAAC;KACtB,KAAG,OAAO,CAGT;IAEF,
|
|
1
|
+
{"version":3,"file":"deepBookRouterPool.d.ts","sourceRoot":"","sources":["../../../../../../src/packages/router/utils/synchronous/routerPools/deepBookRouterPool.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,OAAO,EACP,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,GAAG,EACH,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EACN,kBAAkB,EAElB,MAAM,6CAA6C,CAAC;AAGrD,cAAM,kBAAmB,YAAW,mBAAmB;gBAK1C,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,UAAU,GAAG,GAAG;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