@scallop-io/sui-scallop-sdk 0.46.60 → 0.46.61
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 +66 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -11
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopQuery.d.ts +10 -0
- package/dist/queries/supplyLimit.d.ts +9 -0
- package/dist/types/query/core.d.ts +1 -0
- package/package.json +1 -1
- package/src/models/scallopQuery.ts +18 -0
- package/src/queries/coreQuery.ts +8 -0
- package/src/queries/supplyLimit.ts +48 -0
- package/src/types/query/core.ts +1 -0
|
@@ -367,6 +367,12 @@ export declare class ScallopQuery {
|
|
|
367
367
|
* @return Total value locked.
|
|
368
368
|
*/
|
|
369
369
|
getTvl(indexer?: boolean): Promise<import("../types").TotalValueLocked>;
|
|
370
|
+
/**
|
|
371
|
+
* Get veSca data.
|
|
372
|
+
* @param veScaKey
|
|
373
|
+
* @returns veSca
|
|
374
|
+
*/
|
|
375
|
+
getVeSca(veScaKey: string | SuiObjectData): Promise<import("../types").Vesca | undefined>;
|
|
370
376
|
/**
|
|
371
377
|
* Get all veSca from walletAdddress
|
|
372
378
|
* @param walletAddress
|
|
@@ -431,4 +437,8 @@ export declare class ScallopQuery {
|
|
|
431
437
|
*/
|
|
432
438
|
getSCoinSwapRate(fromSCoin: SupportSCoin, toSCoin: SupportSCoin): Promise<number>;
|
|
433
439
|
getFlashLoanFees(assetCoinNames?: SupportAssetCoins[]): Promise<Record<"eth" | "btc" | "usdc" | "usdt" | "sui" | "apt" | "sol" | "cetus" | "afsui" | "hasui" | "vsui" | "sca", number>>;
|
|
440
|
+
/**
|
|
441
|
+
* Get supply limit of supply pool
|
|
442
|
+
*/
|
|
443
|
+
getPoolSupplyLimit(poolName: SupportPoolCoins): Promise<string | null>;
|
|
434
444
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ScallopUtils } from 'src/models';
|
|
2
|
+
import { SupportPoolCoins } from 'src/types';
|
|
3
|
+
/**
|
|
4
|
+
* Return supply limit of a pool (including the decimals)
|
|
5
|
+
* @param utils
|
|
6
|
+
* @param poolName
|
|
7
|
+
* @returns supply limit (decimals included)
|
|
8
|
+
*/
|
|
9
|
+
export declare const getSupplyLimit: (utils: ScallopUtils, poolName: SupportPoolCoins) => Promise<string | null>;
|
|
@@ -122,6 +122,7 @@ export type MarketPool = {
|
|
|
122
122
|
coinWrappedType: CoinWrappedType;
|
|
123
123
|
coinDecimal: number;
|
|
124
124
|
coinPrice: number;
|
|
125
|
+
supplyLimit: string;
|
|
125
126
|
} & Required<Pick<ParsedMarketPoolData, 'highKink' | 'midKink' | 'reserveFactor' | 'borrowWeight' | 'borrowFee' | 'marketCoinSupplyAmount' | 'minBorrowAmount'>> & CalculatedMarketPoolData;
|
|
126
127
|
export type MarketCollateral = {
|
|
127
128
|
coinName: SupportCollateralCoins;
|
package/package.json
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
getVeScaTreasuryInfo,
|
|
34
34
|
getLoyaltyProgramInformations,
|
|
35
35
|
getFlashLoanFees,
|
|
36
|
+
getVeSca,
|
|
36
37
|
} from '../queries';
|
|
37
38
|
import {
|
|
38
39
|
ScallopQueryParams,
|
|
@@ -60,6 +61,7 @@ import {
|
|
|
60
61
|
getSCoinTotalSupply,
|
|
61
62
|
} from 'src/queries/sCoinQuery';
|
|
62
63
|
import { normalizeSuiAddress } from '@mysten/sui.js/utils';
|
|
64
|
+
import { getSupplyLimit } from 'src/queries/supplyLimit';
|
|
63
65
|
|
|
64
66
|
/**
|
|
65
67
|
* @description
|
|
@@ -563,6 +565,15 @@ export class ScallopQuery {
|
|
|
563
565
|
return await getTotalValueLocked(this, indexer);
|
|
564
566
|
}
|
|
565
567
|
|
|
568
|
+
/**
|
|
569
|
+
* Get veSca data.
|
|
570
|
+
* @param veScaKey
|
|
571
|
+
* @returns veSca
|
|
572
|
+
*/
|
|
573
|
+
public async getVeSca(veScaKey: string | SuiObjectData) {
|
|
574
|
+
return await getVeSca(this.utils, veScaKey);
|
|
575
|
+
}
|
|
576
|
+
|
|
566
577
|
/**
|
|
567
578
|
* Get all veSca from walletAdddress
|
|
568
579
|
* @param walletAddress
|
|
@@ -681,4 +692,11 @@ export class ScallopQuery {
|
|
|
681
692
|
) {
|
|
682
693
|
return await getFlashLoanFees(this, assetCoinNames);
|
|
683
694
|
}
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* Get supply limit of supply pool
|
|
698
|
+
*/
|
|
699
|
+
public async getPoolSupplyLimit(poolName: SupportPoolCoins) {
|
|
700
|
+
return await getSupplyLimit(this.utils, poolName);
|
|
701
|
+
}
|
|
684
702
|
}
|
package/src/queries/coreQuery.ts
CHANGED
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
OptionalKeys,
|
|
38
38
|
} from '../types';
|
|
39
39
|
import BigNumber from 'bignumber.js';
|
|
40
|
+
import { getSupplyLimit } from './supplyLimit';
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
* Query market data.
|
|
@@ -124,6 +125,8 @@ export const queryMarket = async (
|
|
|
124
125
|
parsedMarketPoolData
|
|
125
126
|
);
|
|
126
127
|
|
|
128
|
+
const supplyLimit =
|
|
129
|
+
(await getSupplyLimit(query.utils, poolCoinName)) ?? '0';
|
|
127
130
|
pools[poolCoinName] = {
|
|
128
131
|
coinName: poolCoinName,
|
|
129
132
|
symbol: query.utils.parseSymbol(poolCoinName),
|
|
@@ -142,6 +145,7 @@ export const queryMarket = async (
|
|
|
142
145
|
borrowFee: parsedMarketPoolData.borrowFee,
|
|
143
146
|
marketCoinSupplyAmount: parsedMarketPoolData.marketCoinSupplyAmount,
|
|
144
147
|
minBorrowAmount: parsedMarketPoolData.minBorrowAmount,
|
|
148
|
+
supplyLimit,
|
|
145
149
|
...calculatedMarketPoolData,
|
|
146
150
|
};
|
|
147
151
|
}
|
|
@@ -451,6 +455,9 @@ export const getMarketPool = async (
|
|
|
451
455
|
parsedMarketPoolData
|
|
452
456
|
);
|
|
453
457
|
|
|
458
|
+
const supplyLimit =
|
|
459
|
+
(await getSupplyLimit(query.utils, poolCoinName)) ?? '0';
|
|
460
|
+
|
|
454
461
|
marketPool = {
|
|
455
462
|
coinName: poolCoinName,
|
|
456
463
|
symbol: query.utils.parseSymbol(poolCoinName),
|
|
@@ -469,6 +476,7 @@ export const getMarketPool = async (
|
|
|
469
476
|
borrowFee: parsedMarketPoolData.borrowFee,
|
|
470
477
|
marketCoinSupplyAmount: parsedMarketPoolData.marketCoinSupplyAmount,
|
|
471
478
|
minBorrowAmount: parsedMarketPoolData.minBorrowAmount,
|
|
479
|
+
supplyLimit,
|
|
472
480
|
...calculatedMarketPoolData,
|
|
473
481
|
};
|
|
474
482
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ScallopUtils } from 'src/models';
|
|
2
|
+
import { SupportPoolCoins } from 'src/types';
|
|
3
|
+
import { z as zod } from 'zod';
|
|
4
|
+
|
|
5
|
+
const supplyLimitZod = zod.object({
|
|
6
|
+
dataType: zod.string(),
|
|
7
|
+
type: zod.string(),
|
|
8
|
+
hasPublicTransfer: zod.boolean(),
|
|
9
|
+
fields: zod.object({
|
|
10
|
+
id: zod.object({
|
|
11
|
+
id: zod.string(),
|
|
12
|
+
}),
|
|
13
|
+
name: zod.object({
|
|
14
|
+
type: zod.string(),
|
|
15
|
+
}),
|
|
16
|
+
value: zod.string(),
|
|
17
|
+
}),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const SUPPLY_LIMIT_TYPE =
|
|
21
|
+
'0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Return supply limit of a pool (including the decimals)
|
|
25
|
+
* @param utils
|
|
26
|
+
* @param poolName
|
|
27
|
+
* @returns supply limit (decimals included)
|
|
28
|
+
*/
|
|
29
|
+
export const getSupplyLimit = async (
|
|
30
|
+
utils: ScallopUtils,
|
|
31
|
+
poolName: SupportPoolCoins
|
|
32
|
+
) => {
|
|
33
|
+
const poolCoinType = utils.parseCoinType(poolName).slice(2);
|
|
34
|
+
const marketObject = utils.address.get('core.market');
|
|
35
|
+
if (!marketObject) return null;
|
|
36
|
+
|
|
37
|
+
const object = await utils.cache.queryGetDynamicFieldObject({
|
|
38
|
+
parentId: marketObject,
|
|
39
|
+
name: {
|
|
40
|
+
type: SUPPLY_LIMIT_TYPE,
|
|
41
|
+
value: poolCoinType,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const parsedData = supplyLimitZod.safeParse(object?.data?.content);
|
|
46
|
+
if (!parsedData.success) return null;
|
|
47
|
+
return parsedData.data.fields.value;
|
|
48
|
+
};
|