@alphafi/alphafi-sdk 0.0.66 → 0.0.68

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 (323) hide show
  1. package/dist/cjs/common/coins.d.ts.map +1 -1
  2. package/dist/cjs/common/coins.js +13 -1
  3. package/dist/cjs/common/coins.js.map +1 -1
  4. package/dist/cjs/common/constants.d.ts +235 -0
  5. package/dist/cjs/common/constants.d.ts.map +1 -1
  6. package/dist/cjs/common/constants.js +203 -20
  7. package/dist/cjs/common/constants.js.map +1 -1
  8. package/dist/cjs/common/maps.d.ts +7 -0
  9. package/dist/cjs/common/maps.d.ts.map +1 -1
  10. package/dist/cjs/common/maps.js +184 -1
  11. package/dist/cjs/common/maps.js.map +1 -1
  12. package/dist/cjs/common/pyth.d.ts +1 -1
  13. package/dist/cjs/common/pyth.d.ts.map +1 -1
  14. package/dist/cjs/common/pyth.js.map +1 -1
  15. package/dist/cjs/common/types.d.ts +17 -3
  16. package/dist/cjs/common/types.d.ts.map +1 -1
  17. package/dist/cjs/common/types.js.map +1 -1
  18. package/dist/cjs/index.d.ts +1 -0
  19. package/dist/cjs/index.d.ts.map +1 -1
  20. package/dist/cjs/index.js +3 -1
  21. package/dist/cjs/index.js.map +1 -1
  22. package/dist/cjs/sui-sdk/functions/getPortfolioAmounts.d.ts.map +1 -1
  23. package/dist/cjs/sui-sdk/functions/getPortfolioAmounts.js +17 -2
  24. package/dist/cjs/sui-sdk/functions/getPortfolioAmounts.js.map +1 -1
  25. package/dist/cjs/sui-sdk/transactions/fetchTransactions.d.ts.map +1 -1
  26. package/dist/cjs/sui-sdk/transactions/fetchTransactions.js +21 -5
  27. package/dist/cjs/sui-sdk/transactions/fetchTransactions.js.map +1 -1
  28. package/dist/cjs/sui-sdk/transactions/types.d.ts +2 -1
  29. package/dist/cjs/sui-sdk/transactions/types.d.ts.map +1 -1
  30. package/dist/cjs/sui-sdk/transactions/types.js.map +1 -1
  31. package/dist/cjs/transactions/alpha.js +2 -2
  32. package/dist/cjs/transactions/alpha.js.map +1 -1
  33. package/dist/cjs/transactions/bluefin.d.ts +6 -0
  34. package/dist/cjs/transactions/bluefin.d.ts.map +1 -1
  35. package/dist/cjs/transactions/bluefin.js +153 -1
  36. package/dist/cjs/transactions/bluefin.js.map +1 -1
  37. package/dist/cjs/transactions/deposit.d.ts +3 -3
  38. package/dist/cjs/transactions/deposit.d.ts.map +1 -1
  39. package/dist/cjs/transactions/deposit.js +25 -21
  40. package/dist/cjs/transactions/deposit.js.map +1 -1
  41. package/dist/cjs/transactions/navi-looping.d.ts.map +1 -1
  42. package/dist/cjs/transactions/navi-looping.js +865 -73
  43. package/dist/cjs/transactions/navi-looping.js.map +1 -1
  44. package/dist/cjs/transactions/navi.d.ts.map +1 -1
  45. package/dist/cjs/transactions/navi.js +1556 -191
  46. package/dist/cjs/transactions/navi.js.map +1 -1
  47. package/dist/cjs/transactions/naviOracle.d.ts +3 -0
  48. package/dist/cjs/transactions/naviOracle.d.ts.map +1 -0
  49. package/dist/cjs/transactions/naviOracle.js +18 -0
  50. package/dist/cjs/transactions/naviOracle.js.map +1 -0
  51. package/dist/cjs/transactions/withdraw.d.ts.map +1 -1
  52. package/dist/cjs/transactions/withdraw.js +8 -3
  53. package/dist/cjs/transactions/withdraw.js.map +1 -1
  54. package/dist/cjs/transactions/zapDeposit.d.ts +2 -6
  55. package/dist/cjs/transactions/zapDeposit.d.ts.map +1 -1
  56. package/dist/cjs/transactions/zapDeposit.js +1207 -1497
  57. package/dist/cjs/transactions/zapDeposit.js.map +1 -1
  58. package/dist/cjs/utils/prices.d.ts.map +1 -1
  59. package/dist/cjs/utils/prices.js +1 -1
  60. package/dist/cjs/utils/prices.js.map +1 -1
  61. package/dist/esm/common/coins.d.ts.map +1 -1
  62. package/dist/esm/common/coins.js +13 -1
  63. package/dist/esm/common/coins.js.map +1 -1
  64. package/dist/esm/common/constants.d.ts +235 -0
  65. package/dist/esm/common/constants.d.ts.map +1 -1
  66. package/dist/esm/common/constants.js +203 -20
  67. package/dist/esm/common/constants.js.map +1 -1
  68. package/dist/esm/common/maps.d.ts +7 -0
  69. package/dist/esm/common/maps.d.ts.map +1 -1
  70. package/dist/esm/common/maps.js +183 -0
  71. package/dist/esm/common/maps.js.map +1 -1
  72. package/dist/esm/common/pyth.d.ts +1 -1
  73. package/dist/esm/common/pyth.d.ts.map +1 -1
  74. package/dist/esm/common/pyth.js.map +1 -1
  75. package/dist/esm/common/types.d.ts +17 -3
  76. package/dist/esm/common/types.d.ts.map +1 -1
  77. package/dist/esm/common/types.js.map +1 -1
  78. package/dist/esm/index.d.ts +1 -0
  79. package/dist/esm/index.d.ts.map +1 -1
  80. package/dist/esm/index.js +1 -0
  81. package/dist/esm/index.js.map +1 -1
  82. package/dist/esm/sui-sdk/functions/getPortfolioAmounts.d.ts.map +1 -1
  83. package/dist/esm/sui-sdk/functions/getPortfolioAmounts.js +17 -2
  84. package/dist/esm/sui-sdk/functions/getPortfolioAmounts.js.map +1 -1
  85. package/dist/esm/sui-sdk/transactions/fetchTransactions.d.ts.map +1 -1
  86. package/dist/esm/sui-sdk/transactions/fetchTransactions.js +21 -5
  87. package/dist/esm/sui-sdk/transactions/fetchTransactions.js.map +1 -1
  88. package/dist/esm/sui-sdk/transactions/types.d.ts +2 -1
  89. package/dist/esm/sui-sdk/transactions/types.d.ts.map +1 -1
  90. package/dist/esm/sui-sdk/transactions/types.js.map +1 -1
  91. package/dist/esm/transactions/alpha.js +2 -2
  92. package/dist/esm/transactions/alpha.js.map +1 -1
  93. package/dist/esm/transactions/bluefin.d.ts +6 -0
  94. package/dist/esm/transactions/bluefin.d.ts.map +1 -1
  95. package/dist/esm/transactions/bluefin.js +151 -1
  96. package/dist/esm/transactions/bluefin.js.map +1 -1
  97. package/dist/esm/transactions/deposit.d.ts +3 -3
  98. package/dist/esm/transactions/deposit.d.ts.map +1 -1
  99. package/dist/esm/transactions/deposit.js +26 -22
  100. package/dist/esm/transactions/deposit.js.map +1 -1
  101. package/dist/esm/transactions/navi-looping.d.ts.map +1 -1
  102. package/dist/esm/transactions/navi-looping.js +866 -74
  103. package/dist/esm/transactions/navi-looping.js.map +1 -1
  104. package/dist/esm/transactions/navi.d.ts.map +1 -1
  105. package/dist/esm/transactions/navi.js +1557 -192
  106. package/dist/esm/transactions/navi.js.map +1 -1
  107. package/dist/esm/transactions/naviOracle.d.ts +3 -0
  108. package/dist/esm/transactions/naviOracle.d.ts.map +1 -0
  109. package/dist/esm/transactions/naviOracle.js +15 -0
  110. package/dist/esm/transactions/naviOracle.js.map +1 -0
  111. package/dist/esm/transactions/withdraw.d.ts.map +1 -1
  112. package/dist/esm/transactions/withdraw.js +9 -4
  113. package/dist/esm/transactions/withdraw.js.map +1 -1
  114. package/dist/esm/transactions/zapDeposit.d.ts +2 -6
  115. package/dist/esm/transactions/zapDeposit.d.ts.map +1 -1
  116. package/dist/esm/transactions/zapDeposit.js +1208 -1498
  117. package/dist/esm/transactions/zapDeposit.js.map +1 -1
  118. package/dist/esm/utils/prices.d.ts.map +1 -1
  119. package/dist/esm/utils/prices.js +2 -2
  120. package/dist/esm/utils/prices.js.map +1 -1
  121. package/docs/assets/navigation.js +1 -1
  122. package/docs/assets/search.js +1 -1
  123. package/docs/functions/alphaLpBreakdown.html +1 -1
  124. package/docs/functions/cetusLpBreakdown.html +1 -1
  125. package/docs/functions/claimBlueRewardTxb.html +1 -1
  126. package/docs/functions/claimRewardTxb.html +1 -1
  127. package/docs/functions/coinAmountToXTokensDoubleAsset.html +1 -1
  128. package/docs/functions/coinAmountToXTokensSingleAsset.html +1 -1
  129. package/docs/functions/coinsInPool.html +1 -1
  130. package/docs/functions/collectRewards.html +1 -1
  131. package/docs/functions/deposit.html +1 -1
  132. package/docs/functions/depositDoubleAssetTxb.html +1 -1
  133. package/docs/functions/depositSingleAssetTxb.html +1 -1
  134. package/docs/functions/fetchAfterTransactionEvents.html +1 -1
  135. package/docs/functions/fetchAutoCompoundingEvents.html +1 -1
  136. package/docs/functions/fetchAutoCompoundingEventsGql.html +1 -1
  137. package/docs/functions/fetchCetusPools.html +1 -1
  138. package/docs/functions/fetchChainIdentifier.html +1 -1
  139. package/docs/functions/fetchCheckRatioEvents.html +1 -1
  140. package/docs/functions/fetchLiquidityChangeEvents.html +1 -1
  141. package/docs/functions/fetchMultiCategoryEvents.html +1 -1
  142. package/docs/functions/fetchMultiReceipts.html +1 -1
  143. package/docs/functions/fetchNftHolders.html +1 -1
  144. package/docs/functions/fetchPools.html +1 -1
  145. package/docs/functions/fetchPortfolioData.html +1 -1
  146. package/docs/functions/fetchProtocolData.html +1 -1
  147. package/docs/functions/fetchTVL.html +1 -1
  148. package/docs/functions/fetchTransactions.html +1 -0
  149. package/docs/functions/fetchUserVaultBalances.html +1 -1
  150. package/docs/functions/fetchUserVaults.html +1 -1
  151. package/docs/functions/fetchUserWalletData.html +1 -1
  152. package/docs/functions/fetchVoloExchangeRate.html +1 -1
  153. package/docs/functions/fetchWithdrawV2Events.html +1 -1
  154. package/docs/functions/getAirdropShare.html +1 -1
  155. package/docs/functions/getAllDoubleAssetVaults.html +1 -1
  156. package/docs/functions/getAllSingleAssetVaults.html +1 -1
  157. package/docs/functions/getAllVaultBalances.html +1 -1
  158. package/docs/functions/getAllVaults.html +1 -1
  159. package/docs/functions/getAlphaUnlocks.html +1 -1
  160. package/docs/functions/getAlphaVaultBalance.html +1 -1
  161. package/docs/functions/getAmounts.html +1 -1
  162. package/docs/functions/getApr.html +1 -1
  163. package/docs/functions/getAprs.html +1 -1
  164. package/docs/functions/getApy.html +1 -1
  165. package/docs/functions/getApys.html +1 -1
  166. package/docs/functions/getCetusInvestorTicksMap.html +1 -1
  167. package/docs/functions/getCetusPool.html +1 -1
  168. package/docs/functions/getCetusSqrtPriceMap.html +1 -1
  169. package/docs/functions/getCoinAmountsFromLiquidity.html +1 -1
  170. package/docs/functions/getConf.html +1 -1
  171. package/docs/functions/getCurrentTick.html +1 -1
  172. package/docs/functions/getDistributor.html +1 -1
  173. package/docs/functions/getDoubleAssetVaultBalance.html +1 -1
  174. package/docs/functions/getDoubleAssetVaults.html +1 -1
  175. package/docs/functions/getHoldersFromTransactions.html +1 -1
  176. package/docs/functions/getInvestor.html +1 -1
  177. package/docs/functions/getInvestorPoolMap.html +1 -1
  178. package/docs/functions/getLastAutoCompoundTime.html +1 -1
  179. package/docs/functions/getLatestPrices.html +1 -1
  180. package/docs/functions/getLiquidity.html +1 -1
  181. package/docs/functions/getMultiCetusPool.html +1 -1
  182. package/docs/functions/getMultiInvestor.html +1 -1
  183. package/docs/functions/getMultiLatestPrices.html +1 -1
  184. package/docs/functions/getMultiParentPool.html +1 -1
  185. package/docs/functions/getMultiPool.html +1 -1
  186. package/docs/functions/getMultiReceipts.html +1 -1
  187. package/docs/functions/getParentPool.html +1 -1
  188. package/docs/functions/getPool.html +1 -1
  189. package/docs/functions/getPoolExchangeRate.html +1 -1
  190. package/docs/functions/getPoolExchangeRateMap.html +1 -1
  191. package/docs/functions/getPoolsWeightDistribution.html +1 -1
  192. package/docs/functions/getPositionRange.html +1 -1
  193. package/docs/functions/getPositionRanges.html +1 -1
  194. package/docs/functions/getPositionTicks.html +1 -1
  195. package/docs/functions/getPriceToTick.html +1 -1
  196. package/docs/functions/getRebalanceHistories.html +1 -1
  197. package/docs/functions/getRebalanceHistory.html +1 -1
  198. package/docs/functions/getReceipts.html +1 -1
  199. package/docs/functions/getSingleAssetVaultBalance.html +1 -1
  200. package/docs/functions/getSingleAssetVaults.html +1 -1
  201. package/docs/functions/getSuiClient.html +2 -2
  202. package/docs/functions/getSuiNodeUrl.html +2 -2
  203. package/docs/functions/getTVLs-1.html +1 -1
  204. package/docs/functions/getTickSpacing.html +1 -1
  205. package/docs/functions/getTickToPrice.html +1 -1
  206. package/docs/functions/getTvls.html +1 -1
  207. package/docs/functions/getUserTokensFromTransactions.html +1 -1
  208. package/docs/functions/getUserTokensInUsdFromTransactions.html +1 -1
  209. package/docs/functions/getVaultBalance.html +1 -1
  210. package/docs/functions/getVaultBalanceForActiveUsers.html +1 -1
  211. package/docs/functions/getVaults.html +1 -1
  212. package/docs/functions/getXTokenVaultBalanceForActiveUsers.html +1 -1
  213. package/docs/functions/getZapAmounts.html +1 -1
  214. package/docs/functions/lastAutocompoundTime.html +1 -1
  215. package/docs/functions/liquidityToTokens.html +1 -1
  216. package/docs/functions/multiLiquidityToTokens.html +1 -1
  217. package/docs/functions/multiTokensToUsd.html +1 -1
  218. package/docs/functions/multiXTokensToLiquidity.html +1 -1
  219. package/docs/functions/parseUserWalletData.html +1 -1
  220. package/docs/functions/pendingBlueRewardAmount.html +1 -1
  221. package/docs/functions/setCustomSuiClient.html +2 -2
  222. package/docs/functions/setSuiClient.html +2 -2
  223. package/docs/functions/setSuiNodeUrl.html +2 -2
  224. package/docs/functions/setWeights.html +1 -1
  225. package/docs/functions/withdraw.html +1 -1
  226. package/docs/functions/withdrawAlphaTxb.html +1 -1
  227. package/docs/functions/withdrawTxb.html +1 -1
  228. package/docs/functions/zapDepositTxb.html +1 -1
  229. package/docs/index.html +2 -2
  230. package/docs/interfaces/Coin.html +6 -6
  231. package/docs/interfaces/CoinPair.html +2 -2
  232. package/docs/interfaces/NaviVoloData.html +2 -2
  233. package/docs/interfaces/PoolData.html +2 -2
  234. package/docs/interfaces/PoolWeightDistribution.html +2 -2
  235. package/docs/interfaces/RebalanceHistoryType.html +2 -2
  236. package/docs/modules.html +3 -2
  237. package/docs/types/AfterTransactionEventNode.html +1 -1
  238. package/docs/types/Allocator.html +1 -1
  239. package/docs/types/AlphaFiDoubleAssetVault.html +1 -1
  240. package/docs/types/AlphaFiMultiVaultBalance.html +1 -1
  241. package/docs/types/AlphaFiSingleAssetVault.html +1 -1
  242. package/docs/types/AlphaFiVault.html +1 -1
  243. package/docs/types/AlphaFiVaultBalance.html +1 -1
  244. package/docs/types/AlphaPoolType.html +1 -1
  245. package/docs/types/AlphaReceipt.html +1 -1
  246. package/docs/types/AlphaReceiptFields.html +1 -1
  247. package/docs/types/AlphaVaultBalance.html +1 -1
  248. package/docs/types/AutoBalancePoolNames.html +1 -1
  249. package/docs/types/AutoCompoundingEventNode.html +1 -1
  250. package/docs/types/BluefinInvestor.html +1 -1
  251. package/docs/types/BluefinPoolType.html +1 -1
  252. package/docs/types/BucketInvestor.html +1 -1
  253. package/docs/types/CetusInvestor.html +1 -1
  254. package/docs/types/CetusPoolType.html +1 -1
  255. package/docs/types/CetusSwapOptions.html +1 -1
  256. package/docs/types/CoinAmounts.html +1 -1
  257. package/docs/types/CoinName.html +1 -1
  258. package/docs/types/CoinType.html +1 -1
  259. package/docs/types/CommonInvestorFields.html +1 -1
  260. package/docs/types/CreatePoolOptions.html +1 -1
  261. package/docs/types/Distributor.html +1 -1
  262. package/docs/types/DoubleAssetMultiVaultBalance.html +1 -1
  263. package/docs/types/DoubleAssetPoolNames.html +1 -1
  264. package/docs/types/DoubleAssetTokenHoldings.html +1 -1
  265. package/docs/types/DoubleAssetVaultBalance.html +1 -1
  266. package/docs/types/EventCategory.html +1 -1
  267. package/docs/types/EventNode.html +1 -1
  268. package/docs/types/GetHoldersParams.html +1 -1
  269. package/docs/types/GetTokenHoldingsParams.html +1 -1
  270. package/docs/types/GetUserTokensFromTransactionsParams.html +1 -1
  271. package/docs/types/GetUserTokensInUsdFromTransactionsParams.html +1 -1
  272. package/docs/types/GetVaultBalanceForActiveUsersParams.html +1 -1
  273. package/docs/types/GetVaultBalanceParams.html +1 -1
  274. package/docs/types/HoldingsObj.html +1 -1
  275. package/docs/types/Icon.html +1 -1
  276. package/docs/types/Investor.html +1 -1
  277. package/docs/types/LiquidityChangeEventNode.html +1 -1
  278. package/docs/types/LiquidityToTokensParams.html +1 -1
  279. package/docs/types/LiquidityToUsdParams.html +1 -1
  280. package/docs/types/LoopingDebt.html +1 -1
  281. package/docs/types/LoopingPoolNames.html +1 -1
  282. package/docs/types/LpBreakdownType.html +1 -1
  283. package/docs/types/MemberPoolDataType.html +1 -1
  284. package/docs/types/MemberType.html +1 -1
  285. package/docs/types/MultiGetVaultBalancesParams.html +1 -1
  286. package/docs/types/NaviInvestor.html +1 -1
  287. package/docs/types/OtherReceiptFields.html +1 -1
  288. package/docs/types/PoolName.html +1 -1
  289. package/docs/types/PoolReceipt.html +1 -1
  290. package/docs/types/PoolType.html +1 -1
  291. package/docs/types/Receipt.html +1 -1
  292. package/docs/types/ReceiptGQL.html +1 -1
  293. package/docs/types/SingleAssetMultiVaultBalance.html +1 -1
  294. package/docs/types/SingleAssetPoolNames.html +1 -1
  295. package/docs/types/SingleAssetTokenHoldings.html +1 -1
  296. package/docs/types/SingleAssetVaultBalance.html +1 -1
  297. package/docs/types/SingleGetVaultBalancesParams.html +1 -1
  298. package/docs/types/StrategyType.html +1 -1
  299. package/docs/types/SuiNetwork.html +1 -1
  300. package/docs/types/SwapOptions.html +1 -1
  301. package/docs/types/TickSpacing.html +1 -1
  302. package/docs/types/TotalWeightType.html +1 -1
  303. package/docs/types/TransactionBlockType.html +1 -1
  304. package/docs/types/UserPoolLiquidity.html +1 -1
  305. package/docs/types/UserPoolTokenHoldings.html +1 -1
  306. package/docs/types/UserUsdHoldings.html +1 -1
  307. package/docs/types/VaultBalance.html +1 -1
  308. package/docs/types/WithdrawV2EventNode.html +1 -1
  309. package/docs/variables/bluefinPoolMap.html +1 -1
  310. package/docs/variables/cetusPoolMap.html +1 -1
  311. package/docs/variables/coinsList.html +1 -1
  312. package/docs/variables/defunctPoolsSet.html +1 -1
  313. package/docs/variables/doubleAssetPoolCoinMap.html +1 -1
  314. package/docs/variables/eventCategories.html +1 -1
  315. package/docs/variables/ignoredWalletsForDailyRevenue.html +1 -1
  316. package/docs/variables/loopingAccountAddresses.html +1 -1
  317. package/docs/variables/loopingPoolCoinMap.html +1 -1
  318. package/docs/variables/naviAssetMap.html +1 -1
  319. package/docs/variables/poolIdPoolNameMap.html +1 -1
  320. package/docs/variables/poolInfo.html +1 -1
  321. package/docs/variables/singleAssetPoolCoinMap.html +1 -1
  322. package/docs/variables/stableCoins.html +1 -1
  323. package/package.json +6 -4
@@ -15,243 +15,268 @@ const getReceipts_js_1 = require("../sui-sdk/functions/getReceipts.js");
15
15
  const prices_js_1 = require("../utils/prices.js");
16
16
  const stsui_sdk_1 = require("@alphafi/stsui-sdk");
17
17
  const decimal_js_1 = require("decimal.js");
18
- async function zapDepositTxb(inputCoinName, inputCoinAmount, poolName, slippage, // 0.01 --> 1%, 0.001 --> 0.1%
19
- options) {
20
- let txb = new transactions_1.Transaction();
21
- const suiClient = (0, client_js_1.getSuiClient)();
22
- const address = options.address;
23
- const coinTypeA = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
24
- const coinTypeB = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
25
- const swapObjectA = coins_js_1.coinsList[coinTypeA];
26
- const swapObjectB = coins_js_1.coinsList[coinTypeB];
27
- const inputObject = coins_js_1.coinsList[inputCoinName];
28
- const swapGateway = new _7k_js_1.SevenKGateway();
29
- let coin1, coin2;
30
- let amountA, amountB;
31
- const amounts = await (0, deposit_js_1.getAmounts)(poolName, true, "100000001");
32
- if (!amounts) {
33
- console.error("Error fetching amounts for zap");
18
+ // Case 1: When the first amount is zero
19
+ async function handleFirstAmountZero(params, coinDetails, suiClient) {
20
+ params.amountA = "0";
21
+ params.coinA = params.txb.moveCall({
22
+ target: "0x2::coin::zero",
23
+ typeArguments: [coinDetails.swapObjectA.type],
24
+ arguments: [],
25
+ });
26
+ if (coinDetails.inputObject.type === coinDetails.swapObjectB.type) {
27
+ params.amountB = coinDetails.inputCoinAmount.toString();
28
+ const res = await splitFromExisting(coinDetails.swapObjectB.name, params.amountB ?? "0", params.txb, suiClient, coinDetails.address);
29
+ params.txb = res.tx;
30
+ params.coinB = res.coinOut;
31
+ }
32
+ else {
33
+ const swapOptionsI2B = {
34
+ pair: { coinA: coinDetails.inputObject, coinB: coinDetails.swapObjectB },
35
+ senderAddress: coinDetails.address,
36
+ inAmount: new bn_js_1.default(coinDetails.inputCoinAmount),
37
+ slippage: coinDetails.slippage,
38
+ };
39
+ const result = await zapSwap(swapOptionsI2B, params.txb, coinDetails.poolName);
40
+ if (result) {
41
+ params.amountB = result.amountOut;
42
+ params.txb = result.tx;
43
+ if (result.coinOut)
44
+ params.coinB = result.coinOut;
45
+ }
46
+ }
47
+ return params;
48
+ }
49
+ // Case 2: When the second amount is zero
50
+ async function handleSecondAmountZero(params, coinDetails, suiClient) {
51
+ params.amountB = "0";
52
+ params.coinB = params.txb.moveCall({
53
+ target: "0x2::coin::zero",
54
+ typeArguments: [coinDetails.swapObjectB.type],
55
+ arguments: [],
56
+ });
57
+ if (coinDetails.inputObject.type === coinDetails.swapObjectA.type) {
58
+ params.amountA = coinDetails.inputCoinAmount.toString();
59
+ const res = await splitFromExisting(coinDetails.swapObjectA.name, params.amountA, params.txb, suiClient, coinDetails.address);
60
+ params.txb = res.tx;
61
+ params.coinA = res.coinOut;
62
+ }
63
+ else {
64
+ const swapOptionsI2A = {
65
+ pair: { coinA: coinDetails.inputObject, coinB: coinDetails.swapObjectA },
66
+ senderAddress: coinDetails.address,
67
+ inAmount: new bn_js_1.default(coinDetails.inputCoinAmount),
68
+ slippage: coinDetails.slippage,
69
+ };
70
+ const result = await zapSwap(swapOptionsI2A, params.txb, coinDetails.poolName);
71
+ if (result) {
72
+ params.amountA = result.amountOut;
73
+ params.txb = result.tx;
74
+ if (result.coinOut)
75
+ params.coinA = result.coinOut;
76
+ }
77
+ }
78
+ return params;
79
+ }
80
+ // Case 3: When both amounts are nonzero
81
+ async function handleNonZeroAmounts(params, coinDetails, amounts, suiClient) {
82
+ const amount1 = Number(amounts[0]);
83
+ const amount2 = Number(amounts[1]);
84
+ const swapOptions = {
85
+ pair: { coinA: coinDetails.swapObjectA, coinB: coinDetails.swapObjectB },
86
+ senderAddress: coinDetails.address,
87
+ inAmount: new bn_js_1.default(amount1),
88
+ slippage: coinDetails.slippage,
89
+ };
90
+ const ratioQuote = await zapGetQuote(coinDetails.swapGateway, swapOptions, coinDetails.poolName);
91
+ if (ratioQuote === undefined) {
92
+ console.error("Error fetching ratioQuote for Zap");
34
93
  return undefined;
35
94
  }
36
- if (Number(amounts[0]) === 0) {
37
- amountA = "0";
38
- coin1 = txb.moveCall({
39
- target: "0x2::coin::zero",
40
- typeArguments: [swapObjectA.type],
41
- arguments: [],
42
- });
43
- if (inputCoinName === coinTypeB) {
44
- amountB = inputCoinAmount.toString();
45
- const res = await splitFromExisting(coinTypeB, amountB, txb, suiClient, address);
46
- txb = res.tx;
47
- coin2 = res.coinOut;
95
+ const amount1InCoinType2 = Number(ratioQuote);
96
+ const totalAmount = amount2 + amount1InCoinType2;
97
+ const inputAmountToType1 = Math.floor((coinDetails.inputCoinAmount * amount1InCoinType2) / totalAmount);
98
+ const inputAmountToType2 = Math.floor((coinDetails.inputCoinAmount * amount2) / totalAmount);
99
+ const swapOptionsI2A = {
100
+ pair: { coinA: coinDetails.inputObject, coinB: coinDetails.swapObjectA },
101
+ senderAddress: coinDetails.address,
102
+ inAmount: new bn_js_1.default(inputAmountToType1),
103
+ slippage: coinDetails.slippage,
104
+ };
105
+ const swapOptionsI2B = {
106
+ pair: { coinA: coinDetails.inputObject, coinB: coinDetails.swapObjectB },
107
+ senderAddress: coinDetails.address,
108
+ inAmount: new bn_js_1.default(inputAmountToType2),
109
+ slippage: coinDetails.slippage,
110
+ };
111
+ let swapResult;
112
+ if (coinDetails.inputObject.type === coinDetails.swapObjectA.type) {
113
+ swapResult = await zapSwap(swapOptionsI2B, params.txb, coinDetails.poolName);
114
+ if (swapResult) {
115
+ params.amountB = swapResult.amountOut;
116
+ params.txb = swapResult.tx;
117
+ if (swapResult.coinOut)
118
+ params.coinB = swapResult.coinOut;
119
+ }
120
+ params.amountA = inputAmountToType1.toString();
121
+ if (swapResult && swapResult.remainingLSTCoin) {
122
+ params.coinA = swapResult.remainingLSTCoin;
48
123
  }
49
124
  else {
50
- const swapOptionsI2B = {
51
- pair: {
52
- coinA: inputObject,
53
- coinB: swapObjectB,
54
- },
55
- senderAddress: address,
56
- inAmount: new bn_js_1.default(inputCoinAmount),
57
- slippage: slippage,
58
- };
59
- const result = await zapSwap(swapOptionsI2B, txb, poolName);
60
- if (result) {
61
- amountB = result.amountOut;
62
- txb = result.tx;
63
- if (result.coinOut) {
64
- coin2 = result.coinOut;
65
- }
66
- }
125
+ const res = await splitFromExisting(coinDetails.swapObjectA.name, params.amountA, params.txb, suiClient, coinDetails.address);
126
+ params.txb = res.tx;
127
+ params.coinA = res.coinOut;
67
128
  }
68
129
  }
69
- else if (Number(amounts[1]) === 0) {
70
- amountB = "0";
71
- coin2 = txb.moveCall({
72
- target: "0x2::coin::zero",
73
- typeArguments: [swapObjectB.type],
74
- arguments: [],
75
- });
76
- if (inputCoinName === coinTypeA) {
77
- amountA = inputCoinAmount.toString();
78
- const res = await splitFromExisting(coinTypeA, amountA, txb, suiClient, address);
79
- txb = res.tx;
80
- coin1 = res.coinOut;
130
+ else if (coinDetails.inputObject.type === coinDetails.swapObjectB.type) {
131
+ swapResult = await zapSwap(swapOptionsI2A, params.txb, coinDetails.poolName);
132
+ if (swapResult) {
133
+ params.amountA = swapResult.amountOut;
134
+ params.txb = swapResult.tx;
135
+ if (swapResult.coinOut)
136
+ params.coinA = swapResult.coinOut;
137
+ }
138
+ if (swapResult && swapResult.remainingLSTCoin) {
139
+ params.coinB = swapResult.remainingLSTCoin;
81
140
  }
82
141
  else {
83
- const swapOptionsI2A = {
84
- pair: {
85
- coinA: inputObject,
86
- coinB: swapObjectA,
87
- },
88
- senderAddress: address,
89
- inAmount: new bn_js_1.default(inputCoinAmount),
90
- slippage: slippage,
91
- };
92
- const result = await zapSwap(swapOptionsI2A, txb, poolName);
93
- if (result) {
94
- amountA = result.amountOut;
95
- txb = result.tx;
96
- if (result.coinOut) {
97
- coin1 = result.coinOut;
98
- }
99
- }
142
+ params.amountB = inputAmountToType2.toString();
143
+ const res = await splitFromExisting(coinDetails.swapObjectB.name, params.amountB, params.txb, suiClient, coinDetails.address);
144
+ params.txb = res.tx;
145
+ params.coinB = res.coinOut;
100
146
  }
101
147
  }
102
148
  else {
103
- const amount1 = Number(amounts[0]);
104
- const amount2 = Number(amounts[1]);
105
- const swapOptions = {
106
- pair: {
107
- coinA: swapObjectA,
108
- coinB: swapObjectB,
109
- },
110
- senderAddress: address,
111
- inAmount: new bn_js_1.default(amount1),
112
- slippage: slippage,
113
- };
114
- const ratioQuote = await zapGetQuote(swapGateway, swapOptions, poolName);
115
- if (ratioQuote === undefined) {
116
- console.error("Error fetching ratioQuote for zap");
117
- return undefined;
118
- }
119
- const amount1InCoinType2 = Number(ratioQuote);
120
- const totalAmount = amount2 + amount1InCoinType2;
121
- const inputAmountToType1 = Math.floor((inputCoinAmount * amount1InCoinType2) / totalAmount);
122
- const inputAmountToType2 = Math.floor((inputCoinAmount * amount2) / totalAmount);
123
- const swapOptionsI2A = {
124
- pair: {
125
- coinA: inputObject,
126
- coinB: swapObjectA,
127
- },
128
- senderAddress: address,
129
- inAmount: new bn_js_1.default(inputAmountToType1),
130
- slippage: slippage,
131
- };
132
- const swapOptionsI2B = {
133
- pair: {
134
- coinA: inputObject,
135
- coinB: swapObjectB,
136
- },
137
- senderAddress: address,
138
- inAmount: new bn_js_1.default(inputAmountToType2),
139
- slippage: slippage,
140
- };
141
- if (inputCoinName === coinTypeA) {
142
- const result = await zapSwap(swapOptionsI2B, txb, poolName);
143
- if (result) {
144
- amountB = result.amountOut;
145
- txb = result.tx;
146
- if (result.coinOut) {
147
- coin2 = result.coinOut;
148
- }
149
- }
150
- amountA = inputAmountToType1.toString();
151
- if (result && result.remainingLSTCoin) {
152
- coin1 = result.remainingLSTCoin;
153
- }
154
- else {
155
- const res = await splitFromExisting(coinTypeA, amountA, txb, suiClient, address);
156
- txb = res.tx;
157
- coin1 = res.coinOut;
158
- }
149
+ swapResult = await zapSwap(swapOptionsI2A, params.txb, coinDetails.poolName);
150
+ if (swapResult) {
151
+ params.amountA = swapResult.amountOut;
152
+ params.txb = swapResult.tx;
153
+ if (swapResult.coinOut)
154
+ params.coinA = swapResult.coinOut;
159
155
  }
160
- else if (inputCoinName === coinTypeB) {
161
- const result = await zapSwap(swapOptionsI2A, txb, poolName);
162
- if (result) {
163
- amountA = result.amountOut;
164
- txb = result.tx;
165
- if (result.coinOut) {
166
- coin1 = result.coinOut;
167
- }
168
- }
169
- if (result && result.remainingLSTCoin) {
170
- coin2 = result.remainingLSTCoin;
171
- }
172
- else {
173
- amountB = inputAmountToType2.toString();
174
- const res = await splitFromExisting(coinTypeB, amountB, txb, suiClient, address);
175
- txb = res.tx;
176
- coin2 = res.coinOut;
177
- }
178
- }
179
- else {
180
- let result = await zapSwap(swapOptionsI2A, txb, poolName);
181
- if (result) {
182
- amountA = result.amountOut;
183
- txb = result.tx;
184
- if (result.coinOut) {
185
- coin1 = result.coinOut;
186
- }
187
- }
188
- result = await zapSwap(swapOptionsI2B, txb, poolName);
189
- if (result) {
190
- amountB = result.amountOut;
191
- txb = result.tx;
192
- if (result.coinOut) {
193
- coin2 = result.coinOut;
194
- }
195
- }
156
+ swapResult = await zapSwap(swapOptionsI2B, params.txb, coinDetails.poolName);
157
+ if (swapResult) {
158
+ params.amountB = swapResult.amountOut;
159
+ params.txb = swapResult.tx;
160
+ if (swapResult.coinOut)
161
+ params.coinB = swapResult.coinOut;
196
162
  }
197
163
  }
198
- if (amountA && amountB && coin1 && coin2) {
164
+ return params;
165
+ }
166
+ async function zapDepositTxb(inputCoinName, inputCoinAmount, poolName, slippage, // 0.01 --> 1%, 0.001 --> 0.1%
167
+ address) {
168
+ const suiClient = (0, client_js_1.getSuiClient)();
169
+ let params = {
170
+ txb: new transactions_1.Transaction(),
171
+ coinA: undefined,
172
+ amountA: undefined,
173
+ coinB: undefined,
174
+ amountB: undefined,
175
+ };
176
+ const coinDetails = {
177
+ swapGateway: new _7k_js_1.SevenKGateway(),
178
+ inputObject: coins_js_1.coinsList[inputCoinName],
179
+ inputCoinAmount: inputCoinAmount,
180
+ swapObjectA: coins_js_1.coinsList[maps_js_1.doubleAssetPoolCoinMap[poolName].coin1],
181
+ swapObjectB: coins_js_1.coinsList[maps_js_1.doubleAssetPoolCoinMap[poolName].coin2],
182
+ address: address,
183
+ slippage: slippage,
184
+ poolName: poolName,
185
+ };
186
+ const amounts = await (0, deposit_js_1.getAmounts)(poolName, true, "100000001", true);
187
+ if (Number(amounts[0]) === 0) {
188
+ params = await handleFirstAmountZero(params, coinDetails, suiClient);
189
+ }
190
+ else if (Number(amounts[1]) === 0) {
191
+ params = await handleSecondAmountZero(params, coinDetails, suiClient);
192
+ }
193
+ else {
194
+ const result = await handleNonZeroAmounts(params, coinDetails, amounts, suiClient);
195
+ if (!result)
196
+ return undefined;
197
+ params = result;
198
+ }
199
+ if (params.amountA && params.amountB && params.coinA && params.coinB) {
199
200
  // fee charge
200
- const fee_address = (0, constants_js_1.getConf)().FEE_ADDRESS;
201
201
  const feePercentage = 0.05;
202
- const amountAFee = ((Number(amountA) * feePercentage) / 100).toFixed(0);
203
- const amountBFee = ((Number(amountB) * feePercentage) / 100).toFixed(0);
204
- const [feeCoinA] = txb.splitCoins(coin1, [amountAFee]);
205
- const [feeCoinB] = txb.splitCoins(coin2, [amountBFee]);
206
- txb.transferObjects([feeCoinA, feeCoinB], fee_address);
202
+ const amountAFee = ((Number(params.amountA) * feePercentage) / 100).toFixed(0);
203
+ const amountBFee = ((Number(params.amountB) * feePercentage) / 100).toFixed(0);
204
+ const [feeCoinA] = params.txb.splitCoins(params.coinA, [amountAFee]);
205
+ const [feeCoinB] = params.txb.splitCoins(params.coinB, [amountBFee]);
206
+ params.txb.transferObjects([feeCoinA, feeCoinB], (0, constants_js_1.getConf)().FEE_ADDRESS);
207
+ // Removing fee amounts from amounts and some slippage
207
208
  const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
208
209
  const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
209
- amountA = (Number(amountA) * 0.995).toString();
210
- amountB = (Number(amountB) * 0.995).toString();
210
+ params.amountA = (Number(params.amountA) * 0.995).toString();
211
+ params.amountB = (Number(params.amountB) * 0.995).toString();
212
+ // Conditional deposit calls based on pool and protocol
213
+ const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
214
+ let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, params.amountA, false);
215
+ if (amounts[0] > params.amountA || amounts[1] > params.amountB) {
216
+ amounts = await (0, deposit_js_1.getAmounts)(poolName, false, params.amountB, false);
217
+ }
218
+ const [depositCoinA] = params.txb.splitCoins(params.coinA, [amounts[0]]);
219
+ const [depositCoinB] = params.txb.splitCoins(params.coinB, [amounts[1]]);
220
+ let someReceipt;
221
+ if (receipt.length == 0) {
222
+ [someReceipt] = params.txb.moveCall({
223
+ target: `0x1::option::none`,
224
+ typeArguments: [maps_js_1.poolInfo[poolName].receiptType],
225
+ arguments: [],
226
+ });
227
+ }
228
+ else {
229
+ [someReceipt] = params.txb.moveCall({
230
+ target: `0x1::option::some`,
231
+ typeArguments: [receipt[0].content.type],
232
+ arguments: [params.txb.object(receipt[0].objectId)],
233
+ });
234
+ }
211
235
  if (maps_js_1.poolInfo[poolName].parentProtocolName === "CETUS") {
212
236
  if (pool1 === "CETUS" && pool2 === "SUI") {
213
- txb = await depositCetusSuiTxb(amountA, amountB, poolName, { address }, txb, coin1, coin2);
237
+ params.txb = await depositCetusSuiTxb(params.txb, someReceipt, coinDetails.poolName, depositCoinA, depositCoinB);
214
238
  }
215
239
  else if (pool2 === "SUI") {
216
- txb = await depositCetusAlphaSuiTxb(amountA, amountB, poolName, { address }, txb, coin1, coin2);
240
+ params.txb = await depositCetusAlphaSuiTxb(params.txb, someReceipt, coinDetails.poolName, depositCoinA, depositCoinB);
217
241
  }
218
242
  else {
219
- txb = await depositCetus(amountA, amountB, poolName, { address }, txb, coin1, coin2);
243
+ params.txb = await depositCetusTxb(params.txb, someReceipt, coinDetails.poolName, depositCoinA, depositCoinB);
220
244
  }
221
245
  }
222
246
  else if (maps_js_1.poolInfo[poolName].parentProtocolName === "BLUEFIN") {
223
247
  if (poolName === "BLUEFIN-NAVX-VSUI" ||
224
248
  poolName === "BLUEFIN-ALPHA-USDC" ||
225
249
  poolName === "BLUEFIN-BLUE-USDC") {
226
- txb = await depositBluefinType2Txb(amountA, amountB, poolName, { address }, txb, coin1, coin2);
250
+ params.txb = await depositBluefinType2Txb(params.txb, someReceipt, coinDetails.poolName, depositCoinA, depositCoinB);
227
251
  }
228
252
  else if (pool1 === "SUI") {
229
- txb = await depositBluefinSuiFirstTxb(amountA, amountB, poolName, { address }, txb, coin1, coin2);
253
+ params.txb = await depositBluefinSuiFirstTxb(params.txb, someReceipt, coinDetails.poolName, depositCoinA, depositCoinB);
230
254
  }
231
255
  else if (pool2 === "SUI") {
232
- txb = await depositBluefinSuiSecondTxb(amountA, amountB, poolName, { address }, txb, coin1, coin2);
256
+ params.txb = await depositBluefinSuiSecondTxb(params.txb, someReceipt, coinDetails.poolName, depositCoinA, depositCoinB);
233
257
  }
234
258
  else if (pool1 === "STSUI" || pool2 === "STSUI") {
235
- txb = await depositBluefinStsuiTxb(amountA, amountB, poolName, { address }, txb, coin1, coin2);
259
+ params.txb = await depositBluefinStsuiTxb(params.txb, someReceipt, poolName, depositCoinA, depositCoinB);
236
260
  }
237
261
  else {
238
- txb = await depositBluefinType1Txb(amountA, amountB, poolName, { address }, txb, coin1, coin2);
262
+ params.txb = await depositBluefinType1Txb(params.txb, someReceipt, coinDetails.poolName, depositCoinA, depositCoinB);
239
263
  }
240
264
  }
265
+ params.txb.transferObjects([params.coinA, params.coinB], address);
241
266
  }
242
- txb.setGasBudget(100000000);
243
- return txb;
267
+ params.txb.setGasBudget(100000000);
268
+ return params.txb;
244
269
  }
245
270
  async function zapGetQuote(swapGateway, swapOptions, poolName) {
246
271
  if (swapOptions.pair.coinA.name === "SUI" &&
247
272
  swapOptions.pair.coinB.name === "STSUI") {
248
- const exchangeRate = new decimal_js_1.Decimal(await (0, stsui_sdk_1.stSuiExchangeRate)());
273
+ const exchangeRate = new decimal_js_1.Decimal(await (0, stsui_sdk_1.stSuiExchangeRate)((0, stsui_sdk_1.getConf)().LST_INFO, true));
249
274
  const amount = new decimal_js_1.Decimal(swapOptions.inAmount ? swapOptions.inAmount.toString() : "0");
250
275
  return amount.div(exchangeRate).toString();
251
276
  }
252
277
  else if (swapOptions.pair.coinA.name === "STSUI" &&
253
278
  swapOptions.pair.coinB.name === "SUI") {
254
- const exchangeRate = new decimal_js_1.Decimal(await (0, stsui_sdk_1.stSuiExchangeRate)());
279
+ const exchangeRate = new decimal_js_1.Decimal(await (0, stsui_sdk_1.stSuiExchangeRate)((0, stsui_sdk_1.getConf)().LST_INFO, true));
255
280
  const amount = new decimal_js_1.Decimal(swapOptions.inAmount ? swapOptions.inAmount.toString() : "0");
256
281
  return amount.mul(exchangeRate).toString();
257
282
  }
@@ -329,132 +354,16 @@ async function splitFromExisting(coinType, amount, txb, suiClient, address) {
329
354
  coinOut: coin,
330
355
  };
331
356
  }
332
- const depositCetus = async (amountA, amountB, poolName, options, transaction = undefined, coin1Arg, coin2Arg) => {
333
- const address = options.address;
334
- let txb;
335
- if (transaction)
336
- txb = transaction;
337
- else
338
- txb = new transactions_1.Transaction();
339
- poolName = poolName.toUpperCase();
357
+ const depositCetusTxb = async (txb, someReceipt, poolName, depositCoinA, depositCoinB) => {
340
358
  const poolinfo = maps_js_1.poolInfo[poolName];
341
359
  const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
342
360
  const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
343
- const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
344
- amountA = (Number(amountA) * 0.999).toString();
345
- amountB = (Number(amountB) * 0.999).toString();
346
- let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, amountA);
347
- if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
348
- amounts = await (0, deposit_js_1.getAmounts)(poolName, false, amountB);
349
- }
350
- if (amounts && coin1Arg !== undefined && coin2Arg !== undefined) {
351
- const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
352
- const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
353
- let someReceipt;
354
- if (receipt.length == 0) {
355
- [someReceipt] = txb.moveCall({
356
- target: `0x1::option::none`,
357
- typeArguments: [maps_js_1.poolInfo[poolName].receiptType],
358
- arguments: [],
359
- });
360
- }
361
- else {
362
- [someReceipt] = txb.moveCall({
363
- target: `0x1::option::some`,
364
- typeArguments: [receipt[0].content.type],
365
- arguments: [txb.object(receipt[0].objectId)],
366
- });
367
- }
368
- if (poolName == "WUSDC-WBTC" ||
369
- poolName == "USDC-USDT" ||
370
- poolName == "USDC-WUSDC" ||
371
- poolName == "USDC-ETH") {
372
- txb.moveCall({
373
- target: `${(0, constants_js_1.getConf)().ALPHA_LATEST_PACKAGE_ID}::alphafi_cetus_pool_base_a::user_deposit`,
374
- typeArguments: [coins_js_1.coinsList[pool1].type, coins_js_1.coinsList[pool2].type],
375
- arguments: [
376
- txb.object((0, constants_js_1.getConf)().VERSION),
377
- someReceipt,
378
- txb.object(poolinfo.poolId),
379
- depositCoinA,
380
- depositCoinB,
381
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
382
- txb.object(poolinfo.investorId),
383
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
384
- txb.object((0, constants_js_1.getConf)().CETUS_REWARDER_GLOBAL_VAULT_ID),
385
- txb.object(maps_js_1.cetusPoolMap[`${pool1}-SUI`]),
386
- txb.object(maps_js_1.cetusPoolMap["CETUS-SUI"]),
387
- txb.object(maps_js_1.cetusPoolMap[poolName]),
388
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
389
- ],
390
- });
391
- }
392
- else {
393
- txb.moveCall({
394
- target: `${(0, constants_js_1.getConf)().ALPHA_LATEST_PACKAGE_ID}::alphafi_cetus_pool::user_deposit`,
395
- typeArguments: [coins_js_1.coinsList[pool1].type, coins_js_1.coinsList[pool2].type],
396
- arguments: [
397
- txb.object((0, constants_js_1.getConf)().VERSION),
398
- someReceipt,
399
- txb.object(poolinfo.poolId),
400
- depositCoinA,
401
- depositCoinB,
402
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
403
- txb.object(poolinfo.investorId),
404
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
405
- txb.object((0, constants_js_1.getConf)().CETUS_REWARDER_GLOBAL_VAULT_ID),
406
- txb.object(maps_js_1.cetusPoolMap[`${pool2}-SUI`]),
407
- txb.object(maps_js_1.cetusPoolMap["CETUS-SUI"]),
408
- txb.object(maps_js_1.cetusPoolMap[poolName]),
409
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
410
- ],
411
- });
412
- }
413
- txb.transferObjects([coin1Arg, coin2Arg], address);
414
- }
415
- else {
416
- throw new Error(`No ${pool1} or ${pool2} Coins`);
417
- }
418
- return txb;
419
- };
420
- const depositCetusAlphaSuiTxb = async (amountA, amountB, poolName, options, transaction = undefined, coin1Arg, coin2Arg) => {
421
- const address = options.address;
422
- let txb;
423
- if (transaction)
424
- txb = transaction;
425
- else
426
- txb = new transactions_1.Transaction();
427
- poolName = poolName.toUpperCase();
428
- const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
429
- const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
430
- const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
431
- amountA = (Number(amountA) * 0.999).toString();
432
- amountB = (Number(amountB) * 0.999).toString();
433
- let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, amountA);
434
- if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
435
- amounts = await (0, deposit_js_1.getAmounts)(poolName, false, amountB);
436
- }
437
- if (amounts && coin1Arg != undefined && coin2Arg !== undefined) {
438
- const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
439
- const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
440
- const poolinfo = maps_js_1.poolInfo[poolName];
441
- let someReceipt;
442
- if (receipt.length == 0) {
443
- [someReceipt] = txb.moveCall({
444
- target: `0x1::option::none`,
445
- typeArguments: [poolinfo.receiptType],
446
- arguments: [],
447
- });
448
- }
449
- else {
450
- [someReceipt] = txb.moveCall({
451
- target: `0x1::option::some`,
452
- typeArguments: [receipt[0].content.type],
453
- arguments: [txb.object(receipt[0].objectId)],
454
- });
455
- }
361
+ if (poolName == "WUSDC-WBTC" ||
362
+ poolName == "USDC-USDT" ||
363
+ poolName == "USDC-WUSDC" ||
364
+ poolName == "USDC-ETH") {
456
365
  txb.moveCall({
457
- target: `${poolinfo.packageId}::alphafi_cetus_sui_pool::user_deposit`,
366
+ target: `${(0, constants_js_1.getConf)().ALPHA_LATEST_PACKAGE_ID}::alphafi_cetus_pool_base_a::user_deposit`,
458
367
  typeArguments: [coins_js_1.coinsList[pool1].type, coins_js_1.coinsList[pool2].type],
459
368
  arguments: [
460
369
  txb.object((0, constants_js_1.getConf)().VERSION),
@@ -466,59 +375,18 @@ const depositCetusAlphaSuiTxb = async (amountA, amountB, poolName, options, tran
466
375
  txb.object(poolinfo.investorId),
467
376
  txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
468
377
  txb.object((0, constants_js_1.getConf)().CETUS_REWARDER_GLOBAL_VAULT_ID),
378
+ txb.object(maps_js_1.cetusPoolMap[`${pool1}-SUI`]),
469
379
  txb.object(maps_js_1.cetusPoolMap["CETUS-SUI"]),
470
380
  txb.object(maps_js_1.cetusPoolMap[poolName]),
471
381
  txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
472
382
  ],
473
383
  });
474
- txb.transferObjects([coin1Arg, coin2Arg], address);
475
384
  }
476
385
  else {
477
- throw new Error(`No ${pool1} or ${pool2} Coins`);
478
- }
479
- return txb;
480
- };
481
- const depositCetusSuiTxb = async (amountA, amountB, poolName, options, transaction = undefined, coin1Arg, coin2Arg) => {
482
- const address = options.address;
483
- let txb;
484
- if (transaction)
485
- txb = transaction;
486
- else
487
- txb = new transactions_1.Transaction();
488
- poolName = poolName.toUpperCase();
489
- const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
490
- const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
491
- const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
492
- amountA = (Number(amountA) * 0.999).toString();
493
- amountB = (Number(amountB) * 0.999).toString();
494
- let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, amountA);
495
- if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
496
- amounts = await (0, deposit_js_1.getAmounts)(poolName, false, amountB);
497
- }
498
- if (amounts && coin1Arg && coin2Arg) {
499
- const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
500
- const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
501
- const poolinfo = maps_js_1.poolInfo[poolName];
502
- let someReceipt;
503
- if (receipt.length == 0) {
504
- [someReceipt] = txb.moveCall({
505
- target: `0x1::option::none`,
506
- typeArguments: [poolinfo.receiptType],
507
- arguments: [],
508
- });
509
- }
510
- else {
511
- [someReceipt] = txb.moveCall({
512
- target: `0x1::option::some`,
513
- typeArguments: [receipt[0].content.type],
514
- arguments: [txb.object(receipt[0].objectId)],
515
- });
516
- }
517
386
  txb.moveCall({
518
- target: `${poolinfo.packageId}::alphafi_cetus_sui_pool::user_deposit`,
387
+ target: `${(0, constants_js_1.getConf)().ALPHA_LATEST_PACKAGE_ID}::alphafi_cetus_pool::user_deposit`,
519
388
  typeArguments: [coins_js_1.coinsList[pool1].type, coins_js_1.coinsList[pool2].type],
520
389
  arguments: [
521
- txb.object((0, constants_js_1.getConf)().ALPHA_2_VERSION),
522
390
  txb.object((0, constants_js_1.getConf)().VERSION),
523
391
  someReceipt,
524
392
  txb.object(poolinfo.poolId),
@@ -528,1196 +396,1038 @@ const depositCetusSuiTxb = async (amountA, amountB, poolName, options, transacti
528
396
  txb.object(poolinfo.investorId),
529
397
  txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
530
398
  txb.object((0, constants_js_1.getConf)().CETUS_REWARDER_GLOBAL_VAULT_ID),
399
+ txb.object(maps_js_1.cetusPoolMap[`${pool2}-SUI`]),
400
+ txb.object(maps_js_1.cetusPoolMap["CETUS-SUI"]),
531
401
  txb.object(maps_js_1.cetusPoolMap[poolName]),
532
402
  txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
533
403
  ],
534
404
  });
535
- txb.transferObjects([coin1Arg, coin2Arg], address);
536
- }
537
- else {
538
- throw new Error(`No ${pool1} or ${pool2} Coins`);
539
405
  }
540
406
  return txb;
541
407
  };
542
- const depositBluefinSuiFirstTxb = async (amountA, amountB, poolName, options, transaction = undefined, coin1Arg, coin2Arg) => {
543
- const address = options.address;
544
- let txb;
545
- if (transaction)
546
- txb = transaction;
547
- else
548
- txb = new transactions_1.Transaction();
549
- poolName = poolName.toUpperCase();
408
+ const depositCetusAlphaSuiTxb = async (txb, someReceipt, poolName, depositCoinA, depositCoinB) => {
409
+ const poolinfo = maps_js_1.poolInfo[poolName];
550
410
  const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
551
411
  const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
552
- const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
553
- amountA = (Number(amountA) * 0.999).toString();
554
- amountB = (Number(amountB) * 0.999).toString();
555
- let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, amountA);
556
- if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
557
- amounts = await (0, deposit_js_1.getAmounts)(poolName, false, amountB);
558
- }
559
- if (amounts && coin1Arg && coin2Arg) {
560
- const [depositCoinA] = txb.splitCoins(txb.gas, [amounts[0]]);
561
- const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
562
- const poolinfo = maps_js_1.poolInfo[poolName];
563
- let someReceipt;
564
- if (receipt.length == 0) {
565
- [someReceipt] = txb.moveCall({
566
- target: `0x1::option::none`,
567
- typeArguments: [poolinfo.receiptType],
568
- arguments: [],
569
- });
570
- }
571
- else {
572
- [someReceipt] = txb.moveCall({
573
- target: `0x1::option::some`,
574
- typeArguments: [receipt[0].content.type],
575
- arguments: [txb.object(receipt[0].objectId)],
576
- });
577
- }
578
- if (poolName === "BLUEFIN-SUI-USDC") {
579
- txb.moveCall({
580
- target: `${poolinfo.packageId}::alphafi_bluefin_sui_first_pool::user_deposit_v2`,
581
- typeArguments: [
582
- coins_js_1.coinsList[pool1].type,
583
- coins_js_1.coinsList[pool2].type,
584
- coins_js_1.coinsList["BLUE"].type,
585
- coins_js_1.coinsList["SUI"].type,
586
- ],
587
- arguments: [
588
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
589
- txb.object((0, constants_js_1.getConf)().VERSION),
590
- someReceipt,
591
- txb.object(poolinfo.poolId),
592
- depositCoinA,
593
- depositCoinB,
594
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
595
- txb.object(poolinfo.investorId),
596
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
597
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
598
- txb.object((0, constants_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
599
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
600
- txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
601
- txb.object((0, constants_js_1.getConf)().LST_INFO),
602
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
603
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
604
- ],
605
- });
606
- }
607
- else if (poolName === "BLUEFIN-SUI-BUCK") {
608
- txb.moveCall({
609
- target: `${poolinfo.packageId}::alphafi_bluefin_sui_first_pool::user_deposit_v2`,
610
- typeArguments: [
611
- coins_js_1.coinsList[pool1].type,
612
- coins_js_1.coinsList[pool2].type,
613
- coins_js_1.coinsList["BLUE"].type,
614
- coins_js_1.coinsList["SUI"].type,
615
- ],
616
- arguments: [
617
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
618
- txb.object((0, constants_js_1.getConf)().VERSION),
619
- someReceipt,
620
- txb.object(poolinfo.poolId),
621
- depositCoinA,
622
- depositCoinB,
623
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
624
- txb.object(poolinfo.investorId),
625
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
626
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
627
- txb.object((0, constants_js_1.getConf)().BLUEFIN_SUI_BUCK_POOL),
628
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
629
- txb.object(maps_js_1.cetusPoolMap["BUCK-SUI"]),
630
- txb.object((0, constants_js_1.getConf)().LST_INFO),
631
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
632
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
633
- ],
634
- });
635
- }
636
- else if (poolName === "BLUEFIN-SUI-AUSD") {
637
- txb.moveCall({
638
- target: `${poolinfo.packageId}::alphafi_bluefin_sui_first_pool::user_deposit_v2`,
639
- typeArguments: [
640
- coins_js_1.coinsList[pool1].type,
641
- coins_js_1.coinsList[pool2].type,
642
- coins_js_1.coinsList["BLUE"].type,
643
- coins_js_1.coinsList["SUI"].type,
644
- ],
645
- arguments: [
646
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
647
- txb.object((0, constants_js_1.getConf)().VERSION),
648
- someReceipt,
649
- txb.object(poolinfo.poolId),
650
- depositCoinA,
651
- depositCoinB,
652
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
653
- txb.object(poolinfo.investorId),
654
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
655
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
656
- txb.object((0, constants_js_1.getConf)().BLUEFIN_SUI_AUSD_POOL),
657
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
658
- txb.object(maps_js_1.cetusPoolMap["AUSD-SUI"]),
659
- txb.object((0, constants_js_1.getConf)().LST_INFO),
660
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
661
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
662
- ],
663
- });
664
- }
665
- else if (poolName === "BLUEFIN-AUTOBALANCE-SUI-USDC") {
666
- txb.moveCall({
667
- target: `${poolinfo.packageId}::alphafi_bluefin_sui_first_pool::user_deposit_v2`,
668
- typeArguments: [
669
- coins_js_1.coinsList[pool1].type,
670
- coins_js_1.coinsList[pool2].type,
671
- coins_js_1.coinsList["BLUE"].type,
672
- coins_js_1.coinsList["SUI"].type,
673
- ],
674
- arguments: [
675
- txb.object((0, constants_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
676
- someReceipt,
677
- txb.object(poolinfo.poolId),
678
- depositCoinA,
679
- depositCoinB,
680
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
681
- txb.object(poolinfo.investorId),
682
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
683
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
684
- txb.object((0, constants_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
685
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
686
- txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
687
- txb.object((0, constants_js_1.getConf)().LST_INFO),
688
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
689
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
690
- ],
691
- });
692
- }
693
- txb.transferObjects([coin1Arg, coin2Arg], address);
694
- }
695
- else {
696
- throw new Error(`No ${pool1} or ${pool2} Coins`);
697
- }
412
+ txb.moveCall({
413
+ target: `${poolinfo.packageId}::alphafi_cetus_sui_pool::user_deposit`,
414
+ typeArguments: [coins_js_1.coinsList[pool1].type, coins_js_1.coinsList[pool2].type],
415
+ arguments: [
416
+ txb.object((0, constants_js_1.getConf)().VERSION),
417
+ someReceipt,
418
+ txb.object(poolinfo.poolId),
419
+ depositCoinA,
420
+ depositCoinB,
421
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
422
+ txb.object(poolinfo.investorId),
423
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
424
+ txb.object((0, constants_js_1.getConf)().CETUS_REWARDER_GLOBAL_VAULT_ID),
425
+ txb.object(maps_js_1.cetusPoolMap["CETUS-SUI"]),
426
+ txb.object(maps_js_1.cetusPoolMap[poolName]),
427
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
428
+ ],
429
+ });
430
+ return txb;
431
+ };
432
+ const depositCetusSuiTxb = async (txb, someReceipt, poolName, depositCoinA, depositCoinB) => {
433
+ const poolinfo = maps_js_1.poolInfo[poolName];
434
+ const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
435
+ const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
436
+ txb.moveCall({
437
+ target: `${poolinfo.packageId}::alphafi_cetus_sui_pool::user_deposit`,
438
+ typeArguments: [coins_js_1.coinsList[pool1].type, coins_js_1.coinsList[pool2].type],
439
+ arguments: [
440
+ txb.object((0, constants_js_1.getConf)().ALPHA_2_VERSION),
441
+ txb.object((0, constants_js_1.getConf)().VERSION),
442
+ someReceipt,
443
+ txb.object(poolinfo.poolId),
444
+ depositCoinA,
445
+ depositCoinB,
446
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
447
+ txb.object(poolinfo.investorId),
448
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
449
+ txb.object((0, constants_js_1.getConf)().CETUS_REWARDER_GLOBAL_VAULT_ID),
450
+ txb.object(maps_js_1.cetusPoolMap[poolName]),
451
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
452
+ ],
453
+ });
698
454
  return txb;
699
455
  };
700
- const depositBluefinType1Txb = async (amountA, amountB, poolName, options, transaction = undefined, coin1Arg, coin2Arg) => {
701
- const address = options.address;
702
- let txb;
703
- if (transaction)
704
- txb = transaction;
705
- else
706
- txb = new transactions_1.Transaction();
707
- poolName = poolName.toUpperCase();
456
+ const depositBluefinSuiFirstTxb = async (txb, someReceipt, poolName, depositCoinA, depositCoinB) => {
457
+ const poolinfo = maps_js_1.poolInfo[poolName];
708
458
  const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
709
459
  const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
710
- const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
711
- amountA = (Number(amountA) * 0.999).toString();
712
- amountB = (Number(amountB) * 0.999).toString();
713
- let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, amountA);
714
- if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
715
- amounts = await (0, deposit_js_1.getAmounts)(poolName, false, amountB);
460
+ if (poolName === "BLUEFIN-SUI-USDC") {
461
+ txb.moveCall({
462
+ target: `${poolinfo.packageId}::alphafi_bluefin_sui_first_pool::user_deposit_v2`,
463
+ typeArguments: [
464
+ coins_js_1.coinsList[pool1].type,
465
+ coins_js_1.coinsList[pool2].type,
466
+ coins_js_1.coinsList["BLUE"].type,
467
+ coins_js_1.coinsList["SUI"].type,
468
+ ],
469
+ arguments: [
470
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
471
+ txb.object((0, constants_js_1.getConf)().VERSION),
472
+ someReceipt,
473
+ txb.object(poolinfo.poolId),
474
+ depositCoinA,
475
+ depositCoinB,
476
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
477
+ txb.object(poolinfo.investorId),
478
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
479
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
480
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
481
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
482
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
483
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
484
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
485
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
486
+ ],
487
+ });
716
488
  }
717
- if (amounts && coin1Arg && coin2Arg) {
718
- const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
719
- const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
720
- const poolinfo = maps_js_1.poolInfo[poolName];
721
- let someReceipt;
722
- if (receipt.length == 0) {
723
- [someReceipt] = txb.moveCall({
724
- target: `0x1::option::none`,
725
- typeArguments: [poolinfo.receiptType],
726
- arguments: [],
727
- });
728
- }
729
- else {
730
- [someReceipt] = txb.moveCall({
731
- target: `0x1::option::some`,
732
- typeArguments: [receipt[0].content.type],
733
- arguments: [txb.object(receipt[0].objectId)],
734
- });
735
- }
736
- if (poolName === "BLUEFIN-USDT-USDC") {
737
- txb.moveCall({
738
- target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit_v2`,
739
- typeArguments: [
740
- coins_js_1.coinsList[pool1].type,
741
- coins_js_1.coinsList[pool2].type,
742
- coins_js_1.coinsList["BLUE"].type,
743
- coins_js_1.coinsList["SUI"].type,
744
- ],
745
- arguments: [
746
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
747
- txb.object((0, constants_js_1.getConf)().VERSION),
748
- someReceipt,
749
- txb.object(poolinfo.poolId),
750
- depositCoinA,
751
- depositCoinB,
752
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
753
- txb.object(poolinfo.investorId),
754
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
755
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
756
- txb.object((0, constants_js_1.getConf)().BLUEFIN_USDT_USDC_POOL),
757
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
758
- txb.object(maps_js_1.cetusPoolMap["USDC-USDT"]),
759
- txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
760
- txb.object((0, constants_js_1.getConf)().LST_INFO),
761
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
762
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
763
- ],
764
- });
765
- }
766
- else if (poolName === "BLUEFIN-AUSD-USDC") {
767
- txb.moveCall({
768
- target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit_v2`,
769
- typeArguments: [
770
- coins_js_1.coinsList[pool1].type,
771
- coins_js_1.coinsList[pool2].type,
772
- coins_js_1.coinsList["BLUE"].type,
773
- coins_js_1.coinsList["SUI"].type,
774
- ],
775
- arguments: [
776
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
777
- txb.object((0, constants_js_1.getConf)().VERSION),
778
- someReceipt,
779
- txb.object(poolinfo.poolId),
780
- depositCoinA,
781
- depositCoinB,
782
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
783
- txb.object(poolinfo.investorId),
784
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
785
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
786
- txb.object((0, constants_js_1.getConf)().BLUEFIN_AUSD_USDC_POOL),
787
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
788
- txb.object(maps_js_1.cetusPoolMap["USDC-AUSD"]),
789
- txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
790
- txb.object((0, constants_js_1.getConf)().LST_INFO),
791
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
792
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
793
- ],
794
- });
795
- }
796
- else if (poolName === "BLUEFIN-WBTC-USDC") {
797
- txb.moveCall({
798
- target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit_v2`,
799
- typeArguments: [
800
- coins_js_1.coinsList[pool1].type,
801
- coins_js_1.coinsList[pool2].type,
802
- coins_js_1.coinsList["BLUE"].type,
803
- coins_js_1.coinsList["SUI"].type,
804
- ],
805
- arguments: [
806
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
807
- txb.object((0, constants_js_1.getConf)().VERSION),
808
- someReceipt,
809
- txb.object(poolinfo.poolId),
810
- depositCoinA,
811
- depositCoinB,
812
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
813
- txb.object(poolinfo.investorId),
814
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
815
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
816
- txb.object((0, constants_js_1.getConf)().BLUEFIN_WBTC_USDC_POOL),
817
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
818
- txb.object(maps_js_1.cetusPoolMap["USDC-WBTC"]),
819
- txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
820
- txb.object((0, constants_js_1.getConf)().LST_INFO),
821
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
822
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
823
- ],
824
- });
825
- }
826
- else if (poolName === "BLUEFIN-SEND-USDC") {
827
- txb.moveCall({
828
- target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit_v2`,
829
- typeArguments: [
830
- coins_js_1.coinsList[pool1].type,
831
- coins_js_1.coinsList[pool2].type,
832
- coins_js_1.coinsList["BLUE"].type,
833
- coins_js_1.coinsList["SUI"].type,
834
- ],
835
- arguments: [
836
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
837
- txb.object((0, constants_js_1.getConf)().VERSION),
838
- someReceipt,
839
- txb.object(poolinfo.poolId),
840
- depositCoinA,
841
- depositCoinB,
842
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
843
- txb.object(poolinfo.investorId),
844
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
845
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
846
- txb.object((0, constants_js_1.getConf)().BLUEFIN_SEND_USDC_POOL),
847
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
848
- txb.object(maps_js_1.cetusPoolMap["USDC-SEND"]),
849
- txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
850
- txb.object((0, constants_js_1.getConf)().LST_INFO),
851
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
852
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
853
- ],
854
- });
855
- }
856
- else if (poolName === "BLUEFIN-STSUI-USDC") {
857
- txb.moveCall({
858
- target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit`,
859
- typeArguments: [
860
- coins_js_1.coinsList[pool1].type,
861
- coins_js_1.coinsList[pool2].type,
862
- coins_js_1.coinsList["BLUE"].type,
863
- coins_js_1.coinsList["SUI"].type,
864
- ],
865
- arguments: [
866
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
867
- txb.object((0, constants_js_1.getConf)().VERSION),
868
- someReceipt,
869
- txb.object(poolinfo.poolId),
870
- depositCoinA,
871
- depositCoinB,
872
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
873
- txb.object(poolinfo.investorId),
874
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
875
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
876
- txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_USDC_POOL),
877
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
878
- txb.object(maps_js_1.cetusPoolMap["USDC-STSUI"]),
879
- txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
880
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
881
- ],
882
- });
883
- }
884
- else if (poolName === "BLUEFIN-AUTOBALANCE-USDT-USDC") {
885
- txb.moveCall({
886
- target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit_v2`,
887
- typeArguments: [
888
- coins_js_1.coinsList["USDT"].type,
889
- coins_js_1.coinsList["USDC"].type,
890
- coins_js_1.coinsList["BLUE"].type,
891
- coins_js_1.coinsList["SUI"].type,
892
- ],
893
- arguments: [
894
- txb.object((0, constants_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
895
- someReceipt,
896
- txb.object(poolinfo.poolId),
897
- depositCoinA,
898
- depositCoinB,
899
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
900
- txb.object(poolinfo.investorId),
901
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
902
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
903
- txb.object((0, constants_js_1.getConf)().BLUEFIN_USDT_USDC_POOL),
904
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
905
- txb.object(maps_js_1.cetusPoolMap["USDC-USDT"]),
906
- txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
907
- txb.object((0, constants_js_1.getConf)().LST_INFO),
908
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
909
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
910
- ],
911
- });
912
- }
913
- else if (poolName === "BLUEFIN-SUIUSDT-USDC") {
914
- txb.moveCall({
915
- target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit_v2`,
916
- typeArguments: [
917
- coins_js_1.coinsList[pool1].type,
918
- coins_js_1.coinsList[pool2].type,
919
- coins_js_1.coinsList["BLUE"].type,
920
- coins_js_1.coinsList["SUI"].type,
921
- ],
922
- arguments: [
923
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
924
- txb.object((0, constants_js_1.getConf)().VERSION),
925
- someReceipt,
926
- txb.object(poolinfo.poolId),
927
- depositCoinA,
928
- depositCoinB,
929
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
930
- txb.object(poolinfo.investorId),
931
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
932
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
933
- txb.object((0, constants_js_1.getConf)().BLUEFIN_SUIUSDT_USDC_POOL),
934
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
935
- txb.object(maps_js_1.cetusPoolMap["USDC-SUIUSDT"]),
936
- txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
937
- txb.object((0, constants_js_1.getConf)().LST_INFO),
938
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
939
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
940
- ],
941
- });
942
- }
943
- else if (poolName === "BLUEFIN-AUTOBALANCE-SUIUSDT-USDC") {
944
- txb.moveCall({
945
- target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit_v2`,
946
- typeArguments: [
947
- coins_js_1.coinsList["SUIUSDT"].type,
948
- coins_js_1.coinsList["USDC"].type,
949
- coins_js_1.coinsList["BLUE"].type,
950
- coins_js_1.coinsList["SUI"].type,
951
- ],
952
- arguments: [
953
- txb.object((0, constants_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
954
- someReceipt,
955
- txb.object(poolinfo.poolId),
956
- depositCoinA,
957
- depositCoinB,
958
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
959
- txb.object(poolinfo.investorId),
960
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
961
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
962
- txb.object((0, constants_js_1.getConf)().BLUEFIN_SUIUSDT_USDC_POOL),
963
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
964
- txb.object(maps_js_1.cetusPoolMap["USDC-SUIUSDT"]),
965
- txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
966
- txb.object((0, constants_js_1.getConf)().LST_INFO),
967
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
968
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
969
- ],
970
- });
971
- }
972
- else if (poolName === "BLUEFIN-AUTOBALANCE-DEEP-BLUE") {
973
- txb.moveCall({
974
- target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit_v2`,
975
- typeArguments: [
976
- coins_js_1.coinsList["DEEP"].type,
977
- coins_js_1.coinsList["BLUE"].type,
978
- coins_js_1.coinsList["BLUE"].type,
979
- coins_js_1.coinsList["SUI"].type,
980
- ],
981
- arguments: [
982
- txb.object((0, constants_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
983
- someReceipt,
984
- txb.object(poolinfo.poolId),
985
- depositCoinA,
986
- depositCoinB,
987
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
988
- txb.object(poolinfo.investorId),
989
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
990
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
991
- txb.object((0, constants_js_1.getConf)().BLUEFIN_DEEP_BLUE_POOL),
992
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
993
- txb.object(maps_js_1.cetusPoolMap["BLUE-DEEP"]),
994
- txb.object(maps_js_1.cetusPoolMap["BLUE-SUI"]),
995
- txb.object((0, constants_js_1.getConf)().LST_INFO),
996
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
997
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
998
- ],
999
- });
1000
- }
1001
- txb.transferObjects([coin1Arg, coin2Arg], address);
489
+ else if (poolName === "BLUEFIN-SUI-BUCK") {
490
+ txb.moveCall({
491
+ target: `${poolinfo.packageId}::alphafi_bluefin_sui_first_pool::user_deposit_v2`,
492
+ typeArguments: [
493
+ coins_js_1.coinsList[pool1].type,
494
+ coins_js_1.coinsList[pool2].type,
495
+ coins_js_1.coinsList["BLUE"].type,
496
+ coins_js_1.coinsList["SUI"].type,
497
+ ],
498
+ arguments: [
499
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
500
+ txb.object((0, constants_js_1.getConf)().VERSION),
501
+ someReceipt,
502
+ txb.object(poolinfo.poolId),
503
+ depositCoinA,
504
+ depositCoinB,
505
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
506
+ txb.object(poolinfo.investorId),
507
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
508
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
509
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_SUI_BUCK_POOL),
510
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
511
+ txb.object(maps_js_1.cetusPoolMap["BUCK-SUI"]),
512
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
513
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
514
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
515
+ ],
516
+ });
1002
517
  }
1003
- else {
1004
- throw new Error(`No ${pool1} or ${pool2} Coins`);
518
+ else if (poolName === "BLUEFIN-SUI-AUSD") {
519
+ txb.moveCall({
520
+ target: `${poolinfo.packageId}::alphafi_bluefin_sui_first_pool::user_deposit_v2`,
521
+ typeArguments: [
522
+ coins_js_1.coinsList[pool1].type,
523
+ coins_js_1.coinsList[pool2].type,
524
+ coins_js_1.coinsList["BLUE"].type,
525
+ coins_js_1.coinsList["SUI"].type,
526
+ ],
527
+ arguments: [
528
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
529
+ txb.object((0, constants_js_1.getConf)().VERSION),
530
+ someReceipt,
531
+ txb.object(poolinfo.poolId),
532
+ depositCoinA,
533
+ depositCoinB,
534
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
535
+ txb.object(poolinfo.investorId),
536
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
537
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
538
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_SUI_AUSD_POOL),
539
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
540
+ txb.object(maps_js_1.cetusPoolMap["AUSD-SUI"]),
541
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
542
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
543
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
544
+ ],
545
+ });
546
+ }
547
+ else if (poolName === "BLUEFIN-AUTOBALANCE-SUI-USDC") {
548
+ txb.moveCall({
549
+ target: `${poolinfo.packageId}::alphafi_bluefin_sui_first_pool::user_deposit_v2`,
550
+ typeArguments: [
551
+ coins_js_1.coinsList[pool1].type,
552
+ coins_js_1.coinsList[pool2].type,
553
+ coins_js_1.coinsList["BLUE"].type,
554
+ coins_js_1.coinsList["SUI"].type,
555
+ ],
556
+ arguments: [
557
+ txb.object((0, constants_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
558
+ someReceipt,
559
+ txb.object(poolinfo.poolId),
560
+ depositCoinA,
561
+ depositCoinB,
562
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
563
+ txb.object(poolinfo.investorId),
564
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
565
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
566
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
567
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
568
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
569
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
570
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
571
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
572
+ ],
573
+ });
1005
574
  }
1006
575
  return txb;
1007
576
  };
1008
- const depositBluefinType2Txb = async (amountA, amountB, poolName, options, transaction = undefined, coin1Arg, coin2Arg) => {
1009
- const address = options.address;
1010
- let txb;
1011
- if (transaction)
1012
- txb = transaction;
1013
- else
1014
- txb = new transactions_1.Transaction();
1015
- poolName = poolName.toUpperCase();
577
+ const depositBluefinType1Txb = async (txb, someReceipt, poolName, depositCoinA, depositCoinB) => {
578
+ const poolinfo = maps_js_1.poolInfo[poolName];
1016
579
  const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
1017
580
  const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
1018
- const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
1019
- amountA = (Number(amountA) * 0.999).toString();
1020
- amountB = (Number(amountB) * 0.999).toString();
1021
- let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, amountA);
1022
- if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
1023
- amounts = await (0, deposit_js_1.getAmounts)(poolName, false, amountB);
581
+ if (poolName === "BLUEFIN-USDT-USDC") {
582
+ txb.moveCall({
583
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit_v2`,
584
+ typeArguments: [
585
+ coins_js_1.coinsList[pool1].type,
586
+ coins_js_1.coinsList[pool2].type,
587
+ coins_js_1.coinsList["BLUE"].type,
588
+ coins_js_1.coinsList["SUI"].type,
589
+ ],
590
+ arguments: [
591
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
592
+ txb.object((0, constants_js_1.getConf)().VERSION),
593
+ someReceipt,
594
+ txb.object(poolinfo.poolId),
595
+ depositCoinA,
596
+ depositCoinB,
597
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
598
+ txb.object(poolinfo.investorId),
599
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
600
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
601
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_USDT_USDC_POOL),
602
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
603
+ txb.object(maps_js_1.cetusPoolMap["USDC-USDT"]),
604
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
605
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
606
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
607
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
608
+ ],
609
+ });
1024
610
  }
1025
- if (amounts && coin1Arg && coin2Arg) {
1026
- const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
1027
- const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
1028
- const poolinfo = maps_js_1.poolInfo[poolName];
1029
- let someReceipt;
1030
- if (receipt.length == 0) {
1031
- [someReceipt] = txb.moveCall({
1032
- target: `0x1::option::none`,
1033
- typeArguments: [poolinfo.receiptType],
1034
- arguments: [],
1035
- });
1036
- }
1037
- else {
1038
- [someReceipt] = txb.moveCall({
1039
- target: `0x1::option::some`,
1040
- typeArguments: [receipt[0].content.type],
1041
- arguments: [txb.object(receipt[0].objectId)],
1042
- });
1043
- }
1044
- if (poolName === "BLUEFIN-ALPHA-USDC") {
1045
- txb.moveCall({
1046
- target: `${poolinfo.packageId}::alphafi_bluefin_type_2_pool::user_deposit_v2`,
1047
- typeArguments: [
1048
- coins_js_1.coinsList[pool1].type,
1049
- coins_js_1.coinsList[pool2].type,
1050
- coins_js_1.coinsList["BLUE"].type,
1051
- coins_js_1.coinsList["SUI"].type,
1052
- ],
1053
- arguments: [
1054
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
1055
- txb.object((0, constants_js_1.getConf)().VERSION),
1056
- someReceipt,
1057
- txb.object(poolinfo.poolId),
1058
- depositCoinA,
1059
- depositCoinB,
1060
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1061
- txb.object(poolinfo.investorId),
1062
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1063
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1064
- txb.object((0, constants_js_1.getConf)().BLUEFIN_ALPHA_USDC_POOL),
1065
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1066
- txb.object(maps_js_1.cetusPoolMap["ALPHA-USDC"]),
1067
- txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
1068
- txb.object((0, constants_js_1.getConf)().LST_INFO),
1069
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1070
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1071
- ],
1072
- });
1073
- }
1074
- else if (poolName === "BLUEFIN-NAVX-VSUI") {
1075
- txb.moveCall({
1076
- target: `${poolinfo.packageId}::alphafi_bluefin_type_2_pool::user_deposit_v2`,
1077
- typeArguments: [
1078
- coins_js_1.coinsList[pool1].type,
1079
- coins_js_1.coinsList[pool2].type,
1080
- coins_js_1.coinsList["BLUE"].type,
1081
- coins_js_1.coinsList["SUI"].type,
1082
- ],
1083
- arguments: [
1084
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
1085
- txb.object((0, constants_js_1.getConf)().VERSION),
1086
- someReceipt,
1087
- txb.object(poolinfo.poolId),
1088
- depositCoinA,
1089
- depositCoinB,
1090
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1091
- txb.object(poolinfo.investorId),
1092
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1093
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1094
- txb.object((0, constants_js_1.getConf)().BLUEFIN_NAVX_VSUI_POOL),
1095
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1096
- txb.object(maps_js_1.cetusPoolMap["NAVX-VSUI"]),
1097
- txb.object(maps_js_1.cetusPoolMap["VSUI-SUI"]),
1098
- txb.object((0, constants_js_1.getConf)().LST_INFO),
1099
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1100
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1101
- ],
1102
- });
1103
- }
1104
- else if (poolName === "BLUEFIN-BLUE-USDC") {
1105
- txb.moveCall({
1106
- target: `${poolinfo.packageId}::alphafi_bluefin_type_2_pool::user_deposit_v2`,
1107
- typeArguments: [
1108
- coins_js_1.coinsList[pool1].type,
1109
- coins_js_1.coinsList[pool2].type,
1110
- coins_js_1.coinsList["DEEP"].type,
1111
- coins_js_1.coinsList["SUI"].type,
1112
- ],
1113
- arguments: [
1114
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
1115
- txb.object((0, constants_js_1.getConf)().VERSION),
1116
- someReceipt,
1117
- txb.object(poolinfo.poolId),
1118
- depositCoinA,
1119
- depositCoinB,
1120
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1121
- txb.object(poolinfo.investorId),
1122
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1123
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1124
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_USDC_POOL),
1125
- txb.object((0, constants_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
1126
- txb.object(maps_js_1.cetusPoolMap["BLUE-USDC"]),
1127
- txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
1128
- txb.object((0, constants_js_1.getConf)().LST_INFO),
1129
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1130
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1131
- ],
1132
- });
1133
- }
1134
- else if (poolName === "BLUEFIN-STSUI-ETH") {
1135
- txb.moveCall({
1136
- target: `${poolinfo.packageId}::alphafi_bluefin_type_2_pool::user_deposit`,
1137
- typeArguments: [
1138
- coins_js_1.coinsList[pool1].type,
1139
- coins_js_1.coinsList[pool2].type,
1140
- coins_js_1.coinsList["BLUE"].type,
1141
- coins_js_1.coinsList["SUI"].type,
1142
- ],
1143
- arguments: [
1144
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
1145
- txb.object((0, constants_js_1.getConf)().VERSION),
1146
- someReceipt,
1147
- txb.object(poolinfo.poolId),
1148
- depositCoinA,
1149
- depositCoinB,
1150
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1151
- txb.object(poolinfo.investorId),
1152
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1153
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1154
- txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_ETH_POOL),
1155
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1156
- txb.object(maps_js_1.cetusPoolMap["STSUI-ETH"]),
1157
- txb.object(maps_js_1.cetusPoolMap["ETH-SUI"]),
1158
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1159
- ],
1160
- });
1161
- }
1162
- else if (poolName === "BLUEFIN-STSUI-WSOL") {
1163
- txb.moveCall({
1164
- target: `${poolinfo.packageId}::alphafi_bluefin_type_2_pool::user_deposit`,
1165
- typeArguments: [
1166
- coins_js_1.coinsList[pool1].type,
1167
- coins_js_1.coinsList[pool2].type,
1168
- coins_js_1.coinsList["BLUE"].type,
1169
- coins_js_1.coinsList["SUI"].type,
1170
- ],
1171
- arguments: [
1172
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
1173
- txb.object((0, constants_js_1.getConf)().VERSION),
1174
- someReceipt,
1175
- txb.object(poolinfo.poolId),
1176
- depositCoinA,
1177
- depositCoinB,
1178
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1179
- txb.object(poolinfo.investorId),
1180
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1181
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1182
- txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_WSOL_POOL),
1183
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1184
- txb.object(maps_js_1.cetusPoolMap["STSUI-WSOL"]),
1185
- txb.object(maps_js_1.cetusPoolMap["WSOL-SUI"]),
1186
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1187
- ],
1188
- });
1189
- }
1190
- txb.transferObjects([coin1Arg, coin2Arg], address);
611
+ else if (poolName === "BLUEFIN-AUSD-USDC") {
612
+ txb.moveCall({
613
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit_v2`,
614
+ typeArguments: [
615
+ coins_js_1.coinsList[pool1].type,
616
+ coins_js_1.coinsList[pool2].type,
617
+ coins_js_1.coinsList["BLUE"].type,
618
+ coins_js_1.coinsList["SUI"].type,
619
+ ],
620
+ arguments: [
621
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
622
+ txb.object((0, constants_js_1.getConf)().VERSION),
623
+ someReceipt,
624
+ txb.object(poolinfo.poolId),
625
+ depositCoinA,
626
+ depositCoinB,
627
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
628
+ txb.object(poolinfo.investorId),
629
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
630
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
631
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_AUSD_USDC_POOL),
632
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
633
+ txb.object(maps_js_1.cetusPoolMap["USDC-AUSD"]),
634
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
635
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
636
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
637
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
638
+ ],
639
+ });
1191
640
  }
1192
- else {
1193
- throw new Error(`No ${pool1} or ${pool2} Coins`);
641
+ else if (poolName === "BLUEFIN-WBTC-USDC") {
642
+ txb.moveCall({
643
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit_v2`,
644
+ typeArguments: [
645
+ coins_js_1.coinsList[pool1].type,
646
+ coins_js_1.coinsList[pool2].type,
647
+ coins_js_1.coinsList["BLUE"].type,
648
+ coins_js_1.coinsList["SUI"].type,
649
+ ],
650
+ arguments: [
651
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
652
+ txb.object((0, constants_js_1.getConf)().VERSION),
653
+ someReceipt,
654
+ txb.object(poolinfo.poolId),
655
+ depositCoinA,
656
+ depositCoinB,
657
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
658
+ txb.object(poolinfo.investorId),
659
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
660
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
661
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_WBTC_USDC_POOL),
662
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
663
+ txb.object(maps_js_1.cetusPoolMap["USDC-WBTC"]),
664
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
665
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
666
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
667
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
668
+ ],
669
+ });
670
+ }
671
+ else if (poolName === "BLUEFIN-SEND-USDC") {
672
+ txb.moveCall({
673
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit_v2`,
674
+ typeArguments: [
675
+ coins_js_1.coinsList[pool1].type,
676
+ coins_js_1.coinsList[pool2].type,
677
+ coins_js_1.coinsList["BLUE"].type,
678
+ coins_js_1.coinsList["SUI"].type,
679
+ ],
680
+ arguments: [
681
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
682
+ txb.object((0, constants_js_1.getConf)().VERSION),
683
+ someReceipt,
684
+ txb.object(poolinfo.poolId),
685
+ depositCoinA,
686
+ depositCoinB,
687
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
688
+ txb.object(poolinfo.investorId),
689
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
690
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
691
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_SEND_USDC_POOL),
692
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
693
+ txb.object(maps_js_1.cetusPoolMap["USDC-SEND"]),
694
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
695
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
696
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
697
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
698
+ ],
699
+ });
700
+ }
701
+ else if (poolName === "BLUEFIN-STSUI-USDC") {
702
+ txb.moveCall({
703
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit`,
704
+ typeArguments: [
705
+ coins_js_1.coinsList[pool1].type,
706
+ coins_js_1.coinsList[pool2].type,
707
+ coins_js_1.coinsList["BLUE"].type,
708
+ coins_js_1.coinsList["SUI"].type,
709
+ ],
710
+ arguments: [
711
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
712
+ txb.object((0, constants_js_1.getConf)().VERSION),
713
+ someReceipt,
714
+ txb.object(poolinfo.poolId),
715
+ depositCoinA,
716
+ depositCoinB,
717
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
718
+ txb.object(poolinfo.investorId),
719
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
720
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
721
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_USDC_POOL),
722
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
723
+ txb.object(maps_js_1.cetusPoolMap["USDC-STSUI"]),
724
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
725
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
726
+ ],
727
+ });
728
+ }
729
+ else if (poolName === "BLUEFIN-AUTOBALANCE-USDT-USDC") {
730
+ txb.moveCall({
731
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit_v2`,
732
+ typeArguments: [
733
+ coins_js_1.coinsList["USDT"].type,
734
+ coins_js_1.coinsList["USDC"].type,
735
+ coins_js_1.coinsList["BLUE"].type,
736
+ coins_js_1.coinsList["SUI"].type,
737
+ ],
738
+ arguments: [
739
+ txb.object((0, constants_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
740
+ someReceipt,
741
+ txb.object(poolinfo.poolId),
742
+ depositCoinA,
743
+ depositCoinB,
744
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
745
+ txb.object(poolinfo.investorId),
746
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
747
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
748
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_USDT_USDC_POOL),
749
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
750
+ txb.object(maps_js_1.cetusPoolMap["USDC-USDT"]),
751
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
752
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
753
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
754
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
755
+ ],
756
+ });
757
+ }
758
+ else if (poolName === "BLUEFIN-SUIUSDT-USDC") {
759
+ txb.moveCall({
760
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit_v2`,
761
+ typeArguments: [
762
+ coins_js_1.coinsList[pool1].type,
763
+ coins_js_1.coinsList[pool2].type,
764
+ coins_js_1.coinsList["BLUE"].type,
765
+ coins_js_1.coinsList["SUI"].type,
766
+ ],
767
+ arguments: [
768
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
769
+ txb.object((0, constants_js_1.getConf)().VERSION),
770
+ someReceipt,
771
+ txb.object(poolinfo.poolId),
772
+ depositCoinA,
773
+ depositCoinB,
774
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
775
+ txb.object(poolinfo.investorId),
776
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
777
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
778
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_SUIUSDT_USDC_POOL),
779
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
780
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUIUSDT"]),
781
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
782
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
783
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
784
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
785
+ ],
786
+ });
787
+ }
788
+ else if (poolName === "BLUEFIN-AUTOBALANCE-SUIUSDT-USDC") {
789
+ txb.moveCall({
790
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit_v2`,
791
+ typeArguments: [
792
+ coins_js_1.coinsList["SUIUSDT"].type,
793
+ coins_js_1.coinsList["USDC"].type,
794
+ coins_js_1.coinsList["BLUE"].type,
795
+ coins_js_1.coinsList["SUI"].type,
796
+ ],
797
+ arguments: [
798
+ txb.object((0, constants_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
799
+ someReceipt,
800
+ txb.object(poolinfo.poolId),
801
+ depositCoinA,
802
+ depositCoinB,
803
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
804
+ txb.object(poolinfo.investorId),
805
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
806
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
807
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_SUIUSDT_USDC_POOL),
808
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
809
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUIUSDT"]),
810
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
811
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
812
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
813
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
814
+ ],
815
+ });
816
+ }
817
+ else if (poolName === "BLUEFIN-AUTOBALANCE-DEEP-BLUE") {
818
+ txb.moveCall({
819
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit_v2`,
820
+ typeArguments: [
821
+ coins_js_1.coinsList["DEEP"].type,
822
+ coins_js_1.coinsList["BLUE"].type,
823
+ coins_js_1.coinsList["BLUE"].type,
824
+ coins_js_1.coinsList["SUI"].type,
825
+ ],
826
+ arguments: [
827
+ txb.object((0, constants_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
828
+ someReceipt,
829
+ txb.object(poolinfo.poolId),
830
+ depositCoinA,
831
+ depositCoinB,
832
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
833
+ txb.object(poolinfo.investorId),
834
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
835
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
836
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_DEEP_BLUE_POOL),
837
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
838
+ txb.object(maps_js_1.cetusPoolMap["BLUE-DEEP"]),
839
+ txb.object(maps_js_1.cetusPoolMap["BLUE-SUI"]),
840
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
841
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
842
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
843
+ ],
844
+ });
1194
845
  }
1195
846
  return txb;
1196
847
  };
1197
- const depositBluefinSuiSecondTxb = async (amountA, amountB, poolName, options, transaction = undefined, coin1Arg, coin2Arg) => {
1198
- const address = options.address;
1199
- let txb;
1200
- if (transaction)
1201
- txb = transaction;
1202
- else
1203
- txb = new transactions_1.Transaction();
1204
- poolName = poolName.toUpperCase();
848
+ const depositBluefinType2Txb = async (txb, someReceipt, poolName, depositCoinA, depositCoinB) => {
849
+ const poolinfo = maps_js_1.poolInfo[poolName];
1205
850
  const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
1206
851
  const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
1207
- const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
1208
- amountA = (Number(amountA) * 0.999).toString();
1209
- amountB = (Number(amountB) * 0.999).toString();
1210
- let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, amountA);
1211
- if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
1212
- amounts = await (0, deposit_js_1.getAmounts)(poolName, false, amountB);
852
+ if (poolName === "BLUEFIN-ALPHA-USDC") {
853
+ txb.moveCall({
854
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_2_pool::user_deposit_v2`,
855
+ typeArguments: [
856
+ coins_js_1.coinsList[pool1].type,
857
+ coins_js_1.coinsList[pool2].type,
858
+ coins_js_1.coinsList["BLUE"].type,
859
+ coins_js_1.coinsList["SUI"].type,
860
+ ],
861
+ arguments: [
862
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
863
+ txb.object((0, constants_js_1.getConf)().VERSION),
864
+ someReceipt,
865
+ txb.object(poolinfo.poolId),
866
+ depositCoinA,
867
+ depositCoinB,
868
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
869
+ txb.object(poolinfo.investorId),
870
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
871
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
872
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_ALPHA_USDC_POOL),
873
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
874
+ txb.object(maps_js_1.cetusPoolMap["ALPHA-USDC"]),
875
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
876
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
877
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
878
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
879
+ ],
880
+ });
1213
881
  }
1214
- if (amounts && coin1Arg && coin2Arg) {
1215
- const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
1216
- const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
1217
- const poolinfo = maps_js_1.poolInfo[poolName];
1218
- let someReceipt;
1219
- if (receipt.length == 0) {
1220
- [someReceipt] = txb.moveCall({
1221
- target: `0x1::option::none`,
1222
- typeArguments: [poolinfo.receiptType],
1223
- arguments: [],
1224
- });
1225
- }
1226
- else {
1227
- [someReceipt] = txb.moveCall({
1228
- target: `0x1::option::some`,
1229
- typeArguments: [receipt[0].content.type],
1230
- arguments: [txb.object(receipt[0].objectId)],
1231
- });
1232
- }
1233
- if (poolName === "BLUEFIN-BLUE-SUI") {
1234
- txb.moveCall({
1235
- target: `${poolinfo.packageId}::alphafi_bluefin_sui_second_pool::user_deposit_v2`,
1236
- typeArguments: [
1237
- coins_js_1.coinsList[pool1].type,
1238
- coins_js_1.coinsList[pool2].type,
1239
- coins_js_1.coinsList["DEEP"].type,
1240
- coins_js_1.coinsList["SUI"].type,
1241
- ],
1242
- arguments: [
1243
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
1244
- txb.object((0, constants_js_1.getConf)().VERSION),
1245
- someReceipt,
1246
- txb.object(poolinfo.poolId),
1247
- depositCoinA,
1248
- depositCoinB,
1249
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1250
- txb.object(poolinfo.investorId),
1251
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1252
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1253
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1254
- txb.object((0, constants_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
1255
- txb.object(maps_js_1.cetusPoolMap["BLUE-SUI"]),
1256
- txb.object((0, constants_js_1.getConf)().LST_INFO),
1257
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1258
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1259
- ],
1260
- });
1261
- }
1262
- else if (poolName === "BLUEFIN-WBTC-SUI") {
1263
- txb.moveCall({
1264
- target: `${poolinfo.packageId}::alphafi_bluefin_sui_second_pool::user_deposit_v2`,
1265
- typeArguments: [
1266
- coins_js_1.coinsList[pool1].type,
1267
- coins_js_1.coinsList[pool2].type,
1268
- coins_js_1.coinsList["BLUE"].type,
1269
- coins_js_1.coinsList["SUI"].type,
1270
- ],
1271
- arguments: [
1272
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
1273
- txb.object((0, constants_js_1.getConf)().VERSION),
1274
- someReceipt,
1275
- txb.object(poolinfo.poolId),
1276
- depositCoinA,
1277
- depositCoinB,
1278
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1279
- txb.object(poolinfo.investorId),
1280
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1281
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1282
- txb.object((0, constants_js_1.getConf)().BLUEFIN_WBTC_SUI_POOL),
1283
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1284
- txb.object(maps_js_1.cetusPoolMap["WBTC-SUI"]),
1285
- txb.object((0, constants_js_1.getConf)().LST_INFO),
1286
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1287
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1288
- ],
1289
- });
1290
- }
1291
- else if (poolName === "BLUEFIN-DEEP-SUI") {
1292
- txb.moveCall({
1293
- target: `${poolinfo.packageId}::alphafi_bluefin_sui_second_pool::user_deposit_v2`,
1294
- typeArguments: [
1295
- coins_js_1.coinsList[pool1].type,
1296
- coins_js_1.coinsList[pool2].type,
1297
- coins_js_1.coinsList["BLUE"].type,
1298
- coins_js_1.coinsList["SUI"].type,
1299
- ],
1300
- arguments: [
1301
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
1302
- txb.object((0, constants_js_1.getConf)().VERSION),
1303
- someReceipt,
1304
- txb.object(poolinfo.poolId),
1305
- depositCoinA,
1306
- depositCoinB,
1307
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1308
- txb.object(poolinfo.investorId),
1309
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1310
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1311
- txb.object((0, constants_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
1312
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1313
- txb.object(maps_js_1.cetusPoolMap["DEEP-SUI"]),
1314
- txb.object((0, constants_js_1.getConf)().LST_INFO),
1315
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1316
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1317
- ],
1318
- });
1319
- }
1320
- else if (poolName === "BLUEFIN-STSUI-SUI") {
1321
- txb.moveCall({
1322
- target: `${poolinfo.packageId}::alphafi_bluefin_stsui_sui_pool::user_deposit`,
1323
- typeArguments: [
1324
- coins_js_1.coinsList[pool1].type,
1325
- coins_js_1.coinsList[pool2].type,
1326
- coins_js_1.coinsList["BLUE"].type,
1327
- ],
1328
- arguments: [
1329
- txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
1330
- txb.object((0, constants_js_1.getConf)().VERSION),
1331
- someReceipt,
1332
- txb.object(poolinfo.poolId),
1333
- depositCoinA,
1334
- depositCoinB,
1335
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1336
- txb.object(poolinfo.investorId),
1337
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1338
- txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_SUI_POOL),
1339
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1340
- txb.object((0, constants_js_1.getConf)().LST_INFO),
1341
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1342
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1343
- ],
1344
- });
1345
- }
1346
- else if (poolName === "BLUEFIN-AUTOBALANCE-DEEP-SUI") {
1347
- txb.moveCall({
1348
- target: `${poolinfo.packageId}::alphafi_bluefin_sui_second_pool::user_deposit_v2`,
1349
- typeArguments: [
1350
- coins_js_1.coinsList[pool1].type,
1351
- coins_js_1.coinsList[pool2].type,
1352
- coins_js_1.coinsList["BLUE"].type,
1353
- ],
1354
- arguments: [
1355
- txb.object((0, constants_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
1356
- someReceipt,
1357
- txb.object(poolinfo.poolId),
1358
- depositCoinA,
1359
- depositCoinB,
1360
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1361
- txb.object(poolinfo.investorId),
1362
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1363
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1364
- txb.object((0, constants_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
1365
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1366
- txb.object(maps_js_1.cetusPoolMap["DEEP-SUI"]),
1367
- txb.object((0, constants_js_1.getConf)().LST_INFO),
1368
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1369
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1370
- ],
1371
- });
1372
- }
1373
- else if (poolName === "BLUEFIN-AUTOBALANCE-BLUE-SUI") {
1374
- txb.moveCall({
1375
- target: `${poolinfo.packageId}::alphafi_bluefin_sui_second_pool::user_deposit_v2`,
1376
- typeArguments: [
1377
- coins_js_1.coinsList[pool1].type,
1378
- coins_js_1.coinsList[pool2].type,
1379
- coins_js_1.coinsList["DEEP"].type,
1380
- ],
1381
- arguments: [
1382
- txb.object((0, constants_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
1383
- someReceipt,
1384
- txb.object(poolinfo.poolId),
1385
- depositCoinA,
1386
- depositCoinB,
1387
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1388
- txb.object(poolinfo.investorId),
1389
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1390
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1391
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1392
- txb.object((0, constants_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
1393
- txb.object(maps_js_1.cetusPoolMap["BLUE-SUI"]),
1394
- txb.object((0, constants_js_1.getConf)().LST_INFO),
1395
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1396
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1397
- ],
1398
- });
1399
- }
1400
- txb.transferObjects([coin1Arg, coin2Arg], address);
882
+ else if (poolName === "BLUEFIN-NAVX-VSUI") {
883
+ txb.moveCall({
884
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_2_pool::user_deposit_v2`,
885
+ typeArguments: [
886
+ coins_js_1.coinsList[pool1].type,
887
+ coins_js_1.coinsList[pool2].type,
888
+ coins_js_1.coinsList["BLUE"].type,
889
+ coins_js_1.coinsList["SUI"].type,
890
+ ],
891
+ arguments: [
892
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
893
+ txb.object((0, constants_js_1.getConf)().VERSION),
894
+ someReceipt,
895
+ txb.object(poolinfo.poolId),
896
+ depositCoinA,
897
+ depositCoinB,
898
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
899
+ txb.object(poolinfo.investorId),
900
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
901
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
902
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_NAVX_VSUI_POOL),
903
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
904
+ txb.object(maps_js_1.cetusPoolMap["NAVX-VSUI"]),
905
+ txb.object(maps_js_1.cetusPoolMap["VSUI-SUI"]),
906
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
907
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
908
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
909
+ ],
910
+ });
1401
911
  }
1402
- else {
1403
- throw new Error(`No ${pool1} or ${pool2} Coins`);
912
+ else if (poolName === "BLUEFIN-BLUE-USDC") {
913
+ txb.moveCall({
914
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_2_pool::user_deposit_v2`,
915
+ typeArguments: [
916
+ coins_js_1.coinsList[pool1].type,
917
+ coins_js_1.coinsList[pool2].type,
918
+ coins_js_1.coinsList["DEEP"].type,
919
+ coins_js_1.coinsList["SUI"].type,
920
+ ],
921
+ arguments: [
922
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
923
+ txb.object((0, constants_js_1.getConf)().VERSION),
924
+ someReceipt,
925
+ txb.object(poolinfo.poolId),
926
+ depositCoinA,
927
+ depositCoinB,
928
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
929
+ txb.object(poolinfo.investorId),
930
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
931
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
932
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_USDC_POOL),
933
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
934
+ txb.object(maps_js_1.cetusPoolMap["BLUE-USDC"]),
935
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
936
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
937
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
938
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
939
+ ],
940
+ });
941
+ }
942
+ else if (poolName === "BLUEFIN-STSUI-ETH") {
943
+ txb.moveCall({
944
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_2_pool::user_deposit`,
945
+ typeArguments: [
946
+ coins_js_1.coinsList[pool1].type,
947
+ coins_js_1.coinsList[pool2].type,
948
+ coins_js_1.coinsList["BLUE"].type,
949
+ coins_js_1.coinsList["SUI"].type,
950
+ ],
951
+ arguments: [
952
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
953
+ txb.object((0, constants_js_1.getConf)().VERSION),
954
+ someReceipt,
955
+ txb.object(poolinfo.poolId),
956
+ depositCoinA,
957
+ depositCoinB,
958
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
959
+ txb.object(poolinfo.investorId),
960
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
961
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
962
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_ETH_POOL),
963
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
964
+ txb.object(maps_js_1.cetusPoolMap["STSUI-ETH"]),
965
+ txb.object(maps_js_1.cetusPoolMap["ETH-SUI"]),
966
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
967
+ ],
968
+ });
969
+ }
970
+ else if (poolName === "BLUEFIN-STSUI-WSOL") {
971
+ txb.moveCall({
972
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_2_pool::user_deposit`,
973
+ typeArguments: [
974
+ coins_js_1.coinsList[pool1].type,
975
+ coins_js_1.coinsList[pool2].type,
976
+ coins_js_1.coinsList["BLUE"].type,
977
+ coins_js_1.coinsList["SUI"].type,
978
+ ],
979
+ arguments: [
980
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
981
+ txb.object((0, constants_js_1.getConf)().VERSION),
982
+ someReceipt,
983
+ txb.object(poolinfo.poolId),
984
+ depositCoinA,
985
+ depositCoinB,
986
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
987
+ txb.object(poolinfo.investorId),
988
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
989
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
990
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_WSOL_POOL),
991
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
992
+ txb.object(maps_js_1.cetusPoolMap["STSUI-WSOL"]),
993
+ txb.object(maps_js_1.cetusPoolMap["WSOL-SUI"]),
994
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
995
+ ],
996
+ });
1404
997
  }
1405
998
  return txb;
1406
999
  };
1407
- const depositBluefinStsuiTxb = async (amountA, amountB, poolName, options, transaction = undefined, coin1Arg, coin2Arg) => {
1408
- const address = options.address;
1409
- let txb;
1410
- if (transaction)
1411
- txb = transaction;
1412
- else
1413
- txb = new transactions_1.Transaction();
1414
- poolName = poolName.toUpperCase();
1000
+ const depositBluefinSuiSecondTxb = async (txb, someReceipt, poolName, depositCoinA, depositCoinB) => {
1001
+ const poolinfo = maps_js_1.poolInfo[poolName];
1415
1002
  const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
1416
1003
  const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
1417
- const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
1418
- amountA = (Number(amountA) * 0.999).toString();
1419
- amountB = (Number(amountB) * 0.999).toString();
1420
- let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, amountA);
1421
- if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
1422
- amounts = await (0, deposit_js_1.getAmounts)(poolName, false, amountB);
1004
+ if (poolName === "BLUEFIN-BLUE-SUI") {
1005
+ txb.moveCall({
1006
+ target: `${poolinfo.packageId}::alphafi_bluefin_sui_second_pool::user_deposit_v2`,
1007
+ typeArguments: [
1008
+ coins_js_1.coinsList[pool1].type,
1009
+ coins_js_1.coinsList[pool2].type,
1010
+ coins_js_1.coinsList["DEEP"].type,
1011
+ coins_js_1.coinsList["SUI"].type,
1012
+ ],
1013
+ arguments: [
1014
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
1015
+ txb.object((0, constants_js_1.getConf)().VERSION),
1016
+ someReceipt,
1017
+ txb.object(poolinfo.poolId),
1018
+ depositCoinA,
1019
+ depositCoinB,
1020
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1021
+ txb.object(poolinfo.investorId),
1022
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1023
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1024
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1025
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
1026
+ txb.object(maps_js_1.cetusPoolMap["BLUE-SUI"]),
1027
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
1028
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1029
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1030
+ ],
1031
+ });
1423
1032
  }
1424
- if (amounts && coin1Arg && coin2Arg) {
1425
- const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
1426
- const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
1427
- const poolinfo = maps_js_1.poolInfo[poolName];
1428
- let someReceipt;
1429
- if (receipt.length == 0) {
1430
- [someReceipt] = txb.moveCall({
1431
- target: `0x1::option::none`,
1432
- typeArguments: [poolinfo.receiptType],
1433
- arguments: [],
1434
- });
1435
- }
1436
- else {
1437
- [someReceipt] = txb.moveCall({
1438
- target: `0x1::option::some`,
1439
- typeArguments: [receipt[0].content.type],
1440
- arguments: [txb.object(receipt[0].objectId)],
1441
- });
1442
- }
1443
- if (poolName === "BLUEFIN-STSUI-USDC") {
1444
- txb.moveCall({
1445
- target: `${poolinfo.packageId}::alphafi_bluefin_stsui_first_pool::user_deposit`,
1446
- typeArguments: [
1447
- coins_js_1.coinsList[pool1].type,
1448
- coins_js_1.coinsList[pool2].type,
1449
- coins_js_1.coinsList["BLUE"].type,
1450
- ],
1451
- arguments: [
1452
- txb.object((0, constants_js_1.getConf)().ALPHA_STSUI_VERSION),
1453
- txb.object((0, constants_js_1.getConf)().VERSION),
1454
- someReceipt,
1455
- txb.object(poolinfo.poolId),
1456
- depositCoinA,
1457
- depositCoinB,
1458
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1459
- txb.object(poolinfo.investorId),
1460
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1461
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1462
- txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_USDC_POOL),
1463
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1464
- txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
1465
- txb.object(maps_js_1.bluefinPoolMap["SUI-USDC"]),
1466
- txb.object((0, constants_js_1.getConf)().LST_INFO),
1467
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1468
- txb.pure.bool(true),
1469
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1470
- ],
1471
- });
1472
- }
1473
- else if (poolName === "BLUEFIN-ALPHA-STSUI") {
1474
- txb.moveCall({
1475
- target: `${poolinfo.packageId}::alphafi_bluefin_stsui_second_pool::user_deposit`,
1476
- typeArguments: [
1477
- coins_js_1.coinsList[pool1].type,
1478
- coins_js_1.coinsList[pool2].type,
1479
- coins_js_1.coinsList["BLUE"].type,
1480
- ],
1481
- arguments: [
1482
- txb.object((0, constants_js_1.getConf)().ALPHA_STSUI_VERSION),
1483
- txb.object((0, constants_js_1.getConf)().VERSION),
1484
- someReceipt,
1485
- txb.object(poolinfo.poolId),
1486
- depositCoinA,
1487
- depositCoinB,
1488
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1489
- txb.object(poolinfo.investorId),
1490
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1491
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1492
- txb.object((0, constants_js_1.getConf)().BLUEFIN_ALPHA_STSUI_POOL),
1493
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1494
- txb.object(maps_js_1.cetusPoolMap["ALPHA-SUI"]),
1495
- txb.object(maps_js_1.bluefinPoolMap["SUI-ALPHA"]),
1496
- txb.object((0, constants_js_1.getConf)().LST_INFO),
1497
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1498
- txb.pure.bool(false),
1499
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1500
- ],
1501
- });
1502
- }
1503
- else if (poolName === "BLUEFIN-STSUI-WSOL") {
1504
- txb.moveCall({
1505
- target: `${poolinfo.packageId}::alphafi_bluefin_stsui_first_pool::user_deposit`,
1506
- typeArguments: [
1507
- coins_js_1.coinsList[pool1].type,
1508
- coins_js_1.coinsList[pool2].type,
1509
- coins_js_1.coinsList["BLUE"].type,
1510
- ],
1511
- arguments: [
1512
- txb.object((0, constants_js_1.getConf)().ALPHA_STSUI_VERSION),
1513
- txb.object((0, constants_js_1.getConf)().VERSION),
1514
- someReceipt,
1515
- txb.object(poolinfo.poolId),
1516
- depositCoinA,
1517
- depositCoinB,
1518
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1519
- txb.object(poolinfo.investorId),
1520
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1521
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1522
- txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_WSOL_POOL),
1523
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1524
- txb.object(maps_js_1.cetusPoolMap["WSOL-SUI"]),
1525
- txb.object(maps_js_1.bluefinPoolMap["SUI-WSOL"]),
1526
- txb.object((0, constants_js_1.getConf)().LST_INFO),
1527
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1528
- txb.pure.bool(false),
1529
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1530
- ],
1531
- });
1532
- }
1533
- else if (poolName === "BLUEFIN-STSUI-ETH") {
1534
- txb.moveCall({
1535
- target: `${poolinfo.packageId}::alphafi_bluefin_stsui_first_pool::user_deposit`,
1536
- typeArguments: [
1537
- coins_js_1.coinsList[pool1].type,
1538
- coins_js_1.coinsList[pool2].type,
1539
- coins_js_1.coinsList["BLUE"].type,
1540
- ],
1541
- arguments: [
1542
- txb.object((0, constants_js_1.getConf)().ALPHA_STSUI_VERSION),
1543
- txb.object((0, constants_js_1.getConf)().VERSION),
1544
- someReceipt,
1545
- txb.object(poolinfo.poolId),
1546
- depositCoinA,
1547
- depositCoinB,
1548
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1549
- txb.object(poolinfo.investorId),
1550
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1551
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1552
- txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_ETH_POOL),
1553
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1554
- txb.object(maps_js_1.cetusPoolMap["ETH-SUI"]),
1555
- txb.object(maps_js_1.bluefinPoolMap["SUI-ETH"]),
1556
- txb.object((0, constants_js_1.getConf)().LST_INFO),
1557
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1558
- txb.pure.bool(false),
1559
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1560
- ],
1561
- });
1562
- }
1563
- else if (poolName === "BLUEFIN-STSUI-BUCK") {
1564
- txb.moveCall({
1565
- target: `${poolinfo.packageId}::alphafi_bluefin_stsui_first_pool::user_deposit`,
1566
- typeArguments: [
1567
- coins_js_1.coinsList[pool1].type,
1568
- coins_js_1.coinsList[pool2].type,
1569
- coins_js_1.coinsList["BLUE"].type,
1570
- ],
1571
- arguments: [
1572
- txb.object((0, constants_js_1.getConf)().ALPHA_STSUI_VERSION),
1573
- txb.object((0, constants_js_1.getConf)().VERSION),
1574
- someReceipt,
1575
- txb.object(poolinfo.poolId),
1576
- depositCoinA,
1577
- depositCoinB,
1578
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1579
- txb.object(poolinfo.investorId),
1580
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1581
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1582
- txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_BUCK_POOL),
1583
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1584
- txb.object(maps_js_1.cetusPoolMap["BUCK-SUI"]),
1585
- txb.object(maps_js_1.bluefinPoolMap["SUI-BUCK"]),
1586
- txb.object((0, constants_js_1.getConf)().LST_INFO),
1587
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1588
- txb.pure.bool(false),
1589
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1590
- ],
1591
- });
1592
- }
1593
- else if (poolName === "BLUEFIN-STSUI-MUSD") {
1594
- txb.moveCall({
1595
- target: `${poolinfo.packageId}::alphafi_bluefin_stsui_first_pool::user_deposit`,
1596
- typeArguments: [
1597
- coins_js_1.coinsList[pool1].type,
1598
- coins_js_1.coinsList[pool2].type,
1599
- coins_js_1.coinsList["BLUE"].type,
1600
- ],
1601
- arguments: [
1602
- txb.object((0, constants_js_1.getConf)().ALPHA_STSUI_VERSION),
1603
- txb.object((0, constants_js_1.getConf)().VERSION),
1604
- someReceipt,
1605
- txb.object(poolinfo.poolId),
1606
- depositCoinA,
1607
- depositCoinB,
1608
- txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1609
- txb.object(poolinfo.investorId),
1610
- txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1611
- txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1612
- txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_MUSD_POOL),
1613
- txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1614
- txb.object(maps_js_1.cetusPoolMap["MUSD-SUI"]),
1615
- txb.object(maps_js_1.bluefinPoolMap["SUI-MUSD"]),
1616
- txb.object((0, constants_js_1.getConf)().LST_INFO),
1617
- txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1618
- txb.pure.bool(true),
1619
- txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1620
- ],
1621
- });
1622
- }
1623
- txb.transferObjects([coin1Arg, coin2Arg], address);
1033
+ else if (poolName === "BLUEFIN-WBTC-SUI") {
1034
+ txb.moveCall({
1035
+ target: `${poolinfo.packageId}::alphafi_bluefin_sui_second_pool::user_deposit_v2`,
1036
+ typeArguments: [
1037
+ coins_js_1.coinsList[pool1].type,
1038
+ coins_js_1.coinsList[pool2].type,
1039
+ coins_js_1.coinsList["BLUE"].type,
1040
+ coins_js_1.coinsList["SUI"].type,
1041
+ ],
1042
+ arguments: [
1043
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
1044
+ txb.object((0, constants_js_1.getConf)().VERSION),
1045
+ someReceipt,
1046
+ txb.object(poolinfo.poolId),
1047
+ depositCoinA,
1048
+ depositCoinB,
1049
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1050
+ txb.object(poolinfo.investorId),
1051
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1052
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1053
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_WBTC_SUI_POOL),
1054
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1055
+ txb.object(maps_js_1.cetusPoolMap["WBTC-SUI"]),
1056
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
1057
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1058
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1059
+ ],
1060
+ });
1624
1061
  }
1625
- else {
1626
- throw new Error(`No ${pool1} or ${pool2} Coins`);
1062
+ else if (poolName === "BLUEFIN-DEEP-SUI") {
1063
+ txb.moveCall({
1064
+ target: `${poolinfo.packageId}::alphafi_bluefin_sui_second_pool::user_deposit_v2`,
1065
+ typeArguments: [
1066
+ coins_js_1.coinsList[pool1].type,
1067
+ coins_js_1.coinsList[pool2].type,
1068
+ coins_js_1.coinsList["BLUE"].type,
1069
+ coins_js_1.coinsList["SUI"].type,
1070
+ ],
1071
+ arguments: [
1072
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
1073
+ txb.object((0, constants_js_1.getConf)().VERSION),
1074
+ someReceipt,
1075
+ txb.object(poolinfo.poolId),
1076
+ depositCoinA,
1077
+ depositCoinB,
1078
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1079
+ txb.object(poolinfo.investorId),
1080
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1081
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1082
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
1083
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1084
+ txb.object(maps_js_1.cetusPoolMap["DEEP-SUI"]),
1085
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
1086
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1087
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1088
+ ],
1089
+ });
1090
+ }
1091
+ else if (poolName === "BLUEFIN-STSUI-SUI") {
1092
+ txb.moveCall({
1093
+ target: `${poolinfo.packageId}::alphafi_bluefin_stsui_sui_pool::user_deposit`,
1094
+ typeArguments: [
1095
+ coins_js_1.coinsList[pool1].type,
1096
+ coins_js_1.coinsList[pool2].type,
1097
+ coins_js_1.coinsList["BLUE"].type,
1098
+ ],
1099
+ arguments: [
1100
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
1101
+ txb.object((0, constants_js_1.getConf)().VERSION),
1102
+ someReceipt,
1103
+ txb.object(poolinfo.poolId),
1104
+ depositCoinA,
1105
+ depositCoinB,
1106
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1107
+ txb.object(poolinfo.investorId),
1108
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1109
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_SUI_POOL),
1110
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1111
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
1112
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1113
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1114
+ ],
1115
+ });
1116
+ }
1117
+ else if (poolName === "BLUEFIN-AUTOBALANCE-DEEP-SUI") {
1118
+ txb.moveCall({
1119
+ target: `${poolinfo.packageId}::alphafi_bluefin_sui_second_pool::user_deposit_v2`,
1120
+ typeArguments: [
1121
+ coins_js_1.coinsList[pool1].type,
1122
+ coins_js_1.coinsList[pool2].type,
1123
+ coins_js_1.coinsList["BLUE"].type,
1124
+ ],
1125
+ arguments: [
1126
+ txb.object((0, constants_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
1127
+ someReceipt,
1128
+ txb.object(poolinfo.poolId),
1129
+ depositCoinA,
1130
+ depositCoinB,
1131
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1132
+ txb.object(poolinfo.investorId),
1133
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1134
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1135
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
1136
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1137
+ txb.object(maps_js_1.cetusPoolMap["DEEP-SUI"]),
1138
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
1139
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1140
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1141
+ ],
1142
+ });
1143
+ }
1144
+ else if (poolName === "BLUEFIN-AUTOBALANCE-BLUE-SUI") {
1145
+ txb.moveCall({
1146
+ target: `${poolinfo.packageId}::alphafi_bluefin_sui_second_pool::user_deposit_v2`,
1147
+ typeArguments: [
1148
+ coins_js_1.coinsList[pool1].type,
1149
+ coins_js_1.coinsList[pool2].type,
1150
+ coins_js_1.coinsList["DEEP"].type,
1151
+ ],
1152
+ arguments: [
1153
+ txb.object((0, constants_js_1.getConf)().ALPHA_BLUEFIN_AUTOBALANCE_VERSION),
1154
+ someReceipt,
1155
+ txb.object(poolinfo.poolId),
1156
+ depositCoinA,
1157
+ depositCoinB,
1158
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1159
+ txb.object(poolinfo.investorId),
1160
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1161
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1162
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1163
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
1164
+ txb.object(maps_js_1.cetusPoolMap["BLUE-SUI"]),
1165
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
1166
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1167
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1168
+ ],
1169
+ });
1170
+ }
1171
+ return txb;
1172
+ };
1173
+ const depositBluefinStsuiTxb = async (txb, someReceipt, poolName, depositCoinA, depositCoinB) => {
1174
+ const poolinfo = maps_js_1.poolInfo[poolName];
1175
+ const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
1176
+ const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
1177
+ if (poolName === "BLUEFIN-STSUI-USDC") {
1178
+ txb.moveCall({
1179
+ target: `${poolinfo.packageId}::alphafi_bluefin_stsui_first_pool::user_deposit`,
1180
+ typeArguments: [
1181
+ coins_js_1.coinsList[pool1].type,
1182
+ coins_js_1.coinsList[pool2].type,
1183
+ coins_js_1.coinsList["BLUE"].type,
1184
+ ],
1185
+ arguments: [
1186
+ txb.object((0, constants_js_1.getConf)().ALPHA_STSUI_VERSION),
1187
+ txb.object((0, constants_js_1.getConf)().VERSION),
1188
+ someReceipt,
1189
+ txb.object(poolinfo.poolId),
1190
+ depositCoinA,
1191
+ depositCoinB,
1192
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1193
+ txb.object(poolinfo.investorId),
1194
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1195
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1196
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_USDC_POOL),
1197
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1198
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
1199
+ txb.object(maps_js_1.bluefinPoolMap["SUI-USDC"]),
1200
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
1201
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1202
+ txb.pure.bool(true),
1203
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1204
+ ],
1205
+ });
1206
+ }
1207
+ else if (poolName === "BLUEFIN-ALPHA-STSUI") {
1208
+ txb.moveCall({
1209
+ target: `${poolinfo.packageId}::alphafi_bluefin_stsui_second_pool::user_deposit`,
1210
+ typeArguments: [
1211
+ coins_js_1.coinsList[pool1].type,
1212
+ coins_js_1.coinsList[pool2].type,
1213
+ coins_js_1.coinsList["BLUE"].type,
1214
+ ],
1215
+ arguments: [
1216
+ txb.object((0, constants_js_1.getConf)().ALPHA_STSUI_VERSION),
1217
+ txb.object((0, constants_js_1.getConf)().VERSION),
1218
+ someReceipt,
1219
+ txb.object(poolinfo.poolId),
1220
+ depositCoinA,
1221
+ depositCoinB,
1222
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1223
+ txb.object(poolinfo.investorId),
1224
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1225
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1226
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_ALPHA_STSUI_POOL),
1227
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1228
+ txb.object(maps_js_1.cetusPoolMap["ALPHA-SUI"]),
1229
+ txb.object(maps_js_1.bluefinPoolMap["SUI-ALPHA"]),
1230
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
1231
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1232
+ txb.pure.bool(false),
1233
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1234
+ ],
1235
+ });
1236
+ }
1237
+ else if (poolName === "BLUEFIN-STSUI-WSOL") {
1238
+ txb.moveCall({
1239
+ target: `${poolinfo.packageId}::alphafi_bluefin_stsui_first_pool::user_deposit`,
1240
+ typeArguments: [
1241
+ coins_js_1.coinsList[pool1].type,
1242
+ coins_js_1.coinsList[pool2].type,
1243
+ coins_js_1.coinsList["BLUE"].type,
1244
+ ],
1245
+ arguments: [
1246
+ txb.object((0, constants_js_1.getConf)().ALPHA_STSUI_VERSION),
1247
+ txb.object((0, constants_js_1.getConf)().VERSION),
1248
+ someReceipt,
1249
+ txb.object(poolinfo.poolId),
1250
+ depositCoinA,
1251
+ depositCoinB,
1252
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1253
+ txb.object(poolinfo.investorId),
1254
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1255
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1256
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_WSOL_POOL),
1257
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1258
+ txb.object(maps_js_1.cetusPoolMap["WSOL-SUI"]),
1259
+ txb.object(maps_js_1.bluefinPoolMap["SUI-WSOL"]),
1260
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
1261
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1262
+ txb.pure.bool(false),
1263
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1264
+ ],
1265
+ });
1266
+ }
1267
+ else if (poolName === "BLUEFIN-STSUI-ETH") {
1268
+ txb.moveCall({
1269
+ target: `${poolinfo.packageId}::alphafi_bluefin_stsui_first_pool::user_deposit`,
1270
+ typeArguments: [
1271
+ coins_js_1.coinsList[pool1].type,
1272
+ coins_js_1.coinsList[pool2].type,
1273
+ coins_js_1.coinsList["BLUE"].type,
1274
+ ],
1275
+ arguments: [
1276
+ txb.object((0, constants_js_1.getConf)().ALPHA_STSUI_VERSION),
1277
+ txb.object((0, constants_js_1.getConf)().VERSION),
1278
+ someReceipt,
1279
+ txb.object(poolinfo.poolId),
1280
+ depositCoinA,
1281
+ depositCoinB,
1282
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1283
+ txb.object(poolinfo.investorId),
1284
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1285
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1286
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_ETH_POOL),
1287
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1288
+ txb.object(maps_js_1.cetusPoolMap["ETH-SUI"]),
1289
+ txb.object(maps_js_1.bluefinPoolMap["SUI-ETH"]),
1290
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
1291
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1292
+ txb.pure.bool(false),
1293
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1294
+ ],
1295
+ });
1296
+ }
1297
+ else if (poolName === "BLUEFIN-STSUI-BUCK") {
1298
+ txb.moveCall({
1299
+ target: `${poolinfo.packageId}::alphafi_bluefin_stsui_first_pool::user_deposit`,
1300
+ typeArguments: [
1301
+ coins_js_1.coinsList[pool1].type,
1302
+ coins_js_1.coinsList[pool2].type,
1303
+ coins_js_1.coinsList["BLUE"].type,
1304
+ ],
1305
+ arguments: [
1306
+ txb.object((0, constants_js_1.getConf)().ALPHA_STSUI_VERSION),
1307
+ txb.object((0, constants_js_1.getConf)().VERSION),
1308
+ someReceipt,
1309
+ txb.object(poolinfo.poolId),
1310
+ depositCoinA,
1311
+ depositCoinB,
1312
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1313
+ txb.object(poolinfo.investorId),
1314
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1315
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1316
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_BUCK_POOL),
1317
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1318
+ txb.object(maps_js_1.cetusPoolMap["BUCK-SUI"]),
1319
+ txb.object(maps_js_1.bluefinPoolMap["SUI-BUCK"]),
1320
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
1321
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1322
+ txb.pure.bool(false),
1323
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1324
+ ],
1325
+ });
1326
+ }
1327
+ else if (poolName === "BLUEFIN-STSUI-MUSD") {
1328
+ txb.moveCall({
1329
+ target: `${poolinfo.packageId}::alphafi_bluefin_stsui_first_pool::user_deposit`,
1330
+ typeArguments: [
1331
+ coins_js_1.coinsList[pool1].type,
1332
+ coins_js_1.coinsList[pool2].type,
1333
+ coins_js_1.coinsList["BLUE"].type,
1334
+ ],
1335
+ arguments: [
1336
+ txb.object((0, constants_js_1.getConf)().ALPHA_STSUI_VERSION),
1337
+ txb.object((0, constants_js_1.getConf)().VERSION),
1338
+ someReceipt,
1339
+ txb.object(poolinfo.poolId),
1340
+ depositCoinA,
1341
+ depositCoinB,
1342
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
1343
+ txb.object(poolinfo.investorId),
1344
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
1345
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
1346
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_MUSD_POOL),
1347
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
1348
+ txb.object(maps_js_1.cetusPoolMap["MUSD-SUI"]),
1349
+ txb.object(maps_js_1.bluefinPoolMap["SUI-MUSD"]),
1350
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
1351
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1352
+ txb.pure.bool(true),
1353
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1354
+ ],
1355
+ });
1627
1356
  }
1628
1357
  return txb;
1629
1358
  };
1630
- async function getZapAmounts(inputCoinAmount, inputCoinName, poolName, slippage, options, ignoreCache) {
1631
- const address = options.address;
1359
+ async function getZapAmounts(inputCoinAmount, inputCoinName, poolName, slippage, address, ignoreCache) {
1632
1360
  const coinTypeA = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
1633
1361
  const coinTypeB = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
1634
1362
  const swapObjectA = coins_js_1.coinsList[coinTypeA];
1635
1363
  const swapObjectB = coins_js_1.coinsList[coinTypeB];
1636
1364
  const inputObject = coins_js_1.coinsList[inputCoinName];
1637
1365
  const amounts = await (0, deposit_js_1.getAmounts)(poolName, true, "100000001");
1638
- if (amounts) {
1639
- const amount1 = Number(amounts[0]);
1640
- const amount2 = Number(amounts[1]);
1641
- const swapGateway = new _7k_js_1.SevenKGateway();
1642
- const swapOptions = {
1643
- pair: {
1644
- coinA: swapObjectA,
1645
- coinB: swapObjectB,
1646
- },
1647
- senderAddress: address,
1648
- inAmount: new bn_js_1.default(amount1),
1649
- slippage: slippage,
1650
- };
1651
- const ratioQuote = await zapGetQuote(swapGateway, swapOptions, poolName);
1652
- if (ratioQuote) {
1653
- const amount1InCoinType2 = Number(ratioQuote);
1654
- const totalAmount = amount2 + amount1InCoinType2;
1655
- const inputAmountToType1 = Math.floor((inputCoinAmount * amount1InCoinType2) / totalAmount);
1656
- const inputAmountToType2 = Math.floor((inputCoinAmount * amount2) / totalAmount);
1657
- let amountA, amountB;
1658
- const swapOptionsI2A = {
1659
- pair: {
1660
- coinA: inputObject,
1661
- coinB: swapObjectA,
1662
- },
1663
- senderAddress: address,
1664
- inAmount: new bn_js_1.default(inputAmountToType1),
1665
- slippage: slippage,
1666
- };
1667
- const swapOptionsI2B = {
1668
- pair: {
1669
- coinA: inputObject,
1670
- coinB: swapObjectB,
1671
- },
1672
- senderAddress: address,
1673
- inAmount: new bn_js_1.default(inputAmountToType2),
1674
- slippage: slippage,
1675
- };
1676
- if (inputCoinName === coinTypeA) {
1677
- amountB = await zapGetQuote(swapGateway, swapOptionsI2B, poolName);
1678
- amountA = inputAmountToType1.toString();
1679
- }
1680
- else if (inputCoinName === coinTypeB) {
1681
- amountA = await zapGetQuote(swapGateway, swapOptionsI2A, poolName);
1682
- amountB = inputAmountToType2.toString();
1683
- }
1684
- else {
1685
- amountA = await zapGetQuote(swapGateway, swapOptionsI2A, poolName);
1686
- amountB = await zapGetQuote(swapGateway, swapOptionsI2B, poolName);
1687
- }
1688
- if (amountA && amountB) {
1689
- const [coin1Price, coin2Price] = await (0, prices_js_1.getLatestPrices)([
1690
- `${swapObjectA.name}/USD`,
1691
- `${swapObjectB.name}/USD`,
1692
- ], ignoreCache);
1693
- const coin1InUSD = Number(amountA) * Number(coin1Price);
1694
- const coin2InUSD = Number(amountB) * Number(coin2Price);
1695
- return [
1696
- amountA.toString(),
1697
- coin1InUSD.toString(),
1698
- amountB.toString(),
1699
- coin2InUSD.toString(),
1700
- ];
1701
- }
1702
- }
1366
+ const amount1 = Number(amounts[0]);
1367
+ const amount2 = Number(amounts[1]);
1368
+ const swapGateway = new _7k_js_1.SevenKGateway();
1369
+ const swapOptions = {
1370
+ pair: {
1371
+ coinA: swapObjectA,
1372
+ coinB: swapObjectB,
1373
+ },
1374
+ senderAddress: address,
1375
+ inAmount: new bn_js_1.default(amount1),
1376
+ slippage: slippage,
1377
+ };
1378
+ const ratioQuote = await zapGetQuote(swapGateway, swapOptions, poolName);
1379
+ if (!ratioQuote) {
1380
+ console.error(`Error geting quote for zap`);
1381
+ return undefined;
1382
+ }
1383
+ const amount1InCoinType2 = Number(ratioQuote);
1384
+ const totalAmount = amount2 + amount1InCoinType2;
1385
+ const inputAmountToType1 = Math.floor((inputCoinAmount * amount1InCoinType2) / totalAmount);
1386
+ const inputAmountToType2 = Math.floor((inputCoinAmount * amount2) / totalAmount);
1387
+ let amountA, amountB;
1388
+ const swapOptionsI2A = {
1389
+ pair: {
1390
+ coinA: inputObject,
1391
+ coinB: swapObjectA,
1392
+ },
1393
+ senderAddress: address,
1394
+ inAmount: new bn_js_1.default(inputAmountToType1),
1395
+ slippage: slippage,
1396
+ };
1397
+ const swapOptionsI2B = {
1398
+ pair: {
1399
+ coinA: inputObject,
1400
+ coinB: swapObjectB,
1401
+ },
1402
+ senderAddress: address,
1403
+ inAmount: new bn_js_1.default(inputAmountToType2),
1404
+ slippage: slippage,
1405
+ };
1406
+ if (inputCoinName === coinTypeA) {
1407
+ amountA = inputAmountToType1.toString();
1408
+ amountB = await zapGetQuote(swapGateway, swapOptionsI2B, poolName);
1409
+ }
1410
+ else if (inputCoinName === coinTypeB) {
1411
+ amountA = await zapGetQuote(swapGateway, swapOptionsI2A, poolName);
1412
+ amountB = inputAmountToType2.toString();
1413
+ }
1414
+ else {
1415
+ amountA = await zapGetQuote(swapGateway, swapOptionsI2A, poolName);
1416
+ amountB = await zapGetQuote(swapGateway, swapOptionsI2B, poolName);
1417
+ }
1418
+ if (amountA && amountB) {
1419
+ const [coin1Price, coin2Price] = await (0, prices_js_1.getLatestPrices)([
1420
+ `${swapObjectA.name}/USD`,
1421
+ `${swapObjectB.name}/USD`,
1422
+ ], ignoreCache);
1423
+ const coin1InUSD = Number(amountA) * Number(coin1Price);
1424
+ const coin2InUSD = Number(amountB) * Number(coin2Price);
1425
+ return [
1426
+ amountA.toString(),
1427
+ coin1InUSD.toString(),
1428
+ amountB.toString(),
1429
+ coin2InUSD.toString(),
1430
+ ];
1703
1431
  }
1704
1432
  }
1705
- // export async function zapWithdraw(
1706
- // amount: string,
1707
- // poolName: PoolName,
1708
- // outputCoinName: string,
1709
- // options: { suiClient: SuiClient; address: string },
1710
- // ) {
1711
- // const suiClient = options.suiClient;
1712
- // const address = options.address;
1713
- // const txb = new Transaction();
1714
- // const pool1 = doubleAssetPoolCoinMap[poolName].pool1;
1715
- // const pool2 = doubleAssetPoolCoinMap[poolName].pool2;
1716
- // }
1717
- //calculate ratio of both coins in terms of coin-type 2
1718
- //convert outputAmount in coinType2
1719
- //then calculate coinType1 and coinType2 based on previous ratio
1720
- //convert those amounts to liquidity
1721
- //pass that liquidity into cetusWithdrawTxb
1722
- //swap the amount withdrawn to outputAmountType.
1723
1433
  //# sourceMappingURL=zapDeposit.js.map