@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
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { fetchMultiReceipts, cetusPoolMap, bluefinPoolMap, getConf,
|
|
2
|
-
import {
|
|
1
|
+
import { fetchMultiReceipts, cetusPoolMap, bluefinPoolMap, getConf, } from "../../index.js";
|
|
2
|
+
import { poolInfo } from "../../common/maps.js";
|
|
3
3
|
import { Decimal } from "decimal.js";
|
|
4
4
|
import { getSuiClient } from "../client.js";
|
|
5
5
|
import { SimpleCache } from "../../utils/simpleCache.js";
|
|
6
|
-
import { TickMath } from "@cetusprotocol/cetus-sui-clmm-sdk";
|
|
7
6
|
export function convertReceiptGQLToReceipt(receipts) {
|
|
8
7
|
const res = receipts.map((receipt) => {
|
|
9
8
|
return {
|
|
@@ -166,35 +165,6 @@ export async function getReceipts(poolName, address, ignoreCache) {
|
|
|
166
165
|
}
|
|
167
166
|
return cachedPromise;
|
|
168
167
|
}
|
|
169
|
-
export async function getPoolExchangeRate(poolName, ignoreCache) {
|
|
170
|
-
let pool;
|
|
171
|
-
try {
|
|
172
|
-
pool = await getPool(poolName, ignoreCache);
|
|
173
|
-
const xTokenSupply = new Decimal(pool.content.fields.xTokenSupply);
|
|
174
|
-
let tokensInvested = new Decimal(pool.content.fields.tokensInvested);
|
|
175
|
-
if (poolName == "ALPHA") {
|
|
176
|
-
tokensInvested = new Decimal(pool.content.fields.alpha_bal);
|
|
177
|
-
}
|
|
178
|
-
else if (poolInfo[poolName].parentProtocolName == "CETUS") {
|
|
179
|
-
const investor = (await getInvestor(poolName, ignoreCache));
|
|
180
|
-
if (!investor) {
|
|
181
|
-
throw new Error(`couldnt fetch investor object for pool: ${poolName}`);
|
|
182
|
-
}
|
|
183
|
-
tokensInvested = new Decimal(pool.content.fields.tokensInvested);
|
|
184
|
-
}
|
|
185
|
-
// Check for division by zero
|
|
186
|
-
if (xTokenSupply.eq(0)) {
|
|
187
|
-
console.error("Division by zero error: tokensInvested is zero.");
|
|
188
|
-
return new Decimal(0);
|
|
189
|
-
}
|
|
190
|
-
const poolExchangeRate = tokensInvested.div(xTokenSupply);
|
|
191
|
-
return poolExchangeRate;
|
|
192
|
-
}
|
|
193
|
-
catch (err) {
|
|
194
|
-
console.log(`getPoolExchangeRate failed for poolName: ${poolName}, with error ${err}`);
|
|
195
|
-
throw err;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
168
|
const poolCache = new SimpleCache();
|
|
199
169
|
const poolPromiseCache = new SimpleCache();
|
|
200
170
|
export async function getMultiPool() {
|
|
@@ -205,26 +175,37 @@ export async function getMultiPool() {
|
|
|
205
175
|
const poolIds = pools.map((pool) => {
|
|
206
176
|
return poolInfo[pool].poolId;
|
|
207
177
|
});
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const poolData = o[i].data;
|
|
217
|
-
const cacheKey = `pool_${poolInfo[pools[i]].poolId}`;
|
|
218
|
-
poolCache.set(cacheKey, poolData);
|
|
219
|
-
}
|
|
178
|
+
const batchSize = 49; // Set the desired batch size
|
|
179
|
+
// Create an array to hold the batches
|
|
180
|
+
const batches = [];
|
|
181
|
+
//const batches = [];
|
|
182
|
+
// Loop through the entries array and create batches
|
|
183
|
+
for (let i = 0; i < poolIds.length; i += batchSize) {
|
|
184
|
+
const batchEntries = poolIds.slice(i, i + batchSize);
|
|
185
|
+
batches.push(batchEntries); // Convert to object before pushing
|
|
220
186
|
}
|
|
221
|
-
|
|
222
|
-
|
|
187
|
+
for (const poolIdsBatch of batches) {
|
|
188
|
+
try {
|
|
189
|
+
const o = await getSuiClient().multiGetObjects({
|
|
190
|
+
ids: poolIdsBatch,
|
|
191
|
+
options: {
|
|
192
|
+
showContent: true,
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
for (let i = 0; i < poolIdsBatch.length; i = i + 1) {
|
|
196
|
+
const poolData = o[i].data;
|
|
197
|
+
const cacheKey = `pool_${poolIdsBatch[i]}`;
|
|
198
|
+
poolCache.set(cacheKey, poolData);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
console.error(`Error getting multiPools - ${error}`);
|
|
203
|
+
}
|
|
223
204
|
}
|
|
224
205
|
}
|
|
225
206
|
export async function getPool(poolName, ignoreCache) {
|
|
226
207
|
const suiClient = getSuiClient();
|
|
227
|
-
const cacheKey = `pool_${poolInfo[poolName
|
|
208
|
+
const cacheKey = `pool_${poolInfo[poolName].poolId}`;
|
|
228
209
|
if (ignoreCache) {
|
|
229
210
|
poolCache.delete(cacheKey);
|
|
230
211
|
poolPromiseCache.delete(cacheKey);
|
|
@@ -266,36 +247,135 @@ export async function getPool(poolName, ignoreCache) {
|
|
|
266
247
|
poolPromiseCache.set(cacheKey, poolPromise);
|
|
267
248
|
return poolPromise;
|
|
268
249
|
}
|
|
269
|
-
const
|
|
270
|
-
const
|
|
250
|
+
const parentPoolCache = new SimpleCache();
|
|
251
|
+
const parentPoolPromiseCache = new SimpleCache();
|
|
271
252
|
export async function getMultiParentPool() {
|
|
272
253
|
let pools = Object.keys(poolInfo);
|
|
273
254
|
pools = pools.filter((pool) => {
|
|
274
|
-
return poolInfo[pool].
|
|
255
|
+
return poolInfo[pool].parentPoolId !== "";
|
|
275
256
|
});
|
|
276
|
-
const
|
|
257
|
+
const parentPoolIds = pools.map((pool) => {
|
|
277
258
|
return poolInfo[pool].parentPoolId;
|
|
278
259
|
});
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
cetusPoolCache.set(cacheKey, poolData);
|
|
290
|
-
}
|
|
260
|
+
const poolsSet = new Set(parentPoolIds);
|
|
261
|
+
const poolIds = [...poolsSet];
|
|
262
|
+
const batchSize = 49;
|
|
263
|
+
// Create an array to hold the batches
|
|
264
|
+
const batches = [];
|
|
265
|
+
//const batches = [];
|
|
266
|
+
// Loop through the entries array and create batches
|
|
267
|
+
for (let i = 0; i < poolIds.length; i += batchSize) {
|
|
268
|
+
const batchEntries = poolIds.slice(i, i + batchSize);
|
|
269
|
+
batches.push(batchEntries); // Convert to object before pushing
|
|
291
270
|
}
|
|
292
|
-
|
|
293
|
-
|
|
271
|
+
for (const parentPoolIdsBatch of batches) {
|
|
272
|
+
try {
|
|
273
|
+
const o = await getSuiClient().multiGetObjects({
|
|
274
|
+
ids: parentPoolIdsBatch,
|
|
275
|
+
options: {
|
|
276
|
+
showContent: true,
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
for (let i = 0; i < parentPoolIdsBatch.length; i = i + 1) {
|
|
280
|
+
const parentPoolData = o[i].data;
|
|
281
|
+
const cacheKey = `parentPool_${parentPoolIdsBatch[i]}`;
|
|
282
|
+
parentPoolCache.set(cacheKey, parentPoolData);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
console.error(`Error getting multiParentPools - ${error}`);
|
|
287
|
+
}
|
|
294
288
|
}
|
|
295
289
|
}
|
|
296
290
|
export async function getParentPool(poolName, ignoreCache) {
|
|
297
291
|
const suiClient = getSuiClient();
|
|
298
|
-
const cacheKey = `
|
|
292
|
+
const cacheKey = `parentPool_${poolInfo[poolName].parentPoolId}`;
|
|
293
|
+
if (ignoreCache) {
|
|
294
|
+
parentPoolCache.delete(cacheKey);
|
|
295
|
+
parentPoolPromiseCache.delete(cacheKey);
|
|
296
|
+
}
|
|
297
|
+
// Check if the pool is already in the cache
|
|
298
|
+
const cachedPool = parentPoolCache.get(cacheKey);
|
|
299
|
+
if (cachedPool) {
|
|
300
|
+
return cachedPool;
|
|
301
|
+
}
|
|
302
|
+
// Check if there is already a promise in the cache
|
|
303
|
+
let parentPoolPromise = parentPoolPromiseCache.get(cacheKey);
|
|
304
|
+
if (parentPoolPromise) {
|
|
305
|
+
return parentPoolPromise;
|
|
306
|
+
}
|
|
307
|
+
// If not, create a new promise and cache it
|
|
308
|
+
parentPoolPromise = (async () => {
|
|
309
|
+
try {
|
|
310
|
+
const id = poolInfo[poolName]
|
|
311
|
+
? poolInfo[poolName].parentPoolId
|
|
312
|
+
: cetusPoolMap[poolName]
|
|
313
|
+
? cetusPoolMap[poolName]
|
|
314
|
+
: bluefinPoolMap[poolName];
|
|
315
|
+
const o = await suiClient.getObject({
|
|
316
|
+
id: id,
|
|
317
|
+
options: {
|
|
318
|
+
showContent: true,
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
const parentPool = o.data;
|
|
322
|
+
// Cache the pool object
|
|
323
|
+
parentPoolCache.set(cacheKey, parentPool);
|
|
324
|
+
return parentPool;
|
|
325
|
+
}
|
|
326
|
+
catch (err) {
|
|
327
|
+
console.error(`getParentPool failed for poolName: ${poolName}`);
|
|
328
|
+
throw err;
|
|
329
|
+
}
|
|
330
|
+
finally {
|
|
331
|
+
// Remove the promise from the cache after it resolves
|
|
332
|
+
parentPoolPromiseCache.delete(cacheKey);
|
|
333
|
+
}
|
|
334
|
+
})();
|
|
335
|
+
// Cache the promise
|
|
336
|
+
parentPoolPromiseCache.set(cacheKey, parentPoolPromise);
|
|
337
|
+
return parentPoolPromise;
|
|
338
|
+
}
|
|
339
|
+
const cetusPoolCache = new SimpleCache();
|
|
340
|
+
const cetusPoolPromiseCache = new SimpleCache();
|
|
341
|
+
export async function getMultiCetusPool() {
|
|
342
|
+
let pools = Object.keys(cetusPoolMap);
|
|
343
|
+
pools = pools.filter((pool) => {
|
|
344
|
+
return cetusPoolMap[pool] !== "";
|
|
345
|
+
});
|
|
346
|
+
const poolIds = pools.map((pool) => {
|
|
347
|
+
return cetusPoolMap[pool];
|
|
348
|
+
});
|
|
349
|
+
const batchSize = 49;
|
|
350
|
+
// Create an array to hold the batches
|
|
351
|
+
const batches = [];
|
|
352
|
+
// Loop through the entries array and create batches
|
|
353
|
+
for (let i = 0; i < poolIds.length; i += batchSize) {
|
|
354
|
+
const batchEntries = poolIds.slice(i, i + batchSize);
|
|
355
|
+
batches.push(batchEntries); // Convert to object before pushing
|
|
356
|
+
}
|
|
357
|
+
for (const cetusPoolIdsBatch of batches) {
|
|
358
|
+
try {
|
|
359
|
+
const o = await getSuiClient().multiGetObjects({
|
|
360
|
+
ids: cetusPoolIdsBatch,
|
|
361
|
+
options: {
|
|
362
|
+
showContent: true,
|
|
363
|
+
},
|
|
364
|
+
});
|
|
365
|
+
for (let i = 0; i < pools.length; i = i + 1) {
|
|
366
|
+
const poolData = o[i].data;
|
|
367
|
+
const cacheKey = `cetusPool_${cetusPoolMap[pools[i]]}`;
|
|
368
|
+
cetusPoolCache.set(cacheKey, poolData);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
catch (e) {
|
|
372
|
+
console.error(`Error getting multiCetusPools`, e);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
export async function getCetusPool(poolName, ignoreCache) {
|
|
377
|
+
const suiClient = getSuiClient();
|
|
378
|
+
const cacheKey = `cetusPool_${cetusPoolMap[poolName]}`;
|
|
299
379
|
if (ignoreCache) {
|
|
300
380
|
cetusPoolCache.delete(cacheKey);
|
|
301
381
|
cetusPoolPromiseCache.delete(cacheKey);
|
|
@@ -313,13 +393,8 @@ export async function getParentPool(poolName, ignoreCache) {
|
|
|
313
393
|
// If not, create a new promise and cache it
|
|
314
394
|
cetusPoolPromise = (async () => {
|
|
315
395
|
try {
|
|
316
|
-
const id = poolInfo[poolName]
|
|
317
|
-
? poolInfo[poolName].parentPoolId
|
|
318
|
-
: cetusPoolMap[poolName]
|
|
319
|
-
? cetusPoolMap[poolName]
|
|
320
|
-
: bluefinPoolMap[poolName];
|
|
321
396
|
const o = await suiClient.getObject({
|
|
322
|
-
id:
|
|
397
|
+
id: cetusPoolMap[poolName],
|
|
323
398
|
options: {
|
|
324
399
|
showContent: true,
|
|
325
400
|
},
|
|
@@ -329,9 +404,9 @@ export async function getParentPool(poolName, ignoreCache) {
|
|
|
329
404
|
cetusPoolCache.set(cacheKey, cetusPool);
|
|
330
405
|
return cetusPool;
|
|
331
406
|
}
|
|
332
|
-
catch (
|
|
407
|
+
catch (e) {
|
|
333
408
|
console.error(`getCetusPool failed for poolName: ${poolName}`);
|
|
334
|
-
|
|
409
|
+
return undefined;
|
|
335
410
|
}
|
|
336
411
|
finally {
|
|
337
412
|
// Remove the promise from the cache after it resolves
|
|
@@ -352,26 +427,37 @@ export async function getMultiInvestor() {
|
|
|
352
427
|
const investorIds = pools.map((pool) => {
|
|
353
428
|
return poolInfo[pool].investorId;
|
|
354
429
|
});
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
const investorData = o[i].data;
|
|
364
|
-
const cacheKey = `investor_${poolInfo[pools[i]].investorId}`;
|
|
365
|
-
investorCache.set(cacheKey, investorData);
|
|
366
|
-
}
|
|
430
|
+
const batchSize = 49;
|
|
431
|
+
// Create an array to hold the batches
|
|
432
|
+
const batches = [];
|
|
433
|
+
//const batches = [];
|
|
434
|
+
// Loop through the entries array and create batches
|
|
435
|
+
for (let i = 0; i < investorIds.length; i += batchSize) {
|
|
436
|
+
const batchEntries = investorIds.slice(i, i + batchSize);
|
|
437
|
+
batches.push(batchEntries); // Convert to object before pushing
|
|
367
438
|
}
|
|
368
|
-
|
|
369
|
-
|
|
439
|
+
for (const investorIdsBatch of batches) {
|
|
440
|
+
try {
|
|
441
|
+
const o = await getSuiClient().multiGetObjects({
|
|
442
|
+
ids: investorIdsBatch,
|
|
443
|
+
options: {
|
|
444
|
+
showContent: true,
|
|
445
|
+
},
|
|
446
|
+
});
|
|
447
|
+
for (let i = 0; i < investorIdsBatch.length; i = i + 1) {
|
|
448
|
+
const investorData = o[i].data;
|
|
449
|
+
const cacheKey = `investor_${investorIdsBatch[i]}`;
|
|
450
|
+
investorCache.set(cacheKey, investorData);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
catch (error) {
|
|
454
|
+
console.error(`Error getting multiInvestor - ${error}`);
|
|
455
|
+
}
|
|
370
456
|
}
|
|
371
457
|
}
|
|
372
458
|
export async function getInvestor(poolName, ignoreCache) {
|
|
373
459
|
const suiClient = getSuiClient();
|
|
374
|
-
const cacheKey = `investor_${poolInfo[poolName
|
|
460
|
+
const cacheKey = `investor_${poolInfo[poolName].investorId}`;
|
|
375
461
|
if (ignoreCache) {
|
|
376
462
|
investorCache.delete(cacheKey);
|
|
377
463
|
investorPromiseCache.delete(cacheKey);
|
|
@@ -390,7 +476,7 @@ export async function getInvestor(poolName, ignoreCache) {
|
|
|
390
476
|
cetusInvestorPromise = (async () => {
|
|
391
477
|
try {
|
|
392
478
|
const o = await suiClient.getObject({
|
|
393
|
-
id: poolInfo[poolName
|
|
479
|
+
id: poolInfo[poolName].investorId,
|
|
394
480
|
options: {
|
|
395
481
|
showContent: true,
|
|
396
482
|
},
|
|
@@ -425,46 +511,6 @@ export async function getInvestor(poolName, ignoreCache) {
|
|
|
425
511
|
investorPromiseCache.set(cacheKey, cetusInvestorPromise);
|
|
426
512
|
return cetusInvestorPromise;
|
|
427
513
|
}
|
|
428
|
-
export async function fetchVoloExchangeRate() {
|
|
429
|
-
const apiUrl = "https://open-api.naviprotocol.io/api/volo/stats";
|
|
430
|
-
const NaviVoloDetails = await fetch(apiUrl)
|
|
431
|
-
.then(async (response) => {
|
|
432
|
-
if (!response.ok) {
|
|
433
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
434
|
-
}
|
|
435
|
-
const data = (await response.json()); // Parse the JSON response
|
|
436
|
-
return data;
|
|
437
|
-
})
|
|
438
|
-
.catch((error) => {
|
|
439
|
-
console.log("failed to fetch Navi-volo details", error);
|
|
440
|
-
throw error;
|
|
441
|
-
});
|
|
442
|
-
return NaviVoloDetails;
|
|
443
|
-
}
|
|
444
|
-
export async function multiGetNaviInvestor(poolNames) {
|
|
445
|
-
const results = {};
|
|
446
|
-
const poolInvestorIds = [];
|
|
447
|
-
for (const poolName of poolNames) {
|
|
448
|
-
poolInvestorIds.push(poolInfo[poolName.toUpperCase()].investorId);
|
|
449
|
-
}
|
|
450
|
-
try {
|
|
451
|
-
const suiClient = getSuiClient();
|
|
452
|
-
const objects = await suiClient.multiGetObjects({
|
|
453
|
-
ids: poolInvestorIds,
|
|
454
|
-
options: { showContent: true },
|
|
455
|
-
});
|
|
456
|
-
for (let i = 0; i < objects.length; i++) {
|
|
457
|
-
const investor = objects[i].data;
|
|
458
|
-
results[poolNames[i]] = investor;
|
|
459
|
-
}
|
|
460
|
-
return results;
|
|
461
|
-
}
|
|
462
|
-
catch (err) {
|
|
463
|
-
//improve
|
|
464
|
-
console.error("multiGetNaviInvestor failed for poolNames: ", poolNames.join(", "));
|
|
465
|
-
throw err;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
514
|
const distributorCache = new SimpleCache();
|
|
469
515
|
const distributorPromiseCache = new SimpleCache();
|
|
470
516
|
export async function getDistributor(ignoreCache) {
|
|
@@ -511,83 +557,127 @@ export async function getDistributor(ignoreCache) {
|
|
|
511
557
|
distributorPromiseCache.set(cacheKey, distributorPromise);
|
|
512
558
|
return distributorPromise;
|
|
513
559
|
}
|
|
514
|
-
export async function
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
560
|
+
export async function getPoolExchangeRate(poolName, ignoreCache) {
|
|
561
|
+
let pool;
|
|
562
|
+
try {
|
|
563
|
+
pool = await getPool(poolName, ignoreCache);
|
|
564
|
+
const xTokenSupply = new Decimal(pool.content.fields.xTokenSupply);
|
|
565
|
+
let tokensInvested = new Decimal(pool.content.fields.tokensInvested);
|
|
566
|
+
if (poolName == "ALPHA") {
|
|
567
|
+
tokensInvested = new Decimal(pool.content.fields.alpha_bal);
|
|
521
568
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
569
|
+
else if (poolInfo[poolName].parentProtocolName == "CETUS") {
|
|
570
|
+
const investor = (await getInvestor(poolName, ignoreCache));
|
|
571
|
+
if (!investor) {
|
|
572
|
+
throw new Error(`couldnt fetch investor object for pool: ${poolName}`);
|
|
573
|
+
}
|
|
574
|
+
tokensInvested = new Decimal(pool.content.fields.tokensInvested);
|
|
525
575
|
}
|
|
526
|
-
|
|
527
|
-
|
|
576
|
+
// Check for division by zero
|
|
577
|
+
if (xTokenSupply.eq(0)) {
|
|
578
|
+
console.error("Division by zero error: tokensInvested is zero.");
|
|
579
|
+
return new Decimal(0);
|
|
528
580
|
}
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
581
|
+
const poolExchangeRate = tokensInvested.div(xTokenSupply);
|
|
582
|
+
return poolExchangeRate;
|
|
583
|
+
}
|
|
584
|
+
catch (err) {
|
|
585
|
+
console.log(`getPoolExchangeRate failed for poolName: ${poolName}, with error ${err}`);
|
|
586
|
+
throw err;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
const naviVoloExchangeRateCache = new SimpleCache();
|
|
590
|
+
const naviVoloExchangeRatePromiseCache = new SimpleCache();
|
|
591
|
+
export async function fetchVoloExchangeRate(ignoreCache) {
|
|
592
|
+
const apiUrl = "https://open-api.naviprotocol.io/api/volo/stats";
|
|
593
|
+
let NaviVoloDetails;
|
|
594
|
+
if (ignoreCache) {
|
|
595
|
+
naviVoloExchangeRateCache.clear();
|
|
596
|
+
naviVoloExchangeRatePromiseCache.delete(apiUrl);
|
|
597
|
+
}
|
|
598
|
+
const cachedResponse = naviVoloExchangeRateCache.get(apiUrl);
|
|
599
|
+
if (cachedResponse) {
|
|
600
|
+
NaviVoloDetails = cachedResponse;
|
|
601
|
+
}
|
|
602
|
+
else {
|
|
603
|
+
const default_volo_data = {
|
|
604
|
+
data: {
|
|
605
|
+
operatorBalance: "",
|
|
606
|
+
collectableFee: "",
|
|
607
|
+
pendingStakes: "",
|
|
608
|
+
poolTotalRewards: "0",
|
|
609
|
+
unstakeTicketSupply: "",
|
|
610
|
+
totalStaked: "",
|
|
611
|
+
activeStake: "",
|
|
612
|
+
calcTotalRewards: "",
|
|
613
|
+
currentEpoch: "",
|
|
614
|
+
validators: {},
|
|
615
|
+
exchangeRate: (1 / 0.973).toString(),
|
|
616
|
+
totalSupply: "",
|
|
617
|
+
apy: "",
|
|
618
|
+
sortedValidators: [""],
|
|
619
|
+
maxInstantUnstake: "",
|
|
620
|
+
maxNoFeeUnstake: "",
|
|
621
|
+
},
|
|
622
|
+
code: 0,
|
|
623
|
+
};
|
|
624
|
+
try {
|
|
625
|
+
let cachedPromise = naviVoloExchangeRatePromiseCache.get(apiUrl);
|
|
626
|
+
if (!cachedPromise) {
|
|
627
|
+
cachedPromise = fetch(apiUrl)
|
|
628
|
+
.then(async (response) => {
|
|
629
|
+
if (!response.ok) {
|
|
630
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
631
|
+
}
|
|
632
|
+
const data = (await response.json()); // Parse the JSON response
|
|
633
|
+
naviVoloExchangeRateCache.set(apiUrl, data); // Cache the response
|
|
634
|
+
naviVoloExchangeRatePromiseCache.delete(apiUrl); // Remove the promise from the cache
|
|
635
|
+
return data;
|
|
636
|
+
})
|
|
637
|
+
.catch((error) => {
|
|
638
|
+
naviVoloExchangeRatePromiseCache.delete(apiUrl); // Ensure the promise is removed on error
|
|
639
|
+
throw error;
|
|
640
|
+
});
|
|
641
|
+
naviVoloExchangeRatePromiseCache.set(apiUrl, cachedPromise);
|
|
642
|
+
NaviVoloDetails = await cachedPromise;
|
|
643
|
+
return cachedPromise;
|
|
539
644
|
}
|
|
540
|
-
|
|
541
|
-
|
|
645
|
+
else {
|
|
646
|
+
NaviVoloDetails = default_volo_data;
|
|
647
|
+
return Promise.resolve(default_volo_data);
|
|
542
648
|
}
|
|
543
|
-
const lowerPrice = TickMath.tickIndexToPrice(lowerTick, coinA.expo, coinB.expo);
|
|
544
|
-
const upperPrice = TickMath.tickIndexToPrice(upperTick, coinA.expo, coinB.expo);
|
|
545
|
-
res.set(poolName, {
|
|
546
|
-
lowerPrice: lowerPrice.toString(),
|
|
547
|
-
upperPrice: upperPrice.toString(),
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
}));
|
|
551
|
-
return res;
|
|
552
|
-
}
|
|
553
|
-
export async function getPositionRange(ignoreCache) {
|
|
554
|
-
const res = new Map();
|
|
555
|
-
for (const poolNameString of Object.keys(poolInfo)) {
|
|
556
|
-
const poolName = poolNameString;
|
|
557
|
-
if (poolName == "ALPHA" ||
|
|
558
|
-
!["CETUS", "BLUEFIN"].includes(poolInfo[poolNameString].parentProtocolName)) {
|
|
559
|
-
continue;
|
|
560
649
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
650
|
+
catch (error) {
|
|
651
|
+
console.log("error in api", error);
|
|
652
|
+
NaviVoloDetails = default_volo_data;
|
|
653
|
+
return Promise.resolve(default_volo_data);
|
|
564
654
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
const upperPrice = TickMath.tickIndexToPrice(upperTick, coinA.expo, coinB.expo);
|
|
584
|
-
res.set(poolName, {
|
|
585
|
-
lowerPrice: lowerPrice.toString(),
|
|
586
|
-
upperPrice: upperPrice.toString(),
|
|
587
|
-
});
|
|
655
|
+
}
|
|
656
|
+
return NaviVoloDetails;
|
|
657
|
+
}
|
|
658
|
+
export async function multiGetNaviInvestor(poolNames) {
|
|
659
|
+
const results = {};
|
|
660
|
+
const poolInvestorIds = [];
|
|
661
|
+
for (const poolName of poolNames) {
|
|
662
|
+
poolInvestorIds.push(poolInfo[poolName].investorId);
|
|
663
|
+
}
|
|
664
|
+
try {
|
|
665
|
+
const suiClient = getSuiClient();
|
|
666
|
+
const objects = await suiClient.multiGetObjects({
|
|
667
|
+
ids: poolInvestorIds,
|
|
668
|
+
options: { showContent: true },
|
|
669
|
+
});
|
|
670
|
+
for (let i = 0; i < objects.length; i++) {
|
|
671
|
+
const investor = objects[i].data;
|
|
672
|
+
results[poolNames[i]] = investor;
|
|
588
673
|
}
|
|
674
|
+
return results;
|
|
675
|
+
}
|
|
676
|
+
catch (err) {
|
|
677
|
+
//improve
|
|
678
|
+
console.error("multiGetNaviInvestor failed for poolNames: ", poolNames.join(", "));
|
|
679
|
+
throw err;
|
|
589
680
|
}
|
|
590
|
-
return res;
|
|
591
681
|
}
|
|
592
682
|
/*
|
|
593
683
|
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,
|