@scallop-io/sui-scallop-sdk 1.5.0-alpha.1 → 1.5.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/index.d.mts +3161 -0
- package/dist/index.d.ts +3161 -3
- package/dist/index.js +78 -9966
- package/dist/index.mjs +15 -9892
- package/package.json +5 -6
- package/src/builders/coreBuilder.ts +10 -14
- package/src/builders/oracle.ts +10 -2
- package/src/constants/coinGecko.ts +14 -4
- package/src/constants/common.ts +8 -1
- package/src/constants/enum.ts +28 -57
- package/src/constants/poolAddress.ts +294 -344
- package/src/constants/pyth.ts +4 -1
- package/src/constants/testAddress.ts +487 -61
- package/src/constants/xoracle.ts +18 -16
- package/src/models/scallopAddress.ts +54 -0
- package/src/models/scallopQuery.ts +8 -12
- package/src/queries/coreQuery.ts +4 -4
- package/src/queries/poolAddressesQuery.ts +2 -2
- package/src/queries/portfolioQuery.ts +7 -8
- package/src/queries/xOracleQuery.ts +15 -7
- package/src/types/address.ts +5 -0
- package/src/types/model.ts +1 -0
- package/src/utils/util.ts +8 -3
- package/dist/builders/borrowIncentiveBuilder.d.ts +0 -12
- package/dist/builders/coreBuilder.d.ts +0 -12
- package/dist/builders/index.d.ts +0 -12
- package/dist/builders/loyaltyProgramBuilder.d.ts +0 -12
- package/dist/builders/oracle.d.ts +0 -14
- package/dist/builders/referralBuilder.d.ts +0 -12
- package/dist/builders/sCoinBuilder.d.ts +0 -4
- package/dist/builders/spoolBuilder.d.ts +0 -12
- package/dist/builders/vescaBuilder.d.ts +0 -25
- package/dist/constants/cache.d.ts +0 -14
- package/dist/constants/coinGecko.d.ts +0 -2
- package/dist/constants/common.d.ts +0 -20
- package/dist/constants/enum.d.ts +0 -14
- package/dist/constants/flashloan.d.ts +0 -2
- package/dist/constants/index.d.ts +0 -13
- package/dist/constants/poolAddress.d.ts +0 -27
- package/dist/constants/pyth.d.ts +0 -5
- package/dist/constants/queryKeys.d.ts +0 -54
- package/dist/constants/rpc.d.ts +0 -1
- package/dist/constants/testAddress.d.ts +0 -2
- package/dist/constants/vesca.d.ts +0 -5
- package/dist/constants/xoracle.d.ts +0 -2
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/models/index.d.ts +0 -8
- package/dist/models/scallop.d.ts +0 -73
- package/dist/models/scallopAddress.d.ts +0 -150
- package/dist/models/scallopBuilder.d.ts +0 -90
- package/dist/models/scallopCache.d.ts +0 -81
- package/dist/models/scallopClient.d.ts +0 -321
- package/dist/models/scallopIndexer.d.ts +0 -90
- package/dist/models/scallopPrice.d.ts +0 -0
- package/dist/models/scallopQuery.d.ts +0 -704
- package/dist/models/scallopUtils.d.ts +0 -229
- package/dist/models/suiKit.d.ts +0 -2
- package/dist/queries/borrowIncentiveQuery.d.ts +0 -82
- package/dist/queries/borrowLimitQuery.d.ts +0 -9
- package/dist/queries/coreQuery.d.ts +0 -171
- package/dist/queries/index.d.ts +0 -15
- package/dist/queries/isolatedAssetQuery.d.ts +0 -14
- package/dist/queries/loyaltyProgramQuery.d.ts +0 -10
- package/dist/queries/objectsQuery.d.ts +0 -2
- package/dist/queries/poolAddressesQuery.d.ts +0 -29
- package/dist/queries/portfolioQuery.d.ts +0 -143
- package/dist/queries/priceQuery.d.ts +0 -58
- package/dist/queries/referralQuery.d.ts +0 -7
- package/dist/queries/sCoinQuery.d.ts +0 -41
- package/dist/queries/spoolQuery.d.ts +0 -74
- package/dist/queries/supplyLimitQuery.d.ts +0 -9
- package/dist/queries/vescaQuery.d.ts +0 -36
- package/dist/queries/xOracleQuery.d.ts +0 -13
- package/dist/types/address.d.ts +0 -108
- package/dist/types/builder/borrowIncentive.d.ts +0 -35
- package/dist/types/builder/core.d.ts +0 -56
- package/dist/types/builder/index.d.ts +0 -24
- package/dist/types/builder/loyaltyProgram.d.ts +0 -23
- package/dist/types/builder/referral.d.ts +0 -30
- package/dist/types/builder/sCoin.d.ts +0 -37
- package/dist/types/builder/spool.d.ts +0 -29
- package/dist/types/builder/vesca.d.ts +0 -51
- package/dist/types/constant/common.d.ts +0 -24
- package/dist/types/constant/enum.d.ts +0 -48
- package/dist/types/constant/index.d.ts +0 -3
- package/dist/types/constant/xOracle.d.ts +0 -9
- package/dist/types/index.d.ts +0 -6
- package/dist/types/model.d.ts +0 -60
- package/dist/types/query/borrowIncentive.d.ts +0 -124
- package/dist/types/query/core.d.ts +0 -380
- package/dist/types/query/index.d.ts +0 -7
- package/dist/types/query/loyaltyProgram.d.ts +0 -5
- package/dist/types/query/portfolio.d.ts +0 -119
- package/dist/types/query/sCoin.d.ts +0 -1
- package/dist/types/query/spool.d.ts +0 -142
- package/dist/types/query/vesca.d.ts +0 -26
- package/dist/types/utils.d.ts +0 -22
- package/dist/utils/builder.d.ts +0 -15
- package/dist/utils/core.d.ts +0 -2
- package/dist/utils/index.d.ts +0 -5
- package/dist/utils/indexer.d.ts +0 -17
- package/dist/utils/query.d.ts +0 -62
- package/dist/utils/util.d.ts +0 -27
package/src/constants/xoracle.ts
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { xOracleListType } from 'src/types';
|
|
2
2
|
|
|
3
3
|
export const xOracleList: xOracleListType = {
|
|
4
|
-
// @TODO: Update to real oracle list
|
|
5
4
|
usdc: { primary: ['pyth'], secondary: [] },
|
|
6
|
-
sbeth: { primary: [], secondary: [] },
|
|
7
|
-
sbusdt: { primary: [], secondary: [] },
|
|
8
|
-
sbwbtc: { primary: [], secondary: [] },
|
|
9
|
-
weth: { primary: [], secondary: [] },
|
|
10
|
-
wbtc: { primary: [], secondary: [] },
|
|
11
|
-
wusdc: { primary: [], secondary: [] },
|
|
12
|
-
wusdt: { primary: [], secondary: [] },
|
|
5
|
+
sbeth: { primary: ['pyth'], secondary: [] },
|
|
6
|
+
sbusdt: { primary: ['pyth'], secondary: [] },
|
|
7
|
+
sbwbtc: { primary: ['pyth'], secondary: [] },
|
|
8
|
+
weth: { primary: ['pyth'], secondary: [] },
|
|
9
|
+
wbtc: { primary: ['pyth'], secondary: [] },
|
|
10
|
+
wusdc: { primary: ['pyth'], secondary: [] },
|
|
11
|
+
wusdt: { primary: ['pyth'], secondary: [] },
|
|
13
12
|
sui: { primary: ['pyth'], secondary: [] },
|
|
14
|
-
wapt: { primary: [], secondary: [] },
|
|
15
|
-
wsol: { primary: [], secondary: [] },
|
|
16
|
-
cetus: { primary: [], secondary: [] },
|
|
17
|
-
afsui: { primary: [], secondary: [] },
|
|
18
|
-
hasui: { primary: [], secondary: [] },
|
|
19
|
-
vsui: { primary: [], secondary: [] },
|
|
13
|
+
wapt: { primary: ['pyth'], secondary: [] },
|
|
14
|
+
wsol: { primary: ['pyth'], secondary: [] },
|
|
15
|
+
cetus: { primary: ['pyth'], secondary: [] },
|
|
16
|
+
afsui: { primary: ['pyth'], secondary: [] },
|
|
17
|
+
hasui: { primary: ['pyth'], secondary: [] },
|
|
18
|
+
vsui: { primary: ['pyth'], secondary: [] },
|
|
20
19
|
sca: { primary: ['pyth'], secondary: [] },
|
|
21
20
|
fud: { primary: ['pyth'], secondary: [] },
|
|
22
21
|
deep: { primary: ['pyth'], secondary: [] },
|
|
23
|
-
fdusd: { primary: [], secondary: [] },
|
|
24
|
-
blub: { primary: [], secondary: [] },
|
|
22
|
+
fdusd: { primary: ['pyth'], secondary: [] },
|
|
23
|
+
blub: { primary: ['pyth'], secondary: [] },
|
|
24
|
+
musd: { primary: ['pyth'], secondary: [] },
|
|
25
|
+
ns: { primary: ['pyth'], secondary: [] },
|
|
26
|
+
usdy: { primary: ['pyth'], secondary: [] },
|
|
25
27
|
};
|
|
@@ -25,6 +25,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
25
25
|
id: '',
|
|
26
26
|
metaData: '',
|
|
27
27
|
treasury: '',
|
|
28
|
+
symbol: '',
|
|
29
|
+
coinType: '',
|
|
30
|
+
decimals: 0,
|
|
28
31
|
oracle: {
|
|
29
32
|
supra: '',
|
|
30
33
|
switchboard: '',
|
|
@@ -38,6 +41,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
38
41
|
id: '',
|
|
39
42
|
metaData: '',
|
|
40
43
|
treasury: '',
|
|
44
|
+
symbol: '',
|
|
45
|
+
coinType: '',
|
|
46
|
+
decimals: 0,
|
|
41
47
|
oracle: {
|
|
42
48
|
supra: '',
|
|
43
49
|
switchboard: '',
|
|
@@ -51,6 +57,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
51
57
|
id: '',
|
|
52
58
|
metaData: '',
|
|
53
59
|
treasury: '',
|
|
60
|
+
symbol: '',
|
|
61
|
+
coinType: '',
|
|
62
|
+
decimals: 0,
|
|
54
63
|
oracle: {
|
|
55
64
|
supra: '',
|
|
56
65
|
switchboard: '',
|
|
@@ -64,6 +73,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
64
73
|
id: '',
|
|
65
74
|
metaData: '',
|
|
66
75
|
treasury: '',
|
|
76
|
+
symbol: '',
|
|
77
|
+
coinType: '',
|
|
78
|
+
decimals: 0,
|
|
67
79
|
oracle: {
|
|
68
80
|
supra: '',
|
|
69
81
|
switchboard: '',
|
|
@@ -77,6 +89,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
77
89
|
id: '',
|
|
78
90
|
metaData: '',
|
|
79
91
|
treasury: '',
|
|
92
|
+
symbol: '',
|
|
93
|
+
coinType: '',
|
|
94
|
+
decimals: 0,
|
|
80
95
|
oracle: {
|
|
81
96
|
supra: '',
|
|
82
97
|
switchboard: '',
|
|
@@ -90,6 +105,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
90
105
|
id: '',
|
|
91
106
|
metaData: '',
|
|
92
107
|
treasury: '',
|
|
108
|
+
symbol: '',
|
|
109
|
+
coinType: '',
|
|
110
|
+
decimals: 0,
|
|
93
111
|
oracle: {
|
|
94
112
|
supra: '',
|
|
95
113
|
switchboard: '',
|
|
@@ -103,6 +121,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
103
121
|
id: '',
|
|
104
122
|
metaData: '',
|
|
105
123
|
treasury: '',
|
|
124
|
+
symbol: '',
|
|
125
|
+
coinType: '',
|
|
126
|
+
decimals: 0,
|
|
106
127
|
oracle: {
|
|
107
128
|
supra: '',
|
|
108
129
|
switchboard: '',
|
|
@@ -116,6 +137,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
116
137
|
id: '',
|
|
117
138
|
metaData: '',
|
|
118
139
|
treasury: '',
|
|
140
|
+
symbol: '',
|
|
141
|
+
coinType: '',
|
|
142
|
+
decimals: 0,
|
|
119
143
|
oracle: {
|
|
120
144
|
supra: '',
|
|
121
145
|
switchboard: '',
|
|
@@ -129,6 +153,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
129
153
|
id: '',
|
|
130
154
|
metaData: '',
|
|
131
155
|
treasury: '',
|
|
156
|
+
symbol: '',
|
|
157
|
+
coinType: '',
|
|
158
|
+
decimals: 0,
|
|
132
159
|
oracle: {
|
|
133
160
|
supra: '',
|
|
134
161
|
switchboard: '',
|
|
@@ -142,6 +169,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
142
169
|
id: '',
|
|
143
170
|
metaData: '',
|
|
144
171
|
treasury: '',
|
|
172
|
+
symbol: '',
|
|
173
|
+
coinType: '',
|
|
174
|
+
decimals: 0,
|
|
145
175
|
oracle: {
|
|
146
176
|
supra: '',
|
|
147
177
|
switchboard: '',
|
|
@@ -155,6 +185,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
155
185
|
id: '',
|
|
156
186
|
metaData: '',
|
|
157
187
|
treasury: '',
|
|
188
|
+
symbol: '',
|
|
189
|
+
coinType: '',
|
|
190
|
+
decimals: 0,
|
|
158
191
|
oracle: {
|
|
159
192
|
supra: '',
|
|
160
193
|
switchboard: '',
|
|
@@ -168,6 +201,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
168
201
|
id: '',
|
|
169
202
|
metaData: '',
|
|
170
203
|
treasury: '',
|
|
204
|
+
symbol: '',
|
|
205
|
+
coinType: '',
|
|
206
|
+
decimals: 0,
|
|
171
207
|
oracle: {
|
|
172
208
|
supra: '',
|
|
173
209
|
switchboard: '',
|
|
@@ -316,38 +352,56 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
316
352
|
ssui: {
|
|
317
353
|
coinType: '',
|
|
318
354
|
treasury: '',
|
|
355
|
+
metaData: '',
|
|
356
|
+
symbol: '',
|
|
319
357
|
},
|
|
320
358
|
scetus: {
|
|
321
359
|
coinType: '',
|
|
322
360
|
treasury: '',
|
|
361
|
+
metaData: '',
|
|
362
|
+
symbol: '',
|
|
323
363
|
},
|
|
324
364
|
ssca: {
|
|
325
365
|
coinType: '',
|
|
326
366
|
treasury: '',
|
|
367
|
+
metaData: '',
|
|
368
|
+
symbol: '',
|
|
327
369
|
},
|
|
328
370
|
swusdc: {
|
|
329
371
|
coinType: '',
|
|
330
372
|
treasury: '',
|
|
373
|
+
metaData: '',
|
|
374
|
+
symbol: '',
|
|
331
375
|
},
|
|
332
376
|
swusdt: {
|
|
333
377
|
coinType: '',
|
|
334
378
|
treasury: '',
|
|
379
|
+
metaData: '',
|
|
380
|
+
symbol: '',
|
|
335
381
|
},
|
|
336
382
|
sweth: {
|
|
337
383
|
coinType: '',
|
|
338
384
|
treasury: '',
|
|
385
|
+
metaData: '',
|
|
386
|
+
symbol: '',
|
|
339
387
|
},
|
|
340
388
|
safsui: {
|
|
341
389
|
coinType: '',
|
|
342
390
|
treasury: '',
|
|
391
|
+
metaData: '',
|
|
392
|
+
symbol: '',
|
|
343
393
|
},
|
|
344
394
|
shasui: {
|
|
345
395
|
coinType: '',
|
|
346
396
|
treasury: '',
|
|
397
|
+
metaData: '',
|
|
398
|
+
symbol: '',
|
|
347
399
|
},
|
|
348
400
|
svsui: {
|
|
349
401
|
coinType: '',
|
|
350
402
|
treasury: '',
|
|
403
|
+
metaData: '',
|
|
404
|
+
symbol: '',
|
|
351
405
|
},
|
|
352
406
|
},
|
|
353
407
|
},
|
|
@@ -297,14 +297,8 @@ export class ScallopQuery {
|
|
|
297
297
|
* @param obligationId - The obligation id.
|
|
298
298
|
* @return Obligation data.
|
|
299
299
|
*/
|
|
300
|
-
public async queryObligation(
|
|
301
|
-
|
|
302
|
-
args?: {
|
|
303
|
-
version: SuiObjectArg;
|
|
304
|
-
market: SuiObjectArg;
|
|
305
|
-
}
|
|
306
|
-
) {
|
|
307
|
-
return queryObligation(this, obligationId, args?.version, args?.market);
|
|
300
|
+
public async queryObligation(obligationId: SuiObjectArg) {
|
|
301
|
+
return queryObligation(this, obligationId);
|
|
308
302
|
}
|
|
309
303
|
|
|
310
304
|
/**
|
|
@@ -883,8 +877,10 @@ export class ScallopQuery {
|
|
|
883
877
|
* Query all address (lending pool, collateral pool, borrow dynamics, interest models, etc.) of all pool
|
|
884
878
|
* @returns
|
|
885
879
|
*/
|
|
886
|
-
public async getPoolAddresses(
|
|
887
|
-
|
|
880
|
+
public async getPoolAddresses(
|
|
881
|
+
pools: SupportPoolCoins[] = [...SUPPORT_POOLS]
|
|
882
|
+
) {
|
|
883
|
+
return getAllAddresses(this, pools);
|
|
888
884
|
}
|
|
889
885
|
|
|
890
886
|
/**
|
|
@@ -922,8 +918,8 @@ export class ScallopQuery {
|
|
|
922
918
|
return SUPPORT_POOLS.reduce(
|
|
923
919
|
(acc, pool) => {
|
|
924
920
|
acc[pool] = {
|
|
925
|
-
primary: primary[pool] ?? [],
|
|
926
|
-
secondary: secondary[pool] ?? [],
|
|
921
|
+
primary: primary?.[pool] ?? [],
|
|
922
|
+
secondary: secondary?.[pool] ?? [],
|
|
927
923
|
};
|
|
928
924
|
return acc;
|
|
929
925
|
},
|
package/src/queries/coreQuery.ts
CHANGED
|
@@ -1007,11 +1007,11 @@ export const queryObligation = async (
|
|
|
1007
1007
|
}: {
|
|
1008
1008
|
address: ScallopAddress;
|
|
1009
1009
|
},
|
|
1010
|
-
obligationId: SuiObjectArg
|
|
1011
|
-
version: SuiObjectArg = address.get('core.version'),
|
|
1012
|
-
market: SuiObjectArg = address.get('core.market')
|
|
1010
|
+
obligationId: SuiObjectArg
|
|
1013
1011
|
) => {
|
|
1014
1012
|
const packageId = address.get('core.packages.query.id');
|
|
1013
|
+
const version = address.get('core.version');
|
|
1014
|
+
const market = address.get('core.market');
|
|
1015
1015
|
const queryTarget = `${packageId}::obligation_query::obligation_data`;
|
|
1016
1016
|
|
|
1017
1017
|
const args = [
|
|
@@ -1023,7 +1023,7 @@ export const queryObligation = async (
|
|
|
1023
1023
|
mutable: false,
|
|
1024
1024
|
initialSharedVersion: '1',
|
|
1025
1025
|
},
|
|
1026
|
-
];
|
|
1026
|
+
];
|
|
1027
1027
|
|
|
1028
1028
|
const queryResult = await address.cache.queryInspectTxn(
|
|
1029
1029
|
{ queryTarget, args }
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { PYTH_FEED_IDS
|
|
1
|
+
import { PYTH_FEED_IDS } from 'src/constants';
|
|
2
2
|
import { ScallopQuery } from 'src/models';
|
|
3
3
|
import { OptionalKeys, SupportPoolCoins } from 'src/types';
|
|
4
4
|
|
|
5
5
|
export const getAllAddresses = async (
|
|
6
6
|
query: ScallopQuery,
|
|
7
|
-
pools: SupportPoolCoins[]
|
|
7
|
+
pools: SupportPoolCoins[]
|
|
8
8
|
) => {
|
|
9
9
|
const results: OptionalKeys<
|
|
10
10
|
Record<
|
|
@@ -435,13 +435,11 @@ export const getObligationAccount = async (
|
|
|
435
435
|
marketCollateral.liquidationFactor
|
|
436
436
|
);
|
|
437
437
|
|
|
438
|
-
const poolSizeAmount = BigNumber(marketCollateral.maxDepositAmount).minus(
|
|
439
|
-
|
|
440
|
-
);
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
poolSizeAmount
|
|
444
|
-
);
|
|
438
|
+
// const poolSizeAmount = BigNumber(marketCollateral.maxDepositAmount).minus(
|
|
439
|
+
// marketCollateral.depositAmount
|
|
440
|
+
// );
|
|
441
|
+
|
|
442
|
+
const availableDepositAmount = BigNumber(coinAmount);
|
|
445
443
|
const availableDepositCoin = availableDepositAmount.shiftedBy(
|
|
446
444
|
-1 * coinDecimal
|
|
447
445
|
);
|
|
@@ -766,7 +764,8 @@ export const getObligationAccount = async (
|
|
|
766
764
|
.shiftedBy(marketPool.coinDecimal)
|
|
767
765
|
.dividedBy(marketPool.coinPrice);
|
|
768
766
|
estimatedAvailableBorrowAmount =
|
|
769
|
-
obligationAccount.totalAvailableCollateralValue !== 0
|
|
767
|
+
obligationAccount.totalAvailableCollateralValue !== 0 &&
|
|
768
|
+
BigNumber(marketPool.maxBorrowCoin).isGreaterThan(marketPool.borrowCoin)
|
|
770
769
|
? minBigNumber(
|
|
771
770
|
estimatedAvailableBorrowAmount
|
|
772
771
|
// Note: reduced chance of failure when calculations are inaccurate
|
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
} from 'src/types';
|
|
8
8
|
|
|
9
9
|
const PRIMARY_PRICE_UPDATE_POLICY =
|
|
10
|
-
'
|
|
10
|
+
'0x56e48a141f20a3a6a6d3fc43e58b01fc63f756c08224870e7890c80ec9d2afee';
|
|
11
11
|
const SECONDARY_PRICE_UPDDATE_POLICY =
|
|
12
|
-
'
|
|
12
|
+
'0xef4d9430ae42c1b24199ac55e87ddd7262622447ee3c7de8868efe839b3d8705';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Query the price update policy table ids. Usually the value for these table will be constant.
|
|
16
16
|
* @param query
|
|
17
|
-
* @returns
|
|
17
|
+
* @returns Primary and Secondary price update policy table object
|
|
18
18
|
*/
|
|
19
19
|
export const getPriceUpdatePolicies = async (
|
|
20
20
|
address: ScallopAddress
|
|
@@ -23,7 +23,6 @@ export const getPriceUpdatePolicies = async (
|
|
|
23
23
|
secondary: SuiObjectResponse | null;
|
|
24
24
|
}> => {
|
|
25
25
|
const priceUpdatePolicyRulesKeyType = `${address.get('core.packages.xOracle.object')}::price_update_policy::PriceUpdatePolicyRulesKey`;
|
|
26
|
-
|
|
27
26
|
const [primaryPriceUpdatePolicyTable, secondaryPriceUpdatePolicyTable] =
|
|
28
27
|
await Promise.all([
|
|
29
28
|
address.cache.queryGetDynamicFieldObject({
|
|
@@ -53,14 +52,23 @@ export const getPriceUpdatePolicies = async (
|
|
|
53
52
|
// const SECONDARY_PRICE_UPDATE_POLICY_KEY =
|
|
54
53
|
// '0x304d226734fa5e376423c9ff0f1d49aeb1e2572d4b617d31e11e2f69865b73ed';
|
|
55
54
|
const PRIMARY_PRICE_UPDATE_POLICY_VECSET_ID =
|
|
56
|
-
'
|
|
55
|
+
'0xc22c9d691ee4c780de09db91d8b487d863211ebf08720772144bcf716318826c';
|
|
57
56
|
const SECONDARY_PRICE_UPDATE_POLICY_VECSET_ID =
|
|
58
|
-
'
|
|
57
|
+
'0x3b184ff859f5de30eeaf186898e5224925be6bb6d2baa74347ef471a8cd1c0d3';
|
|
59
58
|
|
|
60
59
|
export const getAssetOracles = async (
|
|
61
60
|
utils: ScallopUtils,
|
|
62
61
|
ruleType: xOracleRuleType
|
|
63
|
-
): Promise<Record<SupportAssetCoins, SupportOracleType[]
|
|
62
|
+
): Promise<Record<SupportAssetCoins, SupportOracleType[]> | null> => {
|
|
63
|
+
if (ruleType === 'primary' && !PRIMARY_PRICE_UPDATE_POLICY_VECSET_ID) {
|
|
64
|
+
console.error('Primary price update policy vecset id is not set');
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
if (ruleType === 'secondary' && !SECONDARY_PRICE_UPDATE_POLICY_VECSET_ID) {
|
|
68
|
+
console.error('Secondary price update policy vecset id is not set');
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
64
72
|
const ruleTypeNameToOracleType: Record<string, SupportOracleType> = {
|
|
65
73
|
[`${utils.address.get('core.packages.pyth.object')}::rule::Rule`]: 'pyth',
|
|
66
74
|
[`${utils.address.get('core.packages.supra.object')}::rule::Rule`]: 'supra',
|
package/src/types/address.ts
CHANGED
|
@@ -23,6 +23,9 @@ export interface AddressesInterface {
|
|
|
23
23
|
id: string;
|
|
24
24
|
treasury: string;
|
|
25
25
|
metaData: string;
|
|
26
|
+
coinType: string;
|
|
27
|
+
symbol: string;
|
|
28
|
+
decimals: number;
|
|
26
29
|
oracle: {
|
|
27
30
|
[K in SupportOracleType]: K extends (typeof SUPPORT_ORACLES)[0]
|
|
28
31
|
? string
|
|
@@ -130,7 +133,9 @@ export interface AddressesInterface {
|
|
|
130
133
|
SupportSCoin,
|
|
131
134
|
{
|
|
132
135
|
coinType: string;
|
|
136
|
+
symbol: string;
|
|
133
137
|
treasury: string;
|
|
138
|
+
metaData: string;
|
|
134
139
|
}
|
|
135
140
|
>
|
|
136
141
|
>;
|
package/src/types/model.ts
CHANGED
|
@@ -78,6 +78,7 @@ export type ScallopClientParams = ScallopParams &
|
|
|
78
78
|
export type ScallopBuilderParams = ScallopParams & {
|
|
79
79
|
pythEndpoints?: string[];
|
|
80
80
|
usePythPullModel?: boolean;
|
|
81
|
+
useOnChainXOracleList?: boolean;
|
|
81
82
|
} & ScallopQueryParams;
|
|
82
83
|
|
|
83
84
|
export type ScallopQueryParams = ScallopParams & ScallopUtilsParams;
|
package/src/utils/util.ts
CHANGED
|
@@ -55,10 +55,13 @@ export const parseAssetSymbol = (coinName: SupportCoins): string => {
|
|
|
55
55
|
return `w${coinName.slice(1).toUpperCase()}`;
|
|
56
56
|
}
|
|
57
57
|
if (isSuiBridgeAsset(coinName)) {
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
switch (coinName) {
|
|
59
|
+
case 'sbwbtc':
|
|
60
|
+
return 'sbwBTC';
|
|
61
|
+
default: {
|
|
62
|
+
return `sb${coinName.slice(2).toUpperCase()}`;
|
|
63
|
+
}
|
|
60
64
|
}
|
|
61
|
-
return `sb${coinName.slice(2).toUpperCase()}`;
|
|
62
65
|
}
|
|
63
66
|
if (isMarketCoin(coinName)) {
|
|
64
67
|
const assetCoinName = coinName.slice(1).toLowerCase() as SupportAssetCoins;
|
|
@@ -71,6 +74,8 @@ export const parseAssetSymbol = (coinName: SupportCoins): string => {
|
|
|
71
74
|
return 'haSUI';
|
|
72
75
|
case 'vsui':
|
|
73
76
|
return 'vSUI';
|
|
77
|
+
case 'musd':
|
|
78
|
+
return 'mUSD';
|
|
74
79
|
default:
|
|
75
80
|
return coinName.toUpperCase();
|
|
76
81
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
-
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
3
|
-
import type { ScallopBuilder } from 'src/models';
|
|
4
|
-
import type { BorrowIncentiveTxBlock, ScallopTxBlock } from '../types';
|
|
5
|
-
/**
|
|
6
|
-
* Create an enhanced transaction block instance for interaction with borrow incentive modules of the Scallop contract.
|
|
7
|
-
*
|
|
8
|
-
* @param builder - Scallop builder instance.
|
|
9
|
-
* @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
|
|
10
|
-
* @return Scallop borrow incentive txBlock.
|
|
11
|
-
*/
|
|
12
|
-
export declare const newBorrowIncentiveTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) => BorrowIncentiveTxBlock;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
-
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
3
|
-
import type { ScallopBuilder } from '../models';
|
|
4
|
-
import type { CoreTxBlock, ScallopTxBlock, SuiTxBlockWithSpool } from '../types';
|
|
5
|
-
/**
|
|
6
|
-
* Create an enhanced transaction block instance for interaction with core modules of the Scallop contract.
|
|
7
|
-
*
|
|
8
|
-
* @param builder - Scallop builder instance.
|
|
9
|
-
* @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
|
|
10
|
-
* @return Scallop core txBlock.
|
|
11
|
-
*/
|
|
12
|
-
export declare const newCoreTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction | SuiTxBlockWithSpool) => CoreTxBlock;
|
package/dist/builders/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
-
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
3
|
-
import type { ScallopBuilder } from '../models';
|
|
4
|
-
import type { ScallopTxBlock } from '../types';
|
|
5
|
-
/**
|
|
6
|
-
* Create a new ScallopTxBlock instance.
|
|
7
|
-
*
|
|
8
|
-
* @param builder - Scallop builder instance.
|
|
9
|
-
* @param txBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
|
|
10
|
-
* @return ScallopTxBlock.
|
|
11
|
-
*/
|
|
12
|
-
export declare const newScallopTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) => ScallopTxBlock;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
-
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
3
|
-
import { ScallopBuilder } from 'src/models';
|
|
4
|
-
import { LoyaltyProgramTxBlock, ScallopTxBlock } from 'src/types';
|
|
5
|
-
/**
|
|
6
|
-
* Create an enhanced transaction block instance for interaction with loyalty program modules of the Scallop contract.
|
|
7
|
-
*
|
|
8
|
-
* @param builder - Scallop builder instance.
|
|
9
|
-
* @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
|
|
10
|
-
* @return Scallop loyalty program txBlock.
|
|
11
|
-
*/
|
|
12
|
-
export declare const newLoyaltyProgramTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) => LoyaltyProgramTxBlock;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
2
|
-
import type { ScallopBuilder } from '../models';
|
|
3
|
-
import type { SupportAssetCoins } from '../types';
|
|
4
|
-
/**
|
|
5
|
-
* Update the price of the oracle for multiple coin.
|
|
6
|
-
*
|
|
7
|
-
* @param builder - The scallop builder.
|
|
8
|
-
* @param txBlock - TxBlock created by SuiKit.
|
|
9
|
-
* @param assetCoinNames - Specific an array of support asset coin name.
|
|
10
|
-
* @param options - The options for update oracles.
|
|
11
|
-
*/
|
|
12
|
-
export declare const updateOracles: (builder: ScallopBuilder, txBlock: SuiKitTxBlock, assetCoinNames?: SupportAssetCoins[], options?: {
|
|
13
|
-
usePythPullModel: boolean;
|
|
14
|
-
}) => Promise<void>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ScallopBuilder } from 'src/models';
|
|
2
|
-
import { ScallopTxBlock } from 'src/types';
|
|
3
|
-
import { SuiTxBlock as SuiKitTxBlock, Transaction } from '@scallop-io/sui-kit';
|
|
4
|
-
import { ReferralTxBlock } from 'src/types/builder/referral';
|
|
5
|
-
/**
|
|
6
|
-
* Create an enhanced transaction block instance for interaction with borrow incentive modules of the Scallop contract.
|
|
7
|
-
*
|
|
8
|
-
* @param builder - Scallop builder instance.
|
|
9
|
-
* @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
|
|
10
|
-
* @return Scallop referral txBlock.
|
|
11
|
-
*/
|
|
12
|
-
export declare const newReferralTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) => ReferralTxBlock;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Transaction, SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
2
|
-
import { ScallopBuilder } from 'src/models';
|
|
3
|
-
import { BaseScallopTxBlock, SCoinTxBlock, ScallopTxBlock } from 'src/types';
|
|
4
|
-
export declare const newSCoinTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction | BaseScallopTxBlock) => SCoinTxBlock;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
-
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
3
|
-
import type { ScallopBuilder } from '../models';
|
|
4
|
-
import type { SpoolTxBlock, ScallopTxBlock, SuiTxBlockWithSCoin } from '../types';
|
|
5
|
-
/**
|
|
6
|
-
* Create an enhanced transaction block instance for interaction with spool modules of the Scallop contract.
|
|
7
|
-
*
|
|
8
|
-
* @param builder - Scallop builder instance.
|
|
9
|
-
* @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
|
|
10
|
-
* @return Scallop spool txBlock.
|
|
11
|
-
*/
|
|
12
|
-
export declare const newSpoolTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction | SuiTxBlockWithSCoin) => SpoolTxBlock;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { SuiTxBlock, Transaction, SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
2
|
-
import { ScallopBuilder } from '../models';
|
|
3
|
-
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
4
|
-
import type { ScallopTxBlock, VeScaTxBlock } from 'src/types';
|
|
5
|
-
/**
|
|
6
|
-
* Check and get veSCA data from transaction block.
|
|
7
|
-
*
|
|
8
|
-
* @description
|
|
9
|
-
* If the veScaKey id is provided, directly return it.
|
|
10
|
-
* Otherwise, automatically get veScaKey from the sender.
|
|
11
|
-
*
|
|
12
|
-
* @param builder - Scallop builder instance.
|
|
13
|
-
* @param txBlock - TxBlock created by SuiKit.
|
|
14
|
-
* @param veScaKey - veSCA key.
|
|
15
|
-
* @return veSCA key, ID, locked amount and unlock at timestamp.
|
|
16
|
-
*/
|
|
17
|
-
export declare const requireVeSca: (builder: ScallopBuilder, SuiTxBlock: SuiTxBlock, veScaKey?: SuiObjectArg | undefined) => Promise<import("src/types").Vesca | undefined>;
|
|
18
|
-
/**
|
|
19
|
-
* Create an enhanced transaction block instance for interaction with veSCA modules of the Scallop contract.
|
|
20
|
-
*
|
|
21
|
-
* @param builder - Scallop builder instance.
|
|
22
|
-
* @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
|
|
23
|
-
* @return Scallop borrow incentive txBlock.
|
|
24
|
-
*/
|
|
25
|
-
export declare const newVeScaTxBlock: (builder: ScallopBuilder, initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction) => VeScaTxBlock;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default cache options for the QueryClient.
|
|
3
|
-
* @type {QueryClientConfig}
|
|
4
|
-
* @description Default cache options for the QueryClient
|
|
5
|
-
* We set the default to 5s to prevent duplicate requests from being requested (e.g. query MarketObject, etc.)
|
|
6
|
-
*/
|
|
7
|
-
export declare const DEFAULT_CACHE_OPTIONS: {
|
|
8
|
-
defaultOptions: {
|
|
9
|
-
queries: {
|
|
10
|
-
staleTime: number;
|
|
11
|
-
gcTime: number;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare const API_BASE_URL: "https://sui.apis.scallop.io";
|
|
2
|
-
export declare const SDK_API_BASE_URL: "https://sdk.api.scallop.io";
|
|
3
|
-
export declare const IS_VE_SCA_TEST: boolean;
|
|
4
|
-
export declare const USE_TEST_ADDRESS: boolean;
|
|
5
|
-
export declare const ADDRESSES_ID: "65fb07c39c845425d71d7b18" | "675c65cd301dd817ea262e76";
|
|
6
|
-
export declare const PROTOCOL_OBJECT_ID: "0xc9f859f98ca352a11b97a038c4b4162bee437b8df8caa047990fe9cb03d4f778" | "0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf";
|
|
7
|
-
export declare const BORROW_FEE_PROTOCOL_ID: "0xc9f859f98ca352a11b97a038c4b4162bee437b8df8caa047990fe9cb03d4f778" | "0xc38f849e81cfe46d4e4320f508ea7dda42934a329d5a6571bb4c3cb6ea63f5da";
|
|
8
|
-
export declare const SCA_COIN_TYPE: "0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524::sca::SCA" | "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6::sca::SCA";
|
|
9
|
-
export declare const OLD_BORROW_INCENTIVE_PROTOCOL_ID: "0xc63072e7f5f4983a2efaf5bdba1480d5e7d74d57948e1c7cc436f8e22cbeb410";
|
|
10
|
-
export declare const SUPPORT_POOLS: readonly ["usdc", "sbeth", "sbusdt", "sbwbtc", "weth", "wbtc", "wusdc", "wusdt", "sui", "wapt", "wsol", "cetus", "afsui", "hasui", "vsui", "sca", "fud", "deep", "fdusd", "blub"];
|
|
11
|
-
export declare const SUPPORT_COLLATERALS: readonly ["usdc", "sbeth", "sbusdt", "sbwbtc", "weth", "wbtc", "wusdc", "wusdt", "sui", "wapt", "wsol", "cetus", "afsui", "hasui", "vsui", "sca", "fdusd"];
|
|
12
|
-
export declare const SUPPORT_SPOOLS: readonly ["susdc", "sweth", "ssui", "swusdc", "swusdt", "scetus", "safsui", "shasui", "svsui"];
|
|
13
|
-
export declare const SUPPORT_SCOIN: readonly ["susdc", "ssbeth", "ssbusdt", "ssbwbtc", "ssui", "swusdc", "swusdt", "safsui", "shasui", "svsui", "sweth", "ssca", "scetus", "swsol", "swbtc", "sdeep", "sfud", "sfdusd", "sblub"];
|
|
14
|
-
export declare const SUPPORT_SUI_BRIDGE: readonly ["sbeth", "sbusdt", "sbwbtc"];
|
|
15
|
-
export declare const SUPPORT_WORMHOLE: readonly ["wusdc", "wusdt", "weth", "wbtc", "wapt", "wsol"];
|
|
16
|
-
export declare const SUPPORT_SPOOLS_REWARDS: readonly ["sui"];
|
|
17
|
-
export declare const SUPPORT_BORROW_INCENTIVE_POOLS: readonly ["usdc", "sbeth", "sbusdt", "sbwbtc", "weth", "wbtc", "wusdc", "wusdt", "sui", "wapt", "wsol", "cetus", "afsui", "hasui", "vsui", "sca", "fud", "deep", "fdusd", "blub"];
|
|
18
|
-
export declare const SUPPORT_BORROW_INCENTIVE_REWARDS: readonly ["usdc", "sbeth", "sbusdt", "sbwbtc", "weth", "wbtc", "wusdc", "wusdt", "sui", "wapt", "wsol", "cetus", "afsui", "hasui", "vsui", "sca", "fud", "deep", "fdusd", "blub", "susdc", "ssbeth", "ssbusdt", "ssbwbtc", "ssui", "swusdc", "swusdt", "safsui", "shasui", "svsui", "sweth", "ssca", "scetus", "swsol", "swbtc", "sdeep", "sfud", "sfdusd", "sblub"];
|
|
19
|
-
export declare const SUPPORT_ORACLES: readonly ["supra", "switchboard", "pyth"];
|
|
20
|
-
export declare const SUPPORT_PACKAGES: readonly ["coinDecimalsRegistry", "math", "whitelist", "x", "protocol", "protocolWhitelist", "query", "supra", "pyth", "switchboard", "xOracle", "testCoin"];
|
package/dist/constants/enum.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type * as types from '../types';
|
|
2
|
-
export declare const coinDecimals: types.SupportCoinDecimals;
|
|
3
|
-
export declare const assetCoins: types.AssetCoins;
|
|
4
|
-
export declare const marketCoins: types.MarketCoins;
|
|
5
|
-
export declare const sCoins: types.SCoins;
|
|
6
|
-
export declare const stakeMarketCoins: types.StakeMarketCoins;
|
|
7
|
-
export declare const spoolRewardCoins: types.StakeRewardCoins;
|
|
8
|
-
export declare const suiBridgeCoins: types.SuiBridgeCoins;
|
|
9
|
-
export declare const coinIds: types.AssetCoinIds;
|
|
10
|
-
export declare const wormholeCoinIds: types.WormholeCoinIds;
|
|
11
|
-
export declare const voloCoinIds: types.VoloCoinIds;
|
|
12
|
-
export declare const sCoinIds: types.SCoinIds;
|
|
13
|
-
export declare const sCoinTypeToName: Record<string, "susdc" | "ssbeth" | "ssbusdt" | "ssbwbtc" | "sweth" | "swbtc" | "swusdc" | "swusdt" | "ssui" | "swsol" | "scetus" | "safsui" | "shasui" | "svsui" | "ssca" | "sfud" | "sdeep" | "sfdusd" | "sblub">;
|
|
14
|
-
export declare const sCoinRawNameToName: Record<string, "susdc" | "ssbeth" | "ssbusdt" | "ssbwbtc" | "sweth" | "swbtc" | "swusdc" | "swusdt" | "ssui" | "swsol" | "scetus" | "safsui" | "shasui" | "svsui" | "ssca" | "sfud" | "sdeep" | "sfdusd" | "sblub">;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from './cache';
|
|
2
|
-
export * from './coinGecko';
|
|
3
|
-
export * from './common';
|
|
4
|
-
export * from './enum';
|
|
5
|
-
export * from './flashloan';
|
|
6
|
-
export * from './poolAddress';
|
|
7
|
-
export * from './pyth';
|
|
8
|
-
export * from './queryKeys';
|
|
9
|
-
export * from './rpc';
|
|
10
|
-
export * from './testAddress';
|
|
11
|
-
export * from './vesca';
|
|
12
|
-
export * from './testAddress';
|
|
13
|
-
export * from './xoracle';
|