@scallop-io/sui-scallop-sdk 0.44.14 → 0.44.15
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 +79 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +79 -9
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopBuilder.d.ts +2 -2
- package/dist/models/scallopQuery.d.ts +12 -3
- package/dist/queries/coreQuery.d.ts +3 -3
- package/dist/queries/spoolQuery.d.ts +3 -0
- package/dist/types/query/portfolio.d.ts +2 -1
- package/package.json +1 -1
- package/src/builders/spoolBuilder.ts +2 -2
- package/src/constants/common.ts +8 -1
- package/src/constants/enum.ts +6 -0
- package/src/models/scallopAddress.ts +16 -0
- package/src/models/scallopBuilder.ts +5 -5
- package/src/queries/portfolioQuery.ts +5 -0
- package/src/queries/spoolQuery.ts +36 -0
- package/src/types/query/portfolio.ts +4 -1
|
@@ -29,9 +29,9 @@ export declare class ScallopBuilder {
|
|
|
29
29
|
/**
|
|
30
30
|
* Request the scallop API to initialize data.
|
|
31
31
|
*
|
|
32
|
-
* @param
|
|
32
|
+
* @param force - Whether to force initialization.
|
|
33
33
|
*/
|
|
34
|
-
init(
|
|
34
|
+
init(force?: boolean): Promise<void>;
|
|
35
35
|
/**
|
|
36
36
|
* Create a scallop txBlock instance that enhances transaction block.
|
|
37
37
|
*
|
|
@@ -151,14 +151,14 @@ export declare class ScallopQuery {
|
|
|
151
151
|
ssui?: number | undefined;
|
|
152
152
|
susdc?: number | undefined;
|
|
153
153
|
susdt?: number | undefined;
|
|
154
|
+
safsui?: number | undefined;
|
|
155
|
+
shasui?: number | undefined;
|
|
156
|
+
svsui?: number | undefined;
|
|
154
157
|
seth?: number | undefined;
|
|
155
158
|
sbtc?: number | undefined;
|
|
156
159
|
sapt?: number | undefined;
|
|
157
160
|
ssol?: number | undefined;
|
|
158
161
|
scetus?: number | undefined;
|
|
159
|
-
safsui?: number | undefined;
|
|
160
|
-
shasui?: number | undefined;
|
|
161
|
-
svsui?: number | undefined;
|
|
162
162
|
}>;
|
|
163
163
|
/**
|
|
164
164
|
* Get market coin amount.
|
|
@@ -186,6 +186,9 @@ export declare class ScallopQuery {
|
|
|
186
186
|
ssui?: import("../types").Spool | undefined;
|
|
187
187
|
susdc?: import("../types").Spool | undefined;
|
|
188
188
|
susdt?: import("../types").Spool | undefined;
|
|
189
|
+
safsui?: import("../types").Spool | undefined;
|
|
190
|
+
shasui?: import("../types").Spool | undefined;
|
|
191
|
+
svsui?: import("../types").Spool | undefined;
|
|
189
192
|
}>;
|
|
190
193
|
/**
|
|
191
194
|
* Get spool data.
|
|
@@ -224,6 +227,9 @@ export declare class ScallopQuery {
|
|
|
224
227
|
ssui?: import("../types").StakePool | undefined;
|
|
225
228
|
susdc?: import("../types").StakePool | undefined;
|
|
226
229
|
susdt?: import("../types").StakePool | undefined;
|
|
230
|
+
safsui?: import("../types").StakePool | undefined;
|
|
231
|
+
shasui?: import("../types").StakePool | undefined;
|
|
232
|
+
svsui?: import("../types").StakePool | undefined;
|
|
227
233
|
}>;
|
|
228
234
|
/**
|
|
229
235
|
* Get stake pool (spool) data.
|
|
@@ -250,6 +256,9 @@ export declare class ScallopQuery {
|
|
|
250
256
|
ssui?: import("../types").StakeRewardPool | undefined;
|
|
251
257
|
susdc?: import("../types").StakeRewardPool | undefined;
|
|
252
258
|
susdt?: import("../types").StakeRewardPool | undefined;
|
|
259
|
+
safsui?: import("../types").StakeRewardPool | undefined;
|
|
260
|
+
shasui?: import("../types").StakeRewardPool | undefined;
|
|
261
|
+
svsui?: import("../types").StakeRewardPool | undefined;
|
|
253
262
|
}>;
|
|
254
263
|
/**
|
|
255
264
|
* Get stake reward pool data.
|
|
@@ -154,14 +154,14 @@ export declare const getMarketCoinAmounts: (query: ScallopQuery, marketCoinNames
|
|
|
154
154
|
ssui?: number | undefined;
|
|
155
155
|
susdc?: number | undefined;
|
|
156
156
|
susdt?: number | undefined;
|
|
157
|
+
safsui?: number | undefined;
|
|
158
|
+
shasui?: number | undefined;
|
|
159
|
+
svsui?: number | undefined;
|
|
157
160
|
seth?: number | undefined;
|
|
158
161
|
sbtc?: number | undefined;
|
|
159
162
|
sapt?: number | undefined;
|
|
160
163
|
ssol?: number | undefined;
|
|
161
164
|
scetus?: number | undefined;
|
|
162
|
-
safsui?: number | undefined;
|
|
163
|
-
shasui?: number | undefined;
|
|
164
|
-
svsui?: number | undefined;
|
|
165
165
|
}>;
|
|
166
166
|
/**
|
|
167
167
|
* Query owned market coin (sCoin) amount.
|
|
@@ -12,6 +12,9 @@ export declare const getSpools: (query: ScallopQuery, stakeMarketCoinNames?: Sup
|
|
|
12
12
|
ssui?: Spool | undefined;
|
|
13
13
|
susdc?: Spool | undefined;
|
|
14
14
|
susdt?: Spool | undefined;
|
|
15
|
+
safsui?: Spool | undefined;
|
|
16
|
+
shasui?: Spool | undefined;
|
|
17
|
+
svsui?: Spool | undefined;
|
|
15
18
|
}>;
|
|
16
19
|
/**
|
|
17
20
|
* Get spool data.
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { MarketPool } from './core';
|
|
2
|
+
import type { Spool } from './spool';
|
|
2
3
|
import type { SupportPoolCoins, SupportCollateralCoins } from '../constant';
|
|
3
4
|
type OptionalKeys<T> = {
|
|
4
5
|
[K in keyof T]?: T[K];
|
|
5
6
|
};
|
|
6
7
|
export type Lendings = OptionalKeys<Record<SupportPoolCoins, Lending>>;
|
|
7
8
|
export type ObligationAccounts = OptionalKeys<Record<string, ObligationAccount>>;
|
|
8
|
-
export type Lending = Required<Pick<MarketPool, 'coinName' | 'symbol' | 'coinType' | 'marketCoinType' | 'coinDecimal' | 'coinPrice'>> & {
|
|
9
|
+
export type Lending = Required<Pick<MarketPool, 'coinName' | 'symbol' | 'coinType' | 'marketCoinType' | 'coinDecimal' | 'coinPrice' | 'conversionRate'> & Pick<Spool, 'marketCoinPrice'>> & {
|
|
9
10
|
supplyApr: number;
|
|
10
11
|
supplyApy: number;
|
|
11
12
|
rewardApr: number;
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ import type {
|
|
|
21
21
|
* Check and get stake account id from transaction block.
|
|
22
22
|
*
|
|
23
23
|
* @description
|
|
24
|
-
* If the stake account id is provided,
|
|
24
|
+
* If the stake account id is provided, directly return it.
|
|
25
25
|
* Otherwise, automatically get all stake account id from the sender.
|
|
26
26
|
*
|
|
27
27
|
* @param builder - Scallop builder instance.
|
|
@@ -52,7 +52,7 @@ const requireStakeAccountIds = async (
|
|
|
52
52
|
* Check and get stake accounts information from transaction block.
|
|
53
53
|
*
|
|
54
54
|
* @description
|
|
55
|
-
* If the stake account id is provided,
|
|
55
|
+
* If the stake account id is provided, directly return its account.
|
|
56
56
|
* Otherwise, automatically get all stake account from the sender.
|
|
57
57
|
*
|
|
58
58
|
* @param builder - Scallop builder instance.
|
package/src/constants/common.ts
CHANGED
|
@@ -37,7 +37,14 @@ export const SUPPORT_COLLATERALS = [
|
|
|
37
37
|
'vsui',
|
|
38
38
|
] as const;
|
|
39
39
|
|
|
40
|
-
export const SUPPORT_SPOOLS = [
|
|
40
|
+
export const SUPPORT_SPOOLS = [
|
|
41
|
+
'ssui',
|
|
42
|
+
'susdc',
|
|
43
|
+
'susdt',
|
|
44
|
+
'safsui',
|
|
45
|
+
'shasui',
|
|
46
|
+
'svsui',
|
|
47
|
+
] as const;
|
|
41
48
|
|
|
42
49
|
export const SUPPORT_SPOOLS_REWARDS = ['sui'] as const;
|
|
43
50
|
|
package/src/constants/enum.ts
CHANGED
|
@@ -67,12 +67,18 @@ export const stakeMarketCoins: StakeMarketCoins = {
|
|
|
67
67
|
ssui: 'ssui',
|
|
68
68
|
susdc: 'susdc',
|
|
69
69
|
susdt: 'susdt',
|
|
70
|
+
safsui: 'safsui',
|
|
71
|
+
shasui: 'shasui',
|
|
72
|
+
svsui: 'svsui',
|
|
70
73
|
};
|
|
71
74
|
|
|
72
75
|
export const spoolRewardCoins: StakeRewardCoins = {
|
|
73
76
|
ssui: 'sui',
|
|
74
77
|
susdc: 'sui',
|
|
75
78
|
susdt: 'sui',
|
|
79
|
+
safsui: 'sui',
|
|
80
|
+
shasui: 'sui',
|
|
81
|
+
svsui: 'sui',
|
|
76
82
|
};
|
|
77
83
|
|
|
78
84
|
export const borrowIncentiveRewardCoins: BorrowIncentiveRewardCoins = {
|
|
@@ -199,6 +199,22 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
199
199
|
id: '',
|
|
200
200
|
rewardPoolId: '',
|
|
201
201
|
},
|
|
202
|
+
susdt: {
|
|
203
|
+
id: '',
|
|
204
|
+
rewardPoolId: '',
|
|
205
|
+
},
|
|
206
|
+
safsui: {
|
|
207
|
+
id: '',
|
|
208
|
+
rewardPoolId: '',
|
|
209
|
+
},
|
|
210
|
+
shasui: {
|
|
211
|
+
id: '',
|
|
212
|
+
rewardPoolId: '',
|
|
213
|
+
},
|
|
214
|
+
svsui: {
|
|
215
|
+
id: '',
|
|
216
|
+
rewardPoolId: '',
|
|
217
|
+
},
|
|
202
218
|
},
|
|
203
219
|
},
|
|
204
220
|
borrowIncentive: {
|
|
@@ -73,14 +73,14 @@ export class ScallopBuilder {
|
|
|
73
73
|
/**
|
|
74
74
|
* Request the scallop API to initialize data.
|
|
75
75
|
*
|
|
76
|
-
* @param
|
|
76
|
+
* @param force - Whether to force initialization.
|
|
77
77
|
*/
|
|
78
|
-
public async init(
|
|
79
|
-
if (
|
|
78
|
+
public async init(force: boolean = false) {
|
|
79
|
+
if (force || !this.address.getAddresses()) {
|
|
80
80
|
await this.address.read();
|
|
81
81
|
}
|
|
82
|
-
await this.query.init(
|
|
83
|
-
await this.utils.init(
|
|
82
|
+
await this.query.init(force);
|
|
83
|
+
await this.utils.init(force);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
/**
|
|
@@ -200,6 +200,9 @@ export const getLending = async (
|
|
|
200
200
|
const suppliedCoin = suppliedAmount.shiftedBy(-1 * coinDecimal);
|
|
201
201
|
const suppliedValue = suppliedCoin.multipliedBy(coinPrice ?? 0);
|
|
202
202
|
|
|
203
|
+
const marketCoinPrice = BigNumber(coinPrice ?? 0).multipliedBy(
|
|
204
|
+
marketPool?.conversionRate ?? 1
|
|
205
|
+
);
|
|
203
206
|
const unstakedMarketAmount = BigNumber(marketCoinAmount);
|
|
204
207
|
const unstakedMarketCoin = unstakedMarketAmount.shiftedBy(-1 * coinDecimal);
|
|
205
208
|
|
|
@@ -221,6 +224,8 @@ export const getLending = async (
|
|
|
221
224
|
marketCoinType: query.utils.parseMarketCoinType(poolCoinName),
|
|
222
225
|
coinDecimal: coinDecimal,
|
|
223
226
|
coinPrice: coinPrice ?? 0,
|
|
227
|
+
conversionRate: marketPool?.conversionRate ?? 1,
|
|
228
|
+
marketCoinPrice: marketCoinPrice.toNumber(),
|
|
224
229
|
supplyApr: marketPool?.supplyApr ?? 0,
|
|
225
230
|
supplyApy: marketPool?.supplyApy ?? 0,
|
|
226
231
|
rewardApr: spool?.rewardApr ?? 0,
|
|
@@ -292,6 +292,9 @@ export const getStakeAccounts = async (
|
|
|
292
292
|
ssui: [],
|
|
293
293
|
susdc: [],
|
|
294
294
|
susdt: [],
|
|
295
|
+
safsui: [],
|
|
296
|
+
shasui: [],
|
|
297
|
+
svsui: [],
|
|
295
298
|
};
|
|
296
299
|
|
|
297
300
|
const stakeMarketCoinTypes: Record<SupportStakeMarketCoins, string> =
|
|
@@ -357,6 +360,39 @@ export const getStakeAccounts = async (
|
|
|
357
360
|
points,
|
|
358
361
|
totalPoints,
|
|
359
362
|
});
|
|
363
|
+
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.safsui) {
|
|
364
|
+
stakeAccounts.safsui.push({
|
|
365
|
+
id,
|
|
366
|
+
type: normalizeStructTag(type),
|
|
367
|
+
stakePoolId,
|
|
368
|
+
stakeType: normalizeStructTag(stakeType),
|
|
369
|
+
staked,
|
|
370
|
+
index,
|
|
371
|
+
points,
|
|
372
|
+
totalPoints,
|
|
373
|
+
});
|
|
374
|
+
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.shasui) {
|
|
375
|
+
stakeAccounts.shasui.push({
|
|
376
|
+
id,
|
|
377
|
+
type: normalizeStructTag(type),
|
|
378
|
+
stakePoolId,
|
|
379
|
+
stakeType: normalizeStructTag(stakeType),
|
|
380
|
+
staked,
|
|
381
|
+
index,
|
|
382
|
+
points,
|
|
383
|
+
totalPoints,
|
|
384
|
+
});
|
|
385
|
+
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.svsui) {
|
|
386
|
+
stakeAccounts.svsui.push({
|
|
387
|
+
id,
|
|
388
|
+
type: normalizeStructTag(type),
|
|
389
|
+
stakePoolId,
|
|
390
|
+
stakeType: normalizeStructTag(stakeType),
|
|
391
|
+
staked,
|
|
392
|
+
index,
|
|
393
|
+
points,
|
|
394
|
+
totalPoints,
|
|
395
|
+
});
|
|
360
396
|
}
|
|
361
397
|
}
|
|
362
398
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { MarketPool } from './core';
|
|
2
|
+
import type { Spool } from './spool';
|
|
2
3
|
import type { SupportPoolCoins, SupportCollateralCoins } from '../constant';
|
|
3
4
|
|
|
4
5
|
type OptionalKeys<T> = {
|
|
@@ -19,7 +20,9 @@ export type Lending = Required<
|
|
|
19
20
|
| 'marketCoinType'
|
|
20
21
|
| 'coinDecimal'
|
|
21
22
|
| 'coinPrice'
|
|
22
|
-
|
|
23
|
+
| 'conversionRate'
|
|
24
|
+
> &
|
|
25
|
+
Pick<Spool, 'marketCoinPrice'>
|
|
23
26
|
> & {
|
|
24
27
|
supplyApr: number;
|
|
25
28
|
supplyApy: number;
|