@alphafi/alphafi-sdk 0.0.37 → 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 (158) hide show
  1. package/README.md +115 -12
  2. package/dist/cjs/adminFunctions.d.ts +6 -0
  3. package/dist/cjs/adminFunctions.d.ts.map +1 -0
  4. package/dist/cjs/adminFunctions.js +52 -0
  5. package/dist/cjs/adminFunctions.js.map +1 -0
  6. package/dist/cjs/common/coins.d.ts.map +1 -1
  7. package/dist/cjs/common/coins.js +1 -2
  8. package/dist/cjs/common/coins.js.map +1 -1
  9. package/dist/cjs/common/constants.d.ts +138 -0
  10. package/dist/cjs/common/constants.d.ts.map +1 -1
  11. package/dist/cjs/common/constants.js +106 -9
  12. package/dist/cjs/common/constants.js.map +1 -1
  13. package/dist/cjs/common/maps.d.ts +3 -1
  14. package/dist/cjs/common/maps.d.ts.map +1 -1
  15. package/dist/cjs/common/maps.js +233 -1
  16. package/dist/cjs/common/maps.js.map +1 -1
  17. package/dist/cjs/common/types.d.ts +112 -3
  18. package/dist/cjs/common/types.d.ts.map +1 -1
  19. package/dist/cjs/common/types.js.map +1 -1
  20. package/dist/cjs/getTVL.d.ts +5 -0
  21. package/dist/cjs/getTVL.d.ts.map +1 -0
  22. package/dist/cjs/getTVL.js +109 -0
  23. package/dist/cjs/getTVL.js.map +1 -0
  24. package/dist/cjs/graphql/getMultiReceipts.d.ts.map +1 -1
  25. package/dist/cjs/graphql/getMultiReceipts.js +16 -57
  26. package/dist/cjs/graphql/getMultiReceipts.js.map +1 -1
  27. package/dist/cjs/index.d.ts +12 -2
  28. package/dist/cjs/index.d.ts.map +1 -1
  29. package/dist/cjs/index.js +22 -4
  30. package/dist/cjs/index.js.map +1 -1
  31. package/dist/cjs/sui-sdk/events/fetchCheckRatioEvents.d.ts +3 -0
  32. package/dist/cjs/sui-sdk/events/fetchCheckRatioEvents.d.ts.map +1 -0
  33. package/dist/cjs/sui-sdk/events/fetchCheckRatioEvents.js +44 -0
  34. package/dist/cjs/sui-sdk/events/fetchCheckRatioEvents.js.map +1 -0
  35. package/dist/cjs/sui-sdk/events/fetchEvents.d.ts.map +1 -1
  36. package/dist/cjs/sui-sdk/events/fetchEvents.js +41 -0
  37. package/dist/cjs/sui-sdk/events/fetchEvents.js.map +1 -1
  38. package/dist/cjs/sui-sdk/events/types.d.ts +9 -1
  39. package/dist/cjs/sui-sdk/events/types.d.ts.map +1 -1
  40. package/dist/cjs/sui-sdk/events/types.js.map +1 -1
  41. package/dist/cjs/sui-sdk/functions/fetchUserVaults.js.map +1 -1
  42. package/dist/cjs/sui-sdk/functions/getReceipts.d.ts +8 -6
  43. package/dist/cjs/sui-sdk/functions/getReceipts.d.ts.map +1 -1
  44. package/dist/cjs/sui-sdk/functions/getReceipts.js +75 -30
  45. package/dist/cjs/sui-sdk/functions/getReceipts.js.map +1 -1
  46. package/dist/cjs/transactions/alpha.d.ts +2 -2
  47. package/dist/cjs/transactions/alpha.d.ts.map +1 -1
  48. package/dist/cjs/transactions/alpha.js +2 -2
  49. package/dist/cjs/transactions/alpha.js.map +1 -1
  50. package/dist/cjs/transactions/bluefin.d.ts +8 -2
  51. package/dist/cjs/transactions/bluefin.d.ts.map +1 -1
  52. package/dist/cjs/transactions/bluefin.js +355 -7
  53. package/dist/cjs/transactions/bluefin.js.map +1 -1
  54. package/dist/cjs/transactions/bucket.d.ts +2 -2
  55. package/dist/cjs/transactions/bucket.js +2 -2
  56. package/dist/cjs/transactions/bucket.js.map +1 -1
  57. package/dist/cjs/transactions/cetus.d.ts +4 -4
  58. package/dist/cjs/transactions/cetus.d.ts.map +1 -1
  59. package/dist/cjs/transactions/cetus.js +27 -29
  60. package/dist/cjs/transactions/cetus.js.map +1 -1
  61. package/dist/cjs/transactions/collect_rewards.d.ts.map +1 -1
  62. package/dist/cjs/transactions/collect_rewards.js +23 -2
  63. package/dist/cjs/transactions/collect_rewards.js.map +1 -1
  64. package/dist/cjs/transactions/deposit.d.ts +2 -2
  65. package/dist/cjs/transactions/deposit.d.ts.map +1 -1
  66. package/dist/cjs/transactions/deposit.js +19 -9
  67. package/dist/cjs/transactions/deposit.js.map +1 -1
  68. package/dist/cjs/transactions/navi-looping.d.ts +33 -0
  69. package/dist/cjs/transactions/navi-looping.d.ts.map +1 -0
  70. package/dist/cjs/transactions/navi-looping.js +597 -0
  71. package/dist/cjs/transactions/navi-looping.js.map +1 -0
  72. package/dist/cjs/transactions/navi.d.ts +2 -2
  73. package/dist/cjs/transactions/navi.d.ts.map +1 -1
  74. package/dist/cjs/transactions/navi.js +137 -9
  75. package/dist/cjs/transactions/navi.js.map +1 -1
  76. package/dist/cjs/transactions/withdraw.d.ts +3 -2
  77. package/dist/cjs/transactions/withdraw.d.ts.map +1 -1
  78. package/dist/cjs/transactions/withdraw.js +39 -15
  79. package/dist/cjs/transactions/withdraw.js.map +1 -1
  80. package/dist/esm/adminFunctions.d.ts +6 -0
  81. package/dist/esm/adminFunctions.d.ts.map +1 -0
  82. package/dist/esm/adminFunctions.js +45 -0
  83. package/dist/esm/adminFunctions.js.map +1 -0
  84. package/dist/esm/common/coins.d.ts.map +1 -1
  85. package/dist/esm/common/coins.js +1 -2
  86. package/dist/esm/common/coins.js.map +1 -1
  87. package/dist/esm/common/constants.d.ts +138 -0
  88. package/dist/esm/common/constants.d.ts.map +1 -1
  89. package/dist/esm/common/constants.js +106 -9
  90. package/dist/esm/common/constants.js.map +1 -1
  91. package/dist/esm/common/maps.d.ts +3 -1
  92. package/dist/esm/common/maps.d.ts.map +1 -1
  93. package/dist/esm/common/maps.js +233 -1
  94. package/dist/esm/common/maps.js.map +1 -1
  95. package/dist/esm/common/types.d.ts +112 -3
  96. package/dist/esm/common/types.d.ts.map +1 -1
  97. package/dist/esm/common/types.js.map +1 -1
  98. package/dist/esm/getTVL.d.ts +5 -0
  99. package/dist/esm/getTVL.d.ts.map +1 -0
  100. package/dist/esm/getTVL.js +103 -0
  101. package/dist/esm/getTVL.js.map +1 -0
  102. package/dist/esm/graphql/getMultiReceipts.d.ts.map +1 -1
  103. package/dist/esm/graphql/getMultiReceipts.js +16 -57
  104. package/dist/esm/graphql/getMultiReceipts.js.map +1 -1
  105. package/dist/esm/index.d.ts +12 -2
  106. package/dist/esm/index.d.ts.map +1 -1
  107. package/dist/esm/index.js +14 -2
  108. package/dist/esm/index.js.map +1 -1
  109. package/dist/esm/sui-sdk/events/fetchCheckRatioEvents.d.ts +3 -0
  110. package/dist/esm/sui-sdk/events/fetchCheckRatioEvents.d.ts.map +1 -0
  111. package/dist/esm/sui-sdk/events/fetchCheckRatioEvents.js +41 -0
  112. package/dist/esm/sui-sdk/events/fetchCheckRatioEvents.js.map +1 -0
  113. package/dist/esm/sui-sdk/events/fetchEvents.d.ts.map +1 -1
  114. package/dist/esm/sui-sdk/events/fetchEvents.js +41 -0
  115. package/dist/esm/sui-sdk/events/fetchEvents.js.map +1 -1
  116. package/dist/esm/sui-sdk/events/types.d.ts +9 -1
  117. package/dist/esm/sui-sdk/events/types.d.ts.map +1 -1
  118. package/dist/esm/sui-sdk/events/types.js.map +1 -1
  119. package/dist/esm/sui-sdk/functions/fetchUserVaults.js.map +1 -1
  120. package/dist/esm/sui-sdk/functions/getReceipts.d.ts +8 -6
  121. package/dist/esm/sui-sdk/functions/getReceipts.d.ts.map +1 -1
  122. package/dist/esm/sui-sdk/functions/getReceipts.js +75 -31
  123. package/dist/esm/sui-sdk/functions/getReceipts.js.map +1 -1
  124. package/dist/esm/transactions/alpha.d.ts +2 -2
  125. package/dist/esm/transactions/alpha.d.ts.map +1 -1
  126. package/dist/esm/transactions/alpha.js +2 -2
  127. package/dist/esm/transactions/alpha.js.map +1 -1
  128. package/dist/esm/transactions/bluefin.d.ts +8 -2
  129. package/dist/esm/transactions/bluefin.d.ts.map +1 -1
  130. package/dist/esm/transactions/bluefin.js +352 -6
  131. package/dist/esm/transactions/bluefin.js.map +1 -1
  132. package/dist/esm/transactions/bucket.d.ts +2 -2
  133. package/dist/esm/transactions/bucket.js +2 -2
  134. package/dist/esm/transactions/bucket.js.map +1 -1
  135. package/dist/esm/transactions/cetus.d.ts +4 -4
  136. package/dist/esm/transactions/cetus.d.ts.map +1 -1
  137. package/dist/esm/transactions/cetus.js +27 -29
  138. package/dist/esm/transactions/cetus.js.map +1 -1
  139. package/dist/esm/transactions/collect_rewards.d.ts.map +1 -1
  140. package/dist/esm/transactions/collect_rewards.js +23 -2
  141. package/dist/esm/transactions/collect_rewards.js.map +1 -1
  142. package/dist/esm/transactions/deposit.d.ts +2 -2
  143. package/dist/esm/transactions/deposit.d.ts.map +1 -1
  144. package/dist/esm/transactions/deposit.js +18 -8
  145. package/dist/esm/transactions/deposit.js.map +1 -1
  146. package/dist/esm/transactions/navi-looping.d.ts +33 -0
  147. package/dist/esm/transactions/navi-looping.d.ts.map +1 -0
  148. package/dist/esm/transactions/navi-looping.js +585 -0
  149. package/dist/esm/transactions/navi-looping.js.map +1 -0
  150. package/dist/esm/transactions/navi.d.ts +2 -2
  151. package/dist/esm/transactions/navi.d.ts.map +1 -1
  152. package/dist/esm/transactions/navi.js +137 -9
  153. package/dist/esm/transactions/navi.js.map +1 -1
  154. package/dist/esm/transactions/withdraw.d.ts +3 -2
  155. package/dist/esm/transactions/withdraw.d.ts.map +1 -1
  156. package/dist/esm/transactions/withdraw.js +39 -17
  157. package/dist/esm/transactions/withdraw.js.map +1 -1
  158. package/package.json +4 -2
@@ -13,6 +13,7 @@ exports.getInvestor = getInvestor;
13
13
  exports.fetchVoloExchangeRate = fetchVoloExchangeRate;
14
14
  exports.getCoinAmountsFromLiquidity = getCoinAmountsFromLiquidity;
15
15
  exports.multiGetNaviInvestor = multiGetNaviInvestor;
16
+ exports.getDistributor = getDistributor;
16
17
  const tslib_1 = require("tslib");
17
18
  const index_js_1 = require("../../index.js");
18
19
  const maps_js_1 = require("../../common/maps.js");
@@ -187,32 +188,30 @@ async function getPoolExchangeRate(poolName, ignoreCache) {
187
188
  let pool;
188
189
  try {
189
190
  pool = await getPool(poolName, ignoreCache);
190
- if (pool) {
191
- const xTokenSupply = new decimal_js_1.Decimal(pool.content.fields.xTokenSupply);
192
- let tokensInvested = new decimal_js_1.Decimal(pool.content.fields.tokensInvested);
193
- if (poolName == "ALPHA") {
194
- tokensInvested = new decimal_js_1.Decimal(pool.content.fields.alpha_bal);
195
- }
196
- else if (maps_js_1.poolInfo[poolName].parentProtocolName == "CETUS") {
197
- const investor = (await getInvestor(poolName, ignoreCache));
198
- if (!investor) {
199
- throw new Error(`couldnt fetch investor object for pool: ${poolName}`);
200
- }
201
- tokensInvested = new decimal_js_1.Decimal(pool.content.fields.tokensInvested);
202
- }
203
- // Check for division by zero
204
- if (xTokenSupply.eq(0)) {
205
- console.error("Division by zero error: tokensInvested is zero.");
206
- return undefined;
191
+ const xTokenSupply = new decimal_js_1.Decimal(pool.content.fields.xTokenSupply);
192
+ let tokensInvested = new decimal_js_1.Decimal(pool.content.fields.tokensInvested);
193
+ if (poolName == "ALPHA") {
194
+ tokensInvested = new decimal_js_1.Decimal(pool.content.fields.alpha_bal);
195
+ }
196
+ else if (maps_js_1.poolInfo[poolName].parentProtocolName == "CETUS") {
197
+ const investor = (await getInvestor(poolName, ignoreCache));
198
+ if (!investor) {
199
+ throw new Error(`couldnt fetch investor object for pool: ${poolName}`);
207
200
  }
208
- const poolExchangeRate = tokensInvested.div(xTokenSupply);
209
- return poolExchangeRate;
201
+ tokensInvested = new decimal_js_1.Decimal(pool.content.fields.tokensInvested);
202
+ }
203
+ // Check for division by zero
204
+ if (xTokenSupply.eq(0)) {
205
+ console.error("Division by zero error: tokensInvested is zero.");
206
+ return new decimal_js_1.Decimal(0);
210
207
  }
208
+ const poolExchangeRate = tokensInvested.div(xTokenSupply);
209
+ return poolExchangeRate;
211
210
  }
212
- catch (e) {
213
- console.log(`getPoolExchangeRate failed for poolName: ${poolName}, with error ${e}`);
211
+ catch (err) {
212
+ console.log(`getPoolExchangeRate failed for poolName: ${poolName}, with error ${err}`);
213
+ throw err;
214
214
  }
215
- return undefined;
216
215
  }
217
216
  const poolCache = new simpleCache_js_1.SimpleCache();
218
217
  const poolPromiseCache = new simpleCache_js_1.SimpleCache();
@@ -237,8 +236,8 @@ async function getMultiPool() {
237
236
  poolCache.set(cacheKey, poolData);
238
237
  }
239
238
  }
240
- catch (e) {
241
- console.error(`Error getting multiPools`);
239
+ catch (error) {
240
+ console.error(`Error getting multiPools - ${error}`);
242
241
  }
243
242
  }
244
243
  async function getPool(poolName, ignoreCache) {
@@ -272,9 +271,9 @@ async function getPool(poolName, ignoreCache) {
272
271
  poolCache.set(cacheKey, poolData);
273
272
  return poolData;
274
273
  }
275
- catch (e) {
274
+ catch (err) {
276
275
  console.error(`Error in getPool; poolName => ${poolName}`);
277
- return undefined;
276
+ throw err;
278
277
  }
279
278
  finally {
280
279
  // Remove the promise from the cache after it resolves
@@ -348,9 +347,9 @@ async function getParentPool(poolName, ignoreCache) {
348
347
  cetusPoolCache.set(cacheKey, cetusPool);
349
348
  return cetusPool;
350
349
  }
351
- catch (e) {
350
+ catch (err) {
352
351
  console.error(`getCetusPool failed for poolName: ${poolName}`);
353
- return undefined;
352
+ throw err;
354
353
  }
355
354
  finally {
356
355
  // Remove the promise from the cache after it resolves
@@ -431,9 +430,9 @@ async function getInvestor(poolName, ignoreCache) {
431
430
  investorCache.set(cacheKey, cetusInvestor);
432
431
  return cetusInvestor;
433
432
  }
434
- catch (e) {
433
+ catch (err) {
435
434
  console.error(`getInvestor failed for pool: ${poolName}`);
436
- return undefined;
435
+ throw err;
437
436
  }
438
437
  finally {
439
438
  // Remove the promise from the cache after it resolves
@@ -505,6 +504,52 @@ async function multiGetNaviInvestor(poolNames) {
505
504
  throw err;
506
505
  }
507
506
  }
507
+ const distributorCache = new simpleCache_js_1.SimpleCache();
508
+ const distributorPromiseCache = new simpleCache_js_1.SimpleCache();
509
+ async function getDistributor(ignoreCache) {
510
+ const suiClient = (0, client_js_1.getSuiClient)();
511
+ const cacheKey = `distributor_${(0, index_js_1.getConf)().ALPHA_DISTRIBUTOR}`;
512
+ if (ignoreCache) {
513
+ distributorCache.delete(cacheKey);
514
+ distributorPromiseCache.delete(cacheKey);
515
+ }
516
+ // Check if the distributor is already in the cache
517
+ const cachedDistributor = distributorCache.get(cacheKey);
518
+ if (cachedDistributor) {
519
+ return cachedDistributor;
520
+ }
521
+ // Check if there is already a promise in the cache
522
+ let distributorPromise = distributorPromiseCache.get(cacheKey);
523
+ if (distributorPromise) {
524
+ return distributorPromise;
525
+ }
526
+ // If not, create a new promise and cache it
527
+ distributorPromise = (async () => {
528
+ try {
529
+ const o = await suiClient.getObject({
530
+ id: (0, index_js_1.getConf)().ALPHA_DISTRIBUTOR,
531
+ options: {
532
+ showContent: true,
533
+ },
534
+ });
535
+ const distributor = o.data;
536
+ // Cache the distributor object
537
+ distributorCache.set(cacheKey, distributor);
538
+ return distributor;
539
+ }
540
+ catch (e) {
541
+ console.error(`getDistributor failed`);
542
+ return undefined;
543
+ }
544
+ finally {
545
+ // Remove the promise from the cache after it resolves
546
+ distributorPromiseCache.delete(cacheKey);
547
+ }
548
+ })();
549
+ // Cache the promise
550
+ distributorPromiseCache.set(cacheKey, distributorPromise);
551
+ return distributorPromise;
552
+ }
508
553
  /*
509
554
  for the missing pools, add a promise, each of those promises waits for there respective object from a map, that map is populated all at once,
510
555
  problem with concurrency
@@ -1 +1 @@
1
- {"version":3,"file":"getReceipts.js","sourceRoot":"","sources":["../../../../src/sui-sdk/functions/getReceipts.ts"],"names":[],"mappings":";;AA4BA,gEAyEC;AAKD,4CA0BC;AAED,kCAoEC;AAED,kDAuCC;AAOD,oCAuBC;AAED,0BAmDC;AAOD,gDAuBC;AAED,sCAqDC;AAKD,4CAuBC;AAED,kCAwDC;AAED,sDAeC;AAED,kEAgCC;AAED,oDA8BC;;AAnkBD,6CAmBwB;AACxB,kDAAgD;AAChD,0EAA2E;AAC3E,0DAAuB;AACvB,2CAAqC;AACrC,4CAA4C;AAC5C,+DAAyD;AAEzD,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AC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,IAA2C,CAAC;YACxE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC;QACnC,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,SAAS;QACT,OAAO,CAAC,KAAK,CACX,6CAA6C,EAC7C,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CACrB,CAAC;QACF,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;;EAGE;AACF,gFAAgF","sourcesContent":["import { PaginatedObjectsResponse } from \"@mysten/sui/client\";\nimport {\n AlphaPoolType,\n CetusInvestor,\n NaviInvestor,\n CommonInvestorFields,\n CetusPoolType,\n CoinAmounts,\n PoolName,\n PoolType,\n Receipt,\n NaviVoloData,\n Investor,\n BluefinInvestor,\n BucketInvestor,\n SingleAssetPoolNames,\n fetchMultiReceipts,\n ReceiptGQL,\n cetusPoolMap,\n bluefinPoolMap,\n} from \"../../index.js\";\nimport { poolInfo } from \"../../common/maps.js\";\nimport { ClmmPoolUtil, TickMath } from \"@cetusprotocol/cetus-sui-clmm-sdk\";\nimport BN from \"bn.js\";\nimport { Decimal } from \"decimal.js\";\nimport { getSuiClient } from \"../client.js\";\nimport { SimpleCache } from \"../../utils/simpleCache.js\";\n\nexport function convertReceiptGQLToReceipt(receipts: ReceiptGQL[]): Receipt[] {\n const res = receipts.map((receipt) => {\n return {\n objectId: receipt.address,\n version: receipt.version,\n digest: receipt.digest,\n content: {\n dataType: \"moveObject\", // Assuming a fixed value as it's not available in ReceiptA\n type: receipt.contents.type.repr,\n hasPublicTransfer: receipt.hasPublicTransfer,\n fields: {\n id: { id: receipt.contents.json.id },\n image_url: receipt.contents.json.image_url,\n last_acc_reward_per_xtoken: {\n type: \"unknown\", // Assuming fixed value\n fields: {\n contents:\n receipt.contents.json.last_acc_reward_per_xtoken.contents.map(\n (item) => ({\n type: \"unknown\", // Assuming fixed value\n fields: {\n value: item.value,\n key: {\n type: \"unknown\", // Assuming fixed value\n fields: {\n name: item.key.name,\n },\n },\n },\n }),\n ),\n },\n },\n locked_balance: receipt.contents.json.locked_balance\n ? {\n type: \"unknown\", // Assuming fixed value\n fields: {\n head: receipt.contents.json.locked_balance.head,\n id: { id: receipt.contents.json.locked_balance.id },\n size: receipt.contents.json.locked_balance.size,\n tail: receipt.contents.json.locked_balance.tail,\n },\n }\n : undefined,\n name: receipt.contents.json.name,\n owner: receipt.contents.json.owner,\n pending_rewards: {\n type: \"unknown\", // Assuming fixed value\n fields: {\n contents: receipt.contents.json.pending_rewards.contents.map(\n (item) => ({\n type: \"unknown\", // Assuming fixed value\n fields: {\n key: {\n type: \"unknown\", // Assuming fixed value\n fields: {\n name: item.key.name,\n },\n },\n value: item.value,\n },\n }),\n ),\n },\n },\n pool_id: receipt.contents.json.pool_id,\n xTokenBalance: receipt.contents.json.xTokenBalance,\n unlocked_xtokens: receipt.contents.json.unlocked_xtokens ?? undefined,\n },\n },\n };\n });\n return res;\n}\n\nconst receiptsCache = new SimpleCache<Receipt[]>(3600000);\nconst receiptsPromiseCache = new SimpleCache<Promise<Receipt[]>>(3600000);\n\nexport async function getMultiReceipts(address: string) {\n try {\n const receiptMap = await fetchMultiReceipts(address);\n for (const pool of Object.keys(poolInfo)) {\n const cacheKey = `getReceipts-${poolInfo[pool].receiptName}-${address}`;\n let receipt: Receipt[] = [];\n if (receiptMap.has(poolInfo[pool].receiptName)) {\n receipt = convertReceiptGQLToReceipt(\n receiptMap.get(poolInfo[pool].receiptName) as ReceiptGQL[],\n );\n }\n receiptsCache.set(cacheKey, receipt);\n }\n } catch (error) {\n console.error(\"Error fetching receipts from graphQL:\", error);\n // get receipts individually\n const pools = Object.keys(poolInfo);\n const receiptPromises = pools.map((pool) => {\n return getReceipts(pool, address, true);\n });\n const receipts = await Promise.all(receiptPromises);\n receipts.forEach((receipt, index) => {\n const cacheKey = `getReceipts-${poolInfo[pools[index]].receiptName}-${address}`;\n receiptsCache.set(cacheKey, receipt);\n });\n }\n}\n\nexport async function getReceipts(\n poolName: string,\n address: string,\n ignoreCache: boolean,\n): Promise<Receipt[]> {\n const suiClient = getSuiClient();\n const receiptsCacheKey = `getReceipts-${poolInfo[poolName].receiptName}-${address}`;\n if (ignoreCache) {\n receiptsCache.delete(receiptsCacheKey);\n receiptsPromiseCache.delete(receiptsCacheKey);\n }\n const cachedResponse = receiptsCache.get(receiptsCacheKey);\n if (cachedResponse) {\n return cachedResponse;\n }\n //\n const nfts: Receipt[] = [];\n if (poolInfo[poolName].receiptType == \"\") {\n return nfts;\n }\n let cachedPromise = receiptsPromiseCache.get(receiptsCacheKey);\n if (!cachedPromise) {\n cachedPromise = (async (): Promise<Receipt[]> => {\n // const first_package = getConf().ALPHA_FIRST_PACKAGE_ID;\n let currentCursor: string | null | undefined = null;\n while (true) {\n const paginatedObjects: PaginatedObjectsResponse =\n await suiClient.getOwnedObjects({\n owner: address,\n cursor: currentCursor,\n filter: {\n // StructType: `${first_package}::${module}::Receipt`,\n StructType: poolInfo[poolName].receiptType,\n },\n options: {\n showContent: true,\n },\n });\n // Traverse the current page data and push to coins array\n paginatedObjects.data.forEach((obj) => {\n const o = obj.data as Receipt;\n if (o) {\n if (poolInfo[poolName].receiptName === o.content.fields.name) {\n nfts.push(o);\n }\n }\n });\n // Check if there's a next page\n if (paginatedObjects.hasNextPage && paginatedObjects.nextCursor) {\n currentCursor = paginatedObjects.nextCursor;\n } else {\n // No more pages available\n // console.log(\"No more receipts available.\");\n break;\n }\n }\n receiptsCache.set(receiptsCacheKey, nfts);\n receiptsPromiseCache.delete(receiptsCacheKey);\n return nfts;\n })().catch((error) => {\n receiptsPromiseCache.delete(receiptsCacheKey); // Remove the promise from cache\n throw error;\n });\n // const data = await cachedPromise;\n // console.log(\"received cached data\", data);\n receiptsPromiseCache.set(receiptsCacheKey, cachedPromise);\n }\n return cachedPromise;\n}\n\nexport async function getPoolExchangeRate(\n poolName: PoolName,\n ignoreCache: boolean,\n): Promise<Decimal | undefined> {\n let pool;\n try {\n pool = await getPool(poolName, ignoreCache);\n if (pool) {\n const xTokenSupply = new Decimal(pool.content.fields.xTokenSupply);\n let tokensInvested = new Decimal(pool.content.fields.tokensInvested);\n if (poolName == \"ALPHA\") {\n tokensInvested = new Decimal(pool.content.fields.alpha_bal);\n } else if (poolInfo[poolName].parentProtocolName == \"CETUS\") {\n const investor = (await getInvestor(\n poolName,\n ignoreCache,\n )) as CetusInvestor & CommonInvestorFields;\n if (!investor) {\n throw new Error(\n `couldnt fetch investor object for pool: ${poolName}`,\n );\n }\n tokensInvested = new Decimal(pool.content.fields.tokensInvested);\n }\n\n // Check for division by zero\n if (xTokenSupply.eq(0)) {\n console.error(\"Division by zero error: tokensInvested is zero.\");\n return undefined;\n }\n const poolExchangeRate = tokensInvested.div(xTokenSupply);\n return poolExchangeRate;\n }\n } catch (e) {\n console.log(\n `getPoolExchangeRate failed for poolName: ${poolName}, with error ${e}`,\n );\n }\n return undefined;\n}\n\nconst poolCache = new SimpleCache<PoolType | AlphaPoolType>();\nconst poolPromiseCache = new SimpleCache<\n Promise<PoolType | AlphaPoolType | undefined>\n>();\n\nexport async function getMultiPool() {\n let pools = Object.keys(poolInfo);\n pools = pools.filter((pool) => {\n return poolInfo[pool].poolId !== \"\";\n });\n const poolIds = pools.map((pool) => {\n return poolInfo[pool].poolId;\n });\n try {\n const o = await getSuiClient().multiGetObjects({\n ids: poolIds,\n options: {\n showContent: true,\n },\n });\n for (let i = 0; i < pools.length; i = i + 1) {\n const poolData = o[i].data as AlphaPoolType | PoolType;\n const cacheKey = `pool_${poolInfo[pools[i]].poolId}`;\n poolCache.set(cacheKey, poolData);\n }\n } catch (e) {\n console.error(`Error getting multiPools`);\n }\n}\n\nexport async function getPool(\n poolName: string,\n ignoreCache: boolean,\n): Promise<PoolType | AlphaPoolType | undefined> {\n const suiClient = getSuiClient();\n const cacheKey = `pool_${poolInfo[poolName.toUpperCase()].poolId}`;\n\n if (ignoreCache) {\n poolCache.delete(cacheKey);\n poolPromiseCache.delete(cacheKey);\n }\n\n // Check if the pool is already in the cache\n const cachedPool = poolCache.get(cacheKey);\n if (cachedPool) {\n return cachedPool;\n }\n\n // Check if there is already a promise in the cache\n let poolPromise = poolPromiseCache.get(cacheKey);\n if (poolPromise) {\n return poolPromise;\n }\n // If not, create a new promise and cache it\n poolPromise = (async () => {\n try {\n const o = await suiClient.getObject({\n id: poolInfo[poolName].poolId,\n options: {\n showContent: true,\n },\n });\n\n const poolData =\n poolName === \"ALPHA\" ? (o.data as AlphaPoolType) : (o.data as PoolType);\n\n // Cache the pool object\n poolCache.set(cacheKey, poolData);\n return poolData;\n } catch (e) {\n console.error(`Error in getPool; poolName => ${poolName}`);\n return undefined;\n } finally {\n // Remove the promise from the cache after it resolves\n poolPromiseCache.delete(cacheKey);\n }\n })();\n\n // Cache the promise\n poolPromiseCache.set(cacheKey, poolPromise);\n return poolPromise;\n}\n\nconst cetusPoolCache = new SimpleCache<CetusPoolType>();\nconst cetusPoolPromiseCache = new SimpleCache<\n Promise<CetusPoolType | undefined>\n>();\n\nexport async function getMultiParentPool() {\n let pools = Object.keys(poolInfo);\n pools = pools.filter((pool) => {\n return poolInfo[pool].poolId !== \"\";\n });\n const poolIds = pools.map((pool) => {\n return poolInfo[pool].parentPoolId;\n });\n try {\n const o = await getSuiClient().multiGetObjects({\n ids: poolIds,\n options: {\n showContent: true,\n },\n });\n for (let i = 0; i < pools.length; i = i + 1) {\n const poolData = o[i].data as CetusPoolType;\n const cacheKey = `pool_${poolInfo[pools[i]].parentPoolId}`;\n cetusPoolCache.set(cacheKey, poolData);\n }\n } catch (e) {\n console.error(`Error getting multiPools`);\n }\n}\n\nexport async function getParentPool(\n poolName: string,\n ignoreCache: boolean,\n): Promise<CetusPoolType | undefined> {\n const suiClient = getSuiClient();\n const cacheKey = `pool_${cetusPoolMap[poolName.toUpperCase()]}`;\n if (ignoreCache) {\n cetusPoolCache.delete(cacheKey);\n cetusPoolPromiseCache.delete(cacheKey);\n }\n\n // Check if the pool is already in the cache\n const cachedPool = cetusPoolCache.get(cacheKey);\n if (cachedPool) {\n return cachedPool;\n }\n\n // Check if there is already a promise in the cache\n let cetusPoolPromise = cetusPoolPromiseCache.get(cacheKey);\n if (cetusPoolPromise) {\n return cetusPoolPromise;\n }\n // If not, create a new promise and cache it\n cetusPoolPromise = (async () => {\n try {\n const id = poolInfo[poolName]\n ? poolInfo[poolName].parentPoolId\n : cetusPoolMap[poolName]\n ? cetusPoolMap[poolName]\n : bluefinPoolMap[poolName];\n const o = await suiClient.getObject({\n id: id,\n options: {\n showContent: true,\n },\n });\n const cetusPool = o.data as CetusPoolType;\n\n // Cache the pool object\n cetusPoolCache.set(cacheKey, cetusPool);\n return cetusPool;\n } catch (e) {\n console.error(`getCetusPool failed for poolName: ${poolName}`);\n return undefined;\n } finally {\n // Remove the promise from the cache after it resolves\n cetusPoolPromiseCache.delete(cacheKey);\n }\n })();\n\n // Cache the promise\n cetusPoolPromiseCache.set(cacheKey, cetusPoolPromise);\n return cetusPoolPromise;\n}\n\nconst investorCache = new SimpleCache<Investor>();\nconst investorPromiseCache = new SimpleCache<Promise<Investor | undefined>>();\n\nexport async function getMultiInvestor() {\n let pools = Object.keys(poolInfo);\n pools = pools.filter((pool) => {\n return poolInfo[pool].investorId !== \"\";\n });\n const investorIds = pools.map((pool) => {\n return poolInfo[pool].investorId;\n });\n try {\n const o = await getSuiClient().multiGetObjects({\n ids: investorIds,\n options: {\n showContent: true,\n },\n });\n for (let i = 0; i < pools.length; i = i + 1) {\n const investorData = o[i].data as Investor;\n const cacheKey = `investor_${poolInfo[pools[i]].investorId}`;\n investorCache.set(cacheKey, investorData);\n }\n } catch (e) {\n console.error(`Error getting multiPools`);\n }\n}\n\nexport async function getInvestor(\n poolName: PoolName,\n ignoreCache: boolean,\n): Promise<Investor | undefined> {\n const suiClient = getSuiClient();\n const cacheKey = `investor_${poolInfo[poolName.toUpperCase()].investorId}`;\n if (ignoreCache) {\n investorCache.delete(cacheKey);\n investorPromiseCache.delete(cacheKey);\n }\n // Check if the investor is already in the cache\n const cachedInvestor = investorCache.get(cacheKey);\n if (cachedInvestor) {\n return cachedInvestor;\n }\n\n // Check if there is already a promise in the cache\n let cetusInvestorPromise = investorPromiseCache.get(cacheKey);\n if (cetusInvestorPromise) {\n return cetusInvestorPromise;\n }\n // If not, create a new promise and cache it\n cetusInvestorPromise = (async () => {\n try {\n const o = await suiClient.getObject({\n id: poolInfo[poolName.toUpperCase()].investorId,\n options: {\n showContent: true,\n },\n });\n let cetusInvestor;\n if (poolInfo[poolName].parentProtocolName == \"NAVI\") {\n cetusInvestor = o.data as NaviInvestor & CommonInvestorFields;\n } else if (poolInfo[poolName].parentProtocolName == \"BUCKET\") {\n cetusInvestor = o.data as BucketInvestor & CommonInvestorFields;\n } else if (poolInfo[poolName].parentProtocolName == \"BLUEFIN\") {\n cetusInvestor = o.data as BluefinInvestor & CommonInvestorFields;\n } else {\n cetusInvestor = o.data as CetusInvestor & CommonInvestorFields;\n }\n\n // Cache the investor object\n investorCache.set(cacheKey, cetusInvestor);\n return cetusInvestor;\n } catch (e) {\n console.error(`getInvestor failed for pool: ${poolName}`);\n return undefined;\n } finally {\n // Remove the promise from the cache after it resolves\n investorPromiseCache.delete(cacheKey);\n }\n })();\n\n // Cache the promise\n investorPromiseCache.set(cacheKey, cetusInvestorPromise);\n return cetusInvestorPromise;\n}\n\nexport async function fetchVoloExchangeRate(): Promise<NaviVoloData> {\n const apiUrl = \"https://open-api.naviprotocol.io/api/volo/stats\";\n const NaviVoloDetails: NaviVoloData = await fetch(apiUrl)\n .then(async (response) => {\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n const data = (await response.json()) as NaviVoloData; // Parse the JSON response\n return data;\n })\n .catch((error) => {\n console.log(\"failed to fetch Navi-volo details\", error);\n throw error;\n });\n return NaviVoloDetails;\n}\n\nexport async function getCoinAmountsFromLiquidity(\n poolName: PoolName,\n liquidity: string,\n ignoreCache: boolean,\n): Promise<[string, string]> {\n const clmmPool = await getParentPool(poolName, ignoreCache);\n const investor = (await getInvestor(poolName, ignoreCache)) as CetusInvestor &\n CommonInvestorFields;\n\n const upper_bound = 443636;\n let lower_tick = Number(investor!.content.fields.lower_tick);\n let upper_tick = Number(investor!.content.fields.upper_tick);\n\n if (lower_tick > upper_bound) {\n lower_tick = -~(lower_tick - 1);\n }\n if (upper_tick > upper_bound) {\n upper_tick = -~(upper_tick - 1);\n }\n if (clmmPool) {\n const liquidityInt = Math.floor(parseFloat(liquidity));\n const coin_amounts: CoinAmounts = ClmmPoolUtil.getCoinAmountFromLiquidity(\n new BN(`${liquidityInt}`),\n new BN(clmmPool.content.fields.current_sqrt_price),\n TickMath.tickIndexToSqrtPriceX64(lower_tick),\n TickMath.tickIndexToSqrtPriceX64(upper_tick),\n true,\n );\n return [coin_amounts.coinA.toString(), coin_amounts.coinB.toString()];\n } else {\n return [\"0\", \"0\"];\n }\n}\n\nexport async function multiGetNaviInvestor(poolNames: SingleAssetPoolNames[]) {\n const results: {\n [poolName in SingleAssetPoolNames]?:\n | (NaviInvestor & CommonInvestorFields)\n | undefined;\n } = {};\n const poolInvestorIds: string[] = [];\n\n for (const poolName of poolNames) {\n poolInvestorIds.push(poolInfo[poolName.toUpperCase()].investorId);\n }\n try {\n const suiClient = getSuiClient();\n const objects = await suiClient.multiGetObjects({\n ids: poolInvestorIds,\n options: { showContent: true },\n });\n for (let i = 0; i < objects.length; i++) {\n const investor = objects[i].data as NaviInvestor & CommonInvestorFields;\n results[poolNames[i]] = investor;\n }\n return results;\n } catch (err) {\n //improve\n console.error(\n \"multiGetNaviInvestor failed for poolNames: \",\n poolNames.join(\", \"),\n );\n throw err;\n }\n}\n\n/*\nfor the missing pools, add a promise, each of those promises waits for there respective object from a map, that map is populated all at once, \nproblem with concurrency\n*/\n// ask how to deal with this kind of probem with high concurrency anf throughput\n"]}
1
+ {"version":3,"file":"getReceipts.js","sourceRoot":"","sources":["../../../../src/sui-sdk/functions/getReceipts.ts"],"names":[],"mappings":";;AA8BA,gEAyEC;AAKD,4CA0BC;AAED,kCAoEC;AAED,kDAmCC;AAKD,oCAuBC;AAED,0BAmDC;AAKD,gDAuBC;AAED,sCAqDC;AAKD,4CAuBC;AAED,kCAwDC;AAED,sDAeC;AAED,kEAgCC;AAED,oDA8BC;AAOD,wCA+CC;;AAnnBD,6CAqBwB;AACxB,kDAAgD;AAChD,0EAA2E;AAC3E,0DAAuB;AACvB,2CAAqC;AACrC,4CAA4C;AAC5C,+DAAyD;AAEzD,SAAgB,0BAA0B,CAAC,QAAsB;IAC/D,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACnC,OAAO;YACL,QAAQ,EAAE,OAAO,CAAC,OAAO;YACzB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,OAAO,EAAE;gBACP,QAAQ,EAAE,YAAY,EAAE,2DAA2D;gBACnF,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI;gBAChC,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;gBAC5C,MAAM,EAAE;oBACN,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE;oBACpC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS;oBAC1C,0BAA0B,EAAE;wBAC1B,IAAI,EAAE,SAAS,EAAE,uBAAuB;wBACxC,MAAM,EAAE;4BACN,QAAQ,EACN,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,0BAA0B,CAAC,QAAQ,CAAC,GAAG,CAC3D,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;gCACT,IAAI,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usInvestor,\n NaviInvestor,\n CommonInvestorFields,\n CetusPoolType,\n CoinAmounts,\n PoolName,\n PoolType,\n Receipt,\n NaviVoloData,\n Investor,\n BluefinInvestor,\n BucketInvestor,\n SingleAssetPoolNames,\n fetchMultiReceipts,\n ReceiptGQL,\n cetusPoolMap,\n bluefinPoolMap,\n Distributor,\n getConf,\n} from \"../../index.js\";\nimport { poolInfo } from \"../../common/maps.js\";\nimport { ClmmPoolUtil, TickMath } from \"@cetusprotocol/cetus-sui-clmm-sdk\";\nimport BN from \"bn.js\";\nimport { Decimal } from \"decimal.js\";\nimport { getSuiClient } from \"../client.js\";\nimport { SimpleCache } from \"../../utils/simpleCache.js\";\n\nexport function convertReceiptGQLToReceipt(receipts: ReceiptGQL[]): Receipt[] {\n const res = receipts.map((receipt) => {\n return {\n objectId: receipt.address,\n version: receipt.version,\n digest: receipt.digest,\n content: {\n dataType: \"moveObject\", // Assuming a fixed value as it's not available in ReceiptA\n type: receipt.contents.type.repr,\n hasPublicTransfer: receipt.hasPublicTransfer,\n fields: {\n id: { id: receipt.contents.json.id },\n image_url: receipt.contents.json.image_url,\n last_acc_reward_per_xtoken: {\n type: \"unknown\", // Assuming fixed value\n fields: {\n contents:\n receipt.contents.json.last_acc_reward_per_xtoken.contents.map(\n (item) => ({\n type: \"unknown\", // Assuming fixed value\n fields: {\n value: item.value,\n key: {\n type: \"unknown\", // Assuming fixed value\n fields: {\n name: item.key.name,\n },\n },\n },\n }),\n ),\n },\n },\n locked_balance: receipt.contents.json.locked_balance\n ? {\n type: \"unknown\", // Assuming fixed value\n fields: {\n head: receipt.contents.json.locked_balance.head,\n id: { id: receipt.contents.json.locked_balance.id },\n size: receipt.contents.json.locked_balance.size,\n tail: receipt.contents.json.locked_balance.tail,\n },\n }\n : undefined,\n name: receipt.contents.json.name,\n owner: receipt.contents.json.owner,\n pending_rewards: {\n type: \"unknown\", // Assuming fixed value\n fields: {\n contents: receipt.contents.json.pending_rewards.contents.map(\n (item) => ({\n type: \"unknown\", // Assuming fixed value\n fields: {\n key: {\n type: \"unknown\", // Assuming fixed value\n fields: {\n name: item.key.name,\n },\n },\n value: item.value,\n },\n }),\n ),\n },\n },\n pool_id: receipt.contents.json.pool_id,\n xTokenBalance: receipt.contents.json.xTokenBalance,\n unlocked_xtokens: receipt.contents.json.unlocked_xtokens ?? undefined,\n },\n },\n };\n });\n return res;\n}\n\nconst receiptsCache = new SimpleCache<Receipt[]>(3600000);\nconst receiptsPromiseCache = new SimpleCache<Promise<Receipt[]>>(3600000);\n\nexport async function getMultiReceipts(address: string) {\n try {\n const receiptMap = await fetchMultiReceipts(address);\n for (const pool of Object.keys(poolInfo)) {\n const cacheKey = `getReceipts-${poolInfo[pool].receiptName}-${address}`;\n let receipt: Receipt[] = [];\n if (receiptMap.has(poolInfo[pool].receiptName)) {\n receipt = convertReceiptGQLToReceipt(\n receiptMap.get(poolInfo[pool].receiptName) as ReceiptGQL[],\n );\n }\n receiptsCache.set(cacheKey, receipt);\n }\n } catch (error) {\n console.error(\"Error fetching receipts from graphQL:\", error);\n // get receipts individually\n const pools = Object.keys(poolInfo);\n const receiptPromises = pools.map((pool) => {\n return getReceipts(pool as PoolName, address, true);\n });\n const receipts = await Promise.all(receiptPromises);\n receipts.forEach((receipt, index) => {\n const cacheKey = `getReceipts-${poolInfo[pools[index]].receiptName}-${address}`;\n receiptsCache.set(cacheKey, receipt);\n });\n }\n}\n\nexport async function getReceipts(\n poolName: PoolName,\n address: string,\n ignoreCache: boolean,\n): Promise<Receipt[]> {\n const suiClient = getSuiClient();\n const receiptsCacheKey = `getReceipts-${poolInfo[poolName].receiptName}-${address}`;\n if (ignoreCache) {\n receiptsCache.delete(receiptsCacheKey);\n receiptsPromiseCache.delete(receiptsCacheKey);\n }\n const cachedResponse = receiptsCache.get(receiptsCacheKey);\n if (cachedResponse) {\n return cachedResponse;\n }\n //\n const nfts: Receipt[] = [];\n if (poolInfo[poolName].receiptType == \"\") {\n return nfts;\n }\n let cachedPromise = receiptsPromiseCache.get(receiptsCacheKey);\n if (!cachedPromise) {\n cachedPromise = (async (): Promise<Receipt[]> => {\n // const first_package = getConf().ALPHA_FIRST_PACKAGE_ID;\n let currentCursor: string | null | undefined = null;\n while (true) {\n const paginatedObjects: PaginatedObjectsResponse =\n await suiClient.getOwnedObjects({\n owner: address,\n cursor: currentCursor,\n filter: {\n // StructType: `${first_package}::${module}::Receipt`,\n StructType: poolInfo[poolName].receiptType,\n },\n options: {\n showContent: true,\n },\n });\n // Traverse the current page data and push to coins array\n paginatedObjects.data.forEach((obj) => {\n const o = obj.data as Receipt;\n if (o) {\n if (poolInfo[poolName].receiptName === o.content.fields.name) {\n nfts.push(o);\n }\n }\n });\n // Check if there's a next page\n if (paginatedObjects.hasNextPage && paginatedObjects.nextCursor) {\n currentCursor = paginatedObjects.nextCursor;\n } else {\n // No more pages available\n // console.log(\"No more receipts available.\");\n break;\n }\n }\n receiptsCache.set(receiptsCacheKey, nfts);\n receiptsPromiseCache.delete(receiptsCacheKey);\n return nfts;\n })().catch((error) => {\n receiptsPromiseCache.delete(receiptsCacheKey); // Remove the promise from cache\n throw error;\n });\n // const data = await cachedPromise;\n // console.log(\"received cached data\", data);\n receiptsPromiseCache.set(receiptsCacheKey, cachedPromise);\n }\n return cachedPromise;\n}\n\nexport async function getPoolExchangeRate(\n poolName: PoolName,\n ignoreCache: boolean,\n): Promise<Decimal> {\n let pool;\n try {\n pool = await getPool(poolName, ignoreCache);\n const xTokenSupply = new Decimal(pool.content.fields.xTokenSupply);\n let tokensInvested = new Decimal(pool.content.fields.tokensInvested);\n if (poolName == \"ALPHA\") {\n tokensInvested = new Decimal(pool.content.fields.alpha_bal);\n } else if (poolInfo[poolName].parentProtocolName == \"CETUS\") {\n const investor = (await getInvestor(\n poolName,\n ignoreCache,\n )) as CetusInvestor & CommonInvestorFields;\n if (!investor) {\n throw new Error(`couldnt fetch investor object for pool: ${poolName}`);\n }\n tokensInvested = new Decimal(pool.content.fields.tokensInvested);\n }\n\n // Check for division by zero\n if (xTokenSupply.eq(0)) {\n console.error(\"Division by zero error: tokensInvested is zero.\");\n return new Decimal(0);\n }\n const poolExchangeRate = tokensInvested.div(xTokenSupply);\n return poolExchangeRate;\n } catch (err) {\n console.log(\n `getPoolExchangeRate failed for poolName: ${poolName}, with error ${err}`,\n );\n throw err;\n }\n}\n\nconst poolCache = new SimpleCache<PoolType | AlphaPoolType>();\nconst poolPromiseCache = new SimpleCache<Promise<PoolType | AlphaPoolType>>();\n\nexport async function getMultiPool() {\n let pools = Object.keys(poolInfo);\n pools = pools.filter((pool) => {\n return poolInfo[pool].poolId !== \"\";\n });\n const poolIds = pools.map((pool) => {\n return poolInfo[pool].poolId;\n });\n try {\n const o = await getSuiClient().multiGetObjects({\n ids: poolIds,\n options: {\n showContent: true,\n },\n });\n for (let i = 0; i < pools.length; i = i + 1) {\n const poolData = o[i].data as AlphaPoolType | PoolType;\n const cacheKey = `pool_${poolInfo[pools[i]].poolId}`;\n poolCache.set(cacheKey, poolData);\n }\n } catch (error) {\n console.error(`Error getting multiPools - ${error}`);\n }\n}\n\nexport async function getPool(\n poolName: string,\n ignoreCache: boolean,\n): Promise<PoolType | AlphaPoolType> {\n const suiClient = getSuiClient();\n const cacheKey = `pool_${poolInfo[poolName.toUpperCase()].poolId}`;\n\n if (ignoreCache) {\n poolCache.delete(cacheKey);\n poolPromiseCache.delete(cacheKey);\n }\n\n // Check if the pool is already in the cache\n const cachedPool = poolCache.get(cacheKey);\n if (cachedPool) {\n return cachedPool;\n }\n\n // Check if there is already a promise in the cache\n let poolPromise = poolPromiseCache.get(cacheKey);\n if (poolPromise) {\n return poolPromise;\n }\n // If not, create a new promise and cache it\n poolPromise = (async () => {\n try {\n const o = await suiClient.getObject({\n id: poolInfo[poolName].poolId,\n options: {\n showContent: true,\n },\n });\n\n const poolData =\n poolName === \"ALPHA\" ? (o.data as AlphaPoolType) : (o.data as PoolType);\n\n // Cache the pool object\n poolCache.set(cacheKey, poolData);\n return poolData;\n } catch (err) {\n console.error(`Error in getPool; poolName => ${poolName}`);\n throw err;\n } finally {\n // Remove the promise from the cache after it resolves\n poolPromiseCache.delete(cacheKey);\n }\n })();\n\n // Cache the promise\n poolPromiseCache.set(cacheKey, poolPromise);\n return poolPromise;\n}\n\nconst cetusPoolCache = new SimpleCache<CetusPoolType>();\nconst cetusPoolPromiseCache = new SimpleCache<Promise<CetusPoolType>>();\n\nexport async function getMultiParentPool() {\n let pools = Object.keys(poolInfo);\n pools = pools.filter((pool) => {\n return poolInfo[pool].poolId !== \"\";\n });\n const poolIds = pools.map((pool) => {\n return poolInfo[pool].parentPoolId;\n });\n try {\n const o = await getSuiClient().multiGetObjects({\n ids: poolIds,\n options: {\n showContent: true,\n },\n });\n for (let i = 0; i < pools.length; i = i + 1) {\n const poolData = o[i].data as CetusPoolType;\n const cacheKey = `pool_${poolInfo[pools[i]].parentPoolId}`;\n cetusPoolCache.set(cacheKey, poolData);\n }\n } catch (e) {\n console.error(`Error getting multiPools`);\n }\n}\n\nexport async function getParentPool(\n poolName: string,\n ignoreCache: boolean,\n): Promise<CetusPoolType> {\n const suiClient = getSuiClient();\n const cacheKey = `pool_${cetusPoolMap[poolName.toUpperCase()]}`;\n if (ignoreCache) {\n cetusPoolCache.delete(cacheKey);\n cetusPoolPromiseCache.delete(cacheKey);\n }\n\n // Check if the pool is already in the cache\n const cachedPool = cetusPoolCache.get(cacheKey);\n if (cachedPool) {\n return cachedPool;\n }\n\n // Check if there is already a promise in the cache\n let cetusPoolPromise = cetusPoolPromiseCache.get(cacheKey);\n if (cetusPoolPromise) {\n return cetusPoolPromise;\n }\n // If not, create a new promise and cache it\n cetusPoolPromise = (async () => {\n try {\n const id = poolInfo[poolName]\n ? poolInfo[poolName].parentPoolId\n : cetusPoolMap[poolName]\n ? cetusPoolMap[poolName]\n : bluefinPoolMap[poolName];\n const o = await suiClient.getObject({\n id: id,\n options: {\n showContent: true,\n },\n });\n const cetusPool = o.data as CetusPoolType;\n\n // Cache the pool object\n cetusPoolCache.set(cacheKey, cetusPool);\n return cetusPool;\n } catch (err) {\n console.error(`getCetusPool failed for poolName: ${poolName}`);\n throw err;\n } finally {\n // Remove the promise from the cache after it resolves\n cetusPoolPromiseCache.delete(cacheKey);\n }\n })();\n\n // Cache the promise\n cetusPoolPromiseCache.set(cacheKey, cetusPoolPromise);\n return cetusPoolPromise;\n}\n\nconst investorCache = new SimpleCache<Investor>();\nconst investorPromiseCache = new SimpleCache<Promise<Investor>>();\n\nexport async function getMultiInvestor() {\n let pools = Object.keys(poolInfo);\n pools = pools.filter((pool) => {\n return poolInfo[pool].investorId !== \"\";\n });\n const investorIds = pools.map((pool) => {\n return poolInfo[pool].investorId;\n });\n try {\n const o = await getSuiClient().multiGetObjects({\n ids: investorIds,\n options: {\n showContent: true,\n },\n });\n for (let i = 0; i < pools.length; i = i + 1) {\n const investorData = o[i].data as Investor;\n const cacheKey = `investor_${poolInfo[pools[i]].investorId}`;\n investorCache.set(cacheKey, investorData);\n }\n } catch (e) {\n console.error(`Error getting multiPools`);\n }\n}\n\nexport async function getInvestor(\n poolName: PoolName,\n ignoreCache: boolean,\n): Promise<Investor> {\n const suiClient = getSuiClient();\n const cacheKey = `investor_${poolInfo[poolName.toUpperCase()].investorId}`;\n if (ignoreCache) {\n investorCache.delete(cacheKey);\n investorPromiseCache.delete(cacheKey);\n }\n // Check if the investor is already in the cache\n const cachedInvestor = investorCache.get(cacheKey);\n if (cachedInvestor) {\n return cachedInvestor;\n }\n\n // Check if there is already a promise in the cache\n let cetusInvestorPromise = investorPromiseCache.get(cacheKey);\n if (cetusInvestorPromise) {\n return cetusInvestorPromise;\n }\n // If not, create a new promise and cache it\n cetusInvestorPromise = (async () => {\n try {\n const o = await suiClient.getObject({\n id: poolInfo[poolName.toUpperCase()].investorId,\n options: {\n showContent: true,\n },\n });\n let cetusInvestor;\n if (poolInfo[poolName].parentProtocolName == \"NAVI\") {\n cetusInvestor = o.data as NaviInvestor & CommonInvestorFields;\n } else if (poolInfo[poolName].parentProtocolName == \"BUCKET\") {\n cetusInvestor = o.data as BucketInvestor & CommonInvestorFields;\n } else if (poolInfo[poolName].parentProtocolName == \"BLUEFIN\") {\n cetusInvestor = o.data as BluefinInvestor & CommonInvestorFields;\n } else {\n cetusInvestor = o.data as CetusInvestor & CommonInvestorFields;\n }\n\n // Cache the investor object\n investorCache.set(cacheKey, cetusInvestor);\n return cetusInvestor;\n } catch (err) {\n console.error(`getInvestor failed for pool: ${poolName}`);\n throw err;\n } finally {\n // Remove the promise from the cache after it resolves\n investorPromiseCache.delete(cacheKey);\n }\n })();\n\n // Cache the promise\n investorPromiseCache.set(cacheKey, cetusInvestorPromise);\n return cetusInvestorPromise;\n}\n\nexport async function fetchVoloExchangeRate(): Promise<NaviVoloData> {\n const apiUrl = \"https://open-api.naviprotocol.io/api/volo/stats\";\n const NaviVoloDetails: NaviVoloData = await fetch(apiUrl)\n .then(async (response) => {\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n const data = (await response.json()) as NaviVoloData; // Parse the JSON response\n return data;\n })\n .catch((error) => {\n console.log(\"failed to fetch Navi-volo details\", error);\n throw error;\n });\n return NaviVoloDetails;\n}\n\nexport async function getCoinAmountsFromLiquidity(\n poolName: PoolName,\n liquidity: string,\n ignoreCache: boolean,\n): Promise<[string, string]> {\n const clmmPool = await getParentPool(poolName, ignoreCache);\n const investor = (await getInvestor(poolName, ignoreCache)) as CetusInvestor &\n CommonInvestorFields;\n\n const upper_bound = 443636;\n let lower_tick = Number(investor!.content.fields.lower_tick);\n let upper_tick = Number(investor!.content.fields.upper_tick);\n\n if (lower_tick > upper_bound) {\n lower_tick = -~(lower_tick - 1);\n }\n if (upper_tick > upper_bound) {\n upper_tick = -~(upper_tick - 1);\n }\n if (clmmPool) {\n const liquidityInt = Math.floor(parseFloat(liquidity));\n const coin_amounts: CoinAmounts = ClmmPoolUtil.getCoinAmountFromLiquidity(\n new BN(`${liquidityInt}`),\n new BN(clmmPool.content.fields.current_sqrt_price),\n TickMath.tickIndexToSqrtPriceX64(lower_tick),\n TickMath.tickIndexToSqrtPriceX64(upper_tick),\n true,\n );\n return [coin_amounts.coinA.toString(), coin_amounts.coinB.toString()];\n } else {\n return [\"0\", \"0\"];\n }\n}\n\nexport async function multiGetNaviInvestor(poolNames: SingleAssetPoolNames[]) {\n const results: {\n [poolName in SingleAssetPoolNames]?:\n | (NaviInvestor & CommonInvestorFields)\n | undefined;\n } = {};\n const poolInvestorIds: string[] = [];\n\n for (const poolName of poolNames) {\n poolInvestorIds.push(poolInfo[poolName.toUpperCase()].investorId);\n }\n try {\n const suiClient = getSuiClient();\n const objects = await suiClient.multiGetObjects({\n ids: poolInvestorIds,\n options: { showContent: true },\n });\n for (let i = 0; i < objects.length; i++) {\n const investor = objects[i].data as NaviInvestor & CommonInvestorFields;\n results[poolNames[i]] = investor;\n }\n return results;\n } catch (err) {\n //improve\n console.error(\n \"multiGetNaviInvestor failed for poolNames: \",\n poolNames.join(\", \"),\n );\n throw err;\n }\n}\n\nconst distributorCache = new SimpleCache<Distributor>();\nconst distributorPromiseCache = new SimpleCache<\n Promise<Distributor | undefined>\n>();\n\nexport async function getDistributor(\n ignoreCache: boolean,\n): Promise<Distributor | undefined> {\n const suiClient = getSuiClient();\n const cacheKey = `distributor_${getConf().ALPHA_DISTRIBUTOR}`;\n if (ignoreCache) {\n distributorCache.delete(cacheKey);\n distributorPromiseCache.delete(cacheKey);\n }\n // Check if the distributor is already in the cache\n const cachedDistributor = distributorCache.get(cacheKey);\n if (cachedDistributor) {\n return cachedDistributor;\n }\n\n // Check if there is already a promise in the cache\n let distributorPromise = distributorPromiseCache.get(cacheKey);\n if (distributorPromise) {\n return distributorPromise;\n }\n\n // If not, create a new promise and cache it\n distributorPromise = (async () => {\n try {\n const o = await suiClient.getObject({\n id: getConf().ALPHA_DISTRIBUTOR,\n options: {\n showContent: true,\n },\n });\n const distributor = o.data as Distributor;\n\n // Cache the distributor object\n distributorCache.set(cacheKey, distributor);\n return distributor;\n } catch (e) {\n console.error(`getDistributor failed`);\n return undefined;\n } finally {\n // Remove the promise from the cache after it resolves\n distributorPromiseCache.delete(cacheKey);\n }\n })();\n\n // Cache the promise\n distributorPromiseCache.set(cacheKey, distributorPromise);\n return distributorPromise;\n}\n\n/*\nfor the missing pools, add a promise, each of those promises waits for there respective object from a map, that map is populated all at once, \nproblem with concurrency\n*/\n// ask how to deal with this kind of probem with high concurrency anf throughput\n"]}
@@ -1,4 +1,4 @@
1
1
  import { Transaction } from "@mysten/sui/transactions";
2
- export declare const depositAlphaTxb: (amount: string | number, address: string) => Promise<Transaction>;
3
- export declare const withdrawAlphaTxb: (amount: string | number, withdrawFromLocked: boolean, address: string) => Promise<Transaction>;
2
+ export declare const depositAlphaTxb: (amount: string, address: string) => Promise<Transaction>;
3
+ export declare const withdrawAlphaTxb: (xTokens: string, withdrawFromLocked: boolean, address: string) => Promise<Transaction>;
4
4
  //# sourceMappingURL=alpha.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.d.ts","sourceRoot":"","sources":["../../../src/transactions/alpha.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD,eAAO,MAAM,eAAe,WAClB,MAAM,GAAG,MAAM,WACd,MAAM,KACd,OAAO,CAAC,WAAW,CAiFrB,CAAC;AAEF,eAAO,MAAM,gBAAgB,WACnB,MAAM,GAAG,MAAM,sBACH,OAAO,WAClB,MAAM,KACd,OAAO,CAAC,WAAW,CAqBrB,CAAC"}
1
+ {"version":3,"file":"alpha.d.ts","sourceRoot":"","sources":["../../../src/transactions/alpha.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD,eAAO,MAAM,eAAe,WAClB,MAAM,WACL,MAAM,KACd,OAAO,CAAC,WAAW,CAiFrB,CAAC;AAEF,eAAO,MAAM,gBAAgB,YAClB,MAAM,sBACK,OAAO,WAClB,MAAM,KACd,OAAO,CAAC,WAAW,CAqBrB,CAAC"}
@@ -77,7 +77,7 @@ const depositAlphaTxb = async (amount, address) => {
77
77
  }
78
78
  };
79
79
  exports.depositAlphaTxb = depositAlphaTxb;
80
- const withdrawAlphaTxb = async (amount, withdrawFromLocked, address) => {
80
+ const withdrawAlphaTxb = async (xTokens, withdrawFromLocked, address) => {
81
81
  const txb = new transactions_1.Transaction();
82
82
  const receipt = await (0, index_js_1.getReceipts)("ALPHA", address, true);
83
83
  if (receipt.length > 0) {
@@ -89,7 +89,7 @@ const withdrawAlphaTxb = async (amount, withdrawFromLocked, address) => {
89
89
  txb.object(receipt[0].objectId),
90
90
  txb.object((0, index_js_1.getConf)().ALPHA_POOL),
91
91
  txb.object((0, index_js_1.getConf)().ALPHA_DISTRIBUTOR),
92
- txb.pure.u64(amount),
92
+ txb.pure.u64(xTokens),
93
93
  txb.object((0, index_js_1.getConf)().CLOCK_PACKAGE_ID),
94
94
  txb.pure.bool(withdrawFromLocked),
95
95
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"alpha.js","sourceRoot":"","sources":["../../../src/transactions/alpha.ts"],"names":[],"mappings":";;;AAAA,2DAAuD;AAEvD,0CAA0E;AAEnE,MAAM,eAAe,GAAG,KAAK,EAClC,MAAuB,EACvB,OAAe,EACO,EAAE;IACxB,MAAM,SAAS,GAAG,IAAA,uBAAY,GAAE,CAAC;IACjC,MAAM,GAAG,GAAG,IAAI,0BAAW,EAAE,CAAC;IAE9B,IAAI,KAAK,GAAiB,EAAE,CAAC;IAE7B,MAAM,OAAO,GAAc,MAAM,IAAA,sBAAW,EAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAErE,IAAI,aAAa,GAA8B,IAAI,CAAC;IAEpD,GAAG,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC;YACxC,KAAK,EAAE,OAAO;YACd,QAAQ,EAAE,IAAA,kBAAO,GAAE,CAAC,eAAe;YACnC,MAA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AgB,oBAyB3B","sourcesContent":["import { Transaction } from \"@mysten/sui/transactions\";\nimport { CoinStruct } from \"@mysten/sui/client\";\nimport { getConf, getReceipts, getSuiClient, Receipt } from \"../index.js\";\n\nexport const depositAlphaTxb = async (\n amount: string | number,\n address: string,\n): Promise<Transaction> => {\n const suiClient = getSuiClient();\n const txb = new Transaction();\n\n let coins: CoinStruct[] = [];\n\n const receipt: Receipt[] = await getReceipts(\"ALPHA\", address, true);\n\n let currentCursor: string | null | undefined = null;\n\n do {\n const response = await suiClient.getCoins({\n owner: address,\n coinType: getConf().ALPHA_COIN_TYPE,\n cursor: currentCursor,\n });\n\n coins = coins.concat(response.data);\n\n // Check if there's a next page\n if (response.hasNextPage && response.nextCursor) {\n currentCursor = response.nextCursor;\n } else {\n // No more pages available\n // console.log(\"No more receipts available.\");\n break;\n }\n } while (true);\n\n let coin: any;\n\n if (coins.length >= 1) {\n [coin] = txb.splitCoins(txb.object(coins[0].coinObjectId), [0]);\n txb.mergeCoins(\n coin,\n coins.map((c) => c.coinObjectId),\n );\n const [depositCoin] = txb.splitCoins(coin, [amount]);\n txb.transferObjects([coin], address);\n\n if (receipt.length == 0) {\n const [receipt] = txb.moveCall({\n target: `0x1::option::none`,\n typeArguments: [getConf().ALPHA_POOL_RECEIPT],\n arguments: [],\n });\n txb.moveCall({\n target: `${getConf().ALPHA_LATEST_PACKAGE_ID}::alphapool::user_deposit`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n txb.object(getConf().VERSION),\n receipt,\n txb.object(getConf().ALPHA_POOL),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n depositCoin,\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n } else {\n const [someReceipt] = txb.moveCall({\n target: `0x1::option::some`,\n typeArguments: [getConf().ALPHA_POOL_RECEIPT],\n arguments: [txb.object(receipt[0].objectId)],\n });\n txb.moveCall({\n target: `${getConf().ALPHA_LATEST_PACKAGE_ID}::alphapool::user_deposit`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n txb.object(getConf().VERSION),\n someReceipt,\n txb.object(getConf().ALPHA_POOL),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n depositCoin,\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n }\n return txb;\n } else {\n throw new Error(\"No Alpha Coins\");\n }\n};\n\nexport const withdrawAlphaTxb = async (\n amount: string | number,\n withdrawFromLocked: boolean,\n address: string,\n): Promise<Transaction> => {\n const txb = new Transaction();\n const receipt: Receipt[] = await getReceipts(\"ALPHA\", address, true);\n if (receipt.length > 0) {\n txb.moveCall({\n target: `${getConf().ALPHA_LATEST_PACKAGE_ID}::alphapool::user_withdraw`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n txb.object(getConf().VERSION),\n txb.object(receipt[0].objectId),\n txb.object(getConf().ALPHA_POOL),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.pure.u64(amount),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n txb.pure.bool(withdrawFromLocked),\n ],\n });\n return txb;\n } else {\n throw new Error(\"No receipt found!\");\n }\n};\n"]}
1
+ {"version":3,"file":"alpha.js","sourceRoot":"","sources":["../../../src/transactions/alpha.ts"],"names":[],"mappings":";;;AAAA,2DAAuD;AAEvD,0CAA0E;AAEnE,MAAM,eAAe,GAAG,KAAK,EAClC,MAAc,EACd,OAAe,EACO,EAAE;IACxB,MAAM,SAAS,GAAG,IAAA,uBAAY,GAAE,CAAC;IACjC,MAAM,GAAG,GAAG,IAAI,0BAAW,EAAE,CAAC;IAE9B,IAAI,KAAK,GAAiB,EAAE,CAAC;IAE7B,MAAM,OAAO,GAAc,MAAM,IAAA,sBAAW,EAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAErE,IAAI,aAAa,GAA8B,IAAI,CAAC;IAEpD,GAAG,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC;YAC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KAAK,CAAC,mBAAmB,CAAC,CAAC;IACvC,CAAC;AACH,CAAC,CAAC;AAzBW,QAAA,gBAAgB,oBAyB3B","sourcesContent":["import { Transaction } from \"@mysten/sui/transactions\";\nimport { CoinStruct } from \"@mysten/sui/client\";\nimport { getConf, getReceipts, getSuiClient, Receipt } from \"../index.js\";\n\nexport const depositAlphaTxb = async (\n amount: string,\n address: string,\n): Promise<Transaction> => {\n const suiClient = getSuiClient();\n const txb = new Transaction();\n\n let coins: CoinStruct[] = [];\n\n const receipt: Receipt[] = await getReceipts(\"ALPHA\", address, true);\n\n let currentCursor: string | null | undefined = null;\n\n do {\n const response = await suiClient.getCoins({\n owner: address,\n coinType: getConf().ALPHA_COIN_TYPE,\n cursor: currentCursor,\n });\n\n coins = coins.concat(response.data);\n\n // Check if there's a next page\n if (response.hasNextPage && response.nextCursor) {\n currentCursor = response.nextCursor;\n } else {\n // No more pages available\n // console.log(\"No more receipts available.\");\n break;\n }\n } while (true);\n\n let coin: any;\n\n if (coins.length >= 1) {\n [coin] = txb.splitCoins(txb.object(coins[0].coinObjectId), [0]);\n txb.mergeCoins(\n coin,\n coins.map((c) => c.coinObjectId),\n );\n const [depositCoin] = txb.splitCoins(coin, [amount]);\n txb.transferObjects([coin], address);\n\n if (receipt.length == 0) {\n const [receipt] = txb.moveCall({\n target: `0x1::option::none`,\n typeArguments: [getConf().ALPHA_POOL_RECEIPT],\n arguments: [],\n });\n txb.moveCall({\n target: `${getConf().ALPHA_LATEST_PACKAGE_ID}::alphapool::user_deposit`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n txb.object(getConf().VERSION),\n receipt,\n txb.object(getConf().ALPHA_POOL),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n depositCoin,\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n } else {\n const [someReceipt] = txb.moveCall({\n target: `0x1::option::some`,\n typeArguments: [getConf().ALPHA_POOL_RECEIPT],\n arguments: [txb.object(receipt[0].objectId)],\n });\n txb.moveCall({\n target: `${getConf().ALPHA_LATEST_PACKAGE_ID}::alphapool::user_deposit`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n txb.object(getConf().VERSION),\n someReceipt,\n txb.object(getConf().ALPHA_POOL),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n depositCoin,\n txb.object(getConf().CLOCK_PACKAGE_ID),\n ],\n });\n }\n return txb;\n } else {\n throw new Error(\"No Alpha Coins\");\n }\n};\n\nexport const withdrawAlphaTxb = async (\n xTokens: string,\n withdrawFromLocked: boolean,\n address: string,\n): Promise<Transaction> => {\n const txb = new Transaction();\n const receipt: Receipt[] = await getReceipts(\"ALPHA\", address, true);\n if (receipt.length > 0) {\n txb.moveCall({\n target: `${getConf().ALPHA_LATEST_PACKAGE_ID}::alphapool::user_withdraw`,\n typeArguments: [getConf().ALPHA_COIN_TYPE],\n arguments: [\n txb.object(getConf().VERSION),\n txb.object(receipt[0].objectId),\n txb.object(getConf().ALPHA_POOL),\n txb.object(getConf().ALPHA_DISTRIBUTOR),\n txb.pure.u64(xTokens),\n txb.object(getConf().CLOCK_PACKAGE_ID),\n txb.pure.bool(withdrawFromLocked),\n ],\n });\n return txb;\n } else {\n throw new Error(\"No receipt found!\");\n }\n};\n"]}
@@ -6,10 +6,16 @@ export declare const depositBluefinSuiFirstTxb: (amount: string, poolName: PoolN
6
6
  export declare const depositBluefinType1Txb: (amount: string, poolName: PoolName, isAmountA: boolean, options: {
7
7
  address: string;
8
8
  }, transaction?: Transaction | undefined) => Promise<Transaction>;
9
- export declare const withdrawBluefinSuiFirstTxb: (amount: string | number, poolName: PoolName, options: {
9
+ export declare const depositBluefinType2Txb: (amount: string, poolName: PoolName, isAmountA: boolean, options: {
10
+ address: string;
11
+ }, transaction?: Transaction | undefined) => Promise<Transaction>;
12
+ export declare const withdrawBluefinSuiFirstTxb: (xTokens: string, poolName: PoolName, options: {
13
+ address: string;
14
+ }) => Promise<Transaction>;
15
+ export declare const withdrawBluefinType1Txb: (xTokens: string, poolName: PoolName, options: {
10
16
  address: string;
11
17
  }) => Promise<Transaction>;
12
- export declare const withdrawBluefinType1Txb: (amount: string | number, poolName: PoolName, options: {
18
+ export declare const withdrawBluefinType2Txb: (xTokens: string, poolName: PoolName, options: {
13
19
  address: string;
14
20
  }) => Promise<Transaction>;
15
21
  //# sourceMappingURL=bluefin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bluefin.d.ts","sourceRoot":"","sources":["../../../src/transactions/bluefin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AASvD,OAAO,EAAE,QAAQ,EAAW,MAAM,oBAAoB,CAAC;AAKvD,eAAO,MAAM,yBAAyB,WAC5B,MAAM,YACJ,QAAQ,aACP,OAAO,WACT;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,gBACf,WAAW,GAAG,SAAS,KACnC,OAAO,CAAC,WAAW,CAiIrB,CAAC;AAEF,eAAO,MAAM,sBAAsB,WACzB,MAAM,YACJ,QAAQ,aACP,OAAO,WACT;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,gBACf,WAAW,GAAG,SAAS,KACnC,OAAO,CAAC,WAAW,CA8JrB,CAAC;AAEF,eAAO,MAAM,0BAA0B,WAC7B,MAAM,GAAG,MAAM,YACb,QAAQ,WACT;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,yBAuF7B,CAAC;AAEF,eAAO,MAAM,uBAAuB,WAC1B,MAAM,GAAG,MAAM,YACb,QAAQ,WACT;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,yBAyF7B,CAAC"}
1
+ {"version":3,"file":"bluefin.d.ts","sourceRoot":"","sources":["../../../src/transactions/bluefin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AASvD,OAAO,EAAE,QAAQ,EAAW,MAAM,oBAAoB,CAAC;AAKvD,eAAO,MAAM,yBAAyB,WAC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