@alphafi/alphafi-sdk 0.0.87 → 0.0.88

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 (269) hide show
  1. package/dist/cjs/common/constants.d.ts +18 -0
  2. package/dist/cjs/common/constants.d.ts.map +1 -1
  3. package/dist/cjs/common/constants.js +23 -12
  4. package/dist/cjs/common/constants.js.map +1 -1
  5. package/dist/cjs/common/maps.d.ts +1 -0
  6. package/dist/cjs/common/maps.d.ts.map +1 -1
  7. package/dist/cjs/common/maps.js +4 -0
  8. package/dist/cjs/common/maps.js.map +1 -1
  9. package/dist/cjs/common/types.d.ts +8 -1
  10. package/dist/cjs/common/types.d.ts.map +1 -1
  11. package/dist/cjs/common/types.js.map +1 -1
  12. package/dist/cjs/index.d.ts +1 -1
  13. package/dist/cjs/index.d.ts.map +1 -1
  14. package/dist/cjs/index.js +3 -2
  15. package/dist/cjs/index.js.map +1 -1
  16. package/dist/cjs/sui-sdk/events/fetchAutoCompoundingEvents.d.ts.map +1 -1
  17. package/dist/cjs/sui-sdk/events/fetchAutoCompoundingEvents.js +15 -17
  18. package/dist/cjs/sui-sdk/events/fetchAutoCompoundingEvents.js.map +1 -1
  19. package/dist/cjs/sui-sdk/events/fetchEvents.d.ts.map +1 -1
  20. package/dist/cjs/sui-sdk/events/fetchEvents.js +29 -3
  21. package/dist/cjs/sui-sdk/events/fetchEvents.js.map +1 -1
  22. package/dist/cjs/sui-sdk/events/types.d.ts +15 -5
  23. package/dist/cjs/sui-sdk/events/types.d.ts.map +1 -1
  24. package/dist/cjs/sui-sdk/events/types.js.map +1 -1
  25. package/dist/cjs/transactions/blueRewards.d.ts +1 -0
  26. package/dist/cjs/transactions/blueRewards.d.ts.map +1 -1
  27. package/dist/cjs/transactions/blueRewards.js +196 -471
  28. package/dist/cjs/transactions/blueRewards.js.map +1 -1
  29. package/dist/cjs/transactions/bluefin.d.ts.map +1 -1
  30. package/dist/cjs/transactions/bluefin.js +83 -495
  31. package/dist/cjs/transactions/bluefin.js.map +1 -1
  32. package/dist/esm/common/constants.d.ts +18 -0
  33. package/dist/esm/common/constants.d.ts.map +1 -1
  34. package/dist/esm/common/constants.js +23 -12
  35. package/dist/esm/common/constants.js.map +1 -1
  36. package/dist/esm/common/maps.d.ts +1 -0
  37. package/dist/esm/common/maps.d.ts.map +1 -1
  38. package/dist/esm/common/maps.js +4 -0
  39. package/dist/esm/common/maps.js.map +1 -1
  40. package/dist/esm/common/types.d.ts +8 -1
  41. package/dist/esm/common/types.d.ts.map +1 -1
  42. package/dist/esm/common/types.js.map +1 -1
  43. package/dist/esm/index.d.ts +1 -1
  44. package/dist/esm/index.d.ts.map +1 -1
  45. package/dist/esm/index.js +1 -1
  46. package/dist/esm/index.js.map +1 -1
  47. package/dist/esm/sui-sdk/events/fetchAutoCompoundingEvents.d.ts.map +1 -1
  48. package/dist/esm/sui-sdk/events/fetchAutoCompoundingEvents.js +15 -17
  49. package/dist/esm/sui-sdk/events/fetchAutoCompoundingEvents.js.map +1 -1
  50. package/dist/esm/sui-sdk/events/fetchEvents.d.ts.map +1 -1
  51. package/dist/esm/sui-sdk/events/fetchEvents.js +29 -3
  52. package/dist/esm/sui-sdk/events/fetchEvents.js.map +1 -1
  53. package/dist/esm/sui-sdk/events/types.d.ts +15 -5
  54. package/dist/esm/sui-sdk/events/types.d.ts.map +1 -1
  55. package/dist/esm/sui-sdk/events/types.js.map +1 -1
  56. package/dist/esm/transactions/blueRewards.d.ts +1 -0
  57. package/dist/esm/transactions/blueRewards.d.ts.map +1 -1
  58. package/dist/esm/transactions/blueRewards.js +196 -472
  59. package/dist/esm/transactions/blueRewards.js.map +1 -1
  60. package/dist/esm/transactions/bluefin.d.ts.map +1 -1
  61. package/dist/esm/transactions/bluefin.js +84 -496
  62. package/dist/esm/transactions/bluefin.js.map +1 -1
  63. package/docs/assets/navigation.js +1 -1
  64. package/docs/assets/search.js +1 -1
  65. package/docs/functions/alphaLpBreakdown.html +1 -1
  66. package/docs/functions/cetusLpBreakdown.html +1 -1
  67. package/docs/functions/claimRewardTxb.html +1 -1
  68. package/docs/functions/claimRewardsTxb.html +1 -1
  69. package/docs/functions/coinAmountToXTokensDoubleAsset.html +1 -1
  70. package/docs/functions/coinAmountToXTokensSingleAsset.html +1 -1
  71. package/docs/functions/coinsInPool.html +1 -1
  72. package/docs/functions/collectRewardTxb.html +1 -0
  73. package/docs/functions/collectRewards.html +1 -1
  74. package/docs/functions/deposit.html +1 -1
  75. package/docs/functions/depositDoubleAssetTxb.html +1 -1
  76. package/docs/functions/depositSingleAssetTxb.html +1 -1
  77. package/docs/functions/fetchAfterTransactionEvents.html +1 -1
  78. package/docs/functions/fetchAirdropClaimEvents.html +1 -1
  79. package/docs/functions/fetchAutoCompoundingEvents.html +1 -1
  80. package/docs/functions/fetchAutoCompoundingEventsGql.html +1 -1
  81. package/docs/functions/fetchCetusPools.html +1 -1
  82. package/docs/functions/fetchChainIdentifier.html +1 -1
  83. package/docs/functions/fetchCheckRatioEvents.html +1 -1
  84. package/docs/functions/fetchEvents.html +1 -1
  85. package/docs/functions/fetchLiquidityChangeEvents.html +1 -1
  86. package/docs/functions/fetchMultiCategoryEvents.html +1 -1
  87. package/docs/functions/fetchMultiReceipts.html +1 -1
  88. package/docs/functions/fetchNftHolders.html +1 -1
  89. package/docs/functions/fetchPools.html +1 -1
  90. package/docs/functions/fetchPortfolioData.html +1 -1
  91. package/docs/functions/fetchProtocolData.html +1 -1
  92. package/docs/functions/fetchRequiredPrices.html +1 -1
  93. package/docs/functions/fetchTVL.html +1 -1
  94. package/docs/functions/fetchTransactions.html +1 -1
  95. package/docs/functions/fetchUserVaultBalances.html +1 -1
  96. package/docs/functions/fetchUserVaults.html +1 -1
  97. package/docs/functions/fetchUserWalletData.html +1 -1
  98. package/docs/functions/fetchVoloExchangeRate.html +1 -1
  99. package/docs/functions/fetchWithdrawV2Events.html +1 -1
  100. package/docs/functions/getAirdropShare.html +1 -1
  101. package/docs/functions/getAllDoubleAssetVaults.html +1 -1
  102. package/docs/functions/getAllSingleAssetVaults.html +1 -1
  103. package/docs/functions/getAllVaultBalances.html +1 -1
  104. package/docs/functions/getAllVaults.html +1 -1
  105. package/docs/functions/getAlphaUnlocks.html +1 -1
  106. package/docs/functions/getAlphaVaultBalance.html +1 -1
  107. package/docs/functions/getAmounts.html +1 -1
  108. package/docs/functions/getApr.html +1 -1
  109. package/docs/functions/getAprs.html +1 -1
  110. package/docs/functions/getApy.html +1 -1
  111. package/docs/functions/getApys.html +1 -1
  112. package/docs/functions/getCetusInvestorTicksMap.html +1 -1
  113. package/docs/functions/getCetusPool.html +1 -1
  114. package/docs/functions/getCetusSqrtPriceMap.html +1 -1
  115. package/docs/functions/getCoinAmountsFromLiquidity.html +1 -1
  116. package/docs/functions/getConf.html +1 -1
  117. package/docs/functions/getCurrentTick.html +1 -1
  118. package/docs/functions/getDistributor.html +1 -1
  119. package/docs/functions/getDoubleAssetVaultBalance.html +1 -1
  120. package/docs/functions/getDoubleAssetVaults.html +1 -1
  121. package/docs/functions/getInvestor.html +1 -1
  122. package/docs/functions/getInvestorPoolMap.html +1 -1
  123. package/docs/functions/getLastAutoCompoundTime.html +1 -1
  124. package/docs/functions/getLatestPrices.html +1 -1
  125. package/docs/functions/getLiquidity.html +1 -1
  126. package/docs/functions/getMultiCetusPool.html +1 -1
  127. package/docs/functions/getMultiInvestor.html +1 -1
  128. package/docs/functions/getMultiLatestPrices.html +1 -1
  129. package/docs/functions/getMultiParentPool.html +1 -1
  130. package/docs/functions/getMultiPool.html +1 -1
  131. package/docs/functions/getMultiReceipts.html +1 -1
  132. package/docs/functions/getParentPool.html +1 -1
  133. package/docs/functions/getPool.html +1 -1
  134. package/docs/functions/getPoolExchangeRate.html +1 -1
  135. package/docs/functions/getPoolExchangeRateMap.html +1 -1
  136. package/docs/functions/getPoolsWeightDistribution.html +1 -1
  137. package/docs/functions/getPositionRange.html +1 -1
  138. package/docs/functions/getPositionRanges.html +1 -1
  139. package/docs/functions/getPositionTicks.html +1 -1
  140. package/docs/functions/getPriceToTick.html +1 -1
  141. package/docs/functions/getRebalanceHistories.html +1 -1
  142. package/docs/functions/getRebalanceHistory.html +1 -1
  143. package/docs/functions/getReceipts.html +1 -1
  144. package/docs/functions/getSingleAssetVaultBalance.html +1 -1
  145. package/docs/functions/getSingleAssetVaults.html +1 -1
  146. package/docs/functions/getSuiClient.html +2 -2
  147. package/docs/functions/getSuiNodeUrl.html +2 -2
  148. package/docs/functions/getTVLs-1.html +1 -1
  149. package/docs/functions/getTickSpacing.html +1 -1
  150. package/docs/functions/getTickToPrice.html +1 -1
  151. package/docs/functions/getTvls.html +1 -1
  152. package/docs/functions/getVaultBalance.html +1 -1
  153. package/docs/functions/getVaults.html +1 -1
  154. package/docs/functions/getZapAmounts.html +1 -1
  155. package/docs/functions/lastAutocompoundTime.html +1 -1
  156. package/docs/functions/liquidityToTokens.html +1 -1
  157. package/docs/functions/migrateBoostedToLoop.html +1 -1
  158. package/docs/functions/multiLiquidityToTokens.html +1 -1
  159. package/docs/functions/multiTokensToUsd.html +1 -1
  160. package/docs/functions/multiXTokensToLiquidity.html +1 -1
  161. package/docs/functions/parseUserWalletData.html +1 -1
  162. package/docs/functions/pendingRewardAmount.html +1 -1
  163. package/docs/functions/setCustomSuiClient.html +2 -2
  164. package/docs/functions/setSuiClient.html +2 -2
  165. package/docs/functions/setSuiNodeUrl.html +2 -2
  166. package/docs/functions/setWeights.html +1 -1
  167. package/docs/functions/withdraw.html +1 -1
  168. package/docs/functions/withdrawAlphaTxb.html +1 -1
  169. package/docs/functions/withdrawTxb.html +1 -1
  170. package/docs/functions/zapDepositTxb.html +1 -1
  171. package/docs/index.html +2 -2
  172. package/docs/interfaces/Coin.html +6 -6
  173. package/docs/interfaces/CoinPair.html +2 -2
  174. package/docs/interfaces/CommonEventAttributes.html +2 -2
  175. package/docs/interfaces/NaviVoloData.html +2 -2
  176. package/docs/interfaces/PoolData.html +2 -2
  177. package/docs/interfaces/PoolWeightDistribution.html +2 -2
  178. package/docs/interfaces/RebalanceHistoryType.html +2 -2
  179. package/docs/modules.html +3 -2
  180. package/docs/types/AfterTransactionEventNode.html +1 -1
  181. package/docs/types/AirdropClaimEventNode.html +1 -1
  182. package/docs/types/Allocator.html +1 -1
  183. package/docs/types/AlphaFiDoubleAssetVault.html +1 -1
  184. package/docs/types/AlphaFiMultiVaultBalance.html +1 -1
  185. package/docs/types/AlphaFiSingleAssetVault.html +1 -1
  186. package/docs/types/AlphaFiVault.html +1 -1
  187. package/docs/types/AlphaFiVaultBalance.html +1 -1
  188. package/docs/types/AlphaLendInvestor.html +1 -1
  189. package/docs/types/AlphaPoolType.html +1 -1
  190. package/docs/types/AlphaReceipt.html +1 -1
  191. package/docs/types/AlphaReceiptFields.html +1 -1
  192. package/docs/types/AlphaVaultBalance.html +1 -1
  193. package/docs/types/AutoBalancePoolNames.html +1 -1
  194. package/docs/types/AutoCompoundingEventNode.html +1 -1
  195. package/docs/types/BluefinInvestor.html +1 -1
  196. package/docs/types/BluefinPoolType.html +1 -1
  197. package/docs/types/BucketInvestor.html +1 -1
  198. package/docs/types/CetusInvestor.html +1 -1
  199. package/docs/types/CetusPoolType.html +1 -1
  200. package/docs/types/CetusSwapOptions.html +1 -1
  201. package/docs/types/CoinAmounts.html +1 -1
  202. package/docs/types/CoinName.html +1 -1
  203. package/docs/types/CoinType.html +1 -1
  204. package/docs/types/CommonInvestorFields.html +1 -1
  205. package/docs/types/CreatePoolOptions.html +1 -1
  206. package/docs/types/Distributor.html +1 -1
  207. package/docs/types/DoubleAssetMultiVaultBalance.html +1 -1
  208. package/docs/types/DoubleAssetPoolNames.html +1 -1
  209. package/docs/types/DoubleAssetTokenHoldings.html +1 -1
  210. package/docs/types/DoubleAssetVaultBalance.html +1 -1
  211. package/docs/types/EventCategory.html +1 -1
  212. package/docs/types/EventNode.html +1 -1
  213. package/docs/types/GetHoldersParams.html +1 -1
  214. package/docs/types/GetTokenHoldingsParams.html +1 -1
  215. package/docs/types/GetUserTokensFromTransactionsParams.html +1 -1
  216. package/docs/types/GetUserTokensInUsdFromTransactionsParams.html +1 -1
  217. package/docs/types/GetVaultBalanceParams.html +1 -1
  218. package/docs/types/HoldingsObj.html +1 -1
  219. package/docs/types/Icon.html +1 -1
  220. package/docs/types/Investor.html +1 -1
  221. package/docs/types/LiquidityChangeEventNode.html +1 -1
  222. package/docs/types/LiquidityToTokensParams.html +1 -1
  223. package/docs/types/LiquidityToUsdParams.html +1 -1
  224. package/docs/types/LoopingDebt.html +1 -1
  225. package/docs/types/LoopingPoolNames.html +1 -1
  226. package/docs/types/LpBreakdownType.html +1 -1
  227. package/docs/types/MemberPoolDataType.html +1 -1
  228. package/docs/types/MemberType.html +1 -1
  229. package/docs/types/MultiGetVaultBalancesParams.html +1 -1
  230. package/docs/types/NaviInvestor.html +1 -1
  231. package/docs/types/OtherReceiptFields.html +1 -1
  232. package/docs/types/PoolName.html +1 -1
  233. package/docs/types/PoolReceipt.html +1 -1
  234. package/docs/types/PoolType.html +1 -1
  235. package/docs/types/Receipt.html +1 -1
  236. package/docs/types/ReceiptGQL.html +1 -1
  237. package/docs/types/SingleAssetMultiVaultBalance.html +1 -1
  238. package/docs/types/SingleAssetPoolNames.html +1 -1
  239. package/docs/types/SingleAssetTokenHoldings.html +1 -1
  240. package/docs/types/SingleAssetVaultBalance.html +1 -1
  241. package/docs/types/SingleGetVaultBalancesParams.html +1 -1
  242. package/docs/types/StrategyType.html +1 -1
  243. package/docs/types/SuiNetwork.html +1 -1
  244. package/docs/types/SwapOptions.html +1 -1
  245. package/docs/types/TickSpacing.html +1 -1
  246. package/docs/types/TotalWeightType.html +1 -1
  247. package/docs/types/TransactionBlockType.html +1 -1
  248. package/docs/types/UserPoolLiquidity.html +1 -1
  249. package/docs/types/UserPoolTokenHoldings.html +1 -1
  250. package/docs/types/UserUsdHoldings.html +1 -1
  251. package/docs/types/VaultBalance.html +1 -1
  252. package/docs/types/VoteCastEvent.html +1 -1
  253. package/docs/types/WithdrawV2EventNode.html +1 -1
  254. package/docs/variables/alphalendMarketIdMap.html +1 -1
  255. package/docs/variables/bluefinPoolMap.html +1 -1
  256. package/docs/variables/cetusPoolMap.html +1 -1
  257. package/docs/variables/coinsList.html +1 -1
  258. package/docs/variables/defunctPoolsSet.html +1 -1
  259. package/docs/variables/doubleAssetPoolCoinMap.html +1 -1
  260. package/docs/variables/eventCategories.html +1 -1
  261. package/docs/variables/ignoredWalletsForDailyRevenue.html +1 -1
  262. package/docs/variables/loopingAccountAddresses.html +1 -1
  263. package/docs/variables/loopingPoolCoinMap.html +1 -1
  264. package/docs/variables/naviAssetMap.html +1 -1
  265. package/docs/variables/poolIdPoolNameMap.html +1 -1
  266. package/docs/variables/poolInfo.html +1 -1
  267. package/docs/variables/singleAssetPoolCoinMap.html +1 -1
  268. package/docs/variables/stableCoins.html +1 -1
  269. package/package.json +1 -1
@@ -23,77 +23,58 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.collectRewardTxb = collectRewardTxb;
26
27
  exports.claimRewardsTxb = claimRewardsTxb;
27
28
  exports.pendingRewardAmount = pendingRewardAmount;
28
29
  const decimal_js_1 = require("decimal.js");
29
30
  const index_js_1 = require("../index.js");
30
31
  const transactions_1 = require("@mysten/sui/transactions");
31
32
  const maps_js_1 = require("../common/maps.js");
32
- async function claimRewardsTxb(userAddress, poolName) {
33
- const { getReceipts } = await Promise.resolve().then(() => __importStar(require("../index.js")));
34
- try {
35
- const receipts = await getReceipts(poolName, userAddress, true);
36
- const txb = new transactions_1.Transaction();
37
- const pool = index_js_1.poolInfo[poolName];
38
- const coin1 = index_js_1.doubleAssetPoolCoinMap[poolName].coin1;
39
- const coin2 = index_js_1.doubleAssetPoolCoinMap[poolName].coin2;
40
- const rewards = [];
41
- if (poolName === "BLUEFIN-AUTOBALANCE-USDT-USDC") {
33
+ async function collectRewardTxb(poolName, ignoreCache, tx) {
34
+ let txb;
35
+ if (tx) {
36
+ txb = tx;
37
+ }
38
+ else {
39
+ txb = new transactions_1.Transaction();
40
+ }
41
+ const bluefinPool = (await (0, index_js_1.getParentPool)(poolName, ignoreCache));
42
+ const pool = index_js_1.poolInfo[poolName];
43
+ const coin1 = index_js_1.doubleAssetPoolCoinMap[poolName].coin1;
44
+ const coin2 = index_js_1.doubleAssetPoolCoinMap[poolName].coin2;
45
+ if (poolName === "BLUEFIN-AUTOBALANCE-SUI-USDC" ||
46
+ poolName === "BLUEFIN-AUTOBALANCE-SUI-LBTC") {
47
+ for (const reward of bluefinPool.content.fields.reward_infos) {
48
+ const rewardType = "0x" + reward.fields.reward_coin_type;
42
49
  txb.moveCall({
43
- target: `${pool.packageId}::alphafi_bluefin_type_1_pool::collect_and_swap_trade_fee`,
44
- typeArguments: [
45
- index_js_1.coinsList["USDT"].type,
46
- index_js_1.coinsList["USDC"].type,
47
- index_js_1.coinsList["SUI"].type,
48
- ],
49
- arguments: [
50
- txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
51
- txb.object(pool.investorId),
52
- txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
53
- txb.object((0, index_js_1.getConf)().BLUEFIN_USDT_USDC_POOL),
54
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
55
- txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
56
- ],
57
- });
58
- const blueBalance = txb.moveCall({
59
- target: `${index_js_1.poolInfo[poolName].packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v2`,
50
+ target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::collect_reward`,
60
51
  typeArguments: [
61
- index_js_1.coinsList["USDT"].type,
62
- index_js_1.coinsList["USDC"].type,
63
- index_js_1.coinsList["BLUE"].type,
64
- index_js_1.coinsList["SUI"].type,
52
+ index_js_1.coinsList[coin1].type,
53
+ index_js_1.coinsList[coin2].type,
54
+ rewardType,
65
55
  ],
66
56
  arguments: [
67
- txb.object(receipts[0].objectId),
68
57
  txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
69
58
  txb.object(pool.poolId),
70
59
  txb.object(pool.investorId),
71
60
  txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
72
61
  txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
73
- txb.object((0, index_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
74
- txb.object((0, index_js_1.getConf)().BLUEFIN_USDT_USDC_POOL),
75
- txb.object((0, index_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
76
- txb.object(index_js_1.cetusPoolMap["USDC-USDT"]),
77
- txb.object(index_js_1.cetusPoolMap["USDC-SUI"]),
78
- txb.object((0, index_js_1.getConf)().LST_INFO),
79
- txb.object((0, index_js_1.getConf)().SUI_SYSTEM_STATE),
62
+ txb.object(pool.parentPoolId),
80
63
  txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
81
64
  ],
82
65
  });
83
- const blueCoin = txb.moveCall({
84
- target: "0x2::coin::from_balance",
85
- typeArguments: [index_js_1.coinsList["BLUE"].type],
86
- arguments: [blueBalance],
87
- });
88
- rewards.push(blueCoin);
89
66
  }
90
- else if (poolName === "BLUEFIN-AUTOBALANCE-SUI-USDC") {
67
+ }
68
+ else if (poolName === "BLUEFIN-AUTOBALANCE-BLUE-SUI" ||
69
+ poolName === "BLUEFIN-AUTOBALANCE-DEEP-SUI") {
70
+ for (const reward of bluefinPool.content.fields.reward_infos) {
71
+ const rewardType = "0x" + reward.fields.reward_coin_type;
91
72
  txb.moveCall({
92
- target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::collect_reward`,
73
+ target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::collect_reward`,
93
74
  typeArguments: [
94
75
  index_js_1.coinsList[coin1].type,
95
76
  index_js_1.coinsList[coin2].type,
96
- index_js_1.coinsList["BLUE"].type,
77
+ rewardType,
97
78
  ],
98
79
  arguments: [
99
80
  txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
@@ -101,69 +82,81 @@ async function claimRewardsTxb(userAddress, poolName) {
101
82
  txb.object(pool.investorId),
102
83
  txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
103
84
  txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
104
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
85
+ txb.object(pool.parentPoolId),
105
86
  txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
106
87
  ],
107
88
  });
89
+ }
90
+ }
91
+ else {
92
+ for (const reward of bluefinPool.content.fields.reward_infos) {
93
+ const rewardType = "0x" + reward.fields.reward_coin_type;
108
94
  txb.moveCall({
109
- target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::collect_reward`,
95
+ target: `${pool.packageId}::alphafi_bluefin_type_1_pool::collect_reward`,
110
96
  typeArguments: [
111
97
  index_js_1.coinsList[coin1].type,
112
98
  index_js_1.coinsList[coin2].type,
113
- index_js_1.coinsList["STSUI"].type,
114
- ],
115
- arguments: [
116
- txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
117
- txb.object(pool.poolId),
118
- txb.object(pool.investorId),
119
- txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
120
- txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
121
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
122
- txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
123
- ],
124
- });
125
- const blueBalance = txb.moveCall({
126
- target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
127
- typeArguments: [
128
- index_js_1.coinsList["SUI"].type,
129
- index_js_1.coinsList["USDC"].type,
130
- index_js_1.coinsList["BLUE"].type,
99
+ rewardType,
131
100
  ],
132
101
  arguments: [
133
- txb.object(receipts[0].objectId),
134
102
  txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
135
103
  txb.object(pool.poolId),
136
104
  txb.object(pool.investorId),
137
105
  txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
138
106
  txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
139
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
107
+ txb.object(pool.parentPoolId),
140
108
  txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
141
109
  ],
142
110
  });
143
- const stsuiBalance = txb.moveCall({
144
- target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
145
- typeArguments: [
146
- index_js_1.coinsList["SUI"].type,
147
- index_js_1.coinsList["USDC"].type,
148
- index_js_1.coinsList["STSUI"].type,
149
- ],
150
- arguments: [
151
- txb.object(receipts[0].objectId),
152
- txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
153
- txb.object(pool.poolId),
154
- txb.object(pool.investorId),
155
- txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
156
- txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
157
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
158
- txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
159
- ],
160
- });
161
- const suiBalance = txb.moveCall({
111
+ }
112
+ }
113
+ return txb;
114
+ }
115
+ async function claimRewardsTxb(userAddress, poolName) {
116
+ const { getReceipts } = await Promise.resolve().then(() => __importStar(require("../index.js")));
117
+ try {
118
+ const receipts = await getReceipts(poolName, userAddress, true);
119
+ const txb = await collectRewardTxb(poolName, true); //false for now
120
+ const bluefinPool = (await (0, index_js_1.getParentPool)(poolName, false));
121
+ const pool = index_js_1.poolInfo[poolName];
122
+ const coin1 = index_js_1.doubleAssetPoolCoinMap[poolName].coin1;
123
+ const coin2 = index_js_1.doubleAssetPoolCoinMap[poolName].coin2;
124
+ const rewards = [];
125
+ if (poolName === "BLUEFIN-AUTOBALANCE-SUI-LBTC" ||
126
+ poolName === "BLUEFIN-AUTOBALANCE-SUI-USDC") {
127
+ for (const reward of bluefinPool.content.fields.reward_infos) {
128
+ const rewardType = "0x" + reward.fields.reward_coin_type;
129
+ const balance = txb.moveCall({
130
+ target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
131
+ typeArguments: [
132
+ index_js_1.coinsList[coin1].type,
133
+ index_js_1.coinsList[coin2].type,
134
+ rewardType,
135
+ ],
136
+ arguments: [
137
+ txb.object(receipts[0].objectId),
138
+ txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
139
+ txb.object(pool.poolId),
140
+ txb.object(pool.investorId),
141
+ txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
142
+ txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
143
+ txb.object(pool.parentPoolId),
144
+ txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
145
+ ],
146
+ });
147
+ const coin = txb.moveCall({
148
+ target: "0x2::coin::from_balance",
149
+ typeArguments: [rewardType],
150
+ arguments: [balance],
151
+ });
152
+ rewards.push(coin);
153
+ }
154
+ const tBalance = txb.moveCall({
162
155
  target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
163
156
  typeArguments: [
164
- index_js_1.coinsList["SUI"].type,
165
- index_js_1.coinsList["USDC"].type,
166
- index_js_1.coinsList["SUI"].type,
157
+ index_js_1.coinsList[coin1].type,
158
+ index_js_1.coinsList[coin2].type,
159
+ index_js_1.coinsList[coin1].type,
167
160
  ],
168
161
  arguments: [
169
162
  txb.object(receipts[0].objectId),
@@ -172,16 +165,16 @@ async function claimRewardsTxb(userAddress, poolName) {
172
165
  txb.object(pool.investorId),
173
166
  txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
174
167
  txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
175
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
168
+ txb.object(pool.parentPoolId),
176
169
  txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
177
170
  ],
178
171
  });
179
- const usdcBalance = txb.moveCall({
172
+ const sBalance = txb.moveCall({
180
173
  target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
181
174
  typeArguments: [
182
- index_js_1.coinsList["SUI"].type,
183
- index_js_1.coinsList["USDC"].type,
184
- index_js_1.coinsList["USDC"].type,
175
+ index_js_1.coinsList[coin1].type,
176
+ index_js_1.coinsList[coin2].type,
177
+ index_js_1.coinsList[coin2].type,
185
178
  ],
186
179
  arguments: [
187
180
  txb.object(receipts[0].objectId),
@@ -190,92 +183,58 @@ async function claimRewardsTxb(userAddress, poolName) {
190
183
  txb.object(pool.investorId),
191
184
  txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
192
185
  txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
193
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
186
+ txb.object(pool.parentPoolId),
194
187
  txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
195
188
  ],
196
189
  });
197
- const blueCoin = txb.moveCall({
198
- target: "0x2::coin::from_balance",
199
- typeArguments: [index_js_1.coinsList["BLUE"].type],
200
- arguments: [blueBalance],
201
- });
202
- const stsuiCoin = txb.moveCall({
190
+ const tCoin = txb.moveCall({
203
191
  target: "0x2::coin::from_balance",
204
- typeArguments: [index_js_1.coinsList["STSUI"].type],
205
- arguments: [stsuiBalance],
206
- });
207
- const suiCoin = txb.moveCall({
208
- target: "0x2::coin::from_balance",
209
- typeArguments: [index_js_1.coinsList["SUI"].type],
210
- arguments: [suiBalance],
211
- });
212
- const usdcCoin = txb.moveCall({
213
- target: "0x2::coin::from_balance",
214
- typeArguments: [index_js_1.coinsList["USDC"].type],
215
- arguments: [usdcBalance],
216
- });
217
- rewards.push(blueCoin);
218
- rewards.push(stsuiCoin);
219
- rewards.push(suiCoin);
220
- rewards.push(usdcCoin);
221
- }
222
- else if (poolName === "BLUEFIN-AUTOBALANCE-SUIUSDT-USDC") {
223
- txb.moveCall({
224
- target: `${pool.packageId}::alphafi_bluefin_type_1_pool::collect_and_swap_trade_fee`,
225
- typeArguments: [
226
- index_js_1.coinsList["SUIUSDT"].type,
227
- index_js_1.coinsList["USDC"].type,
228
- index_js_1.coinsList["SUI"].type,
229
- ],
230
- arguments: [
231
- txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
232
- txb.object(pool.investorId),
233
- txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
234
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUIUSDT_USDC_POOL),
235
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
236
- txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
237
- ],
238
- });
239
- const blueBalance = txb.moveCall({
240
- target: `${index_js_1.poolInfo[poolName].packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v2`,
241
- typeArguments: [
242
- index_js_1.coinsList["SUIUSDT"].type,
243
- index_js_1.coinsList["USDC"].type,
244
- index_js_1.coinsList["BLUE"].type,
245
- index_js_1.coinsList["SUI"].type,
246
- ],
247
- arguments: [
248
- txb.object(receipts[0].objectId),
249
- txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
250
- txb.object(pool.poolId),
251
- txb.object(pool.investorId),
252
- txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
253
- txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
254
- txb.object((0, index_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
255
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUIUSDT_USDC_POOL),
256
- txb.object((0, index_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
257
- txb.object(index_js_1.cetusPoolMap["USDC-SUIUSDT"]),
258
- txb.object(index_js_1.cetusPoolMap["USDC-SUI"]),
259
- txb.object((0, index_js_1.getConf)().LST_INFO),
260
- txb.object((0, index_js_1.getConf)().SUI_SYSTEM_STATE),
261
- txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
262
- ],
192
+ typeArguments: [index_js_1.coinsList[coin1].type],
193
+ arguments: [tBalance],
263
194
  });
264
- const blueCoin = txb.moveCall({
195
+ const sCoin = txb.moveCall({
265
196
  target: "0x2::coin::from_balance",
266
- typeArguments: [index_js_1.coinsList["BLUE"].type],
267
- arguments: [blueBalance],
197
+ typeArguments: [index_js_1.coinsList[coin2].type],
198
+ arguments: [sBalance],
268
199
  });
269
- rewards.push(blueCoin);
200
+ rewards.push(tCoin);
201
+ rewards.push(sCoin);
270
202
  }
271
- else if (poolName === "BLUEFIN-AUTOBALANCE-DEEP-BLUE") {
272
- const blueBalance = txb.moveCall({
273
- target: `${index_js_1.poolInfo[poolName].packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v2`,
203
+ else if (poolName === "BLUEFIN-AUTOBALANCE-BLUE-SUI" ||
204
+ poolName === "BLUEFIN-AUTOBALANCE-DEEP-SUI") {
205
+ for (const reward of bluefinPool.content.fields.reward_infos) {
206
+ const rewardType = "0x" + reward.fields.reward_coin_type;
207
+ const balance = txb.moveCall({
208
+ target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v3`,
209
+ typeArguments: [
210
+ index_js_1.coinsList[coin1].type,
211
+ index_js_1.coinsList[coin2].type,
212
+ rewardType,
213
+ ],
214
+ arguments: [
215
+ txb.object(receipts[0].objectId),
216
+ txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
217
+ txb.object(pool.poolId),
218
+ txb.object(pool.investorId),
219
+ txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
220
+ txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
221
+ txb.object(pool.parentPoolId),
222
+ txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
223
+ ],
224
+ });
225
+ const coin = txb.moveCall({
226
+ target: "0x2::coin::from_balance",
227
+ typeArguments: [rewardType],
228
+ arguments: [balance],
229
+ });
230
+ rewards.push(coin);
231
+ }
232
+ const tBalance = txb.moveCall({
233
+ target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v3`,
274
234
  typeArguments: [
275
- index_js_1.coinsList["DEEP"].type,
276
- index_js_1.coinsList["BLUE"].type,
277
- index_js_1.coinsList["BLUE"].type,
278
- index_js_1.coinsList["SUI"].type,
235
+ index_js_1.coinsList[coin1].type,
236
+ index_js_1.coinsList[coin2].type,
237
+ index_js_1.coinsList[coin1].type,
279
238
  ],
280
239
  arguments: [
281
240
  txb.object(receipts[0].objectId),
@@ -284,30 +243,16 @@ async function claimRewardsTxb(userAddress, poolName) {
284
243
  txb.object(pool.investorId),
285
244
  txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
286
245
  txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
287
- txb.object((0, index_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
288
- txb.object((0, index_js_1.getConf)().BLUEFIN_DEEP_BLUE_POOL),
289
- txb.object((0, index_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
290
- txb.object(index_js_1.cetusPoolMap["BLUE-DEEP"]),
291
- txb.object(index_js_1.cetusPoolMap["BLUE-SUI"]),
292
- txb.object((0, index_js_1.getConf)().LST_INFO),
293
- txb.object((0, index_js_1.getConf)().SUI_SYSTEM_STATE),
246
+ txb.object(pool.parentPoolId),
294
247
  txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
295
248
  ],
296
249
  });
297
- const blueCoin = txb.moveCall({
298
- target: "0x2::coin::from_balance",
299
- typeArguments: [index_js_1.coinsList["BLUE"].type],
300
- arguments: [blueBalance],
301
- });
302
- rewards.push(blueCoin);
303
- }
304
- else if (poolName === "BLUEFIN-AUTOBALANCE-DEEP-SUI") {
305
- const blueBalance = txb.moveCall({
306
- target: `${index_js_1.poolInfo[poolName].packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v2`,
250
+ const sBalance = txb.moveCall({
251
+ target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v3`,
307
252
  typeArguments: [
308
- index_js_1.coinsList["DEEP"].type,
309
- index_js_1.coinsList["SUI"].type,
310
- index_js_1.coinsList["BLUE"].type,
253
+ index_js_1.coinsList[coin1].type,
254
+ index_js_1.coinsList[coin2].type,
255
+ index_js_1.coinsList[coin2].type,
311
256
  ],
312
257
  arguments: [
313
258
  txb.object(receipts[0].objectId),
@@ -316,250 +261,75 @@ async function claimRewardsTxb(userAddress, poolName) {
316
261
  txb.object(pool.investorId),
317
262
  txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
318
263
  txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
319
- txb.object((0, index_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
320
- txb.object((0, index_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
321
- txb.object((0, index_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
322
- txb.object(index_js_1.cetusPoolMap["DEEP-SUI"]),
323
- txb.object((0, index_js_1.getConf)().LST_INFO),
324
- txb.object((0, index_js_1.getConf)().SUI_SYSTEM_STATE),
264
+ txb.object(pool.parentPoolId),
325
265
  txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
326
266
  ],
327
267
  });
328
- const blueCoin = txb.moveCall({
268
+ const tCoin = txb.moveCall({
329
269
  target: "0x2::coin::from_balance",
330
- typeArguments: [index_js_1.coinsList["BLUE"].type],
331
- arguments: [blueBalance],
270
+ typeArguments: [index_js_1.coinsList[coin1].type],
271
+ arguments: [tBalance],
332
272
  });
333
- rewards.push(blueCoin);
334
- }
335
- else if (poolName === "BLUEFIN-AUTOBALANCE-BLUE-SUI") {
336
- const blueBalance = txb.moveCall({
337
- target: `${index_js_1.poolInfo[poolName].packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v2`,
338
- typeArguments: [
339
- index_js_1.coinsList["BLUE"].type,
340
- index_js_1.coinsList["SUI"].type,
341
- index_js_1.coinsList["DEEP"].type,
342
- ],
343
- arguments: [
344
- txb.object(receipts[0].objectId),
345
- txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
346
- txb.object(pool.poolId),
347
- txb.object(pool.investorId),
348
- txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
349
- txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
350
- txb.object((0, index_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
351
- txb.object((0, index_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
352
- txb.object((0, index_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
353
- txb.object(index_js_1.cetusPoolMap["BLUE-SUI"]),
354
- txb.object((0, index_js_1.getConf)().LST_INFO),
355
- txb.object((0, index_js_1.getConf)().SUI_SYSTEM_STATE),
356
- txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
357
- ],
358
- });
359
- const blueCoin = txb.moveCall({
273
+ const sCoin = txb.moveCall({
360
274
  target: "0x2::coin::from_balance",
361
- typeArguments: [index_js_1.coinsList["BLUE"].type],
362
- arguments: [blueBalance],
275
+ typeArguments: [index_js_1.coinsList[coin2].type],
276
+ arguments: [sBalance],
363
277
  });
364
- rewards.push(blueCoin);
278
+ rewards.push(tCoin);
279
+ rewards.push(sCoin);
365
280
  }
366
- else if (poolName === "BLUEFIN-AUTOBALANCE-SUI-LBTC") {
367
- txb.moveCall({
368
- target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::collect_reward`,
281
+ else {
282
+ for (const reward of bluefinPool.content.fields.reward_infos) {
283
+ const rewardType = "0x" + reward.fields.reward_coin_type;
284
+ const balance = txb.moveCall({
285
+ target: `${pool.packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v3`,
286
+ typeArguments: [
287
+ index_js_1.coinsList[coin1].type,
288
+ index_js_1.coinsList[coin2].type,
289
+ rewardType,
290
+ ],
291
+ arguments: [
292
+ txb.object(receipts[0].objectId),
293
+ txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
294
+ txb.object(pool.poolId),
295
+ txb.object(pool.investorId),
296
+ txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
297
+ txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
298
+ txb.object(pool.parentPoolId),
299
+ txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
300
+ ],
301
+ });
302
+ const coin = txb.moveCall({
303
+ target: "0x2::coin::from_balance",
304
+ typeArguments: [rewardType],
305
+ arguments: [balance],
306
+ });
307
+ rewards.push(coin);
308
+ }
309
+ const tBalance = txb.moveCall({
310
+ target: `${pool.packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v3`,
369
311
  typeArguments: [
370
312
  index_js_1.coinsList[coin1].type,
371
313
  index_js_1.coinsList[coin2].type,
372
- index_js_1.coinsList["BLUE"].type,
373
- ],
374
- arguments: [
375
- txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
376
- txb.object(pool.poolId),
377
- txb.object(pool.investorId),
378
- txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
379
- txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
380
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_LBTC_POOL),
381
- txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
382
- ],
383
- });
384
- txb.moveCall({
385
- target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::collect_reward`,
386
- typeArguments: [
387
314
  index_js_1.coinsList[coin1].type,
388
- index_js_1.coinsList[coin2].type,
389
- index_js_1.coinsList["STSUI"].type,
390
315
  ],
391
316
  arguments: [
317
+ txb.object(receipts[0].objectId),
392
318
  txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
393
319
  txb.object(pool.poolId),
394
320
  txb.object(pool.investorId),
395
321
  txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
396
322
  txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
397
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_LBTC_POOL),
323
+ txb.object(pool.parentPoolId),
398
324
  txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
399
325
  ],
400
326
  });
401
- txb.moveCall({
402
- target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::collect_reward`,
327
+ const sBalance = txb.moveCall({
328
+ target: `${pool.packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v3`,
403
329
  typeArguments: [
404
330
  index_js_1.coinsList[coin1].type,
405
331
  index_js_1.coinsList[coin2].type,
406
- index_js_1.coinsList["DEEP"].type,
407
- ],
408
- arguments: [
409
- txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
410
- txb.object(pool.poolId),
411
- txb.object(pool.investorId),
412
- txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
413
- txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
414
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_LBTC_POOL),
415
- txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
416
- ],
417
- });
418
- const blueBalance = txb.moveCall({
419
- target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
420
- typeArguments: [
421
- index_js_1.coinsList["SUI"].type,
422
- index_js_1.coinsList["LBTC"].type,
423
- index_js_1.coinsList["BLUE"].type,
424
- ],
425
- arguments: [
426
- txb.object(receipts[0].objectId),
427
- txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
428
- txb.object(pool.poolId),
429
- txb.object(pool.investorId),
430
- txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
431
- txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
432
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_LBTC_POOL),
433
- txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
434
- ],
435
- });
436
- const stsuiBalance = txb.moveCall({
437
- target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
438
- typeArguments: [
439
- index_js_1.coinsList["SUI"].type,
440
- index_js_1.coinsList["LBTC"].type,
441
- index_js_1.coinsList["STSUI"].type,
442
- ],
443
- arguments: [
444
- txb.object(receipts[0].objectId),
445
- txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
446
- txb.object(pool.poolId),
447
- txb.object(pool.investorId),
448
- txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
449
- txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
450
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_LBTC_POOL),
451
- txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
452
- ],
453
- });
454
- const suiBalance = txb.moveCall({
455
- target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
456
- typeArguments: [
457
- index_js_1.coinsList["SUI"].type,
458
- index_js_1.coinsList["LBTC"].type,
459
- index_js_1.coinsList["SUI"].type,
460
- ],
461
- arguments: [
462
- txb.object(receipts[0].objectId),
463
- txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
464
- txb.object(pool.poolId),
465
- txb.object(pool.investorId),
466
- txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
467
- txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
468
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_LBTC_POOL),
469
- txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
470
- ],
471
- });
472
- const lbtcBalance = txb.moveCall({
473
- target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
474
- typeArguments: [
475
- index_js_1.coinsList["SUI"].type,
476
- index_js_1.coinsList["LBTC"].type,
477
- index_js_1.coinsList["LBTC"].type,
478
- ],
479
- arguments: [
480
- txb.object(receipts[0].objectId),
481
- txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
482
- txb.object(pool.poolId),
483
- txb.object(pool.investorId),
484
- txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
485
- txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
486
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_LBTC_POOL),
487
- txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
488
- ],
489
- });
490
- const deepBalance = txb.moveCall({
491
- target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
492
- typeArguments: [
493
- index_js_1.coinsList["SUI"].type,
494
- index_js_1.coinsList["LBTC"].type,
495
- index_js_1.coinsList["DEEP"].type,
496
- ],
497
- arguments: [
498
- txb.object(receipts[0].objectId),
499
- txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
500
- txb.object(pool.poolId),
501
- txb.object(pool.investorId),
502
- txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
503
- txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
504
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_LBTC_POOL),
505
- txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
506
- ],
507
- });
508
- const blueCoin = txb.moveCall({
509
- target: "0x2::coin::from_balance",
510
- typeArguments: [index_js_1.coinsList["BLUE"].type],
511
- arguments: [blueBalance],
512
- });
513
- const stsuiCoin = txb.moveCall({
514
- target: "0x2::coin::from_balance",
515
- typeArguments: [index_js_1.coinsList["STSUI"].type],
516
- arguments: [stsuiBalance],
517
- });
518
- const suiCoin = txb.moveCall({
519
- target: "0x2::coin::from_balance",
520
- typeArguments: [index_js_1.coinsList["SUI"].type],
521
- arguments: [suiBalance],
522
- });
523
- const lbtcCoin = txb.moveCall({
524
- target: "0x2::coin::from_balance",
525
- typeArguments: [index_js_1.coinsList["LBTC"].type],
526
- arguments: [lbtcBalance],
527
- });
528
- const deepCoin = txb.moveCall({
529
- target: "0x2::coin::from_balance",
530
- typeArguments: [index_js_1.coinsList["DEEP"].type],
531
- arguments: [deepBalance],
532
- });
533
- rewards.push(blueCoin);
534
- rewards.push(stsuiCoin);
535
- rewards.push(suiCoin);
536
- rewards.push(lbtcCoin);
537
- rewards.push(deepCoin);
538
- }
539
- else if (poolName === "BLUEFIN-AUTOBALANCE-WAL-USDC") {
540
- txb.moveCall({
541
- target: `${pool.packageId}::alphafi_bluefin_type_1_pool::collect_and_swap_trade_fee`,
542
- typeArguments: [
543
- index_js_1.coinsList["WAL"].type,
544
- index_js_1.coinsList["USDC"].type,
545
- index_js_1.coinsList["SUI"].type,
546
- ],
547
- arguments: [
548
- txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
549
- txb.object(pool.investorId),
550
- txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
551
- txb.object((0, index_js_1.getConf)().BLUEFIN_WAL_USDC_POOL),
552
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
553
- txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
554
- ],
555
- });
556
- const blueBalance = txb.moveCall({
557
- target: `${index_js_1.poolInfo[poolName].packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v2`,
558
- typeArguments: [
559
- index_js_1.coinsList["WAL"].type,
560
- index_js_1.coinsList["USDC"].type,
561
- index_js_1.coinsList["BLUE"].type,
562
- index_js_1.coinsList["SUI"].type,
332
+ index_js_1.coinsList[coin2].type,
563
333
  ],
564
334
  arguments: [
565
335
  txb.object(receipts[0].objectId),
@@ -568,71 +338,22 @@ async function claimRewardsTxb(userAddress, poolName) {
568
338
  txb.object(pool.investorId),
569
339
  txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
570
340
  txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
571
- txb.object((0, index_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
572
- txb.object((0, index_js_1.getConf)().BLUEFIN_WAL_USDC_POOL),
573
- txb.object((0, index_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
574
- txb.object(index_js_1.cetusPoolMap["USDC-WAL"]),
575
- txb.object(index_js_1.cetusPoolMap["USDC-SUI"]),
576
- txb.object((0, index_js_1.getConf)().LST_INFO),
577
- txb.object((0, index_js_1.getConf)().SUI_SYSTEM_STATE),
341
+ txb.object(pool.parentPoolId),
578
342
  txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
579
343
  ],
580
344
  });
581
- const blueCoin = txb.moveCall({
345
+ const tCoin = txb.moveCall({
582
346
  target: "0x2::coin::from_balance",
583
- typeArguments: [index_js_1.coinsList["BLUE"].type],
584
- arguments: [blueBalance],
585
- });
586
- rewards.push(blueCoin);
587
- }
588
- else if (poolName === "BLUEFIN-AUTOBALANCE-SUIUSDT-USDC-ZERO-ZERO") {
589
- txb.moveCall({
590
- target: `${pool.packageId}::alphafi_bluefin_type_1_pool::collect_and_swap_trade_fee`,
591
- typeArguments: [
592
- index_js_1.coinsList["SUIUSDT"].type,
593
- index_js_1.coinsList["USDC"].type,
594
- index_js_1.coinsList["SUI"].type,
595
- ],
596
- arguments: [
597
- txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
598
- txb.object(pool.investorId),
599
- txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
600
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUIUSDT_USDC_ZERO_ZERO_POOL),
601
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
602
- txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
603
- ],
604
- });
605
- const blueBalance = txb.moveCall({
606
- target: `${index_js_1.poolInfo[poolName].packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v2`,
607
- typeArguments: [
608
- index_js_1.coinsList["SUIUSDT"].type,
609
- index_js_1.coinsList["USDC"].type,
610
- index_js_1.coinsList["BLUE"].type,
611
- index_js_1.coinsList["SUI"].type,
612
- ],
613
- arguments: [
614
- txb.object(receipts[0].objectId),
615
- txb.object((0, index_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
616
- txb.object(pool.poolId),
617
- txb.object(pool.investorId),
618
- txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
619
- txb.object((0, index_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
620
- txb.object((0, index_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
621
- txb.object((0, index_js_1.getConf)().BLUEFIN_SUIUSDT_USDC_ZERO_ZERO_POOL),
622
- txb.object((0, index_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
623
- txb.object(index_js_1.cetusPoolMap["USDC-SUIUSDT"]),
624
- txb.object(index_js_1.cetusPoolMap["USDC-SUI"]),
625
- txb.object((0, index_js_1.getConf)().LST_INFO),
626
- txb.object((0, index_js_1.getConf)().SUI_SYSTEM_STATE),
627
- txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
628
- ],
347
+ typeArguments: [index_js_1.coinsList[coin1].type],
348
+ arguments: [tBalance],
629
349
  });
630
- const blueCoin = txb.moveCall({
350
+ const sCoin = txb.moveCall({
631
351
  target: "0x2::coin::from_balance",
632
- typeArguments: [index_js_1.coinsList["BLUE"].type],
633
- arguments: [blueBalance],
352
+ typeArguments: [index_js_1.coinsList[coin2].type],
353
+ arguments: [sBalance],
634
354
  });
635
- rewards.push(blueCoin);
355
+ rewards.push(tCoin);
356
+ rewards.push(sCoin);
636
357
  }
637
358
  return { txb: txb, coinOut: rewards };
638
359
  }
@@ -665,6 +386,10 @@ async function pendingRewardAmount(userAddress, poolName) {
665
386
  });
666
387
  const coinTypeToCoin = maps_js_1.coinTypeMap;
667
388
  Object.keys(curAcc).forEach((type) => {
389
+ if (!coinTypeToCoin[type]) {
390
+ console.error("coin not present", type);
391
+ return;
392
+ }
668
393
  const cur = new decimal_js_1.Decimal(curAcc[type]);
669
394
  const last = new decimal_js_1.Decimal(type in lastAcc ? lastAcc[type] : "0");
670
395
  const pending = new decimal_js_1.Decimal(type in userPendingReward ? userPendingReward[type] : "0");