@alphafi/alphafi-sdk 0.0.48 → 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/constants.d.ts +20 -2
- package/dist/cjs/common/constants.d.ts.map +1 -1
- package/dist/cjs/common/constants.js +34 -17
- package/dist/cjs/common/constants.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 +18 -0
- 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/events/fetchAutoCompoundingEvents.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/events/fetchAutoCompoundingEvents.js +35 -2
- package/dist/cjs/sui-sdk/events/fetchAutoCompoundingEvents.js.map +1 -1
- package/dist/cjs/sui-sdk/events/fetchEvents.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/events/fetchEvents.js +29 -0
- package/dist/cjs/sui-sdk/events/fetchEvents.js.map +1 -1
- package/dist/cjs/sui-sdk/events/types.d.ts +11 -1
- package/dist/cjs/sui-sdk/events/types.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/events/types.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/blueRewards.d.ts.map +1 -1
- package/dist/cjs/transactions/blueRewards.js +52 -5
- 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 +152 -97
- package/dist/cjs/transactions/bluefin.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/constants.d.ts +20 -2
- package/dist/esm/common/constants.d.ts.map +1 -1
- package/dist/esm/common/constants.js +34 -17
- package/dist/esm/common/constants.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 +18 -0
- 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/events/fetchAutoCompoundingEvents.d.ts.map +1 -1
- package/dist/esm/sui-sdk/events/fetchAutoCompoundingEvents.js +36 -3
- package/dist/esm/sui-sdk/events/fetchAutoCompoundingEvents.js.map +1 -1
- package/dist/esm/sui-sdk/events/fetchEvents.d.ts.map +1 -1
- package/dist/esm/sui-sdk/events/fetchEvents.js +29 -0
- package/dist/esm/sui-sdk/events/fetchEvents.js.map +1 -1
- package/dist/esm/sui-sdk/events/types.d.ts +11 -1
- package/dist/esm/sui-sdk/events/types.d.ts.map +1 -1
- package/dist/esm/sui-sdk/events/types.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/blueRewards.d.ts.map +1 -1
- package/dist/esm/transactions/blueRewards.js +53 -6
- 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 +152 -97
- package/dist/esm/transactions/bluefin.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
|
@@ -112,6 +112,35 @@ async function fetchEvents(params) {
|
|
|
112
112
|
transactionModule: suiEvent.transactionModule,
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
+
else if (isAutoCompoundingEvent(suiEvent.type) &&
|
|
116
|
+
"blue_reward_amount" in suiEventJson) {
|
|
117
|
+
// Handling CetusAutoCompoundingEvent
|
|
118
|
+
eventNode = {
|
|
119
|
+
type: suiEvent.type,
|
|
120
|
+
timestamp: Number(suiEvent.timestampMs),
|
|
121
|
+
blue_reward_amount: BigInt(suiEventJson.blue_reward_amount.toString()),
|
|
122
|
+
current_liquidity: BigInt(suiEventJson.current_liquidity.toString()),
|
|
123
|
+
fee_collected: BigInt(suiEventJson.fee_collected.toString()),
|
|
124
|
+
free_balance_a: BigInt(suiEventJson.free_balance_a.toString()),
|
|
125
|
+
free_balance_b: BigInt(suiEventJson.free_balance_b.toString()),
|
|
126
|
+
investor_id: suiEventJson.investor_id,
|
|
127
|
+
total_amount_a: BigInt(suiEventJson.total_amount_a.toString()),
|
|
128
|
+
total_amount_b: BigInt(suiEventJson.total_amount_b.toString()),
|
|
129
|
+
txDigest: suiEvent.id.txDigest,
|
|
130
|
+
eventSeq: Number(suiEvent.id.eventSeq),
|
|
131
|
+
transactionModule: suiEvent.transactionModule,
|
|
132
|
+
};
|
|
133
|
+
// if (
|
|
134
|
+
// eventNode.investor_id ===
|
|
135
|
+
// "0xd060e81548aee885bd3d37ae0caec181185be792bf45412e0d0acccd1e0174e6"
|
|
136
|
+
// ) {
|
|
137
|
+
// console.log(
|
|
138
|
+
// eventNode.timestamp,
|
|
139
|
+
// (prevTS - eventNode.timestamp) / (1000 * 60),
|
|
140
|
+
// );
|
|
141
|
+
// prevTS = eventNode.timestamp;
|
|
142
|
+
// }
|
|
143
|
+
}
|
|
115
144
|
else if (isRebalanceEvent(suiEvent.type) &&
|
|
116
145
|
"lower_tick_after" in suiEventJson) {
|
|
117
146
|
// Handling RebalanceEvent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchEvents.js","sourceRoot":"","sources":["../../../../src/sui-sdk/events/fetchEvents.ts"],"names":[],"mappings":";;AAqBA,kCAoUC;AAzVD,4CAA4C;AAkB5C,kDAAgD;AAChD,4DAA2D;AAEpD,KAAK,UAAU,WAAW,CAC/B,MAAyB;IAEzB,MAAM,SAAS,GAAgB,EAAE,CAAC;IAClC,IAAI,WAAW,GAAG,IAAI,CAAC;IACvB,IAAI,WAAW,GAA+B,IAAI,CAAC;IAEnD,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,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AiB,EAAE,EAAE;IACpD,MAAM,UAAU,GAAa,MAAM,CAAC,MAAM,CAAC,kBAAQ,CAAC;SACjD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,OAAO,IAAI,CAAC,yBAAyB,CAAC;IACxC,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IACxC,OAAO,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC,CAAC","sourcesContent":["import { getSuiClient } from \"../client.js\";\nimport { EventId, PaginatedEvents } from \"@mysten/sui/client\";\nimport {\n AlphaLiquidityChangeEvent,\n AlphaAutoCompoundingEvent,\n CetusAutoCompoundingEvent,\n CetusLiquidityChangeEvent,\n EventNode,\n FetchEventsParams,\n NaviAutoCompoundingEvent,\n NaviLoopAutoCompoundingEvent,\n NaviLiquidityChangeEvent,\n RebalanceEvent,\n AutoCompoundingEventNode,\n AlphaWithdrawV2Event,\n AfterTransactionEventNode,\n CheckRatioEvent,\n} from \"./types.js\";\nimport { poolInfo } from \"../../common/maps.js\";\nimport { conf, CONF_ENV } from \"../../common/constants.js\";\n\nexport async function fetchEvents(\n params: FetchEventsParams,\n): Promise<EventNode[]> {\n const allEvents: EventNode[] = [];\n let hasNextPage = true;\n let startCursor: EventId | null | undefined = null;\n\n if (params.eventTypes.length > 1) {\n console.warn(\n \"Multiple eventTypes not supported right now, pass only one element in the array.\",\n );\n }\n\n if (params.eventTypes.length < 1) {\n hasNextPage = false;\n }\n\n const now = Date.now();\n const twentyFourHoursAgo = now - 24 * 60 * 60 * 1000; // timestamp for 24 hours ago\n const startTime = params.startTime ? params.startTime : twentyFourHoursAgo;\n const endTime = params.endTime ? params.endTime : now;\n\n if (startTime >= endTime) {\n throw new Error(\"startTime must be less than endTime\");\n }\n\n const suiClient = getSuiClient();\n //const prevTS = 0;\n\n while (hasNextPage) {\n const result: PaginatedEvents = await suiClient.queryEvents({\n cursor: startCursor,\n order: \"descending\",\n query: {\n MoveEventType: params.eventTypes[0],\n },\n });\n\n const se = result.data;\n for (let i = 0; i < se.length; i++) {\n const suiEvent = se[i];\n\n if (Number(suiEvent.timestampMs) > endTime) {\n continue;\n }\n\n if (Number(suiEvent.timestampMs) < startTime) {\n hasNextPage = false; // Stop further pagination\n break; // Exit the loop\n }\n\n const suiEventJson = suiEvent.parsedJson as\n | CetusAutoCompoundingEvent\n | NaviAutoCompoundingEvent\n | NaviLoopAutoCompoundingEvent\n | RebalanceEvent\n | CetusLiquidityChangeEvent\n | AlphaLiquidityChangeEvent\n | NaviLiquidityChangeEvent\n | AlphaAutoCompoundingEvent\n | AlphaWithdrawV2Event\n | AfterTransactionEventNode // TODO: this needs to be changed to AfterTransactionEvent Eventually\n | CheckRatioEvent;\n\n let eventNode: EventNode;\n\n if (\n isAutoCompoundingEvent(suiEvent.type) &&\n \"compound_amount_a\" in suiEventJson &&\n \"compound_amount_b\" in suiEventJson\n ) {\n // Handling CetusAutoCompoundingEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n compound_amount_a: BigInt(suiEventJson.compound_amount_a.toString()),\n compound_amount_b: BigInt(suiEventJson.compound_amount_b.toString()),\n current_liquidity: BigInt(suiEventJson.current_liquidity.toString()),\n fee_collected_a: BigInt(suiEventJson.fee_collected_a.toString()),\n fee_collected_b: BigInt(suiEventJson.fee_collected_b.toString()),\n free_balance_a: BigInt(suiEventJson.free_balance_a.toString()),\n free_balance_b: BigInt(suiEventJson.free_balance_b.toString()),\n investor_id: suiEventJson.investor_id,\n total_amount_a: BigInt(suiEventJson.total_amount_a.toString()),\n total_amount_b: BigInt(suiEventJson.total_amount_b.toString()),\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n\n // if (\n // eventNode.investor_id ===\n // \"0xd060e81548aee885bd3d37ae0caec181185be792bf45412e0d0acccd1e0174e6\"\n // ) {\n // console.log(\n // eventNode.timestamp,\n // (prevTS - eventNode.timestamp) / (1000 * 60),\n // );\n // prevTS = eventNode.timestamp;\n // }\n } else if (\n isAutoCompoundingEvent(suiEvent.type) &&\n \"compound_amount\" in suiEventJson\n ) {\n // Handling NaviAutoCompoundingEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n compound_amount: BigInt(suiEventJson.compound_amount.toString()),\n fee_collected: BigInt(suiEventJson.fee_collected.toString()),\n investor_id: suiEventJson.investor_id,\n location: suiEventJson.location,\n total_amount: BigInt(suiEventJson.total_amount.toString()),\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n if (\n \"cur_total_debt\" in suiEventJson &&\n \"accrued_interest\" in suiEventJson\n ) {\n const loopEvent: AutoCompoundingEventNode = {\n ...eventNode,\n cur_total_debt: BigInt(suiEventJson.cur_total_debt.toString()),\n accrued_interest: BigInt(suiEventJson.accrued_interest.toString()),\n };\n eventNode = loopEvent;\n }\n } else if (\n isAutoCompoundingEvent(suiEvent.type) &&\n \"amount\" in suiEventJson\n ) {\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n amount: suiEventJson.amount,\n investor_id: conf[CONF_ENV].ALPHA_POOL,\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else if (\n isRebalanceEvent(suiEvent.type) &&\n \"lower_tick_after\" in suiEventJson\n ) {\n // Handling RebalanceEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n investor_id: suiEventJson.investor_id.toString(),\n lower_tick_after: suiEventJson.lower_tick_after.toString(),\n upper_tick_after: suiEventJson.upper_tick_after.toString(),\n sqrt_price_after: suiEventJson.sqrt_price_after.toString(),\n amount_a_before: suiEventJson.amount_a_before.toString(),\n amount_b_before: suiEventJson.amount_b_before.toString(),\n amount_a_after: suiEventJson.amount_a_after.toString(),\n amount_b_after: suiEventJson.amount_b_after.toString(),\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else if (\n isLiquidityChangeEvent(suiEvent.type) &&\n \"amount_a\" in suiEventJson\n ) {\n // Handling CetusLiquidityChangeEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n amount_a: suiEventJson.amount_a,\n amount_b: suiEventJson.amount_b,\n event_type: suiEventJson.event_type,\n fee_collected_a: suiEventJson.fee_collected_a,\n fee_collected_b: suiEventJson.fee_collected_b,\n pool_id: suiEventJson.pool_id,\n sender: suiEventJson.sender,\n tokens_invested: suiEventJson.tokens_invested,\n total_amount_a: suiEventJson.total_amount_a,\n total_amount_b: suiEventJson.total_amount_b,\n user_total_x_token_balance: suiEventJson.user_total_x_token_balance,\n x_token_supply: suiEventJson.x_token_supply,\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else if (\n isLiquidityChangeEvent(suiEvent.type) &&\n \"amount\" in suiEventJson &&\n !(\"investor_id\" in suiEventJson) &&\n !(\"amount_withdrawn_from_locked\" in suiEventJson) &&\n !(\"xtokenSupply\" in suiEventJson)\n ) {\n // Handling NaviLiquidityChangeEvent and AlphaLiquidityChangeEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n amount: suiEventJson.amount,\n event_type: suiEventJson.event_type,\n fee_collected: suiEventJson.fee_collected,\n pool_id: suiEventJson.pool_id,\n sender: suiEventJson.sender,\n tokens_invested: suiEventJson.tokens_invested,\n user_total_x_token_balance: suiEventJson.user_total_x_token_balance,\n x_token_supply: suiEventJson.x_token_supply,\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else if (\n isWithdrawV2Event(suiEvent.type) &&\n \"amount_withdrawn_from_locked\" in suiEventJson\n ) {\n // Handling Alpha WithdrawV2 Events\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n amount: suiEventJson.amount,\n amount_withdrawn_from_locked:\n suiEventJson.amount_withdrawn_from_locked,\n amount_withdrawn_from_unlocked:\n suiEventJson.amount_withdrawn_from_unlocked,\n fee_collected: suiEventJson.fee_collected,\n instant_withdraw_fee_collected:\n suiEventJson.instant_withdraw_fee_collected,\n pool_id: suiEventJson.pool_id,\n sender: suiEventJson.sender,\n tokens_invested: suiEventJson.tokens_invested,\n user_total_x_token_balance: suiEventJson.user_total_x_token_balance,\n x_token_supply: suiEventJson.x_token_supply,\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else if (\n isAfterTransactionEvent(suiEvent.type) &&\n \"tokensInvested\" in suiEventJson &&\n !(\"liquidity\" in suiEventJson) &&\n !(\"amount\" in suiEventJson)\n ) {\n //handling alpha after transaction event\n if (suiEvent.id.eventSeq === \"0\") continue;\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n poolName: \"ALPHA\",\n id: {\n eventSeq: Number(suiEvent.id.eventSeq),\n txDigest: suiEvent.id.txDigest,\n },\n tokensInvested: suiEventJson.tokensInvested,\n xTokenSupply: suiEventJson.xTokenSupply,\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else if (\n isAfterTransactionEvent(suiEvent.type) &&\n \"tokensInvested\" in suiEventJson &&\n \"liquidity\" in suiEventJson\n ) {\n //handling cetus after transaction event\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n poolName: undefined,\n id: {\n eventSeq: Number(suiEvent.id.eventSeq),\n txDigest: suiEvent.id.txDigest,\n },\n tokensInvested: suiEventJson.tokensInvested,\n xtokenSupply: suiEventJson.xtokenSupply,\n liquidity: suiEventJson.liquidity,\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else if (\n isAfterTransactionEvent(suiEvent.type) &&\n \"amount\" in suiEventJson &&\n \"tokensInvested\" in suiEventJson\n ) {\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n poolName: undefined,\n id: {\n eventSeq: Number(suiEvent.id.eventSeq),\n txDigest: suiEvent.id.txDigest,\n },\n tokensInvested: suiEventJson.tokensInvested,\n xtokenSupply: suiEventJson.xtokenSupply,\n amount: suiEventJson.amount,\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else if (\"ratio\" in suiEventJson) {\n // Check Ratio - looping pools\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n ratio: suiEventJson.ratio,\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else {\n console.error(\"event: \", suiEvent, \"json: \", suiEventJson);\n throw new Error(\"Unknown event type\");\n }\n\n allEvents.push(eventNode);\n }\n\n // If we set hasPreviousPage to false, exit the outer loop as well\n if (!hasNextPage) {\n break;\n }\n\n hasNextPage = result.hasNextPage;\n startCursor = result.nextCursor;\n }\n\n return allEvents;\n}\n\nconst isAutoCompoundingEvent = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo).map((info) => {\n return info.autoCompoundingEventType;\n });\n return eventTypes.includes(eventType);\n};\n\nconst isRebalanceEvent = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo)\n .filter((info) => {\n return info.rebalanceEventType ? true : false;\n })\n .map((info) => {\n return info.rebalanceEventType as string;\n });\n return eventTypes.includes(eventType);\n};\n\nconst isLiquidityChangeEvent = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo).map((info) => {\n return info.liquidityChangeEventType;\n });\n return eventTypes.includes(eventType);\n};\n\nconst isWithdrawV2Event = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo)\n .map((info) => {\n return info.withdrawV2EventType;\n })\n .filter((type) => type !== undefined);\n return eventTypes.includes(eventType);\n};\n\nconst isAfterTransactionEvent = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo)\n .map((info) => {\n return info.afterTransactionEventType;\n })\n .filter((type) => type !== undefined);\n return eventTypes.includes(eventType);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"fetchEvents.js","sourceRoot":"","sources":["../../../../src/sui-sdk/events/fetchEvents.ts"],"names":[],"mappings":";;AAsBA,kCAsWC;AA5XD,4CAA4C;AAmB5C,kDAAgD;AAChD,4DAA2D;AAEpD,KAAK,UAAU,WAAW,CAC/B,MAAyB;IAEzB,MAAM,SAAS,GAAgB,EAAE,CAAC;IAClC,IAAI,WAAW,GAAG,IAAI,CAAC;IACvB,IAAI,WAAW,GAA+B,IAAI,CAAC;IAEnD,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,IAAI,CACV,kFAAkF,CACnF,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,WAAW,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,kBAAkB,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,6BAA6B;IACnF,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC;IAC3E,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAA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M,CAAC,kBAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAChE,OAAO,IAAI,CAAC,wBAAwB,CAAC;IACvC,CAAC,CAAC,CAAC;IACH,OAAO,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAE,EAAE;IAC9C,MAAM,UAAU,GAAa,MAAM,CAAC,MAAM,CAAC,kBAAQ,CAAC;SACjD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IACxC,OAAO,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,SAAiB,EAAE,EAAE;IACpD,MAAM,UAAU,GAAa,MAAM,CAAC,MAAM,CAAC,kBAAQ,CAAC;SACjD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,OAAO,IAAI,CAAC,yBAAyB,CAAC;IACxC,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IACxC,OAAO,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC,CAAC","sourcesContent":["import { getSuiClient } from \"../client.js\";\nimport { EventId, PaginatedEvents } from \"@mysten/sui/client\";\nimport {\n AlphaLiquidityChangeEvent,\n AlphaAutoCompoundingEvent,\n CetusAutoCompoundingEvent,\n CetusLiquidityChangeEvent,\n EventNode,\n FetchEventsParams,\n NaviAutoCompoundingEvent,\n NaviLoopAutoCompoundingEvent,\n NaviLiquidityChangeEvent,\n RebalanceEvent,\n AutoCompoundingEventNode,\n AlphaWithdrawV2Event,\n AfterTransactionEventNode,\n CheckRatioEvent,\n AutobalancingAutoCompoundingEvent,\n} from \"./types.js\";\nimport { poolInfo } from \"../../common/maps.js\";\nimport { conf, CONF_ENV } from \"../../common/constants.js\";\n\nexport async function fetchEvents(\n params: FetchEventsParams,\n): Promise<EventNode[]> {\n const allEvents: EventNode[] = [];\n let hasNextPage = true;\n let startCursor: EventId | null | undefined = null;\n\n if (params.eventTypes.length > 1) {\n console.warn(\n \"Multiple eventTypes not supported right now, pass only one element in the array.\",\n );\n }\n\n if (params.eventTypes.length < 1) {\n hasNextPage = false;\n }\n\n const now = Date.now();\n const twentyFourHoursAgo = now - 24 * 60 * 60 * 1000; // timestamp for 24 hours ago\n const startTime = params.startTime ? params.startTime : twentyFourHoursAgo;\n const endTime = params.endTime ? params.endTime : now;\n\n if (startTime >= endTime) {\n throw new Error(\"startTime must be less than endTime\");\n }\n\n const suiClient = getSuiClient();\n //const prevTS = 0;\n\n while (hasNextPage) {\n const result: PaginatedEvents = await suiClient.queryEvents({\n cursor: startCursor,\n order: \"descending\",\n query: {\n MoveEventType: params.eventTypes[0],\n },\n });\n\n const se = result.data;\n for (let i = 0; i < se.length; i++) {\n const suiEvent = se[i];\n\n if (Number(suiEvent.timestampMs) > endTime) {\n continue;\n }\n\n if (Number(suiEvent.timestampMs) < startTime) {\n hasNextPage = false; // Stop further pagination\n break; // Exit the loop\n }\n\n const suiEventJson = suiEvent.parsedJson as\n | CetusAutoCompoundingEvent\n | NaviAutoCompoundingEvent\n | NaviLoopAutoCompoundingEvent\n | AutobalancingAutoCompoundingEvent\n | RebalanceEvent\n | CetusLiquidityChangeEvent\n | AlphaLiquidityChangeEvent\n | NaviLiquidityChangeEvent\n | AlphaAutoCompoundingEvent\n | AlphaWithdrawV2Event\n | AfterTransactionEventNode // TODO: this needs to be changed to AfterTransactionEvent Eventually\n | CheckRatioEvent;\n\n let eventNode: EventNode;\n\n if (\n isAutoCompoundingEvent(suiEvent.type) &&\n \"compound_amount_a\" in suiEventJson &&\n \"compound_amount_b\" in suiEventJson\n ) {\n // Handling CetusAutoCompoundingEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n compound_amount_a: BigInt(suiEventJson.compound_amount_a.toString()),\n compound_amount_b: BigInt(suiEventJson.compound_amount_b.toString()),\n current_liquidity: BigInt(suiEventJson.current_liquidity.toString()),\n fee_collected_a: BigInt(suiEventJson.fee_collected_a.toString()),\n fee_collected_b: BigInt(suiEventJson.fee_collected_b.toString()),\n free_balance_a: BigInt(suiEventJson.free_balance_a.toString()),\n free_balance_b: BigInt(suiEventJson.free_balance_b.toString()),\n investor_id: suiEventJson.investor_id,\n total_amount_a: BigInt(suiEventJson.total_amount_a.toString()),\n total_amount_b: BigInt(suiEventJson.total_amount_b.toString()),\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n\n // if (\n // eventNode.investor_id ===\n // \"0xd060e81548aee885bd3d37ae0caec181185be792bf45412e0d0acccd1e0174e6\"\n // ) {\n // console.log(\n // eventNode.timestamp,\n // (prevTS - eventNode.timestamp) / (1000 * 60),\n // );\n // prevTS = eventNode.timestamp;\n // }\n } else if (\n isAutoCompoundingEvent(suiEvent.type) &&\n \"compound_amount\" in suiEventJson\n ) {\n // Handling NaviAutoCompoundingEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n compound_amount: BigInt(suiEventJson.compound_amount.toString()),\n fee_collected: BigInt(suiEventJson.fee_collected.toString()),\n investor_id: suiEventJson.investor_id,\n location: suiEventJson.location,\n total_amount: BigInt(suiEventJson.total_amount.toString()),\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n if (\n \"cur_total_debt\" in suiEventJson &&\n \"accrued_interest\" in suiEventJson\n ) {\n const loopEvent: AutoCompoundingEventNode = {\n ...eventNode,\n cur_total_debt: BigInt(suiEventJson.cur_total_debt.toString()),\n accrued_interest: BigInt(suiEventJson.accrued_interest.toString()),\n };\n eventNode = loopEvent;\n }\n } else if (\n isAutoCompoundingEvent(suiEvent.type) &&\n \"amount\" in suiEventJson\n ) {\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n amount: suiEventJson.amount,\n investor_id: conf[CONF_ENV].ALPHA_POOL,\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else if (\n isAutoCompoundingEvent(suiEvent.type) &&\n \"blue_reward_amount\" in suiEventJson\n ) {\n // Handling CetusAutoCompoundingEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n blue_reward_amount: BigInt(\n suiEventJson.blue_reward_amount.toString(),\n ),\n current_liquidity: BigInt(suiEventJson.current_liquidity.toString()),\n fee_collected: BigInt(suiEventJson.fee_collected.toString()),\n free_balance_a: BigInt(suiEventJson.free_balance_a.toString()),\n free_balance_b: BigInt(suiEventJson.free_balance_b.toString()),\n investor_id: suiEventJson.investor_id,\n total_amount_a: BigInt(suiEventJson.total_amount_a.toString()),\n total_amount_b: BigInt(suiEventJson.total_amount_b.toString()),\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n\n // if (\n // eventNode.investor_id ===\n // \"0xd060e81548aee885bd3d37ae0caec181185be792bf45412e0d0acccd1e0174e6\"\n // ) {\n // console.log(\n // eventNode.timestamp,\n // (prevTS - eventNode.timestamp) / (1000 * 60),\n // );\n // prevTS = eventNode.timestamp;\n // }\n } else if (\n isRebalanceEvent(suiEvent.type) &&\n \"lower_tick_after\" in suiEventJson\n ) {\n // Handling RebalanceEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n investor_id: suiEventJson.investor_id.toString(),\n lower_tick_after: suiEventJson.lower_tick_after.toString(),\n upper_tick_after: suiEventJson.upper_tick_after.toString(),\n sqrt_price_after: suiEventJson.sqrt_price_after.toString(),\n amount_a_before: suiEventJson.amount_a_before.toString(),\n amount_b_before: suiEventJson.amount_b_before.toString(),\n amount_a_after: suiEventJson.amount_a_after.toString(),\n amount_b_after: suiEventJson.amount_b_after.toString(),\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else if (\n isLiquidityChangeEvent(suiEvent.type) &&\n \"amount_a\" in suiEventJson\n ) {\n // Handling CetusLiquidityChangeEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n amount_a: suiEventJson.amount_a,\n amount_b: suiEventJson.amount_b,\n event_type: suiEventJson.event_type,\n fee_collected_a: suiEventJson.fee_collected_a,\n fee_collected_b: suiEventJson.fee_collected_b,\n pool_id: suiEventJson.pool_id,\n sender: suiEventJson.sender,\n tokens_invested: suiEventJson.tokens_invested,\n total_amount_a: suiEventJson.total_amount_a,\n total_amount_b: suiEventJson.total_amount_b,\n user_total_x_token_balance: suiEventJson.user_total_x_token_balance,\n x_token_supply: suiEventJson.x_token_supply,\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else if (\n isLiquidityChangeEvent(suiEvent.type) &&\n \"amount\" in suiEventJson &&\n !(\"investor_id\" in suiEventJson) &&\n !(\"amount_withdrawn_from_locked\" in suiEventJson) &&\n !(\"xtokenSupply\" in suiEventJson)\n ) {\n // Handling NaviLiquidityChangeEvent and AlphaLiquidityChangeEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n amount: suiEventJson.amount,\n event_type: suiEventJson.event_type,\n fee_collected: suiEventJson.fee_collected,\n pool_id: suiEventJson.pool_id,\n sender: suiEventJson.sender,\n tokens_invested: suiEventJson.tokens_invested,\n user_total_x_token_balance: suiEventJson.user_total_x_token_balance,\n x_token_supply: suiEventJson.x_token_supply,\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else if (\n isWithdrawV2Event(suiEvent.type) &&\n \"amount_withdrawn_from_locked\" in suiEventJson\n ) {\n // Handling Alpha WithdrawV2 Events\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n amount: suiEventJson.amount,\n amount_withdrawn_from_locked:\n suiEventJson.amount_withdrawn_from_locked,\n amount_withdrawn_from_unlocked:\n suiEventJson.amount_withdrawn_from_unlocked,\n fee_collected: suiEventJson.fee_collected,\n instant_withdraw_fee_collected:\n suiEventJson.instant_withdraw_fee_collected,\n pool_id: suiEventJson.pool_id,\n sender: suiEventJson.sender,\n tokens_invested: suiEventJson.tokens_invested,\n user_total_x_token_balance: suiEventJson.user_total_x_token_balance,\n x_token_supply: suiEventJson.x_token_supply,\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else if (\n isAfterTransactionEvent(suiEvent.type) &&\n \"tokensInvested\" in suiEventJson &&\n !(\"liquidity\" in suiEventJson) &&\n !(\"amount\" in suiEventJson)\n ) {\n //handling alpha after transaction event\n if (suiEvent.id.eventSeq === \"0\") continue;\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n poolName: \"ALPHA\",\n id: {\n eventSeq: Number(suiEvent.id.eventSeq),\n txDigest: suiEvent.id.txDigest,\n },\n tokensInvested: suiEventJson.tokensInvested,\n xTokenSupply: suiEventJson.xTokenSupply,\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else if (\n isAfterTransactionEvent(suiEvent.type) &&\n \"tokensInvested\" in suiEventJson &&\n \"liquidity\" in suiEventJson\n ) {\n //handling cetus after transaction event\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n poolName: undefined,\n id: {\n eventSeq: Number(suiEvent.id.eventSeq),\n txDigest: suiEvent.id.txDigest,\n },\n tokensInvested: suiEventJson.tokensInvested,\n xtokenSupply: suiEventJson.xtokenSupply,\n liquidity: suiEventJson.liquidity,\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else if (\n isAfterTransactionEvent(suiEvent.type) &&\n \"amount\" in suiEventJson &&\n \"tokensInvested\" in suiEventJson\n ) {\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n poolName: undefined,\n id: {\n eventSeq: Number(suiEvent.id.eventSeq),\n txDigest: suiEvent.id.txDigest,\n },\n tokensInvested: suiEventJson.tokensInvested,\n xtokenSupply: suiEventJson.xtokenSupply,\n amount: suiEventJson.amount,\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else if (\"ratio\" in suiEventJson) {\n // Check Ratio - looping pools\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n ratio: suiEventJson.ratio,\n txDigest: suiEvent.id.txDigest,\n eventSeq: Number(suiEvent.id.eventSeq),\n transactionModule: suiEvent.transactionModule,\n };\n } else {\n console.error(\"event: \", suiEvent, \"json: \", suiEventJson);\n throw new Error(\"Unknown event type\");\n }\n\n allEvents.push(eventNode);\n }\n\n // If we set hasPreviousPage to false, exit the outer loop as well\n if (!hasNextPage) {\n break;\n }\n\n hasNextPage = result.hasNextPage;\n startCursor = result.nextCursor;\n }\n\n return allEvents;\n}\n\nconst isAutoCompoundingEvent = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo).map((info) => {\n return info.autoCompoundingEventType;\n });\n return eventTypes.includes(eventType);\n};\n\nconst isRebalanceEvent = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo)\n .filter((info) => {\n return info.rebalanceEventType ? true : false;\n })\n .map((info) => {\n return info.rebalanceEventType as string;\n });\n return eventTypes.includes(eventType);\n};\n\nconst isLiquidityChangeEvent = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo).map((info) => {\n return info.liquidityChangeEventType;\n });\n return eventTypes.includes(eventType);\n};\n\nconst isWithdrawV2Event = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo)\n .map((info) => {\n return info.withdrawV2EventType;\n })\n .filter((type) => type !== undefined);\n return eventTypes.includes(eventType);\n};\n\nconst isAfterTransactionEvent = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo)\n .map((info) => {\n return info.afterTransactionEventType;\n })\n .filter((type) => type !== undefined);\n return eventTypes.includes(eventType);\n};\n"]}
|
|
@@ -29,6 +29,16 @@ export interface NaviLoopAutoCompoundingEvent extends NaviAutoCompoundingEvent {
|
|
|
29
29
|
cur_total_debt: bigint;
|
|
30
30
|
accrued_interest: bigint;
|
|
31
31
|
}
|
|
32
|
+
export interface AutobalancingAutoCompoundingEvent {
|
|
33
|
+
blue_reward_amount: bigint;
|
|
34
|
+
current_liquidity: bigint;
|
|
35
|
+
fee_collected: bigint;
|
|
36
|
+
free_balance_a: bigint;
|
|
37
|
+
free_balance_b: bigint;
|
|
38
|
+
investor_id: string;
|
|
39
|
+
total_amount_a: bigint;
|
|
40
|
+
total_amount_b: bigint;
|
|
41
|
+
}
|
|
32
42
|
export interface RebalanceEvent {
|
|
33
43
|
investor_id: string;
|
|
34
44
|
lower_tick_after: string;
|
|
@@ -164,7 +174,7 @@ export type AfterTransactionEventNode = (CetusAfterTransactionEvent & CommonEven
|
|
|
164
174
|
txDigest: string;
|
|
165
175
|
};
|
|
166
176
|
});
|
|
167
|
-
export type AutoCompoundingEventNode = (CetusAutoCompoundingEvent & CommonEventAttributes) | (NaviAutoCompoundingEvent & CommonEventAttributes) | (NaviLoopAutoCompoundingEvent & CommonEventAttributes) | (AlphaAutoCompoundingEvent & CommonEventAttributes);
|
|
177
|
+
export type AutoCompoundingEventNode = (CetusAutoCompoundingEvent & CommonEventAttributes) | (NaviAutoCompoundingEvent & CommonEventAttributes) | (NaviLoopAutoCompoundingEvent & CommonEventAttributes) | (AlphaAutoCompoundingEvent & CommonEventAttributes) | (AutobalancingAutoCompoundingEvent & CommonEventAttributes);
|
|
168
178
|
export type RebalanceEventNode = RebalanceEvent & CommonEventAttributes;
|
|
169
179
|
export type LiquidityChangeEventNode = (CetusLiquidityChangeEvent & CommonEventAttributes) | (NaviLiquidityChangeEvent & CommonEventAttributes) | (AlphaLiquidityChangeEvent & CommonEventAttributes);
|
|
170
180
|
export type WithdrawV2EventNode = AlphaWithdrawV2Event & CommonEventAttributes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/sui-sdk/events/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,UAAU,qBAAqB;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,yBAAyB;IACxC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,wBAAwB;IACvC,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IAC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M,MAAM,2BAA2B,GAAG;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,gCAAgC,CAAC;AAE3E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/sui-sdk/events/types.ts"],"names":[],"mappings":"","sourcesContent":["import { PoolName } from \"../../common/types.js\";\n\ninterface CommonEventAttributes {\n type: string;\n timestamp: number;\n txDigest: string;\n eventSeq: number;\n transactionModule: string;\n}\n\nexport interface CetusAutoCompoundingEvent {\n compound_amount_a: bigint;\n compound_amount_b: bigint;\n current_liquidity: bigint;\n fee_collected_a: bigint;\n fee_collected_b: bigint;\n free_balance_a: bigint;\n free_balance_b: bigint;\n investor_id: string;\n total_amount_a: bigint;\n total_amount_b: bigint;\n}\n\nexport interface NaviAutoCompoundingEvent {\n compound_amount: bigint;\n fee_collected: bigint;\n investor_id: string;\n location: number;\n total_amount: bigint;\n}\n\nexport interface NaviLoopAutoCompoundingEvent extends NaviAutoCompoundingEvent {\n cur_total_debt: bigint;\n accrued_interest: bigint;\n}\n\nexport interface RebalanceEvent {\n investor_id: string;\n lower_tick_after: string;\n upper_tick_after: string;\n sqrt_price_after: string;\n amount_a_before: string;\n amount_b_before: string;\n amount_a_after: string;\n amount_b_after: string;\n}\n\n//verify, this might be wrong, alphapool reward event is defined as alpha autocompounding event\nexport interface AlphaAutoCompoundingEvent {\n amount: string;\n investor_id: string;\n}\n\nexport interface CetusLiquidityChangeEvent {\n amount_a: string;\n amount_b: string;\n event_type: number;\n fee_collected_a: string;\n fee_collected_b: string;\n pool_id: string;\n sender: string;\n tokens_invested: string;\n total_amount_a: string;\n total_amount_b: string;\n user_total_x_token_balance: string;\n x_token_supply: string;\n}\n\nexport interface NaviLiquidityChangeEvent {\n amount: string;\n event_type: number;\n fee_collected: string;\n pool_id: string;\n sender: string;\n tokens_invested: string;\n user_total_x_token_balance: string;\n x_token_supply: string;\n}\n\nexport interface AlphaLiquidityChangeEvent {\n amount: string;\n event_type: number;\n fee_collected: string;\n pool_id: string;\n sender: string;\n tokens_invested: string;\n user_total_x_token_balance: string;\n x_token_supply: string;\n}\n\nexport interface AlphaWithdrawV2Event {\n amount: string;\n amount_withdrawn_from_locked: string;\n amount_withdrawn_from_unlocked: string;\n fee_collected: string;\n instant_withdraw_fee_collected: string;\n pool_id: string;\n sender: string;\n tokens_invested: string;\n user_total_x_token_balance: string;\n x_token_supply: string;\n}\n\nexport interface CetusAfterTransactionEvent {\n liquidity: string;\n tokensInvested: string;\n xtokenSupply: string;\n}\nexport interface NaviAfterTransactionEvent {\n amount: string;\n tokensInvested: string;\n xtokenSupply: string;\n}\n\n// only event sequence non zero are after transaction\nexport interface AlphaBeforeAndAfterEvent {\n tokensInvested: string;\n xTokenSupply: string;\n}\n\nexport type CetusAddLiquidityEvent = {\n after_liquidity: string;\n amount_a: string;\n amount_b: string;\n liquidity: string;\n pool: string;\n position: string;\n tick_lower: { bits: number };\n tick_upper: { bits: number };\n};\nexport type CetusRemoveLiquidityEvent = {\n after_liquidity: string;\n amount_a: string;\n amount_b: string;\n liquidity: string;\n pool: string;\n position: string;\n tick_lower: { bits: number };\n tick_upper: { bits: number };\n};\n\nexport type NaviPoolDepositEvent = {\n amount: string;\n pool: string;\n sender: string;\n};\nexport type NaviPoolWithdrawEvent = {\n amount: string;\n pool: string;\n recipient: string;\n sender: string;\n};\n\nexport interface CheckRatioEvent {\n ratio: string;\n}\n\nexport type AfterTransactionEventNode =\n | (CetusAfterTransactionEvent &\n CommonEventAttributes & {\n poolName: PoolName | undefined;\n id: { eventSeq: number; txDigest: string };\n })\n | (NaviAfterTransactionEvent &\n CommonEventAttributes & {\n poolName: PoolName | undefined;\n id: { eventSeq: number; txDigest: string };\n })\n | (AlphaBeforeAndAfterEvent &\n CommonEventAttributes & {\n poolName: PoolName | undefined;\n id: { eventSeq: number; txDigest: string };\n });\n\nexport type AutoCompoundingEventNode =\n | (CetusAutoCompoundingEvent & CommonEventAttributes)\n | (NaviAutoCompoundingEvent & CommonEventAttributes)\n | (NaviLoopAutoCompoundingEvent & CommonEventAttributes)\n | (AlphaAutoCompoundingEvent & CommonEventAttributes);\n\nexport type RebalanceEventNode = RebalanceEvent & CommonEventAttributes;\n\nexport type LiquidityChangeEventNode =\n | (CetusLiquidityChangeEvent & CommonEventAttributes)\n | (NaviLiquidityChangeEvent & CommonEventAttributes)\n | (AlphaLiquidityChangeEvent & CommonEventAttributes);\n\nexport type WithdrawV2EventNode = AlphaWithdrawV2Event & CommonEventAttributes;\n\nexport type CheckRatioEventNode = CheckRatioEvent & CommonEventAttributes;\n\nexport type EventNode =\n | AutoCompoundingEventNode\n | RebalanceEventNode\n | LiquidityChangeEventNode\n | WithdrawV2EventNode\n | AfterTransactionEventNode\n | CheckRatioEventNode;\n\nexport type FetchAutoCompoundingEventsParams = {\n startTime?: number;\n endTime?: number;\n poolNames?: PoolName[];\n};\n\nexport type FetchRebalanceEventsParams = FetchAutoCompoundingEventsParams;\n\nexport type FetchLiquidityChangeEventsParams = FetchAutoCompoundingEventsParams;\n\nexport type FetchWithdrawV2EventsParams = {\n startTime?: number;\n endTime?: number;\n};\n\nexport type FetchCheckRatioEventsParams = FetchAutoCompoundingEventsParams;\n\nexport type FetchEventsParams = {\n eventTypes: string[];\n startTime?: number;\n endTime?: number;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/sui-sdk/events/types.ts"],"names":[],"mappings":"","sourcesContent":["import { PoolName } from \"../../common/types.js\";\n\ninterface CommonEventAttributes {\n type: string;\n timestamp: number;\n txDigest: string;\n eventSeq: number;\n transactionModule: string;\n}\n\nexport interface CetusAutoCompoundingEvent {\n compound_amount_a: bigint;\n compound_amount_b: bigint;\n current_liquidity: bigint;\n fee_collected_a: bigint;\n fee_collected_b: bigint;\n free_balance_a: bigint;\n free_balance_b: bigint;\n investor_id: string;\n total_amount_a: bigint;\n total_amount_b: bigint;\n}\n\nexport interface NaviAutoCompoundingEvent {\n compound_amount: bigint;\n fee_collected: bigint;\n investor_id: string;\n location: number;\n total_amount: bigint;\n}\n\nexport interface NaviLoopAutoCompoundingEvent extends NaviAutoCompoundingEvent {\n cur_total_debt: bigint;\n accrued_interest: bigint;\n}\n\nexport interface AutobalancingAutoCompoundingEvent {\n blue_reward_amount: bigint;\n current_liquidity: bigint;\n fee_collected: bigint;\n free_balance_a: bigint;\n free_balance_b: bigint;\n investor_id: string;\n total_amount_a: bigint;\n total_amount_b: bigint;\n}\n\nexport interface RebalanceEvent {\n investor_id: string;\n lower_tick_after: string;\n upper_tick_after: string;\n sqrt_price_after: string;\n amount_a_before: string;\n amount_b_before: string;\n amount_a_after: string;\n amount_b_after: string;\n}\n\n//verify, this might be wrong, alphapool reward event is defined as alpha autocompounding event\nexport interface AlphaAutoCompoundingEvent {\n amount: string;\n investor_id: string;\n}\n\nexport interface CetusLiquidityChangeEvent {\n amount_a: string;\n amount_b: string;\n event_type: number;\n fee_collected_a: string;\n fee_collected_b: string;\n pool_id: string;\n sender: string;\n tokens_invested: string;\n total_amount_a: string;\n total_amount_b: string;\n user_total_x_token_balance: string;\n x_token_supply: string;\n}\n\nexport interface NaviLiquidityChangeEvent {\n amount: string;\n event_type: number;\n fee_collected: string;\n pool_id: string;\n sender: string;\n tokens_invested: string;\n user_total_x_token_balance: string;\n x_token_supply: string;\n}\n\nexport interface AlphaLiquidityChangeEvent {\n amount: string;\n event_type: number;\n fee_collected: string;\n pool_id: string;\n sender: string;\n tokens_invested: string;\n user_total_x_token_balance: string;\n x_token_supply: string;\n}\n\nexport interface AlphaWithdrawV2Event {\n amount: string;\n amount_withdrawn_from_locked: string;\n amount_withdrawn_from_unlocked: string;\n fee_collected: string;\n instant_withdraw_fee_collected: string;\n pool_id: string;\n sender: string;\n tokens_invested: string;\n user_total_x_token_balance: string;\n x_token_supply: string;\n}\n\nexport interface CetusAfterTransactionEvent {\n liquidity: string;\n tokensInvested: string;\n xtokenSupply: string;\n}\nexport interface NaviAfterTransactionEvent {\n amount: string;\n tokensInvested: string;\n xtokenSupply: string;\n}\n\n// only event sequence non zero are after transaction\nexport interface AlphaBeforeAndAfterEvent {\n tokensInvested: string;\n xTokenSupply: string;\n}\n\nexport type CetusAddLiquidityEvent = {\n after_liquidity: string;\n amount_a: string;\n amount_b: string;\n liquidity: string;\n pool: string;\n position: string;\n tick_lower: { bits: number };\n tick_upper: { bits: number };\n};\nexport type CetusRemoveLiquidityEvent = {\n after_liquidity: string;\n amount_a: string;\n amount_b: string;\n liquidity: string;\n pool: string;\n position: string;\n tick_lower: { bits: number };\n tick_upper: { bits: number };\n};\n\nexport type NaviPoolDepositEvent = {\n amount: string;\n pool: string;\n sender: string;\n};\nexport type NaviPoolWithdrawEvent = {\n amount: string;\n pool: string;\n recipient: string;\n sender: string;\n};\n\nexport interface CheckRatioEvent {\n ratio: string;\n}\n\nexport type AfterTransactionEventNode =\n | (CetusAfterTransactionEvent &\n CommonEventAttributes & {\n poolName: PoolName | undefined;\n id: { eventSeq: number; txDigest: string };\n })\n | (NaviAfterTransactionEvent &\n CommonEventAttributes & {\n poolName: PoolName | undefined;\n id: { eventSeq: number; txDigest: string };\n })\n | (AlphaBeforeAndAfterEvent &\n CommonEventAttributes & {\n poolName: PoolName | undefined;\n id: { eventSeq: number; txDigest: string };\n });\n\nexport type AutoCompoundingEventNode =\n | (CetusAutoCompoundingEvent & CommonEventAttributes)\n | (NaviAutoCompoundingEvent & CommonEventAttributes)\n | (NaviLoopAutoCompoundingEvent & CommonEventAttributes)\n | (AlphaAutoCompoundingEvent & CommonEventAttributes)\n | (AutobalancingAutoCompoundingEvent & CommonEventAttributes);\n\nexport type RebalanceEventNode = RebalanceEvent & CommonEventAttributes;\n\nexport type LiquidityChangeEventNode =\n | (CetusLiquidityChangeEvent & CommonEventAttributes)\n | (NaviLiquidityChangeEvent & CommonEventAttributes)\n | (AlphaLiquidityChangeEvent & CommonEventAttributes);\n\nexport type WithdrawV2EventNode = AlphaWithdrawV2Event & CommonEventAttributes;\n\nexport type CheckRatioEventNode = CheckRatioEvent & CommonEventAttributes;\n\nexport type EventNode =\n | AutoCompoundingEventNode\n | RebalanceEventNode\n | LiquidityChangeEventNode\n | WithdrawV2EventNode\n | AfterTransactionEventNode\n | CheckRatioEventNode;\n\nexport type FetchAutoCompoundingEventsParams = {\n startTime?: number;\n endTime?: number;\n poolNames?: PoolName[];\n};\n\nexport type FetchRebalanceEventsParams = FetchAutoCompoundingEventsParams;\n\nexport type FetchLiquidityChangeEventsParams = FetchAutoCompoundingEventsParams;\n\nexport type FetchWithdrawV2EventsParams = {\n startTime?: number;\n endTime?: number;\n};\n\nexport type FetchCheckRatioEventsParams = FetchAutoCompoundingEventsParams;\n\nexport type FetchEventsParams = {\n eventTypes: string[];\n startTime?: number;\n endTime?: number;\n};\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PoolName } from "../../common/types.js";
|
|
2
|
+
export declare function getPositionRanges(poolNames?: PoolName[]): Promise<Map<PoolName, {
|
|
3
|
+
lowerPrice: string;
|
|
4
|
+
upperPrice: string;
|
|
5
|
+
}>>;
|
|
6
|
+
export declare function getPositionRange(ignoreCache: boolean): Promise<Map<PoolName, {
|
|
7
|
+
lowerPrice: string;
|
|
8
|
+
upperPrice: string;
|
|
9
|
+
}>>;
|
|
10
|
+
//# sourceMappingURL=getPositionRange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPositionRange.d.ts","sourceRoot":"","sources":["../../../../src/sui-sdk/functions/getPositionRange.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,QAAQ,EAKT,MAAM,uBAAuB,CAAC;AAE/B,wBAAsB,iBAAiB,CAAC,SAAS,GAAE,QAAQ,EAAO;gBACpB,MAAM;gBAAc,MAAM;IAyDvE;AAED,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAuDpE"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPositionRanges = getPositionRanges;
|
|
4
|
+
exports.getPositionRange = getPositionRange;
|
|
5
|
+
const cetus_sui_clmm_sdk_1 = require("@cetusprotocol/cetus-sui-clmm-sdk");
|
|
6
|
+
const index_js_1 = require("../../index.js");
|
|
7
|
+
const coins_js_1 = require("../../common/coins.js");
|
|
8
|
+
async function getPositionRanges(poolNames = []) {
|
|
9
|
+
const res = new Map();
|
|
10
|
+
// Use Promise.all to handle multiple promises in parallel
|
|
11
|
+
await Promise.all(poolNames.map(async (poolName) => {
|
|
12
|
+
if (poolName == "ALPHA" ||
|
|
13
|
+
!["CETUS", "BLUEFIN"].includes(index_js_1.poolInfo[poolName.toString()].parentProtocolName)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
let investor;
|
|
17
|
+
if (index_js_1.poolInfo[poolName.toString()].parentProtocolName == "CETUS") {
|
|
18
|
+
investor = (await (0, index_js_1.getInvestor)(poolName, false));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
investor = (await (0, index_js_1.getInvestor)(poolName, false));
|
|
22
|
+
}
|
|
23
|
+
const coinAName = index_js_1.doubleAssetPoolCoinMap[poolName].coin1;
|
|
24
|
+
const coinA = coins_js_1.coinsList[coinAName];
|
|
25
|
+
const coinBName = index_js_1.doubleAssetPoolCoinMap[poolName].coin2;
|
|
26
|
+
const coinB = coins_js_1.coinsList[coinBName];
|
|
27
|
+
if (investor) {
|
|
28
|
+
const upperBound = 443636;
|
|
29
|
+
let lowerTick = Number(investor.content.fields.lower_tick);
|
|
30
|
+
let upperTick = Number(investor.content.fields.upper_tick);
|
|
31
|
+
if (lowerTick > upperBound) {
|
|
32
|
+
lowerTick = -~(lowerTick - 1);
|
|
33
|
+
}
|
|
34
|
+
if (upperTick > upperBound) {
|
|
35
|
+
upperTick = -~(upperTick - 1);
|
|
36
|
+
}
|
|
37
|
+
const lowerPrice = cetus_sui_clmm_sdk_1.TickMath.tickIndexToPrice(lowerTick, coinA.expo, coinB.expo);
|
|
38
|
+
const upperPrice = cetus_sui_clmm_sdk_1.TickMath.tickIndexToPrice(upperTick, coinA.expo, coinB.expo);
|
|
39
|
+
res.set(poolName, {
|
|
40
|
+
lowerPrice: lowerPrice.toString(),
|
|
41
|
+
upperPrice: upperPrice.toString(),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}));
|
|
45
|
+
return res;
|
|
46
|
+
}
|
|
47
|
+
async function getPositionRange(ignoreCache) {
|
|
48
|
+
const res = new Map();
|
|
49
|
+
for (const poolNameString of Object.keys(index_js_1.poolInfo)) {
|
|
50
|
+
const poolName = poolNameString;
|
|
51
|
+
if (poolName == "ALPHA" ||
|
|
52
|
+
!["CETUS", "BLUEFIN"].includes(index_js_1.poolInfo[poolNameString].parentProtocolName)) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
let investor;
|
|
56
|
+
if (index_js_1.poolInfo[poolNameString].parentProtocolName == "CETUS") {
|
|
57
|
+
investor = (await (0, index_js_1.getInvestor)(poolName, ignoreCache));
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
investor = (await (0, index_js_1.getInvestor)(poolName, ignoreCache));
|
|
61
|
+
}
|
|
62
|
+
const coinAName = index_js_1.doubleAssetPoolCoinMap[poolName].coin1;
|
|
63
|
+
const coinA = coins_js_1.coinsList[coinAName];
|
|
64
|
+
const coinBName = index_js_1.doubleAssetPoolCoinMap[poolName].coin2;
|
|
65
|
+
const coinB = coins_js_1.coinsList[coinBName];
|
|
66
|
+
if (investor) {
|
|
67
|
+
const upperBound = 443636;
|
|
68
|
+
let lowerTick = Number(investor.content.fields.lower_tick);
|
|
69
|
+
let upperTick = Number(investor.content.fields.upper_tick);
|
|
70
|
+
if (lowerTick > upperBound) {
|
|
71
|
+
lowerTick = -~(lowerTick - 1);
|
|
72
|
+
}
|
|
73
|
+
if (upperTick > upperBound) {
|
|
74
|
+
upperTick = -~(upperTick - 1);
|
|
75
|
+
}
|
|
76
|
+
const lowerPrice = cetus_sui_clmm_sdk_1.TickMath.tickIndexToPrice(lowerTick, coinA.expo, coinB.expo);
|
|
77
|
+
const upperPrice = cetus_sui_clmm_sdk_1.TickMath.tickIndexToPrice(upperTick, coinA.expo, coinB.expo);
|
|
78
|
+
res.set(poolName, {
|
|
79
|
+
lowerPrice: lowerPrice.toString(),
|
|
80
|
+
upperPrice: upperPrice.toString(),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return res;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=getPositionRange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPositionRange.js","sourceRoot":"","sources":["../../../../src/sui-sdk/functions/getPositionRange.ts"],"names":[],"mappings":";;AAWA,8CA0DC;AAED,4CAyDC;AAhID,0EAA6D;AAC7D,6CAA+E;AAC/E,oDAAkD;AAS3C,KAAK,UAAU,iBAAiB,CAAC,YAAwB,EAAE;IAChE,MAAM,GAAG,GAAG,IAAI,GAAG,EAAwD,CAAC;IAE5E,0DAA0D;IAC1D,MAAM,OAAO,CAAC,GAAG,CACf,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;QAC/B,IACE,QAAQ,IAAI,OAAO;YACnB,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,QAAQ,CAC5B,mBAAQ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MAAM,SAAS,GAAG,iCAAsB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;QACzD,MAAM,KAAK,GAAG,oBAAS,CAAC,SAAS,CAAC,CAAC;QACnC,IAAI,QAAQ,EAAE,CAAC;YACb,MAAM,UAAU,GAAG,MAAM,CAAC;YAC1B,IAAI,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAC3D,IAAI,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAC3D,IAAI,SAAS,GAAG,UAAU,EAAE,CAAC;gBAC3B,SAAS,GAAG,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;YAChC,CAAC;YACD,IAAI,SAAS,GAAG,UAAU,EAAE,CAAC;gBAC3B,SAAS,GAAG,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;YAChC,CAAC;YACD,MAAM,UAAU,GAAG,6BAAQ,CAAC,gBAAgB,CAC1C,SAAS,EACT,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,IAAI,CACX,CAAC;YACF,MAAM,UAAU,GAAG,6BAAQ,CAAC,gBAAgB,CAC1C,SAAS,EACT,KAAK,CAAC,IAAI,EACV,KAAK,CAAC,IAAI,CACX,CAAC;YACF,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE;gBAChB,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE;gBACjC,UAAU,EAAE,UAAU,CAAC,QAAQ,EAAE;aAClC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { TickMath } from \"@cetusprotocol/cetus-sui-clmm-sdk\";\nimport { poolInfo, getInvestor, doubleAssetPoolCoinMap } from \"../../index.js\";\nimport { coinsList } from \"../../common/coins.js\";\nimport {\n PoolName,\n Investor,\n CetusInvestor,\n CommonInvestorFields,\n BluefinInvestor,\n} from \"../../common/types.js\";\n\nexport async function getPositionRanges(poolNames: PoolName[] = []) {\n const res = new Map<PoolName, { lowerPrice: string; upperPrice: string }>();\n\n // Use Promise.all to handle multiple promises in parallel\n await Promise.all(\n poolNames.map(async (poolName) => {\n if (\n poolName == \"ALPHA\" ||\n ![\"CETUS\", \"BLUEFIN\"].includes(\n poolInfo[poolName.toString()].parentProtocolName,\n )\n ) {\n return;\n }\n let investor: Investor;\n if (poolInfo[poolName.toString()].parentProtocolName == \"CETUS\") {\n investor = (await getInvestor(\n poolName as PoolName,\n false,\n )) as CetusInvestor & CommonInvestorFields;\n } else {\n investor = (await getInvestor(\n poolName as PoolName,\n false,\n )) as BluefinInvestor & CommonInvestorFields;\n }\n const coinAName = doubleAssetPoolCoinMap[poolName].coin1;\n const coinA = coinsList[coinAName];\n const coinBName = doubleAssetPoolCoinMap[poolName].coin2;\n const coinB = coinsList[coinBName];\n if (investor) {\n const upperBound = 443636;\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 const lowerPrice = TickMath.tickIndexToPrice(\n lowerTick,\n coinA.expo,\n coinB.expo,\n );\n const upperPrice = TickMath.tickIndexToPrice(\n upperTick,\n coinA.expo,\n coinB.expo,\n );\n res.set(poolName, {\n lowerPrice: lowerPrice.toString(),\n upperPrice: upperPrice.toString(),\n });\n }\n }),\n );\n return res;\n}\n\nexport async function getPositionRange(\n ignoreCache: boolean,\n): Promise<Map<PoolName, { lowerPrice: string; upperPrice: string }>> {\n const res = new Map<PoolName, { lowerPrice: string; upperPrice: string }>();\n for (const poolNameString of Object.keys(poolInfo)) {\n const poolName = poolNameString as PoolName;\n if (\n poolName == \"ALPHA\" ||\n ![\"CETUS\", \"BLUEFIN\"].includes(\n poolInfo[poolNameString].parentProtocolName,\n )\n ) {\n continue;\n }\n let investor: Investor;\n if (poolInfo[poolNameString].parentProtocolName == \"CETUS\") {\n investor = (await getInvestor(\n poolName as PoolName,\n ignoreCache,\n )) as CetusInvestor & CommonInvestorFields;\n } else {\n investor = (await getInvestor(\n poolName as PoolName,\n ignoreCache,\n )) as BluefinInvestor & CommonInvestorFields;\n }\n const coinAName = doubleAssetPoolCoinMap[poolName].coin1;\n const coinA = coinsList[coinAName];\n const coinBName = doubleAssetPoolCoinMap[poolName].coin2;\n const coinB = coinsList[coinBName];\n if (investor) {\n const upperBound = 443636;\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 const lowerPrice = TickMath.tickIndexToPrice(\n lowerTick,\n coinA.expo,\n coinB.expo,\n );\n const upperPrice = TickMath.tickIndexToPrice(\n upperTick,\n coinA.expo,\n coinB.expo,\n );\n res.set(poolName, {\n lowerPrice: lowerPrice.toString(),\n upperPrice: upperPrice.toString(),\n });\n }\n }\n return res;\n}\n"]}
|
|
@@ -19,25 +19,17 @@ export declare function multiGetNaviInvestor(poolNames: SingleAssetPoolNames[]):
|
|
|
19
19
|
"NAVI-USDT"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
20
20
|
"NAVI-WUSDC"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
21
21
|
"NAVI-HASUI"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
22
|
-
"NAVI-LOOP-SUI-VSUI"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
23
|
-
"NAVI-LOOP-USDC-USDT"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
24
22
|
"NAVI-USDC"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
25
23
|
"BUCKET-BUCK"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
26
24
|
"NAVI-USDY"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
27
25
|
"NAVI-AUSD"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
28
26
|
"NAVI-ETH"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
29
|
-
"NAVI-LOOP-HASUI-SUI"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
30
|
-
"NAVI-LOOP-USDT-USDC"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
31
27
|
"NAVI-NS"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
32
28
|
"NAVI-NAVX"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
29
|
+
"NAVI-LOOP-HASUI-SUI"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
30
|
+
"NAVI-LOOP-USDT-USDC"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
31
|
+
"NAVI-LOOP-SUI-VSUI"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
32
|
+
"NAVI-LOOP-USDC-USDT"?: (NaviInvestor & CommonInvestorFields) | undefined;
|
|
33
33
|
}>;
|
|
34
34
|
export declare function getDistributor(ignoreCache: boolean): Promise<Distributor | undefined>;
|
|
35
|
-
export declare function getPositionRanges(poolNames?: PoolName[]): Promise<Map<PoolName, {
|
|
36
|
-
lowerPrice: string;
|
|
37
|
-
upperPrice: string;
|
|
38
|
-
}>>;
|
|
39
|
-
export declare function getPositionRange(ignoreCache: boolean): Promise<Map<PoolName, {
|
|
40
|
-
lowerPrice: string;
|
|
41
|
-
upperPrice: string;
|
|
42
|
-
}>>;
|
|
43
35
|
//# sourceMappingURL=getReceipts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getReceipts.d.ts","sourceRoot":"","sources":["../../../../src/sui-sdk/functions/getReceipts.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAEb,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,QAAQ,EACR,QAAQ,EACR,OAAO,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AAQ,CAAC,CAqDnB;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,YAAY,CAAC,CAenE;AAED,wBAAsB,oBAAoB,CAAC,SAAS,EAAE,oBAAoB,EAAE;;;;;;;;;;;;;;;;;;;GA8B3E;AAOD,wBAAsB,cAAc,CAClC,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CA6ClC"}
|
|
@@ -13,14 +13,11 @@ exports.getInvestor = getInvestor;
|
|
|
13
13
|
exports.fetchVoloExchangeRate = fetchVoloExchangeRate;
|
|
14
14
|
exports.multiGetNaviInvestor = multiGetNaviInvestor;
|
|
15
15
|
exports.getDistributor = getDistributor;
|
|
16
|
-
exports.getPositionRanges = getPositionRanges;
|
|
17
|
-
exports.getPositionRange = getPositionRange;
|
|
18
16
|
const index_js_1 = require("../../index.js");
|
|
19
17
|
const maps_js_1 = require("../../common/maps.js");
|
|
20
18
|
const decimal_js_1 = require("decimal.js");
|
|
21
19
|
const client_js_1 = require("../client.js");
|
|
22
20
|
const simpleCache_js_1 = require("../../utils/simpleCache.js");
|
|
23
|
-
const cetus_sui_clmm_sdk_1 = require("@cetusprotocol/cetus-sui-clmm-sdk");
|
|
24
21
|
function convertReceiptGQLToReceipt(receipts) {
|
|
25
22
|
const res = receipts.map((receipt) => {
|
|
26
23
|
return {
|
|
@@ -528,84 +525,6 @@ async function getDistributor(ignoreCache) {
|
|
|
528
525
|
distributorPromiseCache.set(cacheKey, distributorPromise);
|
|
529
526
|
return distributorPromise;
|
|
530
527
|
}
|
|
531
|
-
async function getPositionRanges(poolNames = []) {
|
|
532
|
-
const res = new Map();
|
|
533
|
-
// Use Promise.all to handle multiple promises in parallel
|
|
534
|
-
await Promise.all(poolNames.map(async (poolName) => {
|
|
535
|
-
if (poolName == "ALPHA" ||
|
|
536
|
-
!["CETUS", "BLUEFIN"].includes(maps_js_1.poolInfo[poolName.toString()].parentProtocolName)) {
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
|
-
let investor;
|
|
540
|
-
if (maps_js_1.poolInfo[poolName.toString()].parentProtocolName == "CETUS") {
|
|
541
|
-
investor = (await getInvestor(poolName, false));
|
|
542
|
-
}
|
|
543
|
-
else {
|
|
544
|
-
investor = (await getInvestor(poolName, false));
|
|
545
|
-
}
|
|
546
|
-
const coinAName = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
|
|
547
|
-
const coinA = index_js_1.coinsList[coinAName];
|
|
548
|
-
const coinBName = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
|
|
549
|
-
const coinB = index_js_1.coinsList[coinBName];
|
|
550
|
-
if (investor) {
|
|
551
|
-
const upperBound = 443636;
|
|
552
|
-
let lowerTick = Number(investor.content.fields.lower_tick);
|
|
553
|
-
let upperTick = Number(investor.content.fields.upper_tick);
|
|
554
|
-
if (lowerTick > upperBound) {
|
|
555
|
-
lowerTick = -~(lowerTick - 1);
|
|
556
|
-
}
|
|
557
|
-
if (upperTick > upperBound) {
|
|
558
|
-
upperTick = -~(upperTick - 1);
|
|
559
|
-
}
|
|
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
|
-
}
|
|
582
|
-
else {
|
|
583
|
-
investor = (await getInvestor(poolName, ignoreCache));
|
|
584
|
-
}
|
|
585
|
-
const coinAName = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
|
|
586
|
-
const coinA = index_js_1.coinsList[coinAName];
|
|
587
|
-
const coinBName = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
|
|
588
|
-
const coinB = index_js_1.coinsList[coinBName];
|
|
589
|
-
if (investor) {
|
|
590
|
-
const upperBound = 443636;
|
|
591
|
-
let lowerTick = Number(investor.content.fields.lower_tick);
|
|
592
|
-
let upperTick = Number(investor.content.fields.upper_tick);
|
|
593
|
-
if (lowerTick > upperBound) {
|
|
594
|
-
lowerTick = -~(lowerTick - 1);
|
|
595
|
-
}
|
|
596
|
-
if (upperTick > upperBound) {
|
|
597
|
-
upperTick = -~(upperTick - 1);
|
|
598
|
-
}
|
|
599
|
-
const lowerPrice = cetus_sui_clmm_sdk_1.TickMath.tickIndexToPrice(lowerTick, coinA.expo, coinB.expo);
|
|
600
|
-
const upperPrice = cetus_sui_clmm_sdk_1.TickMath.tickIndexToPrice(upperTick, coinA.expo, coinB.expo);
|
|
601
|
-
res.set(poolName, {
|
|
602
|
-
lowerPrice: lowerPrice.toString(),
|
|
603
|
-
upperPrice: upperPrice.toString(),
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
return res;
|
|
608
|
-
}
|
|
609
528
|
/*
|
|
610
529
|
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,
|
|
611
530
|
problem with concurrency
|