@alphafi/alphafi-sdk 0.0.89 → 0.0.91

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 (258) hide show
  1. package/dist/cjs/common/constants.d.ts +57 -0
  2. package/dist/cjs/common/constants.d.ts.map +1 -1
  3. package/dist/cjs/common/constants.js +34 -0
  4. package/dist/cjs/common/constants.js.map +1 -1
  5. package/dist/cjs/common/maps.d.ts +3 -0
  6. package/dist/cjs/common/maps.d.ts.map +1 -1
  7. package/dist/cjs/common/maps.js +83 -1
  8. package/dist/cjs/common/maps.js.map +1 -1
  9. package/dist/cjs/common/types.d.ts +1 -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 +5 -1
  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 +0 -1
  18. package/dist/cjs/sui-sdk/events/fetchAutoCompoundingEvents.js.map +1 -1
  19. package/dist/cjs/transactions/blueRewards.d.ts.map +1 -1
  20. package/dist/cjs/transactions/blueRewards.js +15 -160
  21. package/dist/cjs/transactions/blueRewards.js.map +1 -1
  22. package/dist/cjs/transactions/bluefin.d.ts.map +1 -1
  23. package/dist/cjs/transactions/bluefin.js +8 -218
  24. package/dist/cjs/transactions/bluefin.js.map +1 -1
  25. package/dist/esm/common/constants.d.ts +57 -0
  26. package/dist/esm/common/constants.d.ts.map +1 -1
  27. package/dist/esm/common/constants.js +34 -0
  28. package/dist/esm/common/constants.js.map +1 -1
  29. package/dist/esm/common/maps.d.ts +3 -0
  30. package/dist/esm/common/maps.d.ts.map +1 -1
  31. package/dist/esm/common/maps.js +82 -0
  32. package/dist/esm/common/maps.js.map +1 -1
  33. package/dist/esm/common/types.d.ts +1 -1
  34. package/dist/esm/common/types.d.ts.map +1 -1
  35. package/dist/esm/common/types.js.map +1 -1
  36. package/dist/esm/index.d.ts +1 -1
  37. package/dist/esm/index.d.ts.map +1 -1
  38. package/dist/esm/index.js +1 -1
  39. package/dist/esm/index.js.map +1 -1
  40. package/dist/esm/sui-sdk/events/fetchAutoCompoundingEvents.d.ts.map +1 -1
  41. package/dist/esm/sui-sdk/events/fetchAutoCompoundingEvents.js +0 -1
  42. package/dist/esm/sui-sdk/events/fetchAutoCompoundingEvents.js.map +1 -1
  43. package/dist/esm/transactions/blueRewards.d.ts.map +1 -1
  44. package/dist/esm/transactions/blueRewards.js +17 -162
  45. package/dist/esm/transactions/blueRewards.js.map +1 -1
  46. package/dist/esm/transactions/bluefin.d.ts.map +1 -1
  47. package/dist/esm/transactions/bluefin.js +9 -219
  48. package/dist/esm/transactions/bluefin.js.map +1 -1
  49. package/docs/assets/navigation.js +1 -1
  50. package/docs/assets/search.js +1 -1
  51. package/docs/functions/alphaLpBreakdown.html +1 -1
  52. package/docs/functions/cetusLpBreakdown.html +1 -1
  53. package/docs/functions/claimRewardTxb.html +1 -1
  54. package/docs/functions/claimRewardsTxb.html +1 -1
  55. package/docs/functions/coinAmountToXTokensDoubleAsset.html +1 -1
  56. package/docs/functions/coinAmountToXTokensSingleAsset.html +1 -1
  57. package/docs/functions/coinsInPool.html +1 -1
  58. package/docs/functions/collectRewardTxb.html +1 -1
  59. package/docs/functions/collectRewards.html +1 -1
  60. package/docs/functions/deposit.html +1 -1
  61. package/docs/functions/depositDoubleAssetTxb.html +1 -1
  62. package/docs/functions/depositSingleAssetTxb.html +1 -1
  63. package/docs/functions/fetchAfterTransactionEvents.html +1 -1
  64. package/docs/functions/fetchAirdropClaimEvents.html +1 -1
  65. package/docs/functions/fetchAutoCompoundingEvents.html +1 -1
  66. package/docs/functions/fetchAutoCompoundingEventsGql.html +1 -1
  67. package/docs/functions/fetchCetusPools.html +1 -1
  68. package/docs/functions/fetchChainIdentifier.html +1 -1
  69. package/docs/functions/fetchCheckRatioEvents.html +1 -1
  70. package/docs/functions/fetchEvents.html +1 -1
  71. package/docs/functions/fetchLiquidityChangeEvents.html +1 -1
  72. package/docs/functions/fetchMultiCategoryEvents.html +1 -1
  73. package/docs/functions/fetchMultiReceipts.html +1 -1
  74. package/docs/functions/fetchNftHolders.html +1 -1
  75. package/docs/functions/fetchPools.html +1 -1
  76. package/docs/functions/fetchPortfolioData.html +1 -1
  77. package/docs/functions/fetchProtocolData.html +1 -1
  78. package/docs/functions/fetchRequiredPrices.html +1 -1
  79. package/docs/functions/fetchTVL.html +1 -1
  80. package/docs/functions/fetchTransactions.html +1 -1
  81. package/docs/functions/fetchUserVaultBalances.html +1 -1
  82. package/docs/functions/fetchUserVaults.html +1 -1
  83. package/docs/functions/fetchUserWalletData.html +1 -1
  84. package/docs/functions/fetchVoloExchangeRate.html +1 -1
  85. package/docs/functions/fetchWithdrawV2Events.html +1 -1
  86. package/docs/functions/getAirdropShare.html +1 -1
  87. package/docs/functions/getAllDoubleAssetVaults.html +1 -1
  88. package/docs/functions/getAllSingleAssetVaults.html +1 -1
  89. package/docs/functions/getAllVaultBalances.html +1 -1
  90. package/docs/functions/getAllVaults.html +1 -1
  91. package/docs/functions/getAlphaUnlocks.html +1 -1
  92. package/docs/functions/getAlphaVaultBalance.html +1 -1
  93. package/docs/functions/getAmounts.html +1 -1
  94. package/docs/functions/getApr.html +1 -1
  95. package/docs/functions/getAprs.html +1 -1
  96. package/docs/functions/getApy.html +1 -1
  97. package/docs/functions/getApys.html +1 -1
  98. package/docs/functions/getCetusInvestorTicksMap.html +1 -1
  99. package/docs/functions/getCetusPool.html +1 -1
  100. package/docs/functions/getCetusSqrtPriceMap.html +1 -1
  101. package/docs/functions/getCoinAmountsFromLiquidity.html +1 -1
  102. package/docs/functions/getConf.html +1 -1
  103. package/docs/functions/getCurrentTick.html +1 -1
  104. package/docs/functions/getDistributor.html +1 -1
  105. package/docs/functions/getDoubleAssetVaultBalance.html +1 -1
  106. package/docs/functions/getDoubleAssetVaults.html +1 -1
  107. package/docs/functions/getInvestor.html +1 -1
  108. package/docs/functions/getInvestorPoolMap.html +1 -1
  109. package/docs/functions/getLastAutoCompoundTime.html +1 -1
  110. package/docs/functions/getLatestPrices.html +1 -1
  111. package/docs/functions/getLiquidity.html +1 -1
  112. package/docs/functions/getMultiCetusPool.html +1 -1
  113. package/docs/functions/getMultiInvestor.html +1 -1
  114. package/docs/functions/getMultiLatestPrices.html +1 -1
  115. package/docs/functions/getMultiParentPool.html +1 -1
  116. package/docs/functions/getMultiPool.html +1 -1
  117. package/docs/functions/getMultiReceipts.html +1 -1
  118. package/docs/functions/getParentPool.html +1 -1
  119. package/docs/functions/getPool.html +1 -1
  120. package/docs/functions/getPoolExchangeRate.html +1 -1
  121. package/docs/functions/getPoolExchangeRateMap.html +1 -1
  122. package/docs/functions/getPoolsWeightDistribution.html +1 -1
  123. package/docs/functions/getPositionRange.html +1 -1
  124. package/docs/functions/getPositionRanges.html +1 -1
  125. package/docs/functions/getPositionTicks.html +1 -1
  126. package/docs/functions/getPriceToTick.html +1 -1
  127. package/docs/functions/getRebalanceHistories.html +1 -1
  128. package/docs/functions/getRebalanceHistory.html +1 -1
  129. package/docs/functions/getReceipts.html +1 -1
  130. package/docs/functions/getSingleAssetVaultBalance.html +1 -1
  131. package/docs/functions/getSingleAssetVaults.html +1 -1
  132. package/docs/functions/getSuiClient.html +2 -2
  133. package/docs/functions/getSuiNodeUrl.html +2 -2
  134. package/docs/functions/getTVLs-1.html +1 -1
  135. package/docs/functions/getTickSpacing.html +1 -1
  136. package/docs/functions/getTickToPrice.html +1 -1
  137. package/docs/functions/getTvls.html +1 -1
  138. package/docs/functions/getVaultBalance.html +1 -1
  139. package/docs/functions/getVaults.html +1 -1
  140. package/docs/functions/getZapAmounts.html +1 -1
  141. package/docs/functions/lastAutocompoundTime.html +1 -1
  142. package/docs/functions/liquidityToTokens.html +1 -1
  143. package/docs/functions/migrateBoostedToLoop.html +1 -1
  144. package/docs/functions/multiLiquidityToTokens.html +1 -1
  145. package/docs/functions/multiTokensToUsd.html +1 -1
  146. package/docs/functions/multiXTokensToLiquidity.html +1 -1
  147. package/docs/functions/parseUserWalletData.html +1 -1
  148. package/docs/functions/pendingRewardAmount.html +1 -1
  149. package/docs/functions/setCustomSuiClient.html +2 -2
  150. package/docs/functions/setSuiClient.html +2 -2
  151. package/docs/functions/setSuiNodeUrl.html +2 -2
  152. package/docs/functions/setWeights.html +1 -1
  153. package/docs/functions/withdraw.html +1 -1
  154. package/docs/functions/withdrawAlphaTxb.html +1 -1
  155. package/docs/functions/withdrawTxb.html +1 -1
  156. package/docs/functions/zapDepositTxb.html +1 -1
  157. package/docs/index.html +2 -2
  158. package/docs/interfaces/Coin.html +6 -6
  159. package/docs/interfaces/CoinPair.html +2 -2
  160. package/docs/interfaces/CommonEventAttributes.html +2 -2
  161. package/docs/interfaces/NaviVoloData.html +2 -2
  162. package/docs/interfaces/PoolData.html +2 -2
  163. package/docs/interfaces/PoolWeightDistribution.html +2 -2
  164. package/docs/interfaces/RebalanceHistoryType.html +2 -2
  165. package/docs/modules.html +5 -2
  166. package/docs/types/AfterTransactionEventNode.html +1 -1
  167. package/docs/types/AirdropClaimEventNode.html +1 -1
  168. package/docs/types/Allocator.html +1 -1
  169. package/docs/types/AlphaFiDoubleAssetVault.html +1 -1
  170. package/docs/types/AlphaFiMultiVaultBalance.html +1 -1
  171. package/docs/types/AlphaFiSingleAssetVault.html +1 -1
  172. package/docs/types/AlphaFiVault.html +1 -1
  173. package/docs/types/AlphaFiVaultBalance.html +1 -1
  174. package/docs/types/AlphaLendInvestor.html +1 -1
  175. package/docs/types/AlphaPoolType.html +1 -1
  176. package/docs/types/AlphaReceipt.html +1 -1
  177. package/docs/types/AlphaReceiptFields.html +1 -1
  178. package/docs/types/AlphaVaultBalance.html +1 -1
  179. package/docs/types/AutoBalancePoolNames.html +1 -1
  180. package/docs/types/AutoCompoundingEventNode.html +1 -1
  181. package/docs/types/BluefinInvestor.html +1 -1
  182. package/docs/types/BluefinPoolType.html +1 -1
  183. package/docs/types/BucketInvestor.html +1 -1
  184. package/docs/types/CetusInvestor.html +1 -1
  185. package/docs/types/CetusPoolType.html +1 -1
  186. package/docs/types/CetusSwapOptions.html +1 -1
  187. package/docs/types/CoinAmounts.html +1 -1
  188. package/docs/types/CoinName.html +1 -1
  189. package/docs/types/CoinType.html +1 -1
  190. package/docs/types/CommonInvestorFields.html +1 -1
  191. package/docs/types/CreatePoolOptions.html +1 -1
  192. package/docs/types/Distributor.html +1 -1
  193. package/docs/types/DoubleAssetMultiVaultBalance.html +1 -1
  194. package/docs/types/DoubleAssetPoolNames.html +1 -1
  195. package/docs/types/DoubleAssetTokenHoldings.html +1 -1
  196. package/docs/types/DoubleAssetVaultBalance.html +1 -1
  197. package/docs/types/EventCategory.html +1 -1
  198. package/docs/types/EventNode.html +1 -1
  199. package/docs/types/GetHoldersParams.html +1 -1
  200. package/docs/types/GetTokenHoldingsParams.html +1 -1
  201. package/docs/types/GetUserTokensFromTransactionsParams.html +1 -1
  202. package/docs/types/GetUserTokensInUsdFromTransactionsParams.html +1 -1
  203. package/docs/types/GetVaultBalanceParams.html +1 -1
  204. package/docs/types/HoldingsObj.html +1 -1
  205. package/docs/types/Icon.html +1 -1
  206. package/docs/types/Investor.html +1 -1
  207. package/docs/types/LiquidityChangeEventNode.html +1 -1
  208. package/docs/types/LiquidityToTokensParams.html +1 -1
  209. package/docs/types/LiquidityToUsdParams.html +1 -1
  210. package/docs/types/LoopingDebt.html +1 -1
  211. package/docs/types/LoopingPoolNames.html +1 -1
  212. package/docs/types/LpBreakdownType.html +1 -1
  213. package/docs/types/MemberPoolDataType.html +1 -1
  214. package/docs/types/MemberType.html +1 -1
  215. package/docs/types/MultiGetVaultBalancesParams.html +1 -1
  216. package/docs/types/NaviInvestor.html +1 -1
  217. package/docs/types/OtherReceiptFields.html +1 -1
  218. package/docs/types/PoolName.html +1 -1
  219. package/docs/types/PoolReceipt.html +1 -1
  220. package/docs/types/PoolType.html +1 -1
  221. package/docs/types/Receipt.html +1 -1
  222. package/docs/types/ReceiptGQL.html +1 -1
  223. package/docs/types/SingleAssetMultiVaultBalance.html +1 -1
  224. package/docs/types/SingleAssetPoolNames.html +1 -1
  225. package/docs/types/SingleAssetTokenHoldings.html +1 -1
  226. package/docs/types/SingleAssetVaultBalance.html +1 -1
  227. package/docs/types/SingleGetVaultBalancesParams.html +1 -1
  228. package/docs/types/StrategyType.html +1 -1
  229. package/docs/types/SuiNetwork.html +1 -1
  230. package/docs/types/SwapOptions.html +1 -1
  231. package/docs/types/TickSpacing.html +1 -1
  232. package/docs/types/TotalWeightType.html +1 -1
  233. package/docs/types/TransactionBlockType.html +1 -1
  234. package/docs/types/UserPoolLiquidity.html +1 -1
  235. package/docs/types/UserPoolTokenHoldings.html +1 -1
  236. package/docs/types/UserUsdHoldings.html +1 -1
  237. package/docs/types/VaultBalance.html +1 -1
  238. package/docs/types/VoteCastEvent.html +1 -1
  239. package/docs/types/WithdrawV2EventNode.html +1 -1
  240. package/docs/variables/AUTOBALANCE_SUI_FIRST_POOLS.html +1 -0
  241. package/docs/variables/AUTOBALANCE_SUI_SECOND_POOLS.html +1 -0
  242. package/docs/variables/AUTOBALANCE_TYPE_1_POOLS.html +1 -0
  243. package/docs/variables/alphalendMarketIdMap.html +1 -1
  244. package/docs/variables/bluefinPoolMap.html +1 -1
  245. package/docs/variables/cetusPoolMap.html +1 -1
  246. package/docs/variables/coinsList.html +1 -1
  247. package/docs/variables/defunctPoolsSet.html +1 -1
  248. package/docs/variables/doubleAssetPoolCoinMap.html +1 -1
  249. package/docs/variables/eventCategories.html +1 -1
  250. package/docs/variables/ignoredWalletsForDailyRevenue.html +1 -1
  251. package/docs/variables/loopingAccountAddresses.html +1 -1
  252. package/docs/variables/loopingPoolCoinMap.html +1 -1
  253. package/docs/variables/naviAssetMap.html +1 -1
  254. package/docs/variables/poolIdPoolNameMap.html +1 -1
  255. package/docs/variables/poolInfo.html +1 -1
  256. package/docs/variables/singleAssetPoolCoinMap.html +1 -1
  257. package/docs/variables/stableCoins.html +1 -1
  258. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import { Decimal } from "decimal.js";
2
- import { getConf, poolInfo, coinsList, getPool, doubleAssetPoolCoinMap, getParentPool, } from "../index.js";
2
+ import { getConf, poolInfo, coinsList, getPool, doubleAssetPoolCoinMap, getParentPool, AUTOBALANCE_TYPE_1_POOLS, } from "../index.js";
3
3
  import { Transaction } from "@mysten/sui/transactions";
4
- import { coinTypeMap } from "../common/maps.js";
4
+ import { AUTOBALANCE_SUI_FIRST_POOLS, AUTOBALANCE_SUI_SECOND_POOLS, coinTypeMap, } from "../common/maps.js";
5
5
  export async function collectRewardTxb(poolName, ignoreCache, tx) {
6
6
  let txb;
7
7
  if (tx) {
@@ -14,8 +14,7 @@ export async function collectRewardTxb(poolName, ignoreCache, tx) {
14
14
  const pool = poolInfo[poolName];
15
15
  const coin1 = doubleAssetPoolCoinMap[poolName].coin1;
16
16
  const coin2 = doubleAssetPoolCoinMap[poolName].coin2;
17
- if (poolName === "BLUEFIN-AUTOBALANCE-SUI-USDC" ||
18
- poolName === "BLUEFIN-AUTOBALANCE-SUI-LBTC") {
17
+ if (AUTOBALANCE_SUI_FIRST_POOLS.includes(poolName)) {
19
18
  for (const reward of bluefinPool.content.fields.reward_infos) {
20
19
  const rewardType = "0x" + reward.fields.reward_coin_type;
21
20
  txb.moveCall({
@@ -37,8 +36,7 @@ export async function collectRewardTxb(poolName, ignoreCache, tx) {
37
36
  });
38
37
  }
39
38
  }
40
- else if (poolName === "BLUEFIN-AUTOBALANCE-BLUE-SUI" ||
41
- poolName === "BLUEFIN-AUTOBALANCE-DEEP-SUI") {
39
+ else if (AUTOBALANCE_SUI_SECOND_POOLS.includes(poolName)) {
42
40
  for (const reward of bluefinPool.content.fields.reward_infos) {
43
41
  const rewardType = "0x" + reward.fields.reward_coin_type;
44
42
  txb.moveCall({
@@ -60,7 +58,7 @@ export async function collectRewardTxb(poolName, ignoreCache, tx) {
60
58
  });
61
59
  }
62
60
  }
63
- else {
61
+ else if (AUTOBALANCE_TYPE_1_POOLS.includes(poolName)) {
64
62
  for (const reward of bluefinPool.content.fields.reward_infos) {
65
63
  const rewardType = "0x" + reward.fields.reward_coin_type;
66
64
  txb.moveCall({
@@ -94,10 +92,14 @@ export async function claimRewardsTxb(userAddress, poolName) {
94
92
  const coin1 = doubleAssetPoolCoinMap[poolName].coin1;
95
93
  const coin2 = doubleAssetPoolCoinMap[poolName].coin2;
96
94
  const rewards = [];
97
- if (poolName === "BLUEFIN-AUTOBALANCE-SUI-LBTC" ||
98
- poolName === "BLUEFIN-AUTOBALANCE-SUI-USDC") {
99
- for (const reward of bluefinPool.content.fields.reward_infos) {
100
- const rewardType = "0x" + reward.fields.reward_coin_type;
95
+ const rewardsList = bluefinPool.content.fields.reward_infos.map((ele) => {
96
+ return "0x" + ele.fields.reward_coin_type;
97
+ });
98
+ rewardsList.push(coinsList[coin1].type.substring(2));
99
+ rewardsList.push(coinsList[coin2].type.substring(2));
100
+ console.log(rewardsList);
101
+ if (AUTOBALANCE_SUI_FIRST_POOLS.includes(poolName)) {
102
+ for (const rewardType of [...new Set(rewardsList)]) {
101
103
  const balance = txb.moveCall({
102
104
  target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
103
105
  typeArguments: [
@@ -123,59 +125,9 @@ export async function claimRewardsTxb(userAddress, poolName) {
123
125
  });
124
126
  rewards.push(coin);
125
127
  }
126
- const tBalance = txb.moveCall({
127
- target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
128
- typeArguments: [
129
- coinsList[coin1].type,
130
- coinsList[coin2].type,
131
- coinsList[coin1].type,
132
- ],
133
- arguments: [
134
- txb.object(receipts[0].objectId),
135
- txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
136
- txb.object(pool.poolId),
137
- txb.object(pool.investorId),
138
- txb.object(getConf().ALPHA_DISTRIBUTOR),
139
- txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
140
- txb.object(pool.parentPoolId),
141
- txb.object(getConf().CLOCK_PACKAGE_ID),
142
- ],
143
- });
144
- const sBalance = txb.moveCall({
145
- target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,
146
- typeArguments: [
147
- coinsList[coin1].type,
148
- coinsList[coin2].type,
149
- coinsList[coin2].type,
150
- ],
151
- arguments: [
152
- txb.object(receipts[0].objectId),
153
- txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
154
- txb.object(pool.poolId),
155
- txb.object(pool.investorId),
156
- txb.object(getConf().ALPHA_DISTRIBUTOR),
157
- txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
158
- txb.object(pool.parentPoolId),
159
- txb.object(getConf().CLOCK_PACKAGE_ID),
160
- ],
161
- });
162
- const tCoin = txb.moveCall({
163
- target: "0x2::coin::from_balance",
164
- typeArguments: [coinsList[coin1].type],
165
- arguments: [tBalance],
166
- });
167
- const sCoin = txb.moveCall({
168
- target: "0x2::coin::from_balance",
169
- typeArguments: [coinsList[coin2].type],
170
- arguments: [sBalance],
171
- });
172
- rewards.push(tCoin);
173
- rewards.push(sCoin);
174
128
  }
175
- else if (poolName === "BLUEFIN-AUTOBALANCE-BLUE-SUI" ||
176
- poolName === "BLUEFIN-AUTOBALANCE-DEEP-SUI") {
177
- for (const reward of bluefinPool.content.fields.reward_infos) {
178
- const rewardType = "0x" + reward.fields.reward_coin_type;
129
+ else if (AUTOBALANCE_SUI_SECOND_POOLS.includes(poolName)) {
130
+ for (const rewardType of [...new Set(rewardsList)]) {
179
131
  const balance = txb.moveCall({
180
132
  target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v3`,
181
133
  typeArguments: [
@@ -201,58 +153,9 @@ export async function claimRewardsTxb(userAddress, poolName) {
201
153
  });
202
154
  rewards.push(coin);
203
155
  }
204
- const tBalance = txb.moveCall({
205
- target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v3`,
206
- typeArguments: [
207
- coinsList[coin1].type,
208
- coinsList[coin2].type,
209
- coinsList[coin1].type,
210
- ],
211
- arguments: [
212
- txb.object(receipts[0].objectId),
213
- txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
214
- txb.object(pool.poolId),
215
- txb.object(pool.investorId),
216
- txb.object(getConf().ALPHA_DISTRIBUTOR),
217
- txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
218
- txb.object(pool.parentPoolId),
219
- txb.object(getConf().CLOCK_PACKAGE_ID),
220
- ],
221
- });
222
- const sBalance = txb.moveCall({
223
- target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v3`,
224
- typeArguments: [
225
- coinsList[coin1].type,
226
- coinsList[coin2].type,
227
- coinsList[coin2].type,
228
- ],
229
- arguments: [
230
- txb.object(receipts[0].objectId),
231
- txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
232
- txb.object(pool.poolId),
233
- txb.object(pool.investorId),
234
- txb.object(getConf().ALPHA_DISTRIBUTOR),
235
- txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
236
- txb.object(pool.parentPoolId),
237
- txb.object(getConf().CLOCK_PACKAGE_ID),
238
- ],
239
- });
240
- const tCoin = txb.moveCall({
241
- target: "0x2::coin::from_balance",
242
- typeArguments: [coinsList[coin1].type],
243
- arguments: [tBalance],
244
- });
245
- const sCoin = txb.moveCall({
246
- target: "0x2::coin::from_balance",
247
- typeArguments: [coinsList[coin2].type],
248
- arguments: [sBalance],
249
- });
250
- rewards.push(tCoin);
251
- rewards.push(sCoin);
252
156
  }
253
- else {
254
- for (const reward of bluefinPool.content.fields.reward_infos) {
255
- const rewardType = "0x" + reward.fields.reward_coin_type;
157
+ else if (AUTOBALANCE_TYPE_1_POOLS.includes(poolName)) {
158
+ for (const rewardType of [...new Set(rewardsList)]) {
256
159
  const balance = txb.moveCall({
257
160
  target: `${pool.packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v3`,
258
161
  typeArguments: [
@@ -278,54 +181,6 @@ export async function claimRewardsTxb(userAddress, poolName) {
278
181
  });
279
182
  rewards.push(coin);
280
183
  }
281
- const tBalance = txb.moveCall({
282
- target: `${pool.packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v3`,
283
- typeArguments: [
284
- coinsList[coin1].type,
285
- coinsList[coin2].type,
286
- coinsList[coin1].type,
287
- ],
288
- arguments: [
289
- txb.object(receipts[0].objectId),
290
- txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
291
- txb.object(pool.poolId),
292
- txb.object(pool.investorId),
293
- txb.object(getConf().ALPHA_DISTRIBUTOR),
294
- txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
295
- txb.object(pool.parentPoolId),
296
- txb.object(getConf().CLOCK_PACKAGE_ID),
297
- ],
298
- });
299
- const sBalance = txb.moveCall({
300
- target: `${pool.packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v3`,
301
- typeArguments: [
302
- coinsList[coin1].type,
303
- coinsList[coin2].type,
304
- coinsList[coin2].type,
305
- ],
306
- arguments: [
307
- txb.object(receipts[0].objectId),
308
- txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
309
- txb.object(pool.poolId),
310
- txb.object(pool.investorId),
311
- txb.object(getConf().ALPHA_DISTRIBUTOR),
312
- txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
313
- txb.object(pool.parentPoolId),
314
- txb.object(getConf().CLOCK_PACKAGE_ID),
315
- ],
316
- });
317
- const tCoin = txb.moveCall({
318
- target: "0x2::coin::from_balance",
319
- typeArguments: [coinsList[coin1].type],
320
- arguments: [tBalance],
321
- });
322
- const sCoin = txb.moveCall({
323
- target: "0x2::coin::from_balance",
324
- typeArguments: [coinsList[coin2].type],
325
- arguments: [sBalance],
326
- });
327
- rewards.push(tCoin);
328
- rewards.push(sCoin);
329
184
  }
330
185
  return { txb: txb, coinOut: rewards };
331
186
  }
@@ -1 +1 @@
1
- {"version":3,"file":"blueRewards.js","sourceRoot":"","sources":["../../../src/transactions/blueRewards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EACL,OAAO,EACP,QAAQ,EACR,SAAS,EAET,OAAO,EACP,sBAAsB,EACtB,aAAa,GAEd,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAqB,MAAM,0BAA0B,CAAC;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKhD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,QAAkB,EAClB,WAAoB,EACpB,EAAgB;IAEhB,IAAI,GAA2C,CAAC;IAChD,IAAI,EAAE,EAAE,CAAC;QACP,GAAG,GAAG,EAAE,CAAC;IACX,CAAC;SAAM,CAAC;QACN,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;IAC1B,CAAC;IACD,MAAM,WAAW,GAAG,CAAC,MAAM,aAAa,CACtC,QAAQ,EACR,WAAW,CACZ,CAAoB,CAAC;IACtB,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,KAAK,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;IACrD,MAAM,KAAK,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;IACrD,IACE,QAAQ,KAAK,8BAA8B;QAC3C,QAAQ,KAAK,8BAA8B,EAC3C,CAAC;QACD,KAAK,MAAM,MAAM,IAAI,WAAW,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAC7D,MAAM,UAAU,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC;YACzD,GAAG,CAAC,QAAQ,CAAC;gBACX,MAAM,EAAE,GAA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AAC,CAAC,CAAC;QAC5D,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC","sourcesContent":["import { Decimal } from \"decimal.js\";\nimport {\n getConf,\n poolInfo,\n coinsList,\n PoolName,\n getPool,\n doubleAssetPoolCoinMap,\n getParentPool,\n BluefinPoolType,\n} from \"../index.js\";\nimport { Transaction, TransactionResult } from \"@mysten/sui/transactions\";\nimport { UserAutoBalanceRewardAmounts } from \"./types.js\";\nimport { coinTypeMap } from \"../common/maps.js\";\nexport interface ClaimRewardResponse {\n txb: Transaction;\n coinOut: TransactionResult[];\n}\nexport async function collectRewardTxb(\n poolName: PoolName,\n ignoreCache: boolean,\n tx?: Transaction,\n): Promise<Transaction> {\n let txb: Transaction | PromiseLike<Transaction>;\n if (tx) {\n txb = tx;\n } else {\n txb = new Transaction();\n }\n const bluefinPool = (await getParentPool(\n poolName,\n ignoreCache,\n )) as BluefinPoolType;\n const pool = poolInfo[poolName];\n const coin1 = doubleAssetPoolCoinMap[poolName].coin1;\n const coin2 = doubleAssetPoolCoinMap[poolName].coin2;\n if (\n poolName === \"BLUEFIN-AUTOBALANCE-SUI-USDC\" ||\n poolName === \"BLUEFIN-AUTOBALANCE-SUI-LBTC\"\n ) {\n for (const reward of bluefinPool.content.fields.reward_infos) {\n const rewardType = \"0x\" + reward.fields.reward_coin_type;\n txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::collect_reward`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n rewardType,\n ],\n arguments: [\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n }\n } else if (\n poolName === \"BLUEFIN-AUTOBALANCE-BLUE-SUI\" ||\n poolName === \"BLUEFIN-AUTOBALANCE-DEEP-SUI\"\n ) {\n for (const reward of bluefinPool.content.fields.reward_infos) {\n const rewardType = \"0x\" + reward.fields.reward_coin_type;\n txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::collect_reward`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n rewardType,\n ],\n arguments: [\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n }\n } else {\n for (const reward of bluefinPool.content.fields.reward_infos) {\n const rewardType = \"0x\" + reward.fields.reward_coin_type;\n txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_type_1_pool::collect_reward`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n rewardType,\n ],\n arguments: [\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n }\n }\n return txb;\n}\nexport async function claimRewardsTxb(\n userAddress: string,\n poolName: PoolName,\n): Promise<ClaimRewardResponse | undefined> {\n const { getReceipts } = await import(\"../index.js\");\n try {\n const receipts = await getReceipts(poolName, userAddress, true);\n const txb = await collectRewardTxb(poolName, true); //false for now\n const bluefinPool = (await getParentPool(\n poolName,\n false,\n )) as BluefinPoolType;\n const pool = poolInfo[poolName];\n const coin1 = doubleAssetPoolCoinMap[poolName].coin1;\n const coin2 = doubleAssetPoolCoinMap[poolName].coin2;\n const rewards: TransactionResult[] = [];\n if (\n poolName === \"BLUEFIN-AUTOBALANCE-SUI-LBTC\" ||\n poolName === \"BLUEFIN-AUTOBALANCE-SUI-USDC\"\n ) {\n for (const reward of bluefinPool.content.fields.reward_infos) {\n const rewardType = \"0x\" + reward.fields.reward_coin_type;\n const balance = txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n rewardType,\n ],\n arguments: [\n txb.object(receipts[0].objectId),\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n const coin = txb.moveCall({\n target: \"0x2::coin::from_balance\",\n typeArguments: [rewardType],\n arguments: [balance!],\n });\n rewards.push(coin);\n }\n const tBalance = txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n coinsList[coin1].type,\n ],\n arguments: [\n txb.object(receipts[0].objectId),\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n const sBalance = txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n coinsList[coin2].type,\n ],\n arguments: [\n txb.object(receipts[0].objectId),\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n const tCoin = txb.moveCall({\n target: \"0x2::coin::from_balance\",\n typeArguments: [coinsList[coin1].type],\n arguments: [tBalance!],\n });\n const sCoin = txb.moveCall({\n target: \"0x2::coin::from_balance\",\n typeArguments: [coinsList[coin2].type],\n arguments: [sBalance!],\n });\n rewards.push(tCoin);\n rewards.push(sCoin);\n } else if (\n poolName === \"BLUEFIN-AUTOBALANCE-BLUE-SUI\" ||\n poolName === \"BLUEFIN-AUTOBALANCE-DEEP-SUI\"\n ) {\n for (const reward of bluefinPool.content.fields.reward_infos) {\n const rewardType = \"0x\" + reward.fields.reward_coin_type;\n const balance = txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v3`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n rewardType,\n ],\n arguments: [\n txb.object(receipts[0].objectId),\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n const coin = txb.moveCall({\n target: \"0x2::coin::from_balance\",\n typeArguments: [rewardType],\n arguments: [balance!],\n });\n rewards.push(coin);\n }\n const tBalance = txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v3`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n coinsList[coin1].type,\n ],\n arguments: [\n txb.object(receipts[0].objectId),\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n const sBalance = txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v3`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n coinsList[coin2].type,\n ],\n arguments: [\n txb.object(receipts[0].objectId),\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n const tCoin = txb.moveCall({\n target: \"0x2::coin::from_balance\",\n typeArguments: [coinsList[coin1].type],\n arguments: [tBalance!],\n });\n const sCoin = txb.moveCall({\n target: \"0x2::coin::from_balance\",\n typeArguments: [coinsList[coin2].type],\n arguments: [sBalance!],\n });\n rewards.push(tCoin);\n rewards.push(sCoin);\n } else {\n for (const reward of bluefinPool.content.fields.reward_infos) {\n const rewardType = \"0x\" + reward.fields.reward_coin_type;\n const balance = txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v3`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n rewardType,\n ],\n arguments: [\n txb.object(receipts[0].objectId),\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n const coin = txb.moveCall({\n target: \"0x2::coin::from_balance\",\n typeArguments: [rewardType],\n arguments: [balance!],\n });\n rewards.push(coin);\n }\n const tBalance = txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v3`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n coinsList[coin1].type,\n ],\n arguments: [\n txb.object(receipts[0].objectId),\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n const sBalance = txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v3`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n coinsList[coin2].type,\n ],\n arguments: [\n txb.object(receipts[0].objectId),\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n const tCoin = txb.moveCall({\n target: \"0x2::coin::from_balance\",\n typeArguments: [coinsList[coin1].type],\n arguments: [tBalance!],\n });\n const sCoin = txb.moveCall({\n target: \"0x2::coin::from_balance\",\n typeArguments: [coinsList[coin2].type],\n arguments: [sBalance!],\n });\n rewards.push(tCoin);\n rewards.push(sCoin);\n }\n return { txb: txb, coinOut: rewards };\n } catch (e) {\n console.error(\"error in claim blue rewards\", e);\n }\n}\n\nexport async function pendingRewardAmount(\n userAddress: string,\n poolName: PoolName,\n): Promise<UserAutoBalanceRewardAmounts> {\n const { getReceipts } = await import(\"../index.js\");\n try {\n const receipts = await getReceipts(poolName, userAddress, true);\n const receipt = receipts[0];\n const userXtokenBalance = receipt.content.fields.xTokenBalance;\n const totalPendingRewardAmounts: UserAutoBalanceRewardAmounts = {};\n const userPendingReward: { [key in string]: string } = {};\n const curAcc: { [key in string]: string } = {};\n const lastAcc: { [key in string]: string } = {};\n const userPendingRewardsAll =\n receipt.content.fields.pending_rewards.fields.contents;\n for (let i = 0; i < userPendingRewardsAll.length; i++) {\n userPendingReward[\n \"0x\" + userPendingRewardsAll[i].fields.key.fields.name\n ] = userPendingRewardsAll[i].fields.value;\n }\n const pool = await getPool(poolName, false);\n const currAccForAllRewards =\n pool!.content.fields.acc_rewards_per_xtoken.fields.contents;\n currAccForAllRewards?.forEach((reward) => {\n curAcc[\"0x\" + reward.fields.key.fields.name] = reward.fields.value;\n });\n const lastAccAll =\n receipt.content.fields.last_acc_reward_per_xtoken.fields.contents;\n lastAccAll.forEach((reward) => {\n lastAcc[\"0x\" + reward.fields.key.fields.name] = reward.fields.value;\n });\n const coinTypeToCoin = coinTypeMap;\n Object.keys(curAcc).forEach((type) => {\n if (!coinTypeToCoin[type]) {\n console.error(\"coin not present\", type);\n return;\n }\n const cur = new Decimal(curAcc[type]);\n const last = new Decimal(type in lastAcc ? lastAcc[type] : \"0\");\n const pending = new Decimal(\n type in userPendingReward ? userPendingReward[type] : \"0\",\n );\n\n const totalPending = cur\n .minus(last)\n .mul(userXtokenBalance)\n .div(1e36)\n .plus(pending)\n .div(Math.pow(10, coinsList[coinTypeToCoin[type]].expo))\n .toString();\n totalPendingRewardAmounts[type] = totalPending.toString();\n });\n return totalPendingRewardAmounts;\n } catch (e) {\n console.error(\"error in calculate pending blue rewards\", e);\n return {};\n }\n}\n"]}
1
+ {"version":3,"file":"blueRewards.js","sourceRoot":"","sources":["../../../src/transactions/blueRewards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EACL,OAAO,EACP,QAAQ,EACR,SAAS,EAET,OAAO,EACP,sBAAsB,EACtB,aAAa,EAEb,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAqB,M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Info,\n coinsList,\n PoolName,\n getPool,\n doubleAssetPoolCoinMap,\n getParentPool,\n BluefinPoolType,\n AUTOBALANCE_TYPE_1_POOLS,\n} from \"../index.js\";\nimport { Transaction, TransactionResult } from \"@mysten/sui/transactions\";\nimport { UserAutoBalanceRewardAmounts } from \"./types.js\";\nimport {\n AUTOBALANCE_SUI_FIRST_POOLS,\n AUTOBALANCE_SUI_SECOND_POOLS,\n coinTypeMap,\n} from \"../common/maps.js\";\nexport interface ClaimRewardResponse {\n txb: Transaction;\n coinOut: TransactionResult[];\n}\nexport async function collectRewardTxb(\n poolName: PoolName,\n ignoreCache: boolean,\n tx?: Transaction,\n): Promise<Transaction> {\n let txb: Transaction | PromiseLike<Transaction>;\n if (tx) {\n txb = tx;\n } else {\n txb = new Transaction();\n }\n const bluefinPool = (await getParentPool(\n poolName,\n ignoreCache,\n )) as BluefinPoolType;\n const pool = poolInfo[poolName];\n const coin1 = doubleAssetPoolCoinMap[poolName].coin1;\n const coin2 = doubleAssetPoolCoinMap[poolName].coin2;\n if (AUTOBALANCE_SUI_FIRST_POOLS.includes(poolName)) {\n for (const reward of bluefinPool.content.fields.reward_infos) {\n const rewardType = \"0x\" + reward.fields.reward_coin_type;\n txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::collect_reward`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n rewardType,\n ],\n arguments: [\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n }\n } else if (AUTOBALANCE_SUI_SECOND_POOLS.includes(poolName)) {\n for (const reward of bluefinPool.content.fields.reward_infos) {\n const rewardType = \"0x\" + reward.fields.reward_coin_type;\n txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::collect_reward`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n rewardType,\n ],\n arguments: [\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n }\n } else if (AUTOBALANCE_TYPE_1_POOLS.includes(poolName)) {\n for (const reward of bluefinPool.content.fields.reward_infos) {\n const rewardType = \"0x\" + reward.fields.reward_coin_type;\n txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_type_1_pool::collect_reward`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n rewardType,\n ],\n arguments: [\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n }\n }\n return txb;\n}\nexport async function claimRewardsTxb(\n userAddress: string,\n poolName: PoolName,\n): Promise<ClaimRewardResponse | undefined> {\n const { getReceipts } = await import(\"../index.js\");\n try {\n const receipts = await getReceipts(poolName, userAddress, true);\n const txb = await collectRewardTxb(poolName, true); //false for now\n const bluefinPool = (await getParentPool(\n poolName,\n false,\n )) as BluefinPoolType;\n const pool = poolInfo[poolName];\n const coin1 = doubleAssetPoolCoinMap[poolName].coin1;\n const coin2 = doubleAssetPoolCoinMap[poolName].coin2;\n const rewards: TransactionResult[] = [];\n const rewardsList = bluefinPool.content.fields.reward_infos.map((ele) => {\n return \"0x\" + ele.fields.reward_coin_type;\n });\n rewardsList.push(coinsList[coin1].type.substring(2));\n rewardsList.push(coinsList[coin2].type.substring(2));\n console.log(rewardsList);\n\n if (AUTOBALANCE_SUI_FIRST_POOLS.includes(poolName)) {\n for (const rewardType of [...new Set(rewardsList)]) {\n const balance = txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_sui_first_pool::get_user_rewards_v4`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n rewardType,\n ],\n arguments: [\n txb.object(receipts[0].objectId),\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n const coin = txb.moveCall({\n target: \"0x2::coin::from_balance\",\n typeArguments: [rewardType],\n arguments: [balance!],\n });\n rewards.push(coin);\n }\n } else if (AUTOBALANCE_SUI_SECOND_POOLS.includes(poolName)) {\n for (const rewardType of [...new Set(rewardsList)]) {\n const balance = txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_sui_second_pool::get_user_rewards_v3`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n rewardType,\n ],\n arguments: [\n txb.object(receipts[0].objectId),\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n const coin = txb.moveCall({\n target: \"0x2::coin::from_balance\",\n typeArguments: [rewardType],\n arguments: [balance!],\n });\n rewards.push(coin);\n }\n } else if (AUTOBALANCE_TYPE_1_POOLS.includes(poolName)) {\n for (const rewardType of [...new Set(rewardsList)]) {\n const balance = txb.moveCall({\n target: `${pool.packageId}::alphafi_bluefin_type_1_pool::get_user_rewards_v3`,\n typeArguments: [\n coinsList[coin1].type,\n coinsList[coin2].type,\n rewardType,\n ],\n arguments: [\n txb.object(receipts[0].objectId),\n txb.object(getConf().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),\n txb.object(pool.poolId),\n txb.object(pool.investorId),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),\n txb.object(pool.parentPoolId),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n const coin = txb.moveCall({\n target: \"0x2::coin::from_balance\",\n typeArguments: [rewardType],\n arguments: [balance!],\n });\n rewards.push(coin);\n }\n }\n return { txb: txb, coinOut: rewards };\n } catch (e) {\n console.error(\"error in claim blue rewards\", e);\n }\n}\n\nexport async function pendingRewardAmount(\n userAddress: string,\n poolName: PoolName,\n): Promise<UserAutoBalanceRewardAmounts> {\n const { getReceipts } = await import(\"../index.js\");\n try {\n const receipts = await getReceipts(poolName, userAddress, true);\n const receipt = receipts[0];\n const userXtokenBalance = receipt.content.fields.xTokenBalance;\n const totalPendingRewardAmounts: UserAutoBalanceRewardAmounts = {};\n const userPendingReward: { [key in string]: string } = {};\n const curAcc: { [key in string]: string } = {};\n const lastAcc: { [key in string]: string } = {};\n const userPendingRewardsAll =\n receipt.content.fields.pending_rewards.fields.contents;\n for (let i = 0; i < userPendingRewardsAll.length; i++) {\n userPendingReward[\n \"0x\" + userPendingRewardsAll[i].fields.key.fields.name\n ] = userPendingRewardsAll[i].fields.value;\n }\n const pool = await getPool(poolName, false);\n const currAccForAllRewards =\n pool!.content.fields.acc_rewards_per_xtoken.fields.contents;\n currAccForAllRewards?.forEach((reward) => {\n curAcc[\"0x\" + reward.fields.key.fields.name] = reward.fields.value;\n });\n const lastAccAll =\n receipt.content.fields.last_acc_reward_per_xtoken.fields.contents;\n lastAccAll.forEach((reward) => {\n lastAcc[\"0x\" + reward.fields.key.fields.name] = reward.fields.value;\n });\n const coinTypeToCoin = coinTypeMap;\n Object.keys(curAcc).forEach((type) => {\n if (!coinTypeToCoin[type]) {\n console.error(\"coin not present\", type);\n return;\n }\n const cur = new Decimal(curAcc[type]);\n const last = new Decimal(type in lastAcc ? lastAcc[type] : \"0\");\n const pending = new Decimal(\n type in userPendingReward ? userPendingReward[type] : \"0\",\n );\n\n const totalPending = cur\n .minus(last)\n .mul(userXtokenBalance)\n .div(1e36)\n .plus(pending)\n .div(Math.pow(10, coinsList[coinTypeToCoin[type]].expo))\n .toString();\n totalPendingRewardAmounts[type] = totalPending.toString();\n });\n return totalPendingRewardAmounts;\n } catch (e) {\n console.error(\"error in calculate pending blue rewards\", e);\n return {};\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"bluefin.d.ts","sourceRoot":"","sources":["../../../src/transactions/bluefin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAUlC,OAAO,EAAE,QAAQ,EAAW,MAAM,oBAAoB,CAAC;AAMvD,eAAO,MAAM,yBAAyB,WAC5B,MAAM,YACJ,QAAQ,aACP,OAAO,WACT;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,gBACf,WAAW,GAAG,SAAS,KACnC,OAAO,CAAC,WAAW,CAoMrB,CAAC;AAEF,eAAO,MAAM,0BAA0B,WAC7B,MAAM,YACJ,QAAQ,aACP,OAAO,WACT;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,gBACf,WAAW,GAAG,SAAS,KACnC,OAAO,CAAC,WAAW,CA6NrB,CAAC;AAEF,eAAO,MAAM,sBAAsB,WACzB,MAAM,YACJ,QAAQ,aACP,OAAO,WACT;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,gBACf,WAAW,GAAG,SAAS,KACnC,OAAO,CAAC,WAAW,CA0mBrB,CAAC;AAEF,eAAO,MAAM,sBAAsB,WACzB,MAAM,YACJ,QAAQ,aACP,OAAO,WACT;IAAE,OAAO,EAAE,MAAM,CAAA;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