@scallop-io/sui-scallop-sdk 1.4.12 → 1.4.14
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/constants/common.d.ts +1 -1
- package/dist/index.js +18 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -28
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopQuery.d.ts +12 -0
- package/dist/models/scallopUtils.d.ts +4 -2
- package/dist/queries/borrowIncentiveQuery.d.ts +12 -0
- package/dist/utils/query.d.ts +1 -1
- package/package.json +1 -1
- package/src/constants/common.ts +1 -12
- package/src/models/scallopUtils.ts +10 -3
- package/src/queries/borrowIncentiveQuery.ts +5 -7
- package/src/queries/portfolioQuery.ts +6 -1
- package/src/utils/query.ts +5 -7
|
@@ -14,7 +14,7 @@ export declare const SUPPORT_SCOIN: readonly ["susdc", "ssbeth", "ssui", "swusdc
|
|
|
14
14
|
export declare const SUPPORT_SUI_BRIDGE: readonly ["sbeth"];
|
|
15
15
|
export declare const SUPPORT_WORMHOLE: readonly ["wusdc", "wusdt", "weth", "wbtc", "wapt", "wsol"];
|
|
16
16
|
export declare const SUPPORT_SPOOLS_REWARDS: readonly ["sui"];
|
|
17
|
-
export declare const SUPPORT_BORROW_INCENTIVE_POOLS: readonly ["
|
|
17
|
+
export declare const SUPPORT_BORROW_INCENTIVE_POOLS: readonly ["usdc", "sbeth", "weth", "wbtc", "wusdc", "wusdt", "sui", "wapt", "wsol", "cetus", "afsui", "hasui", "vsui", "sca", "fud", "deep"];
|
|
18
18
|
export declare const SUPPORT_BORROW_INCENTIVE_REWARDS: readonly ["usdc", "sbeth", "weth", "wbtc", "wusdc", "wusdt", "sui", "wapt", "wsol", "cetus", "afsui", "hasui", "vsui", "sca", "fud", "deep", "susdc", "ssbeth", "ssui", "swusdc", "swusdt", "safsui", "shasui", "svsui", "sweth", "ssca", "scetus", "swsol", "swbtc", "sdeep", "sfud"];
|
|
19
19
|
export declare const SUPPORT_ORACLES: readonly ["supra", "switchboard", "pyth"];
|
|
20
20
|
export declare const SUPPORT_PACKAGES: readonly ["coinDecimalsRegistry", "math", "whitelist", "x", "protocol", "protocolWhitelist", "query", "supra", "pyth", "switchboard", "xOracle", "testCoin"];
|
package/dist/index.js
CHANGED
|
@@ -206,18 +206,7 @@ var SUPPORT_WORMHOLE = [
|
|
|
206
206
|
"wsol"
|
|
207
207
|
];
|
|
208
208
|
var SUPPORT_SPOOLS_REWARDS = ["sui"];
|
|
209
|
-
var SUPPORT_BORROW_INCENTIVE_POOLS = [
|
|
210
|
-
"sui",
|
|
211
|
-
"wusdc",
|
|
212
|
-
"wusdt",
|
|
213
|
-
"afsui",
|
|
214
|
-
"hasui",
|
|
215
|
-
"vsui",
|
|
216
|
-
"weth",
|
|
217
|
-
"sbeth",
|
|
218
|
-
"sca",
|
|
219
|
-
"usdc"
|
|
220
|
-
];
|
|
209
|
+
var SUPPORT_BORROW_INCENTIVE_POOLS = [...SUPPORT_POOLS];
|
|
221
210
|
var SUPPORT_BORROW_INCENTIVE_REWARDS = [
|
|
222
211
|
...SUPPORT_POOLS,
|
|
223
212
|
...SUPPORT_SCOIN
|
|
@@ -1452,7 +1441,7 @@ var parseOriginBorrowIncentivesPoolPointData = (originBorrowIncentivePoolPointDa
|
|
|
1452
1441
|
createdAt: Number(originBorrowIncentivePoolPointData.created_at)
|
|
1453
1442
|
};
|
|
1454
1443
|
};
|
|
1455
|
-
var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
|
|
1444
|
+
var parseOriginBorrowIncentivePoolData = (utils, originBorrowIncentivePoolData) => {
|
|
1456
1445
|
return {
|
|
1457
1446
|
poolType: (0, import_utils.normalizeStructTag)(originBorrowIncentivePoolData.pool_type.name),
|
|
1458
1447
|
minStakes: Number(originBorrowIncentivePoolData.min_stakes),
|
|
@@ -1461,12 +1450,9 @@ var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
|
|
|
1461
1450
|
poolPoints: originBorrowIncentivePoolData.points.reduce(
|
|
1462
1451
|
(acc, point) => {
|
|
1463
1452
|
const parsed = parseOriginBorrowIncentivesPoolPointData(point);
|
|
1464
|
-
|
|
1465
|
-
parsed.pointType
|
|
1466
|
-
)
|
|
1467
|
-
if (sCoinRawNameToName[name]) {
|
|
1468
|
-
name = sCoinRawNameToName[name];
|
|
1469
|
-
}
|
|
1453
|
+
const name = utils.parseSCoinTypeNameToMarketCoinName(
|
|
1454
|
+
(0, import_utils.parseStructTag)(parsed.pointType).name.toLowerCase()
|
|
1455
|
+
);
|
|
1470
1456
|
acc[name] = parsed;
|
|
1471
1457
|
return acc;
|
|
1472
1458
|
},
|
|
@@ -2623,7 +2609,10 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
|
|
|
2623
2609
|
);
|
|
2624
2610
|
for (const pool of borrowIncentivePoolsQueryData?.incentive_pools ?? []) {
|
|
2625
2611
|
const borrowIncentivePoolPoints = {};
|
|
2626
|
-
const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(
|
|
2612
|
+
const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(
|
|
2613
|
+
query.utils,
|
|
2614
|
+
pool
|
|
2615
|
+
);
|
|
2627
2616
|
const poolCoinType = (0, import_utils3.normalizeStructTag)(pool.pool_type.name);
|
|
2628
2617
|
const poolCoinName = query.utils.parseCoinNameFromType(
|
|
2629
2618
|
poolCoinType
|
|
@@ -2637,12 +2626,9 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
|
|
|
2637
2626
|
parsedBorrowIncentivePoolData.poolPoints
|
|
2638
2627
|
)) {
|
|
2639
2628
|
const rewardCoinType = poolPoint.pointType;
|
|
2640
|
-
|
|
2629
|
+
const rewardCoinName = query.utils.parseCoinNameFromType(
|
|
2641
2630
|
rewardCoinType
|
|
2642
2631
|
);
|
|
2643
|
-
if (sCoinRawNameToName[rewardCoinName]) {
|
|
2644
|
-
rewardCoinName = sCoinRawNameToName[rewardCoinName];
|
|
2645
|
-
}
|
|
2646
2632
|
const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
|
|
2647
2633
|
const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
|
|
2648
2634
|
const symbol = query.utils.parseSymbol(rewardCoinName);
|
|
@@ -3952,7 +3938,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3952
3938
|
const rewards = [];
|
|
3953
3939
|
Object.entries(borrowIncentiveAccount.pointList).forEach(
|
|
3954
3940
|
([key, accountPoint]) => {
|
|
3955
|
-
const poolPoint = borrowIncentivePool.points[key];
|
|
3941
|
+
const poolPoint = borrowIncentivePool.points[query.utils.parseSCoinTypeNameToMarketCoinName(key)];
|
|
3956
3942
|
if (accountPoint && poolPoint) {
|
|
3957
3943
|
let availableClaimAmount = (0, import_bignumber5.default)(0);
|
|
3958
3944
|
let availableClaimCoin = (0, import_bignumber5.default)(0);
|
|
@@ -4984,13 +4970,14 @@ var ScallopUtils = class {
|
|
|
4984
4970
|
}
|
|
4985
4971
|
}
|
|
4986
4972
|
/**
|
|
4987
|
-
* Convert sCoin name to coin name.
|
|
4973
|
+
* Convert sCoin name to market coin name.
|
|
4988
4974
|
* This function will parse new sCoin name `scallop_...` to its old market coin name which is shorter
|
|
4989
4975
|
* e.g: `scallop_sui -> ssui
|
|
4976
|
+
* if no `scallop_...` is encountered, return coinName
|
|
4990
4977
|
* @return sCoin name
|
|
4991
4978
|
*/
|
|
4992
|
-
|
|
4993
|
-
return sCoinRawNameToName[coinName];
|
|
4979
|
+
parseSCoinTypeNameToMarketCoinName(coinName) {
|
|
4980
|
+
return sCoinRawNameToName[coinName] ?? coinName;
|
|
4994
4981
|
}
|
|
4995
4982
|
/**
|
|
4996
4983
|
* Convert sCoin name into sCoin type
|
|
@@ -5039,6 +5026,9 @@ var ScallopUtils = class {
|
|
|
5039
5026
|
}
|
|
5040
5027
|
parseCoinNameFromType(coinType) {
|
|
5041
5028
|
coinType = (0, import_utils10.normalizeStructTag)(coinType);
|
|
5029
|
+
if (sCoinTypeToName[coinType]) {
|
|
5030
|
+
return sCoinTypeToName[coinType];
|
|
5031
|
+
}
|
|
5042
5032
|
const coinTypeRegex = new RegExp(`((0x[^:]+::[^:]+::[^<>]+))(?![^<>]*<)`);
|
|
5043
5033
|
const coinTypeMatch = coinType.match(coinTypeRegex);
|
|
5044
5034
|
const isMarketCoinType = coinType.includes("reserve::MarketCoin");
|