@alphafi/alphafi-sdk 0.0.38 → 0.0.39

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 (121) hide show
  1. package/dist/cjs/adminFunctions.d.ts +6 -0
  2. package/dist/cjs/adminFunctions.d.ts.map +1 -0
  3. package/dist/cjs/adminFunctions.js +52 -0
  4. package/dist/cjs/adminFunctions.js.map +1 -0
  5. package/dist/cjs/common/coins.d.ts.map +1 -1
  6. package/dist/cjs/common/coins.js +1 -2
  7. package/dist/cjs/common/coins.js.map +1 -1
  8. package/dist/cjs/common/constants.d.ts +48 -0
  9. package/dist/cjs/common/constants.d.ts.map +1 -1
  10. package/dist/cjs/common/constants.js +50 -15
  11. package/dist/cjs/common/constants.js.map +1 -1
  12. package/dist/cjs/common/maps.d.ts +2 -2
  13. package/dist/cjs/common/maps.d.ts.map +1 -1
  14. package/dist/cjs/common/maps.js +180 -42
  15. package/dist/cjs/common/maps.js.map +1 -1
  16. package/dist/cjs/common/types.d.ts +112 -3
  17. package/dist/cjs/common/types.d.ts.map +1 -1
  18. package/dist/cjs/common/types.js.map +1 -1
  19. package/dist/cjs/getTVL.d.ts +5 -0
  20. package/dist/cjs/getTVL.d.ts.map +1 -0
  21. package/dist/cjs/getTVL.js +109 -0
  22. package/dist/cjs/getTVL.js.map +1 -0
  23. package/dist/cjs/graphql/getMultiReceipts.d.ts.map +1 -1
  24. package/dist/cjs/graphql/getMultiReceipts.js +16 -57
  25. package/dist/cjs/graphql/getMultiReceipts.js.map +1 -1
  26. package/dist/cjs/index.d.ts +8 -0
  27. package/dist/cjs/index.d.ts.map +1 -1
  28. package/dist/cjs/index.js +14 -2
  29. package/dist/cjs/index.js.map +1 -1
  30. package/dist/cjs/sui-sdk/functions/fetchUserVaults.js.map +1 -1
  31. package/dist/cjs/sui-sdk/functions/getReceipts.d.ts +4 -2
  32. package/dist/cjs/sui-sdk/functions/getReceipts.d.ts.map +1 -1
  33. package/dist/cjs/sui-sdk/functions/getReceipts.js +49 -2
  34. package/dist/cjs/sui-sdk/functions/getReceipts.js.map +1 -1
  35. package/dist/cjs/transactions/alpha.d.ts +1 -1
  36. package/dist/cjs/transactions/alpha.d.ts.map +1 -1
  37. package/dist/cjs/transactions/alpha.js.map +1 -1
  38. package/dist/cjs/transactions/bluefin.d.ts +6 -0
  39. package/dist/cjs/transactions/bluefin.d.ts.map +1 -1
  40. package/dist/cjs/transactions/bluefin.js +349 -1
  41. package/dist/cjs/transactions/bluefin.js.map +1 -1
  42. package/dist/cjs/transactions/bucket.d.ts +1 -1
  43. package/dist/cjs/transactions/bucket.js.map +1 -1
  44. package/dist/cjs/transactions/collect_rewards.d.ts.map +1 -1
  45. package/dist/cjs/transactions/collect_rewards.js +23 -2
  46. package/dist/cjs/transactions/collect_rewards.js.map +1 -1
  47. package/dist/cjs/transactions/deposit.d.ts.map +1 -1
  48. package/dist/cjs/transactions/deposit.js +15 -5
  49. package/dist/cjs/transactions/deposit.js.map +1 -1
  50. package/dist/cjs/transactions/navi-looping.d.ts +33 -0
  51. package/dist/cjs/transactions/navi-looping.d.ts.map +1 -0
  52. package/dist/cjs/transactions/navi-looping.js +597 -0
  53. package/dist/cjs/transactions/navi-looping.js.map +1 -0
  54. package/dist/cjs/transactions/navi.d.ts +1 -1
  55. package/dist/cjs/transactions/navi.d.ts.map +1 -1
  56. package/dist/cjs/transactions/navi.js +128 -0
  57. package/dist/cjs/transactions/navi.js.map +1 -1
  58. package/dist/cjs/transactions/withdraw.d.ts.map +1 -1
  59. package/dist/cjs/transactions/withdraw.js +12 -2
  60. package/dist/cjs/transactions/withdraw.js.map +1 -1
  61. package/dist/esm/adminFunctions.d.ts +6 -0
  62. package/dist/esm/adminFunctions.d.ts.map +1 -0
  63. package/dist/esm/adminFunctions.js +45 -0
  64. package/dist/esm/adminFunctions.js.map +1 -0
  65. package/dist/esm/common/coins.d.ts.map +1 -1
  66. package/dist/esm/common/coins.js +1 -2
  67. package/dist/esm/common/coins.js.map +1 -1
  68. package/dist/esm/common/constants.d.ts +48 -0
  69. package/dist/esm/common/constants.d.ts.map +1 -1
  70. package/dist/esm/common/constants.js +50 -15
  71. package/dist/esm/common/constants.js.map +1 -1
  72. package/dist/esm/common/maps.d.ts +2 -2
  73. package/dist/esm/common/maps.d.ts.map +1 -1
  74. package/dist/esm/common/maps.js +180 -42
  75. package/dist/esm/common/maps.js.map +1 -1
  76. package/dist/esm/common/types.d.ts +112 -3
  77. package/dist/esm/common/types.d.ts.map +1 -1
  78. package/dist/esm/common/types.js.map +1 -1
  79. package/dist/esm/getTVL.d.ts +5 -0
  80. package/dist/esm/getTVL.d.ts.map +1 -0
  81. package/dist/esm/getTVL.js +103 -0
  82. package/dist/esm/getTVL.js.map +1 -0
  83. package/dist/esm/graphql/getMultiReceipts.d.ts.map +1 -1
  84. package/dist/esm/graphql/getMultiReceipts.js +16 -57
  85. package/dist/esm/graphql/getMultiReceipts.js.map +1 -1
  86. package/dist/esm/index.d.ts +8 -0
  87. package/dist/esm/index.d.ts.map +1 -1
  88. package/dist/esm/index.js +10 -0
  89. package/dist/esm/index.js.map +1 -1
  90. package/dist/esm/sui-sdk/functions/fetchUserVaults.js.map +1 -1
  91. package/dist/esm/sui-sdk/functions/getReceipts.d.ts +4 -2
  92. package/dist/esm/sui-sdk/functions/getReceipts.d.ts.map +1 -1
  93. package/dist/esm/sui-sdk/functions/getReceipts.js +49 -3
  94. package/dist/esm/sui-sdk/functions/getReceipts.js.map +1 -1
  95. package/dist/esm/transactions/alpha.d.ts +1 -1
  96. package/dist/esm/transactions/alpha.d.ts.map +1 -1
  97. package/dist/esm/transactions/alpha.js.map +1 -1
  98. package/dist/esm/transactions/bluefin.d.ts +6 -0
  99. package/dist/esm/transactions/bluefin.d.ts.map +1 -1
  100. package/dist/esm/transactions/bluefin.js +346 -0
  101. package/dist/esm/transactions/bluefin.js.map +1 -1
  102. package/dist/esm/transactions/bucket.d.ts +1 -1
  103. package/dist/esm/transactions/bucket.js.map +1 -1
  104. package/dist/esm/transactions/collect_rewards.d.ts.map +1 -1
  105. package/dist/esm/transactions/collect_rewards.js +23 -2
  106. package/dist/esm/transactions/collect_rewards.js.map +1 -1
  107. package/dist/esm/transactions/deposit.d.ts.map +1 -1
  108. package/dist/esm/transactions/deposit.js +16 -6
  109. package/dist/esm/transactions/deposit.js.map +1 -1
  110. package/dist/esm/transactions/navi-looping.d.ts +33 -0
  111. package/dist/esm/transactions/navi-looping.d.ts.map +1 -0
  112. package/dist/esm/transactions/navi-looping.js +585 -0
  113. package/dist/esm/transactions/navi-looping.js.map +1 -0
  114. package/dist/esm/transactions/navi.d.ts +1 -1
  115. package/dist/esm/transactions/navi.d.ts.map +1 -1
  116. package/dist/esm/transactions/navi.js +128 -0
  117. package/dist/esm/transactions/navi.js.map +1 -1
  118. package/dist/esm/transactions/withdraw.d.ts.map +1 -1
  119. package/dist/esm/transactions/withdraw.js +13 -3
  120. package/dist/esm/transactions/withdraw.js.map +1 -1
  121. package/package.json +1 -1
@@ -0,0 +1,585 @@
1
+ import { Transaction } from "@mysten/sui/transactions";
2
+ import { getConf } from "../common/constants.js";
3
+ import { getSuiClient } from "../sui-sdk/client.js";
4
+ import { cetusPoolMap, poolInfo, singleAssetPoolCoinMap, } from "../common/maps.js";
5
+ import { coinsList } from "../common/coins.js";
6
+ import { getReceipts } from "../sui-sdk/functions/getReceipts.js";
7
+ export async function loopingDeposit(poolName, amount, options) {
8
+ let txb = new Transaction();
9
+ if (poolName === "NAVI-LOOP-HASUI-SUI") {
10
+ txb = await naviHasuiSuiLoopDepositTx(amount, options);
11
+ }
12
+ else if (poolName === "NAVI-LOOP-SUI-VSUI") {
13
+ txb = await naviSuiVsuiLoopDepositTx(amount, options);
14
+ }
15
+ else if (poolName === "NAVI-LOOP-USDC-USDT") {
16
+ txb = await naviUsdcUsdtLoopDepositTx(amount, options);
17
+ }
18
+ else if (poolName === "NAVI-LOOP-USDT-USDC") {
19
+ txb = await naviUsdtUsdcLoopDepositTx(amount, options);
20
+ }
21
+ return txb;
22
+ }
23
+ export async function loopingWithdraw(poolName, xTokens, options) {
24
+ let txb = new Transaction();
25
+ if (poolName === "NAVI-LOOP-HASUI-SUI") {
26
+ txb = await naviHasuiSuiLoopWithdrawTx(xTokens, options);
27
+ }
28
+ else if (poolName === "NAVI-LOOP-SUI-VSUI") {
29
+ txb = await naviSuiVsuiLoopWithdrawTx(xTokens, options);
30
+ }
31
+ else if (poolName === "NAVI-LOOP-USDC-USDT") {
32
+ txb = await naviUsdcUsdtLoopWithdrawTx(xTokens, options);
33
+ }
34
+ else if (poolName === "NAVI-LOOP-USDT-USDC") {
35
+ txb = await naviUsdtUsdcLoopWithdrawTx(xTokens, options);
36
+ }
37
+ return txb;
38
+ }
39
+ export async function naviHasuiSuiLoopDepositTx(amount, options) {
40
+ const C = await getConf();
41
+ const suiClient = getSuiClient();
42
+ const address = options.address;
43
+ const txb = new Transaction();
44
+ const poolData = poolInfo["NAVI-LOOP-HASUI-SUI"];
45
+ const receipt = await getReceipts("NAVI-LOOP-HASUI-SUI", address, true);
46
+ let coins = [];
47
+ let currentCursor = null;
48
+ do {
49
+ const response = await suiClient.getCoins({
50
+ owner: address,
51
+ coinType: coinsList[singleAssetPoolCoinMap["NAVI-LOOP-HASUI-SUI"].coin].type,
52
+ cursor: currentCursor,
53
+ });
54
+ coins = coins.concat(response.data);
55
+ // Check if there's a next page
56
+ if (response.hasNextPage && response.nextCursor) {
57
+ currentCursor = response.nextCursor;
58
+ }
59
+ else {
60
+ // No more pages available
61
+ // console.log("No more receipts available.");
62
+ break;
63
+ }
64
+ } while (true);
65
+ if (coins.length >= 1) {
66
+ const [coin] = txb.splitCoins(txb.object(coins[0].coinObjectId), [0]);
67
+ txb.mergeCoins(coin, coins.map((c) => c.coinObjectId));
68
+ const [depositCoin] = txb.splitCoins(coin, [amount]);
69
+ let someReceipt;
70
+ if (receipt.length == 0) {
71
+ [someReceipt] = txb.moveCall({
72
+ target: `0x1::option::none`,
73
+ typeArguments: [poolData.receiptType],
74
+ arguments: [],
75
+ });
76
+ }
77
+ else {
78
+ [someReceipt] = txb.moveCall({
79
+ target: `0x1::option::some`,
80
+ typeArguments: [receipt[0].content.type],
81
+ arguments: [txb.object(receipt[0].objectId)],
82
+ });
83
+ }
84
+ txb.moveCall({
85
+ target: `${poolData.packageId}::alphafi_navi_hasui_sui_pool::user_deposit`, // change package id for testing
86
+ typeArguments: [C.NAVX_COIN_TYPE],
87
+ arguments: [
88
+ txb.object(C.ALPHA_2_VERSION), // change version object id for testing
89
+ txb.object(C.VERSION),
90
+ someReceipt,
91
+ txb.object(poolData.poolId),
92
+ depositCoin,
93
+ txb.object(poolData.investorId),
94
+ txb.object(C.ALPHA_DISTRIBUTOR),
95
+ txb.object(C.PRICE_ORACLE),
96
+ txb.object(C.NAVI_STORAGE),
97
+ txb.object(C.NAVI_HASUI_POOL),
98
+ txb.object(C.NAVI_SUI_POOL),
99
+ txb.object(C.NAVI_INCENTIVE_V1),
100
+ txb.object(C.NAVI_INCENTIVE_V2),
101
+ txb.object(C.NAVI_NAVX_FUNDS_POOL),
102
+ txb.object(C.NAVI_VSUI_FUNDS_POOL),
103
+ txb.object(C.CETUS_GLOBAL_CONFIG_ID),
104
+ txb.object(cetusPoolMap["NAVX-SUI"]),
105
+ txb.object(cetusPoolMap["VSUI-SUI"]),
106
+ txb.object(cetusPoolMap["HASUI-SUI"]),
107
+ txb.object(C.HAEDEL_STAKING),
108
+ txb.object(C.SUI_SYSTEM_STATE),
109
+ txb.object(C.CLOCK_PACKAGE_ID),
110
+ ],
111
+ });
112
+ txb.transferObjects([coin], address);
113
+ }
114
+ else {
115
+ throw new Error("No coin");
116
+ }
117
+ return txb;
118
+ }
119
+ export async function naviSuiVsuiLoopDepositTx(amount, options) {
120
+ const C = await getConf();
121
+ const address = options.address;
122
+ const txb = new Transaction();
123
+ const poolData = poolInfo["NAVI-LOOP-SUI-VSUI"];
124
+ const receipt = await getReceipts("NAVI-LOOP-SUI-VSUI", address, true);
125
+ let someReceipt;
126
+ if (receipt.length == 0) {
127
+ [someReceipt] = txb.moveCall({
128
+ target: `0x1::option::none`,
129
+ typeArguments: [poolData.receiptType],
130
+ arguments: [],
131
+ });
132
+ }
133
+ else {
134
+ [someReceipt] = txb.moveCall({
135
+ target: `0x1::option::some`,
136
+ typeArguments: [receipt[0].content.type],
137
+ arguments: [txb.object(receipt[0].objectId)],
138
+ });
139
+ }
140
+ const [depositCoin] = txb.splitCoins(txb.gas, [amount]);
141
+ txb.moveCall({
142
+ target: `${poolData.packageId}::alphafi_navi_sui_vsui_pool::user_deposit`,
143
+ typeArguments: [coinsList["NAVX"].type],
144
+ arguments: [
145
+ txb.object(C.ALPHA_2_VERSION),
146
+ txb.object(C.VERSION),
147
+ someReceipt,
148
+ txb.object(poolData.poolId),
149
+ depositCoin,
150
+ txb.object(poolData.investorId),
151
+ txb.object(C.ALPHA_DISTRIBUTOR),
152
+ txb.object(C.PRICE_ORACLE),
153
+ txb.object(C.NAVI_STORAGE),
154
+ txb.object(C.NAVI_VSUI_POOL),
155
+ txb.object(C.NAVI_SUI_POOL),
156
+ txb.object(C.NAVI_INCENTIVE_V1),
157
+ txb.object(C.NAVI_INCENTIVE_V2),
158
+ txb.object(C.NAVI_NAVX_FUNDS_POOL),
159
+ txb.object(C.NAVI_VSUI_FUNDS_POOL),
160
+ txb.object(C.CETUS_GLOBAL_CONFIG_ID),
161
+ txb.object(cetusPoolMap["NAVX-SUI"]),
162
+ txb.object(cetusPoolMap["VSUI-SUI"]),
163
+ txb.object(C.VOLO_NATIVE_POOL),
164
+ txb.object(C.VOLO_METADATA),
165
+ txb.object(C.SUI_SYSTEM_STATE),
166
+ txb.object(C.KRIYA_VSUI_SUI_POOL),
167
+ txb.object(C.KRIYA_VERSION),
168
+ txb.object(C.CLOCK_PACKAGE_ID),
169
+ ],
170
+ });
171
+ return txb;
172
+ }
173
+ export async function naviUsdcUsdtLoopDepositTx(amount, options) {
174
+ const C = await getConf();
175
+ const suiClient = getSuiClient();
176
+ const address = options.address;
177
+ const txb = new Transaction();
178
+ const poolData = poolInfo["NAVI-LOOP-USDC-USDT"];
179
+ const receipt = await getReceipts("NAVI-LOOP-USDC-USDT", address, true);
180
+ let coins = [];
181
+ let currentCursor = null;
182
+ do {
183
+ const response = await suiClient.getCoins({
184
+ owner: address,
185
+ coinType: coinsList[singleAssetPoolCoinMap["NAVI-LOOP-USDC-USDT"].coin].type,
186
+ cursor: currentCursor,
187
+ });
188
+ coins = coins.concat(response.data);
189
+ // Check if there's a next page
190
+ if (response.hasNextPage && response.nextCursor) {
191
+ currentCursor = response.nextCursor;
192
+ }
193
+ else {
194
+ // No more pages available
195
+ // console.log("No more receipts available.");
196
+ break;
197
+ }
198
+ } while (true);
199
+ if (coins.length >= 1) {
200
+ const [coin] = txb.splitCoins(txb.object(coins[0].coinObjectId), [0]);
201
+ txb.mergeCoins(coin, coins.map((c) => c.coinObjectId));
202
+ const [depositCoin] = txb.splitCoins(coin, [amount]);
203
+ let someReceipt;
204
+ if (receipt.length == 0) {
205
+ [someReceipt] = txb.moveCall({
206
+ target: `0x1::option::none`,
207
+ typeArguments: [poolData.receiptType],
208
+ arguments: [],
209
+ });
210
+ }
211
+ else {
212
+ [someReceipt] = txb.moveCall({
213
+ target: `0x1::option::some`,
214
+ typeArguments: [receipt[0].content.type],
215
+ arguments: [txb.object(receipt[0].objectId)],
216
+ });
217
+ }
218
+ txb.moveCall({
219
+ target: `${poolData.packageId}::alphafi_navi_native_usdc_usdt_pool::user_deposit`,
220
+ arguments: [
221
+ txb.object(C.ALPHA_2_VERSION),
222
+ txb.object(C.VERSION),
223
+ someReceipt,
224
+ txb.object(poolData.poolId),
225
+ depositCoin,
226
+ txb.object(poolData.investorId),
227
+ txb.object(C.ALPHA_DISTRIBUTOR),
228
+ txb.object(C.PRICE_ORACLE),
229
+ txb.object(C.NAVI_STORAGE),
230
+ txb.object(C.NAVI_USDC_POOL),
231
+ txb.object(C.NAVI_USDT_POOL),
232
+ txb.object(C.NAVI_INCENTIVE_V1),
233
+ txb.object(C.NAVI_INCENTIVE_V2),
234
+ txb.object(C.NAVI_VSUI_FUNDS_POOL),
235
+ txb.object(C.NAVI_NAVX_FUNDS_POOL),
236
+ txb.object(C.CETUS_GLOBAL_CONFIG_ID),
237
+ txb.object(cetusPoolMap["VSUI-SUI"]),
238
+ txb.object(cetusPoolMap["NAVX-SUI"]),
239
+ txb.object(cetusPoolMap["USDC-SUI"]),
240
+ txb.object(cetusPoolMap["USDC-USDT"]),
241
+ txb.object(C.CLOCK_PACKAGE_ID),
242
+ ],
243
+ });
244
+ txb.transferObjects([coin], address);
245
+ }
246
+ else {
247
+ throw new Error("No coin");
248
+ }
249
+ return txb;
250
+ }
251
+ export async function naviUsdtUsdcLoopDepositTx(amount, options) {
252
+ const C = await getConf();
253
+ const suiClient = getSuiClient();
254
+ const address = options.address;
255
+ const txb = new Transaction();
256
+ const poolData = poolInfo["NAVI-LOOP-USDT-USDC"];
257
+ const receipt = await getReceipts("NAVI-LOOP-USDT-USDC", address, true);
258
+ let coins = [];
259
+ let currentCursor = null;
260
+ do {
261
+ const response = await suiClient.getCoins({
262
+ owner: address,
263
+ coinType: coinsList[singleAssetPoolCoinMap["NAVI-LOOP-USDT-USDC"].coin].type,
264
+ cursor: currentCursor,
265
+ });
266
+ coins = coins.concat(response.data);
267
+ // Check if there's a next page
268
+ if (response.hasNextPage && response.nextCursor) {
269
+ currentCursor = response.nextCursor;
270
+ }
271
+ else {
272
+ // No more pages available
273
+ // console.log("No more receipts available.");
274
+ break;
275
+ }
276
+ } while (true);
277
+ if (coins.length >= 1) {
278
+ const [coin] = txb.splitCoins(txb.object(coins[0].coinObjectId), [0]);
279
+ txb.mergeCoins(coin, coins.map((c) => c.coinObjectId));
280
+ const [depositCoin] = txb.splitCoins(coin, [amount]);
281
+ let someReceipt;
282
+ if (receipt.length == 0) {
283
+ [someReceipt] = txb.moveCall({
284
+ target: `0x1::option::none`,
285
+ typeArguments: [poolData.receiptType],
286
+ arguments: [],
287
+ });
288
+ }
289
+ else {
290
+ [someReceipt] = txb.moveCall({
291
+ target: `0x1::option::some`,
292
+ typeArguments: [receipt[0].content.type],
293
+ arguments: [txb.object(receipt[0].objectId)],
294
+ });
295
+ }
296
+ txb.moveCall({
297
+ target: `${poolData.packageId}::alphafi_navi_usdt_usdc_pool::user_deposit`,
298
+ typeArguments: [coinsList["NAVX"].type],
299
+ arguments: [
300
+ txb.object(C.ALPHA_5_VERSION),
301
+ txb.object(C.VERSION),
302
+ someReceipt,
303
+ txb.object(poolData.poolId),
304
+ depositCoin,
305
+ txb.object(poolData.investorId),
306
+ txb.object(C.ALPHA_DISTRIBUTOR),
307
+ txb.object(C.PRICE_ORACLE),
308
+ txb.object(C.NAVI_STORAGE),
309
+ txb.object(C.NAVI_USDT_POOL),
310
+ txb.object(C.NAVI_USDC_POOL),
311
+ txb.object(C.NAVI_INCENTIVE_V1),
312
+ txb.object(C.NAVI_INCENTIVE_V2),
313
+ txb.object(C.NAVI_VSUI_FUNDS_POOL),
314
+ txb.object(C.NAVI_NAVX_FUNDS_POOL),
315
+ txb.object(C.CETUS_GLOBAL_CONFIG_ID),
316
+ txb.object(cetusPoolMap["VSUI-SUI"]),
317
+ txb.object(cetusPoolMap["USDC-USDT"]),
318
+ txb.object(cetusPoolMap["USDC-SUI"]),
319
+ txb.object(cetusPoolMap["NAVX-SUI"]),
320
+ txb.object(C.CLOCK_PACKAGE_ID),
321
+ ],
322
+ });
323
+ txb.transferObjects([coin], address);
324
+ }
325
+ else {
326
+ throw new Error("No coin");
327
+ }
328
+ return txb;
329
+ }
330
+ export async function naviHasuiSuiLoopWithdrawTx(xTokens, options) {
331
+ const C = await getConf();
332
+ const address = options.address;
333
+ const txb = new Transaction();
334
+ const poolData = poolInfo["NAVI-LOOP-HASUI-SUI"];
335
+ const receipt = await getReceipts("NAVI-LOOP-HASUI-SUI", address, true);
336
+ const alphaReceipt = await getReceipts("ALPHA", address, true);
337
+ if (receipt.length > 0) {
338
+ let alpha_receipt;
339
+ if (alphaReceipt.length == 0) {
340
+ [alpha_receipt] = txb.moveCall({
341
+ target: `0x1::option::none`,
342
+ typeArguments: [C.ALPHA_POOL_RECEIPT],
343
+ arguments: [],
344
+ });
345
+ }
346
+ else {
347
+ [alpha_receipt] = txb.moveCall({
348
+ target: `0x1::option::some`,
349
+ typeArguments: [alphaReceipt[0].content.type],
350
+ arguments: [txb.object(alphaReceipt[0].objectId)],
351
+ });
352
+ }
353
+ const [hasuiCoin] = txb.moveCall({
354
+ target: `${poolData.packageId}::alphafi_navi_hasui_sui_pool::user_withdraw`, // change package id for testing
355
+ typeArguments: [C.NAVX_COIN_TYPE],
356
+ arguments: [
357
+ txb.object(C.ALPHA_2_VERSION), // change version object id for testing
358
+ txb.object(C.VERSION),
359
+ txb.object(receipt[0].objectId),
360
+ alpha_receipt,
361
+ txb.object(C.ALPHA_POOL),
362
+ txb.object(poolData.poolId),
363
+ txb.pure.u64(xTokens),
364
+ txb.object(poolData.investorId),
365
+ txb.object(C.ALPHA_DISTRIBUTOR),
366
+ txb.object(C.PRICE_ORACLE),
367
+ txb.object(C.NAVI_STORAGE),
368
+ txb.object(C.NAVI_HASUI_POOL),
369
+ txb.object(C.NAVI_SUI_POOL),
370
+ txb.object(C.NAVI_INCENTIVE_V1),
371
+ txb.object(C.NAVI_INCENTIVE_V2),
372
+ txb.object(C.NAVI_NAVX_FUNDS_POOL),
373
+ txb.object(C.NAVI_VSUI_FUNDS_POOL),
374
+ txb.object(C.CETUS_GLOBAL_CONFIG_ID),
375
+ txb.object(cetusPoolMap["NAVX-SUI"]),
376
+ txb.object(cetusPoolMap["VSUI-SUI"]),
377
+ txb.object(cetusPoolMap["HASUI-SUI"]),
378
+ txb.object(C.HAEDEL_STAKING),
379
+ txb.object(C.SUI_SYSTEM_STATE),
380
+ txb.object(C.CLOCK_PACKAGE_ID),
381
+ ],
382
+ });
383
+ txb.moveCall({
384
+ target: `0x2::transfer::public_transfer`,
385
+ typeArguments: [`0x2::coin::Coin<${coinsList["HASUI"].type}>`],
386
+ arguments: [hasuiCoin, txb.pure.address(address)],
387
+ });
388
+ }
389
+ else {
390
+ throw new Error(`No ${"NAVI-LOOP-HASUI-SUI"} Receipt`);
391
+ }
392
+ return txb;
393
+ }
394
+ export async function naviSuiVsuiLoopWithdrawTx(xTokens, options) {
395
+ const C = await getConf();
396
+ const address = options.address;
397
+ const txb = new Transaction();
398
+ const poolData = poolInfo["NAVI-LOOP-SUI-VSUI"];
399
+ const receipt = await getReceipts("NAVI-LOOP-SUI-VSUI", address, true);
400
+ const alphaReceipt = await getReceipts("ALPHA", address, true);
401
+ if (receipt.length > 0) {
402
+ let alpha_receipt;
403
+ if (alphaReceipt.length == 0) {
404
+ [alpha_receipt] = txb.moveCall({
405
+ target: `0x1::option::none`,
406
+ typeArguments: [C.ALPHA_POOL_RECEIPT],
407
+ arguments: [],
408
+ });
409
+ }
410
+ else {
411
+ [alpha_receipt] = txb.moveCall({
412
+ target: `0x1::option::some`,
413
+ typeArguments: [alphaReceipt[0].content.type],
414
+ arguments: [txb.object(alphaReceipt[0].objectId)],
415
+ });
416
+ }
417
+ const [vsui_coin] = txb.moveCall({
418
+ target: `${poolData.packageId}::alphafi_navi_sui_vsui_pool::user_withdraw`,
419
+ typeArguments: [coinsList["NAVX"].type],
420
+ arguments: [
421
+ txb.object(C.ALPHA_2_VERSION),
422
+ txb.object(C.VERSION),
423
+ txb.object(receipt[0].objectId),
424
+ alpha_receipt,
425
+ txb.object(C.ALPHA_POOL),
426
+ txb.object(poolData.poolId),
427
+ txb.pure.u64(xTokens),
428
+ txb.object(poolData.investorId),
429
+ txb.object(C.ALPHA_DISTRIBUTOR),
430
+ txb.object(C.PRICE_ORACLE),
431
+ txb.object(C.NAVI_STORAGE),
432
+ txb.object(C.NAVI_VSUI_POOL),
433
+ txb.object(C.NAVI_SUI_POOL),
434
+ txb.object(C.NAVI_INCENTIVE_V1),
435
+ txb.object(C.NAVI_INCENTIVE_V2),
436
+ txb.object(C.NAVI_NAVX_FUNDS_POOL),
437
+ txb.object(C.NAVI_VSUI_FUNDS_POOL),
438
+ txb.object(C.CETUS_GLOBAL_CONFIG_ID),
439
+ txb.object(cetusPoolMap["NAVX-SUI"]),
440
+ txb.object(cetusPoolMap["VSUI-SUI"]),
441
+ txb.object(C.VOLO_NATIVE_POOL),
442
+ txb.object(C.VOLO_METADATA),
443
+ txb.object(C.SUI_SYSTEM_STATE),
444
+ txb.object(C.KRIYA_VSUI_SUI_POOL),
445
+ txb.object(C.KRIYA_VERSION),
446
+ txb.object(C.CLOCK_PACKAGE_ID),
447
+ ],
448
+ });
449
+ txb.moveCall({
450
+ target: `0x2::transfer::public_transfer`,
451
+ typeArguments: [`0x2::coin::Coin<${coinsList["VSUI"].type}>`],
452
+ arguments: [vsui_coin, txb.pure.address(address)],
453
+ });
454
+ }
455
+ else {
456
+ throw new Error(`No ${"NAVI-LOOP-SUI-VSUI"} Receipt`);
457
+ }
458
+ return txb;
459
+ }
460
+ export async function naviUsdcUsdtLoopWithdrawTx(xTokens, options) {
461
+ const C = await getConf();
462
+ const address = options.address;
463
+ const txb = new Transaction();
464
+ const poolData = poolInfo["NAVI-LOOP-USDC-USDT"];
465
+ const receipt = await getReceipts("NAVI-LOOP-USDC-USDT", address, true);
466
+ const alphaReceipt = await getReceipts("ALPHA", address, true);
467
+ if (receipt.length > 0) {
468
+ let alpha_receipt;
469
+ if (alphaReceipt.length == 0) {
470
+ [alpha_receipt] = txb.moveCall({
471
+ target: `0x1::option::none`,
472
+ typeArguments: [C.ALPHA_POOL_RECEIPT],
473
+ arguments: [],
474
+ });
475
+ }
476
+ else {
477
+ [alpha_receipt] = txb.moveCall({
478
+ target: `0x1::option::some`,
479
+ typeArguments: [alphaReceipt[0].content.type],
480
+ arguments: [txb.object(alphaReceipt[0].objectId)],
481
+ });
482
+ }
483
+ const [usdcCoin] = txb.moveCall({
484
+ target: `${poolData.packageId}::alphafi_navi_native_usdc_usdt_pool::user_withdraw`,
485
+ arguments: [
486
+ txb.object(C.ALPHA_2_VERSION),
487
+ txb.object(C.VERSION),
488
+ txb.object(receipt[0].objectId),
489
+ alpha_receipt,
490
+ txb.object(C.ALPHA_POOL),
491
+ txb.object(poolData.poolId),
492
+ txb.pure.u256(xTokens),
493
+ txb.object(poolData.investorId),
494
+ txb.object(C.ALPHA_DISTRIBUTOR),
495
+ txb.object(C.PRICE_ORACLE),
496
+ txb.object(C.NAVI_STORAGE),
497
+ txb.object(C.NAVI_USDC_POOL),
498
+ txb.object(C.NAVI_USDT_POOL),
499
+ txb.object(C.NAVI_INCENTIVE_V1),
500
+ txb.object(C.NAVI_INCENTIVE_V2),
501
+ txb.object(C.NAVI_VSUI_FUNDS_POOL),
502
+ txb.object(C.NAVI_NAVX_FUNDS_POOL),
503
+ txb.object(C.CETUS_GLOBAL_CONFIG_ID),
504
+ txb.object(cetusPoolMap["VSUI-SUI"]),
505
+ txb.object(cetusPoolMap["NAVX-SUI"]),
506
+ txb.object(cetusPoolMap["USDC-SUI"]),
507
+ txb.object(cetusPoolMap["USDC-USDT"]),
508
+ txb.object(C.CLOCK_PACKAGE_ID),
509
+ ],
510
+ });
511
+ txb.moveCall({
512
+ target: `0x2::transfer::public_transfer`,
513
+ typeArguments: [`0x2::coin::Coin<${coinsList["USDC"].type}>`],
514
+ arguments: [usdcCoin, txb.pure.address(address)],
515
+ });
516
+ }
517
+ else {
518
+ throw new Error(`No ${"NAVI-LOOP-USDC-USDT"} Receipt`);
519
+ }
520
+ return txb;
521
+ }
522
+ export async function naviUsdtUsdcLoopWithdrawTx(xTokens, options) {
523
+ const C = await getConf();
524
+ const address = options.address;
525
+ const txb = new Transaction();
526
+ const poolData = poolInfo["NAVI-LOOP-USDT-USDC"];
527
+ const receipt = await getReceipts("NAVI-LOOP-USDT-USDC", address, true);
528
+ const alphaReceipt = await getReceipts("ALPHA", address, true);
529
+ if (receipt.length > 0) {
530
+ let alpha_receipt;
531
+ if (alphaReceipt.length == 0) {
532
+ [alpha_receipt] = txb.moveCall({
533
+ target: `0x1::option::none`,
534
+ typeArguments: [C.ALPHA_POOL_RECEIPT],
535
+ arguments: [],
536
+ });
537
+ }
538
+ else {
539
+ [alpha_receipt] = txb.moveCall({
540
+ target: `0x1::option::some`,
541
+ typeArguments: [alphaReceipt[0].content.type],
542
+ arguments: [txb.object(alphaReceipt[0].objectId)],
543
+ });
544
+ }
545
+ const [usdtCoin] = txb.moveCall({
546
+ target: `${poolData.packageId}::alphafi_navi_usdt_usdc_pool::user_withdraw`,
547
+ typeArguments: [coinsList["NAVX"].type],
548
+ arguments: [
549
+ txb.object(C.ALPHA_5_VERSION),
550
+ txb.object(C.VERSION),
551
+ txb.object(receipt[0].objectId),
552
+ alpha_receipt,
553
+ txb.object(C.ALPHA_POOL),
554
+ txb.object(poolData.poolId),
555
+ txb.pure.u256(xTokens),
556
+ txb.object(poolData.investorId),
557
+ txb.object(C.ALPHA_DISTRIBUTOR),
558
+ txb.object(C.PRICE_ORACLE),
559
+ txb.object(C.NAVI_STORAGE),
560
+ txb.object(C.NAVI_USDT_POOL),
561
+ txb.object(C.NAVI_USDC_POOL),
562
+ txb.object(C.NAVI_INCENTIVE_V1),
563
+ txb.object(C.NAVI_INCENTIVE_V2),
564
+ txb.object(C.NAVI_VSUI_FUNDS_POOL),
565
+ txb.object(C.NAVI_NAVX_FUNDS_POOL),
566
+ txb.object(C.CETUS_GLOBAL_CONFIG_ID),
567
+ txb.object(cetusPoolMap["VSUI-SUI"]),
568
+ txb.object(cetusPoolMap["USDC-USDT"]),
569
+ txb.object(cetusPoolMap["USDC-SUI"]),
570
+ txb.object(cetusPoolMap["NAVX-SUI"]),
571
+ txb.object(C.CLOCK_PACKAGE_ID),
572
+ ],
573
+ });
574
+ txb.moveCall({
575
+ target: `0x2::transfer::public_transfer`,
576
+ typeArguments: [`0x2::coin::Coin<${coinsList["USDT"].type}>`],
577
+ arguments: [usdtCoin, txb.pure.address(address)],
578
+ });
579
+ }
580
+ else {
581
+ throw new Error(`No ${"NAVI-LOOP-USDT-USDC"} Receipt`);
582
+ }
583
+ return txb;
584
+ }
585
+ //# sourceMappingURL=navi-looping.js.map