@scallop-io/sui-scallop-sdk 1.4.13 → 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/index.js +17 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -16
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopUtils.d.ts +4 -2
- package/dist/utils/query.d.ts +1 -1
- package/package.json +1 -1
- 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
package/dist/index.mjs
CHANGED
|
@@ -1352,7 +1352,7 @@ var parseOriginBorrowIncentivesPoolPointData = (originBorrowIncentivePoolPointDa
|
|
|
1352
1352
|
createdAt: Number(originBorrowIncentivePoolPointData.created_at)
|
|
1353
1353
|
};
|
|
1354
1354
|
};
|
|
1355
|
-
var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
|
|
1355
|
+
var parseOriginBorrowIncentivePoolData = (utils, originBorrowIncentivePoolData) => {
|
|
1356
1356
|
return {
|
|
1357
1357
|
poolType: normalizeStructTag(originBorrowIncentivePoolData.pool_type.name),
|
|
1358
1358
|
minStakes: Number(originBorrowIncentivePoolData.min_stakes),
|
|
@@ -1361,12 +1361,9 @@ var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
|
|
|
1361
1361
|
poolPoints: originBorrowIncentivePoolData.points.reduce(
|
|
1362
1362
|
(acc, point) => {
|
|
1363
1363
|
const parsed = parseOriginBorrowIncentivesPoolPointData(point);
|
|
1364
|
-
|
|
1365
|
-
parsed.pointType
|
|
1366
|
-
)
|
|
1367
|
-
if (sCoinRawNameToName[name]) {
|
|
1368
|
-
name = sCoinRawNameToName[name];
|
|
1369
|
-
}
|
|
1364
|
+
const name = utils.parseSCoinTypeNameToMarketCoinName(
|
|
1365
|
+
parseStructTag(parsed.pointType).name.toLowerCase()
|
|
1366
|
+
);
|
|
1370
1367
|
acc[name] = parsed;
|
|
1371
1368
|
return acc;
|
|
1372
1369
|
},
|
|
@@ -2523,7 +2520,10 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
|
|
|
2523
2520
|
);
|
|
2524
2521
|
for (const pool of borrowIncentivePoolsQueryData?.incentive_pools ?? []) {
|
|
2525
2522
|
const borrowIncentivePoolPoints = {};
|
|
2526
|
-
const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(
|
|
2523
|
+
const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(
|
|
2524
|
+
query.utils,
|
|
2525
|
+
pool
|
|
2526
|
+
);
|
|
2527
2527
|
const poolCoinType = normalizeStructTag3(pool.pool_type.name);
|
|
2528
2528
|
const poolCoinName = query.utils.parseCoinNameFromType(
|
|
2529
2529
|
poolCoinType
|
|
@@ -2537,12 +2537,9 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
|
|
|
2537
2537
|
parsedBorrowIncentivePoolData.poolPoints
|
|
2538
2538
|
)) {
|
|
2539
2539
|
const rewardCoinType = poolPoint.pointType;
|
|
2540
|
-
|
|
2540
|
+
const rewardCoinName = query.utils.parseCoinNameFromType(
|
|
2541
2541
|
rewardCoinType
|
|
2542
2542
|
);
|
|
2543
|
-
if (sCoinRawNameToName[rewardCoinName]) {
|
|
2544
|
-
rewardCoinName = sCoinRawNameToName[rewardCoinName];
|
|
2545
|
-
}
|
|
2546
2543
|
const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
|
|
2547
2544
|
const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
|
|
2548
2545
|
const symbol = query.utils.parseSymbol(rewardCoinName);
|
|
@@ -3852,7 +3849,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3852
3849
|
const rewards = [];
|
|
3853
3850
|
Object.entries(borrowIncentiveAccount.pointList).forEach(
|
|
3854
3851
|
([key, accountPoint]) => {
|
|
3855
|
-
const poolPoint = borrowIncentivePool.points[key];
|
|
3852
|
+
const poolPoint = borrowIncentivePool.points[query.utils.parseSCoinTypeNameToMarketCoinName(key)];
|
|
3856
3853
|
if (accountPoint && poolPoint) {
|
|
3857
3854
|
let availableClaimAmount = BigNumber5(0);
|
|
3858
3855
|
let availableClaimCoin = BigNumber5(0);
|
|
@@ -4884,13 +4881,14 @@ var ScallopUtils = class {
|
|
|
4884
4881
|
}
|
|
4885
4882
|
}
|
|
4886
4883
|
/**
|
|
4887
|
-
* Convert sCoin name to coin name.
|
|
4884
|
+
* Convert sCoin name to market coin name.
|
|
4888
4885
|
* This function will parse new sCoin name `scallop_...` to its old market coin name which is shorter
|
|
4889
4886
|
* e.g: `scallop_sui -> ssui
|
|
4887
|
+
* if no `scallop_...` is encountered, return coinName
|
|
4890
4888
|
* @return sCoin name
|
|
4891
4889
|
*/
|
|
4892
|
-
|
|
4893
|
-
return sCoinRawNameToName[coinName];
|
|
4890
|
+
parseSCoinTypeNameToMarketCoinName(coinName) {
|
|
4891
|
+
return sCoinRawNameToName[coinName] ?? coinName;
|
|
4894
4892
|
}
|
|
4895
4893
|
/**
|
|
4896
4894
|
* Convert sCoin name into sCoin type
|
|
@@ -4939,6 +4937,9 @@ var ScallopUtils = class {
|
|
|
4939
4937
|
}
|
|
4940
4938
|
parseCoinNameFromType(coinType) {
|
|
4941
4939
|
coinType = normalizeStructTag6(coinType);
|
|
4940
|
+
if (sCoinTypeToName[coinType]) {
|
|
4941
|
+
return sCoinTypeToName[coinType];
|
|
4942
|
+
}
|
|
4942
4943
|
const coinTypeRegex = new RegExp(`((0x[^:]+::[^:]+::[^<>]+))(?![^<>]*<)`);
|
|
4943
4944
|
const coinTypeMatch = coinType.match(coinTypeRegex);
|
|
4944
4945
|
const isMarketCoinType = coinType.includes("reserve::MarketCoin");
|