@scallop-io/sui-scallop-sdk 1.3.4-alpha.5 → 1.3.4-alpha.7
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.
- package/dist/builders/borrowIncentiveBuilder.d.ts +1 -1
- package/dist/builders/coreBuilder.d.ts +2 -2
- package/dist/builders/index.d.ts +2 -2
- package/dist/builders/oracle.d.ts +2 -2
- package/dist/builders/referralBuilder.d.ts +1 -1
- package/dist/builders/spoolBuilder.d.ts +2 -2
- package/dist/builders/vescaBuilder.d.ts +2 -2
- package/dist/constants/coinGecko.d.ts +1 -1
- package/dist/constants/enum.d.ts +1 -1
- package/dist/constants/index.d.ts +1 -1
- package/dist/index.js +96 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -96
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallop.d.ts +1 -1
- package/dist/models/scallopAddress.d.ts +1 -1
- package/dist/models/scallopBuilder.d.ts +1 -1
- package/dist/models/scallopClient.d.ts +8 -8
- package/dist/models/scallopIndexer.d.ts +1 -1
- package/dist/models/scallopQuery.d.ts +96 -96
- package/dist/models/scallopUtils.d.ts +2 -2
- package/dist/queries/borrowIncentiveQuery.d.ts +12 -12
- package/dist/queries/coreQuery.d.ts +2 -2
- package/dist/queries/isolatedAssetQuery.d.ts +2 -2
- package/dist/queries/portfolioQuery.d.ts +2 -2
- package/dist/queries/priceQuery.d.ts +2 -2
- package/dist/queries/spoolQuery.d.ts +2 -2
- package/dist/queries/supplyLimitQuery.d.ts +2 -2
- package/dist/queries/vescaQuery.d.ts +2 -2
- package/dist/types/address.d.ts +1 -1
- package/dist/types/builder/borrowIncentive.d.ts +2 -2
- package/dist/types/builder/core.d.ts +2 -2
- package/dist/types/builder/index.d.ts +4 -5
- package/dist/types/builder/referral.d.ts +1 -1
- package/dist/types/builder/sCoin.d.ts +1 -1
- package/dist/types/builder/spool.d.ts +2 -2
- package/dist/types/constant/common.d.ts +1 -1
- package/dist/types/model.d.ts +2 -2
- package/dist/types/query/borrowIncentive.d.ts +1 -1
- package/dist/types/query/core.d.ts +1 -1
- package/dist/types/query/portfolio.d.ts +1 -1
- package/dist/types/query/spool.d.ts +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/query.d.ts +2 -2
- package/dist/utils/util.d.ts +2 -2
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +8 -8
- package/src/builders/coreBuilder.ts +5 -5
- package/src/builders/index.ts +2 -2
- package/src/builders/oracle.ts +4 -4
- package/src/builders/referralBuilder.ts +1 -1
- package/src/builders/spoolBuilder.ts +6 -6
- package/src/builders/vescaBuilder.ts +4 -4
- package/src/constants/coinGecko.ts +1 -1
- package/src/constants/enum.ts +1 -1
- package/src/constants/index.ts +1 -1
- package/src/models/scallop.ts +5 -5
- package/src/models/scallopAddress.ts +6 -9
- package/src/models/scallopBuilder.ts +5 -4
- package/src/models/scallopCache.ts +4 -4
- package/src/models/scallopClient.ts +4 -4
- package/src/models/scallopIndexer.ts +4 -3
- package/src/models/scallopQuery.ts +4 -8
- package/src/models/scallopUtils.ts +8 -11
- package/src/models/suiKit.ts +1 -1
- package/src/queries/borrowIncentiveQuery.ts +5 -5
- package/src/queries/coreQuery.ts +4 -4
- package/src/queries/isolatedAssetQuery.ts +2 -2
- package/src/queries/portfolioQuery.ts +4 -4
- package/src/queries/priceQuery.ts +2 -2
- package/src/queries/spoolQuery.ts +5 -5
- package/src/queries/supplyLimitQuery.ts +2 -2
- package/src/queries/vescaQuery.ts +2 -2
- package/src/types/address.ts +1 -1
- package/src/types/builder/borrowIncentive.ts +3 -3
- package/src/types/builder/core.ts +3 -3
- package/src/types/builder/index.ts +4 -5
- package/src/types/builder/referral.ts +1 -1
- package/src/types/builder/sCoin.ts +1 -1
- package/src/types/builder/spool.ts +2 -2
- package/src/types/constant/common.ts +1 -1
- package/src/types/model.ts +2 -2
- package/src/types/query/borrowIncentive.ts +2 -2
- package/src/types/query/core.ts +1 -1
- package/src/types/query/portfolio.ts +2 -2
- package/src/types/query/spool.ts +1 -1
- package/src/utils/builder.ts +1 -1
- package/src/utils/index.ts +2 -2
- package/src/utils/query.ts +3 -3
- package/src/utils/tokenBucket.ts +1 -1
- package/src/utils/util.ts +4 -4
- package/dist/test.d.ts +0 -0
- package/src/test.ts +0 -30
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Transaction } from '@mysten/sui/transactions';
|
|
2
2
|
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
3
3
|
import type { ScallopBuilder } from 'src/models';
|
|
4
|
-
import {
|
|
4
|
+
import type { BorrowIncentiveTxBlock, ScallopTxBlock } from '../types';
|
|
5
5
|
/**
|
|
6
6
|
* Create an enhanced transaction block instance for interaction with borrow incentive modules of the Scallop contract.
|
|
7
7
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Transaction } from '@mysten/sui/transactions';
|
|
2
2
|
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
3
|
-
import type { ScallopBuilder } from '
|
|
4
|
-
import { CoreTxBlock, ScallopTxBlock, SuiTxBlockWithSpool } from '
|
|
3
|
+
import type { ScallopBuilder } from '../models';
|
|
4
|
+
import type { CoreTxBlock, ScallopTxBlock, SuiTxBlockWithSpool } from '../types';
|
|
5
5
|
/**
|
|
6
6
|
* Create an enhanced transaction block instance for interaction with core modules of the Scallop contract.
|
|
7
7
|
*
|
package/dist/builders/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Transaction } from '@mysten/sui/transactions';
|
|
2
2
|
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
3
|
-
import type { ScallopBuilder } from '
|
|
4
|
-
import { ScallopTxBlock } from '
|
|
3
|
+
import type { ScallopBuilder } from '../models';
|
|
4
|
+
import type { ScallopTxBlock } from '../types';
|
|
5
5
|
/**
|
|
6
6
|
* Create a new ScallopTxBlock instance.
|
|
7
7
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
2
|
-
import type { ScallopBuilder } from '
|
|
3
|
-
import { SupportAssetCoins } from '
|
|
2
|
+
import type { ScallopBuilder } from '../models';
|
|
3
|
+
import type { SupportAssetCoins } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Update the price of the oracle for multiple coin.
|
|
6
6
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ScallopBuilder } from 'src/models';
|
|
2
2
|
import { ScallopTxBlock } from 'src/types';
|
|
3
3
|
import { SuiTxBlock as SuiKitTxBlock, Transaction } from '@scallop-io/sui-kit';
|
|
4
|
-
import { ReferralTxBlock } from 'src/types';
|
|
4
|
+
import { ReferralTxBlock } from 'src/types/builder/referral';
|
|
5
5
|
/**
|
|
6
6
|
* Create an enhanced transaction block instance for interaction with borrow incentive modules of the Scallop contract.
|
|
7
7
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Transaction } from '@mysten/sui/transactions';
|
|
2
2
|
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
3
|
-
import type { ScallopBuilder } from '
|
|
4
|
-
import { SpoolTxBlock, ScallopTxBlock, SuiTxBlockWithSCoin } from '
|
|
3
|
+
import type { ScallopBuilder } from '../models';
|
|
4
|
+
import type { SpoolTxBlock, ScallopTxBlock, SuiTxBlockWithSCoin } from '../types';
|
|
5
5
|
/**
|
|
6
6
|
* Create an enhanced transaction block instance for interaction with spool modules of the Scallop contract.
|
|
7
7
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SuiTxBlock, Transaction, SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
2
|
-
import { ScallopBuilder } from '
|
|
2
|
+
import { ScallopBuilder } from '../models';
|
|
3
3
|
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
4
|
-
import { ScallopTxBlock, VeScaTxBlock } from 'src/types';
|
|
4
|
+
import type { ScallopTxBlock, VeScaTxBlock } from 'src/types';
|
|
5
5
|
/**
|
|
6
6
|
* Check and get veSCA data from transaction block.
|
|
7
7
|
*
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SupportPoolCoins } from 'src/types';
|
|
1
|
+
import { SupportPoolCoins } from 'src/types/constant/common';
|
|
2
2
|
export declare const COIN_GECKGO_IDS: Record<SupportPoolCoins, string>;
|
package/dist/constants/enum.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -572,6 +572,23 @@ var queryKeys = {
|
|
|
572
572
|
}
|
|
573
573
|
};
|
|
574
574
|
|
|
575
|
+
// src/constants/rpc.ts
|
|
576
|
+
var import_client = require("@mysten/sui/client");
|
|
577
|
+
var RPC_PROVIDERS = [
|
|
578
|
+
(0, import_client.getFullnodeUrl)("mainnet"),
|
|
579
|
+
"https://sui-mainnet.public.blastapi.io",
|
|
580
|
+
"https://sui-mainnet-ca-2.cosmostation.io",
|
|
581
|
+
"https://sui-mainnet-eu-4.cosmostation.io",
|
|
582
|
+
"https://sui-mainnet-endpoint.blockvision.org",
|
|
583
|
+
"https://sui-rpc.publicnode.com",
|
|
584
|
+
"https://sui-mainnet-rpc.allthatnode.com",
|
|
585
|
+
"https://mainnet.suiet.app",
|
|
586
|
+
"https://mainnet.sui.rpcpool.com",
|
|
587
|
+
"https://sui1mainnet-rpc.chainode.tech",
|
|
588
|
+
"https://fullnode.mainnet.apis.scallop.io",
|
|
589
|
+
"https://sui-mainnet-us-2.cosmostation.io"
|
|
590
|
+
];
|
|
591
|
+
|
|
575
592
|
// src/constants/testAddress.ts
|
|
576
593
|
var TEST_ADDRESSES = {
|
|
577
594
|
core: {
|
|
@@ -973,23 +990,6 @@ var MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION;
|
|
|
973
990
|
var MIN_INITIAL_LOCK_AMOUNT = 1e10;
|
|
974
991
|
var MIN_TOP_UP_AMOUNT = 1e9;
|
|
975
992
|
|
|
976
|
-
// src/constants/rpc.ts
|
|
977
|
-
var import_client = require("@mysten/sui/client");
|
|
978
|
-
var RPC_PROVIDERS = [
|
|
979
|
-
(0, import_client.getFullnodeUrl)("mainnet"),
|
|
980
|
-
"https://sui-mainnet.public.blastapi.io",
|
|
981
|
-
"https://sui-mainnet-ca-2.cosmostation.io",
|
|
982
|
-
"https://sui-mainnet-eu-4.cosmostation.io",
|
|
983
|
-
"https://sui-mainnet-endpoint.blockvision.org",
|
|
984
|
-
"https://sui-rpc.publicnode.com",
|
|
985
|
-
"https://sui-mainnet-rpc.allthatnode.com",
|
|
986
|
-
"https://mainnet.suiet.app",
|
|
987
|
-
"https://mainnet.sui.rpcpool.com",
|
|
988
|
-
"https://sui1mainnet-rpc.chainode.tech",
|
|
989
|
-
"https://fullnode.mainnet.apis.scallop.io",
|
|
990
|
-
"https://sui-mainnet-us-2.cosmostation.io"
|
|
991
|
-
];
|
|
992
|
-
|
|
993
993
|
// src/models/scallopAddress.ts
|
|
994
994
|
var import_sui_kit2 = require("@scallop-io/sui-kit");
|
|
995
995
|
|
|
@@ -1100,25 +1100,6 @@ var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays, prevUnlockAtInMillisT
|
|
|
1100
1100
|
}
|
|
1101
1101
|
};
|
|
1102
1102
|
|
|
1103
|
-
// src/utils/indexer.ts
|
|
1104
|
-
async function callMethodWithIndexerFallback(method, context, ...args) {
|
|
1105
|
-
const indexer = args[args.length - 1];
|
|
1106
|
-
if (indexer) {
|
|
1107
|
-
try {
|
|
1108
|
-
return await method.apply(context, args);
|
|
1109
|
-
} catch (e) {
|
|
1110
|
-
console.warn(`Indexer requests failed: ${e}. Retrying without indexer..`);
|
|
1111
|
-
return await method.apply(context, [...args.slice(0, -1), false]);
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
return await method.apply(context, args);
|
|
1115
|
-
}
|
|
1116
|
-
function withIndexerFallback(method) {
|
|
1117
|
-
return (...args) => {
|
|
1118
|
-
return callMethodWithIndexerFallback(method, this, ...args);
|
|
1119
|
-
};
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
1103
|
// src/utils/query.ts
|
|
1123
1104
|
var import_bignumber = __toESM(require("bignumber.js"));
|
|
1124
1105
|
var import_utils = require("@mysten/sui/utils");
|
|
@@ -1503,66 +1484,6 @@ var estimatedFactor = (amount, scaleStep, type) => {
|
|
|
1503
1484
|
return adjustFactor;
|
|
1504
1485
|
};
|
|
1505
1486
|
|
|
1506
|
-
// src/utils/tokenBucket.ts
|
|
1507
|
-
var TokenBucket = class {
|
|
1508
|
-
constructor(tokensPerInterval, intervalInMs) {
|
|
1509
|
-
this.tokensPerInterval = tokensPerInterval;
|
|
1510
|
-
this.interval = intervalInMs;
|
|
1511
|
-
this.tokens = tokensPerInterval;
|
|
1512
|
-
this.lastRefill = Date.now();
|
|
1513
|
-
}
|
|
1514
|
-
refill() {
|
|
1515
|
-
const now = Date.now();
|
|
1516
|
-
const elapsed = now - this.lastRefill;
|
|
1517
|
-
if (elapsed > this.interval) {
|
|
1518
|
-
const tokensToAdd = Math.floor(elapsed / this.interval) * this.tokensPerInterval;
|
|
1519
|
-
this.tokens = Math.min(this.tokens + tokensToAdd, this.tokensPerInterval);
|
|
1520
|
-
this.lastRefill = now;
|
|
1521
|
-
}
|
|
1522
|
-
}
|
|
1523
|
-
removeTokens(count) {
|
|
1524
|
-
this.refill();
|
|
1525
|
-
if (this.tokens >= count) {
|
|
1526
|
-
this.tokens -= count;
|
|
1527
|
-
return true;
|
|
1528
|
-
}
|
|
1529
|
-
return false;
|
|
1530
|
-
}
|
|
1531
|
-
};
|
|
1532
|
-
var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVAL_IN_MS, maxRetries = 30, backoffFactor = 1.25) => {
|
|
1533
|
-
let retries = 0;
|
|
1534
|
-
const tryRequest = async () => {
|
|
1535
|
-
if (tokenBucket.removeTokens(1)) {
|
|
1536
|
-
try {
|
|
1537
|
-
const result = await fn();
|
|
1538
|
-
if (result && result.status === 429) {
|
|
1539
|
-
throw new Error("Unexpected status code: 429");
|
|
1540
|
-
}
|
|
1541
|
-
return result;
|
|
1542
|
-
} catch (error) {
|
|
1543
|
-
if (error.message === "Unexpected status code: 429" && retries < maxRetries) {
|
|
1544
|
-
retries++;
|
|
1545
|
-
const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
|
|
1546
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1547
|
-
return tryRequest();
|
|
1548
|
-
} else {
|
|
1549
|
-
console.error("An error occurred:", error.message);
|
|
1550
|
-
return null;
|
|
1551
|
-
}
|
|
1552
|
-
}
|
|
1553
|
-
} else if (retries < maxRetries) {
|
|
1554
|
-
retries++;
|
|
1555
|
-
const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
|
|
1556
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1557
|
-
return tryRequest();
|
|
1558
|
-
} else {
|
|
1559
|
-
console.error("Maximum retries reached");
|
|
1560
|
-
return null;
|
|
1561
|
-
}
|
|
1562
|
-
};
|
|
1563
|
-
return tryRequest();
|
|
1564
|
-
};
|
|
1565
|
-
|
|
1566
1487
|
// src/utils/util.ts
|
|
1567
1488
|
var COIN_SET = Array.from(
|
|
1568
1489
|
/* @__PURE__ */ new Set([
|
|
@@ -1635,6 +1556,85 @@ var findClosestUnlockRound = (unlockAtInSecondTimestamp) => {
|
|
|
1635
1556
|
return Math.floor(closestTwelveAM.getTime() / 1e3);
|
|
1636
1557
|
};
|
|
1637
1558
|
|
|
1559
|
+
// src/utils/tokenBucket.ts
|
|
1560
|
+
var TokenBucket = class {
|
|
1561
|
+
constructor(tokensPerInterval, intervalInMs) {
|
|
1562
|
+
this.tokensPerInterval = tokensPerInterval;
|
|
1563
|
+
this.interval = intervalInMs;
|
|
1564
|
+
this.tokens = tokensPerInterval;
|
|
1565
|
+
this.lastRefill = Date.now();
|
|
1566
|
+
}
|
|
1567
|
+
refill() {
|
|
1568
|
+
const now = Date.now();
|
|
1569
|
+
const elapsed = now - this.lastRefill;
|
|
1570
|
+
if (elapsed > this.interval) {
|
|
1571
|
+
const tokensToAdd = Math.floor(elapsed / this.interval) * this.tokensPerInterval;
|
|
1572
|
+
this.tokens = Math.min(this.tokens + tokensToAdd, this.tokensPerInterval);
|
|
1573
|
+
this.lastRefill = now;
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
removeTokens(count) {
|
|
1577
|
+
this.refill();
|
|
1578
|
+
if (this.tokens >= count) {
|
|
1579
|
+
this.tokens -= count;
|
|
1580
|
+
return true;
|
|
1581
|
+
}
|
|
1582
|
+
return false;
|
|
1583
|
+
}
|
|
1584
|
+
};
|
|
1585
|
+
var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVAL_IN_MS, maxRetries = 30, backoffFactor = 1.25) => {
|
|
1586
|
+
let retries = 0;
|
|
1587
|
+
const tryRequest = async () => {
|
|
1588
|
+
if (tokenBucket.removeTokens(1)) {
|
|
1589
|
+
try {
|
|
1590
|
+
const result = await fn();
|
|
1591
|
+
if (result && result.status === 429) {
|
|
1592
|
+
throw new Error("Unexpected status code: 429");
|
|
1593
|
+
}
|
|
1594
|
+
return result;
|
|
1595
|
+
} catch (error) {
|
|
1596
|
+
if (error.message === "Unexpected status code: 429" && retries < maxRetries) {
|
|
1597
|
+
retries++;
|
|
1598
|
+
const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
|
|
1599
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1600
|
+
return tryRequest();
|
|
1601
|
+
} else {
|
|
1602
|
+
console.error("An error occurred:", error.message);
|
|
1603
|
+
return null;
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
} else if (retries < maxRetries) {
|
|
1607
|
+
retries++;
|
|
1608
|
+
const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
|
|
1609
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1610
|
+
return tryRequest();
|
|
1611
|
+
} else {
|
|
1612
|
+
console.error("Maximum retries reached");
|
|
1613
|
+
return null;
|
|
1614
|
+
}
|
|
1615
|
+
};
|
|
1616
|
+
return tryRequest();
|
|
1617
|
+
};
|
|
1618
|
+
|
|
1619
|
+
// src/utils/indexer.ts
|
|
1620
|
+
async function callMethodWithIndexerFallback(method, context, ...args) {
|
|
1621
|
+
const indexer = args[args.length - 1];
|
|
1622
|
+
if (indexer) {
|
|
1623
|
+
try {
|
|
1624
|
+
return await method.apply(context, args);
|
|
1625
|
+
} catch (e) {
|
|
1626
|
+
console.warn(`Indexer requests failed: ${e}. Retrying without indexer..`);
|
|
1627
|
+
return await method.apply(context, [...args.slice(0, -1), false]);
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
return await method.apply(context, args);
|
|
1631
|
+
}
|
|
1632
|
+
function withIndexerFallback(method) {
|
|
1633
|
+
return (...args) => {
|
|
1634
|
+
return callMethodWithIndexerFallback(method, this, ...args);
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
1638
|
// src/models/scallopCache.ts
|
|
1639
1639
|
var ScallopCache = class {
|
|
1640
1640
|
constructor(suiKit, walletAddress, cacheOptions, tokenBucket, queryClient) {
|