@scallop-io/sui-scallop-sdk 1.4.14 → 1.4.15-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/poolAddress.d.ts +14 -4
- package/dist/constants/queryKeys.d.ts +1 -2
- package/dist/constants/tokenBucket.d.ts +2 -2
- package/dist/index.js +719 -307
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +674 -262
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopCache.d.ts +1 -0
- package/dist/models/scallopQuery.d.ts +20 -17
- 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 +15 -0
- package/dist/types/query/core.d.ts +22 -5
- package/dist/types/utils.d.ts +7 -2
- package/dist/utils/core.d.ts +2 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/util.d.ts +1 -0
- package/package.json +1 -1
- package/src/constants/poolAddress.ts +290 -29
- package/src/constants/queryKeys.ts +5 -5
- package/src/constants/tokenBucket.ts +2 -2
- package/src/models/scallopCache.ts +43 -11
- package/src/models/scallopQuery.ts +24 -12
- package/src/queries/borrowIncentiveQuery.ts +1 -1
- package/src/queries/coreQuery.ts +378 -248
- 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 +134 -0
- package/src/queries/portfolioQuery.ts +14 -7
- package/src/queries/priceQuery.ts +3 -1
- package/src/queries/spoolQuery.ts +3 -1
- package/src/types/query/core.ts +21 -5
- package/src/types/utils.ts +8 -3
- package/src/utils/core.ts +11 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/query.ts +16 -2
- package/src/utils/tokenBucket.ts +2 -2
- package/src/utils/util.ts +8 -0
|
@@ -38,6 +38,7 @@ export declare class ScallopCache {
|
|
|
38
38
|
* - `none`: No queries will be refetched. Queries that match the refetch predicate will only be marked as invalid.
|
|
39
39
|
*/
|
|
40
40
|
invalidateAllCache(): Promise<Promise<void>[]>;
|
|
41
|
+
private retryFn;
|
|
41
42
|
/**
|
|
42
43
|
* @description Provides cache for inspectTxn of the SuiKit.
|
|
43
44
|
* @param QueryInspectTxnParams
|
|
@@ -34,6 +34,7 @@ export declare class ScallopQuery {
|
|
|
34
34
|
*/
|
|
35
35
|
init(force?: boolean, address?: ScallopAddress): Promise<void>;
|
|
36
36
|
/**
|
|
37
|
+
* @deprecated use getMarketPools
|
|
37
38
|
* Query market data.
|
|
38
39
|
* @param indexer - Whether to use indexer.
|
|
39
40
|
* @return Market data.
|
|
@@ -57,22 +58,8 @@ export declare class ScallopQuery {
|
|
|
57
58
|
coinPrices?: CoinPrices;
|
|
58
59
|
indexer?: boolean;
|
|
59
60
|
}): Promise<{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
weth?: MarketPool | undefined;
|
|
63
|
-
wbtc?: MarketPool | undefined;
|
|
64
|
-
wusdc?: MarketPool | undefined;
|
|
65
|
-
wusdt?: MarketPool | undefined;
|
|
66
|
-
sui?: MarketPool | undefined;
|
|
67
|
-
wapt?: MarketPool | undefined;
|
|
68
|
-
wsol?: MarketPool | undefined;
|
|
69
|
-
cetus?: MarketPool | undefined;
|
|
70
|
-
afsui?: MarketPool | undefined;
|
|
71
|
-
hasui?: MarketPool | undefined;
|
|
72
|
-
vsui?: MarketPool | undefined;
|
|
73
|
-
sca?: MarketPool | undefined;
|
|
74
|
-
fud?: MarketPool | undefined;
|
|
75
|
-
deep?: MarketPool | undefined;
|
|
61
|
+
pools: MarketPools;
|
|
62
|
+
collaterals: import("../types").MarketCollaterals;
|
|
76
63
|
}>;
|
|
77
64
|
/**
|
|
78
65
|
* Get market pool
|
|
@@ -82,7 +69,6 @@ export declare class ScallopQuery {
|
|
|
82
69
|
* @return Market pool data.
|
|
83
70
|
*/
|
|
84
71
|
getMarketPool(poolCoinName: SupportPoolCoins, args?: {
|
|
85
|
-
marketObject?: SuiObjectData | null;
|
|
86
72
|
coinPrice?: number;
|
|
87
73
|
indexer?: boolean;
|
|
88
74
|
}): Promise<MarketPool | undefined>;
|
|
@@ -568,4 +554,21 @@ export declare class ScallopQuery {
|
|
|
568
554
|
deep?: number | undefined;
|
|
569
555
|
swapt?: number | undefined;
|
|
570
556
|
}>;
|
|
557
|
+
/**
|
|
558
|
+
* Query all address (lending pool, collateral pool, borrow dynamics, interest models) of all pool
|
|
559
|
+
* @returns
|
|
560
|
+
*/
|
|
561
|
+
getPoolAddresses(): Promise<import("../types").OptionalKeys<Record<"usdc" | "sbeth" | "weth" | "wbtc" | "wusdc" | "wusdt" | "sui" | "wapt" | "wsol" | "cetus" | "afsui" | "hasui" | "vsui" | "sca" | "fud" | "deep", {
|
|
562
|
+
lendingPoolAddress?: string;
|
|
563
|
+
collateralPoolAddress?: string;
|
|
564
|
+
borrowDynamic?: string;
|
|
565
|
+
spoolReward?: string;
|
|
566
|
+
spool?: string;
|
|
567
|
+
interestModel?: string;
|
|
568
|
+
riskModel?: string;
|
|
569
|
+
borrowFeeKey?: string;
|
|
570
|
+
supplyLimitKey?: string;
|
|
571
|
+
borrowLimitKey?: string;
|
|
572
|
+
isolatedAssetKey?: string;
|
|
573
|
+
}>>>;
|
|
571
574
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { SuiObjectData } from '@mysten/sui/client';
|
|
2
2
|
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
3
3
|
import type { ScallopAddress, ScallopCache, ScallopQuery } from '../models';
|
|
4
|
-
import { Market, MarketPool, MarketCollateral, SupportAssetCoins, SupportPoolCoins, SupportCollateralCoins, ObligationQueryInterface, Obligation, SupportMarketCoins, OptionalKeys, CoinPrices } from '../types';
|
|
4
|
+
import { Market, MarketPools, MarketPool, MarketCollaterals, MarketCollateral, SupportAssetCoins, SupportPoolCoins, SupportCollateralCoins, ObligationQueryInterface, Obligation, SupportMarketCoins, OptionalKeys, CoinPrices } from '../types';
|
|
5
5
|
/**
|
|
6
6
|
* Query market data.
|
|
7
7
|
*
|
|
8
|
+
* @deprecated Use query market pools
|
|
9
|
+
*
|
|
8
10
|
* @description
|
|
9
11
|
* Use inspectTxn call to obtain the data provided in the scallop contract query module.
|
|
10
12
|
*
|
|
@@ -25,23 +27,9 @@ export declare const queryMarket: (query: ScallopQuery, indexer?: boolean, coinP
|
|
|
25
27
|
* @param indexer - Whether to use indexer.
|
|
26
28
|
* @return Market pools data.
|
|
27
29
|
*/
|
|
28
|
-
export declare const getMarketPools: (query: ScallopQuery, poolCoinNames
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
weth?: MarketPool | undefined;
|
|
32
|
-
wbtc?: MarketPool | undefined;
|
|
33
|
-
wusdc?: MarketPool | undefined;
|
|
34
|
-
wusdt?: MarketPool | undefined;
|
|
35
|
-
sui?: MarketPool | undefined;
|
|
36
|
-
wapt?: MarketPool | undefined;
|
|
37
|
-
wsol?: MarketPool | undefined;
|
|
38
|
-
cetus?: MarketPool | undefined;
|
|
39
|
-
afsui?: MarketPool | undefined;
|
|
40
|
-
hasui?: MarketPool | undefined;
|
|
41
|
-
vsui?: MarketPool | undefined;
|
|
42
|
-
sca?: MarketPool | undefined;
|
|
43
|
-
fud?: MarketPool | undefined;
|
|
44
|
-
deep?: MarketPool | undefined;
|
|
30
|
+
export declare const getMarketPools: (query: ScallopQuery, poolCoinNames: SupportPoolCoins[], indexer?: boolean, coinPrices?: CoinPrices) => Promise<{
|
|
31
|
+
pools: MarketPools;
|
|
32
|
+
collaterals: MarketCollaterals;
|
|
45
33
|
}>;
|
|
46
34
|
/**
|
|
47
35
|
* Get market pool data.
|
|
@@ -53,7 +41,18 @@ export declare const getMarketPools: (query: ScallopQuery, poolCoinNames?: Suppo
|
|
|
53
41
|
* @param coinPrice - The coin price.
|
|
54
42
|
* @returns Market pool data.
|
|
55
43
|
*/
|
|
56
|
-
export declare const getMarketPool: (query: ScallopQuery, poolCoinName: SupportPoolCoins, indexer
|
|
44
|
+
export declare const getMarketPool: (query: ScallopQuery, poolCoinName: SupportPoolCoins, indexer: boolean | undefined, coinPrice: number, requiredObjects?: {
|
|
45
|
+
balanceSheet: SuiObjectData;
|
|
46
|
+
borrowDynamic: SuiObjectData;
|
|
47
|
+
interestModel: SuiObjectData;
|
|
48
|
+
borrowFeeKey: SuiObjectData;
|
|
49
|
+
supplyLimitKey: SuiObjectData;
|
|
50
|
+
borrowLimitKey: SuiObjectData;
|
|
51
|
+
isolatedAssetKey: SuiObjectData;
|
|
52
|
+
}) => Promise<{
|
|
53
|
+
marketPool: MarketPool;
|
|
54
|
+
collateral?: MarketCollateral;
|
|
55
|
+
} | undefined>;
|
|
57
56
|
/**
|
|
58
57
|
* Get coin market collaterals data.
|
|
59
58
|
*
|
package/dist/queries/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ScallopQuery, ScallopUtils } from '../models';
|
|
2
2
|
import { SupportPoolCoins } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Return list of isolated assets coin types
|
|
5
5
|
* @param utils ScallopUtils
|
|
6
6
|
* @returns list of isolated assets coin types
|
|
7
7
|
*/
|
|
8
|
-
export declare const getIsolatedAssets: (
|
|
8
|
+
export declare const getIsolatedAssets: (query: ScallopQuery) => Promise<string[]>;
|
|
9
9
|
/**
|
|
10
10
|
* Check if the coin type is an isolated asset
|
|
11
11
|
* @param coinName coin name
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SuiObjectDataOptions } from '@mysten/sui/dist/cjs/client';
|
|
2
|
+
import { ScallopCache } from 'src/models/scallopCache';
|
|
3
|
+
export declare const queryMultipleObjects: (cache: ScallopCache, objectIds: string[], options?: SuiObjectDataOptions, partitionSize?: number) => Promise<import("@mysten/sui/dist/cjs/client").SuiObjectData[]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ScallopQuery } from 'src/models';
|
|
2
|
+
import { OptionalKeys } from 'src/types';
|
|
3
|
+
export declare const getAllAddresses: (query: ScallopQuery) => Promise<OptionalKeys<Record<"usdc" | "sbeth" | "weth" | "wbtc" | "wusdc" | "wusdt" | "sui" | "wapt" | "wsol" | "cetus" | "afsui" | "hasui" | "vsui" | "sca" | "fud" | "deep", {
|
|
4
|
+
lendingPoolAddress?: string;
|
|
5
|
+
collateralPoolAddress?: string;
|
|
6
|
+
borrowDynamic?: string;
|
|
7
|
+
spoolReward?: string;
|
|
8
|
+
spool?: string;
|
|
9
|
+
interestModel?: string;
|
|
10
|
+
riskModel?: string;
|
|
11
|
+
borrowFeeKey?: string;
|
|
12
|
+
supplyLimitKey?: string;
|
|
13
|
+
borrowLimitKey?: string;
|
|
14
|
+
isolatedAssetKey?: string;
|
|
15
|
+
}>>>;
|
|
@@ -13,7 +13,7 @@ export type BalanceSheet = {
|
|
|
13
13
|
market_coin_supply: string;
|
|
14
14
|
revenue: string;
|
|
15
15
|
};
|
|
16
|
-
export type
|
|
16
|
+
export type BorrowDynamic = {
|
|
17
17
|
borrow_index: string;
|
|
18
18
|
interest_rate: {
|
|
19
19
|
fields: {
|
|
@@ -23,6 +23,9 @@ export type BorrowIndex = {
|
|
|
23
23
|
interest_rate_scale: string;
|
|
24
24
|
last_updated: string;
|
|
25
25
|
};
|
|
26
|
+
export type BorrowFee = {
|
|
27
|
+
value: string;
|
|
28
|
+
};
|
|
26
29
|
export type InterestModel = {
|
|
27
30
|
base_borrow_rate_per_sec: {
|
|
28
31
|
fields: {
|
|
@@ -135,7 +138,7 @@ export type MarketCollateral = {
|
|
|
135
138
|
coinDecimal: number;
|
|
136
139
|
coinPrice: number;
|
|
137
140
|
isIsolated: boolean;
|
|
138
|
-
} & Required<Pick<ParsedMarketCollateralData, 'collateralFactor' | 'liquidationFactor' | 'liquidationDiscount' | '
|
|
141
|
+
} & Required<Pick<ParsedMarketCollateralData, 'collateralFactor' | 'liquidationFactor' | 'liquidationDiscount' | 'liquidationPenalty' | 'liquidationReserveFactor'>> & CalculatedMarketCollateralData;
|
|
139
142
|
export type OriginMarketPoolData = {
|
|
140
143
|
type: {
|
|
141
144
|
name: string;
|
|
@@ -178,6 +181,9 @@ export type OriginMarketPoolData = {
|
|
|
178
181
|
value: string;
|
|
179
182
|
};
|
|
180
183
|
minBorrowAmount: string;
|
|
184
|
+
isIsolated: boolean;
|
|
185
|
+
supplyLimit: string;
|
|
186
|
+
borrowLimit: string;
|
|
181
187
|
};
|
|
182
188
|
export type ParsedMarketPoolData = {
|
|
183
189
|
coinType: string;
|
|
@@ -199,6 +205,9 @@ export type ParsedMarketPoolData = {
|
|
|
199
205
|
highKink: number;
|
|
200
206
|
midKink: number;
|
|
201
207
|
minBorrowAmount: number;
|
|
208
|
+
isIsolated: boolean;
|
|
209
|
+
supplyLimit: number;
|
|
210
|
+
borrowLimit: number;
|
|
202
211
|
};
|
|
203
212
|
export type CalculatedMarketPoolData = {
|
|
204
213
|
baseBorrowApr: number;
|
|
@@ -207,6 +216,8 @@ export type CalculatedMarketPoolData = {
|
|
|
207
216
|
borrowApyOnHighKink: number;
|
|
208
217
|
borrowAprOnMidKink: number;
|
|
209
218
|
borrowApyOnMidKink: number;
|
|
219
|
+
coinDecimal: number;
|
|
220
|
+
conversionRate: number;
|
|
210
221
|
maxBorrowApr: number;
|
|
211
222
|
maxBorrowApy: number;
|
|
212
223
|
borrowApr: number;
|
|
@@ -222,12 +233,15 @@ export type CalculatedMarketPoolData = {
|
|
|
222
233
|
utilizationRate: number;
|
|
223
234
|
supplyApr: number;
|
|
224
235
|
supplyApy: number;
|
|
225
|
-
|
|
236
|
+
isIsolated: boolean;
|
|
237
|
+
maxSupplyCoin: number;
|
|
238
|
+
maxBorrowCoin: number;
|
|
226
239
|
};
|
|
227
240
|
export type OriginMarketCollateralData = {
|
|
228
241
|
type: {
|
|
229
242
|
name: string;
|
|
230
243
|
};
|
|
244
|
+
isIsolated: boolean;
|
|
231
245
|
collateralFactor: {
|
|
232
246
|
value: string;
|
|
233
247
|
};
|
|
@@ -237,7 +251,7 @@ export type OriginMarketCollateralData = {
|
|
|
237
251
|
liquidationDiscount: {
|
|
238
252
|
value: string;
|
|
239
253
|
};
|
|
240
|
-
|
|
254
|
+
liquidationPenalty: {
|
|
241
255
|
value: string;
|
|
242
256
|
};
|
|
243
257
|
liquidationReserveFactor: {
|
|
@@ -251,12 +265,15 @@ export type ParsedMarketCollateralData = {
|
|
|
251
265
|
collateralFactor: number;
|
|
252
266
|
liquidationFactor: number;
|
|
253
267
|
liquidationDiscount: number;
|
|
254
|
-
|
|
268
|
+
liquidationPenalty: number;
|
|
255
269
|
liquidationReserveFactor: number;
|
|
256
270
|
maxCollateralAmount: number;
|
|
257
271
|
totalCollateralAmount: number;
|
|
272
|
+
isIsolated: boolean;
|
|
258
273
|
};
|
|
259
274
|
export type CalculatedMarketCollateralData = {
|
|
275
|
+
coinDecimal: number;
|
|
276
|
+
isIsolated: boolean;
|
|
260
277
|
maxDepositAmount: number;
|
|
261
278
|
maxDepositCoin: number;
|
|
262
279
|
depositAmount: number;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -8,10 +8,15 @@ export type PoolAddressInfo = {
|
|
|
8
8
|
coingeckoId: string;
|
|
9
9
|
decimal: number;
|
|
10
10
|
pythFeedId: string;
|
|
11
|
-
lendingPoolAddress
|
|
11
|
+
lendingPoolAddress?: string;
|
|
12
12
|
collateralPoolAddress?: string;
|
|
13
|
+
borrowDynamic?: string;
|
|
14
|
+
interestModelId?: string;
|
|
15
|
+
borrowFeeKey?: string;
|
|
16
|
+
supplyLimitKey?: string;
|
|
17
|
+
borrowLimitKey?: string;
|
|
18
|
+
isolatedAssetKey?: string;
|
|
13
19
|
sCoinAddress: string | undefined;
|
|
14
20
|
marketCoinAddress: string;
|
|
15
|
-
coinAddress: string;
|
|
16
21
|
sCoinName: string | undefined;
|
|
17
22
|
};
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/util.d.ts
CHANGED
|
@@ -24,3 +24,4 @@ export declare const parseDataFromPythPriceFeed: (feed: PriceFeed, address: Scal
|
|
|
24
24
|
* @returns Closest round (12AM) in seconds timestamp.
|
|
25
25
|
*/
|
|
26
26
|
export declare const findClosestUnlockRound: (unlockAtInSecondTimestamp: number) => number;
|
|
27
|
+
export declare const partitionArray: <T>(array: T[], chunkSize: number) => T[][];
|