@scallop-io/sui-scallop-sdk 1.3.3-alpha.2 → 1.3.3
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/index.d.ts +0 -1
- package/dist/constants/queryKeys.d.ts +1 -2
- package/dist/index.js +1011 -1022
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1011 -1021
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopIndexer.d.ts +6 -0
- package/dist/models/scallopPrice.d.ts +0 -0
- package/dist/models/scallopQuery.d.ts +6 -0
- package/dist/queries/vescaQuery.d.ts +2 -2
- package/dist/types/query/core.d.ts +0 -1
- package/dist/types/query/portfolio.d.ts +1 -1
- package/dist/types/query/spool.d.ts +1 -0
- package/dist/types/query/vesca.d.ts +1 -1
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +3 -2
- package/src/constants/enum.ts +4 -11
- package/src/constants/index.ts +0 -1
- package/src/constants/queryKeys.ts +2 -2
- package/src/constants/testAddress.ts +35 -76
- package/src/models/scallopBuilder.ts +3 -2
- package/src/models/scallopClient.ts +3 -3
- package/src/models/scallopIndexer.ts +9 -0
- package/src/models/scallopPrice.ts +0 -0
- package/src/models/scallopQuery.ts +12 -4
- package/src/models/scallopUtils.ts +28 -39
- package/src/queries/coreQuery.ts +225 -230
- package/src/queries/isolatedAsset.ts +4 -4
- package/src/queries/portfolioQuery.ts +10 -6
- package/src/queries/referralQuery.ts +1 -0
- package/src/queries/spoolQuery.ts +2 -1
- package/src/queries/vescaQuery.ts +4 -6
- package/src/types/query/core.ts +0 -1
- package/src/types/query/portfolio.ts +1 -0
- package/src/types/query/spool.ts +1 -0
- package/src/types/query/vesca.ts +1 -1
|
@@ -80,4 +80,10 @@ export declare class ScallopIndexer {
|
|
|
80
80
|
borrowValueChangeRatio: number;
|
|
81
81
|
supplyValueChangeRatio: number;
|
|
82
82
|
}>;
|
|
83
|
+
/**
|
|
84
|
+
* Get coin price index data.
|
|
85
|
+
*
|
|
86
|
+
* @return price data.
|
|
87
|
+
*/
|
|
88
|
+
getCoinPrice(poolCoinName: SupportPoolCoins): Promise<number>;
|
|
83
89
|
}
|
|
File without changes
|
|
@@ -465,4 +465,10 @@ export declare class ScallopQuery {
|
|
|
465
465
|
* Check if asset is an isolated asset
|
|
466
466
|
*/
|
|
467
467
|
isIsolatedAsset(assetCoinName: SupportAssetCoins): Promise<boolean>;
|
|
468
|
+
/**
|
|
469
|
+
* Get pool coin price from indexer
|
|
470
|
+
* @param coinName
|
|
471
|
+
* @returns price data
|
|
472
|
+
*/
|
|
473
|
+
getCoinPriceByIndexer(poolName: SupportPoolCoins): Promise<number>;
|
|
468
474
|
}
|
|
@@ -18,7 +18,7 @@ export declare const getVescaKeys: (utils: ScallopUtils, ownerAddress?: string)
|
|
|
18
18
|
*/
|
|
19
19
|
export declare const getVeScas: ({ utils, }: {
|
|
20
20
|
utils: ScallopUtils;
|
|
21
|
-
}, ownerAddress
|
|
21
|
+
}, ownerAddress: string, excludeEmpty?: boolean) => Promise<Vesca[]>;
|
|
22
22
|
/**
|
|
23
23
|
* Get veSca data.
|
|
24
24
|
*
|
|
@@ -27,7 +27,7 @@ export declare const getVeScas: ({ utils, }: {
|
|
|
27
27
|
* @param ownerAddress - The owner address.
|
|
28
28
|
* @returns Vesca data.
|
|
29
29
|
*/
|
|
30
|
-
export declare const getVeSca: (utils: ScallopUtils, veScaKey
|
|
30
|
+
export declare const getVeSca: (utils: ScallopUtils, veScaKey: string | SuiObjectData) => Promise<Vesca | undefined>;
|
|
31
31
|
/**
|
|
32
32
|
* Get veSCA treasury informations
|
|
33
33
|
* @param query
|
|
@@ -133,7 +133,6 @@ export type MarketCollateral = {
|
|
|
133
133
|
coinWrappedType: CoinWrappedType;
|
|
134
134
|
coinDecimal: number;
|
|
135
135
|
coinPrice: number;
|
|
136
|
-
isIsolated: boolean;
|
|
137
136
|
} & Required<Pick<ParsedMarketCollateralData, 'collateralFactor' | 'liquidationFactor' | 'liquidationDiscount' | 'liquidationPanelty' | 'liquidationReserveFactor'>> & CalculatedMarketCollateralData;
|
|
138
137
|
export type OriginMarketPoolData = {
|
|
139
138
|
type: {
|
|
@@ -6,7 +6,7 @@ type OptionalKeys<T> = {
|
|
|
6
6
|
};
|
|
7
7
|
export type Lendings = OptionalKeys<Record<SupportPoolCoins, Lending>>;
|
|
8
8
|
export type ObligationAccounts = OptionalKeys<Record<string, ObligationAccount>>;
|
|
9
|
-
export type Lending = Required<Pick<MarketPool, 'coinName' | 'symbol' | 'coinType' | 'marketCoinType' | 'coinDecimal' | 'coinPrice' | 'conversionRate' | 'isIsolated'> & Pick<Spool, 'marketCoinPrice'>> & {
|
|
9
|
+
export type Lending = Required<Pick<MarketPool, 'coinName' | 'symbol' | 'coinType' | 'marketCoinType' | 'sCoinType' | 'coinDecimal' | 'coinPrice' | 'conversionRate' | 'isIsolated'> & Pick<Spool, 'marketCoinPrice'>> & {
|
|
10
10
|
supplyApr: number;
|
|
11
11
|
supplyApy: number;
|
|
12
12
|
rewardApr: number;
|
package/package.json
CHANGED
|
@@ -255,13 +255,14 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
255
255
|
const bindedVeScaKey =
|
|
256
256
|
await builder.query.getBindedVeScaKey(obligationArg);
|
|
257
257
|
|
|
258
|
-
|
|
258
|
+
const _veScaKey = bindedVeScaKey ?? veScaKey;
|
|
259
|
+
if (!_veScaKey) {
|
|
259
260
|
txBlock.stakeObligation(obligationArg, obligationKeyArg);
|
|
260
261
|
} else {
|
|
261
262
|
txBlock.stakeObligationWithVesca(
|
|
262
263
|
obligationArg,
|
|
263
264
|
obligationKeyArg,
|
|
264
|
-
|
|
265
|
+
_veScaKey
|
|
265
266
|
);
|
|
266
267
|
}
|
|
267
268
|
}
|
package/src/constants/enum.ts
CHANGED
|
@@ -161,21 +161,14 @@ export const sCoinIds: types.SCoinIds = {
|
|
|
161
161
|
'0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC',
|
|
162
162
|
ssbeth:
|
|
163
163
|
'0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH',
|
|
164
|
-
|
|
165
|
-
ssui: '0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI',
|
|
166
|
-
// ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
|
|
164
|
+
ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
|
|
167
165
|
scetus:
|
|
168
166
|
'0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS',
|
|
169
|
-
|
|
170
|
-
ssca: '0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA',
|
|
171
|
-
// '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
|
|
172
|
-
// TODO: Change this to the correct value on production release
|
|
167
|
+
ssca: '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
|
|
173
168
|
swusdc:
|
|
174
|
-
'
|
|
175
|
-
// '0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
|
|
169
|
+
'0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
|
|
176
170
|
swusdt:
|
|
177
|
-
|
|
178
|
-
'0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
|
|
171
|
+
'0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
|
|
179
172
|
sweth:
|
|
180
173
|
'0x67540ceb850d418679e69f1fb6b2093d6df78a2a699ffc733f7646096d552e9b::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH',
|
|
181
174
|
safsui:
|
package/src/constants/index.ts
CHANGED
|
@@ -99,10 +99,10 @@ export const queryKeys = {
|
|
|
99
99
|
],
|
|
100
100
|
},
|
|
101
101
|
oracle: {
|
|
102
|
-
getPythLatestPriceFeed: (pythPriceId?: string
|
|
102
|
+
getPythLatestPriceFeed: (pythPriceId?: string) => [
|
|
103
103
|
'oracle',
|
|
104
104
|
'getPythPriceId',
|
|
105
|
-
{ pythPriceId
|
|
105
|
+
{ pythPriceId },
|
|
106
106
|
],
|
|
107
107
|
},
|
|
108
108
|
};
|
|
@@ -5,17 +5,17 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
5
5
|
// version:
|
|
6
6
|
// '0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7',
|
|
7
7
|
version:
|
|
8
|
-
'
|
|
8
|
+
'0x6156d5cd1538bec8a167a40fe1209a4ec9cf8137921fe0a697f191ac561f0b09',
|
|
9
9
|
versionCap:
|
|
10
10
|
'0x590a4011cb649b3878f3ea14b3a78674642a9548d79b7e091ef679574b158a07',
|
|
11
11
|
// object:
|
|
12
12
|
// '0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf',
|
|
13
13
|
object:
|
|
14
|
-
'
|
|
14
|
+
'0x87ddec2984645dbbe2403a509cc6edf393a43acdba9b77d45da2bcbefcf733c1',
|
|
15
15
|
// market:
|
|
16
16
|
// '0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9',
|
|
17
17
|
market:
|
|
18
|
-
'
|
|
18
|
+
'0x8606ed145cc887985b8ed793f7753ff5dc762a42c379dac035f568e1bac58490',
|
|
19
19
|
adminCap:
|
|
20
20
|
'0x09689d018e71c337d9db6d67cbca06b74ed92196103624028ccc3ecea411777c',
|
|
21
21
|
coinDecimalsRegistry:
|
|
@@ -23,23 +23,8 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
23
23
|
// obligationAccessStore:
|
|
24
24
|
// '0x733e30b7c94d619d78cb8f5bc4bfbb759ced9a531239028caabb2474e5be59c9',
|
|
25
25
|
obligationAccessStore:
|
|
26
|
-
'
|
|
26
|
+
'0x48b472d68ca910c45f7f3b6c26836b6aa6d2569810d94b1b939023da05ae0a23',
|
|
27
27
|
coins: {
|
|
28
|
-
usdc: {
|
|
29
|
-
id: '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7',
|
|
30
|
-
metaData:
|
|
31
|
-
'0x69b7a7c3c200439c1b5f3b19d7d495d5966d5f08de66c69276152f8db3992ec6',
|
|
32
|
-
treasury: '',
|
|
33
|
-
oracle: {
|
|
34
|
-
supra: '',
|
|
35
|
-
switchboard: '',
|
|
36
|
-
pyth: {
|
|
37
|
-
feed: 'eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a',
|
|
38
|
-
feedObject:
|
|
39
|
-
'0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
28
|
cetus: {
|
|
44
29
|
id: '0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b',
|
|
45
30
|
metaData:
|
|
@@ -221,21 +206,6 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
221
206
|
},
|
|
222
207
|
},
|
|
223
208
|
},
|
|
224
|
-
sbeth: {
|
|
225
|
-
id: '0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29',
|
|
226
|
-
metaData:
|
|
227
|
-
'0x89b04ba87f8832d4d76e17a1c9dce72eb3e64d372cf02012b8d2de5384faeef0',
|
|
228
|
-
treasury: '',
|
|
229
|
-
oracle: {
|
|
230
|
-
supra: '',
|
|
231
|
-
switchboard: '',
|
|
232
|
-
pyth: {
|
|
233
|
-
feed: 'ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace',
|
|
234
|
-
feedObject:
|
|
235
|
-
'0x9193fd47f9a0ab99b6e365a464c8a9ae30e6150fc37ed2a89c1586631f6fc4ab',
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
209
|
},
|
|
240
210
|
oracles: {
|
|
241
211
|
xOracle:
|
|
@@ -279,7 +249,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
279
249
|
'0x3f203f6fff6a69d151e4f1cd931f22b68c489ef2759765662fc7baf673943c9e',
|
|
280
250
|
},
|
|
281
251
|
protocol: {
|
|
282
|
-
id: '
|
|
252
|
+
id: '0x87ddec2984645dbbe2403a509cc6edf393a43acdba9b77d45da2bcbefcf733c1',
|
|
283
253
|
upgradeCap:
|
|
284
254
|
'0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a',
|
|
285
255
|
},
|
|
@@ -299,7 +269,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
299
269
|
// '0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f',
|
|
300
270
|
// },
|
|
301
271
|
query: {
|
|
302
|
-
id: '
|
|
272
|
+
id: '0xe4f9d62d17746d5b9dbf0d5557747430021a71575780b515161210cdba0a4c1c',
|
|
303
273
|
upgradeCap:
|
|
304
274
|
'0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f',
|
|
305
275
|
},
|
|
@@ -340,11 +310,6 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
340
310
|
// '0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9',
|
|
341
311
|
'0xc3206071a8d43212efb6e3b5504f2321f8df97ab122b466c0bc7cfdf398dc13a',
|
|
342
312
|
},
|
|
343
|
-
susdc: {
|
|
344
|
-
id: '0x0b5f5f413bd3799e4052c37311966c77f3a4545eb125d2e93e67a68478021918',
|
|
345
|
-
rewardPoolId:
|
|
346
|
-
'0x85ed6ed72ea97c35dbf0cdc7ed6fbc48d8ec15de9b17c74bf4512df8a6d7f166',
|
|
347
|
-
},
|
|
348
313
|
swusdc: {
|
|
349
314
|
// id: '0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0',
|
|
350
315
|
id: '0xf1b383b9cf2e9f515fc69567df1053098f273849d09cd84b0278a773429bd2b2',
|
|
@@ -389,35 +354,35 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
389
354
|
config: '',
|
|
390
355
|
},
|
|
391
356
|
borrowIncentive: {
|
|
392
|
-
id: '
|
|
357
|
+
id: '0x6152f696fc3a658f33c4b891764731a59153125ffedfa8bff7167c42823f58a9',
|
|
393
358
|
adminCap:
|
|
394
|
-
'
|
|
359
|
+
'0xc486afa253646f4d381e81d7f1df8aa4723b845a6bb356f69bad635ffefffe2c',
|
|
395
360
|
object:
|
|
396
|
-
'
|
|
397
|
-
query: '
|
|
361
|
+
'0x002875153e09f8145ab63527bc85c00f2bd102e12f9573c47f8cdf1a1cb62934',
|
|
362
|
+
query: '0x529edc54a3dce2207703ceebbccb0ac14133f7825c1f528775ba0d85a4063489',
|
|
398
363
|
incentivePools:
|
|
399
|
-
'
|
|
364
|
+
'0x6547e143d406b5ccd5f46aae482497de279cc1a68c406f701df70a05f9212ab4',
|
|
400
365
|
incentiveAccounts:
|
|
401
|
-
'
|
|
366
|
+
'0xc4701fdbc1c92f9a636d334d66012b3027659e9fb8aff27279a82edfb6b77d02',
|
|
402
367
|
config:
|
|
403
|
-
'
|
|
368
|
+
'0xdf5d04b4691cc67e82fd4db8394d89ff44823a9de29716c924f74bb4f11cc1f7',
|
|
404
369
|
},
|
|
405
370
|
referral: {
|
|
406
|
-
id: '
|
|
371
|
+
id: '0xa3654ebb63eb06c0f4ff52f8aa6512df9f164f7772bdf15dac3709bd3798dda9',
|
|
407
372
|
object:
|
|
408
373
|
'0x5658d4bf5ddcba27e4337b4262108b3ad1716643cac8c2054ac341538adc72ec',
|
|
409
374
|
adminCap:
|
|
410
375
|
'0xc5dc06b9074291259f2cac460c940012c781c4430e42125c541cc43101c3bcbd',
|
|
411
376
|
referralBindings:
|
|
412
|
-
'
|
|
377
|
+
'0xf63299d58789d99de94092b9011323466e55ca0c1ea1a7a3786a589af46e1c09',
|
|
413
378
|
bindingTableId:
|
|
414
|
-
'
|
|
379
|
+
'0x1c8202b17267ec8d6cf97ca013615354181a04f179570e42601ff2dae19294b1',
|
|
415
380
|
referralRevenuePool:
|
|
416
|
-
'
|
|
381
|
+
'0x6abd852caf90769c1b185cdf636d841673fa95528f0550f018b8a138bd283c07',
|
|
417
382
|
revenueTableId:
|
|
418
383
|
'0x595baa3654c297bff84ab7786a2d250f019cefc66e8df8e89fd9d41e02bd30dd',
|
|
419
384
|
referralTiers:
|
|
420
|
-
'
|
|
385
|
+
'0x962cb903d8d7346190c5204785ccbb91b61086aa764f674c8145df82335cf83e',
|
|
421
386
|
tiersTableId:
|
|
422
387
|
'0xeac755a7a8b7798530905ac79e8c114f19d0f130f6eab012954f08faac29c75d',
|
|
423
388
|
// authorizedWitnessList:
|
|
@@ -425,21 +390,21 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
425
390
|
authorizedWitnessList:
|
|
426
391
|
'0x9d6223dc52015b8a3986a573590ef2af8f1b8f3e4685513888c052f001b87e7f',
|
|
427
392
|
version:
|
|
428
|
-
'
|
|
393
|
+
'0x1bd4b7285f72e11c316b828c7c47b3f4da18dcec9f9b3dba6d8629cbb6f93e5e',
|
|
429
394
|
},
|
|
430
395
|
vesca: {
|
|
431
|
-
id: '
|
|
396
|
+
id: '0xb15b6e0cdd85afb5028bea851dd249405e734d800a259147bbc24980629723a4',
|
|
432
397
|
object:
|
|
433
|
-
'
|
|
398
|
+
'0xb15b6e0cdd85afb5028bea851dd249405e734d800a259147bbc24980629723a4',
|
|
434
399
|
adminCap:
|
|
435
400
|
'0x8ffa76135c5b85c5fbd73a6448a4a733d826cb63a267ab817656acb77c72d4a5',
|
|
436
401
|
tableId:
|
|
437
|
-
'
|
|
438
|
-
table: '
|
|
402
|
+
'0xe3153b2bf124be0b86cb8bd468346a861efd0da52fc42197b54d2f616488a311',
|
|
403
|
+
table: '0x611cb8d9d4d90867467b5ebdf4cc447a0047ed5b01334a28a29fcfe733e3d609',
|
|
439
404
|
treasury:
|
|
440
|
-
'
|
|
405
|
+
'0xe8c112c09b88158dc6c8e23d1fbae5b3c7136cdee54b7dafc08e65db28c4a5bc',
|
|
441
406
|
config:
|
|
442
|
-
'
|
|
407
|
+
'0xe0a2ff281e73c1d53cfa85807080f87e833e4f1a7f93dcf8800b3865269a76b9',
|
|
443
408
|
},
|
|
444
409
|
loyaltyProgram: {
|
|
445
410
|
id: '0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907',
|
|
@@ -451,13 +416,13 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
451
416
|
'0x748a80395849ed37db1b0e14f2ab5d1d96458d2359ab3a84eb079d0f4ac7cf2e',
|
|
452
417
|
},
|
|
453
418
|
scoin: {
|
|
454
|
-
id: '
|
|
419
|
+
id: '0xad2ca2aa5089df94bb2d444d5eb3520378c2f2dfb3a0bd2a2c994145ac4b0a53',
|
|
455
420
|
coins: {
|
|
456
421
|
ssui: {
|
|
457
422
|
coinType:
|
|
458
|
-
'
|
|
423
|
+
'0xfac769100bccc0caebcf4f4e2d00ac2f8883f07f724be28940df90605f5e7e9a::scallop_sui::SCALLOP_SUI',
|
|
459
424
|
treasury:
|
|
460
|
-
'
|
|
425
|
+
'0x9cb4551b36c17d37e19d700147fa819ea1c487ff8bcf18374de2cceb2e9d4845',
|
|
461
426
|
},
|
|
462
427
|
scetus: {
|
|
463
428
|
coinType:
|
|
@@ -467,21 +432,21 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
467
432
|
},
|
|
468
433
|
ssca: {
|
|
469
434
|
coinType:
|
|
470
|
-
'
|
|
435
|
+
'0x0a9d3c6c9af9f6e8def82921541bcbd17f73ed31bed3adcb684f2a4c267e42f0::scallop_sca::SCALLOP_SCA',
|
|
471
436
|
treasury:
|
|
472
|
-
'
|
|
437
|
+
'0xe818636d1d6c46d6ea1a2dce9d94696d7cbc18ce27451b603eeaa47aba8d75e0',
|
|
473
438
|
},
|
|
474
439
|
swusdc: {
|
|
475
440
|
coinType:
|
|
476
|
-
'
|
|
441
|
+
'0xaedc3ab75db8680b81a755015fa90124d217be93457b893c05bac033817defaf::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
|
|
477
442
|
treasury:
|
|
478
|
-
'
|
|
443
|
+
'0xfc6971648f867f7fd6928d1b873af71577e2eaf2c7543ef8bc82c431d833ae78',
|
|
479
444
|
},
|
|
480
445
|
swusdt: {
|
|
481
446
|
coinType:
|
|
482
|
-
'
|
|
447
|
+
'0xbf02fc87ddc104b342ad8414c85ceadf5b0c823c055a06fb0ed776272c01a52a::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
|
|
483
448
|
treasury:
|
|
484
|
-
'
|
|
449
|
+
'0xb9593e2c3a0ba796ee815012b75ae46468ea78cda0188b9ac6816efe65503521',
|
|
485
450
|
},
|
|
486
451
|
sweth: {
|
|
487
452
|
coinType:
|
|
@@ -505,13 +470,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
505
470
|
coinType:
|
|
506
471
|
'0x97023a317320c4498cc4cd239dd02fd30c28246e5e8f81325d63f2bd8d70f6b3::scallop_v_sui::SCALLOP_V_SUI',
|
|
507
472
|
treasury:
|
|
508
|
-
'0x327114f0bf3559d7e2de10282147ed76a236c7c6775029165c4db09a6062ead6',
|
|
509
|
-
},
|
|
510
|
-
ssbeth: {
|
|
511
|
-
coinType:
|
|
512
|
-
'0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH',
|
|
513
|
-
treasury:
|
|
514
|
-
'0xfd0f02def6358a1f266acfa1493d4707ee8387460d434fb667d63d755ff907ed',
|
|
473
|
+
'0x327114f0bf3559d7e2de10282147ed76a236c7c6775029165c4db09a6062ead6ƒ',
|
|
515
474
|
},
|
|
516
475
|
},
|
|
517
476
|
},
|
|
@@ -98,9 +98,10 @@ export class ScallopBuilder {
|
|
|
98
98
|
* @param address - ScallopAddress instance.
|
|
99
99
|
*/
|
|
100
100
|
public async init(force: boolean = false, address?: ScallopAddress) {
|
|
101
|
-
if (
|
|
102
|
-
if (force || !this.address.getAddresses()) {
|
|
101
|
+
if (force || !this.address.getAddresses() || !address?.getAddresses()) {
|
|
103
102
|
await this.address.read();
|
|
103
|
+
} else {
|
|
104
|
+
this.address = address;
|
|
104
105
|
}
|
|
105
106
|
await this.query.init(force, this.address);
|
|
106
107
|
await this.utils.init(force, this.address);
|
|
@@ -518,7 +518,7 @@ export class ScallopClient {
|
|
|
518
518
|
);
|
|
519
519
|
txBlock.transferObjects([coin], sender);
|
|
520
520
|
if (sign && availableStake) {
|
|
521
|
-
await txBlock.
|
|
521
|
+
await txBlock.stakeObligationWithVeScaQuick(obligationId, obligationKey);
|
|
522
522
|
}
|
|
523
523
|
|
|
524
524
|
if (sign) {
|
|
@@ -560,7 +560,7 @@ export class ScallopClient {
|
|
|
560
560
|
}
|
|
561
561
|
await txBlock.repayQuick(amount, poolCoinName, obligationId);
|
|
562
562
|
if (sign && availableStake) {
|
|
563
|
-
await txBlock.
|
|
563
|
+
await txBlock.stakeObligationWithVeScaQuick(obligationId, obligationKey);
|
|
564
564
|
}
|
|
565
565
|
|
|
566
566
|
if (sign) {
|
|
@@ -902,7 +902,7 @@ export class ScallopClient {
|
|
|
902
902
|
const sender = walletAddress || this.walletAddress;
|
|
903
903
|
txBlock.setSender(sender);
|
|
904
904
|
|
|
905
|
-
await txBlock.
|
|
905
|
+
await txBlock.stakeObligationWithVeScaQuick(obligationId, obligationKeyId);
|
|
906
906
|
|
|
907
907
|
if (sign) {
|
|
908
908
|
return (await this.suiKit.signAndSendTxn(
|
|
@@ -264,4 +264,13 @@ export class ScallopIndexer {
|
|
|
264
264
|
throw Error('Failed to getTotalValueLocked.');
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Get coin price index data.
|
|
270
|
+
*
|
|
271
|
+
* @return price data.
|
|
272
|
+
*/
|
|
273
|
+
public async getCoinPrice(poolCoinName: SupportPoolCoins): Promise<number> {
|
|
274
|
+
return (await this.getMarketPool(poolCoinName))?.coinPrice ?? 0;
|
|
275
|
+
}
|
|
267
276
|
}
|
|
File without changes
|
|
@@ -167,11 +167,10 @@ export class ScallopQuery {
|
|
|
167
167
|
* @param address - ScallopAddress instance.
|
|
168
168
|
*/
|
|
169
169
|
public async init(force: boolean = false, address?: ScallopAddress) {
|
|
170
|
-
if (
|
|
171
|
-
this.address = address;
|
|
172
|
-
}
|
|
173
|
-
if (force || !this.address.getAddresses()) {
|
|
170
|
+
if (force || !this.address.getAddresses() || !address?.getAddresses()) {
|
|
174
171
|
await this.address.read();
|
|
172
|
+
} else {
|
|
173
|
+
this.address = address;
|
|
175
174
|
}
|
|
176
175
|
|
|
177
176
|
await this.utils.init(force, this.address);
|
|
@@ -755,4 +754,13 @@ export class ScallopQuery {
|
|
|
755
754
|
public async isIsolatedAsset(assetCoinName: SupportAssetCoins) {
|
|
756
755
|
return isIsolatedAsset(this.utils, assetCoinName);
|
|
757
756
|
}
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Get pool coin price from indexer
|
|
760
|
+
* @param coinName
|
|
761
|
+
* @returns price data
|
|
762
|
+
*/
|
|
763
|
+
public async getCoinPriceByIndexer(poolName: SupportPoolCoins) {
|
|
764
|
+
return this.indexer.getCoinPrice(poolName);
|
|
765
|
+
}
|
|
758
766
|
}
|
|
@@ -129,9 +129,10 @@ export class ScallopUtils {
|
|
|
129
129
|
* @param address - ScallopAddress instance.
|
|
130
130
|
*/
|
|
131
131
|
public async init(force: boolean = false, address?: ScallopAddress) {
|
|
132
|
-
if (
|
|
133
|
-
if (force || !this.address.getAddresses()) {
|
|
132
|
+
if (force || !this.address.getAddresses() || !address?.getAddresses()) {
|
|
134
133
|
await this.address.read();
|
|
134
|
+
} else {
|
|
135
|
+
this.address = address;
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
|
|
@@ -552,51 +553,39 @@ export class ScallopUtils {
|
|
|
552
553
|
const priceId = this.address.get(
|
|
553
554
|
`core.coins.${coinName}.oracle.pyth.feed`
|
|
554
555
|
);
|
|
555
|
-
|
|
556
|
-
acc[coinName] = priceId;
|
|
557
|
-
}
|
|
556
|
+
acc[coinName] = priceId;
|
|
558
557
|
return acc;
|
|
559
558
|
},
|
|
560
559
|
{} as Record<SupportAssetCoins, string>
|
|
561
560
|
);
|
|
562
561
|
|
|
563
562
|
await Promise.allSettled(
|
|
564
|
-
Object.entries(priceIds)
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
priceId,
|
|
573
|
-
endpoint
|
|
574
|
-
),
|
|
575
|
-
queryFn: async () => {
|
|
576
|
-
return (
|
|
577
|
-
(await pythConnection.getLatestPriceFeeds([priceId])) ??
|
|
578
|
-
[]
|
|
579
|
-
);
|
|
580
|
-
},
|
|
581
|
-
});
|
|
582
|
-
if (feed[0]) {
|
|
583
|
-
const data = parseDataFromPythPriceFeed(
|
|
584
|
-
feed[0],
|
|
585
|
-
this.address
|
|
563
|
+
Object.entries(priceIds).map(async ([coinName, priceId]) => {
|
|
564
|
+
const pythConnection = new SuiPriceServiceConnection(endpoint);
|
|
565
|
+
try {
|
|
566
|
+
const feed = await this.cache.queryClient.fetchQuery({
|
|
567
|
+
queryKey: queryKeys.oracle.getPythLatestPriceFeed(priceId),
|
|
568
|
+
queryFn: async () => {
|
|
569
|
+
return (
|
|
570
|
+
(await pythConnection.getLatestPriceFeeds([priceId])) ?? []
|
|
586
571
|
);
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
`Failed to get price ${coinName} feeds with endpoint ${endpoint}: ${e}`
|
|
597
|
-
);
|
|
572
|
+
},
|
|
573
|
+
});
|
|
574
|
+
if (feed[0]) {
|
|
575
|
+
const data = parseDataFromPythPriceFeed(feed[0], this.address);
|
|
576
|
+
this._priceMap.set(coinName as SupportAssetCoins, {
|
|
577
|
+
price: data.price,
|
|
578
|
+
publishTime: data.publishTime,
|
|
579
|
+
});
|
|
580
|
+
coinPrices[coinName as SupportAssetCoins] = data.price;
|
|
598
581
|
}
|
|
599
|
-
|
|
582
|
+
failedRequests.delete(coinName as SupportAssetCoins); // remove success price feed to prevent duplicate request on the next endpoint
|
|
583
|
+
} catch (e) {
|
|
584
|
+
console.warn(
|
|
585
|
+
`Failed to get price ${coinName} feeds with endpoint ${endpoint}: ${e}`
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
})
|
|
600
589
|
);
|
|
601
590
|
if (failedRequests.size === 0) break;
|
|
602
591
|
}
|