@alphafi/alphafi-sdk 0.0.49 → 0.0.51
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/cjs/adminFunctions.d.ts +4 -1
- package/dist/cjs/adminFunctions.d.ts.map +1 -1
- package/dist/cjs/adminFunctions.js +77 -0
- package/dist/cjs/adminFunctions.js.map +1 -1
- package/dist/cjs/common/coins.d.ts.map +1 -1
- package/dist/cjs/common/coins.js +6 -0
- package/dist/cjs/common/coins.js.map +1 -1
- package/dist/cjs/common/constants.d.ts +48 -0
- package/dist/cjs/common/constants.d.ts.map +1 -1
- package/dist/cjs/common/constants.js +34 -0
- package/dist/cjs/common/constants.js.map +1 -1
- package/dist/cjs/common/maps.d.ts +3 -0
- package/dist/cjs/common/maps.d.ts.map +1 -1
- package/dist/cjs/common/maps.js +144 -0
- package/dist/cjs/common/maps.js.map +1 -1
- package/dist/cjs/common/pyth.d.ts +1 -1
- package/dist/cjs/common/pyth.d.ts.map +1 -1
- package/dist/cjs/common/pyth.js.map +1 -1
- package/dist/cjs/common/types.d.ts +22 -6
- package/dist/cjs/common/types.d.ts.map +1 -1
- package/dist/cjs/common/types.js.map +1 -1
- package/dist/cjs/getVaultBalances.js +1 -1
- package/dist/cjs/getVaultBalances.js.map +1 -1
- package/dist/cjs/graphql/getMultiReceipts.d.ts.map +1 -1
- package/dist/cjs/graphql/getMultiReceipts.js +21 -4
- package/dist/cjs/graphql/getMultiReceipts.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +11 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/sui-sdk/client.d.ts +8 -0
- package/dist/cjs/sui-sdk/client.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/client.js +12 -0
- package/dist/cjs/sui-sdk/client.js.map +1 -1
- package/dist/cjs/sui-sdk/functions/getPortfolioAmounts.js +1 -1
- package/dist/cjs/sui-sdk/functions/getPortfolioAmounts.js.map +1 -1
- package/dist/cjs/sui-sdk/functions/getPositionRange.d.ts +10 -0
- package/dist/cjs/sui-sdk/functions/getPositionRange.d.ts.map +1 -0
- package/dist/cjs/sui-sdk/functions/getPositionRange.js +86 -0
- package/dist/cjs/sui-sdk/functions/getPositionRange.js.map +1 -0
- package/dist/cjs/sui-sdk/functions/getReceipts.d.ts +9 -15
- package/dist/cjs/sui-sdk/functions/getReceipts.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/functions/getReceipts.js +290 -200
- package/dist/cjs/sui-sdk/functions/getReceipts.js.map +1 -1
- package/dist/cjs/transactions/blueRewards.d.ts.map +1 -1
- package/dist/cjs/transactions/blueRewards.js +27 -2
- package/dist/cjs/transactions/blueRewards.js.map +1 -1
- package/dist/cjs/transactions/bluefin.d.ts.map +1 -1
- package/dist/cjs/transactions/bluefin.js +110 -0
- package/dist/cjs/transactions/bluefin.js.map +1 -1
- package/dist/cjs/transactions/collect_rewards.d.ts.map +1 -1
- package/dist/cjs/transactions/collect_rewards.js +2 -1
- package/dist/cjs/transactions/collect_rewards.js.map +1 -1
- package/dist/cjs/transactions/deposit.d.ts.map +1 -1
- package/dist/cjs/transactions/deposit.js +10 -3
- package/dist/cjs/transactions/deposit.js.map +1 -1
- package/dist/cjs/transactions/zapDeposit.d.ts.map +1 -1
- package/dist/cjs/transactions/zapDeposit.js +58 -29
- package/dist/cjs/transactions/zapDeposit.js.map +1 -1
- package/dist/cjs/utils/prices.d.ts.map +1 -1
- package/dist/cjs/utils/prices.js +1 -0
- package/dist/cjs/utils/prices.js.map +1 -1
- package/dist/esm/adminFunctions.d.ts +4 -1
- package/dist/esm/adminFunctions.d.ts.map +1 -1
- package/dist/esm/adminFunctions.js +76 -2
- package/dist/esm/adminFunctions.js.map +1 -1
- package/dist/esm/common/coins.d.ts.map +1 -1
- package/dist/esm/common/coins.js +6 -0
- package/dist/esm/common/coins.js.map +1 -1
- package/dist/esm/common/constants.d.ts +48 -0
- package/dist/esm/common/constants.d.ts.map +1 -1
- package/dist/esm/common/constants.js +34 -0
- package/dist/esm/common/constants.js.map +1 -1
- package/dist/esm/common/maps.d.ts +3 -0
- package/dist/esm/common/maps.d.ts.map +1 -1
- package/dist/esm/common/maps.js +144 -0
- package/dist/esm/common/maps.js.map +1 -1
- package/dist/esm/common/pyth.d.ts +1 -1
- package/dist/esm/common/pyth.d.ts.map +1 -1
- package/dist/esm/common/pyth.js.map +1 -1
- package/dist/esm/common/types.d.ts +22 -6
- package/dist/esm/common/types.d.ts.map +1 -1
- package/dist/esm/common/types.js.map +1 -1
- package/dist/esm/getVaultBalances.js +1 -1
- package/dist/esm/getVaultBalances.js.map +1 -1
- package/dist/esm/graphql/getMultiReceipts.d.ts.map +1 -1
- package/dist/esm/graphql/getMultiReceipts.js +21 -3
- package/dist/esm/graphql/getMultiReceipts.js.map +1 -1
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/sui-sdk/client.d.ts +8 -0
- package/dist/esm/sui-sdk/client.d.ts.map +1 -1
- package/dist/esm/sui-sdk/client.js +10 -0
- package/dist/esm/sui-sdk/client.js.map +1 -1
- package/dist/esm/sui-sdk/functions/getPortfolioAmounts.js +1 -1
- package/dist/esm/sui-sdk/functions/getPortfolioAmounts.js.map +1 -1
- package/dist/esm/sui-sdk/functions/getPositionRange.d.ts +10 -0
- package/dist/esm/sui-sdk/functions/getPositionRange.d.ts.map +1 -0
- package/dist/esm/sui-sdk/functions/getPositionRange.js +82 -0
- package/dist/esm/sui-sdk/functions/getPositionRange.js.map +1 -0
- package/dist/esm/sui-sdk/functions/getReceipts.d.ts +9 -15
- package/dist/esm/sui-sdk/functions/getReceipts.d.ts.map +1 -1
- package/dist/esm/sui-sdk/functions/getReceipts.js +288 -198
- package/dist/esm/sui-sdk/functions/getReceipts.js.map +1 -1
- package/dist/esm/transactions/blueRewards.d.ts.map +1 -1
- package/dist/esm/transactions/blueRewards.js +27 -2
- package/dist/esm/transactions/blueRewards.js.map +1 -1
- package/dist/esm/transactions/bluefin.d.ts.map +1 -1
- package/dist/esm/transactions/bluefin.js +110 -0
- package/dist/esm/transactions/bluefin.js.map +1 -1
- package/dist/esm/transactions/collect_rewards.d.ts.map +1 -1
- package/dist/esm/transactions/collect_rewards.js +2 -1
- package/dist/esm/transactions/collect_rewards.js.map +1 -1
- package/dist/esm/transactions/deposit.d.ts.map +1 -1
- package/dist/esm/transactions/deposit.js +10 -3
- package/dist/esm/transactions/deposit.js.map +1 -1
- package/dist/esm/transactions/zapDeposit.d.ts.map +1 -1
- package/dist/esm/transactions/zapDeposit.js +59 -30
- package/dist/esm/transactions/zapDeposit.js.map +1 -1
- package/dist/esm/utils/prices.d.ts.map +1 -1
- package/dist/esm/utils/prices.js +1 -0
- package/dist/esm/utils/prices.js.map +1 -1
- package/docs/assets/highlight.css +51 -74
- package/docs/assets/icons.js +17 -20
- package/docs/assets/main.js +5 -2163
- package/docs/assets/navigation.js +1 -2
- package/docs/assets/search.js +1 -2
- package/docs/assets/style.css +850 -846
- package/docs/functions/alphaLpBreakdown.html +1 -253
- package/docs/functions/cetusLpBreakdown.html +1 -253
- package/docs/functions/claimBlueRewardTxb.html +1 -0
- package/docs/functions/claimRewardTxb.html +1 -243
- package/docs/functions/coinAmountToXTokensDoubleAsset.html +1 -267
- package/docs/functions/coinAmountToXTokensSingleAsset.html +1 -260
- package/docs/functions/coinsInPool.html +1 -438
- package/docs/functions/collectRewards.html +1 -242
- package/docs/functions/deposit.html +1 -246
- package/docs/functions/depositDoubleAssetTxb.html +1 -270
- package/docs/functions/depositSingleAssetTxb.html +1 -263
- package/docs/functions/fetchAfterTransactionEvents.html +1 -306
- package/docs/functions/fetchAutoCompoundingEvents.html +1 -257
- package/docs/functions/fetchAutoCompoundingEventsGql.html +1 -251
- package/docs/functions/fetchCetusPools.html +1 -231
- package/docs/functions/fetchChainIdentifier.html +1 -233
- package/docs/functions/fetchCheckRatioEvents.html +1 -249
- package/docs/functions/fetchLiquidityChangeEvents.html +1 -257
- package/docs/functions/fetchMultiReceipts.html +1 -261
- package/docs/functions/fetchNftHolders.html +1 -233
- package/docs/functions/fetchPools.html +1 -230
- package/docs/functions/fetchPortfolioData.html +1 -243
- package/docs/functions/fetchProtocolData.html +1 -231
- package/docs/functions/fetchTVL.html +1 -253
- package/docs/functions/fetchUserVaultBalances.html +1 -245
- package/docs/functions/fetchUserVaults.html +1 -243
- package/docs/functions/fetchUserWalletData.html +1 -243
- package/docs/functions/fetchVoloExchangeRate.html +1 -0
- package/docs/functions/fetchWithdrawV2Events.html +1 -255
- package/docs/functions/getAirdropShare.html +1 -243
- package/docs/functions/getAllDoubleAssetVaults.html +1 -235
- package/docs/functions/getAllSingleAssetVaults.html +1 -235
- package/docs/functions/getAllVaultBalances.html +1 -265
- package/docs/functions/getAllVaults.html +1 -233
- package/docs/functions/getAlphaUnlocks.html +1 -245
- package/docs/functions/getAlphaVaultBalance.html +1 -255
- package/docs/functions/getAmounts.html +1 -272
- package/docs/functions/getApr.html +1 -243
- package/docs/functions/getAprs.html +1 -255
- package/docs/functions/getApy.html +1 -243
- package/docs/functions/getApys.html +1 -255
- package/docs/functions/getCetusInvestorTicksMap.html +1 -284
- package/docs/functions/getCetusPool.html +1 -0
- package/docs/functions/getCetusSqrtPriceMap.html +1 -249
- package/docs/functions/getCoinAmountsFromLiquidity.html +1 -273
- package/docs/functions/getConf.html +1 -11763
- package/docs/functions/getCurrentTick.html +1 -247
- package/docs/functions/getDistributor.html +1 -0
- package/docs/functions/getDoubleAssetVaultBalance.html +1 -268
- package/docs/functions/getDoubleAssetVaults.html +1 -253
- package/docs/functions/getHoldersFromTransactions.html +1 -299
- package/docs/functions/getInvestor.html +1 -259
- package/docs/functions/getInvestorPoolMap.html +1 -241
- package/docs/functions/getLastAutoCompoundTime.html +1 -249
- package/docs/functions/getLatestPrices.html +1 -253
- package/docs/functions/getLiquidity.html +1 -260
- package/docs/functions/getMultiCetusPool.html +1 -0
- package/docs/functions/getMultiInvestor.html +1 -231
- package/docs/functions/getMultiLatestPrices.html +1 -233
- package/docs/functions/getMultiParentPool.html +1 -231
- package/docs/functions/getMultiPool.html +1 -231
- package/docs/functions/getMultiReceipts.html +1 -243
- package/docs/functions/getParentPool.html +1 -266
- package/docs/functions/getPool.html +1 -262
- package/docs/functions/getPoolExchangeRate.html +1 -0
- package/docs/functions/getPoolExchangeRateMap.html +1 -249
- package/docs/functions/getPoolsWeightDistribution.html +1 -0
- package/docs/functions/getPositionRange.html +1 -283
- package/docs/functions/getPositionRanges.html +1 -289
- package/docs/functions/getPositionTicks.html +1 -249
- package/docs/functions/getPriceToTick.html +1 -254
- package/docs/functions/getRebalanceHistories.html +1 -269
- package/docs/functions/getRebalanceHistory.html +1 -255
- package/docs/functions/getReceipts.html +1 -268
- package/docs/functions/getSingleAssetVaultBalance.html +1 -268
- package/docs/functions/getSingleAssetVaults.html +1 -253
- package/docs/functions/getSuiClient.html +3 -247
- package/docs/functions/getSuiNodeUrl.html +3 -232
- package/docs/functions/getTVLs-1.html +1 -243
- package/docs/functions/getTickToPrice.html +1 -254
- package/docs/functions/getTvls.html +1 -259
- package/docs/functions/getUserTokensFromTransactions.html +1 -269
- package/docs/functions/getUserTokensInUsdFromTransactions.html +1 -263
- package/docs/functions/getVaultBalance.html +1 -277
- package/docs/functions/getVaultBalanceForActiveUsers.html +1 -261
- package/docs/functions/getVaults.html +1 -250
- package/docs/functions/getXTokenVaultBalanceForActiveUsers.html +1 -261
- package/docs/functions/getZapAmounts.html +1 -323
- package/docs/functions/lastAutocompoundTime.html +1 -249
- package/docs/functions/liquidityToTokens.html +1 -253
- package/docs/functions/multiLiquidityToTokens.html +1 -271
- package/docs/functions/multiTokensToUsd.html +1 -262
- package/docs/functions/multiXTokensToLiquidity.html +1 -257
- package/docs/functions/parseUserWalletData.html +1 -243
- package/docs/functions/pendingBlueRewardAmount.html +1 -0
- package/docs/functions/setCustomSuiClient.html +5 -0
- package/docs/functions/setSuiClient.html +7 -255
- package/docs/functions/setSuiNodeUrl.html +5 -249
- package/docs/functions/setWeights.html +1 -0
- package/docs/functions/withdraw.html +1 -249
- package/docs/functions/withdrawAlphaTxb.html +1 -257
- package/docs/functions/withdrawTxb.html +1 -260
- package/docs/functions/zapDepositTxb.html +1 -300
- package/docs/index.html +41 -587
- package/docs/interfaces/Coin.html +12 -474
- package/docs/interfaces/CoinPair.html +3 -358
- package/docs/interfaces/NaviVoloData.html +3 -514
- package/docs/interfaces/PoolData.html +8 -0
- package/docs/interfaces/PoolWeightDistribution.html +4 -0
- package/docs/interfaces/RebalanceHistoryType.html +9 -652
- package/docs/modules.html +193 -1315
- package/docs/types/AfterTransactionEventNode.html +1 -305
- package/docs/types/Allocator.html +1 -321
- package/docs/types/AlphaFiDoubleAssetVault.html +1 -258
- package/docs/types/AlphaFiMultiVaultBalance.html +1 -219
- package/docs/types/AlphaFiSingleAssetVault.html +1 -244
- package/docs/types/AlphaFiVault.html +1 -214
- package/docs/types/AlphaFiVaultBalance.html +1 -220
- package/docs/types/AlphaPoolType.html +1 -383
- package/docs/types/AlphaReceipt.html +1 -220
- package/docs/types/AlphaReceiptFields.html +1 -421
- package/docs/types/AlphaVaultBalance.html +1 -245
- package/docs/types/AutoBalancePoolNames.html +1 -0
- package/docs/types/AutoCompoundingEventNode.html +1 -225
- package/docs/types/BluefinInvestor.html +1 -209
- package/docs/types/BluefinPoolType.html +1 -440
- package/docs/types/BucketInvestor.html +1 -249
- package/docs/types/CetusInvestor.html +1 -240
- package/docs/types/CetusPoolType.html +1 -433
- package/docs/types/CetusSwapOptions.html +1 -209
- package/docs/types/CoinAmounts.html +1 -216
- package/docs/types/CoinName.html +1 -290
- package/docs/types/CoinType.html +1 -291
- package/docs/types/CommonInvestorFields.html +1 -276
- package/docs/types/CreatePoolOptions.html +1 -246
- package/docs/types/Distributor.html +1 -341
- package/docs/types/DoubleAssetMultiVaultBalance.html +1 -236
- package/docs/types/DoubleAssetPoolNames.html +1 -289
- package/docs/types/DoubleAssetTokenHoldings.html +1 -232
- package/docs/types/DoubleAssetVaultBalance.html +1 -229
- package/docs/types/GetHoldersParams.html +1 -221
- package/docs/types/GetTokenHoldingsParams.html +1 -227
- package/docs/types/GetUserTokensFromTransactionsParams.html +1 -233
- package/docs/types/GetUserTokensInUsdFromTransactionsParams.html +1 -244
- package/docs/types/GetVaultBalanceForActiveUsersParams.html +1 -231
- package/docs/types/GetVaultBalanceParams.html +1 -217
- package/docs/types/HoldingsObj.html +1 -223
- package/docs/types/Icon.html +1 -266
- package/docs/types/Investor.html +1 -245
- package/docs/types/LiquidityChangeEventNode.html +1 -220
- package/docs/types/LiquidityToTokensParams.html +1 -255
- package/docs/types/LiquidityToUsdParams.html +1 -267
- package/docs/types/LoopingDebt.html +1 -258
- package/docs/types/LoopingPoolNames.html +1 -0
- package/docs/types/LpBreakdownType.html +1 -238
- package/docs/types/MemberPoolDataType.html +1 -276
- package/docs/types/MemberType.html +1 -269
- package/docs/types/MultiGetVaultBalancesParams.html +1 -229
- package/docs/types/NaviInvestor.html +1 -235
- package/docs/types/OtherReceiptFields.html +1 -373
- package/docs/types/PoolName.html +1 -326
- package/docs/types/PoolReceipt.html +1 -253
- package/docs/types/PoolType.html +1 -388
- package/docs/types/Receipt.html +1 -475
- package/docs/types/ReceiptGQL.html +1 -374
- package/docs/types/SingleAssetMultiVaultBalance.html +1 -232
- package/docs/types/SingleAssetPoolNames.html +1 -247
- package/docs/types/SingleAssetTokenHoldings.html +1 -228
- package/docs/types/SingleAssetVaultBalance.html +1 -223
- package/docs/types/SingleGetVaultBalancesParams.html +1 -224
- package/docs/types/StrategyType.html +1 -217
- package/docs/types/SuiNetwork.html +1 -213
- package/docs/types/SwapOptions.html +1 -248
- package/docs/types/TickSpacing.html +1 -212
- package/docs/types/TotalWeightType.html +1 -246
- package/docs/types/TransactionBlockType.html +1 -358
- package/docs/types/UserPoolLiquidity.html +1 -221
- package/docs/types/UserPoolTokenHoldings.html +1 -217
- package/docs/types/UserUsdHoldings.html +1 -223
- package/docs/types/VaultBalance.html +1 -216
- package/docs/types/WithdrawV2EventNode.html +1 -208
- package/docs/variables/bluefinPoolMap.html +1 -214
- package/docs/variables/cetusPoolMap.html +1 -214
- package/docs/variables/coinsList.html +1 -220
- package/docs/variables/defunctPoolsSet.html +1 -209
- package/docs/variables/doubleAssetPoolCoinMap.html +1 -237
- package/docs/variables/ignoredWalletsForDailyRevenue.html +1 -218
- package/docs/variables/loopingAccountAddresses.html +1 -219
- package/docs/variables/loopingPoolCoinMap.html +1 -233
- package/docs/variables/naviAssetMap.html +1 -215
- package/docs/variables/poolIdPoolNameMap.html +1 -218
- package/docs/variables/poolInfo.html +1 -304
- package/docs/variables/singleAssetPoolCoinMap.html +1 -229
- package/docs/variables/stableCoins.html +1 -207
- package/package.json +2 -3
|
@@ -3,24 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.convertReceiptGQLToReceipt = convertReceiptGQLToReceipt;
|
|
4
4
|
exports.getMultiReceipts = getMultiReceipts;
|
|
5
5
|
exports.getReceipts = getReceipts;
|
|
6
|
-
exports.getPoolExchangeRate = getPoolExchangeRate;
|
|
7
6
|
exports.getMultiPool = getMultiPool;
|
|
8
7
|
exports.getPool = getPool;
|
|
9
8
|
exports.getMultiParentPool = getMultiParentPool;
|
|
10
9
|
exports.getParentPool = getParentPool;
|
|
10
|
+
exports.getMultiCetusPool = getMultiCetusPool;
|
|
11
|
+
exports.getCetusPool = getCetusPool;
|
|
11
12
|
exports.getMultiInvestor = getMultiInvestor;
|
|
12
13
|
exports.getInvestor = getInvestor;
|
|
14
|
+
exports.getDistributor = getDistributor;
|
|
15
|
+
exports.getPoolExchangeRate = getPoolExchangeRate;
|
|
13
16
|
exports.fetchVoloExchangeRate = fetchVoloExchangeRate;
|
|
14
17
|
exports.multiGetNaviInvestor = multiGetNaviInvestor;
|
|
15
|
-
exports.getDistributor = getDistributor;
|
|
16
|
-
exports.getPositionRanges = getPositionRanges;
|
|
17
|
-
exports.getPositionRange = getPositionRange;
|
|
18
18
|
const index_js_1 = require("../../index.js");
|
|
19
19
|
const maps_js_1 = require("../../common/maps.js");
|
|
20
20
|
const decimal_js_1 = require("decimal.js");
|
|
21
21
|
const client_js_1 = require("../client.js");
|
|
22
22
|
const simpleCache_js_1 = require("../../utils/simpleCache.js");
|
|
23
|
-
const cetus_sui_clmm_sdk_1 = require("@cetusprotocol/cetus-sui-clmm-sdk");
|
|
24
23
|
function convertReceiptGQLToReceipt(receipts) {
|
|
25
24
|
const res = receipts.map((receipt) => {
|
|
26
25
|
return {
|
|
@@ -183,35 +182,6 @@ async function getReceipts(poolName, address, ignoreCache) {
|
|
|
183
182
|
}
|
|
184
183
|
return cachedPromise;
|
|
185
184
|
}
|
|
186
|
-
async function getPoolExchangeRate(poolName, ignoreCache) {
|
|
187
|
-
let pool;
|
|
188
|
-
try {
|
|
189
|
-
pool = await getPool(poolName, ignoreCache);
|
|
190
|
-
const xTokenSupply = new decimal_js_1.Decimal(pool.content.fields.xTokenSupply);
|
|
191
|
-
let tokensInvested = new decimal_js_1.Decimal(pool.content.fields.tokensInvested);
|
|
192
|
-
if (poolName == "ALPHA") {
|
|
193
|
-
tokensInvested = new decimal_js_1.Decimal(pool.content.fields.alpha_bal);
|
|
194
|
-
}
|
|
195
|
-
else if (maps_js_1.poolInfo[poolName].parentProtocolName == "CETUS") {
|
|
196
|
-
const investor = (await getInvestor(poolName, ignoreCache));
|
|
197
|
-
if (!investor) {
|
|
198
|
-
throw new Error(`couldnt fetch investor object for pool: ${poolName}`);
|
|
199
|
-
}
|
|
200
|
-
tokensInvested = new decimal_js_1.Decimal(pool.content.fields.tokensInvested);
|
|
201
|
-
}
|
|
202
|
-
// Check for division by zero
|
|
203
|
-
if (xTokenSupply.eq(0)) {
|
|
204
|
-
console.error("Division by zero error: tokensInvested is zero.");
|
|
205
|
-
return new decimal_js_1.Decimal(0);
|
|
206
|
-
}
|
|
207
|
-
const poolExchangeRate = tokensInvested.div(xTokenSupply);
|
|
208
|
-
return poolExchangeRate;
|
|
209
|
-
}
|
|
210
|
-
catch (err) {
|
|
211
|
-
console.log(`getPoolExchangeRate failed for poolName: ${poolName}, with error ${err}`);
|
|
212
|
-
throw err;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
185
|
const poolCache = new simpleCache_js_1.SimpleCache();
|
|
216
186
|
const poolPromiseCache = new simpleCache_js_1.SimpleCache();
|
|
217
187
|
async function getMultiPool() {
|
|
@@ -222,26 +192,37 @@ async function getMultiPool() {
|
|
|
222
192
|
const poolIds = pools.map((pool) => {
|
|
223
193
|
return maps_js_1.poolInfo[pool].poolId;
|
|
224
194
|
});
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
const poolData = o[i].data;
|
|
234
|
-
const cacheKey = `pool_${maps_js_1.poolInfo[pools[i]].poolId}`;
|
|
235
|
-
poolCache.set(cacheKey, poolData);
|
|
236
|
-
}
|
|
195
|
+
const batchSize = 49; // Set the desired batch size
|
|
196
|
+
// Create an array to hold the batches
|
|
197
|
+
const batches = [];
|
|
198
|
+
//const batches = [];
|
|
199
|
+
// Loop through the entries array and create batches
|
|
200
|
+
for (let i = 0; i < poolIds.length; i += batchSize) {
|
|
201
|
+
const batchEntries = poolIds.slice(i, i + batchSize);
|
|
202
|
+
batches.push(batchEntries); // Convert to object before pushing
|
|
237
203
|
}
|
|
238
|
-
|
|
239
|
-
|
|
204
|
+
for (const poolIdsBatch of batches) {
|
|
205
|
+
try {
|
|
206
|
+
const o = await (0, client_js_1.getSuiClient)().multiGetObjects({
|
|
207
|
+
ids: poolIdsBatch,
|
|
208
|
+
options: {
|
|
209
|
+
showContent: true,
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
for (let i = 0; i < poolIdsBatch.length; i = i + 1) {
|
|
213
|
+
const poolData = o[i].data;
|
|
214
|
+
const cacheKey = `pool_${poolIdsBatch[i]}`;
|
|
215
|
+
poolCache.set(cacheKey, poolData);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
catch (error) {
|
|
219
|
+
console.error(`Error getting multiPools - ${error}`);
|
|
220
|
+
}
|
|
240
221
|
}
|
|
241
222
|
}
|
|
242
223
|
async function getPool(poolName, ignoreCache) {
|
|
243
224
|
const suiClient = (0, client_js_1.getSuiClient)();
|
|
244
|
-
const cacheKey = `pool_${maps_js_1.poolInfo[poolName
|
|
225
|
+
const cacheKey = `pool_${maps_js_1.poolInfo[poolName].poolId}`;
|
|
245
226
|
if (ignoreCache) {
|
|
246
227
|
poolCache.delete(cacheKey);
|
|
247
228
|
poolPromiseCache.delete(cacheKey);
|
|
@@ -283,36 +264,135 @@ async function getPool(poolName, ignoreCache) {
|
|
|
283
264
|
poolPromiseCache.set(cacheKey, poolPromise);
|
|
284
265
|
return poolPromise;
|
|
285
266
|
}
|
|
286
|
-
const
|
|
287
|
-
const
|
|
267
|
+
const parentPoolCache = new simpleCache_js_1.SimpleCache();
|
|
268
|
+
const parentPoolPromiseCache = new simpleCache_js_1.SimpleCache();
|
|
288
269
|
async function getMultiParentPool() {
|
|
289
270
|
let pools = Object.keys(maps_js_1.poolInfo);
|
|
290
271
|
pools = pools.filter((pool) => {
|
|
291
|
-
return maps_js_1.poolInfo[pool].
|
|
272
|
+
return maps_js_1.poolInfo[pool].parentPoolId !== "";
|
|
292
273
|
});
|
|
293
|
-
const
|
|
274
|
+
const parentPoolIds = pools.map((pool) => {
|
|
294
275
|
return maps_js_1.poolInfo[pool].parentPoolId;
|
|
295
276
|
});
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
cetusPoolCache.set(cacheKey, poolData);
|
|
307
|
-
}
|
|
277
|
+
const poolsSet = new Set(parentPoolIds);
|
|
278
|
+
const poolIds = [...poolsSet];
|
|
279
|
+
const batchSize = 49;
|
|
280
|
+
// Create an array to hold the batches
|
|
281
|
+
const batches = [];
|
|
282
|
+
//const batches = [];
|
|
283
|
+
// Loop through the entries array and create batches
|
|
284
|
+
for (let i = 0; i < poolIds.length; i += batchSize) {
|
|
285
|
+
const batchEntries = poolIds.slice(i, i + batchSize);
|
|
286
|
+
batches.push(batchEntries); // Convert to object before pushing
|
|
308
287
|
}
|
|
309
|
-
|
|
310
|
-
|
|
288
|
+
for (const parentPoolIdsBatch of batches) {
|
|
289
|
+
try {
|
|
290
|
+
const o = await (0, client_js_1.getSuiClient)().multiGetObjects({
|
|
291
|
+
ids: parentPoolIdsBatch,
|
|
292
|
+
options: {
|
|
293
|
+
showContent: true,
|
|
294
|
+
},
|
|
295
|
+
});
|
|
296
|
+
for (let i = 0; i < parentPoolIdsBatch.length; i = i + 1) {
|
|
297
|
+
const parentPoolData = o[i].data;
|
|
298
|
+
const cacheKey = `parentPool_${parentPoolIdsBatch[i]}`;
|
|
299
|
+
parentPoolCache.set(cacheKey, parentPoolData);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
console.error(`Error getting multiParentPools - ${error}`);
|
|
304
|
+
}
|
|
311
305
|
}
|
|
312
306
|
}
|
|
313
307
|
async function getParentPool(poolName, ignoreCache) {
|
|
314
308
|
const suiClient = (0, client_js_1.getSuiClient)();
|
|
315
|
-
const cacheKey = `
|
|
309
|
+
const cacheKey = `parentPool_${maps_js_1.poolInfo[poolName].parentPoolId}`;
|
|
310
|
+
if (ignoreCache) {
|
|
311
|
+
parentPoolCache.delete(cacheKey);
|
|
312
|
+
parentPoolPromiseCache.delete(cacheKey);
|
|
313
|
+
}
|
|
314
|
+
// Check if the pool is already in the cache
|
|
315
|
+
const cachedPool = parentPoolCache.get(cacheKey);
|
|
316
|
+
if (cachedPool) {
|
|
317
|
+
return cachedPool;
|
|
318
|
+
}
|
|
319
|
+
// Check if there is already a promise in the cache
|
|
320
|
+
let parentPoolPromise = parentPoolPromiseCache.get(cacheKey);
|
|
321
|
+
if (parentPoolPromise) {
|
|
322
|
+
return parentPoolPromise;
|
|
323
|
+
}
|
|
324
|
+
// If not, create a new promise and cache it
|
|
325
|
+
parentPoolPromise = (async () => {
|
|
326
|
+
try {
|
|
327
|
+
const id = maps_js_1.poolInfo[poolName]
|
|
328
|
+
? maps_js_1.poolInfo[poolName].parentPoolId
|
|
329
|
+
: index_js_1.cetusPoolMap[poolName]
|
|
330
|
+
? index_js_1.cetusPoolMap[poolName]
|
|
331
|
+
: index_js_1.bluefinPoolMap[poolName];
|
|
332
|
+
const o = await suiClient.getObject({
|
|
333
|
+
id: id,
|
|
334
|
+
options: {
|
|
335
|
+
showContent: true,
|
|
336
|
+
},
|
|
337
|
+
});
|
|
338
|
+
const parentPool = o.data;
|
|
339
|
+
// Cache the pool object
|
|
340
|
+
parentPoolCache.set(cacheKey, parentPool);
|
|
341
|
+
return parentPool;
|
|
342
|
+
}
|
|
343
|
+
catch (err) {
|
|
344
|
+
console.error(`getParentPool failed for poolName: ${poolName}`);
|
|
345
|
+
throw err;
|
|
346
|
+
}
|
|
347
|
+
finally {
|
|
348
|
+
// Remove the promise from the cache after it resolves
|
|
349
|
+
parentPoolPromiseCache.delete(cacheKey);
|
|
350
|
+
}
|
|
351
|
+
})();
|
|
352
|
+
// Cache the promise
|
|
353
|
+
parentPoolPromiseCache.set(cacheKey, parentPoolPromise);
|
|
354
|
+
return parentPoolPromise;
|
|
355
|
+
}
|
|
356
|
+
const cetusPoolCache = new simpleCache_js_1.SimpleCache();
|
|
357
|
+
const cetusPoolPromiseCache = new simpleCache_js_1.SimpleCache();
|
|
358
|
+
async function getMultiCetusPool() {
|
|
359
|
+
let pools = Object.keys(index_js_1.cetusPoolMap);
|
|
360
|
+
pools = pools.filter((pool) => {
|
|
361
|
+
return index_js_1.cetusPoolMap[pool] !== "";
|
|
362
|
+
});
|
|
363
|
+
const poolIds = pools.map((pool) => {
|
|
364
|
+
return index_js_1.cetusPoolMap[pool];
|
|
365
|
+
});
|
|
366
|
+
const batchSize = 49;
|
|
367
|
+
// Create an array to hold the batches
|
|
368
|
+
const batches = [];
|
|
369
|
+
// Loop through the entries array and create batches
|
|
370
|
+
for (let i = 0; i < poolIds.length; i += batchSize) {
|
|
371
|
+
const batchEntries = poolIds.slice(i, i + batchSize);
|
|
372
|
+
batches.push(batchEntries); // Convert to object before pushing
|
|
373
|
+
}
|
|
374
|
+
for (const cetusPoolIdsBatch of batches) {
|
|
375
|
+
try {
|
|
376
|
+
const o = await (0, client_js_1.getSuiClient)().multiGetObjects({
|
|
377
|
+
ids: cetusPoolIdsBatch,
|
|
378
|
+
options: {
|
|
379
|
+
showContent: true,
|
|
380
|
+
},
|
|
381
|
+
});
|
|
382
|
+
for (let i = 0; i < pools.length; i = i + 1) {
|
|
383
|
+
const poolData = o[i].data;
|
|
384
|
+
const cacheKey = `cetusPool_${index_js_1.cetusPoolMap[pools[i]]}`;
|
|
385
|
+
cetusPoolCache.set(cacheKey, poolData);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
catch (e) {
|
|
389
|
+
console.error(`Error getting multiCetusPools`, e);
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
async function getCetusPool(poolName, ignoreCache) {
|
|
394
|
+
const suiClient = (0, client_js_1.getSuiClient)();
|
|
395
|
+
const cacheKey = `cetusPool_${index_js_1.cetusPoolMap[poolName]}`;
|
|
316
396
|
if (ignoreCache) {
|
|
317
397
|
cetusPoolCache.delete(cacheKey);
|
|
318
398
|
cetusPoolPromiseCache.delete(cacheKey);
|
|
@@ -330,13 +410,8 @@ async function getParentPool(poolName, ignoreCache) {
|
|
|
330
410
|
// If not, create a new promise and cache it
|
|
331
411
|
cetusPoolPromise = (async () => {
|
|
332
412
|
try {
|
|
333
|
-
const id = maps_js_1.poolInfo[poolName]
|
|
334
|
-
? maps_js_1.poolInfo[poolName].parentPoolId
|
|
335
|
-
: index_js_1.cetusPoolMap[poolName]
|
|
336
|
-
? index_js_1.cetusPoolMap[poolName]
|
|
337
|
-
: index_js_1.bluefinPoolMap[poolName];
|
|
338
413
|
const o = await suiClient.getObject({
|
|
339
|
-
id:
|
|
414
|
+
id: index_js_1.cetusPoolMap[poolName],
|
|
340
415
|
options: {
|
|
341
416
|
showContent: true,
|
|
342
417
|
},
|
|
@@ -346,9 +421,9 @@ async function getParentPool(poolName, ignoreCache) {
|
|
|
346
421
|
cetusPoolCache.set(cacheKey, cetusPool);
|
|
347
422
|
return cetusPool;
|
|
348
423
|
}
|
|
349
|
-
catch (
|
|
424
|
+
catch (e) {
|
|
350
425
|
console.error(`getCetusPool failed for poolName: ${poolName}`);
|
|
351
|
-
|
|
426
|
+
return undefined;
|
|
352
427
|
}
|
|
353
428
|
finally {
|
|
354
429
|
// Remove the promise from the cache after it resolves
|
|
@@ -369,26 +444,37 @@ async function getMultiInvestor() {
|
|
|
369
444
|
const investorIds = pools.map((pool) => {
|
|
370
445
|
return maps_js_1.poolInfo[pool].investorId;
|
|
371
446
|
});
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
const investorData = o[i].data;
|
|
381
|
-
const cacheKey = `investor_${maps_js_1.poolInfo[pools[i]].investorId}`;
|
|
382
|
-
investorCache.set(cacheKey, investorData);
|
|
383
|
-
}
|
|
447
|
+
const batchSize = 49;
|
|
448
|
+
// Create an array to hold the batches
|
|
449
|
+
const batches = [];
|
|
450
|
+
//const batches = [];
|
|
451
|
+
// Loop through the entries array and create batches
|
|
452
|
+
for (let i = 0; i < investorIds.length; i += batchSize) {
|
|
453
|
+
const batchEntries = investorIds.slice(i, i + batchSize);
|
|
454
|
+
batches.push(batchEntries); // Convert to object before pushing
|
|
384
455
|
}
|
|
385
|
-
|
|
386
|
-
|
|
456
|
+
for (const investorIdsBatch of batches) {
|
|
457
|
+
try {
|
|
458
|
+
const o = await (0, client_js_1.getSuiClient)().multiGetObjects({
|
|
459
|
+
ids: investorIdsBatch,
|
|
460
|
+
options: {
|
|
461
|
+
showContent: true,
|
|
462
|
+
},
|
|
463
|
+
});
|
|
464
|
+
for (let i = 0; i < investorIdsBatch.length; i = i + 1) {
|
|
465
|
+
const investorData = o[i].data;
|
|
466
|
+
const cacheKey = `investor_${investorIdsBatch[i]}`;
|
|
467
|
+
investorCache.set(cacheKey, investorData);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
console.error(`Error getting multiInvestor - ${error}`);
|
|
472
|
+
}
|
|
387
473
|
}
|
|
388
474
|
}
|
|
389
475
|
async function getInvestor(poolName, ignoreCache) {
|
|
390
476
|
const suiClient = (0, client_js_1.getSuiClient)();
|
|
391
|
-
const cacheKey = `investor_${maps_js_1.poolInfo[poolName
|
|
477
|
+
const cacheKey = `investor_${maps_js_1.poolInfo[poolName].investorId}`;
|
|
392
478
|
if (ignoreCache) {
|
|
393
479
|
investorCache.delete(cacheKey);
|
|
394
480
|
investorPromiseCache.delete(cacheKey);
|
|
@@ -407,7 +493,7 @@ async function getInvestor(poolName, ignoreCache) {
|
|
|
407
493
|
cetusInvestorPromise = (async () => {
|
|
408
494
|
try {
|
|
409
495
|
const o = await suiClient.getObject({
|
|
410
|
-
id: maps_js_1.poolInfo[poolName
|
|
496
|
+
id: maps_js_1.poolInfo[poolName].investorId,
|
|
411
497
|
options: {
|
|
412
498
|
showContent: true,
|
|
413
499
|
},
|
|
@@ -442,46 +528,6 @@ async function getInvestor(poolName, ignoreCache) {
|
|
|
442
528
|
investorPromiseCache.set(cacheKey, cetusInvestorPromise);
|
|
443
529
|
return cetusInvestorPromise;
|
|
444
530
|
}
|
|
445
|
-
async function fetchVoloExchangeRate() {
|
|
446
|
-
const apiUrl = "https://open-api.naviprotocol.io/api/volo/stats";
|
|
447
|
-
const NaviVoloDetails = await fetch(apiUrl)
|
|
448
|
-
.then(async (response) => {
|
|
449
|
-
if (!response.ok) {
|
|
450
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
451
|
-
}
|
|
452
|
-
const data = (await response.json()); // Parse the JSON response
|
|
453
|
-
return data;
|
|
454
|
-
})
|
|
455
|
-
.catch((error) => {
|
|
456
|
-
console.log("failed to fetch Navi-volo details", error);
|
|
457
|
-
throw error;
|
|
458
|
-
});
|
|
459
|
-
return NaviVoloDetails;
|
|
460
|
-
}
|
|
461
|
-
async function multiGetNaviInvestor(poolNames) {
|
|
462
|
-
const results = {};
|
|
463
|
-
const poolInvestorIds = [];
|
|
464
|
-
for (const poolName of poolNames) {
|
|
465
|
-
poolInvestorIds.push(maps_js_1.poolInfo[poolName.toUpperCase()].investorId);
|
|
466
|
-
}
|
|
467
|
-
try {
|
|
468
|
-
const suiClient = (0, client_js_1.getSuiClient)();
|
|
469
|
-
const objects = await suiClient.multiGetObjects({
|
|
470
|
-
ids: poolInvestorIds,
|
|
471
|
-
options: { showContent: true },
|
|
472
|
-
});
|
|
473
|
-
for (let i = 0; i < objects.length; i++) {
|
|
474
|
-
const investor = objects[i].data;
|
|
475
|
-
results[poolNames[i]] = investor;
|
|
476
|
-
}
|
|
477
|
-
return results;
|
|
478
|
-
}
|
|
479
|
-
catch (err) {
|
|
480
|
-
//improve
|
|
481
|
-
console.error("multiGetNaviInvestor failed for poolNames: ", poolNames.join(", "));
|
|
482
|
-
throw err;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
531
|
const distributorCache = new simpleCache_js_1.SimpleCache();
|
|
486
532
|
const distributorPromiseCache = new simpleCache_js_1.SimpleCache();
|
|
487
533
|
async function getDistributor(ignoreCache) {
|
|
@@ -528,83 +574,127 @@ async function getDistributor(ignoreCache) {
|
|
|
528
574
|
distributorPromiseCache.set(cacheKey, distributorPromise);
|
|
529
575
|
return distributorPromise;
|
|
530
576
|
}
|
|
531
|
-
async function
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
577
|
+
async function getPoolExchangeRate(poolName, ignoreCache) {
|
|
578
|
+
let pool;
|
|
579
|
+
try {
|
|
580
|
+
pool = await getPool(poolName, ignoreCache);
|
|
581
|
+
const xTokenSupply = new decimal_js_1.Decimal(pool.content.fields.xTokenSupply);
|
|
582
|
+
let tokensInvested = new decimal_js_1.Decimal(pool.content.fields.tokensInvested);
|
|
583
|
+
if (poolName == "ALPHA") {
|
|
584
|
+
tokensInvested = new decimal_js_1.Decimal(pool.content.fields.alpha_bal);
|
|
538
585
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
586
|
+
else if (maps_js_1.poolInfo[poolName].parentProtocolName == "CETUS") {
|
|
587
|
+
const investor = (await getInvestor(poolName, ignoreCache));
|
|
588
|
+
if (!investor) {
|
|
589
|
+
throw new Error(`couldnt fetch investor object for pool: ${poolName}`);
|
|
590
|
+
}
|
|
591
|
+
tokensInvested = new decimal_js_1.Decimal(pool.content.fields.tokensInvested);
|
|
542
592
|
}
|
|
543
|
-
|
|
544
|
-
|
|
593
|
+
// Check for division by zero
|
|
594
|
+
if (xTokenSupply.eq(0)) {
|
|
595
|
+
console.error("Division by zero error: tokensInvested is zero.");
|
|
596
|
+
return new decimal_js_1.Decimal(0);
|
|
545
597
|
}
|
|
546
|
-
const
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
598
|
+
const poolExchangeRate = tokensInvested.div(xTokenSupply);
|
|
599
|
+
return poolExchangeRate;
|
|
600
|
+
}
|
|
601
|
+
catch (err) {
|
|
602
|
+
console.log(`getPoolExchangeRate failed for poolName: ${poolName}, with error ${err}`);
|
|
603
|
+
throw err;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
const naviVoloExchangeRateCache = new simpleCache_js_1.SimpleCache();
|
|
607
|
+
const naviVoloExchangeRatePromiseCache = new simpleCache_js_1.SimpleCache();
|
|
608
|
+
async function fetchVoloExchangeRate(ignoreCache) {
|
|
609
|
+
const apiUrl = "https://open-api.naviprotocol.io/api/volo/stats";
|
|
610
|
+
let NaviVoloDetails;
|
|
611
|
+
if (ignoreCache) {
|
|
612
|
+
naviVoloExchangeRateCache.clear();
|
|
613
|
+
naviVoloExchangeRatePromiseCache.delete(apiUrl);
|
|
614
|
+
}
|
|
615
|
+
const cachedResponse = naviVoloExchangeRateCache.get(apiUrl);
|
|
616
|
+
if (cachedResponse) {
|
|
617
|
+
NaviVoloDetails = cachedResponse;
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
const default_volo_data = {
|
|
621
|
+
data: {
|
|
622
|
+
operatorBalance: "",
|
|
623
|
+
collectableFee: "",
|
|
624
|
+
pendingStakes: "",
|
|
625
|
+
poolTotalRewards: "0",
|
|
626
|
+
unstakeTicketSupply: "",
|
|
627
|
+
totalStaked: "",
|
|
628
|
+
activeStake: "",
|
|
629
|
+
calcTotalRewards: "",
|
|
630
|
+
currentEpoch: "",
|
|
631
|
+
validators: {},
|
|
632
|
+
exchangeRate: (1 / 0.973).toString(),
|
|
633
|
+
totalSupply: "",
|
|
634
|
+
apy: "",
|
|
635
|
+
sortedValidators: [""],
|
|
636
|
+
maxInstantUnstake: "",
|
|
637
|
+
maxNoFeeUnstake: "",
|
|
638
|
+
},
|
|
639
|
+
code: 0,
|
|
640
|
+
};
|
|
641
|
+
try {
|
|
642
|
+
let cachedPromise = naviVoloExchangeRatePromiseCache.get(apiUrl);
|
|
643
|
+
if (!cachedPromise) {
|
|
644
|
+
cachedPromise = fetch(apiUrl)
|
|
645
|
+
.then(async (response) => {
|
|
646
|
+
if (!response.ok) {
|
|
647
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
648
|
+
}
|
|
649
|
+
const data = (await response.json()); // Parse the JSON response
|
|
650
|
+
naviVoloExchangeRateCache.set(apiUrl, data); // Cache the response
|
|
651
|
+
naviVoloExchangeRatePromiseCache.delete(apiUrl); // Remove the promise from the cache
|
|
652
|
+
return data;
|
|
653
|
+
})
|
|
654
|
+
.catch((error) => {
|
|
655
|
+
naviVoloExchangeRatePromiseCache.delete(apiUrl); // Ensure the promise is removed on error
|
|
656
|
+
throw error;
|
|
657
|
+
});
|
|
658
|
+
naviVoloExchangeRatePromiseCache.set(apiUrl, cachedPromise);
|
|
659
|
+
NaviVoloDetails = await cachedPromise;
|
|
660
|
+
return cachedPromise;
|
|
556
661
|
}
|
|
557
|
-
|
|
558
|
-
|
|
662
|
+
else {
|
|
663
|
+
NaviVoloDetails = default_volo_data;
|
|
664
|
+
return Promise.resolve(default_volo_data);
|
|
559
665
|
}
|
|
560
|
-
const lowerPrice = cetus_sui_clmm_sdk_1.TickMath.tickIndexToPrice(lowerTick, coinA.expo, coinB.expo);
|
|
561
|
-
const upperPrice = cetus_sui_clmm_sdk_1.TickMath.tickIndexToPrice(upperTick, coinA.expo, coinB.expo);
|
|
562
|
-
res.set(poolName, {
|
|
563
|
-
lowerPrice: lowerPrice.toString(),
|
|
564
|
-
upperPrice: upperPrice.toString(),
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
}));
|
|
568
|
-
return res;
|
|
569
|
-
}
|
|
570
|
-
async function getPositionRange(ignoreCache) {
|
|
571
|
-
const res = new Map();
|
|
572
|
-
for (const poolNameString of Object.keys(maps_js_1.poolInfo)) {
|
|
573
|
-
const poolName = poolNameString;
|
|
574
|
-
if (poolName == "ALPHA" ||
|
|
575
|
-
!["CETUS", "BLUEFIN"].includes(maps_js_1.poolInfo[poolNameString].parentProtocolName)) {
|
|
576
|
-
continue;
|
|
577
|
-
}
|
|
578
|
-
let investor;
|
|
579
|
-
if (maps_js_1.poolInfo[poolNameString].parentProtocolName == "CETUS") {
|
|
580
|
-
investor = (await getInvestor(poolName, ignoreCache));
|
|
581
666
|
}
|
|
582
|
-
|
|
583
|
-
|
|
667
|
+
catch (error) {
|
|
668
|
+
console.log("error in api", error);
|
|
669
|
+
NaviVoloDetails = default_volo_data;
|
|
670
|
+
return Promise.resolve(default_volo_data);
|
|
584
671
|
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
upperPrice: upperPrice.toString(),
|
|
604
|
-
});
|
|
672
|
+
}
|
|
673
|
+
return NaviVoloDetails;
|
|
674
|
+
}
|
|
675
|
+
async function multiGetNaviInvestor(poolNames) {
|
|
676
|
+
const results = {};
|
|
677
|
+
const poolInvestorIds = [];
|
|
678
|
+
for (const poolName of poolNames) {
|
|
679
|
+
poolInvestorIds.push(maps_js_1.poolInfo[poolName].investorId);
|
|
680
|
+
}
|
|
681
|
+
try {
|
|
682
|
+
const suiClient = (0, client_js_1.getSuiClient)();
|
|
683
|
+
const objects = await suiClient.multiGetObjects({
|
|
684
|
+
ids: poolInvestorIds,
|
|
685
|
+
options: { showContent: true },
|
|
686
|
+
});
|
|
687
|
+
for (let i = 0; i < objects.length; i++) {
|
|
688
|
+
const investor = objects[i].data;
|
|
689
|
+
results[poolNames[i]] = investor;
|
|
605
690
|
}
|
|
691
|
+
return results;
|
|
692
|
+
}
|
|
693
|
+
catch (err) {
|
|
694
|
+
//improve
|
|
695
|
+
console.error("multiGetNaviInvestor failed for poolNames: ", poolNames.join(", "));
|
|
696
|
+
throw err;
|
|
606
697
|
}
|
|
607
|
-
return res;
|
|
608
698
|
}
|
|
609
699
|
/*
|
|
610
700
|
for the missing pools, add a promise, each of those promises waits for there respective object from a map, that map is populated all at once,
|