@scallop-io/sui-scallop-sdk 1.3.4-alpha.5 → 1.3.4-alpha.6

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 (126) hide show
  1. package/dist/index.js +96 -96
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs +96 -96
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +2 -2
  6. package/src/builders/borrowIncentiveBuilder.ts +8 -8
  7. package/src/builders/coreBuilder.ts +5 -5
  8. package/src/builders/index.ts +2 -2
  9. package/src/builders/oracle.ts +4 -4
  10. package/src/builders/referralBuilder.ts +1 -1
  11. package/src/builders/spoolBuilder.ts +6 -6
  12. package/src/builders/vescaBuilder.ts +4 -4
  13. package/src/constants/coinGecko.ts +1 -1
  14. package/src/constants/enum.ts +1 -1
  15. package/src/constants/index.ts +1 -1
  16. package/src/models/scallop.ts +5 -5
  17. package/src/models/scallopAddress.ts +6 -9
  18. package/src/models/scallopBuilder.ts +5 -4
  19. package/src/models/scallopCache.ts +4 -4
  20. package/src/models/scallopClient.ts +4 -4
  21. package/src/models/scallopIndexer.ts +4 -3
  22. package/src/models/scallopQuery.ts +4 -8
  23. package/src/models/scallopUtils.ts +8 -11
  24. package/src/models/suiKit.ts +1 -1
  25. package/src/queries/borrowIncentiveQuery.ts +5 -5
  26. package/src/queries/coreQuery.ts +4 -4
  27. package/src/queries/isolatedAssetQuery.ts +2 -2
  28. package/src/queries/portfolioQuery.ts +4 -4
  29. package/src/queries/priceQuery.ts +2 -2
  30. package/src/queries/spoolQuery.ts +5 -5
  31. package/src/queries/supplyLimitQuery.ts +2 -2
  32. package/src/queries/vescaQuery.ts +2 -2
  33. package/src/types/address.ts +1 -1
  34. package/src/types/builder/borrowIncentive.ts +3 -3
  35. package/src/types/builder/core.ts +3 -3
  36. package/src/types/builder/index.ts +4 -5
  37. package/src/types/builder/referral.ts +1 -1
  38. package/src/types/builder/sCoin.ts +1 -1
  39. package/src/types/builder/spool.ts +2 -2
  40. package/src/types/constant/common.ts +1 -1
  41. package/src/types/model.ts +2 -2
  42. package/src/types/query/borrowIncentive.ts +2 -2
  43. package/src/types/query/core.ts +1 -1
  44. package/src/types/query/portfolio.ts +2 -2
  45. package/src/types/query/spool.ts +1 -1
  46. package/src/utils/builder.ts +1 -1
  47. package/src/utils/index.ts +2 -2
  48. package/src/utils/query.ts +3 -3
  49. package/src/utils/tokenBucket.ts +1 -1
  50. package/src/utils/util.ts +4 -4
  51. package/dist/builders/borrowIncentiveBuilder.d.ts +0 -12
  52. package/dist/builders/coreBuilder.d.ts +0 -12
  53. package/dist/builders/index.d.ts +0 -12
  54. package/dist/builders/loyaltyProgramBuilder.d.ts +0 -12
  55. package/dist/builders/oracle.d.ts +0 -14
  56. package/dist/builders/referralBuilder.d.ts +0 -12
  57. package/dist/builders/sCoinBuilder.d.ts +0 -4
  58. package/dist/builders/spoolBuilder.d.ts +0 -12
  59. package/dist/builders/vescaBuilder.d.ts +0 -25
  60. package/dist/constants/cache.d.ts +0 -14
  61. package/dist/constants/coinGecko.d.ts +0 -2
  62. package/dist/constants/common.d.ts +0 -20
  63. package/dist/constants/enum.d.ts +0 -14
  64. package/dist/constants/flashloan.d.ts +0 -2
  65. package/dist/constants/index.d.ts +0 -12
  66. package/dist/constants/poolAddress.d.ts +0 -5
  67. package/dist/constants/pyth.d.ts +0 -5
  68. package/dist/constants/queryKeys.d.ts +0 -56
  69. package/dist/constants/rpc.d.ts +0 -1
  70. package/dist/constants/testAddress.d.ts +0 -2
  71. package/dist/constants/tokenBucket.d.ts +0 -2
  72. package/dist/constants/vesca.d.ts +0 -5
  73. package/dist/index.d.ts +0 -3
  74. package/dist/models/index.d.ts +0 -8
  75. package/dist/models/scallop.d.ts +0 -74
  76. package/dist/models/scallopAddress.d.ts +0 -150
  77. package/dist/models/scallopBuilder.d.ts +0 -89
  78. package/dist/models/scallopCache.d.ts +0 -74
  79. package/dist/models/scallopClient.d.ts +0 -321
  80. package/dist/models/scallopIndexer.d.ts +0 -89
  81. package/dist/models/scallopQuery.d.ts +0 -489
  82. package/dist/models/scallopUtils.d.ts +0 -227
  83. package/dist/models/suiKit.d.ts +0 -2
  84. package/dist/queries/borrowIncentiveQuery.d.ts +0 -61
  85. package/dist/queries/coreQuery.d.ts +0 -167
  86. package/dist/queries/index.d.ts +0 -11
  87. package/dist/queries/isolatedAssetQuery.d.ts +0 -14
  88. package/dist/queries/loyaltyProgramQuery.d.ts +0 -10
  89. package/dist/queries/portfolioQuery.d.ts +0 -73
  90. package/dist/queries/priceQuery.d.ts +0 -16
  91. package/dist/queries/referralQuery.d.ts +0 -7
  92. package/dist/queries/sCoinQuery.d.ts +0 -41
  93. package/dist/queries/spoolQuery.d.ts +0 -70
  94. package/dist/queries/supplyLimitQuery.d.ts +0 -9
  95. package/dist/queries/vescaQuery.d.ts +0 -36
  96. package/dist/test.d.ts +0 -0
  97. package/dist/types/address.d.ts +0 -107
  98. package/dist/types/builder/borrowIncentive.d.ts +0 -35
  99. package/dist/types/builder/core.d.ts +0 -56
  100. package/dist/types/builder/index.d.ts +0 -25
  101. package/dist/types/builder/loyaltyProgram.d.ts +0 -23
  102. package/dist/types/builder/referral.d.ts +0 -30
  103. package/dist/types/builder/sCoin.d.ts +0 -37
  104. package/dist/types/builder/spool.d.ts +0 -29
  105. package/dist/types/builder/vesca.d.ts +0 -51
  106. package/dist/types/constant/common.d.ts +0 -24
  107. package/dist/types/constant/enum.d.ts +0 -48
  108. package/dist/types/constant/index.d.ts +0 -2
  109. package/dist/types/index.d.ts +0 -6
  110. package/dist/types/model.d.ts +0 -54
  111. package/dist/types/query/borrowIncentive.d.ts +0 -124
  112. package/dist/types/query/core.d.ts +0 -361
  113. package/dist/types/query/index.d.ts +0 -7
  114. package/dist/types/query/loyaltyProgram.d.ts +0 -5
  115. package/dist/types/query/portfolio.d.ts +0 -115
  116. package/dist/types/query/sCoin.d.ts +0 -1
  117. package/dist/types/query/spool.d.ts +0 -122
  118. package/dist/types/query/vesca.d.ts +0 -26
  119. package/dist/types/utils.d.ts +0 -21
  120. package/dist/utils/builder.d.ts +0 -15
  121. package/dist/utils/index.d.ts +0 -5
  122. package/dist/utils/indexer.d.ts +0 -17
  123. package/dist/utils/query.d.ts +0 -62
  124. package/dist/utils/tokenBucket.d.ts +0 -11
  125. package/dist/utils/util.d.ts +0 -26
  126. package/src/test.ts +0 -30
package/dist/index.mjs CHANGED
@@ -480,6 +480,23 @@ var queryKeys = {
480
480
  }
481
481
  };
482
482
 
483
+ // src/constants/rpc.ts
484
+ import { getFullnodeUrl } from "@mysten/sui/client";
485
+ var RPC_PROVIDERS = [
486
+ getFullnodeUrl("mainnet"),
487
+ "https://sui-mainnet.public.blastapi.io",
488
+ "https://sui-mainnet-ca-2.cosmostation.io",
489
+ "https://sui-mainnet-eu-4.cosmostation.io",
490
+ "https://sui-mainnet-endpoint.blockvision.org",
491
+ "https://sui-rpc.publicnode.com",
492
+ "https://sui-mainnet-rpc.allthatnode.com",
493
+ "https://mainnet.suiet.app",
494
+ "https://mainnet.sui.rpcpool.com",
495
+ "https://sui1mainnet-rpc.chainode.tech",
496
+ "https://fullnode.mainnet.apis.scallop.io",
497
+ "https://sui-mainnet-us-2.cosmostation.io"
498
+ ];
499
+
483
500
  // src/constants/testAddress.ts
484
501
  var TEST_ADDRESSES = {
485
502
  core: {
@@ -881,23 +898,6 @@ var MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION;
881
898
  var MIN_INITIAL_LOCK_AMOUNT = 1e10;
882
899
  var MIN_TOP_UP_AMOUNT = 1e9;
883
900
 
884
- // src/constants/rpc.ts
885
- import { getFullnodeUrl } from "@mysten/sui/client";
886
- var RPC_PROVIDERS = [
887
- getFullnodeUrl("mainnet"),
888
- "https://sui-mainnet.public.blastapi.io",
889
- "https://sui-mainnet-ca-2.cosmostation.io",
890
- "https://sui-mainnet-eu-4.cosmostation.io",
891
- "https://sui-mainnet-endpoint.blockvision.org",
892
- "https://sui-rpc.publicnode.com",
893
- "https://sui-mainnet-rpc.allthatnode.com",
894
- "https://mainnet.suiet.app",
895
- "https://mainnet.sui.rpcpool.com",
896
- "https://sui1mainnet-rpc.chainode.tech",
897
- "https://fullnode.mainnet.apis.scallop.io",
898
- "https://sui-mainnet-us-2.cosmostation.io"
899
- ];
900
-
901
901
  // src/models/scallopAddress.ts
902
902
  import { SuiKit } from "@scallop-io/sui-kit";
903
903
 
@@ -1011,25 +1011,6 @@ var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays, prevUnlockAtInMillisT
1011
1011
  }
1012
1012
  };
1013
1013
 
1014
- // src/utils/indexer.ts
1015
- async function callMethodWithIndexerFallback(method, context, ...args) {
1016
- const indexer = args[args.length - 1];
1017
- if (indexer) {
1018
- try {
1019
- return await method.apply(context, args);
1020
- } catch (e) {
1021
- console.warn(`Indexer requests failed: ${e}. Retrying without indexer..`);
1022
- return await method.apply(context, [...args.slice(0, -1), false]);
1023
- }
1024
- }
1025
- return await method.apply(context, args);
1026
- }
1027
- function withIndexerFallback(method) {
1028
- return (...args) => {
1029
- return callMethodWithIndexerFallback(method, this, ...args);
1030
- };
1031
- }
1032
-
1033
1014
  // src/utils/query.ts
1034
1015
  import BigNumber from "bignumber.js";
1035
1016
  import { normalizeStructTag, parseStructTag } from "@mysten/sui/utils";
@@ -1414,66 +1395,6 @@ var estimatedFactor = (amount, scaleStep, type) => {
1414
1395
  return adjustFactor;
1415
1396
  };
1416
1397
 
1417
- // src/utils/tokenBucket.ts
1418
- var TokenBucket = class {
1419
- constructor(tokensPerInterval, intervalInMs) {
1420
- this.tokensPerInterval = tokensPerInterval;
1421
- this.interval = intervalInMs;
1422
- this.tokens = tokensPerInterval;
1423
- this.lastRefill = Date.now();
1424
- }
1425
- refill() {
1426
- const now = Date.now();
1427
- const elapsed = now - this.lastRefill;
1428
- if (elapsed > this.interval) {
1429
- const tokensToAdd = Math.floor(elapsed / this.interval) * this.tokensPerInterval;
1430
- this.tokens = Math.min(this.tokens + tokensToAdd, this.tokensPerInterval);
1431
- this.lastRefill = now;
1432
- }
1433
- }
1434
- removeTokens(count) {
1435
- this.refill();
1436
- if (this.tokens >= count) {
1437
- this.tokens -= count;
1438
- return true;
1439
- }
1440
- return false;
1441
- }
1442
- };
1443
- var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVAL_IN_MS, maxRetries = 30, backoffFactor = 1.25) => {
1444
- let retries = 0;
1445
- const tryRequest = async () => {
1446
- if (tokenBucket.removeTokens(1)) {
1447
- try {
1448
- const result = await fn();
1449
- if (result && result.status === 429) {
1450
- throw new Error("Unexpected status code: 429");
1451
- }
1452
- return result;
1453
- } catch (error) {
1454
- if (error.message === "Unexpected status code: 429" && retries < maxRetries) {
1455
- retries++;
1456
- const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
1457
- await new Promise((resolve) => setTimeout(resolve, delay));
1458
- return tryRequest();
1459
- } else {
1460
- console.error("An error occurred:", error.message);
1461
- return null;
1462
- }
1463
- }
1464
- } else if (retries < maxRetries) {
1465
- retries++;
1466
- const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
1467
- await new Promise((resolve) => setTimeout(resolve, delay));
1468
- return tryRequest();
1469
- } else {
1470
- console.error("Maximum retries reached");
1471
- return null;
1472
- }
1473
- };
1474
- return tryRequest();
1475
- };
1476
-
1477
1398
  // src/utils/util.ts
1478
1399
  var COIN_SET = Array.from(
1479
1400
  /* @__PURE__ */ new Set([
@@ -1546,6 +1467,85 @@ var findClosestUnlockRound = (unlockAtInSecondTimestamp) => {
1546
1467
  return Math.floor(closestTwelveAM.getTime() / 1e3);
1547
1468
  };
1548
1469
 
1470
+ // src/utils/tokenBucket.ts
1471
+ var TokenBucket = class {
1472
+ constructor(tokensPerInterval, intervalInMs) {
1473
+ this.tokensPerInterval = tokensPerInterval;
1474
+ this.interval = intervalInMs;
1475
+ this.tokens = tokensPerInterval;
1476
+ this.lastRefill = Date.now();
1477
+ }
1478
+ refill() {
1479
+ const now = Date.now();
1480
+ const elapsed = now - this.lastRefill;
1481
+ if (elapsed > this.interval) {
1482
+ const tokensToAdd = Math.floor(elapsed / this.interval) * this.tokensPerInterval;
1483
+ this.tokens = Math.min(this.tokens + tokensToAdd, this.tokensPerInterval);
1484
+ this.lastRefill = now;
1485
+ }
1486
+ }
1487
+ removeTokens(count) {
1488
+ this.refill();
1489
+ if (this.tokens >= count) {
1490
+ this.tokens -= count;
1491
+ return true;
1492
+ }
1493
+ return false;
1494
+ }
1495
+ };
1496
+ var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVAL_IN_MS, maxRetries = 30, backoffFactor = 1.25) => {
1497
+ let retries = 0;
1498
+ const tryRequest = async () => {
1499
+ if (tokenBucket.removeTokens(1)) {
1500
+ try {
1501
+ const result = await fn();
1502
+ if (result && result.status === 429) {
1503
+ throw new Error("Unexpected status code: 429");
1504
+ }
1505
+ return result;
1506
+ } catch (error) {
1507
+ if (error.message === "Unexpected status code: 429" && retries < maxRetries) {
1508
+ retries++;
1509
+ const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
1510
+ await new Promise((resolve) => setTimeout(resolve, delay));
1511
+ return tryRequest();
1512
+ } else {
1513
+ console.error("An error occurred:", error.message);
1514
+ return null;
1515
+ }
1516
+ }
1517
+ } else if (retries < maxRetries) {
1518
+ retries++;
1519
+ const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
1520
+ await new Promise((resolve) => setTimeout(resolve, delay));
1521
+ return tryRequest();
1522
+ } else {
1523
+ console.error("Maximum retries reached");
1524
+ return null;
1525
+ }
1526
+ };
1527
+ return tryRequest();
1528
+ };
1529
+
1530
+ // src/utils/indexer.ts
1531
+ async function callMethodWithIndexerFallback(method, context, ...args) {
1532
+ const indexer = args[args.length - 1];
1533
+ if (indexer) {
1534
+ try {
1535
+ return await method.apply(context, args);
1536
+ } catch (e) {
1537
+ console.warn(`Indexer requests failed: ${e}. Retrying without indexer..`);
1538
+ return await method.apply(context, [...args.slice(0, -1), false]);
1539
+ }
1540
+ }
1541
+ return await method.apply(context, args);
1542
+ }
1543
+ function withIndexerFallback(method) {
1544
+ return (...args) => {
1545
+ return callMethodWithIndexerFallback(method, this, ...args);
1546
+ };
1547
+ }
1548
+
1549
1549
  // src/models/scallopCache.ts
1550
1550
  var ScallopCache = class {
1551
1551
  constructor(suiKit, walletAddress, cacheOptions, tokenBucket, queryClient) {