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,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("../../../../../general/utils");
|
|
4
|
+
const kriyaApi_1 = require("../../../../external/kriya/kriyaApi");
|
|
5
|
+
class KriyaRouterPool {
|
|
6
|
+
// =========================================================================
|
|
7
|
+
// Constructor
|
|
8
|
+
// =========================================================================
|
|
9
|
+
constructor(pool, network) {
|
|
10
|
+
// =========================================================================
|
|
11
|
+
// Constants
|
|
12
|
+
// =========================================================================
|
|
13
|
+
this.protocolName = "Kriya";
|
|
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 = kriyaApi_1.KriyaApi.isCoinX({
|
|
42
|
+
pool: this.pool,
|
|
43
|
+
coinType: inputs.coinInType,
|
|
44
|
+
});
|
|
45
|
+
const { recievedAmount } = this.getSwapAmountStable(coinInReserve, coinOutReserve, Number(isCoinInX ? this.pool.scaleX : this.pool.scaleY), Number(isCoinInX ? this.pool.scaleY : this.pool.scaleX), 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
|
+
.Kriya()
|
|
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 = kriyaApi_1.KriyaApi.isCoinX({
|
|
65
|
+
coinType: inputs.coinInType,
|
|
66
|
+
pool: this.pool,
|
|
67
|
+
});
|
|
68
|
+
let newPoolObject = utils_1.Helpers.deepCopy(this.pool);
|
|
69
|
+
newPoolObject.tokenXValue += isCoinInX
|
|
70
|
+
? inputs.coinInAmount
|
|
71
|
+
: -inputs.coinOutAmount;
|
|
72
|
+
newPoolObject.tokenYValue += isCoinInX
|
|
73
|
+
? -inputs.coinOutAmount
|
|
74
|
+
: inputs.coinInAmount;
|
|
75
|
+
return new KriyaRouterPool(utils_1.Helpers.deepCopy(newPoolObject), this.network);
|
|
76
|
+
};
|
|
77
|
+
// =========================================================================
|
|
78
|
+
// Private Helpers
|
|
79
|
+
// =========================================================================
|
|
80
|
+
this.getPoolBalance = (coinType) => {
|
|
81
|
+
return Number(kriyaApi_1.KriyaApi.isCoinX({ coinType, pool: this.pool })
|
|
82
|
+
? this.pool.tokenXValue
|
|
83
|
+
: this.pool.tokenYValue);
|
|
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 * (KriyaRouterPool.FEE_SCALING - fee_percent);
|
|
140
|
+
let numerator = input_amount_with_fee * output_reserve;
|
|
141
|
+
let denominator = input_reserve * KriyaRouterPool.FEE_SCALING + input_amount_with_fee;
|
|
142
|
+
return numerator / denominator;
|
|
143
|
+
};
|
|
144
|
+
this.get_input_price_stable = (input_amount, input_reserve, output_reserve, fee_percent, input_scale, output_scale) => {
|
|
145
|
+
let u2561e8 = KriyaRouterPool.ONE_E_8;
|
|
146
|
+
let xy = this.lp_value(input_reserve, input_scale, output_reserve, output_scale);
|
|
147
|
+
let reserve_in_u256 = (input_reserve * u2561e8) / input_scale;
|
|
148
|
+
let reserve_out_u256 = (output_reserve * u2561e8) / output_scale;
|
|
149
|
+
let amount_in = (input_amount * u2561e8) / input_scale;
|
|
150
|
+
let amount_in_with_fees_scaling = (amount_in * (KriyaRouterPool.FEE_SCALING - fee_percent)) /
|
|
151
|
+
KriyaRouterPool.FEE_SCALING;
|
|
152
|
+
let total_reserve = amount_in_with_fees_scaling + reserve_in_u256;
|
|
153
|
+
let y = reserve_out_u256 - this.get_y(total_reserve, xy, reserve_out_u256);
|
|
154
|
+
let r = (y * output_scale) / u2561e8;
|
|
155
|
+
return r;
|
|
156
|
+
};
|
|
157
|
+
this.lp_value = (x_coin, x_scale, y_coin, y_scale) => {
|
|
158
|
+
let _x = (x_coin * KriyaRouterPool.ONE_E_8) / x_scale;
|
|
159
|
+
let _y = (y_coin * KriyaRouterPool.ONE_E_8) / y_scale;
|
|
160
|
+
let xy = _x * _y;
|
|
161
|
+
let x2_y2 = _x * _x + _y * _y;
|
|
162
|
+
return xy * x2_y2;
|
|
163
|
+
};
|
|
164
|
+
this.get_y = (x0, xy, y) => {
|
|
165
|
+
let i = 0;
|
|
166
|
+
let one_u256 = 1;
|
|
167
|
+
while (i < 255) {
|
|
168
|
+
let k = this.calcF(x0, y);
|
|
169
|
+
let _dy = 0;
|
|
170
|
+
if (xy > k) {
|
|
171
|
+
_dy = (xy - k) / this.calcD(x0, y) + one_u256; // Round up
|
|
172
|
+
y = y + _dy;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
_dy = (k - xy) / this.calcD(x0, y) + one_u256;
|
|
176
|
+
y = y - _dy;
|
|
177
|
+
}
|
|
178
|
+
if (_dy <= one_u256) {
|
|
179
|
+
return y;
|
|
180
|
+
}
|
|
181
|
+
i = i + 1;
|
|
182
|
+
}
|
|
183
|
+
return y;
|
|
184
|
+
};
|
|
185
|
+
this.calcF = (x0_u256, y_u256) => {
|
|
186
|
+
// x0*(y*y/1e18*y/1e18)/1e18
|
|
187
|
+
let yy = y_u256 * y_u256;
|
|
188
|
+
let yyy = yy * y_u256;
|
|
189
|
+
let a = x0_u256 * yyy;
|
|
190
|
+
//(x0*x0/1e18*x0/1e18)*y/1e18
|
|
191
|
+
let xx = x0_u256 * x0_u256;
|
|
192
|
+
let xxx = xx * x0_u256;
|
|
193
|
+
let b = xxx * y_u256;
|
|
194
|
+
// a + b
|
|
195
|
+
return a + b;
|
|
196
|
+
};
|
|
197
|
+
this.calcD = (x0_u256, y_u256) => {
|
|
198
|
+
let three_u256 = 3;
|
|
199
|
+
// 3 * x0 * (y * y / 1e8) / 1e8
|
|
200
|
+
let x3 = three_u256 * x0_u256;
|
|
201
|
+
let yy = y_u256 * y_u256;
|
|
202
|
+
let xyy3 = x3 * yy;
|
|
203
|
+
let xx = x0_u256 * x0_u256;
|
|
204
|
+
// x0 * x0 / 1e8 * x0 / 1e8
|
|
205
|
+
let xxx = xx * x0_u256;
|
|
206
|
+
return xyy3 + xxx;
|
|
207
|
+
};
|
|
208
|
+
this.pool = pool;
|
|
209
|
+
this.network = network;
|
|
210
|
+
this.uid = pool.objectId;
|
|
211
|
+
this.coinTypes = [pool.coinTypeX, pool.coinTypeY];
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
KriyaRouterPool.FEE_SCALING = 1000000;
|
|
215
|
+
KriyaRouterPool.ONE_E_8 = 100000000;
|
|
216
|
+
exports.default = KriyaRouterPool;
|
|
@@ -3,18 +3,17 @@ import { Balance, Slippage, SuiNetwork, UniqueId, Url } from "../../../../../typ
|
|
|
3
3
|
import { CoinType } from "../../../../coin/coinTypes";
|
|
4
4
|
import { RouterPoolInterface } from "../interfaces/routerPoolInterface";
|
|
5
5
|
import { AftermathApi } from "../../../../../general/providers";
|
|
6
|
-
import {
|
|
7
|
-
declare class
|
|
8
|
-
constructor(pool:
|
|
9
|
-
readonly protocolName = "
|
|
6
|
+
import { SuiswapPoolObject } from "../../../../external/suiswap/suiswapTypes";
|
|
7
|
+
declare class SuiswapRouterPool implements RouterPoolInterface {
|
|
8
|
+
constructor(pool: SuiswapPoolObject, network: SuiNetwork | Url);
|
|
9
|
+
readonly protocolName = "Suiswap";
|
|
10
10
|
readonly expectedGasCostPerHop: bigint;
|
|
11
11
|
readonly noHopsAllowed = false;
|
|
12
|
-
readonly pool:
|
|
12
|
+
readonly pool: SuiswapPoolObject;
|
|
13
13
|
readonly network: SuiNetwork | Url;
|
|
14
14
|
readonly uid: UniqueId;
|
|
15
15
|
readonly coinTypes: CoinType[];
|
|
16
|
-
private readonly
|
|
17
|
-
private readonly basisPointsIn100Percent;
|
|
16
|
+
private static readonly BPS_SCALING;
|
|
18
17
|
getSpotPrice: (inputs: {
|
|
19
18
|
coinInType: CoinType;
|
|
20
19
|
coinOutType: CoinType;
|
|
@@ -25,17 +24,20 @@ declare class NojoRouterPool implements RouterPoolInterface {
|
|
|
25
24
|
coinOutType: CoinType;
|
|
26
25
|
referrer?: SuiAddress;
|
|
27
26
|
}) => Balance;
|
|
28
|
-
|
|
27
|
+
tradeTx: (inputs: {
|
|
29
28
|
provider: AftermathApi;
|
|
30
29
|
tx: TransactionBlock;
|
|
31
30
|
coinIn: ObjectId | TransactionArgument;
|
|
32
31
|
coinInAmount: Balance;
|
|
33
32
|
coinInType: CoinType;
|
|
34
33
|
coinOutType: CoinType;
|
|
35
|
-
|
|
34
|
+
expectedCoinOutAmount: Balance;
|
|
36
35
|
slippage: Slippage;
|
|
36
|
+
tradePotato: TransactionArgument;
|
|
37
|
+
isFirstSwapForPath: boolean;
|
|
38
|
+
isLastSwapForPath: boolean;
|
|
37
39
|
referrer?: SuiAddress;
|
|
38
|
-
}) => {
|
|
40
|
+
}) => ({
|
|
39
41
|
kind: "Input";
|
|
40
42
|
index: number;
|
|
41
43
|
type?: "object" | "pure" | undefined;
|
|
@@ -49,7 +51,21 @@ declare class NojoRouterPool implements RouterPoolInterface {
|
|
|
49
51
|
kind: "NestedResult";
|
|
50
52
|
index: number;
|
|
51
53
|
resultIndex: number;
|
|
52
|
-
}
|
|
54
|
+
}) & ({
|
|
55
|
+
kind: "Input";
|
|
56
|
+
index: number;
|
|
57
|
+
type?: "object" | "pure" | undefined;
|
|
58
|
+
value?: any;
|
|
59
|
+
} | {
|
|
60
|
+
kind: "GasCoin";
|
|
61
|
+
} | {
|
|
62
|
+
kind: "Result";
|
|
63
|
+
index: number;
|
|
64
|
+
} | {
|
|
65
|
+
kind: "NestedResult";
|
|
66
|
+
index: number;
|
|
67
|
+
resultIndex: number;
|
|
68
|
+
})[];
|
|
53
69
|
getTradeAmountIn: (inputs: {
|
|
54
70
|
coinInType: CoinType;
|
|
55
71
|
coinOutAmount: Balance;
|
|
@@ -68,7 +84,12 @@ declare class NojoRouterPool implements RouterPoolInterface {
|
|
|
68
84
|
coinOutType: CoinType;
|
|
69
85
|
coinOutAmount: Balance;
|
|
70
86
|
}) => RouterPoolInterface;
|
|
71
|
-
private
|
|
87
|
+
private getXToYAmount;
|
|
88
|
+
private getYToXAmount;
|
|
89
|
+
private _computeAmount;
|
|
90
|
+
private _computeAmountStable;
|
|
91
|
+
private totalAdminFee;
|
|
92
|
+
private totalLpFee;
|
|
72
93
|
}
|
|
73
|
-
export default
|
|
74
|
-
//# sourceMappingURL=
|
|
94
|
+
export default SuiswapRouterPool;
|
|
95
|
+
//# sourceMappingURL=suiswapRouterPool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suiswapRouterPool.d.ts","sourceRoot":"","sources":["../../../../../../src/packages/router/utils/synchronous/routerPools/suiswapRouterPool.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;AAGxE,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAG9E,cAAM,iBAAkB,YAAW,mBAAmB;gBAKzC,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAE,UAAU,GAAG,GAAG;IAW9D,QAAQ,CAAC,YAAY,aAAa;IAElC,QAAQ,CAAC,qBAAqB,SAAsB;IACpD,QAAQ,CAAC,aAAa,SAAS;IAE/B,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,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,CAAmB;IAMtD,YAAY,WAAY;QACvB,UAAU,EAAE,QAAQ,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC;KACtB,YAqBC;IAGF,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,CAWT;IAEF,OAAO,WAAY;QAClB,QAAQ,EAAE,YAAY,CAAC;QACvB,EAAE,EAAE,gBAAgB,CAAC;QACrB,MAAM,EAAE,QAAQ,GAAG,mBAAmB,CAAC;QACvC,YAAY,EAAE,OAAO,CAAC;QACtB,UAAU,EAAE,QAAQ,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC;QACtB,qBAAqB,EAAE,OAAO,CAAC;QAC/B,QAAQ,EAAE,QAAQ,CAAC;QACnB,WAAW,EAAE,mBAAmB,CAAC;QACjC,kBAAkB,EAAE,OAAO,CAAC;QAC5B,iBAAiB,EAAE,OAAO,CAAC;QAC3B,QAAQ,CAAC,EAAE,UAAU,CAAC;KACtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAUC;IAEF,gBAAgB,WAAY;QAC3B,UAAU,EAAE,QAAQ,CAAC;QACrB,aAAa,EAAE,OAAO,CAAC;QACvB,WAAW,EAAE,QAAQ,CAAC;QACtB,QAAQ,CAAC,EAAE,UAAU,CAAC;KACtB,KAAG,OAAO,CAET;IAEF,yBAAyB,WAAY;QACpC,UAAU,EAAE,QAAQ,CAAC;QACrB,YAAY,EAAE,OAAO,CAAC;QACtB,WAAW,EAAE,QAAQ,CAAC;QACtB,aAAa,EAAE,OAAO,CAAC;KACvB,KAAG,mBAAmB,CAMrB;IAEF,wBAAwB,WAAY;QACnC,UAAU,EAAE,QAAQ,CAAC;QACrB,YAAY,EAAE,OAAO,CAAC;QACtB,WAAW,EAAE,QAAQ,CAAC;QACtB,aAAa,EAAE,OAAO,CAAC;KACvB,KAAG,mBAAmB,CAmBrB;IAMF,OAAO,CAAC,aAAa,CAgCnB;IAEF,OAAO,CAAC,aAAa,CAgCnB;IAEF,OAAO,CAAC,cAAc,CAKpB;IAEF,OAAO,CAAC,oBAAoB,CAc1B;IAEF,OAAO,CAAC,aAAa,CAEnB;IAEF,OAAO,CAAC,UAAU,CAEhB;CACF;AAiHD,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const utils_1 = require("../../../../../general/utils");
|
|
5
|
+
const suiswapApi_1 = require("../../../../external/suiswap/suiswapApi");
|
|
6
|
+
class SuiswapRouterPool {
|
|
7
|
+
// =========================================================================
|
|
8
|
+
// Constructor
|
|
9
|
+
// =========================================================================
|
|
10
|
+
constructor(pool, network) {
|
|
11
|
+
// =========================================================================
|
|
12
|
+
// Constants
|
|
13
|
+
// =========================================================================
|
|
14
|
+
this.protocolName = "Suiswap";
|
|
15
|
+
// TODO: update gas price
|
|
16
|
+
this.expectedGasCostPerHop = BigInt(50000000); // 0.05 SUI
|
|
17
|
+
this.noHopsAllowed = false;
|
|
18
|
+
// =========================================================================
|
|
19
|
+
// Public Interface
|
|
20
|
+
// =========================================================================
|
|
21
|
+
this.getSpotPrice = (inputs) => {
|
|
22
|
+
// TODO: do this calc correctly
|
|
23
|
+
let smallAmountIn = BigInt(100000);
|
|
24
|
+
while (smallAmountIn < utils_1.Casting.u64MaxBigInt) {
|
|
25
|
+
try {
|
|
26
|
+
const smallAmountOut = this.getTradeAmountOut(Object.assign(Object.assign({}, inputs), { coinInAmount: smallAmountIn }));
|
|
27
|
+
if (smallAmountOut <= BigInt(0))
|
|
28
|
+
throw new Error("0 amount out");
|
|
29
|
+
return Number(smallAmountIn) / Number(smallAmountOut);
|
|
30
|
+
}
|
|
31
|
+
catch (e) { }
|
|
32
|
+
smallAmountIn *= BigInt(10);
|
|
33
|
+
}
|
|
34
|
+
// this shouldn't be reached
|
|
35
|
+
return 1;
|
|
36
|
+
};
|
|
37
|
+
// TODO: calc by taking into account fee amount
|
|
38
|
+
this.getTradeAmountOut = (inputs) => {
|
|
39
|
+
const isCoinInX = suiswapApi_1.SuiswapApi.isCoinX({
|
|
40
|
+
coinType: inputs.coinInType,
|
|
41
|
+
pool: this.pool,
|
|
42
|
+
});
|
|
43
|
+
if (isCoinInX) {
|
|
44
|
+
return this.getXToYAmount(inputs.coinInAmount);
|
|
45
|
+
}
|
|
46
|
+
return this.getYToXAmount(inputs.coinInAmount);
|
|
47
|
+
};
|
|
48
|
+
this.tradeTx = (inputs) => {
|
|
49
|
+
return inputs.provider
|
|
50
|
+
.Router()
|
|
51
|
+
.Suiswap()
|
|
52
|
+
.tradeTx(Object.assign(Object.assign({}, inputs), { pool: this.pool, coinInId: inputs.coinIn, minAmountOut: BigInt(0) }));
|
|
53
|
+
};
|
|
54
|
+
this.getTradeAmountIn = (inputs) => {
|
|
55
|
+
throw new Error("not implemented");
|
|
56
|
+
};
|
|
57
|
+
this.getUpdatedPoolBeforeTrade = (inputs) => {
|
|
58
|
+
return this.getUpdatedPoolAfterTrade(Object.assign(Object.assign({}, inputs), { coinInAmount: -inputs.coinInAmount, coinOutAmount: -inputs.coinOutAmount }));
|
|
59
|
+
};
|
|
60
|
+
this.getUpdatedPoolAfterTrade = (inputs) => {
|
|
61
|
+
const isCoinInX = suiswapApi_1.SuiswapApi.isCoinX({
|
|
62
|
+
coinType: inputs.coinInType,
|
|
63
|
+
pool: this.pool,
|
|
64
|
+
});
|
|
65
|
+
let newPoolObject = utils_1.Helpers.deepCopy(this.pool);
|
|
66
|
+
newPoolObject.xValue += isCoinInX
|
|
67
|
+
? inputs.coinInAmount
|
|
68
|
+
: -inputs.coinOutAmount;
|
|
69
|
+
newPoolObject.yValue += isCoinInX
|
|
70
|
+
? -inputs.coinOutAmount
|
|
71
|
+
: inputs.coinInAmount;
|
|
72
|
+
return new SuiswapRouterPool(utils_1.Helpers.deepCopy(newPoolObject), this.network);
|
|
73
|
+
};
|
|
74
|
+
// =========================================================================
|
|
75
|
+
// Private Calculations
|
|
76
|
+
// =========================================================================
|
|
77
|
+
this.getXToYAmount = (dx) => {
|
|
78
|
+
const x_reserve_amt = this.pool.xValue;
|
|
79
|
+
const y_reserve_amt = this.pool.yValue;
|
|
80
|
+
if (this.pool.feeDirection === "X") {
|
|
81
|
+
dx =
|
|
82
|
+
dx -
|
|
83
|
+
(dx * this.totalAdminFee()) / SuiswapRouterPool.BPS_SCALING;
|
|
84
|
+
}
|
|
85
|
+
dx = dx - (dx * this.totalLpFee()) / SuiswapRouterPool.BPS_SCALING;
|
|
86
|
+
if (dx < BigInt(0)) {
|
|
87
|
+
return BigInt(0);
|
|
88
|
+
}
|
|
89
|
+
let dy = this.pool.poolType == "v2"
|
|
90
|
+
? this._computeAmount(dx, x_reserve_amt, y_reserve_amt)
|
|
91
|
+
: this._computeAmountStable(dx, x_reserve_amt, y_reserve_amt, this.pool.stableXScale, this.pool.stableYScale);
|
|
92
|
+
if (this.pool.feeDirection === "Y") {
|
|
93
|
+
dy =
|
|
94
|
+
dy -
|
|
95
|
+
(dy * this.totalAdminFee()) / SuiswapRouterPool.BPS_SCALING;
|
|
96
|
+
}
|
|
97
|
+
return dy;
|
|
98
|
+
};
|
|
99
|
+
this.getYToXAmount = (dy) => {
|
|
100
|
+
const x_reserve_amt = this.pool.xValue;
|
|
101
|
+
const y_reserve_amt = this.pool.yValue;
|
|
102
|
+
if (this.pool.feeDirection === "Y") {
|
|
103
|
+
dy =
|
|
104
|
+
dy -
|
|
105
|
+
(dy * this.totalAdminFee()) / SuiswapRouterPool.BPS_SCALING;
|
|
106
|
+
}
|
|
107
|
+
dy = dy - (dy * this.totalLpFee()) / SuiswapRouterPool.BPS_SCALING;
|
|
108
|
+
if (dy < BigInt(0)) {
|
|
109
|
+
return BigInt(0);
|
|
110
|
+
}
|
|
111
|
+
let dx = this.pool.poolType == "v2"
|
|
112
|
+
? this._computeAmount(dy, y_reserve_amt, x_reserve_amt)
|
|
113
|
+
: this._computeAmountStable(dy, y_reserve_amt, x_reserve_amt, this.pool.stableYScale, this.pool.stableXScale);
|
|
114
|
+
if (this.pool.feeDirection === "X") {
|
|
115
|
+
dx =
|
|
116
|
+
dx -
|
|
117
|
+
(dx * this.totalAdminFee()) / SuiswapRouterPool.BPS_SCALING;
|
|
118
|
+
}
|
|
119
|
+
return dx;
|
|
120
|
+
};
|
|
121
|
+
this._computeAmount = (dx, x, y) => {
|
|
122
|
+
const numerator = y * dx;
|
|
123
|
+
const denominator = x + dx;
|
|
124
|
+
const dy = numerator / denominator;
|
|
125
|
+
return dy;
|
|
126
|
+
};
|
|
127
|
+
this._computeAmountStable = (dx, x, y, x_scale, y_scale) => {
|
|
128
|
+
const dy_ = StableSwapHelper.computeY(dx * x_scale, x * x_scale, y * y_scale, this.pool.stableAmp);
|
|
129
|
+
return dy_ / y_scale;
|
|
130
|
+
};
|
|
131
|
+
this.totalAdminFee = () => {
|
|
132
|
+
return this.pool.feeAdmin; // + this.connectFee
|
|
133
|
+
};
|
|
134
|
+
this.totalLpFee = () => {
|
|
135
|
+
return this.pool.feeLp; // + this.incentiveFee
|
|
136
|
+
};
|
|
137
|
+
this.pool = pool;
|
|
138
|
+
this.network = network;
|
|
139
|
+
this.uid = pool.objectId;
|
|
140
|
+
this.coinTypes = [pool.coinTypeX, pool.coinTypeY];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
SuiswapRouterPool.BPS_SCALING = BigInt("10000");
|
|
144
|
+
class StableSwapHelper {
|
|
145
|
+
}
|
|
146
|
+
_a = StableSwapHelper;
|
|
147
|
+
StableSwapHelper.MINUS_ONE = BigInt(-1);
|
|
148
|
+
StableSwapHelper.ZERO = BigInt(0);
|
|
149
|
+
StableSwapHelper.ONE = BigInt(1);
|
|
150
|
+
StableSwapHelper.TWO = BigInt(2);
|
|
151
|
+
StableSwapHelper.THREE = BigInt(3);
|
|
152
|
+
StableSwapHelper.FOUR = BigInt(4);
|
|
153
|
+
StableSwapHelper._1E1 = BigInt(Math.pow(10, 1));
|
|
154
|
+
StableSwapHelper.compuateDNext = (dInit, dProd, sumX, A) => {
|
|
155
|
+
const leverage = sumX * StableSwapHelper.TWO * A;
|
|
156
|
+
const numerator = dInit * (StableSwapHelper.TWO * dProd + leverage);
|
|
157
|
+
const denominator = dInit * (StableSwapHelper.TWO * A - StableSwapHelper.ONE) +
|
|
158
|
+
StableSwapHelper.THREE * dProd;
|
|
159
|
+
return numerator / denominator;
|
|
160
|
+
};
|
|
161
|
+
StableSwapHelper.computeD = (b, q, A) => {
|
|
162
|
+
if (b + q == StableSwapHelper.ZERO) {
|
|
163
|
+
return StableSwapHelper.ZERO;
|
|
164
|
+
}
|
|
165
|
+
let d = b + q;
|
|
166
|
+
for (let __i = 0; __i < 256; ++__i) {
|
|
167
|
+
let dProd = d;
|
|
168
|
+
dProd = (dProd * d) / (StableSwapHelper.TWO * b);
|
|
169
|
+
dProd = (dProd * d) / (StableSwapHelper.TWO * q);
|
|
170
|
+
const dPrev = d;
|
|
171
|
+
d = StableSwapHelper.compuateDNext(d, dProd, b + q, A);
|
|
172
|
+
const diff = d - dPrev;
|
|
173
|
+
if (diff === StableSwapHelper.ONE ||
|
|
174
|
+
diff === StableSwapHelper.MINUS_ONE ||
|
|
175
|
+
diff === StableSwapHelper.ZERO) {
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return d;
|
|
180
|
+
};
|
|
181
|
+
StableSwapHelper.computeY = (dx, x, y, A) => {
|
|
182
|
+
const d = StableSwapHelper.computeD(x, y, A);
|
|
183
|
+
let c = (d * d) / (StableSwapHelper.TWO * (x + dx));
|
|
184
|
+
c = (c * d) / (StableSwapHelper.FOUR * A);
|
|
185
|
+
const b = d / (StableSwapHelper.TWO * A) + (x + dx);
|
|
186
|
+
let yy = d;
|
|
187
|
+
for (let __i = 0; __i < 256; ++__i) {
|
|
188
|
+
const yPrev = yy;
|
|
189
|
+
const yn = yy * yy + c;
|
|
190
|
+
const yd = StableSwapHelper.TWO * yy + b - d;
|
|
191
|
+
yy = yn / yd;
|
|
192
|
+
const diff = yy - yPrev;
|
|
193
|
+
if (diff === StableSwapHelper.ONE ||
|
|
194
|
+
diff === StableSwapHelper.MINUS_ONE ||
|
|
195
|
+
diff === StableSwapHelper.ZERO) {
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return y - yy - StableSwapHelper.ONE;
|
|
200
|
+
};
|
|
201
|
+
StableSwapHelper.computeDDecimal = (b, q, A, bd, qd) => {
|
|
202
|
+
const md = Math.max(bd, qd);
|
|
203
|
+
StableSwapHelper.computeD(b * _a.bigintPow(StableSwapHelper._1E1, md - bd), q * _a.bigintPow(StableSwapHelper._1E1, md - qd), A);
|
|
204
|
+
};
|
|
205
|
+
StableSwapHelper.computeYDecimal = (dx, x, y, A, xd, yd) => {
|
|
206
|
+
const md = Math.max(xd, yd);
|
|
207
|
+
const xs = _a.bigintPow(StableSwapHelper._1E1, md - xd);
|
|
208
|
+
const ys = _a.bigintPow(StableSwapHelper._1E1, md - yd);
|
|
209
|
+
const dy = StableSwapHelper.computeY(dx * xs, x * xs, y * ys, A);
|
|
210
|
+
return dy / ys;
|
|
211
|
+
};
|
|
212
|
+
StableSwapHelper.bigintPow = (a, b) => {
|
|
213
|
+
return Array(b)
|
|
214
|
+
.fill(BigInt(a))
|
|
215
|
+
.reduce((a, b) => a * b, BigInt(1));
|
|
216
|
+
};
|
|
217
|
+
exports.default = SuiswapRouterPool;
|
|
@@ -23,15 +23,18 @@ declare class TurbosRouterPool 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
|
externalFee?: RouterExternalFee;
|
|
37
40
|
}) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turbosRouterPool.d.ts","sourceRoot":"","sources":["../../../../../../src/packages/router/utils/synchronous/routerPools/turbosRouterPool.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,OAAO,EACP,iBAAiB,EACjB,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,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,cAAM,gBAAiB,YAAW,mBAAmB;gBAKxC,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,UAAU,GAAG,GAAG;IAW7D,QAAQ,CAAC,YAAY,YAAY;IACjC,QAAQ,CAAC,qBAAqB,SAAqB;IACnD,QAAQ,CAAC,aAAa,QAAQ;IAE9B,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,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,MAAO;QAAE,UAAU,EAAE,QAAQ,CAAC;QAAC,WAAW,EAAE,QAAQ,CAAA;KAAE,WAEhE;IAEF,iBAAiB,MAAO;QACvB,UAAU,EAAE,QAAQ,CAAC;QACrB,YAAY,EAAE,OAAO,CAAC;QACtB,WAAW,EAAE,QAAQ,CAAC;QACtB,QAAQ,CAAC,EAAE,UAAU,CAAC;KACtB,KAAG,OAAO,CAET;IAEF,
|
|
1
|
+
{"version":3,"file":"turbosRouterPool.d.ts","sourceRoot":"","sources":["../../../../../../src/packages/router/utils/synchronous/routerPools/turbosRouterPool.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,gBAAgB,EAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,OAAO,EACP,iBAAiB,EACjB,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,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,cAAM,gBAAiB,YAAW,mBAAmB;gBAKxC,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,UAAU,GAAG,GAAG;IAW7D,QAAQ,CAAC,YAAY,YAAY;IACjC,QAAQ,CAAC,qBAAqB,SAAqB;IACnD,QAAQ,CAAC,aAAa,QAAQ;IAE9B,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,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,MAAO;QAAE,UAAU,EAAE,QAAQ,CAAC;QAAC,WAAW,EAAE,QAAQ,CAAA;KAAE,WAEhE;IAEF,iBAAiB,MAAO;QACvB,UAAU,EAAE,QAAQ,CAAC;QACrB,YAAY,EAAE,OAAO,CAAC;QACtB,WAAW,EAAE,QAAQ,CAAC;QACtB,QAAQ,CAAC,EAAE,UAAU,CAAC;KACtB,KAAG,OAAO,CAET;IAEF,OAAO,WAAY;QAClB,QAAQ,EAAE,YAAY,CAAC;QACvB,EAAE,EAAE,gBAAgB,CAAC;QACrB,MAAM,EAAE,QAAQ,GAAG,mBAAmB,CAAC;QACvC,YAAY,EAAE,OAAO,CAAC;QACtB,UAAU,EAAE,QAAQ,CAAC;QACrB,WAAW,EAAE,QAAQ,CAAC;QACtB,qBAAqB,EAAE,OAAO,CAAC;QAC/B,QAAQ,EAAE,QAAQ,CAAC;QACnB,WAAW,EAAE,mBAAmB,CAAC;QACjC,kBAAkB,EAAE,OAAO,CAAC;QAC5B,iBAAiB,EAAE,OAAO,CAAC;QAC3B,QAAQ,CAAC,EAAE,UAAU,CAAC;QACtB,WAAW,CAAC,EAAE,iBAAiB,CAAC;KAChC;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAcC;IAEF,gBAAgB,MAAO;QACtB,UAAU,EAAE,QAAQ,CAAC;QACrB,aAAa,EAAE,OAAO,CAAC;QACvB,WAAW,EAAE,QAAQ,CAAC;QACtB,QAAQ,CAAC,EAAE,UAAU,CAAC;KACtB,KAAG,OAAO,CAET;IAEF,yBAAyB,MAAO;QAC/B,UAAU,EAAE,QAAQ,CAAC;QACrB,YAAY,EAAE,OAAO,CAAC;QACtB,WAAW,EAAE,QAAQ,CAAC;QACtB,aAAa,EAAE,OAAO,CAAC;KACvB,KAAG,mBAAmB,CAAkD;IAEzE,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,CAAkD;CACzE;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
class TurbosRouterPool {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
// =========================================================================
|
|
5
|
+
// Constructor
|
|
6
|
+
// =========================================================================
|
|
7
7
|
constructor(pool, network) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
// =========================================================================
|
|
9
|
+
// Constants
|
|
10
|
+
// =========================================================================
|
|
11
11
|
this.protocolName = "Turbos";
|
|
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
|
if (!inputs.tx.blockData.sender)
|
|
26
26
|
throw new Error("no sender for tx set (required for turbos txs)");
|
|
27
27
|
return inputs.provider
|
|
28
28
|
.Router()
|
|
29
29
|
.Turbos()
|
|
30
|
-
.
|
|
30
|
+
.tradeTx(Object.assign(Object.assign({}, inputs), { coinInId: inputs.coinIn, pool: this.pool, walletAddress: inputs.tx.blockData.sender }));
|
|
31
31
|
};
|
|
32
32
|
this.getTradeAmountIn = (_) => {
|
|
33
33
|
throw new Error("uncallable");
|