@scallop-io/sui-scallop-sdk 1.4.1 → 1.4.2-rc.1
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/constants/poolAddress.d.ts +16 -4
- package/dist/constants/queryKeys.d.ts +2 -2
- package/dist/constants/tokenBucket.d.ts +2 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1270 -588
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1225 -544
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopBuilder.d.ts +2 -1
- package/dist/models/scallopCache.d.ts +2 -0
- package/dist/models/scallopQuery.d.ts +38 -20
- package/dist/models/scallopUtils.d.ts +4 -2
- package/dist/queries/borrowIncentiveQuery.d.ts +12 -0
- package/dist/queries/coreQuery.d.ts +18 -19
- package/dist/queries/index.d.ts +2 -0
- package/dist/queries/isolatedAssetQuery.d.ts +2 -2
- package/dist/queries/objectsQuery.d.ts +3 -0
- package/dist/queries/poolAddressesQuery.d.ts +18 -0
- package/dist/queries/spoolQuery.d.ts +6 -2
- package/dist/test.d.ts +1 -0
- package/dist/types/builder/borrowIncentive.d.ts +5 -5
- package/dist/types/builder/core.d.ts +20 -16
- package/dist/types/builder/loyaltyProgram.d.ts +1 -1
- package/dist/types/builder/referral.d.ts +4 -4
- package/dist/types/builder/sCoin.d.ts +2 -2
- package/dist/types/builder/spool.d.ts +4 -4
- package/dist/types/builder/vesca.d.ts +6 -6
- package/dist/types/query/core.d.ts +22 -5
- package/dist/types/query/spool.d.ts +20 -0
- package/dist/types/utils.d.ts +7 -2
- package/dist/utils/core.d.ts +2 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/query.d.ts +1 -1
- package/dist/utils/util.d.ts +1 -0
- package/package.json +7 -7
- package/src/builders/borrowIncentiveBuilder.ts +28 -15
- package/src/builders/coreBuilder.ts +76 -49
- package/src/builders/loyaltyProgramBuilder.ts +4 -3
- package/src/builders/referralBuilder.ts +23 -10
- package/src/builders/sCoinBuilder.ts +8 -6
- package/src/builders/spoolBuilder.ts +21 -14
- package/src/builders/vescaBuilder.ts +23 -13
- package/src/constants/common.ts +1 -12
- package/src/constants/poolAddress.ts +336 -10
- package/src/constants/queryKeys.ts +9 -5
- package/src/constants/testAddress.ts +42 -0
- package/src/constants/tokenBucket.ts +2 -2
- package/src/index.ts +1 -0
- package/src/models/scallopBuilder.ts +59 -2
- package/src/models/scallopCache.ts +171 -19
- package/src/models/scallopClient.ts +16 -10
- package/src/models/scallopQuery.ts +36 -28
- package/src/models/scallopUtils.ts +11 -4
- package/src/queries/borrowIncentiveQuery.ts +6 -8
- package/src/queries/borrowLimitQuery.ts +1 -0
- package/src/queries/coreQuery.ts +408 -258
- package/src/queries/index.ts +2 -0
- package/src/queries/isolatedAssetQuery.ts +37 -31
- package/src/queries/objectsQuery.ts +20 -0
- package/src/queries/poolAddressesQuery.ts +146 -0
- package/src/queries/portfolioQuery.ts +31 -13
- package/src/queries/priceQuery.ts +3 -1
- package/src/queries/spoolQuery.ts +189 -122
- package/src/test.ts +17 -0
- package/src/types/builder/borrowIncentive.ts +8 -5
- package/src/types/builder/core.ts +23 -17
- package/src/types/builder/loyaltyProgram.ts +1 -1
- package/src/types/builder/referral.ts +6 -4
- package/src/types/builder/sCoin.ts +2 -2
- package/src/types/builder/spool.ts +4 -4
- package/src/types/builder/vesca.ts +9 -6
- package/src/types/query/core.ts +21 -5
- package/src/types/query/spool.ts +21 -0
- package/src/types/utils.ts +8 -3
- package/src/utils/core.ts +18 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/query.ts +21 -5
- package/src/utils/tokenBucket.ts +9 -29
- package/src/utils/util.ts +8 -0
|
@@ -232,13 +232,14 @@ export class ScallopUtils {
|
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
/**
|
|
235
|
-
* Convert sCoin name to coin name.
|
|
235
|
+
* Convert sCoin name to market coin name.
|
|
236
236
|
* This function will parse new sCoin name `scallop_...` to its old market coin name which is shorter
|
|
237
237
|
* e.g: `scallop_sui -> ssui
|
|
238
|
+
* if no `scallop_...` is encountered, return coinName
|
|
238
239
|
* @return sCoin name
|
|
239
240
|
*/
|
|
240
|
-
public
|
|
241
|
-
return sCoinRawNameToName[coinName];
|
|
241
|
+
public parseSCoinTypeNameToMarketCoinName(coinName: string) {
|
|
242
|
+
return sCoinRawNameToName[coinName] ?? coinName;
|
|
242
243
|
}
|
|
243
244
|
|
|
244
245
|
/**
|
|
@@ -311,8 +312,14 @@ export class ScallopUtils {
|
|
|
311
312
|
public parseCoinNameFromType<T extends SupportCoins>(
|
|
312
313
|
coinType: string
|
|
313
314
|
): T extends SupportCoins ? T : SupportCoins;
|
|
315
|
+
public parseCoinNameFromType<T extends SupportSCoin>(
|
|
316
|
+
coinType: string
|
|
317
|
+
): T extends SupportSCoin ? T : SupportSCoin;
|
|
314
318
|
public parseCoinNameFromType(coinType: string) {
|
|
315
319
|
coinType = normalizeStructTag(coinType);
|
|
320
|
+
if (sCoinTypeToName[coinType]) {
|
|
321
|
+
return sCoinTypeToName[coinType] as SupportSCoin;
|
|
322
|
+
}
|
|
316
323
|
|
|
317
324
|
const coinTypeRegex = new RegExp(`((0x[^:]+::[^:]+::[^<>]+))(?![^<>]*<)`);
|
|
318
325
|
const coinTypeMatch = coinType.match(coinTypeRegex);
|
|
@@ -553,7 +560,7 @@ export class ScallopUtils {
|
|
|
553
560
|
const priceIds = priceIdPairs.map(([_, priceId]) => priceId);
|
|
554
561
|
|
|
555
562
|
const pythConnection = new SuiPriceServiceConnection(endpoint, {
|
|
556
|
-
timeout:
|
|
563
|
+
timeout: 4000,
|
|
557
564
|
});
|
|
558
565
|
|
|
559
566
|
try {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { normalizeStructTag } from '@mysten/sui/utils';
|
|
2
2
|
import {
|
|
3
|
-
sCoinRawNameToName,
|
|
4
3
|
SUPPORT_BORROW_INCENTIVE_POOLS,
|
|
5
4
|
SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
6
5
|
} from '../constants';
|
|
@@ -66,7 +65,7 @@ export const getBorrowIncentivePools = async (
|
|
|
66
65
|
const borrowIncentivePools: BorrowIncentivePools = {};
|
|
67
66
|
marketPools =
|
|
68
67
|
marketPools ??
|
|
69
|
-
(await query.getMarketPools(undefined, { coinPrices, indexer }));
|
|
68
|
+
(await query.getMarketPools(undefined, { coinPrices, indexer })).pools;
|
|
70
69
|
coinPrices = coinPrices ?? (await query.getAllCoinPrices({ marketPools }));
|
|
71
70
|
|
|
72
71
|
if (indexer) {
|
|
@@ -100,8 +99,10 @@ export const getBorrowIncentivePools = async (
|
|
|
100
99
|
const borrowIncentivePoolPoints: OptionalKeys<
|
|
101
100
|
Record<SupportBorrowIncentiveRewardCoins, BorrowIncentivePoolPoints>
|
|
102
101
|
> = {};
|
|
103
|
-
const parsedBorrowIncentivePoolData =
|
|
104
|
-
|
|
102
|
+
const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(
|
|
103
|
+
query.utils,
|
|
104
|
+
pool
|
|
105
|
+
);
|
|
105
106
|
|
|
106
107
|
const poolCoinType = normalizeStructTag(pool.pool_type.name);
|
|
107
108
|
const poolCoinName =
|
|
@@ -121,13 +122,10 @@ export const getBorrowIncentivePools = async (
|
|
|
121
122
|
parsedBorrowIncentivePoolData.poolPoints
|
|
122
123
|
)) {
|
|
123
124
|
const rewardCoinType = poolPoint.pointType;
|
|
124
|
-
|
|
125
|
+
const rewardCoinName = query.utils.parseCoinNameFromType(
|
|
125
126
|
rewardCoinType
|
|
126
127
|
) as SupportBorrowIncentiveRewardCoins;
|
|
127
128
|
// handle for scoin name
|
|
128
|
-
if (sCoinRawNameToName[rewardCoinName]) {
|
|
129
|
-
rewardCoinName = sCoinRawNameToName[rewardCoinName];
|
|
130
|
-
}
|
|
131
129
|
const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
|
|
132
130
|
const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
|
|
133
131
|
|
|
@@ -19,6 +19,7 @@ const borrowLimitZod = zod.object({
|
|
|
19
19
|
|
|
20
20
|
const borrowLimitKeyType = `0xe7dbb371a9595631f7964b7ece42255ad0e738cc85fe6da26c7221b220f01af6::market_dynamic_keys::BorrowLimitKey`; // prod
|
|
21
21
|
// const borrowLimitKeyType = `0xb784ea287d944e478a3ceaa071f8885072cce6b7224cf245914dc2f9963f460e::market_dynamic_keys::BorrowLimitKey`;
|
|
22
|
+
|
|
22
23
|
/**
|
|
23
24
|
* Return supply limit of a pool (including the decimals)
|
|
24
25
|
* @param utils
|