@alphafi/alphafi-sdk 0.0.102 → 0.0.103

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.
Files changed (359) hide show
  1. package/#package.json# +98 -0
  2. package/FETCH_OVERRIDE_FIX.md +222 -0
  3. package/dist/cjs/adminFunctions.d.ts +8 -0
  4. package/dist/cjs/adminFunctions.d.ts.map +1 -1
  5. package/dist/cjs/adminFunctions.js +97 -3
  6. package/dist/cjs/adminFunctions.js.map +1 -1
  7. package/dist/cjs/common/constants.d.ts +79 -10
  8. package/dist/cjs/common/constants.d.ts.map +1 -1
  9. package/dist/cjs/common/constants.js +108 -23
  10. package/dist/cjs/common/constants.js.map +1 -1
  11. package/dist/cjs/common/maps.d.ts.map +1 -1
  12. package/dist/cjs/common/maps.js +72 -4
  13. package/dist/cjs/common/maps.js.map +1 -1
  14. package/dist/cjs/common/types.d.ts +76 -26
  15. package/dist/cjs/common/types.d.ts.map +1 -1
  16. package/dist/cjs/common/types.js.map +1 -1
  17. package/dist/cjs/getAprs.d.ts.map +1 -1
  18. package/dist/cjs/getAprs.js +0 -27
  19. package/dist/cjs/getAprs.js.map +1 -1
  20. package/dist/cjs/graphql/getMultiReceipts.js +1 -1
  21. package/dist/cjs/graphql/getMultiReceipts.js.map +1 -1
  22. package/dist/cjs/index.d.ts +3 -1
  23. package/dist/cjs/index.d.ts.map +1 -1
  24. package/dist/cjs/index.js +13 -3
  25. package/dist/cjs/index.js.map +1 -1
  26. package/dist/cjs/sui-sdk/functions/getReceipts.d.ts +4 -0
  27. package/dist/cjs/sui-sdk/functions/getReceipts.d.ts.map +1 -1
  28. package/dist/cjs/sui-sdk/functions/getReceipts.js +31 -15
  29. package/dist/cjs/sui-sdk/functions/getReceipts.js.map +1 -1
  30. package/dist/cjs/transactions/alphaVault.d.ts +26 -0
  31. package/dist/cjs/transactions/alphaVault.d.ts.map +1 -0
  32. package/dist/cjs/transactions/alphaVault.js +385 -0
  33. package/dist/cjs/transactions/alphaVault.js.map +1 -0
  34. package/dist/cjs/transactions/alphalend.d.ts.map +1 -1
  35. package/dist/cjs/transactions/alphalend.js +10 -32
  36. package/dist/cjs/transactions/alphalend.js.map +1 -1
  37. package/dist/cjs/transactions/bluefin.d.ts.map +1 -1
  38. package/dist/cjs/transactions/bluefin.js +30 -80
  39. package/dist/cjs/transactions/bluefin.js.map +1 -1
  40. package/dist/cjs/transactions/bucket.d.ts.map +1 -1
  41. package/dist/cjs/transactions/bucket.js +5 -16
  42. package/dist/cjs/transactions/bucket.js.map +1 -1
  43. package/dist/cjs/transactions/cetus.d.ts.map +1 -1
  44. package/dist/cjs/transactions/cetus.js +17 -50
  45. package/dist/cjs/transactions/cetus.js.map +1 -1
  46. package/dist/cjs/transactions/collect_rewards.d.ts +1 -0
  47. package/dist/cjs/transactions/collect_rewards.d.ts.map +1 -1
  48. package/dist/cjs/transactions/collect_rewards.js +143 -38
  49. package/dist/cjs/transactions/collect_rewards.js.map +1 -1
  50. package/dist/cjs/transactions/deposit.d.ts.map +1 -1
  51. package/dist/cjs/transactions/deposit.js +4 -0
  52. package/dist/cjs/transactions/deposit.js.map +1 -1
  53. package/dist/cjs/transactions/navi-looping.d.ts +11 -11
  54. package/dist/cjs/transactions/navi-looping.d.ts.map +1 -1
  55. package/dist/cjs/transactions/navi-looping.js +61 -134
  56. package/dist/cjs/transactions/navi-looping.js.map +1 -1
  57. package/dist/cjs/transactions/navi.d.ts.map +1 -1
  58. package/dist/cjs/transactions/navi.js +61 -106
  59. package/dist/cjs/transactions/navi.js.map +1 -1
  60. package/dist/cjs/transactions/slush.d.ts +12 -0
  61. package/dist/cjs/transactions/slush.d.ts.map +1 -0
  62. package/dist/cjs/transactions/slush.js +143 -0
  63. package/dist/cjs/transactions/slush.js.map +1 -0
  64. package/dist/cjs/transactions/withdraw.d.ts.map +1 -1
  65. package/dist/cjs/transactions/withdraw.js +4 -0
  66. package/dist/cjs/transactions/withdraw.js.map +1 -1
  67. package/dist/esm/adminFunctions.d.ts +8 -0
  68. package/dist/esm/adminFunctions.d.ts.map +1 -1
  69. package/dist/esm/adminFunctions.js +95 -5
  70. package/dist/esm/adminFunctions.js.map +1 -1
  71. package/dist/esm/common/constants.d.ts +79 -10
  72. package/dist/esm/common/constants.d.ts.map +1 -1
  73. package/dist/esm/common/constants.js +108 -23
  74. package/dist/esm/common/constants.js.map +1 -1
  75. package/dist/esm/common/maps.d.ts.map +1 -1
  76. package/dist/esm/common/maps.js +72 -4
  77. package/dist/esm/common/maps.js.map +1 -1
  78. package/dist/esm/common/types.d.ts +76 -26
  79. package/dist/esm/common/types.d.ts.map +1 -1
  80. package/dist/esm/common/types.js.map +1 -1
  81. package/dist/esm/getAprs.d.ts.map +1 -1
  82. package/dist/esm/getAprs.js +0 -27
  83. package/dist/esm/getAprs.js.map +1 -1
  84. package/dist/esm/graphql/getMultiReceipts.js +1 -1
  85. package/dist/esm/graphql/getMultiReceipts.js.map +1 -1
  86. package/dist/esm/index.d.ts +3 -1
  87. package/dist/esm/index.d.ts.map +1 -1
  88. package/dist/esm/index.js +3 -1
  89. package/dist/esm/index.js.map +1 -1
  90. package/dist/esm/sui-sdk/functions/getReceipts.d.ts +4 -0
  91. package/dist/esm/sui-sdk/functions/getReceipts.d.ts.map +1 -1
  92. package/dist/esm/sui-sdk/functions/getReceipts.js +31 -15
  93. package/dist/esm/sui-sdk/functions/getReceipts.js.map +1 -1
  94. package/dist/esm/transactions/alphaVault.d.ts +26 -0
  95. package/dist/esm/transactions/alphaVault.d.ts.map +1 -0
  96. package/dist/esm/transactions/alphaVault.js +377 -0
  97. package/dist/esm/transactions/alphaVault.js.map +1 -0
  98. package/dist/esm/transactions/alphalend.d.ts.map +1 -1
  99. package/dist/esm/transactions/alphalend.js +10 -32
  100. package/dist/esm/transactions/alphalend.js.map +1 -1
  101. package/dist/esm/transactions/bluefin.d.ts.map +1 -1
  102. package/dist/esm/transactions/bluefin.js +30 -80
  103. package/dist/esm/transactions/bluefin.js.map +1 -1
  104. package/dist/esm/transactions/bucket.d.ts.map +1 -1
  105. package/dist/esm/transactions/bucket.js +5 -16
  106. package/dist/esm/transactions/bucket.js.map +1 -1
  107. package/dist/esm/transactions/cetus.d.ts.map +1 -1
  108. package/dist/esm/transactions/cetus.js +17 -50
  109. package/dist/esm/transactions/cetus.js.map +1 -1
  110. package/dist/esm/transactions/collect_rewards.d.ts +1 -0
  111. package/dist/esm/transactions/collect_rewards.d.ts.map +1 -1
  112. package/dist/esm/transactions/collect_rewards.js +142 -38
  113. package/dist/esm/transactions/collect_rewards.js.map +1 -1
  114. package/dist/esm/transactions/deposit.d.ts.map +1 -1
  115. package/dist/esm/transactions/deposit.js +4 -0
  116. package/dist/esm/transactions/deposit.js.map +1 -1
  117. package/dist/esm/transactions/navi-looping.d.ts +11 -11
  118. package/dist/esm/transactions/navi-looping.d.ts.map +1 -1
  119. package/dist/esm/transactions/navi-looping.js +61 -134
  120. package/dist/esm/transactions/navi-looping.js.map +1 -1
  121. package/dist/esm/transactions/navi.d.ts.map +1 -1
  122. package/dist/esm/transactions/navi.js +61 -106
  123. package/dist/esm/transactions/navi.js.map +1 -1
  124. package/dist/esm/transactions/slush.d.ts +12 -0
  125. package/dist/esm/transactions/slush.d.ts.map +1 -0
  126. package/dist/esm/transactions/slush.js +137 -0
  127. package/dist/esm/transactions/slush.js.map +1 -0
  128. package/dist/esm/transactions/withdraw.d.ts.map +1 -1
  129. package/dist/esm/transactions/withdraw.js +4 -0
  130. package/dist/esm/transactions/withdraw.js.map +1 -1
  131. package/docs/assets/navigation.js +1 -1
  132. package/docs/assets/search.js +1 -1
  133. package/docs/functions/addAirdropCoin.html +1 -0
  134. package/docs/functions/alphaLpBreakdown.html +1 -1
  135. package/docs/functions/cetusLpBreakdown.html +1 -1
  136. package/docs/functions/claimAirdropTx.html +1 -0
  137. package/docs/functions/claimRewardTxb.html +1 -1
  138. package/docs/functions/claimRewardsTxb.html +1 -1
  139. package/docs/functions/claimWithdrawAlphaTx.html +1 -0
  140. package/docs/functions/coinAmountToXTokensDoubleAsset.html +1 -1
  141. package/docs/functions/coinAmountToXTokensSingleAsset.html +1 -1
  142. package/docs/functions/coinsInPool.html +1 -1
  143. package/docs/functions/collectAndSwapRewardsLyf.html +1 -1
  144. package/docs/functions/collectAndSwapRewardsSingleLoop.html +1 -1
  145. package/docs/functions/collectRewardTxb.html +1 -1
  146. package/docs/functions/collectRewards.html +1 -1
  147. package/docs/functions/collectRewardsAndSwapSlush.html +1 -0
  148. package/docs/functions/collectUnsuppliedBalance.html +1 -0
  149. package/docs/functions/deposit.html +1 -1
  150. package/docs/functions/depositAlphaTx.html +1 -0
  151. package/docs/functions/depositDoubleAssetTxb.html +1 -1
  152. package/docs/functions/depositSingleAssetTxb.html +1 -1
  153. package/docs/functions/fetchAfterTransactionEvents.html +1 -1
  154. package/docs/functions/fetchAirdropClaimEvents.html +1 -1
  155. package/docs/functions/fetchAutoCompoundingEvents.html +1 -1
  156. package/docs/functions/fetchAutoCompoundingEventsGql.html +1 -1
  157. package/docs/functions/fetchCetusPools.html +1 -1
  158. package/docs/functions/fetchChainIdentifier.html +1 -1
  159. package/docs/functions/fetchCheckRatioEvents.html +1 -1
  160. package/docs/functions/fetchEvents.html +1 -1
  161. package/docs/functions/fetchLiquidityChangeEvents.html +1 -1
  162. package/docs/functions/fetchMultiCategoryEvents.html +1 -1
  163. package/docs/functions/fetchMultiReceipts.html +1 -1
  164. package/docs/functions/fetchNftHolders.html +1 -1
  165. package/docs/functions/fetchPools.html +1 -1
  166. package/docs/functions/fetchPortfolioData.html +1 -1
  167. package/docs/functions/fetchProtocolData.html +1 -1
  168. package/docs/functions/fetchRequiredPrices.html +1 -1
  169. package/docs/functions/fetchTVL.html +1 -1
  170. package/docs/functions/fetchTransactions.html +1 -1
  171. package/docs/functions/fetchUserVaultBalances.html +1 -1
  172. package/docs/functions/fetchUserVaults.html +1 -1
  173. package/docs/functions/fetchUserWalletData.html +1 -1
  174. package/docs/functions/fetchVoloExchangeRate.html +1 -1
  175. package/docs/functions/fetchWithdrawV2Events.html +1 -1
  176. package/docs/functions/getAirdropShare.html +1 -1
  177. package/docs/functions/getAllDoubleAssetVaults.html +1 -1
  178. package/docs/functions/getAllSingleAssetVaults.html +1 -1
  179. package/docs/functions/getAllVaultBalances.html +1 -1
  180. package/docs/functions/getAllVaults.html +1 -1
  181. package/docs/functions/getAlphaUnlocks.html +1 -1
  182. package/docs/functions/getAlphaVaultBalance.html +1 -1
  183. package/docs/functions/getAmounts.html +1 -1
  184. package/docs/functions/getApr.html +1 -1
  185. package/docs/functions/getAprs.html +1 -1
  186. package/docs/functions/getApy.html +1 -1
  187. package/docs/functions/getApys.html +1 -1
  188. package/docs/functions/getCetusInvestorTicksMap.html +1 -1
  189. package/docs/functions/getCetusPool.html +1 -1
  190. package/docs/functions/getCetusSqrtPriceMap.html +1 -1
  191. package/docs/functions/getCoinAmountsFromLiquidity.html +1 -1
  192. package/docs/functions/getConf.html +1 -1
  193. package/docs/functions/getCurrentTick.html +1 -1
  194. package/docs/functions/getDistributor.html +1 -1
  195. package/docs/functions/getDoubleAssetVaultBalance.html +1 -1
  196. package/docs/functions/getDoubleAssetVaults.html +1 -1
  197. package/docs/functions/getInvestor.html +1 -1
  198. package/docs/functions/getInvestorPoolMap.html +1 -1
  199. package/docs/functions/getLastAutoCompoundTime.html +1 -1
  200. package/docs/functions/getLatestPrices.html +1 -1
  201. package/docs/functions/getLiquidity.html +1 -1
  202. package/docs/functions/getMultiCetusPool.html +1 -1
  203. package/docs/functions/getMultiInvestor.html +1 -1
  204. package/docs/functions/getMultiLatestPrices.html +1 -1
  205. package/docs/functions/getMultiParentPool.html +1 -1
  206. package/docs/functions/getMultiPool.html +1 -1
  207. package/docs/functions/getMultiReceipts.html +1 -1
  208. package/docs/functions/getParentPool.html +1 -1
  209. package/docs/functions/getPool.html +1 -1
  210. package/docs/functions/getPoolExchangeRate.html +1 -1
  211. package/docs/functions/getPoolExchangeRateMap.html +1 -1
  212. package/docs/functions/getPoolsWeightDistribution.html +1 -1
  213. package/docs/functions/getPositionRange.html +1 -1
  214. package/docs/functions/getPositionRanges.html +1 -1
  215. package/docs/functions/getPositionTicks.html +1 -1
  216. package/docs/functions/getPriceToTick.html +1 -1
  217. package/docs/functions/getRebalanceHistories.html +1 -1
  218. package/docs/functions/getRebalanceHistory.html +1 -1
  219. package/docs/functions/getReceipts.html +1 -1
  220. package/docs/functions/getSingleAssetVaultBalance.html +1 -1
  221. package/docs/functions/getSingleAssetVaults.html +1 -1
  222. package/docs/functions/getSlushUserTotalXtokens.html +1 -0
  223. package/docs/functions/getSuiClient.html +2 -2
  224. package/docs/functions/getSuiNodeUrl.html +2 -2
  225. package/docs/functions/getTVLs-1.html +1 -1
  226. package/docs/functions/getTickSpacing.html +1 -1
  227. package/docs/functions/getTickToPrice.html +1 -1
  228. package/docs/functions/getTvls.html +1 -1
  229. package/docs/functions/getVaultBalance.html +1 -1
  230. package/docs/functions/getVaults.html +1 -1
  231. package/docs/functions/getWithdrawRequestAndUnsuppliedAmounts.html +1 -0
  232. package/docs/functions/initiateWithdrawAlpha.html +1 -0
  233. package/docs/functions/lastAutocompoundTime.html +1 -1
  234. package/docs/functions/liquidityToTokens.html +1 -1
  235. package/docs/functions/migrateBoostedToLoop.html +1 -1
  236. package/docs/functions/multiLiquidityToTokens.html +1 -1
  237. package/docs/functions/multiTokensToUsd.html +1 -1
  238. package/docs/functions/multiXTokensToLiquidity.html +1 -1
  239. package/docs/functions/parseUserWalletData.html +1 -1
  240. package/docs/functions/pendingRewardAmount.html +1 -1
  241. package/docs/functions/processWithdrawRequestsManual.html +1 -0
  242. package/docs/functions/setCustomSuiClient.html +2 -2
  243. package/docs/functions/setSuiClient.html +2 -2
  244. package/docs/functions/setSuiNodeUrl.html +2 -2
  245. package/docs/functions/setWeights.html +1 -1
  246. package/docs/functions/slushDeposit.html +1 -0
  247. package/docs/functions/slushWithdraw.html +1 -0
  248. package/docs/functions/withdraw.html +1 -1
  249. package/docs/functions/withdrawAlphaTxb.html +1 -1
  250. package/docs/functions/withdrawTxb.html +1 -1
  251. package/docs/functions/zapDepositQuoteTxb.html +1 -1
  252. package/docs/functions/zapDepositTxb.html +1 -1
  253. package/docs/hierarchy.html +1 -1
  254. package/docs/index.html +2 -2
  255. package/docs/interfaces/Coin.html +6 -6
  256. package/docs/interfaces/CoinPair.html +2 -2
  257. package/docs/interfaces/CommonEventAttributes.html +2 -2
  258. package/docs/interfaces/NaviVoloData.html +2 -2
  259. package/docs/interfaces/PoolData.html +2 -2
  260. package/docs/interfaces/PoolWeightDistribution.html +2 -2
  261. package/docs/interfaces/RebalanceHistoryType.html +2 -2
  262. package/docs/modules.html +1 -1
  263. package/docs/types/AfterTransactionEventNode.html +1 -1
  264. package/docs/types/AirdropClaimEventNode.html +1 -1
  265. package/docs/types/Allocator.html +2 -2
  266. package/docs/types/AlphaFiDoubleAssetVault.html +2 -2
  267. package/docs/types/AlphaFiMultiVaultBalance.html +1 -1
  268. package/docs/types/AlphaFiSingleAssetVault.html +2 -2
  269. package/docs/types/AlphaFiVault.html +1 -1
  270. package/docs/types/AlphaFiVaultBalance.html +1 -1
  271. package/docs/types/AlphaLendInvestor.html +1 -1
  272. package/docs/types/AlphaPoolType.html +2 -2
  273. package/docs/types/AlphaReceipt.html +2 -2
  274. package/docs/types/AlphaReceiptFields.html +2 -2
  275. package/docs/types/AlphaVaultBalance.html +2 -2
  276. package/docs/types/AutoBalancePoolNames.html +1 -1
  277. package/docs/types/AutoCompoundingEventNode.html +1 -1
  278. package/docs/types/Bag.html +3 -0
  279. package/docs/types/BluefinInvestor.html +1 -1
  280. package/docs/types/BluefinLyfInvestor.html +1 -1
  281. package/docs/types/BluefinPoolType.html +2 -2
  282. package/docs/types/BucketInvestor.html +2 -2
  283. package/docs/types/CetusInvestor.html +2 -2
  284. package/docs/types/CetusPoolType.html +2 -2
  285. package/docs/types/CetusSwapOptions.html +1 -1
  286. package/docs/types/CoinAmounts.html +2 -2
  287. package/docs/types/CoinName.html +1 -1
  288. package/docs/types/CoinType.html +1 -1
  289. package/docs/types/CommonInvestorFields.html +2 -2
  290. package/docs/types/CreatePoolOptions.html +2 -2
  291. package/docs/types/Distributor.html +2 -2
  292. package/docs/types/DoubleAssetMultiVaultBalance.html +2 -2
  293. package/docs/types/DoubleAssetPoolNames.html +1 -1
  294. package/docs/types/DoubleAssetTokenHoldings.html +2 -2
  295. package/docs/types/DoubleAssetVaultBalance.html +2 -2
  296. package/docs/types/EventCategory.html +1 -1
  297. package/docs/types/EventNode.html +1 -1
  298. package/docs/types/GetHoldersParams.html +2 -2
  299. package/docs/types/GetTokenHoldingsParams.html +2 -2
  300. package/docs/types/GetUserTokensFromTransactionsParams.html +2 -2
  301. package/docs/types/GetUserTokensInUsdFromTransactionsParams.html +2 -2
  302. package/docs/types/GetVaultBalanceParams.html +1 -1
  303. package/docs/types/HoldingsObj.html +2 -2
  304. package/docs/types/Icon.html +1 -1
  305. package/docs/types/Investor.html +1 -1
  306. package/docs/types/LiquidityChangeEventNode.html +1 -1
  307. package/docs/types/LiquidityToTokensParams.html +2 -2
  308. package/docs/types/LiquidityToUsdParams.html +2 -2
  309. package/docs/types/LoopingDebt.html +2 -2
  310. package/docs/types/LoopingPoolNames.html +1 -1
  311. package/docs/types/LpBreakdownType.html +2 -2
  312. package/docs/types/MemberPoolDataType.html +2 -2
  313. package/docs/types/MemberType.html +2 -2
  314. package/docs/types/MultiGetVaultBalancesParams.html +2 -2
  315. package/docs/types/NaviInvestor.html +2 -2
  316. package/docs/types/ObjectTable.html +1 -0
  317. package/docs/types/OtherReceiptFields.html +2 -2
  318. package/docs/types/PoolName.html +1 -1
  319. package/docs/types/PoolReceipt.html +1 -1
  320. package/docs/types/PoolType.html +2 -2
  321. package/docs/types/Receipt.html +2 -2
  322. package/docs/types/ReceiptGQL.html +2 -2
  323. package/docs/types/SingleAssetMultiVaultBalance.html +2 -2
  324. package/docs/types/SingleAssetPoolNames.html +1 -1
  325. package/docs/types/SingleAssetTokenHoldings.html +2 -2
  326. package/docs/types/SingleAssetVaultBalance.html +2 -2
  327. package/docs/types/SingleGetVaultBalancesParams.html +2 -2
  328. package/docs/types/StrategyType.html +1 -1
  329. package/docs/types/SuiNetwork.html +1 -1
  330. package/docs/types/SwapOptions.html +1 -1
  331. package/docs/types/TickSpacing.html +1 -1
  332. package/docs/types/TotalWeightType.html +2 -2
  333. package/docs/types/TransactionBlockType.html +2 -2
  334. package/docs/types/UserPoolLiquidity.html +2 -2
  335. package/docs/types/UserPoolTokenHoldings.html +1 -1
  336. package/docs/types/UserUsdHoldings.html +2 -2
  337. package/docs/types/VaultBalance.html +1 -1
  338. package/docs/types/VecMap.html +3 -0
  339. package/docs/types/VoteCastEvent.html +1 -1
  340. package/docs/types/WithdrawV2EventNode.html +1 -1
  341. package/docs/variables/AUTOBALANCE_SUI_FIRST_POOLS.html +1 -1
  342. package/docs/variables/AUTOBALANCE_SUI_SECOND_POOLS.html +1 -1
  343. package/docs/variables/AUTOBALANCE_TYPE_1_POOLS.html +1 -1
  344. package/docs/variables/alphalendMarketIdMap.html +1 -1
  345. package/docs/variables/bluefinPoolMap.html +1 -1
  346. package/docs/variables/cetusPoolMap.html +1 -1
  347. package/docs/variables/coinsList.html +1 -1
  348. package/docs/variables/defunctPoolsSet.html +1 -1
  349. package/docs/variables/doubleAssetPoolCoinMap.html +1 -1
  350. package/docs/variables/eventCategories.html +1 -1
  351. package/docs/variables/ignoredWalletsForDailyRevenue.html +1 -1
  352. package/docs/variables/loopingAccountAddresses.html +1 -1
  353. package/docs/variables/loopingPoolCoinMap.html +1 -1
  354. package/docs/variables/naviAssetMap.html +1 -1
  355. package/docs/variables/poolIdPoolNameMap.html +1 -1
  356. package/docs/variables/poolInfo.html +1 -1
  357. package/docs/variables/singleAssetPoolCoinMap.html +1 -1
  358. package/docs/variables/stableCoins.html +1 -1
  359. package/package.json +2 -1
package/#package.json# ADDED
@@ -0,0 +1,98 @@
1
+ {
2
+ "name": "@alphafi/alphafi-sdk",
3
+ "version": "0.0.92",
4
+ "description": "Official AlphaFi SDK to access AlphaFi data",
5
+ "type": "module",
6
+ "main": "dist/cjs/index.js",
7
+ "module": "dist/esm/index.js",
8
+ "types": "dist/cjs/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/esm/index.js",
12
+ "require": "./dist/cjs/index.js"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "prebuild": "npm run pretty && npm run lint",
17
+ "build": "npm run build:cjs && npm run build:esm",
18
+ "build:esm": "tsc --project tsconfig.esm.json && echo '{\"type\":\"module\"}' > dist/esm/package.json",
19
+ "build:cjs": "tsc --project tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
20
+ "pretty": "prettier . --write",
21
+ "lint": "eslint 'src/**/*.ts' --fix",
22
+ "cpx": "cpx 'src/**/*.graphql' dist/cjs && cpx 'src/**/*.graphql' dist/esm",
23
+ "prettier": "prettier --write 'src/**/*.ts'",
24
+ "gen": "node embed-graphql.js",
25
+ "docs": "typedoc",
26
+ "test:esm": "jest --config jest.config.esm.js",
27
+ "test:cjs": "jest --config jest.config.cjs.js",
28
+ "test": "npm run test:esm && npm run test:cjs",
29
+ "prepublish": "npm run docs"
30
+ },
31
+ "keywords": [],
32
+ "author": "AlphaFi",
33
+ "license": "ISC",
34
+ "devDependencies": {
35
+ "@babel/cli": "^7.24.8",
36
+ "@babel/core": "^7.25.2",
37
+ "@babel/preset-env": "^7.25.3",
38
+ "@babel/preset-typescript": "^7.24.7",
39
+ "@types/bn.js": "^5.1.5",
40
+ "@types/jest": "^30.0.0",
41
+ "@types/node": "^24.3.1",
42
+ "@typescript-eslint/eslint-plugin": "^8.43.0",
43
+ "@typescript-eslint/parser": "^8.43.0",
44
+ "babel-loader": "^10.0.0",
45
+ "clean-webpack-plugin": "^4.0.0",
46
+ "cpx": "^1.5.0",
47
+ "eslint": "^9.35.0",
48
+ "eslint-config-prettier": "^10.1.8",
49
+ "eslint-plugin-import": "^2.29.1",
50
+ "eslint-plugin-prettier": "^5.2.1",
51
+ "globals": "^16.4.0",
52
+ "jest": "^30.1.3",
53
+ "prettier": "^3.3.2",
54
+ "source-map-loader": "^5.0.0",
55
+ "ts-jest": "^29.2.1",
56
+ "ts-loader": "^9.5.1",
57
+ "ts-node": "^10.9.2",
58
+ "typedoc": "^0.28.12",
59
+ "typescript": "^5.9.2",
60
+ "webpack": "^5.92.1",
61
+ "webpack-cli": "^6.0.1"
62
+ },
63
+ "dependencies": {
64
+ "@7kprotocol/sdk-ts": "^3.4.1",
65
+ "@alphafi/alphalend-sdk": "^1.1.16",
66
+ "@apollo/client": "^4.0.4",
67
+ "@cetusprotocol/cetus-sui-clmm-sdk": "^5.4.0",
68
+ "@hop.ag/sdk": "^4.0.17",
69
+ "bignumber.js": "^9.1.2",
70
+ "bn.js": "^5.2.1",
71
+ "decimal.js": "^10.4.3",
72
+ "graphql": "^16.9.0",
73
+ "navi-sdk": "^1.6.2",
74
+ "react": "^19.1.1"
75
+ },
76
+ "peerDependencies": {
77
+ "@alphafi/stsui-sdk": "^0.0.22",
78
+ "@mysten/sui": "^1.30.0"
79
+ },
80
+ "overrides": {
81
+ "ansi-regex": "^6.0.1",
82
+ "strip-ansi": "^7.1.2",
83
+ "glob-parent": "^6.0.2",
84
+ "braces": "^3.0.3",
85
+ "minimist": "^1.2.8",
86
+ "word-wrap": "^1.2.5",
87
+ "postcss": "^8.4.47",
88
+ "nth-check": "^2.1.1",
89
+ "tough-cookie": "^4.1.3",
90
+ "json5": "^2.2.3",
91
+ "decode-uri-component": "^0.2.2",
92
+ "ws": "^8.18.3",
93
+ "esbuild": ">=0.24.3",
94
+ "vite": ">=6.1.7",
95
+ "vite-node": ">=2.2.1",
96
+ "vitest": ">=2.2.1"
97
+ }
98
+ }
@@ -0,0 +1,222 @@
1
+ # Global Fetch Override Issue - Analysis & Solutions
2
+
3
+ ## Problem Summary
4
+
5
+ The `get_navi_rewards.ts` file overrides `globalThis.fetch` to add NAVI-specific headers when calling the `@naviprotocol/lending` library. This creates a critical race condition where:
6
+
7
+ 1. During the async execution of `getUserAvailableLendingRewards()`, `globalThis.fetch` is overridden
8
+ 2. ANY fetch calls from the consuming application during this window will use the wrapped version
9
+ 3. The wrapped version may not properly handle all request types, causing CORS errors and production failures
10
+
11
+ ### Call Chain Leading to Override
12
+
13
+ ```
14
+ User App → pendingRewardAmount()
15
+ → getReceipts()
16
+ → getMultiReceipts()
17
+ → (on GraphQL failure) loops through ALL pools
18
+ → getAvailableRewards() for NAVI pools
19
+ → OVERRIDES globalThis.fetch
20
+ ```
21
+
22
+ ## Implemented Solution: Mutex-Based Coordination
23
+
24
+ **Status**: ✅ Implemented in current commit
25
+
26
+ The current implementation uses a `FetchMutex` class to ensure only one SDK function can override `globalThis.fetch` at a time. This prevents concurrent SDK calls from interfering with each other.
27
+
28
+ ### Benefits:
29
+
30
+ - Prevents multiple SDK functions from racing to override fetch
31
+ - Queues SDK calls that need fetch override
32
+ - More predictable behavior than previous version
33
+
34
+ ### Limitations:
35
+
36
+ - Still overrides `globalThis.fetch` temporarily (~100-500ms per call)
37
+ - Consuming application's fetch calls during this window may still be affected
38
+ - Performance cost due to sequential execution of NAVI reward queries
39
+
40
+ ## Alternative Solutions
41
+
42
+ ### Option A: Direct API Call (RECOMMENDED)
43
+
44
+ Instead of using `@naviprotocol/lending`'s `getUserAvailableLendingRewards()`, make the API call directly with proper headers:
45
+
46
+ ```typescript
47
+ export async function getAvailableRewards(address: string) {
48
+ const response = await fetch("https://api.naviprotocol.io/lending/rewards", {
49
+ method: "POST", // or GET - verify NAVI's API
50
+ headers: {
51
+ "Content-Type": "application/json",
52
+ Host: "app.naviprotocol.io",
53
+ "User-Agent":
54
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
55
+ Referer: "https://app.naviprotocol.io/",
56
+ Origin: "app.naviprotocol.io",
57
+ },
58
+ body: JSON.stringify({ address }),
59
+ });
60
+
61
+ const rewards = await response.json();
62
+
63
+ // Convert to expected format
64
+ const rewardsByAsset: Record<string, any[]> = {};
65
+ // ... rest of transformation logic
66
+
67
+ return rewardsByAsset;
68
+ }
69
+ ```
70
+
71
+ **Benefits:**
72
+
73
+ - No global override at all
74
+ - No race conditions
75
+ - Better performance (no mutex queuing)
76
+ - Full control over request/response handling
77
+
78
+ **Drawbacks:**
79
+
80
+ - Need to reverse-engineer NAVI's API endpoint and format
81
+ - May break if NAVI changes their API
82
+ - Need to maintain API call logic ourselves
83
+
84
+ ### Option B: Proxy/Interceptor Pattern
85
+
86
+ Create a transparent fetch proxy that intercepts requests at a lower level:
87
+
88
+ ```typescript
89
+ class FetchProxy {
90
+ private static instance: FetchProxy;
91
+ private originalFetch: typeof fetch;
92
+ private interceptors: Array<(req: Request) => Request> = [];
93
+
94
+ private constructor() {
95
+ this.originalFetch = globalThis.fetch;
96
+ this.install();
97
+ }
98
+
99
+ private install() {
100
+ globalThis.fetch = this.proxyFetch.bind(this);
101
+ }
102
+
103
+ private async proxyFetch(
104
+ input: RequestInfo | URL,
105
+ init?: RequestInit,
106
+ ): Promise<Response> {
107
+ // Check all registered interceptors
108
+ // Only modify if interceptor matches
109
+ // Otherwise pass through unchanged
110
+ }
111
+
112
+ static registerInterceptor(
113
+ matcher: (url: string) => boolean,
114
+ modifier: (init: RequestInit) => RequestInit,
115
+ ) {
116
+ // Register NAVI-specific interceptor
117
+ }
118
+ }
119
+
120
+ // In SDK initialization
121
+ FetchProxy.registerInterceptor(
122
+ (url) => /\.naviprotocol\.io$/i.test(new URL(url).hostname),
123
+ (init) => ({ ...init, headers: { ...init.headers, ...naviHeaders } }),
124
+ );
125
+ ```
126
+
127
+ **Benefits:**
128
+
129
+ - Single global override at SDK initialization
130
+ - All SDK calls benefit from interceptor
131
+ - Consuming app can also register interceptors
132
+ - Transparent to NAVI library
133
+
134
+ **Drawbacks:**
135
+
136
+ - Complex implementation
137
+ - SDK now "owns" the fetch API
138
+ - May conflict with other libraries that also override fetch
139
+ - Harder to debug
140
+
141
+ ### Option C: AsyncLocalStorage (Node.js only)
142
+
143
+ Use Node.js's `AsyncLocalStorage` to maintain per-context fetch implementations:
144
+
145
+ ```typescript
146
+ import { AsyncLocalStorage } from "async_hooks";
147
+
148
+ const fetchContext = new AsyncLocalStorage<typeof fetch>();
149
+
150
+ export async function getAvailableRewards(address: string) {
151
+ const naviFetch = createNaviFetch();
152
+
153
+ return fetchContext.run(naviFetch, async () => {
154
+ // Within this context, use naviFetch
155
+ const rewards = await getUserAvailableLendingRewards(address);
156
+ // ... process rewards
157
+ });
158
+ }
159
+
160
+ // Modify @naviprotocol/lending to use contextual fetch
161
+ // (requires patching or proposing upstream changes)
162
+ ```
163
+
164
+ **Benefits:**
165
+
166
+ - True context isolation
167
+ - No race conditions
168
+ - No global overrides
169
+
170
+ **Drawbacks:**
171
+
172
+ - Node.js only (not browser compatible)
173
+ - Requires patching NAVI library or convincing them to use context
174
+ - Complex setup
175
+
176
+ ## Recommendations
177
+
178
+ ### Short-term (Current Implementation)
179
+
180
+ ✅ **Use the mutex-based solution** to prevent SDK-internal race conditions. This is already implemented and provides immediate improvement.
181
+
182
+ ### Mid-term (Next Release)
183
+
184
+ 🎯 **Implement Option A (Direct API Call)** if feasible:
185
+
186
+ 1. Research NAVI's rewards API endpoint and format
187
+ 2. Implement direct API call with proper headers
188
+ 3. Remove dependency on `@naviprotocol/lending` for this function
189
+ 4. Thoroughly test against NAVI's production API
190
+
191
+ ### Long-term (Future Enhancement)
192
+
193
+ 🚀 **Consider Option B (Proxy Pattern)** if multiple protocols require similar header manipulation:
194
+
195
+ 1. Design a flexible interceptor architecture
196
+ 2. Allow consuming apps to opt-in to interceptor usage
197
+ 3. Document clearly in README
198
+ 4. Provide escape hatch to disable if conflicts occur
199
+
200
+ ## Testing Recommendations
201
+
202
+ 1. **Concurrent Load Test**: Call `pendingRewardAmount()` for multiple pools simultaneously while making unrelated fetch calls
203
+ 2. **CORS Verification**: Ensure non-NAVI requests maintain proper CORS headers
204
+ 3. **GraphQL POST Test**: Specifically test GraphQL POST requests during NAVI reward queries
205
+ 4. **Error Handling**: Test behavior when NAVI API is down or returns errors
206
+
207
+ ## Migration Guide for Consuming Applications
208
+
209
+ If your application experiences fetch-related issues with v0.0.98+:
210
+
211
+ 1. **Upgrade to latest version** with mutex fix (this version)
212
+ 2. **Minimize concurrent calls**: Batch reward queries where possible
213
+ 3. **Add retry logic**: Wrap SDK calls in retry logic for transient failures
214
+ 4. **Monitor**: Add logging around SDK calls to identify patterns
215
+ 5. **Report issues**: If problems persist, provide reproduction case to SDK maintainers
216
+
217
+ ## Version History
218
+
219
+ - **v0.0.92**: No fetch override (user's fallback version)
220
+ - **v0.0.98**: Introduced fetch override with race conditions
221
+ - **v0.0.99** (this version): Added mutex to coordinate overrides
222
+ - **v0.1.0** (planned): Remove fetch override entirely (Option A or B)
@@ -7,4 +7,12 @@ export declare function getPriceToTick(poolName: PoolName, price: string, tickSp
7
7
  export declare function getTickSpacing(poolName: PoolName): Promise<number>;
8
8
  export declare const setWeights: (poolIdNames: string[], weightsString: string[], setWeightCoinType: CoinName, address: string) => Promise<Transaction>;
9
9
  export declare function getPoolsWeightDistribution(coinTypetoSetWeight: CoinName, ignoreCache: boolean): Promise<PoolWeightDistribution>;
10
+ export declare function processWithdrawRequestsManual(amount: string, address: string): Promise<Transaction>;
11
+ export declare function collectUnsuppliedBalance(): Promise<Transaction>;
12
+ export declare function getWithdrawRequestAndUnsuppliedAmounts(): Promise<{
13
+ withdrawRequestAmount: string;
14
+ unsuppliedAmount: string;
15
+ settleRequestTime: string;
16
+ }>;
17
+ export declare function addAirdropCoin(amount: string, address: string): Promise<Transaction>;
10
18
  //# sourceMappingURL=adminFunctions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"adminFunctions.d.ts","sourceRoot":"","sources":["../../src/adminFunctions.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,QAAQ,EAC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Ae,UAiBzB;AAED,wBAAsB,cAAc,CAAC,QAAQ,EAAE,QAAQ,mBAUtD;AAED,eAAO,MAAM,UAAU,GACrB,aAAa,MAAM,EAAE,EACrB,eAAe,MAAM,EAAE,EACvB,mBAAmB,QAAQ,EAC3B,SAAS,MAAM,yBA+ChB,CAAC;AAEF,wBAAsB,0BAA0B,CAC9C,mBAAmB,EAAE,QAAQ,EAC7B,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,sBAAsB,CAAC,CAmFjC;AAED,wBAAsB,6BAA6B,CACjD,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,WAAW,CAAC,CAsBtB;AAED,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,WAAW,CAAC,CAiBrE;AACD,wBAAsB,sCAAsC,IAAI,OAAO,CAAC;IACtE,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC,CA2BD;AACD,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,WAAW,CAAC,CAwBtB"}
@@ -7,6 +7,10 @@ exports.getTickToPrice = getTickToPrice;
7
7
  exports.getPriceToTick = getPriceToTick;
8
8
  exports.getTickSpacing = getTickSpacing;
9
9
  exports.getPoolsWeightDistribution = getPoolsWeightDistribution;
10
+ exports.processWithdrawRequestsManual = processWithdrawRequestsManual;
11
+ exports.collectUnsuppliedBalance = collectUnsuppliedBalance;
12
+ exports.getWithdrawRequestAndUnsuppliedAmounts = getWithdrawRequestAndUnsuppliedAmounts;
13
+ exports.addAirdropCoin = addAirdropCoin;
10
14
  const tslib_1 = require("tslib");
11
15
  const cetus_sui_clmm_sdk_1 = require("@cetusprotocol/cetus-sui-clmm-sdk");
12
16
  const getReceipts_js_1 = require("./sui-sdk/functions/getReceipts.js");
@@ -17,6 +21,8 @@ const decimal_js_1 = require("decimal.js");
17
21
  const transactions_1 = require("@mysten/sui/transactions");
18
22
  const constants_js_1 = require("./common/constants.js");
19
23
  const index_js_1 = require("./index.js");
24
+ const bluefin_js_1 = require("./transactions/bluefin.js");
25
+ const ALPHA_KEEPER_POOL_ID = "0x1fef238763e8afa3180b0d6a74abecc94feeca2a92f671e881de034ae74c4a4f";
20
26
  async function getCurrentTick(poolName) {
21
27
  const parentPool = await (0, getReceipts_js_1.getParentPool)(poolName, false);
22
28
  const current_sqrt_price = parentPool.content.fields.current_sqrt_price;
@@ -73,7 +79,7 @@ const setWeights = async (poolIdNames, weightsString, setWeightCoinType, address
73
79
  const txb = new transactions_1.Transaction();
74
80
  poolIdNames.forEach((poolName) => {
75
81
  if (poolName === "ALPHA-KEEPER") {
76
- poolIds.push("0x5a9fac4148605191b8e0de25a6671ba8008c344c1558bbaac73a947bd6c903b1");
82
+ poolIds.push(ALPHA_KEEPER_POOL_ID);
77
83
  }
78
84
  else {
79
85
  poolIds.push(maps_js_1.poolInfo[poolName].poolId);
@@ -132,8 +138,7 @@ async function getPoolsWeightDistribution(coinTypetoSetWeight, ignoreCache) {
132
138
  for (const member of members) {
133
139
  const poolId = member.fields.key;
134
140
  const poolName = poolIdmap[poolId];
135
- if (poolId ===
136
- "0x5a9fac4148605191b8e0de25a6671ba8008c344c1558bbaac73a947bd6c903b1") {
141
+ if (poolId === ALPHA_KEEPER_POOL_ID) {
137
142
  let weight = 0;
138
143
  if (member.fields.value.fields) {
139
144
  const poolData = member.fields.value.fields.pool_data.fields.contents;
@@ -183,4 +188,93 @@ async function getPoolsWeightDistribution(coinTypetoSetWeight, ignoreCache) {
183
188
  coinType: coinTypetoSetWeight,
184
189
  };
185
190
  }
191
+ // alpha vault functions
192
+ async function processWithdrawRequestsManual(amount, address) {
193
+ const txb = new transactions_1.Transaction();
194
+ const poolName = "ALPHA";
195
+ const pool = maps_js_1.poolInfo[poolName];
196
+ const coin1 = index_js_1.singleAssetPoolCoinMap[poolName].coin;
197
+ const typeT = coins_js_1.coinsList[coin1].type;
198
+ let coin = await (0, bluefin_js_1.getCoinObject)(typeT, address, txb);
199
+ if (!coin) {
200
+ throw new Error("no coin available");
201
+ }
202
+ let finalCoin = txb.splitCoins(coin, [amount]);
203
+ txb.transferObjects([coin], address);
204
+ txb.moveCall({
205
+ target: `${pool.packageId}::interface::process_withdraw_requests_manual`,
206
+ typeArguments: [typeT],
207
+ arguments: [
208
+ txb.object((0, constants_js_1.getConf)().ALPHA_EMBER_VERSION),
209
+ txb.object(pool.poolId),
210
+ txb.object(finalCoin),
211
+ ],
212
+ });
213
+ return txb;
214
+ }
215
+ async function collectUnsuppliedBalance() {
216
+ const txb = new transactions_1.Transaction();
217
+ const poolName = "ALPHA";
218
+ const pool = maps_js_1.poolInfo[poolName];
219
+ const coin1 = index_js_1.singleAssetPoolCoinMap[poolName].coin;
220
+ const typeT = coins_js_1.coinsList[coin1].type;
221
+ txb.moveCall({
222
+ target: `${pool.packageId}::interface::collect_unsupplied_balance`,
223
+ typeArguments: [typeT],
224
+ arguments: [
225
+ txb.object((0, constants_js_1.getConf)().ALPHA_EMBER_VERSION),
226
+ txb.object(pool.poolId),
227
+ ],
228
+ });
229
+ return txb;
230
+ }
231
+ async function getWithdrawRequestAndUnsuppliedAmounts() {
232
+ const poolName = "ALPHA";
233
+ const poolId = maps_js_1.poolInfo[poolName].poolId;
234
+ const pool = await (0, index_js_1.getSuiClient)().getObject({
235
+ id: poolId,
236
+ options: {
237
+ showContent: true,
238
+ },
239
+ });
240
+ if (!pool.data || !pool.data.content) {
241
+ throw new Error("Pool data not found");
242
+ }
243
+ const unsuppliedAmount = pool.data.content.fields.unsupplied_balance.toString();
244
+ let settleRequestTime = "";
245
+ const withdrawRequests = pool.data.content.fields.withdraw_requests
246
+ .fields.contents;
247
+ let withdrawRequestAmount = "0";
248
+ if (withdrawRequests[0]) {
249
+ withdrawRequestAmount =
250
+ withdrawRequests[0].fields.value.fields.leftover_amount.toString();
251
+ settleRequestTime = withdrawRequests[0].fields.key.toString();
252
+ }
253
+ return { withdrawRequestAmount, unsuppliedAmount, settleRequestTime };
254
+ }
255
+ async function addAirdropCoin(amount, address) {
256
+ const txb = new transactions_1.Transaction();
257
+ const poolName = "ALPHA";
258
+ const pool = maps_js_1.poolInfo[poolName];
259
+ const coin1 = index_js_1.singleAssetPoolCoinMap[poolName].coin;
260
+ const coin2 = "SUI";
261
+ const typeT = coins_js_1.coinsList[coin1].type;
262
+ const typeR = coins_js_1.coinsList[coin2].type;
263
+ let coin = await (0, bluefin_js_1.getCoinObject)(typeR, address, txb);
264
+ if (!coin) {
265
+ throw new Error("no coin available");
266
+ }
267
+ let finalCoin = txb.splitCoins(coin, [amount]);
268
+ txb.transferObjects([coin], address);
269
+ txb.moveCall({
270
+ target: `${pool.packageId}::interface::add_airdrop_coin`,
271
+ typeArguments: [typeT, typeR],
272
+ arguments: [
273
+ txb.object((0, constants_js_1.getConf)().ALPHA_EMBER_VERSION),
274
+ txb.object(pool.poolId),
275
+ txb.object(finalCoin),
276
+ ],
277
+ });
278
+ return txb;
279
+ }
186
280
  //# sourceMappingURL=adminFunctions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"adminFunctions.js","sourceRoot":"","sources":["../../src/adminFunctions.ts"],"names":[],"mappings":";;;AA8BA,wCAKC;AAED,4CAaC;AAED,wCASC;AAED,wCAqBC;AAED,wCAUC;AAyDD,gEAyFC;;AAlPD,0EAA6D;AAa7D,uEAI4C;AAC5C,0DAAuB;AACvB,gDAA8C;AAC9C,8CAI0B;AAC1B,2CAAqC;AACrC,2DAAuD;AACvD,wDAAuD;AACvD,yCAA0C;AAEnC,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,6BA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n CommonInvestorFields,\n MemberType,\n PoolName,\n CoinName,\n PoolWeightDistribution,\n PoolData,\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\";\nimport { Transaction } from \"@mysten/sui/transactions\";\nimport { conf, CONF_ENV } from \"./common/constants.js\";\nimport { getSuiClient } from \"./index.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;\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, upperTick];\n}\n\nexport function getTickToPrice(poolName: PoolName, tick: number) {\n const coinAName = doubleAssetPoolCoinMap[poolName].coin1;\n const coinBName = doubleAssetPoolCoinMap[poolName].coin2;\n const price = TickMath.tickIndexToPrice(\n tick,\n coinsList[coinAName].expo,\n coinsList[coinBName].expo,\n );\n return price.toString();\n}\n\nexport function getPriceToTick(\n poolName: PoolName,\n price: string,\n tickSpacing: number,\n isUpper: boolean = false,\n) {\n const coinAName = doubleAssetPoolCoinMap[poolName].coin1;\n const coinBName = doubleAssetPoolCoinMap[poolName].coin2;\n let tick = TickMath.priceToTickIndex(\n new Decimal(price),\n coinsList[coinAName].expo,\n coinsList[coinBName].expo,\n );\n if (tick % tickSpacing) {\n if (isUpper === tick > 0) {\n tick = tick + tickSpacing - (tick % tickSpacing);\n } else {\n tick = tick - (tick % tickSpacing);\n }\n }\n return tick;\n}\n\nexport async function getTickSpacing(poolName: PoolName) {\n const parentPool = await getParentPool(poolName, false);\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 return tickSpacing;\n}\n\nexport const setWeights = async (\n poolIdNames: string[],\n weightsString: string[],\n setWeightCoinType: CoinName,\n address: string,\n) => {\n const poolIds: string[] = [];\n const txb = new Transaction();\n poolIdNames.forEach((poolName) => {\n if (poolName === \"ALPHA-KEEPER\") {\n poolIds.push(\n \"0x5a9fac4148605191b8e0de25a6671ba8008c344c1558bbaac73a947bd6c903b1\",\n );\n } else {\n poolIds.push(poolInfo[poolName].poolId);\n }\n });\n const adminCap = await getSuiClient().getOwnedObjects({\n owner: address,\n filter: {\n StructType:\n \"0x9bbd650b8442abb082c20f3bc95a9434a8d47b4bef98b0832dab57c1a8ba7123::distributor::AdminCap\",\n },\n options: {\n showContent: true,\n },\n });\n\n if (!adminCap.data || adminCap.data.length === 0) {\n throw new Error(\"No adminCap data found.\");\n }\n\n if (!adminCap.data[0].data) {\n throw new Error(\"adminCap.data[0].data is undefined.\");\n }\n\n const objectId = adminCap.data[0].data.objectId;\n txb.moveCall({\n target: `${conf[CONF_ENV].ALPHA_LATEST_PACKAGE_ID}::distributor::set_weights`,\n typeArguments: [coinsList[setWeightCoinType].type],\n arguments: [\n txb.object(objectId),\n txb.object(conf[CONF_ENV].ALPHA_DISTRIBUTOR),\n txb.object(conf[CONF_ENV].VERSION),\n txb.pure.vector(\"id\", poolIds),\n txb.pure.vector(\"u64\", weightsString),\n txb.object(conf[CONF_ENV].CLOCK_PACKAGE_ID),\n ],\n });\n\n // executeTransactionBlock(txb);\n // dryRunTransactionBlock(txb);\n return txb;\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 (\n poolId ===\n \"0x5a9fac4148605191b8e0de25a6671ba8008c344c1558bbaac73a947bd6c903b1\"\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 imageUrl1: undefined,\n imageUrl2: undefined,\n lockIcon: undefined,\n poolName: \"ALPHA-KEEPER\",\n });\n continue;\n }\n\n if (!poolInfo[poolName]) {\n continue;\n }\n const imageUrl1 = poolInfo[poolName].imageUrl1;\n const imageUrl2 = poolInfo[poolName].imageUrl2;\n const lockIcon = poolInfo[poolName].lockIcon;\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 imageUrl1: imageUrl1,\n imageUrl2: imageUrl2,\n lockIcon: lockIcon,\n poolName: poolName,\n });\n }\n return {\n data: poolDataArray,\n totalWeight: totalWeight,\n coinType: coinTypetoSetWeight,\n };\n}\n"]}
1
+ {"version":3,"file":"adminFunctions.js","sourceRoot":"","sources":["../../src/adminFunctions.ts"],"names":[],"mappings":";;;AAkCA,wCAKC;AAED,4CAaC;AAED,wCASC;AAED,wCAqBC;AAED,wCAUC;AAuDD,gEAsFC;AAED,sEAyBC;AAED,4DAiBC;AACD,wFA+BC;AACD,wCA2BC;;AA3VD,0EAA6D;AAa7D,uEAI4C;AAC5C,0DAAuB;AACvB,gDAA8C;AAC9C,8CAI0B;AAC1B,2CAAqC;AACrC,2DAAuD;AACvD,wDAAgE;AAChE,yCAAkE;AAClE,0DAA0D;AAE1D,MAAM,oBAAoB,GACxB,oEAAoE,CAAC;AAEhE,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;AACd,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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ChC,MAAM,KAAK,GAAG,iCAAsB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC;IACpD,MAAM,KAAK,GAAG,KAAK,CAAC;IACpB,MAAM,KAAK,GAAG,oBAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;IACpC,MAAM,KAAK,GAAG,oBAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;IACpC,IAAI,IAAI,GAAG,MAAM,IAAA,0BAAa,EAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IACpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACvC,CAAC;IACD,IAAI,SAAS,GAAG,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC;IACrC,GAAG,CAAC,QAAQ,CAAC;QACX,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,+BAA+B;QACxD,aAAa,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;QAC7B,SAAS,EAAE;YACT,GAAG,CAAC,MAAM,CAAC,IAAA,sBAAO,GAAE,CAAC,mBAAmB,CAAC;YACzC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;YACvB,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC;SACtB;KACF,CAAC,CAAC;IACH,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { TickMath } from \"@cetusprotocol/cetus-sui-clmm-sdk\";\nimport {\n Allocator,\n BluefinPoolType,\n CetusInvestor,\n CetusPoolType,\n CommonInvestorFields,\n MemberType,\n PoolName,\n CoinName,\n PoolWeightDistribution,\n PoolData,\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\";\nimport { Transaction } from \"@mysten/sui/transactions\";\nimport { conf, CONF_ENV, getConf } from \"./common/constants.js\";\nimport { getSuiClient, singleAssetPoolCoinMap } from \"./index.js\";\nimport { getCoinObject } from \"./transactions/bluefin.js\";\n\nconst ALPHA_KEEPER_POOL_ID =\n \"0x1fef238763e8afa3180b0d6a74abecc94feeca2a92f671e881de034ae74c4a4f\";\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;\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, upperTick];\n}\n\nexport function getTickToPrice(poolName: PoolName, tick: number) {\n const coinAName = doubleAssetPoolCoinMap[poolName].coin1;\n const coinBName = doubleAssetPoolCoinMap[poolName].coin2;\n const price = TickMath.tickIndexToPrice(\n tick,\n coinsList[coinAName].expo,\n coinsList[coinBName].expo,\n );\n return price.toString();\n}\n\nexport function getPriceToTick(\n poolName: PoolName,\n price: string,\n tickSpacing: number,\n isUpper: boolean = false,\n) {\n const coinAName = doubleAssetPoolCoinMap[poolName].coin1;\n const coinBName = doubleAssetPoolCoinMap[poolName].coin2;\n let tick = TickMath.priceToTickIndex(\n new Decimal(price),\n coinsList[coinAName].expo,\n coinsList[coinBName].expo,\n );\n if (tick % tickSpacing) {\n if (isUpper === tick > 0) {\n tick = tick + tickSpacing - (tick % tickSpacing);\n } else {\n tick = tick - (tick % tickSpacing);\n }\n }\n return tick;\n}\n\nexport async function getTickSpacing(poolName: PoolName) {\n const parentPool = await getParentPool(poolName, false);\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 return tickSpacing;\n}\n\nexport const setWeights = async (\n poolIdNames: string[],\n weightsString: string[],\n setWeightCoinType: CoinName,\n address: string,\n) => {\n const poolIds: string[] = [];\n const txb = new Transaction();\n poolIdNames.forEach((poolName) => {\n if (poolName === \"ALPHA-KEEPER\") {\n poolIds.push(ALPHA_KEEPER_POOL_ID);\n } else {\n poolIds.push(poolInfo[poolName].poolId);\n }\n });\n const adminCap = await getSuiClient().getOwnedObjects({\n owner: address,\n filter: {\n StructType:\n \"0x9bbd650b8442abb082c20f3bc95a9434a8d47b4bef98b0832dab57c1a8ba7123::distributor::AdminCap\",\n },\n options: {\n showContent: true,\n },\n });\n\n if (!adminCap.data || adminCap.data.length === 0) {\n throw new Error(\"No adminCap data found.\");\n }\n\n if (!adminCap.data[0].data) {\n throw new Error(\"adminCap.data[0].data is undefined.\");\n }\n\n const objectId = adminCap.data[0].data.objectId;\n txb.moveCall({\n target: `${conf[CONF_ENV].ALPHA_LATEST_PACKAGE_ID}::distributor::set_weights`,\n typeArguments: [coinsList[setWeightCoinType].type],\n arguments: [\n txb.object(objectId),\n txb.object(conf[CONF_ENV].ALPHA_DISTRIBUTOR),\n txb.object(conf[CONF_ENV].VERSION),\n txb.pure.vector(\"id\", poolIds),\n txb.pure.vector(\"u64\", weightsString),\n txb.object(conf[CONF_ENV].CLOCK_PACKAGE_ID),\n ],\n });\n\n // executeTransactionBlock(txb);\n // dryRunTransactionBlock(txb);\n return txb;\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 (poolId === ALPHA_KEEPER_POOL_ID) {\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 imageUrl1: undefined,\n imageUrl2: undefined,\n lockIcon: undefined,\n poolName: \"ALPHA-KEEPER\",\n });\n continue;\n }\n\n if (!poolInfo[poolName]) {\n continue;\n }\n const imageUrl1 = poolInfo[poolName].imageUrl1;\n const imageUrl2 = poolInfo[poolName].imageUrl2;\n const lockIcon = poolInfo[poolName].lockIcon;\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 imageUrl1: imageUrl1,\n imageUrl2: imageUrl2,\n lockIcon: lockIcon,\n poolName: poolName,\n });\n }\n return {\n data: poolDataArray,\n totalWeight: totalWeight,\n coinType: coinTypetoSetWeight,\n };\n}\n// alpha vault functions\nexport async function processWithdrawRequestsManual(\n amount: string,\n address: string,\n): Promise<Transaction> {\n const txb = new Transaction();\n const poolName = \"ALPHA\" as PoolName;\n const pool = poolInfo[poolName];\n const coin1 = singleAssetPoolCoinMap[poolName].coin;\n const typeT = coinsList[coin1].type;\n let coin = await getCoinObject(typeT, address, txb);\n if (!coin) {\n throw new Error(\"no coin available\");\n }\n let finalCoin = txb.splitCoins(coin, [amount]);\n txb.transferObjects([coin], address);\n txb.moveCall({\n target: `${pool.packageId}::interface::process_withdraw_requests_manual`,\n typeArguments: [typeT],\n arguments: [\n txb.object(getConf().ALPHA_EMBER_VERSION),\n txb.object(pool.poolId),\n txb.object(finalCoin),\n ],\n });\n return txb;\n}\n\nexport async function collectUnsuppliedBalance(): Promise<Transaction> {\n const txb = new Transaction();\n const poolName = \"ALPHA\" as PoolName;\n const pool = poolInfo[poolName];\n const coin1 = singleAssetPoolCoinMap[poolName].coin;\n const typeT = coinsList[coin1].type;\n\n txb.moveCall({\n target: `${pool.packageId}::interface::collect_unsupplied_balance`,\n typeArguments: [typeT],\n arguments: [\n txb.object(getConf().ALPHA_EMBER_VERSION),\n txb.object(pool.poolId),\n ],\n });\n\n return txb;\n}\nexport async function getWithdrawRequestAndUnsuppliedAmounts(): Promise<{\n withdrawRequestAmount: string;\n unsuppliedAmount: string;\n settleRequestTime: string;\n}> {\n const poolName = \"ALPHA\" as PoolName;\n const poolId = poolInfo[poolName].poolId;\n const pool = await getSuiClient().getObject({\n id: poolId,\n options: {\n showContent: true,\n },\n });\n if (!pool.data || !pool.data.content) {\n throw new Error(\"Pool data not found\");\n }\n\n const unsuppliedAmount = (\n pool.data.content as any\n ).fields.unsupplied_balance.toString();\n let settleRequestTime = \"\";\n const withdrawRequests = (pool.data.content as any).fields.withdraw_requests\n .fields.contents;\n let withdrawRequestAmount = \"0\";\n if (withdrawRequests[0]) {\n withdrawRequestAmount =\n withdrawRequests[0].fields.value.fields.leftover_amount.toString();\n settleRequestTime = withdrawRequests[0].fields.key.toString();\n }\n\n return { withdrawRequestAmount, unsuppliedAmount, settleRequestTime };\n}\nexport async function addAirdropCoin(\n amount: string,\n address: string,\n): Promise<Transaction> {\n const txb = new Transaction();\n const poolName = \"ALPHA\" as PoolName;\n const pool = poolInfo[poolName];\n const coin1 = singleAssetPoolCoinMap[poolName].coin;\n const coin2 = \"SUI\";\n const typeT = coinsList[coin1].type;\n const typeR = coinsList[coin2].type;\n let coin = await getCoinObject(typeR, address, txb);\n if (!coin) {\n throw new Error(\"no coin available\");\n }\n let finalCoin = txb.splitCoins(coin, [amount]);\n txb.transferObjects([coin], address);\n txb.moveCall({\n target: `${pool.packageId}::interface::add_airdrop_coin`,\n typeArguments: [typeT, typeR],\n arguments: [\n txb.object(getConf().ALPHA_EMBER_VERSION),\n txb.object(pool.poolId),\n txb.object(finalCoin),\n ],\n });\n return txb;\n}\n"]}