@alphafi/alphafi-sdk 0.0.39 → 0.0.41

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 (322) hide show
  1. package/dist/cjs/adminFunctions.d.ts.map +1 -1
  2. package/dist/cjs/adminFunctions.js +9 -1
  3. package/dist/cjs/adminFunctions.js.map +1 -1
  4. package/dist/cjs/common/coins.d.ts.map +1 -1
  5. package/dist/cjs/common/coins.js +18 -0
  6. package/dist/cjs/common/coins.js.map +1 -1
  7. package/dist/cjs/common/constants.d.ts +288 -0
  8. package/dist/cjs/common/constants.d.ts.map +1 -1
  9. package/dist/cjs/common/constants.js +214 -8
  10. package/dist/cjs/common/constants.js.map +1 -1
  11. package/dist/cjs/common/maps.d.ts +1 -0
  12. package/dist/cjs/common/maps.d.ts.map +1 -1
  13. package/dist/cjs/common/maps.js +207 -14
  14. package/dist/cjs/common/maps.js.map +1 -1
  15. package/dist/cjs/common/types.d.ts +58 -5
  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/graphql/getMultiReceipts.d.ts.map +1 -1
  19. package/dist/cjs/graphql/getMultiReceipts.js +49 -36
  20. package/dist/cjs/graphql/getMultiReceipts.js.map +1 -1
  21. package/dist/cjs/index.d.ts +5 -9
  22. package/dist/cjs/index.d.ts.map +1 -1
  23. package/dist/cjs/index.js +17 -8
  24. package/dist/cjs/index.js.map +1 -1
  25. package/dist/cjs/sui-sdk/functions/fetchUserVaultBalances.d.ts.map +1 -1
  26. package/dist/cjs/sui-sdk/functions/fetchUserVaultBalances.js +2 -3
  27. package/dist/cjs/sui-sdk/functions/fetchUserVaultBalances.js.map +1 -1
  28. package/dist/cjs/sui-sdk/functions/getPortfolioAmounts.d.ts.map +1 -1
  29. package/dist/cjs/sui-sdk/functions/getPortfolioAmounts.js +6 -12
  30. package/dist/cjs/sui-sdk/functions/getPortfolioAmounts.js.map +1 -1
  31. package/dist/cjs/sui-sdk/functions/getReceipts.d.ts +6 -3
  32. package/dist/cjs/sui-sdk/functions/getReceipts.d.ts.map +1 -1
  33. package/dist/cjs/sui-sdk/functions/getReceipts.js +42 -26
  34. package/dist/cjs/sui-sdk/functions/getReceipts.js.map +1 -1
  35. package/dist/cjs/transactions/7k.d.ts +13 -0
  36. package/dist/cjs/transactions/7k.d.ts.map +1 -0
  37. package/dist/cjs/transactions/7k.js +46 -0
  38. package/dist/cjs/transactions/7k.js.map +1 -0
  39. package/dist/cjs/transactions/alpha.d.ts.map +1 -1
  40. package/dist/cjs/transactions/alpha.js +1 -0
  41. package/dist/cjs/transactions/alpha.js.map +1 -1
  42. package/dist/cjs/transactions/bluefin.d.ts +12 -0
  43. package/dist/cjs/transactions/bluefin.d.ts.map +1 -1
  44. package/dist/cjs/transactions/bluefin.js +937 -91
  45. package/dist/cjs/transactions/bluefin.js.map +1 -1
  46. package/dist/cjs/transactions/cetus.d.ts +0 -3
  47. package/dist/cjs/transactions/cetus.d.ts.map +1 -1
  48. package/dist/cjs/transactions/cetus.js +4 -63
  49. package/dist/cjs/transactions/cetus.js.map +1 -1
  50. package/dist/cjs/transactions/deposit.d.ts +3 -0
  51. package/dist/cjs/transactions/deposit.d.ts.map +1 -1
  52. package/dist/cjs/transactions/deposit.js +77 -1
  53. package/dist/cjs/transactions/deposit.js.map +1 -1
  54. package/dist/cjs/transactions/deposit1.d.ts +1 -0
  55. package/dist/cjs/transactions/deposit1.d.ts.map +1 -0
  56. package/dist/cjs/transactions/deposit1.js +86 -0
  57. package/dist/cjs/transactions/deposit1.js.map +1 -0
  58. package/dist/cjs/transactions/types.d.ts +14 -0
  59. package/dist/cjs/transactions/types.d.ts.map +1 -0
  60. package/dist/cjs/transactions/types.js +3 -0
  61. package/dist/cjs/transactions/types.js.map +1 -0
  62. package/dist/cjs/transactions/withdraw.d.ts.map +1 -1
  63. package/dist/cjs/transactions/withdraw.js +17 -2
  64. package/dist/cjs/transactions/withdraw.js.map +1 -1
  65. package/dist/cjs/transactions/zapDeposit.d.ts +9 -0
  66. package/dist/cjs/transactions/zapDeposit.d.ts.map +1 -1
  67. package/dist/cjs/transactions/zapDeposit.js +1117 -725
  68. package/dist/cjs/transactions/zapDeposit.js.map +1 -1
  69. package/dist/esm/adminFunctions.d.ts.map +1 -1
  70. package/dist/esm/adminFunctions.js +10 -2
  71. package/dist/esm/adminFunctions.js.map +1 -1
  72. package/dist/esm/common/coins.d.ts.map +1 -1
  73. package/dist/esm/common/coins.js +18 -0
  74. package/dist/esm/common/coins.js.map +1 -1
  75. package/dist/esm/common/constants.d.ts +288 -0
  76. package/dist/esm/common/constants.d.ts.map +1 -1
  77. package/dist/esm/common/constants.js +214 -8
  78. package/dist/esm/common/constants.js.map +1 -1
  79. package/dist/esm/common/maps.d.ts +1 -0
  80. package/dist/esm/common/maps.d.ts.map +1 -1
  81. package/dist/esm/common/maps.js +206 -13
  82. package/dist/esm/common/maps.js.map +1 -1
  83. package/dist/esm/common/types.d.ts +58 -5
  84. package/dist/esm/common/types.d.ts.map +1 -1
  85. package/dist/esm/common/types.js.map +1 -1
  86. package/dist/esm/graphql/getMultiReceipts.d.ts.map +1 -1
  87. package/dist/esm/graphql/getMultiReceipts.js +49 -36
  88. package/dist/esm/graphql/getMultiReceipts.js.map +1 -1
  89. package/dist/esm/index.d.ts +5 -9
  90. package/dist/esm/index.d.ts.map +1 -1
  91. package/dist/esm/index.js +5 -9
  92. package/dist/esm/index.js.map +1 -1
  93. package/dist/esm/sui-sdk/functions/fetchUserVaultBalances.d.ts.map +1 -1
  94. package/dist/esm/sui-sdk/functions/fetchUserVaultBalances.js +2 -3
  95. package/dist/esm/sui-sdk/functions/fetchUserVaultBalances.js.map +1 -1
  96. package/dist/esm/sui-sdk/functions/getPortfolioAmounts.d.ts.map +1 -1
  97. package/dist/esm/sui-sdk/functions/getPortfolioAmounts.js +7 -13
  98. package/dist/esm/sui-sdk/functions/getPortfolioAmounts.js.map +1 -1
  99. package/dist/esm/sui-sdk/functions/getReceipts.d.ts +6 -3
  100. package/dist/esm/sui-sdk/functions/getReceipts.d.ts.map +1 -1
  101. package/dist/esm/sui-sdk/functions/getReceipts.js +43 -26
  102. package/dist/esm/sui-sdk/functions/getReceipts.js.map +1 -1
  103. package/dist/esm/transactions/7k.d.ts +13 -0
  104. package/dist/esm/transactions/7k.d.ts.map +1 -0
  105. package/dist/esm/transactions/7k.js +42 -0
  106. package/dist/esm/transactions/7k.js.map +1 -0
  107. package/dist/esm/transactions/alpha.d.ts.map +1 -1
  108. package/dist/esm/transactions/alpha.js +1 -0
  109. package/dist/esm/transactions/alpha.js.map +1 -1
  110. package/dist/esm/transactions/bluefin.d.ts +12 -0
  111. package/dist/esm/transactions/bluefin.d.ts.map +1 -1
  112. package/dist/esm/transactions/bluefin.js +928 -86
  113. package/dist/esm/transactions/bluefin.js.map +1 -1
  114. package/dist/esm/transactions/cetus.d.ts +0 -3
  115. package/dist/esm/transactions/cetus.d.ts.map +1 -1
  116. package/dist/esm/transactions/cetus.js +2 -57
  117. package/dist/esm/transactions/cetus.js.map +1 -1
  118. package/dist/esm/transactions/deposit.d.ts +3 -0
  119. package/dist/esm/transactions/deposit.d.ts.map +1 -1
  120. package/dist/esm/transactions/deposit.js +74 -2
  121. package/dist/esm/transactions/deposit.js.map +1 -1
  122. package/dist/esm/transactions/deposit1.d.ts +2 -0
  123. package/dist/esm/transactions/deposit1.d.ts.map +1 -0
  124. package/dist/esm/transactions/deposit1.js +86 -0
  125. package/dist/esm/transactions/deposit1.js.map +1 -0
  126. package/dist/esm/transactions/types.d.ts +14 -0
  127. package/dist/esm/transactions/types.d.ts.map +1 -0
  128. package/dist/esm/transactions/types.js +2 -0
  129. package/dist/esm/transactions/types.js.map +1 -0
  130. package/dist/esm/transactions/withdraw.d.ts.map +1 -1
  131. package/dist/esm/transactions/withdraw.js +18 -3
  132. package/dist/esm/transactions/withdraw.js.map +1 -1
  133. package/dist/esm/transactions/zapDeposit.d.ts +9 -1
  134. package/dist/esm/transactions/zapDeposit.d.ts.map +1 -1
  135. package/dist/esm/transactions/zapDeposit.js +1113 -726
  136. package/dist/esm/transactions/zapDeposit.js.map +1 -1
  137. package/docs/assets/highlight.css +78 -0
  138. package/docs/assets/icons.js +18 -0
  139. package/docs/assets/icons.svg +1 -0
  140. package/docs/assets/main.js +60 -0
  141. package/docs/assets/navigation.js +1 -0
  142. package/docs/assets/search.js +1 -0
  143. package/docs/assets/style.css +1493 -0
  144. package/docs/functions/alphaLpBreakdown.html +1 -0
  145. package/docs/functions/cetusLpBreakdown.html +1 -0
  146. package/docs/functions/claimRewardTxb.html +1 -0
  147. package/docs/functions/coinAmountToXTokensDoubleAsset.html +1 -0
  148. package/docs/functions/coinAmountToXTokensSingleAsset.html +1 -0
  149. package/docs/functions/coinsInPool.html +1 -0
  150. package/docs/functions/collectRewards.html +1 -0
  151. package/docs/functions/deposit.html +1 -0
  152. package/docs/functions/depositDoubleAssetTxb.html +1 -0
  153. package/docs/functions/depositSingleAssetTxb.html +1 -0
  154. package/docs/functions/fetchAfterTransactionEvents.html +1 -0
  155. package/docs/functions/fetchAutoCompoundingEvents.html +1 -0
  156. package/docs/functions/fetchAutoCompoundingEventsGql.html +1 -0
  157. package/docs/functions/fetchCetusPools.html +1 -0
  158. package/docs/functions/fetchChainIdentifier.html +1 -0
  159. package/docs/functions/fetchCheckRatioEvents.html +1 -0
  160. package/docs/functions/fetchLiquidityChangeEvents.html +1 -0
  161. package/docs/functions/fetchMultiReceipts.html +1 -0
  162. package/docs/functions/fetchNftHolders.html +1 -0
  163. package/docs/functions/fetchPools.html +1 -0
  164. package/docs/functions/fetchPortfolioData.html +1 -0
  165. package/docs/functions/fetchProtocolData.html +1 -0
  166. package/docs/functions/fetchTVL.html +1 -0
  167. package/docs/functions/fetchUserVaultBalances.html +1 -0
  168. package/docs/functions/fetchUserVaults.html +1 -0
  169. package/docs/functions/fetchUserWalletData.html +1 -0
  170. package/docs/functions/fetchWithdrawV2Events.html +1 -0
  171. package/docs/functions/getAirdropShare.html +1 -0
  172. package/docs/functions/getAllDoubleAssetVaults.html +1 -0
  173. package/docs/functions/getAllSingleAssetVaults.html +1 -0
  174. package/docs/functions/getAllVaultBalances.html +1 -0
  175. package/docs/functions/getAllVaults.html +1 -0
  176. package/docs/functions/getAlphaUnlocks.html +1 -0
  177. package/docs/functions/getAlphaVaultBalance.html +1 -0
  178. package/docs/functions/getAmounts.html +1 -0
  179. package/docs/functions/getApr.html +1 -0
  180. package/docs/functions/getAprs.html +1 -0
  181. package/docs/functions/getApy.html +1 -0
  182. package/docs/functions/getApys.html +1 -0
  183. package/docs/functions/getCetusInvestorTicksMap.html +1 -0
  184. package/docs/functions/getCetusSqrtPriceMap.html +1 -0
  185. package/docs/functions/getCoinAmountsFromLiquidity.html +1 -0
  186. package/docs/functions/getConf.html +1 -0
  187. package/docs/functions/getCurrentTick.html +1 -0
  188. package/docs/functions/getDoubleAssetVaultBalance.html +1 -0
  189. package/docs/functions/getDoubleAssetVaults.html +1 -0
  190. package/docs/functions/getHoldersFromTransactions.html +1 -0
  191. package/docs/functions/getInvestor.html +1 -0
  192. package/docs/functions/getInvestorPoolMap.html +1 -0
  193. package/docs/functions/getLastAutoCompoundTime.html +1 -0
  194. package/docs/functions/getLatestPrices.html +1 -0
  195. package/docs/functions/getLiquidity.html +1 -0
  196. package/docs/functions/getMultiInvestor.html +1 -0
  197. package/docs/functions/getMultiLatestPrices.html +1 -0
  198. package/docs/functions/getMultiParentPool.html +1 -0
  199. package/docs/functions/getMultiPool.html +1 -0
  200. package/docs/functions/getMultiReceipts.html +1 -0
  201. package/docs/functions/getParentPool.html +1 -0
  202. package/docs/functions/getPool.html +1 -0
  203. package/docs/functions/getPoolExchangeRateMap.html +1 -0
  204. package/docs/functions/getPositionRange.html +1 -0
  205. package/docs/functions/getPositionTicks.html +1 -0
  206. package/docs/functions/getPriceToTick.html +1 -0
  207. package/docs/functions/getRebalanceHistories.html +1 -0
  208. package/docs/functions/getRebalanceHistory.html +1 -0
  209. package/docs/functions/getReceipts.html +1 -0
  210. package/docs/functions/getSingleAssetVaultBalance.html +1 -0
  211. package/docs/functions/getSingleAssetVaults.html +1 -0
  212. package/docs/functions/getSuiClient.html +3 -0
  213. package/docs/functions/getSuiNodeUrl.html +3 -0
  214. package/docs/functions/getTVLs.html +1 -0
  215. package/docs/functions/getTickToPrice.html +1 -0
  216. package/docs/functions/getUserTokensFromTransactions.html +1 -0
  217. package/docs/functions/getUserTokensInUsdFromTransactions.html +1 -0
  218. package/docs/functions/getVaultBalance.html +1 -0
  219. package/docs/functions/getVaultBalanceForActiveUsers.html +1 -0
  220. package/docs/functions/getVaults.html +1 -0
  221. package/docs/functions/getXTokenVaultBalanceForActiveUsers.html +1 -0
  222. package/docs/functions/getZapAmounts.html +1 -0
  223. package/docs/functions/lastAutocompoundTime.html +1 -0
  224. package/docs/functions/liquidityToTokens.html +1 -0
  225. package/docs/functions/multiLiquidityToTokens.html +1 -0
  226. package/docs/functions/multiTokensToUsd.html +1 -0
  227. package/docs/functions/multiXTokensToLiquidity.html +1 -0
  228. package/docs/functions/parseUserWalletData.html +1 -0
  229. package/docs/functions/setSuiClient.html +7 -0
  230. package/docs/functions/setSuiNodeUrl.html +5 -0
  231. package/docs/functions/withdraw.html +1 -0
  232. package/docs/functions/withdrawAlphaTxb.html +1 -0
  233. package/docs/functions/withdrawTxb.html +1 -0
  234. package/docs/functions/zapDepositTxb.html +1 -0
  235. package/docs/index.html +76 -0
  236. package/docs/interfaces/Coin.html +12 -0
  237. package/docs/interfaces/CoinPair.html +3 -0
  238. package/docs/interfaces/NaviVoloData.html +3 -0
  239. package/docs/interfaces/RebalanceHistoryType.html +9 -0
  240. package/docs/modules.html +177 -0
  241. package/docs/types/AfterTransactionEventNode.html +1 -0
  242. package/docs/types/Allocator.html +1 -0
  243. package/docs/types/AlphaFiDoubleAssetVault.html +1 -0
  244. package/docs/types/AlphaFiMultiVaultBalance.html +1 -0
  245. package/docs/types/AlphaFiSingleAssetVault.html +1 -0
  246. package/docs/types/AlphaFiVault.html +1 -0
  247. package/docs/types/AlphaFiVaultBalance.html +1 -0
  248. package/docs/types/AlphaPoolType.html +1 -0
  249. package/docs/types/AlphaReceipt.html +1 -0
  250. package/docs/types/AlphaReceiptFields.html +1 -0
  251. package/docs/types/AlphaVaultBalance.html +1 -0
  252. package/docs/types/AutoCompoundingEventNode.html +1 -0
  253. package/docs/types/BluefinInvestor.html +1 -0
  254. package/docs/types/BluefinPoolType.html +1 -0
  255. package/docs/types/BucketInvestor.html +1 -0
  256. package/docs/types/CetusInvestor.html +1 -0
  257. package/docs/types/CetusPoolType.html +1 -0
  258. package/docs/types/CetusSwapOptions.html +1 -0
  259. package/docs/types/CoinAmounts.html +1 -0
  260. package/docs/types/CoinName.html +1 -0
  261. package/docs/types/CoinType.html +1 -0
  262. package/docs/types/CommonInvestorFields.html +1 -0
  263. package/docs/types/CreatePoolOptions.html +1 -0
  264. package/docs/types/Distributor.html +1 -0
  265. package/docs/types/DoubleAssetMultiVaultBalance.html +1 -0
  266. package/docs/types/DoubleAssetPoolNames.html +1 -0
  267. package/docs/types/DoubleAssetTokenHoldings.html +1 -0
  268. package/docs/types/DoubleAssetVaultBalance.html +1 -0
  269. package/docs/types/GetHoldersParams.html +1 -0
  270. package/docs/types/GetTokenHoldingsParams.html +1 -0
  271. package/docs/types/GetUserTokensFromTransactionsParams.html +1 -0
  272. package/docs/types/GetUserTokensInUsdFromTransactionsParams.html +1 -0
  273. package/docs/types/GetVaultBalanceForActiveUsersParams.html +1 -0
  274. package/docs/types/GetVaultBalanceParams.html +1 -0
  275. package/docs/types/HoldingsObj.html +1 -0
  276. package/docs/types/Icon.html +1 -0
  277. package/docs/types/Investor.html +1 -0
  278. package/docs/types/LiquidityChangeEventNode.html +1 -0
  279. package/docs/types/LiquidityToTokensParams.html +1 -0
  280. package/docs/types/LiquidityToUsdParams.html +1 -0
  281. package/docs/types/LoopingDebt.html +1 -0
  282. package/docs/types/LpBreakdownType.html +1 -0
  283. package/docs/types/MemberPoolDataType.html +1 -0
  284. package/docs/types/MemberType.html +1 -0
  285. package/docs/types/MultiGetVaultBalancesParams.html +1 -0
  286. package/docs/types/NaviInvestor.html +1 -0
  287. package/docs/types/OtherReceiptFields.html +1 -0
  288. package/docs/types/PoolName.html +1 -0
  289. package/docs/types/PoolReceipt.html +1 -0
  290. package/docs/types/PoolType.html +1 -0
  291. package/docs/types/Receipt.html +1 -0
  292. package/docs/types/ReceiptGQL.html +1 -0
  293. package/docs/types/SingleAssetMultiVaultBalance.html +1 -0
  294. package/docs/types/SingleAssetPoolNames.html +1 -0
  295. package/docs/types/SingleAssetTokenHoldings.html +1 -0
  296. package/docs/types/SingleAssetVaultBalance.html +1 -0
  297. package/docs/types/SingleGetVaultBalancesParams.html +1 -0
  298. package/docs/types/StrategyType.html +1 -0
  299. package/docs/types/SuiNetwork.html +1 -0
  300. package/docs/types/SwapOptions.html +1 -0
  301. package/docs/types/TickSpacing.html +1 -0
  302. package/docs/types/TotalWeightType.html +1 -0
  303. package/docs/types/TransactionBlockType.html +1 -0
  304. package/docs/types/UserPoolLiquidity.html +1 -0
  305. package/docs/types/UserPoolTokenHoldings.html +1 -0
  306. package/docs/types/UserUsdHoldings.html +1 -0
  307. package/docs/types/VaultBalance.html +1 -0
  308. package/docs/types/WithdrawV2EventNode.html +1 -0
  309. package/docs/variables/bluefinPoolMap.html +1 -0
  310. package/docs/variables/cetusPoolMap.html +1 -0
  311. package/docs/variables/coinsList.html +1 -0
  312. package/docs/variables/defunctPoolsSet.html +1 -0
  313. package/docs/variables/doubleAssetPoolCoinMap.html +1 -0
  314. package/docs/variables/ignoredWalletsForDailyRevenue.html +1 -0
  315. package/docs/variables/loopingAccountAddresses.html +1 -0
  316. package/docs/variables/loopingPoolCoinMap.html +1 -0
  317. package/docs/variables/naviAssetMap.html +1 -0
  318. package/docs/variables/poolIdPoolNameMap.html +1 -0
  319. package/docs/variables/poolInfo.html +1 -0
  320. package/docs/variables/singleAssetPoolCoinMap.html +1 -0
  321. package/docs/variables/stableCoins.html +1 -0
  322. package/package.json +2 -1
@@ -1,730 +1,1122 @@
1
1
  "use strict";
2
- // import {
3
- // Transaction,
4
- // TransactionObjectArgument,
5
- // } from "@mysten/sui/transactions";
6
- // import { CoinStruct } from "@mysten/sui/client";
7
- // import { coinsList } from "../common/coins.js";
8
- // import {
9
- // cetusPoolMap,
10
- // doubleAssetPoolCoinMap,
11
- // poolInfo,
12
- // } from "../common/maps.js";
13
- // import { CoinName, PoolName, Receipt, SwapOptions } from "../common/types.js";
14
- // import { getReceipts } from "../sui-sdk/functions/getReceipts.js";
15
- // import { getConf } from "../common/constants.js";
16
- // import { getSuiClient } from "../sui-sdk/client.js";
17
- // import BN from "bn.js";
18
- // import { PythPriceIdPair } from "../common/pyth.js";
19
- // import { getLatestPrices } from "../utils/prices.js";
20
- // import { getAmounts } from "./cetus.js";
21
- // export async function zapDepositTxb(
22
- // inputCoinName: CoinName,
23
- // inputCoinAmount: number,
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.zapDepositTxb = zapDepositTxb;
4
+ exports.getZapAmounts = getZapAmounts;
5
+ const tslib_1 = require("tslib");
6
+ const transactions_1 = require("@mysten/sui/transactions");
7
+ const bn_js_1 = tslib_1.__importDefault(require("bn.js"));
8
+ const client_js_1 = require("../sui-sdk/client.js");
9
+ const maps_js_1 = require("../common/maps.js");
10
+ const coins_js_1 = require("../common/coins.js");
11
+ const deposit_js_1 = require("./deposit.js");
12
+ const _7k_js_1 = require("./7k.js");
13
+ const constants_js_1 = require("../common/constants.js");
14
+ const getReceipts_js_1 = require("../sui-sdk/functions/getReceipts.js");
15
+ const prices_js_1 = require("../utils/prices.js");
16
+ async function zapDepositTxb(inputCoinName, inputCoinAmount, poolName, slippage, // 0.01 --> 1%, 0.001 --> 0.1%
17
+ options) {
18
+ let txb = new transactions_1.Transaction();
19
+ const suiClient = (0, client_js_1.getSuiClient)();
20
+ const address = options.address;
21
+ const coinTypeA = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
22
+ const coinTypeB = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
23
+ const swapObjectA = coins_js_1.coinsList[coinTypeA];
24
+ const swapObjectB = coins_js_1.coinsList[coinTypeB];
25
+ const inputObject = coins_js_1.coinsList[inputCoinName];
26
+ let coin1, coin2;
27
+ const amounts = await (0, deposit_js_1.getAmounts)(poolName, true, "100000001");
28
+ if (amounts) {
29
+ const amount1 = Number(amounts[0]);
30
+ const amount2 = Number(amounts[1]);
31
+ const swapGateway = new _7k_js_1.SevenKGateway();
32
+ const swapOptions = {
33
+ pair: {
34
+ coinA: swapObjectA,
35
+ coinB: swapObjectB,
36
+ },
37
+ senderAddress: address,
38
+ inAmount: new bn_js_1.default(amount1),
39
+ slippage: slippage,
40
+ };
41
+ const ratioQuote = await swapGateway.getQuote(swapOptions);
42
+ if (ratioQuote) {
43
+ const amount1InCoinType2 = Number(ratioQuote.returnAmountWithDecimal);
44
+ const totalAmount = amount2 + amount1InCoinType2;
45
+ const inputAmountToType1 = Math.floor((inputCoinAmount * amount1InCoinType2) / totalAmount);
46
+ const inputAmountToType2 = Math.floor((inputCoinAmount * amount2) / totalAmount);
47
+ let amountA, amountB;
48
+ const swapOptionsI2A = {
49
+ pair: {
50
+ coinA: inputObject,
51
+ coinB: swapObjectA,
52
+ },
53
+ senderAddress: address,
54
+ inAmount: new bn_js_1.default(inputAmountToType1),
55
+ slippage: slippage,
56
+ };
57
+ const swapOptionsI2B = {
58
+ pair: {
59
+ coinA: inputObject,
60
+ coinB: swapObjectB,
61
+ },
62
+ senderAddress: address,
63
+ inAmount: new bn_js_1.default(inputAmountToType2),
64
+ slippage: slippage,
65
+ };
66
+ if (inputCoinName === coinTypeA) {
67
+ const quoteResponse = await swapGateway.getQuote(swapOptionsI2B);
68
+ if (quoteResponse) {
69
+ amountB = quoteResponse.returnAmountWithDecimal;
70
+ const result = await swapGateway.getTransactionBlock(swapOptionsI2B, quoteResponse, txb);
71
+ txb = result.tx;
72
+ if (result.coinOut) {
73
+ coin2 = result.coinOut;
74
+ }
75
+ }
76
+ amountA = inputAmountToType1.toString();
77
+ if (coinTypeA === "SUI") {
78
+ [coin1] = txb.splitCoins(txb.gas, [amountA]);
79
+ }
80
+ else {
81
+ let currentCursor = null;
82
+ let coins1 = [];
83
+ do {
84
+ const response = await suiClient.getCoins({
85
+ owner: address,
86
+ coinType: coins_js_1.coinsList[coinTypeA].type,
87
+ cursor: currentCursor,
88
+ });
89
+ coins1 = coins1.concat(response.data);
90
+ if (response.hasNextPage && response.nextCursor) {
91
+ currentCursor = response.nextCursor;
92
+ }
93
+ else
94
+ break;
95
+ } while (true);
96
+ [coin1] = txb.splitCoins(txb.object(coins1[0].coinObjectId), [0]);
97
+ txb.mergeCoins(coin1, coins1.map((c) => c.coinObjectId));
98
+ }
99
+ }
100
+ else if (inputCoinName === coinTypeB) {
101
+ const quoteResponse = await swapGateway.getQuote(swapOptionsI2A);
102
+ if (quoteResponse) {
103
+ amountA = quoteResponse.returnAmountWithDecimal;
104
+ const result = await swapGateway.getTransactionBlock(swapOptionsI2A, quoteResponse, txb);
105
+ txb = result.tx;
106
+ if (result.coinOut) {
107
+ coin1 = result.coinOut;
108
+ }
109
+ }
110
+ amountB = inputAmountToType2.toString();
111
+ if (coinTypeB === "SUI") {
112
+ [coin2] = txb.splitCoins(txb.gas, [amountB]);
113
+ }
114
+ else {
115
+ let currentCursor = null;
116
+ let coins2 = [];
117
+ do {
118
+ const response = await suiClient.getCoins({
119
+ owner: address,
120
+ coinType: coins_js_1.coinsList[coinTypeB].type,
121
+ cursor: currentCursor,
122
+ });
123
+ coins2 = coins2.concat(response.data);
124
+ if (response.hasNextPage && response.nextCursor) {
125
+ currentCursor = response.nextCursor;
126
+ }
127
+ else
128
+ break;
129
+ } while (true);
130
+ [coin2] = txb.splitCoins(txb.object(coins2[0].coinObjectId), [0]);
131
+ txb.mergeCoins(coin2, coins2.map((c) => c.coinObjectId));
132
+ }
133
+ }
134
+ else {
135
+ let quoteResponse = await swapGateway.getQuote(swapOptionsI2A);
136
+ if (quoteResponse) {
137
+ amountA = quoteResponse.returnAmountWithDecimal;
138
+ const result = await swapGateway.getTransactionBlock(swapOptionsI2A, quoteResponse, txb);
139
+ txb = result.tx;
140
+ if (result.coinOut) {
141
+ coin1 = result.coinOut;
142
+ }
143
+ }
144
+ quoteResponse = await swapGateway.getQuote(swapOptionsI2B);
145
+ if (quoteResponse) {
146
+ amountB = quoteResponse.returnAmountWithDecimal;
147
+ const result = await swapGateway.getTransactionBlock(swapOptionsI2B, quoteResponse, txb);
148
+ txb = result.tx;
149
+ if (result.coinOut) {
150
+ coin2 = result.coinOut;
151
+ }
152
+ }
153
+ }
154
+ if (amountA && amountB) {
155
+ if (coin1 && coin2) {
156
+ // fee charge
157
+ const fee_address = (0, constants_js_1.getConf)().FEE_ADDRESS;
158
+ const feePercentage = 0.05;
159
+ const amountAFee = ((Number(amountA) * feePercentage) / 100).toFixed(0);
160
+ const amountBFee = ((Number(amountB) * feePercentage) / 100).toFixed(0);
161
+ const [feeCoinA] = txb.splitCoins(coin1, [amountAFee]);
162
+ const [feeCoinB] = txb.splitCoins(coin2, [amountBFee]);
163
+ txb.transferObjects([feeCoinA, feeCoinB], fee_address);
164
+ const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
165
+ const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
166
+ if (maps_js_1.poolInfo[poolName].parentProtocolName === "CETUS") {
167
+ if (pool1 === "CETUS" && pool2 === "SUI") {
168
+ txb = await depositCetusSuiTxb(amountA, amountB, poolName, { address }, txb, coin1, coin2);
169
+ }
170
+ else if (pool2 === "SUI") {
171
+ txb = await depositCetusAlphaSuiTxb(amountA, amountB, poolName, { address }, txb, coin1, coin2);
172
+ }
173
+ else {
174
+ txb = await depositCetus(amountA, amountB, poolName, { address }, txb, coin1, coin2);
175
+ }
176
+ }
177
+ else if (maps_js_1.poolInfo[poolName].parentProtocolName === "BLUEFIN") {
178
+ if (poolName === "BLUEFIN-NAVX-VSUI" ||
179
+ poolName === "BLUEFIN-ALPHA-USDC" ||
180
+ poolName === "BLUEFIN-BLUE-USDC") {
181
+ txb = await depositBluefinType2Txb(amountA, amountB, poolName, { address }, txb, coin1, coin2);
182
+ }
183
+ else if (pool1 === "SUI") {
184
+ txb = await depositBluefinSuiFirstTxb(amountA, amountB, poolName, { address }, txb, coin1, coin2);
185
+ }
186
+ else if (pool2 === "SUI") {
187
+ txb = await depositBluefinSuiSecondTxb(amountA, amountB, poolName, { address }, txb, coin1, coin2);
188
+ }
189
+ else if (pool1 === "STSUI") {
190
+ txb = await depositBluefinStsuiTxb(amountA, amountB, poolName, { address }, txb, coin1, coin2);
191
+ }
192
+ else {
193
+ txb = await depositBluefinType1Txb(amountA, amountB, poolName, { address }, txb, coin1, coin2);
194
+ }
195
+ }
196
+ }
197
+ }
198
+ txb.setGasBudget(100000000);
199
+ return txb;
200
+ }
201
+ }
202
+ return undefined;
203
+ }
204
+ const depositCetus = async (amountA, amountB, poolName, options, transaction = undefined, coin1Arg, coin2Arg) => {
205
+ const address = options.address;
206
+ let txb;
207
+ if (transaction)
208
+ txb = transaction;
209
+ else
210
+ txb = new transactions_1.Transaction();
211
+ poolName = poolName.toUpperCase();
212
+ const poolinfo = maps_js_1.poolInfo[poolName];
213
+ const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
214
+ const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
215
+ const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
216
+ amountA = (Number(amountA) * 0.999).toString();
217
+ amountB = (Number(amountB) * 0.999).toString();
218
+ let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, amountA);
219
+ if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
220
+ amounts = await (0, deposit_js_1.getAmounts)(poolName, false, amountB);
221
+ }
222
+ if (amounts && coin1Arg !== undefined && coin2Arg !== undefined) {
223
+ const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
224
+ const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
225
+ let someReceipt;
226
+ if (receipt.length == 0) {
227
+ [someReceipt] = txb.moveCall({
228
+ target: `0x1::option::none`,
229
+ typeArguments: [maps_js_1.poolInfo[poolName].receiptType],
230
+ arguments: [],
231
+ });
232
+ }
233
+ else {
234
+ [someReceipt] = txb.moveCall({
235
+ target: `0x1::option::some`,
236
+ typeArguments: [receipt[0].content.type],
237
+ arguments: [txb.object(receipt[0].objectId)],
238
+ });
239
+ }
240
+ if (poolName == "WUSDC-WBTC" ||
241
+ poolName == "USDC-USDT" ||
242
+ poolName == "USDC-WUSDC" ||
243
+ poolName == "USDC-ETH") {
244
+ txb.moveCall({
245
+ target: `${(0, constants_js_1.getConf)().ALPHA_LATEST_PACKAGE_ID}::alphafi_cetus_pool_base_a::user_deposit`,
246
+ typeArguments: [coins_js_1.coinsList[pool1].type, coins_js_1.coinsList[pool2].type],
247
+ arguments: [
248
+ txb.object((0, constants_js_1.getConf)().VERSION),
249
+ someReceipt,
250
+ txb.object(poolinfo.poolId),
251
+ depositCoinA,
252
+ depositCoinB,
253
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
254
+ txb.object(poolinfo.investorId),
255
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
256
+ txb.object((0, constants_js_1.getConf)().CETUS_REWARDER_GLOBAL_VAULT_ID),
257
+ txb.object(maps_js_1.cetusPoolMap[`${pool1}-SUI`]),
258
+ txb.object(maps_js_1.cetusPoolMap["CETUS-SUI"]),
259
+ txb.object(maps_js_1.cetusPoolMap[poolName]),
260
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
261
+ ],
262
+ });
263
+ }
264
+ else {
265
+ txb.moveCall({
266
+ target: `${(0, constants_js_1.getConf)().ALPHA_LATEST_PACKAGE_ID}::alphafi_cetus_pool::user_deposit`,
267
+ typeArguments: [coins_js_1.coinsList[pool1].type, coins_js_1.coinsList[pool2].type],
268
+ arguments: [
269
+ txb.object((0, constants_js_1.getConf)().VERSION),
270
+ someReceipt,
271
+ txb.object(poolinfo.poolId),
272
+ depositCoinA,
273
+ depositCoinB,
274
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
275
+ txb.object(poolinfo.investorId),
276
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
277
+ txb.object((0, constants_js_1.getConf)().CETUS_REWARDER_GLOBAL_VAULT_ID),
278
+ txb.object(maps_js_1.cetusPoolMap[`${pool2}-SUI`]),
279
+ txb.object(maps_js_1.cetusPoolMap["CETUS-SUI"]),
280
+ txb.object(maps_js_1.cetusPoolMap[poolName]),
281
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
282
+ ],
283
+ });
284
+ }
285
+ txb.transferObjects([coin1Arg, coin2Arg], address);
286
+ }
287
+ else {
288
+ throw new Error(`No ${pool1} or ${pool2} Coins`);
289
+ }
290
+ return txb;
291
+ };
292
+ const depositCetusAlphaSuiTxb = async (amountA, amountB, poolName, options, transaction = undefined, coin1Arg, coin2Arg) => {
293
+ const address = options.address;
294
+ let txb;
295
+ if (transaction)
296
+ txb = transaction;
297
+ else
298
+ txb = new transactions_1.Transaction();
299
+ poolName = poolName.toUpperCase();
300
+ const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
301
+ const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
302
+ const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
303
+ amountA = (Number(amountA) * 0.999).toString();
304
+ amountB = (Number(amountB) * 0.999).toString();
305
+ let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, amountA);
306
+ if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
307
+ amounts = await (0, deposit_js_1.getAmounts)(poolName, false, amountB);
308
+ }
309
+ if (amounts && coin1Arg != undefined && coin2Arg !== undefined) {
310
+ const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
311
+ const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
312
+ const poolinfo = maps_js_1.poolInfo[poolName];
313
+ let someReceipt;
314
+ if (receipt.length == 0) {
315
+ [someReceipt] = txb.moveCall({
316
+ target: `0x1::option::none`,
317
+ typeArguments: [poolinfo.receiptType],
318
+ arguments: [],
319
+ });
320
+ }
321
+ else {
322
+ [someReceipt] = txb.moveCall({
323
+ target: `0x1::option::some`,
324
+ typeArguments: [receipt[0].content.type],
325
+ arguments: [txb.object(receipt[0].objectId)],
326
+ });
327
+ }
328
+ txb.moveCall({
329
+ target: `${(0, constants_js_1.getConf)().ALPHA_LATEST_PACKAGE_ID}::alphafi_cetus_sui_pool::user_deposit`,
330
+ typeArguments: [coins_js_1.coinsList[pool1].type, coins_js_1.coinsList[pool2].type],
331
+ arguments: [
332
+ txb.object((0, constants_js_1.getConf)().VERSION),
333
+ someReceipt,
334
+ txb.object(poolinfo.poolId),
335
+ depositCoinA,
336
+ depositCoinB,
337
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
338
+ txb.object(poolinfo.investorId),
339
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
340
+ txb.object((0, constants_js_1.getConf)().CETUS_REWARDER_GLOBAL_VAULT_ID),
341
+ txb.object(maps_js_1.cetusPoolMap["CETUS-SUI"]),
342
+ txb.object(poolinfo.parentPoolId),
343
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
344
+ ],
345
+ });
346
+ txb.transferObjects([coin1Arg, coin2Arg], address);
347
+ }
348
+ else {
349
+ throw new Error(`No ${pool1} or ${pool2} Coins`);
350
+ }
351
+ return txb;
352
+ };
353
+ const depositCetusSuiTxb = async (amountA, amountB, poolName, options, transaction = undefined, coin1Arg, coin2Arg) => {
354
+ const address = options.address;
355
+ let txb;
356
+ if (transaction)
357
+ txb = transaction;
358
+ else
359
+ txb = new transactions_1.Transaction();
360
+ poolName = poolName.toUpperCase();
361
+ const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
362
+ const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
363
+ const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
364
+ amountA = (Number(amountA) * 0.999).toString();
365
+ amountB = (Number(amountB) * 0.999).toString();
366
+ let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, amountA);
367
+ if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
368
+ amounts = await (0, deposit_js_1.getAmounts)(poolName, false, amountB);
369
+ }
370
+ if (amounts && coin1Arg && coin2Arg) {
371
+ const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
372
+ const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
373
+ const poolinfo = maps_js_1.poolInfo[poolName];
374
+ let someReceipt;
375
+ if (receipt.length == 0) {
376
+ [someReceipt] = txb.moveCall({
377
+ target: `0x1::option::none`,
378
+ typeArguments: [poolinfo.receiptType],
379
+ arguments: [],
380
+ });
381
+ }
382
+ else {
383
+ [someReceipt] = txb.moveCall({
384
+ target: `0x1::option::some`,
385
+ typeArguments: [receipt[0].content.type],
386
+ arguments: [txb.object(receipt[0].objectId)],
387
+ });
388
+ }
389
+ txb.moveCall({
390
+ target: `${poolinfo.packageId}::alphafi_cetus_sui_pool::user_deposit`,
391
+ typeArguments: [coins_js_1.coinsList[pool1].type, coins_js_1.coinsList[pool2].type],
392
+ arguments: [
393
+ txb.object((0, constants_js_1.getConf)().ALPHA_2_VERSION),
394
+ txb.object((0, constants_js_1.getConf)().VERSION),
395
+ someReceipt,
396
+ txb.object(poolinfo.poolId),
397
+ depositCoinA,
398
+ depositCoinB,
399
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
400
+ txb.object(poolinfo.investorId),
401
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
402
+ txb.object((0, constants_js_1.getConf)().CETUS_REWARDER_GLOBAL_VAULT_ID),
403
+ txb.object(maps_js_1.cetusPoolMap[poolName]),
404
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
405
+ ],
406
+ });
407
+ txb.transferObjects([coin1Arg, coin2Arg], address);
408
+ }
409
+ else {
410
+ throw new Error(`No ${pool1} or ${pool2} Coins`);
411
+ }
412
+ return txb;
413
+ };
414
+ const depositBluefinSuiFirstTxb = async (amountA, amountB, poolName, options, transaction = undefined, coin1Arg, coin2Arg) => {
415
+ const address = options.address;
416
+ let txb;
417
+ if (transaction)
418
+ txb = transaction;
419
+ else
420
+ txb = new transactions_1.Transaction();
421
+ poolName = poolName.toUpperCase();
422
+ const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
423
+ const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
424
+ const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
425
+ amountA = (Number(amountA) * 0.999).toString();
426
+ amountB = (Number(amountB) * 0.999).toString();
427
+ let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, amountA);
428
+ if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
429
+ amounts = await (0, deposit_js_1.getAmounts)(poolName, false, amountB);
430
+ }
431
+ if (amounts && coin1Arg && coin2Arg) {
432
+ const [depositCoinA] = txb.splitCoins(txb.gas, [amounts[0]]);
433
+ const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
434
+ const poolinfo = maps_js_1.poolInfo[poolName];
435
+ let someReceipt;
436
+ if (receipt.length == 0) {
437
+ [someReceipt] = txb.moveCall({
438
+ target: `0x1::option::none`,
439
+ typeArguments: [poolinfo.receiptType],
440
+ arguments: [],
441
+ });
442
+ }
443
+ else {
444
+ [someReceipt] = txb.moveCall({
445
+ target: `0x1::option::some`,
446
+ typeArguments: [receipt[0].content.type],
447
+ arguments: [txb.object(receipt[0].objectId)],
448
+ });
449
+ }
450
+ if (poolName === "BLUEFIN-SUI-USDC") {
451
+ txb.moveCall({
452
+ target: `${poolinfo.packageId}::alphafi_bluefin_sui_first_pool::user_deposit`,
453
+ typeArguments: [
454
+ coins_js_1.coinsList[pool1].type,
455
+ coins_js_1.coinsList[pool2].type,
456
+ coins_js_1.coinsList["BLUE"].type,
457
+ coins_js_1.coinsList["SUI"].type,
458
+ ],
459
+ arguments: [
460
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
461
+ txb.object((0, constants_js_1.getConf)().VERSION),
462
+ someReceipt,
463
+ txb.object(poolinfo.poolId),
464
+ depositCoinA,
465
+ depositCoinB,
466
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
467
+ txb.object(poolinfo.investorId),
468
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
469
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
470
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_SUI_USDC_POOL),
471
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL_AUTOCOMPOUND),
472
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
473
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
474
+ ],
475
+ });
476
+ }
477
+ else if (poolName === "BLUEFIN-SUI-BUCK") {
478
+ txb.moveCall({
479
+ target: `${poolinfo.packageId}::alphafi_bluefin_sui_first_pool::user_deposit`,
480
+ typeArguments: [
481
+ coins_js_1.coinsList[pool1].type,
482
+ coins_js_1.coinsList[pool2].type,
483
+ coins_js_1.coinsList["BLUE"].type,
484
+ coins_js_1.coinsList["SUI"].type,
485
+ ],
486
+ arguments: [
487
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
488
+ txb.object((0, constants_js_1.getConf)().VERSION),
489
+ someReceipt,
490
+ txb.object(poolinfo.poolId),
491
+ depositCoinA,
492
+ depositCoinB,
493
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
494
+ txb.object(poolinfo.investorId),
495
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
496
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
497
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_SUI_BUCK_POOL),
498
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL_AUTOCOMPOUND),
499
+ txb.object(maps_js_1.cetusPoolMap["BUCK-SUI"]),
500
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
501
+ ],
502
+ });
503
+ }
504
+ else if (poolName === "BLUEFIN-SUI-AUSD") {
505
+ txb.moveCall({
506
+ target: `${poolinfo.packageId}::alphafi_bluefin_sui_first_pool::user_deposit`,
507
+ typeArguments: [
508
+ coins_js_1.coinsList[pool1].type,
509
+ coins_js_1.coinsList[pool2].type,
510
+ coins_js_1.coinsList["BLUE"].type,
511
+ coins_js_1.coinsList["SUI"].type,
512
+ ],
513
+ arguments: [
514
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
515
+ txb.object((0, constants_js_1.getConf)().VERSION),
516
+ someReceipt,
517
+ txb.object(poolinfo.poolId),
518
+ depositCoinA,
519
+ depositCoinB,
520
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
521
+ txb.object(poolinfo.investorId),
522
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
523
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
524
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_SUI_AUSD_POOL),
525
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL_AUTOCOMPOUND),
526
+ txb.object(maps_js_1.cetusPoolMap["AUSD-SUI"]),
527
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
528
+ ],
529
+ });
530
+ }
531
+ txb.transferObjects([coin1Arg, coin2Arg], address);
532
+ }
533
+ else {
534
+ throw new Error(`No ${pool1} or ${pool2} Coins`);
535
+ }
536
+ return txb;
537
+ };
538
+ const depositBluefinType1Txb = async (amountA, amountB, poolName, options, transaction = undefined, coin1Arg, coin2Arg) => {
539
+ const address = options.address;
540
+ let txb;
541
+ if (transaction)
542
+ txb = transaction;
543
+ else
544
+ txb = new transactions_1.Transaction();
545
+ poolName = poolName.toUpperCase();
546
+ const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
547
+ const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
548
+ const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
549
+ amountA = (Number(amountA) * 0.999).toString();
550
+ amountB = (Number(amountB) * 0.999).toString();
551
+ let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, amountA);
552
+ if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
553
+ amounts = await (0, deposit_js_1.getAmounts)(poolName, false, amountB);
554
+ }
555
+ if (amounts && coin1Arg && coin2Arg) {
556
+ const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
557
+ const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
558
+ const poolinfo = maps_js_1.poolInfo[poolName];
559
+ let someReceipt;
560
+ if (receipt.length == 0) {
561
+ [someReceipt] = txb.moveCall({
562
+ target: `0x1::option::none`,
563
+ typeArguments: [poolinfo.receiptType],
564
+ arguments: [],
565
+ });
566
+ }
567
+ else {
568
+ [someReceipt] = txb.moveCall({
569
+ target: `0x1::option::some`,
570
+ typeArguments: [receipt[0].content.type],
571
+ arguments: [txb.object(receipt[0].objectId)],
572
+ });
573
+ }
574
+ if (poolName === "BLUEFIN-USDT-USDC") {
575
+ txb.moveCall({
576
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit`,
577
+ typeArguments: [
578
+ coins_js_1.coinsList[pool1].type,
579
+ coins_js_1.coinsList[pool2].type,
580
+ coins_js_1.coinsList["BLUE"].type,
581
+ coins_js_1.coinsList["SUI"].type,
582
+ ],
583
+ arguments: [
584
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
585
+ txb.object((0, constants_js_1.getConf)().VERSION),
586
+ someReceipt,
587
+ txb.object(poolinfo.poolId),
588
+ depositCoinA,
589
+ depositCoinB,
590
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
591
+ txb.object(poolinfo.investorId),
592
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
593
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
594
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_USDT_USDC_POOL),
595
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL_AUTOCOMPOUND),
596
+ txb.object(maps_js_1.cetusPoolMap["USDC-USDT"]),
597
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
598
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
599
+ ],
600
+ });
601
+ }
602
+ else if (poolName === "BLUEFIN-AUSD-USDC") {
603
+ txb.moveCall({
604
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit`,
605
+ typeArguments: [
606
+ coins_js_1.coinsList[pool1].type,
607
+ coins_js_1.coinsList[pool2].type,
608
+ coins_js_1.coinsList["BLUE"].type,
609
+ coins_js_1.coinsList["SUI"].type,
610
+ ],
611
+ arguments: [
612
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
613
+ txb.object((0, constants_js_1.getConf)().VERSION),
614
+ someReceipt,
615
+ txb.object(poolinfo.poolId),
616
+ depositCoinA,
617
+ depositCoinB,
618
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
619
+ txb.object(poolinfo.investorId),
620
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
621
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
622
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_AUSD_USDC_POOL),
623
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL_AUTOCOMPOUND),
624
+ txb.object(maps_js_1.cetusPoolMap["USDC-AUSD"]),
625
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
626
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
627
+ ],
628
+ });
629
+ }
630
+ else if (poolName === "BLUEFIN-WBTC-USDC") {
631
+ txb.moveCall({
632
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit`,
633
+ typeArguments: [
634
+ coins_js_1.coinsList[pool1].type,
635
+ coins_js_1.coinsList[pool2].type,
636
+ coins_js_1.coinsList["BLUE"].type,
637
+ coins_js_1.coinsList["SUI"].type,
638
+ ],
639
+ arguments: [
640
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
641
+ txb.object((0, constants_js_1.getConf)().VERSION),
642
+ someReceipt,
643
+ txb.object(poolinfo.poolId),
644
+ depositCoinA,
645
+ depositCoinB,
646
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
647
+ txb.object(poolinfo.investorId),
648
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
649
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
650
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_WBTC_USDC_POOL),
651
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL_AUTOCOMPOUND),
652
+ txb.object(maps_js_1.cetusPoolMap["USDC-WBTC"]),
653
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
654
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
655
+ ],
656
+ });
657
+ }
658
+ else if (poolName === "BLUEFIN-SEND-USDC") {
659
+ txb.moveCall({
660
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit`,
661
+ typeArguments: [
662
+ coins_js_1.coinsList[pool1].type,
663
+ coins_js_1.coinsList[pool2].type,
664
+ coins_js_1.coinsList["BLUE"].type,
665
+ coins_js_1.coinsList["SUI"].type,
666
+ ],
667
+ arguments: [
668
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
669
+ txb.object((0, constants_js_1.getConf)().VERSION),
670
+ someReceipt,
671
+ txb.object(poolinfo.poolId),
672
+ depositCoinA,
673
+ depositCoinB,
674
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
675
+ txb.object(poolinfo.investorId),
676
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
677
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
678
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_SEND_USDC_POOL),
679
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL_AUTOCOMPOUND),
680
+ txb.object(maps_js_1.cetusPoolMap["USDC-SEND"]),
681
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
682
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
683
+ ],
684
+ });
685
+ }
686
+ txb.transferObjects([coin1Arg, coin2Arg], address);
687
+ }
688
+ else {
689
+ throw new Error(`No ${pool1} or ${pool2} Coins`);
690
+ }
691
+ return txb;
692
+ };
693
+ const depositBluefinType2Txb = async (amountA, amountB, poolName, options, transaction = undefined, coin1Arg, coin2Arg) => {
694
+ const address = options.address;
695
+ let txb;
696
+ if (transaction)
697
+ txb = transaction;
698
+ else
699
+ txb = new transactions_1.Transaction();
700
+ poolName = poolName.toUpperCase();
701
+ const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
702
+ const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
703
+ const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
704
+ amountA = (Number(amountA) * 0.999).toString();
705
+ amountB = (Number(amountB) * 0.999).toString();
706
+ let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, amountA);
707
+ if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
708
+ amounts = await (0, deposit_js_1.getAmounts)(poolName, false, amountB);
709
+ }
710
+ if (amounts && coin1Arg && coin2Arg) {
711
+ const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
712
+ const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
713
+ const poolinfo = maps_js_1.poolInfo[poolName];
714
+ let someReceipt;
715
+ if (receipt.length == 0) {
716
+ [someReceipt] = txb.moveCall({
717
+ target: `0x1::option::none`,
718
+ typeArguments: [poolinfo.receiptType],
719
+ arguments: [],
720
+ });
721
+ }
722
+ else {
723
+ [someReceipt] = txb.moveCall({
724
+ target: `0x1::option::some`,
725
+ typeArguments: [receipt[0].content.type],
726
+ arguments: [txb.object(receipt[0].objectId)],
727
+ });
728
+ }
729
+ if (poolName === "BLUEFIN-ALPHA-USDC") {
730
+ txb.moveCall({
731
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_2_pool::user_deposit`,
732
+ typeArguments: [
733
+ coins_js_1.coinsList[pool1].type,
734
+ coins_js_1.coinsList[pool2].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_4_VERSION),
740
+ txb.object((0, constants_js_1.getConf)().VERSION),
741
+ someReceipt,
742
+ txb.object(poolinfo.poolId),
743
+ depositCoinA,
744
+ depositCoinB,
745
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
746
+ txb.object(poolinfo.investorId),
747
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
748
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
749
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_ALPHA_USDC_POOL),
750
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL_AUTOCOMPOUND),
751
+ txb.object(maps_js_1.cetusPoolMap["ALPHA-USDC"]),
752
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
753
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
754
+ ],
755
+ });
756
+ }
757
+ else if (poolName === "BLUEFIN-NAVX-VSUI") {
758
+ txb.moveCall({
759
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_2_pool::user_deposit`,
760
+ typeArguments: [
761
+ coins_js_1.coinsList[pool1].type,
762
+ coins_js_1.coinsList[pool2].type,
763
+ coins_js_1.coinsList["BLUE"].type,
764
+ coins_js_1.coinsList["SUI"].type,
765
+ ],
766
+ arguments: [
767
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
768
+ txb.object((0, constants_js_1.getConf)().VERSION),
769
+ someReceipt,
770
+ txb.object(poolinfo.poolId),
771
+ depositCoinA,
772
+ depositCoinB,
773
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
774
+ txb.object(poolinfo.investorId),
775
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
776
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
777
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_NAVX_VSUI_POOL),
778
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL_AUTOCOMPOUND),
779
+ txb.object(maps_js_1.cetusPoolMap["NAVX-VSUI"]),
780
+ txb.object(maps_js_1.cetusPoolMap["VSUI-SUI"]),
781
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
782
+ ],
783
+ });
784
+ }
785
+ else if (poolName === "BLUEFIN-BLUE-USDC") {
786
+ txb.moveCall({
787
+ target: `${poolinfo.packageId}::alphafi_bluefin_type_2_pool::user_deposit`,
788
+ typeArguments: [
789
+ coins_js_1.coinsList[pool1].type,
790
+ coins_js_1.coinsList[pool2].type,
791
+ coins_js_1.coinsList["DEEP"].type,
792
+ coins_js_1.coinsList["SUI"].type,
793
+ ],
794
+ arguments: [
795
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
796
+ txb.object((0, constants_js_1.getConf)().VERSION),
797
+ someReceipt,
798
+ txb.object(poolinfo.poolId),
799
+ depositCoinA,
800
+ depositCoinB,
801
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
802
+ txb.object(poolinfo.investorId),
803
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
804
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
805
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_USDC_POOL),
806
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
807
+ txb.object(maps_js_1.cetusPoolMap["BLUE-USDC"]),
808
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
809
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
810
+ ],
811
+ });
812
+ }
813
+ txb.transferObjects([coin1Arg, coin2Arg], address);
814
+ }
815
+ else {
816
+ throw new Error(`No ${pool1} or ${pool2} Coins`);
817
+ }
818
+ return txb;
819
+ };
820
+ const depositBluefinSuiSecondTxb = async (amountA, amountB, poolName, options, transaction = undefined, coin1Arg, coin2Arg) => {
821
+ const address = options.address;
822
+ let txb;
823
+ if (transaction)
824
+ txb = transaction;
825
+ else
826
+ txb = new transactions_1.Transaction();
827
+ poolName = poolName.toUpperCase();
828
+ const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
829
+ const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
830
+ const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
831
+ amountA = (Number(amountA) * 0.999).toString();
832
+ amountB = (Number(amountB) * 0.999).toString();
833
+ let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, amountA);
834
+ if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
835
+ amounts = await (0, deposit_js_1.getAmounts)(poolName, false, amountB);
836
+ }
837
+ if (amounts && coin1Arg && coin2Arg) {
838
+ const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
839
+ const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
840
+ const poolinfo = maps_js_1.poolInfo[poolName];
841
+ let someReceipt;
842
+ if (receipt.length == 0) {
843
+ [someReceipt] = txb.moveCall({
844
+ target: `0x1::option::none`,
845
+ typeArguments: [poolinfo.receiptType],
846
+ arguments: [],
847
+ });
848
+ }
849
+ else {
850
+ [someReceipt] = txb.moveCall({
851
+ target: `0x1::option::some`,
852
+ typeArguments: [receipt[0].content.type],
853
+ arguments: [txb.object(receipt[0].objectId)],
854
+ });
855
+ }
856
+ if (poolName === "BLUEFIN-BLUE-SUI") {
857
+ txb.moveCall({
858
+ target: `${poolinfo.packageId}::alphafi_bluefin_sui_second_pool::user_deposit`,
859
+ typeArguments: [
860
+ coins_js_1.coinsList[pool1].type,
861
+ coins_js_1.coinsList[pool2].type,
862
+ coins_js_1.coinsList["DEEP"].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_BLUE_SUI_POOL),
877
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
878
+ txb.object(maps_js_1.cetusPoolMap["BLUE-SUI"]),
879
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
880
+ ],
881
+ });
882
+ }
883
+ else if (poolName === "BLUEFIN-WBTC-SUI") {
884
+ txb.moveCall({
885
+ target: `${poolinfo.packageId}::alphafi_bluefin_sui_second_pool::user_deposit`,
886
+ typeArguments: [
887
+ coins_js_1.coinsList[pool1].type,
888
+ coins_js_1.coinsList[pool2].type,
889
+ coins_js_1.coinsList["BLUE"].type,
890
+ coins_js_1.coinsList["SUI"].type,
891
+ ],
892
+ arguments: [
893
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
894
+ txb.object((0, constants_js_1.getConf)().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_WBTC_SUI_POOL),
904
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
905
+ txb.object(maps_js_1.cetusPoolMap["WBTC-SUI"]),
906
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
907
+ ],
908
+ });
909
+ }
910
+ else if (poolName === "BLUEFIN-DEEP-SUI") {
911
+ txb.moveCall({
912
+ target: `${poolinfo.packageId}::alphafi_bluefin_sui_second_pool::user_deposit`,
913
+ typeArguments: [
914
+ coins_js_1.coinsList[pool1].type,
915
+ coins_js_1.coinsList[pool2].type,
916
+ coins_js_1.coinsList["BLUE"].type,
917
+ coins_js_1.coinsList["SUI"].type,
918
+ ],
919
+ arguments: [
920
+ txb.object((0, constants_js_1.getConf)().ALPHA_4_VERSION),
921
+ txb.object((0, constants_js_1.getConf)().VERSION),
922
+ someReceipt,
923
+ txb.object(poolinfo.poolId),
924
+ depositCoinA,
925
+ depositCoinB,
926
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
927
+ txb.object(poolinfo.investorId),
928
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
929
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
930
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_DEEP_SUI_POOL),
931
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL),
932
+ txb.object(maps_js_1.cetusPoolMap["DEEP-SUI"]),
933
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
934
+ ],
935
+ });
936
+ }
937
+ txb.transferObjects([coin1Arg, coin2Arg], address);
938
+ }
939
+ else {
940
+ throw new Error(`No ${pool1} or ${pool2} Coins`);
941
+ }
942
+ return txb;
943
+ };
944
+ const depositBluefinStsuiTxb = async (amountA, amountB, poolName, options, transaction = undefined, coin1Arg, coin2Arg) => {
945
+ const address = options.address;
946
+ let txb;
947
+ if (transaction)
948
+ txb = transaction;
949
+ else
950
+ txb = new transactions_1.Transaction();
951
+ poolName = poolName.toUpperCase();
952
+ const pool1 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
953
+ const pool2 = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
954
+ const receipt = await (0, getReceipts_js_1.getReceipts)(poolName, address, true);
955
+ amountA = (Number(amountA) * 0.999).toString();
956
+ amountB = (Number(amountB) * 0.999).toString();
957
+ let amounts = await (0, deposit_js_1.getAmounts)(poolName, true, amountA);
958
+ if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
959
+ amounts = await (0, deposit_js_1.getAmounts)(poolName, false, amountB);
960
+ }
961
+ if (amounts && coin1Arg && coin2Arg) {
962
+ const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
963
+ const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
964
+ const poolinfo = maps_js_1.poolInfo[poolName];
965
+ let someReceipt;
966
+ if (receipt.length == 0) {
967
+ [someReceipt] = txb.moveCall({
968
+ target: `0x1::option::none`,
969
+ typeArguments: [poolinfo.receiptType],
970
+ arguments: [],
971
+ });
972
+ }
973
+ else {
974
+ [someReceipt] = txb.moveCall({
975
+ target: `0x1::option::some`,
976
+ typeArguments: [receipt[0].content.type],
977
+ arguments: [txb.object(receipt[0].objectId)],
978
+ });
979
+ }
980
+ if (poolName === "BLUEFIN-STSUI-USDC") {
981
+ txb.moveCall({
982
+ target: `${poolinfo.packageId}::alphafi_bluefin_stsui_first_pool::user_deposit`,
983
+ typeArguments: [
984
+ coins_js_1.coinsList[pool1].type,
985
+ coins_js_1.coinsList[pool2].type,
986
+ coins_js_1.coinsList["BLUE"].type,
987
+ ],
988
+ arguments: [
989
+ txb.object((0, constants_js_1.getConf)().ALPHA_STSUI_VERSION),
990
+ txb.object((0, constants_js_1.getConf)().VERSION),
991
+ someReceipt,
992
+ txb.object(poolinfo.poolId),
993
+ depositCoinA,
994
+ depositCoinB,
995
+ txb.object((0, constants_js_1.getConf)().ALPHA_DISTRIBUTOR),
996
+ txb.object(poolinfo.investorId),
997
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_GLOBAL_CONFIG),
998
+ txb.object((0, constants_js_1.getConf)().CETUS_GLOBAL_CONFIG_ID),
999
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_STSUI_USDC_POOL),
1000
+ txb.object((0, constants_js_1.getConf)().BLUEFIN_BLUE_SUI_POOL_AUTOCOMPOUND),
1001
+ txb.object(maps_js_1.cetusPoolMap["USDC-SUI"]),
1002
+ txb.object(maps_js_1.bluefinPoolMap["SUI-USDC"]),
1003
+ txb.object((0, constants_js_1.getConf)().LST_INFO),
1004
+ txb.object((0, constants_js_1.getConf)().SUI_SYSTEM_STATE),
1005
+ txb.pure.bool(true),
1006
+ txb.object((0, constants_js_1.getConf)().CLOCK_PACKAGE_ID),
1007
+ ],
1008
+ });
1009
+ }
1010
+ txb.transferObjects([coin1Arg, coin2Arg], address);
1011
+ }
1012
+ else {
1013
+ throw new Error(`No ${pool1} or ${pool2} Coins`);
1014
+ }
1015
+ return txb;
1016
+ };
1017
+ async function getZapAmounts(inputCoinAmount, inputCoinName, poolName, slippage, options, ignoreCache) {
1018
+ const address = options.address;
1019
+ const coinTypeA = maps_js_1.doubleAssetPoolCoinMap[poolName].coin1;
1020
+ const coinTypeB = maps_js_1.doubleAssetPoolCoinMap[poolName].coin2;
1021
+ const swapObjectA = coins_js_1.coinsList[coinTypeA];
1022
+ const swapObjectB = coins_js_1.coinsList[coinTypeB];
1023
+ const inputObject = coins_js_1.coinsList[inputCoinName];
1024
+ const amounts = await (0, deposit_js_1.getAmounts)(poolName, true, "100000001");
1025
+ if (amounts) {
1026
+ const amount1 = Number(amounts[0]);
1027
+ const amount2 = Number(amounts[1]);
1028
+ const swapGateway = new _7k_js_1.SevenKGateway();
1029
+ const swapOptions = {
1030
+ pair: {
1031
+ coinA: swapObjectA,
1032
+ coinB: swapObjectB,
1033
+ },
1034
+ senderAddress: address,
1035
+ inAmount: new bn_js_1.default(amount1),
1036
+ slippage: slippage,
1037
+ };
1038
+ const ratioQuote = await swapGateway.getQuote(swapOptions);
1039
+ if (ratioQuote) {
1040
+ const amount1InCoinType2 = Number(ratioQuote.returnAmountWithDecimal);
1041
+ const totalAmount = amount2 + amount1InCoinType2;
1042
+ const inputAmountToType1 = Math.floor((inputCoinAmount * amount1InCoinType2) / totalAmount);
1043
+ const inputAmountToType2 = Math.floor((inputCoinAmount * amount2) / totalAmount);
1044
+ let amountA, amountB;
1045
+ const swapOptionsI2A = {
1046
+ pair: {
1047
+ coinA: inputObject,
1048
+ coinB: swapObjectA,
1049
+ },
1050
+ senderAddress: address,
1051
+ inAmount: new bn_js_1.default(inputAmountToType1),
1052
+ slippage: slippage,
1053
+ };
1054
+ const swapOptionsI2B = {
1055
+ pair: {
1056
+ coinA: inputObject,
1057
+ coinB: swapObjectB,
1058
+ },
1059
+ senderAddress: address,
1060
+ inAmount: new bn_js_1.default(inputAmountToType2),
1061
+ slippage: slippage,
1062
+ };
1063
+ if (inputCoinName === coinTypeA) {
1064
+ const quoteResponse = await swapGateway.getQuote(swapOptionsI2B);
1065
+ if (quoteResponse) {
1066
+ amountB = quoteResponse.returnAmountWithDecimal;
1067
+ }
1068
+ amountA = inputAmountToType1.toString();
1069
+ }
1070
+ else if (inputCoinName === coinTypeB) {
1071
+ const quoteResponse = await swapGateway.getQuote(swapOptionsI2A);
1072
+ if (quoteResponse) {
1073
+ amountA = quoteResponse.returnAmountWithDecimal;
1074
+ }
1075
+ amountB = inputAmountToType2.toString();
1076
+ }
1077
+ else {
1078
+ let quoteResponse = await swapGateway.getQuote(swapOptionsI2A);
1079
+ if (quoteResponse) {
1080
+ amountA = quoteResponse.returnAmountWithDecimal;
1081
+ }
1082
+ quoteResponse = await swapGateway.getQuote(swapOptionsI2B);
1083
+ if (quoteResponse) {
1084
+ amountB = quoteResponse.returnAmountWithDecimal;
1085
+ }
1086
+ }
1087
+ if (amountA && amountB) {
1088
+ const [coin1Price, coin2Price] = await (0, prices_js_1.getLatestPrices)([
1089
+ `${swapObjectA.name}/USD`,
1090
+ `${swapObjectB.name}/USD`,
1091
+ ], ignoreCache);
1092
+ const coin1InUSD = Number(amountA) * Number(coin1Price);
1093
+ const coin2InUSD = Number(amountB) * Number(coin2Price);
1094
+ return [
1095
+ amountA.toString(),
1096
+ coin1InUSD.toString(),
1097
+ amountB.toString(),
1098
+ coin2InUSD.toString(),
1099
+ ];
1100
+ }
1101
+ }
1102
+ }
1103
+ }
1104
+ // export async function zapWithdraw(
1105
+ // amount: string,
24
1106
  // poolName: PoolName,
25
- // slippage: number, // 0.01 --> 1%, 0.001 --> 0.1%
26
- // options: { address: string },
27
- // ): Promise<Transaction | undefined> {
28
- // let txb = new Transaction();
29
- // const suiClient = getSuiClient();
1107
+ // outputCoinName: string,
1108
+ // options: { suiClient: SuiClient; address: string },
1109
+ // ) {
1110
+ // const suiClient = options.suiClient;
30
1111
  // const address = options.address;
31
- // const coinTypeA = doubleAssetPoolCoinMap[poolName].coin1;
32
- // const coinTypeB = doubleAssetPoolCoinMap[poolName].coin2;
33
- // const swapObjectA = coinsList[coinTypeA];
34
- // const swapObjectB = coinsList[coinTypeB];
35
- // const inputObject = coinsList[inputCoinName];
36
- // let coin1, coin2;
37
- // const amounts = await getAmounts(poolName, true, "100000001");
38
- // if (amounts) {
39
- // const amount1 = Number(amounts[0]);
40
- // const amount2 = Number(amounts[1]);
41
- // const swapGateway = new SevenKGateway();
42
- // const swapOptions: SwapOptions = {
43
- // pair: {
44
- // coinA: swapObjectA,
45
- // coinB: swapObjectB,
46
- // },
47
- // senderAddress: address,
48
- // inAmount: new BN(amount1),
49
- // slippage: slippage,
50
- // };
51
- // const ratioQuote = await swapGateway.getQuote(swapOptions);
52
- // if (ratioQuote) {
53
- // const amount1InCoinType2 = Number(ratioQuote.returnAmountWithDecimal);
54
- // const totalAmount = amount2 + amount1InCoinType2;
55
- // const inputAmountToType1 = Math.floor(
56
- // (inputCoinAmount * amount1InCoinType2) / totalAmount,
57
- // );
58
- // const inputAmountToType2 = Math.floor(
59
- // (inputCoinAmount * amount2) / totalAmount,
60
- // );
61
- // let amountA, amountB;
62
- // const swapOptionsI2A = {
63
- // pair: {
64
- // coinA: inputObject,
65
- // coinB: swapObjectA,
66
- // },
67
- // senderAddress: address,
68
- // inAmount: new BN(inputAmountToType1),
69
- // slippage: slippage,
70
- // };
71
- // const swapOptionsI2B = {
72
- // pair: {
73
- // coinA: inputObject,
74
- // coinB: swapObjectB,
75
- // },
76
- // senderAddress: address,
77
- // inAmount: new BN(inputAmountToType2),
78
- // slippage: slippage,
79
- // };
80
- // if (inputCoinName === coinTypeA) {
81
- // const quoteResponse = await swapGateway.getQuote(swapOptionsI2B);
82
- // if (quoteResponse) {
83
- // amountB = quoteResponse.returnAmountWithDecimal;
84
- // const result = await swapGateway.getTransactionBlock(
85
- // swapOptionsI2B,
86
- // quoteResponse,
87
- // txb,
88
- // );
89
- // txb = result.tx;
90
- // if (result.coinOut) {
91
- // coin2 = result.coinOut;
92
- // }
93
- // }
94
- // amountA = inputAmountToType1.toString();
95
- // if (coinTypeA === "SUI") {
96
- // [coin1] = txb.splitCoins(txb.gas, [amountA]);
97
- // } else {
98
- // let currentCursor: string | null | undefined = null;
99
- // let coins1: CoinStruct[] = [];
100
- // do {
101
- // const response = await suiClient.getCoins({
102
- // owner: address,
103
- // coinType: coinsList[coinTypeA].type,
104
- // cursor: currentCursor,
105
- // });
106
- // coins1 = coins1.concat(response.data);
107
- // if (response.hasNextPage && response.nextCursor) {
108
- // currentCursor = response.nextCursor;
109
- // } else break;
110
- // } while (true);
111
- // [coin1] = txb.splitCoins(txb.object(coins1[0].coinObjectId), [0]);
112
- // txb.mergeCoins(
113
- // coin1,
114
- // coins1.map((c) => c.coinObjectId),
115
- // );
116
- // }
117
- // } else if (inputCoinName === coinTypeB) {
118
- // const quoteResponse = await swapGateway.getQuote(swapOptionsI2A);
119
- // if (quoteResponse) {
120
- // amountA = quoteResponse.returnAmountWithDecimal;
121
- // const result = await swapGateway.getTransactionBlock(
122
- // swapOptionsI2A,
123
- // quoteResponse,
124
- // txb,
125
- // );
126
- // txb = result.tx;
127
- // if (result.coinOut) {
128
- // coin1 = result.coinOut;
129
- // }
130
- // }
131
- // amountB = inputAmountToType2.toString();
132
- // if (coinTypeB === "SUI") {
133
- // [coin2] = txb.splitCoins(txb.gas, [amountB]);
134
- // } else {
135
- // let currentCursor: string | null | undefined = null;
136
- // let coins2: CoinStruct[] = [];
137
- // do {
138
- // const response = await suiClient.getCoins({
139
- // owner: address,
140
- // coinType: coinsList[coinTypeB].type,
141
- // cursor: currentCursor,
142
- // });
143
- // coins2 = coins2.concat(response.data);
144
- // if (response.hasNextPage && response.nextCursor) {
145
- // currentCursor = response.nextCursor;
146
- // } else break;
147
- // } while (true);
148
- // [coin2] = txb.splitCoins(txb.object(coins2[0].coinObjectId), [0]);
149
- // txb.mergeCoins(
150
- // coin2,
151
- // coins2.map((c) => c.coinObjectId),
152
- // );
153
- // }
154
- // } else {
155
- // let quoteResponse = await swapGateway.getQuote(swapOptionsI2A);
156
- // if (quoteResponse) {
157
- // amountA = quoteResponse.returnAmountWithDecimal;
158
- // const result = await swapGateway.getTransactionBlock(
159
- // swapOptionsI2A,
160
- // quoteResponse,
161
- // txb,
162
- // );
163
- // txb = result.tx;
164
- // if (result.coinOut) {
165
- // coin1 = result.coinOut;
166
- // }
167
- // }
168
- // quoteResponse = await swapGateway.getQuote(swapOptionsI2B);
169
- // if (quoteResponse) {
170
- // amountB = quoteResponse.returnAmountWithDecimal;
171
- // const result = await swapGateway.getTransactionBlock(
172
- // swapOptionsI2B,
173
- // quoteResponse,
174
- // txb,
175
- // );
176
- // txb = result.tx;
177
- // if (result.coinOut) {
178
- // coin2 = result.coinOut;
179
- // }
180
- // }
181
- // }
182
- // if (amountA && amountB) {
183
- // if (coin1 && coin2) {
184
- // // fee charge
185
- // const fee_address = getConf().FEE_ADDRESS;
186
- // const feePercentage = 0.05;
187
- // const amountAFee = ((Number(amountA) * feePercentage) / 100).toFixed(
188
- // 0,
189
- // );
190
- // const amountBFee = ((Number(amountB) * feePercentage) / 100).toFixed(
191
- // 0,
192
- // );
193
- // const [feeCoinA] = txb.splitCoins(coin1, [amountAFee]);
194
- // const [feeCoinB] = txb.splitCoins(coin2, [amountBFee]);
195
- // txb.transferObjects([feeCoinA, feeCoinB], fee_address);
196
- // if (
197
- // poolName === "ALPHA-SUI" ||
198
- // poolName === "WUSDC-SUI" ||
199
- // poolName === "NAVX-SUI" ||
200
- // poolName === "USDC-SUI" ||
201
- // poolName === "BUCK-SUI" ||
202
- // poolName === "DEEP-SUI" ||
203
- // poolName === "FUD-SUI"
204
- // ) {
205
- // txb = await depositCetusAlphaSuiTxb(
206
- // amountA,
207
- // amountB,
208
- // poolName,
209
- // { address },
210
- // txb,
211
- // coin1,
212
- // coin2,
213
- // );
214
- // } else if (poolName === "CETUS-SUI") {
215
- // txb = await depositCetusSuiTxb(
216
- // amountA,
217
- // amountB,
218
- // poolName,
219
- // { address },
220
- // txb,
221
- // coin1,
222
- // coin2,
223
- // );
224
- // } else if (poolName === "BLUEFIN-SUI-USDC") {
225
- // txb = await depositBluefinSuiFirstTxb(
226
- // amountA,
227
- // amountB,
228
- // poolName,
229
- // { address },
230
- // txb,
231
- // coin1,
232
- // coin2,
233
- // );
234
- // } else if (poolName === "BLUEFIN-USDT-USDC") {
235
- // txb = await depositBluefinType1Txb(
236
- // amountA,
237
- // amountB,
238
- // poolName,
239
- // { address },
240
- // txb,
241
- // coin1,
242
- // coin2,
243
- // );
244
- // } else {
245
- // txb = await depositCetus(
246
- // amountA,
247
- // amountB,
248
- // poolName,
249
- // { address },
250
- // txb,
251
- // coin1,
252
- // coin2,
253
- // );
254
- // }
255
- // }
256
- // }
257
- // txb.setGasBudget(100000000);
258
- // return txb;
259
- // }
260
- // }
261
- // return undefined;
262
- // }
263
- // const depositCetus = async (
264
- // amountA: string,
265
- // amountB: string,
266
- // poolName: PoolName,
267
- // options: { address: string },
268
- // transaction: Transaction | undefined = undefined,
269
- // coin1Arg: TransactionObjectArgument | undefined,
270
- // coin2Arg: TransactionObjectArgument | undefined,
271
- // ): Promise<Transaction> => {
272
- // const address = options.address;
273
- // let txb;
274
- // if (transaction) txb = transaction;
275
- // else txb = new Transaction();
276
- // poolName = poolName.toUpperCase() as PoolName;
277
- // const poolinfo = poolInfo[poolName];
278
- // const pool1 = doubleAssetPoolCoinMap[poolName].coin1;
279
- // const pool2 = doubleAssetPoolCoinMap[poolName].coin2;
280
- // const receipt: Receipt[] = await getReceipts(poolName, address, true);
281
- // amountA = (Number(amountA) * 0.999).toString();
282
- // amountB = (Number(amountB) * 0.999).toString();
283
- // let amounts = await getAmounts(poolName, true, amountA);
284
- // if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
285
- // amounts = await getAmounts(poolName, false, amountB);
286
- // }
287
- // if (amounts && coin1Arg !== undefined && coin2Arg !== undefined) {
288
- // const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
289
- // const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
290
- // let someReceipt: any;
291
- // if (receipt.length == 0) {
292
- // [someReceipt] = txb.moveCall({
293
- // target: `0x1::option::none`,
294
- // typeArguments: [poolInfo[poolName].receiptType],
295
- // arguments: [],
296
- // });
297
- // } else {
298
- // [someReceipt] = txb.moveCall({
299
- // target: `0x1::option::some`,
300
- // typeArguments: [receipt[0].content.type],
301
- // arguments: [txb.object(receipt[0].objectId)],
302
- // });
303
- // }
304
- // if (
305
- // poolName == "WUSDC-WBTC" ||
306
- // poolName == "USDC-USDT" ||
307
- // poolName == "USDC-WUSDC" ||
308
- // poolName == "USDC-ETH"
309
- // ) {
310
- // txb.moveCall({
311
- // target: `${getConf().ALPHA_LATEST_PACKAGE_ID}::alphafi_cetus_pool_base_a::user_deposit`,
312
- // typeArguments: [coinsList[pool1].type, coinsList[pool2].type],
313
- // arguments: [
314
- // txb.object(getConf().VERSION),
315
- // someReceipt,
316
- // txb.object(poolinfo.poolId),
317
- // depositCoinA,
318
- // depositCoinB,
319
- // txb.object(getConf().ALPHA_DISTRIBUTOR),
320
- // txb.object(poolinfo.investorId),
321
- // txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
322
- // txb.object(getConf().CETUS_REWARDER_GLOBAL_VAULT_ID),
323
- // txb.object(cetusPoolMap[`${pool1}-SUI`]),
324
- // txb.object(cetusPoolMap["CETUS-SUI"]),
325
- // txb.object(cetusPoolMap[poolName]),
326
- // txb.object(getConf().CLOCK_PACKAGE_ID),
327
- // ],
328
- // });
329
- // } else {
330
- // txb.moveCall({
331
- // target: `${getConf().ALPHA_LATEST_PACKAGE_ID}::alphafi_cetus_pool::user_deposit`,
332
- // typeArguments: [coinsList[pool1].type, coinsList[pool2].type],
333
- // arguments: [
334
- // txb.object(getConf().VERSION),
335
- // someReceipt,
336
- // txb.object(poolinfo.poolId),
337
- // depositCoinA,
338
- // depositCoinB,
339
- // txb.object(getConf().ALPHA_DISTRIBUTOR),
340
- // txb.object(poolinfo.investorId),
341
- // txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
342
- // txb.object(getConf().CETUS_REWARDER_GLOBAL_VAULT_ID),
343
- // txb.object(cetusPoolMap[`${pool2}-SUI`]),
344
- // txb.object(cetusPoolMap["CETUS-SUI"]),
345
- // txb.object(cetusPoolMap[poolName]),
346
- // txb.object(getConf().CLOCK_PACKAGE_ID),
347
- // ],
348
- // });
349
- // }
350
- // txb.transferObjects([coin1Arg, coin2Arg], address);
351
- // } else {
352
- // throw new Error(`No ${pool1} or ${pool2} Coins`);
353
- // }
354
- // return txb;
355
- // };
356
- // const depositCetusAlphaSuiTxb = async (
357
- // amountA: string,
358
- // amountB: string,
359
- // poolName: PoolName,
360
- // options: { address: string },
361
- // transaction: Transaction | undefined = undefined,
362
- // coin1Arg: TransactionObjectArgument | undefined,
363
- // coin2Arg: TransactionObjectArgument | undefined,
364
- // ): Promise<Transaction> => {
365
- // const address = options.address;
366
- // let txb;
367
- // if (transaction) txb = transaction;
368
- // else txb = new Transaction();
369
- // poolName = poolName.toUpperCase() as PoolName;
370
- // const pool1 = doubleAssetPoolCoinMap[poolName].coin1;
371
- // const pool2 = doubleAssetPoolCoinMap[poolName].coin2;
372
- // const receipt: Receipt[] = await getReceipts(poolName, address, true);
373
- // amountA = (Number(amountA) * 0.999).toString();
374
- // amountB = (Number(amountB) * 0.999).toString();
375
- // let amounts = await getAmounts(poolName, true, amountA);
376
- // if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
377
- // amounts = await getAmounts(poolName, false, amountB);
378
- // }
379
- // if (amounts && coin1Arg != undefined && coin2Arg !== undefined) {
380
- // const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
381
- // const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
382
- // const poolinfo = poolInfo[poolName];
383
- // let someReceipt: any;
384
- // if (receipt.length == 0) {
385
- // [someReceipt] = txb.moveCall({
386
- // target: `0x1::option::none`,
387
- // typeArguments: [poolinfo.receiptType],
388
- // arguments: [],
389
- // });
390
- // } else {
391
- // [someReceipt] = txb.moveCall({
392
- // target: `0x1::option::some`,
393
- // typeArguments: [receipt[0].content.type],
394
- // arguments: [txb.object(receipt[0].objectId)],
395
- // });
396
- // }
397
- // txb.moveCall({
398
- // target: `${getConf().ALPHA_LATEST_PACKAGE_ID}::alphafi_cetus_sui_pool::user_deposit`,
399
- // typeArguments: [coinsList[pool1].type, coinsList[pool2].type],
400
- // arguments: [
401
- // txb.object(getConf().VERSION),
402
- // someReceipt,
403
- // txb.object(poolinfo.poolId),
404
- // depositCoinA,
405
- // depositCoinB,
406
- // txb.object(getConf().ALPHA_DISTRIBUTOR),
407
- // txb.object(poolinfo.investorId),
408
- // txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
409
- // txb.object(getConf().CETUS_REWARDER_GLOBAL_VAULT_ID),
410
- // txb.object(cetusPoolMap["CETUS-SUI"]),
411
- // txb.object(poolinfo.parentPoolId),
412
- // txb.object(getConf().CLOCK_PACKAGE_ID),
413
- // ],
414
- // });
415
- // txb.transferObjects([coin1Arg, coin2Arg], address);
416
- // } else {
417
- // throw new Error(`No ${pool1} or ${pool2} Coins`);
418
- // }
419
- // return txb;
420
- // };
421
- // const depositCetusSuiTxb = async (
422
- // amountA: string,
423
- // amountB: string,
424
- // poolName: PoolName,
425
- // options: { address: string },
426
- // transaction: Transaction | undefined = undefined,
427
- // coin1Arg: TransactionObjectArgument | undefined,
428
- // coin2Arg: TransactionObjectArgument | undefined,
429
- // ): Promise<Transaction> => {
430
- // const address = options.address;
431
- // let txb;
432
- // if (transaction) txb = transaction;
433
- // else txb = new Transaction();
434
- // poolName = poolName.toUpperCase() as PoolName;
435
- // const pool1 = doubleAssetPoolCoinMap[poolName].coin1;
436
- // const pool2 = doubleAssetPoolCoinMap[poolName].coin2;
437
- // const receipt: Receipt[] = await getReceipts(poolName, address, true);
438
- // amountA = (Number(amountA) * 0.999).toString();
439
- // amountB = (Number(amountB) * 0.999).toString();
440
- // let amounts = await getAmounts(poolName, true, amountA);
441
- // if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
442
- // amounts = await getAmounts(poolName, false, amountB);
443
- // }
444
- // if (amounts && coin1Arg && coin2Arg) {
445
- // const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
446
- // const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
447
- // const poolinfo = poolInfo[poolName];
448
- // let someReceipt: any;
449
- // if (receipt.length == 0) {
450
- // [someReceipt] = txb.moveCall({
451
- // target: `0x1::option::none`,
452
- // typeArguments: [poolinfo.receiptType],
453
- // arguments: [],
454
- // });
455
- // } else {
456
- // [someReceipt] = txb.moveCall({
457
- // target: `0x1::option::some`,
458
- // typeArguments: [receipt[0].content.type],
459
- // arguments: [txb.object(receipt[0].objectId)],
460
- // });
461
- // }
462
- // txb.moveCall({
463
- // target: `${poolinfo.packageId}::alphafi_cetus_sui_pool::user_deposit`,
464
- // typeArguments: [coinsList[pool1].type, coinsList[pool2].type],
465
- // arguments: [
466
- // txb.object(getConf().ALPHA_2_VERSION),
467
- // txb.object(getConf().VERSION),
468
- // someReceipt,
469
- // txb.object(poolinfo.poolId),
470
- // depositCoinA,
471
- // depositCoinB,
472
- // txb.object(getConf().ALPHA_DISTRIBUTOR),
473
- // txb.object(poolinfo.investorId),
474
- // txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
475
- // txb.object(getConf().CETUS_REWARDER_GLOBAL_VAULT_ID),
476
- // txb.object(cetusPoolMap[poolName]),
477
- // txb.object(getConf().CLOCK_PACKAGE_ID),
478
- // ],
479
- // });
480
- // txb.transferObjects([coin1Arg, coin2Arg], address);
481
- // } else {
482
- // throw new Error(`No ${pool1} or ${pool2} Coins`);
483
- // }
484
- // return txb;
485
- // };
486
- // const depositBluefinSuiFirstTxb = async (
487
- // amountA: string,
488
- // amountB: string,
489
- // poolName: PoolName,
490
- // options: { address: string },
491
- // transaction: Transaction | undefined = undefined,
492
- // coin1Arg: TransactionObjectArgument | undefined,
493
- // coin2Arg: TransactionObjectArgument | undefined,
494
- // ): Promise<Transaction> => {
495
- // const address = options.address;
496
- // let txb;
497
- // if (transaction) txb = transaction;
498
- // else txb = new Transaction();
499
- // poolName = poolName.toUpperCase() as PoolName;
500
- // const pool1 = doubleAssetPoolCoinMap[poolName].coin1;
501
- // const pool2 = doubleAssetPoolCoinMap[poolName].coin2;
502
- // const receipt: Receipt[] = await getReceipts(poolName, address, true);
503
- // amountA = (Number(amountA) * 0.999).toString();
504
- // amountB = (Number(amountB) * 0.999).toString();
505
- // let amounts = await getAmounts(poolName, true, amountA);
506
- // if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
507
- // amounts = await getAmounts(poolName, false, amountB);
508
- // }
509
- // if (amounts && coin1Arg && coin2Arg) {
510
- // const [depositCoinA] = txb.splitCoins(txb.gas, [amounts[0]]);
511
- // const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
512
- // const poolinfo = poolInfo[poolName];
513
- // let someReceipt: any;
514
- // if (receipt.length == 0) {
515
- // [someReceipt] = txb.moveCall({
516
- // target: `0x1::option::none`,
517
- // typeArguments: [poolinfo.receiptType],
518
- // arguments: [],
519
- // });
520
- // } else {
521
- // [someReceipt] = txb.moveCall({
522
- // target: `0x1::option::some`,
523
- // typeArguments: [receipt[0].content.type],
524
- // arguments: [txb.object(receipt[0].objectId)],
525
- // });
526
- // }
527
- // txb.moveCall({
528
- // target: `${poolinfo.packageId}::alphafi_bluefin_sui_first_pool::user_deposit`,
529
- // typeArguments: [
530
- // coinsList[pool1].type,
531
- // coinsList[pool2].type,
532
- // coinsList["DEEP"].type,
533
- // coinsList["SUI"].type,
534
- // ],
535
- // arguments: [
536
- // txb.object(getConf().ALPHA_4_VERSION),
537
- // txb.object(getConf().VERSION),
538
- // someReceipt,
539
- // txb.object(poolinfo.poolId),
540
- // depositCoinA,
541
- // depositCoinB,
542
- // txb.object(getConf().ALPHA_DISTRIBUTOR),
543
- // txb.object(poolinfo.investorId),
544
- // txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
545
- // txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
546
- // txb.object(getConf().BLUEFIN_SUI_USDC_POOL),
547
- // txb.object(getConf().BLUEFIN_DEEP_SUI_POOL),
548
- // txb.object(cetusPoolMap["USDC-SUI"]),
549
- // txb.object(getConf().CLOCK_PACKAGE_ID),
550
- // ],
551
- // });
552
- // txb.transferObjects([coin1Arg, coin2Arg], address);
553
- // } else {
554
- // throw new Error(`No ${pool1} or ${pool2} Coins`);
555
- // }
556
- // return txb;
557
- // };
558
- // const depositBluefinType1Txb = async (
559
- // amountA: string,
560
- // amountB: string,
561
- // poolName: PoolName,
562
- // options: { address: string },
563
- // transaction: Transaction | undefined = undefined,
564
- // coin1Arg: TransactionObjectArgument | undefined,
565
- // coin2Arg: TransactionObjectArgument | undefined,
566
- // ): Promise<Transaction> => {
567
- // const address = options.address;
568
- // let txb;
569
- // if (transaction) txb = transaction;
570
- // else txb = new Transaction();
571
- // poolName = poolName.toUpperCase() as PoolName;
572
- // const pool1 = doubleAssetPoolCoinMap[poolName].coin1;
573
- // const pool2 = doubleAssetPoolCoinMap[poolName].coin2;
574
- // const receipt: Receipt[] = await getReceipts(poolName, address, true);
575
- // amountA = (Number(amountA) * 0.999).toString();
576
- // amountB = (Number(amountB) * 0.999).toString();
577
- // let amounts = await getAmounts(poolName, true, amountA);
578
- // if (amounts === undefined || amounts[0] > amountA || amounts[1] > amountB) {
579
- // amounts = await getAmounts(poolName, false, amountB);
580
- // }
581
- // if (amounts && coin1Arg && coin2Arg) {
582
- // const [depositCoinA] = txb.splitCoins(coin1Arg, [amounts[0]]);
583
- // const [depositCoinB] = txb.splitCoins(coin2Arg, [amounts[1]]);
584
- // const poolinfo = poolInfo[poolName];
585
- // let someReceipt: any;
586
- // if (receipt.length == 0) {
587
- // [someReceipt] = txb.moveCall({
588
- // target: `0x1::option::none`,
589
- // typeArguments: [poolinfo.receiptType],
590
- // arguments: [],
591
- // });
592
- // } else {
593
- // [someReceipt] = txb.moveCall({
594
- // target: `0x1::option::some`,
595
- // typeArguments: [receipt[0].content.type],
596
- // arguments: [txb.object(receipt[0].objectId)],
597
- // });
598
- // }
599
- // txb.moveCall({
600
- // target: `${poolinfo.packageId}::alphafi_bluefin_type_1_pool::user_deposit`,
601
- // typeArguments: [
602
- // coinsList[pool1].type,
603
- // coinsList[pool2].type,
604
- // coinsList["DEEP"].type,
605
- // coinsList["SUI"].type,
606
- // ],
607
- // arguments: [
608
- // txb.object(getConf().ALPHA_4_VERSION),
609
- // txb.object(getConf().VERSION),
610
- // someReceipt,
611
- // txb.object(poolinfo.poolId),
612
- // depositCoinA,
613
- // depositCoinB,
614
- // txb.object(getConf().ALPHA_DISTRIBUTOR),
615
- // txb.object(poolinfo.investorId),
616
- // txb.object(getConf().BLUEFIN_GLOBAL_CONFIG),
617
- // txb.object(getConf().CETUS_GLOBAL_CONFIG_ID),
618
- // txb.object(getConf().BLUEFIN_USDT_USDC_POOL),
619
- // txb.object(getConf().BLUEFIN_DEEP_SUI_POOL),
620
- // txb.object(cetusPoolMap["USDC-USDT"]),
621
- // txb.object(cetusPoolMap["USDC-SUI"]),
622
- // txb.object(getConf().CLOCK_PACKAGE_ID),
623
- // ],
624
- // });
625
- // txb.transferObjects([coin1Arg, coin2Arg], address);
626
- // } else {
627
- // throw new Error(`No ${pool1} or ${pool2} Coins`);
628
- // }
629
- // return txb;
630
- // };
631
- // export async function getZapAmounts(
632
- // inputCoinAmount: number,
633
- // inputCoinName: CoinName,
634
- // poolName: PoolName,
635
- // slippage: number,
636
- // options: { address: string },
637
- // ignoreCache: boolean,
638
- // ): Promise<[string, string, string, string] | undefined> {
639
- // const address = options.address;
640
- // const coinTypeA = doubleAssetPoolCoinMap[poolName].coin1;
641
- // const coinTypeB = doubleAssetPoolCoinMap[poolName].coin2;
642
- // const swapObjectA = coinsList[coinTypeA];
643
- // const swapObjectB = coinsList[coinTypeB];
644
- // const inputObject = coinsList[inputCoinName];
645
- // const amounts = await getAmounts(poolName, true, "100000001");
646
- // if (amounts) {
647
- // const amount1 = Number(amounts[0]);
648
- // const amount2 = Number(amounts[1]);
649
- // const swapGateway = new SevenKGateway();
650
- // const swapOptions: SwapOptions = {
651
- // pair: {
652
- // coinA: swapObjectA,
653
- // coinB: swapObjectB,
654
- // },
655
- // senderAddress: address,
656
- // inAmount: new BN(amount1),
657
- // slippage: slippage,
658
- // };
659
- // const ratioQuote = await swapGateway.getQuote(swapOptions);
660
- // if (ratioQuote) {
661
- // const amount1InCoinType2 = Number(ratioQuote.returnAmountWithDecimal);
662
- // const totalAmount = amount2 + amount1InCoinType2;
663
- // const inputAmountToType1 = Math.floor(
664
- // (inputCoinAmount * amount1InCoinType2) / totalAmount,
665
- // );
666
- // const inputAmountToType2 = Math.floor(
667
- // (inputCoinAmount * amount2) / totalAmount,
668
- // );
669
- // let amountA, amountB;
670
- // const swapOptionsI2A = {
671
- // pair: {
672
- // coinA: inputObject,
673
- // coinB: swapObjectA,
674
- // },
675
- // senderAddress: address,
676
- // inAmount: new BN(inputAmountToType1),
677
- // slippage: slippage,
678
- // };
679
- // const swapOptionsI2B = {
680
- // pair: {
681
- // coinA: inputObject,
682
- // coinB: swapObjectB,
683
- // },
684
- // senderAddress: address,
685
- // inAmount: new BN(inputAmountToType2),
686
- // slippage: slippage,
687
- // };
688
- // if (inputCoinName === coinTypeA) {
689
- // const quoteResponse = await swapGateway.getQuote(swapOptionsI2B);
690
- // if (quoteResponse) {
691
- // amountB = quoteResponse.returnAmountWithDecimal;
692
- // }
693
- // amountA = inputAmountToType1.toString();
694
- // } else if (inputCoinName === coinTypeB) {
695
- // const quoteResponse = await swapGateway.getQuote(swapOptionsI2A);
696
- // if (quoteResponse) {
697
- // amountA = quoteResponse.returnAmountWithDecimal;
698
- // }
699
- // amountB = inputAmountToType2.toString();
700
- // } else {
701
- // let quoteResponse = await swapGateway.getQuote(swapOptionsI2A);
702
- // if (quoteResponse) {
703
- // amountA = quoteResponse.returnAmountWithDecimal;
704
- // }
705
- // quoteResponse = await swapGateway.getQuote(swapOptionsI2B);
706
- // if (quoteResponse) {
707
- // amountB = quoteResponse.returnAmountWithDecimal;
708
- // }
709
- // }
710
- // if (amountA && amountB) {
711
- // const [coin1Price, coin2Price] = await getLatestPrices(
712
- // [
713
- // `${swapObjectA.name}/USD` as PythPriceIdPair,
714
- // `${swapObjectB.name}/USD` as PythPriceIdPair,
715
- // ],
716
- // ignoreCache,
717
- // );
718
- // const coin1InUSD = Number(amountA) * Number(coin1Price);
719
- // const coin2InUSD = Number(amountB) * Number(coin2Price);
720
- // return [
721
- // amountA.toString(),
722
- // coin1InUSD.toString(),
723
- // amountB.toString(),
724
- // coin2InUSD.toString(),
725
- // ];
726
- // }
727
- // }
728
- // }
1112
+ // const txb = new Transaction();
1113
+ // const pool1 = doubleAssetPoolCoinMap[poolName].pool1;
1114
+ // const pool2 = doubleAssetPoolCoinMap[poolName].pool2;
729
1115
  // }
1116
+ //calculate ratio of both coins in terms of coin-type 2
1117
+ //convert outputAmount in coinType2
1118
+ //then calculate coinType1 and coinType2 based on previous ratio
1119
+ //convert those amounts to liquidity
1120
+ //pass that liquidity into cetusWithdrawTxb
1121
+ //swap the amount withdrawn to outputAmountType.
730
1122
  //# sourceMappingURL=zapDeposit.js.map