@alphafi/alphafi-sdk 0.0.49 → 0.0.50
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 +2 -1
- package/dist/cjs/adminFunctions.d.ts.map +1 -1
- package/dist/cjs/adminFunctions.js +47 -0
- package/dist/cjs/adminFunctions.js.map +1 -1
- package/dist/cjs/common/maps.d.ts +1 -0
- package/dist/cjs/common/maps.d.ts.map +1 -1
- package/dist/cjs/common/maps.js.map +1 -1
- package/dist/cjs/common/types.d.ts +17 -3
- package/dist/cjs/common/types.d.ts.map +1 -1
- package/dist/cjs/common/types.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +3 -2
- 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/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 +4 -12
- package/dist/cjs/sui-sdk/functions/getReceipts.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/functions/getReceipts.js +0 -81
- package/dist/cjs/sui-sdk/functions/getReceipts.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/esm/adminFunctions.d.ts +2 -1
- package/dist/esm/adminFunctions.d.ts.map +1 -1
- package/dist/esm/adminFunctions.js +48 -2
- package/dist/esm/adminFunctions.js.map +1 -1
- package/dist/esm/common/maps.d.ts +1 -0
- package/dist/esm/common/maps.d.ts.map +1 -1
- package/dist/esm/common/maps.js.map +1 -1
- package/dist/esm/common/types.d.ts +17 -3
- package/dist/esm/common/types.d.ts.map +1 -1
- package/dist/esm/common/types.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -1
- 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/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 +4 -12
- package/dist/esm/sui-sdk/functions/getReceipts.d.ts.map +1 -1
- package/dist/esm/sui-sdk/functions/getReceipts.js +2 -81
- package/dist/esm/sui-sdk/functions/getReceipts.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/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/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/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/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/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/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/setSuiClient.html +7 -255
- package/docs/functions/setSuiNodeUrl.html +5 -249
- 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 +6 -0
- package/docs/interfaces/PoolWeightDistribution.html +4 -0
- package/docs/interfaces/RebalanceHistoryType.html +9 -652
- package/docs/modules.html +186 -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,6 +1,7 @@
|
|
|
1
|
-
import { PoolName } from "./common/types.js";
|
|
1
|
+
import { PoolName, PoolWeightDistribution, CoinName } from "./common/types.js";
|
|
2
2
|
export declare function getCurrentTick(poolName: PoolName): Promise<string>;
|
|
3
3
|
export declare function getPositionTicks(poolName: PoolName): Promise<string[]>;
|
|
4
4
|
export declare function getTickToPrice(poolName: PoolName, tick: string): Promise<string>;
|
|
5
5
|
export declare function getPriceToTick(poolName: PoolName, price: string): Promise<string>;
|
|
6
|
+
export declare function getPoolsWeightDistribution(coinTypetoSetWeight: CoinName, ignoreCache: boolean): Promise<PoolWeightDistribution>;
|
|
6
7
|
//# sourceMappingURL=adminFunctions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adminFunctions.d.ts","sourceRoot":"","sources":["../../src/adminFunctions.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"adminFunctions.d.ts","sourceRoot":"","sources":["../../src/adminFunctions.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,QAAQ,EACR,sBAAsB,EACtB,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAe3B,wBAAsB,cAAc,CAAC,QAAQ,EAAE,QAAQ,mBAKtD;AAED,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,qBAaxD;AAED,wBAAsB,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,mBAOpE;AAED,wBAAsB,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAsBrE;AAED,wBAAsB,0BAA0B,CAC9C,mBAAmB,EAAE,QAAQ,EAC7B,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,sBAAsB,CAAC,CAuDjC"}
|
|
@@ -4,6 +4,7 @@ exports.getCurrentTick = getCurrentTick;
|
|
|
4
4
|
exports.getPositionTicks = getPositionTicks;
|
|
5
5
|
exports.getTickToPrice = getTickToPrice;
|
|
6
6
|
exports.getPriceToTick = getPriceToTick;
|
|
7
|
+
exports.getPoolsWeightDistribution = getPoolsWeightDistribution;
|
|
7
8
|
const tslib_1 = require("tslib");
|
|
8
9
|
const cetus_sui_clmm_sdk_1 = require("@cetusprotocol/cetus-sui-clmm-sdk");
|
|
9
10
|
const getReceipts_js_1 = require("./sui-sdk/functions/getReceipts.js");
|
|
@@ -57,4 +58,50 @@ async function getPriceToTick(poolName, price) {
|
|
|
57
58
|
const tick = cetus_sui_clmm_sdk_1.TickMath.priceToInitializableTickIndex(priceDecimal, coinA.expo, coinB.expo, tickSpacing);
|
|
58
59
|
return tick.toString();
|
|
59
60
|
}
|
|
61
|
+
async function getPoolsWeightDistribution(coinTypetoSetWeight, ignoreCache) {
|
|
62
|
+
const distributor = await (0, getReceipts_js_1.getDistributor)(ignoreCache);
|
|
63
|
+
if (!distributor || !distributor.content.fields.pool_allocator) {
|
|
64
|
+
throw new Error("Distributor or pool allocator not found");
|
|
65
|
+
}
|
|
66
|
+
const allocator = distributor.content.fields.pool_allocator;
|
|
67
|
+
const members = allocator.fields.members.fields.contents;
|
|
68
|
+
const totalWeightArr = allocator.fields.total_weights.fields.contents;
|
|
69
|
+
let totalWeight = 0;
|
|
70
|
+
totalWeightArr.forEach((entry) => {
|
|
71
|
+
if (entry.fields.key.fields.name ===
|
|
72
|
+
coins_js_1.coinsList[coinTypetoSetWeight].type.substring(2)) {
|
|
73
|
+
totalWeight = Number(entry.fields.value);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
const poolIdmap = maps_js_1.poolIdPoolNameMap;
|
|
77
|
+
const poolDataArray = [];
|
|
78
|
+
for (const member of members) {
|
|
79
|
+
const poolId = member.fields.key;
|
|
80
|
+
const poolName = poolIdmap[poolId];
|
|
81
|
+
if (!maps_js_1.poolInfo[poolName]) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const imageUrl = maps_js_1.poolInfo[poolName].imageUrl;
|
|
85
|
+
let weight = 0;
|
|
86
|
+
if (member.fields.value.fields) {
|
|
87
|
+
const poolData = member.fields.value.fields.pool_data.fields.contents;
|
|
88
|
+
poolData.forEach((entry) => {
|
|
89
|
+
if (entry.fields.key.fields.name ===
|
|
90
|
+
coins_js_1.coinsList[coinTypetoSetWeight].type.substring(2)) {
|
|
91
|
+
weight = Number(entry.fields.value.fields.weight);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
poolDataArray.push({
|
|
96
|
+
weight: weight,
|
|
97
|
+
imageUrl: imageUrl,
|
|
98
|
+
poolName: poolName,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
data: poolDataArray,
|
|
103
|
+
totalWeight: totalWeight,
|
|
104
|
+
coinType: coinTypetoSetWeight,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
60
107
|
//# sourceMappingURL=adminFunctions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adminFunctions.js","sourceRoot":"","sources":["../../src/adminFunctions.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"adminFunctions.js","sourceRoot":"","sources":["../../src/adminFunctions.ts"],"names":[],"mappings":";;AA2BA,wCAKC;AAED,4CAaC;AAED,wCAOC;AAED,wCAsBC;AAED,gEA0DC;;AA5ID,0EAA6D;AAa7D,uEAI4C;AAC5C,0DAAuB;AACvB,gDAA8C;AAC9C,8CAI0B;AAC1B,2CAAqC;AAE9B,KAAK,UAAU,cAAc,CAAC,QAAkB;IACrD,MAAM,UAAU,GAAG,MAAM,IAAA,8BAAa,EAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACxD,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC;IACxE,MAAM,IAAI,GAAG,6BAAQ,CAAC,uBAAuB,CAAC,IAAI,eAAE,CAAC,kBAAkB,CAAC,CAAC,CAAC;IAC1E,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;AACzB,CAAC;AAEM,KAAK,UAAU,gBAAgB,CAAC,QAAkB;IACvD,MAAM,UAAU,GAAG,MAAM,CAAC;IAC1B,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAA,4BAAW,EAAC,QAAQ,EAAE,KAAK,CAAC,CAC9B,CAAC;IACvB,IAAI,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC3D,IAAI,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC3D,IAAI,SAAS,GAAG,UAAU,EAAE,CAAC;QAC3B,SAAS,GAAG,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IAChC,CAAC;IACD,IAAI,SAAS,GAAG,UAAU,EAAE,CAAC;QAC3B,SAAS,GAAG,CAAC,CAAC,CAAC,SAAS,GAAG,CAA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;QACnB,WAAW,EAAE,WAAW;QACxB,QAAQ,EAAE,mBAAmB;KAC9B,CAAC;AACJ,CAAC","sourcesContent":["import { TickMath } from \"@cetusprotocol/cetus-sui-clmm-sdk\";\nimport {\n Allocator,\n BluefinPoolType,\n CetusInvestor,\n CetusPoolType,\n CommonInvestorFields,\n MemberType,\n PoolData,\n PoolName,\n PoolWeightDistribution,\n CoinName,\n} from \"./common/types.js\";\nimport {\n getDistributor,\n getInvestor,\n getParentPool,\n} from \"./sui-sdk/functions/getReceipts.js\";\nimport BN from \"bn.js\";\nimport { coinsList } from \"./common/coins.js\";\nimport {\n doubleAssetPoolCoinMap,\n poolIdPoolNameMap,\n poolInfo,\n} from \"./common/maps.js\";\nimport { Decimal } from \"decimal.js\";\n\nexport async function getCurrentTick(poolName: PoolName) {\n const parentPool = await getParentPool(poolName, false);\n const current_sqrt_price = parentPool.content.fields.current_sqrt_price;\n const tick = TickMath.sqrtPriceX64ToTickIndex(new BN(current_sqrt_price));\n return tick.toString();\n}\n\nexport async function getPositionTicks(poolName: PoolName) {\n const upperBound = 443636;\n const investor = (await getInvestor(poolName, false)) as CetusInvestor &\n CommonInvestorFields;\n let lowerTick = Number(investor.content.fields.lower_tick);\n let upperTick = Number(investor.content.fields.upper_tick);\n if (lowerTick > upperBound) {\n lowerTick = -~(lowerTick - 1);\n }\n if (upperTick > upperBound) {\n upperTick = -~(upperTick - 1);\n }\n return [lowerTick.toString(), upperTick.toString()];\n}\n\nexport async function getTickToPrice(poolName: PoolName, tick: string) {\n const coinAName = doubleAssetPoolCoinMap[poolName].coin1;\n const coinA = coinsList[coinAName];\n const coinBName = doubleAssetPoolCoinMap[poolName].coin2;\n const coinB = coinsList[coinBName];\n const price = TickMath.tickIndexToPrice(Number(tick), coinA.expo, coinB.expo);\n return price.toString();\n}\n\nexport async function getPriceToTick(poolName: PoolName, price: string) {\n const coinAName = doubleAssetPoolCoinMap[poolName].coin1;\n const coinA = coinsList[coinAName];\n const coinBName = doubleAssetPoolCoinMap[poolName].coin2;\n const coinB = coinsList[coinBName];\n const parentPool = await getParentPool(poolName, false);\n console.log(parentPool.content.fields);\n let tickSpacing = 1;\n if (poolInfo[poolName].parentProtocolName === \"CETUS\") {\n tickSpacing = (parentPool as CetusPoolType).content.fields.tick_spacing;\n } else if (poolInfo[poolName].parentProtocolName === \"BLUEFIN\") {\n tickSpacing = (parentPool as BluefinPoolType).content.fields.ticks_manager\n .fields.tick_spacing;\n }\n const priceDecimal = new Decimal(price);\n const tick = TickMath.priceToInitializableTickIndex(\n priceDecimal,\n coinA.expo,\n coinB.expo,\n tickSpacing,\n );\n return tick.toString();\n}\n\nexport async function getPoolsWeightDistribution(\n coinTypetoSetWeight: CoinName,\n ignoreCache: boolean,\n): Promise<PoolWeightDistribution> {\n const distributor = await getDistributor(ignoreCache);\n if (!distributor || !distributor.content.fields.pool_allocator) {\n throw new Error(\"Distributor or pool allocator not found\");\n }\n const allocator: Allocator = distributor.content.fields.pool_allocator;\n const members: MemberType[] = allocator.fields.members.fields.contents;\n\n const totalWeightArr = allocator.fields.total_weights.fields.contents;\n let totalWeight = 0;\n totalWeightArr.forEach((entry) => {\n if (\n entry.fields.key.fields.name ===\n coinsList[coinTypetoSetWeight].type.substring(2)\n ) {\n totalWeight = Number(entry.fields.value);\n }\n });\n\n const poolIdmap = poolIdPoolNameMap;\n\n const poolDataArray: PoolData[] = [];\n\n for (const member of members) {\n const poolId = member.fields.key;\n const poolName = poolIdmap[poolId];\n if (!poolInfo[poolName]) {\n continue;\n }\n const imageUrl = poolInfo[poolName].imageUrl;\n\n let weight = 0;\n if (member.fields.value.fields) {\n const poolData = member.fields.value.fields.pool_data.fields.contents;\n poolData.forEach((entry) => {\n if (\n entry.fields.key.fields.name ===\n coinsList[coinTypetoSetWeight].type.substring(2)\n ) {\n weight = Number(entry.fields.value.fields.weight);\n }\n });\n }\n\n poolDataArray.push({\n weight: weight,\n imageUrl: imageUrl,\n poolName: poolName,\n });\n }\n return {\n data: poolDataArray,\n totalWeight: totalWeight,\n coinType: coinTypetoSetWeight,\n };\n}\n"]}
|
|
@@ -47,6 +47,7 @@ export declare const poolInfo: {
|
|
|
47
47
|
afterTransactionEventType?: string;
|
|
48
48
|
strategyType?: StrategyType;
|
|
49
49
|
checkRatioEventType?: string;
|
|
50
|
+
imageUrl?: string | undefined;
|
|
50
51
|
};
|
|
51
52
|
};
|
|
52
53
|
export declare function coinsInPool(poolName: DoubleAssetPoolNames, event?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"maps.d.ts","sourceRoot":"","sources":["../../../src/common/maps.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,QAAQ,EAER,oBAAoB,EACpB,QAAQ,EACR,WAAW,EAEX,oBAAoB,EACpB,YAAY,EACb,MAAM,YAAY,CAAC;AAQpB,eAAO,MAAM,WAAW,UASvB,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE;KAClC,GAAG,IAAI,MAAM,GAAG;QAAE,KAAK,EAAE,QAAQ,CAAC;QAAC,KAAK,EAAE,QAAQ,CAAA;KAAE;CA2CtD,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE;KAClC,GAAG,IAAI,MAAM,GAAG;QAAE,IAAI,EAAE,QAAQ,CAAA;KAAE;CAoBpC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE;KAC9B,GAAG,IAAI,MAAM,GAAG;QAAE,UAAU,EAAE,QAAQ,CAAC;QAAC,UAAU,EAAE,QAAQ,CAAA;KAAE;CAMhE,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE;KACxB,GAAG,IAAI,MAAM,GAAG,MAAM;CAexB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAsCjD,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAqBnD,CAAC;AAEF,eAAO,MAAM,uBAAuB,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