@scallop-io/sui-scallop-sdk 1.3.4-alpha.6 → 1.3.4-isolated-asset.2
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/builders/borrowIncentiveBuilder.d.ts +12 -0
- package/dist/builders/coreBuilder.d.ts +12 -0
- package/dist/builders/index.d.ts +12 -0
- package/dist/builders/loyaltyProgramBuilder.d.ts +12 -0
- package/dist/builders/oracle.d.ts +14 -0
- package/dist/builders/referralBuilder.d.ts +12 -0
- package/dist/builders/sCoinBuilder.d.ts +4 -0
- package/dist/builders/spoolBuilder.d.ts +12 -0
- package/dist/builders/vescaBuilder.d.ts +25 -0
- package/dist/constants/cache.d.ts +14 -0
- package/dist/constants/coinGecko.d.ts +2 -0
- package/dist/constants/common.d.ts +20 -0
- package/dist/constants/enum.d.ts +14 -0
- package/dist/constants/flashloan.d.ts +2 -0
- package/dist/constants/index.d.ts +13 -0
- package/dist/constants/poolAddress.d.ts +5 -0
- package/dist/constants/pyth.d.ts +5 -0
- package/dist/constants/queryKeys.d.ts +56 -0
- package/dist/constants/rpc.d.ts +1 -0
- package/dist/constants/testAddress.d.ts +2 -0
- package/dist/constants/tokenBucket.d.ts +2 -0
- package/dist/constants/vesca.d.ts +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +438 -331
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +438 -331
- package/dist/index.mjs.map +1 -1
- package/dist/models/index.d.ts +8 -0
- package/dist/models/scallop.d.ts +74 -0
- package/dist/models/scallopAddress.d.ts +150 -0
- package/dist/models/scallopBuilder.d.ts +89 -0
- package/dist/models/scallopCache.d.ts +74 -0
- package/dist/models/scallopClient.d.ts +321 -0
- package/dist/models/scallopIndexer.d.ts +89 -0
- package/dist/models/scallopQuery.d.ts +497 -0
- package/dist/models/scallopUtils.d.ts +227 -0
- package/dist/models/suiKit.d.ts +2 -0
- package/dist/queries/borrowIncentiveQuery.d.ts +61 -0
- package/dist/queries/borrowLimitQuery.d.ts +9 -0
- package/dist/queries/coreQuery.d.ts +169 -0
- package/dist/queries/index.d.ts +12 -0
- package/dist/queries/isolatedAssetQuery.d.ts +14 -0
- package/dist/queries/loyaltyProgramQuery.d.ts +10 -0
- package/dist/queries/portfolioQuery.d.ts +75 -0
- package/dist/queries/priceQuery.d.ts +16 -0
- package/dist/queries/referralQuery.d.ts +7 -0
- package/dist/queries/sCoinQuery.d.ts +41 -0
- package/dist/queries/spoolQuery.d.ts +70 -0
- package/dist/queries/supplyLimitQuery.d.ts +9 -0
- package/dist/queries/vescaQuery.d.ts +36 -0
- package/dist/types/address.d.ts +107 -0
- package/dist/types/builder/borrowIncentive.d.ts +35 -0
- package/dist/types/builder/core.d.ts +56 -0
- package/dist/types/builder/index.d.ts +24 -0
- package/dist/types/builder/loyaltyProgram.d.ts +23 -0
- package/dist/types/builder/referral.d.ts +30 -0
- package/dist/types/builder/sCoin.d.ts +37 -0
- package/dist/types/builder/spool.d.ts +29 -0
- package/dist/types/builder/vesca.d.ts +51 -0
- package/dist/types/constant/common.d.ts +24 -0
- package/dist/types/constant/enum.d.ts +48 -0
- package/dist/types/constant/index.d.ts +2 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/model.d.ts +54 -0
- package/dist/types/query/borrowIncentive.d.ts +124 -0
- package/dist/types/query/core.d.ts +363 -0
- package/dist/types/query/index.d.ts +7 -0
- package/dist/types/query/loyaltyProgram.d.ts +5 -0
- package/dist/types/query/portfolio.d.ts +115 -0
- package/dist/types/query/sCoin.d.ts +1 -0
- package/dist/types/query/spool.d.ts +122 -0
- package/dist/types/query/vesca.d.ts +26 -0
- package/dist/types/utils.d.ts +21 -0
- package/dist/utils/builder.d.ts +15 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/indexer.d.ts +17 -0
- package/dist/utils/query.d.ts +62 -0
- package/dist/utils/tokenBucket.d.ts +11 -0
- package/dist/utils/util.d.ts +26 -0
- package/package.json +2 -2
- package/src/constants/coinGecko.ts +4 -2
- package/src/constants/common.ts +2 -0
- package/src/constants/enum.ts +25 -4
- package/src/constants/index.ts +1 -0
- package/src/constants/poolAddress.ts +7 -1
- package/src/constants/pyth.ts +2 -0
- package/src/constants/testAddress.ts +76 -35
- package/src/models/scallopBuilder.ts +2 -3
- package/src/models/scallopQuery.ts +26 -18
- package/src/models/scallopUtils.ts +5 -6
- package/src/queries/borrowLimitQuery.ts +53 -0
- package/src/queries/coreQuery.ts +238 -229
- package/src/queries/index.ts +1 -0
- package/src/queries/isolatedAssetQuery.ts +5 -5
- package/src/queries/referralQuery.ts +0 -1
- package/src/queries/spoolQuery.ts +1 -1
- package/src/queries/supplyLimitQuery.ts +23 -18
- package/src/types/query/core.ts +2 -0
- package/src/types/utils.ts +1 -1
|
@@ -5,17 +5,17 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
5
5
|
// version:
|
|
6
6
|
// '0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7',
|
|
7
7
|
version:
|
|
8
|
-
'
|
|
8
|
+
'0xd318de9b0f6873879a82cbfcc2daa1d1591a8b54e7cea9f4b567da63c692a52b',
|
|
9
9
|
versionCap:
|
|
10
10
|
'0x590a4011cb649b3878f3ea14b3a78674642a9548d79b7e091ef679574b158a07',
|
|
11
11
|
// object:
|
|
12
12
|
// '0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf',
|
|
13
13
|
object:
|
|
14
|
-
'
|
|
14
|
+
'0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d',
|
|
15
15
|
// market:
|
|
16
16
|
// '0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9',
|
|
17
17
|
market:
|
|
18
|
-
'
|
|
18
|
+
'0x9d6434e97f3f98fd9b0c0e1dca22632073985abcd22541feae7ee1e34cbe3af2',
|
|
19
19
|
adminCap:
|
|
20
20
|
'0x09689d018e71c337d9db6d67cbca06b74ed92196103624028ccc3ecea411777c',
|
|
21
21
|
coinDecimalsRegistry:
|
|
@@ -23,8 +23,23 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
23
23
|
// obligationAccessStore:
|
|
24
24
|
// '0x733e30b7c94d619d78cb8f5bc4bfbb759ced9a531239028caabb2474e5be59c9',
|
|
25
25
|
obligationAccessStore:
|
|
26
|
-
'
|
|
26
|
+
'0x46e9b44a77ee9c9d33cc2689ecdfbb8f681935cbc6bdf6ac3df048e396c36c82',
|
|
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
|
+
},
|
|
28
43
|
cetus: {
|
|
29
44
|
id: '0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b',
|
|
30
45
|
metaData:
|
|
@@ -206,6 +221,21 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
206
221
|
},
|
|
207
222
|
},
|
|
208
223
|
},
|
|
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
|
+
},
|
|
209
239
|
},
|
|
210
240
|
oracles: {
|
|
211
241
|
xOracle:
|
|
@@ -249,7 +279,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
249
279
|
'0x3f203f6fff6a69d151e4f1cd931f22b68c489ef2759765662fc7baf673943c9e',
|
|
250
280
|
},
|
|
251
281
|
protocol: {
|
|
252
|
-
id: '
|
|
282
|
+
id: '0xb784ea287d944e478a3ceaa071f8885072cce6b7224cf245914dc2f9963f460e',
|
|
253
283
|
upgradeCap:
|
|
254
284
|
'0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a',
|
|
255
285
|
},
|
|
@@ -269,7 +299,7 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
269
299
|
// '0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f',
|
|
270
300
|
// },
|
|
271
301
|
query: {
|
|
272
|
-
id: '
|
|
302
|
+
id: '0x89706958f43fb170de134579e3fbc53972b946ee78bd2442d8e1adc36074fbdc',
|
|
273
303
|
upgradeCap:
|
|
274
304
|
'0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f',
|
|
275
305
|
},
|
|
@@ -310,6 +340,11 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
310
340
|
// '0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9',
|
|
311
341
|
'0xc3206071a8d43212efb6e3b5504f2321f8df97ab122b466c0bc7cfdf398dc13a',
|
|
312
342
|
},
|
|
343
|
+
susdc: {
|
|
344
|
+
id: '0x0b5f5f413bd3799e4052c37311966c77f3a4545eb125d2e93e67a68478021918',
|
|
345
|
+
rewardPoolId:
|
|
346
|
+
'0x85ed6ed72ea97c35dbf0cdc7ed6fbc48d8ec15de9b17c74bf4512df8a6d7f166',
|
|
347
|
+
},
|
|
313
348
|
swusdc: {
|
|
314
349
|
// id: '0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0',
|
|
315
350
|
id: '0xf1b383b9cf2e9f515fc69567df1053098f273849d09cd84b0278a773429bd2b2',
|
|
@@ -354,35 +389,35 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
354
389
|
config: '',
|
|
355
390
|
},
|
|
356
391
|
borrowIncentive: {
|
|
357
|
-
id: '
|
|
392
|
+
id: '0x85769d63565ce99c7622f8e336ca1460926ddf29738ad2a39407b5cac29f61fe',
|
|
358
393
|
adminCap:
|
|
359
|
-
'
|
|
394
|
+
'0x56ac8e6f2b360b2b35c0168d72cc6cd17d9592afb83709865cb87af24bb2025b',
|
|
360
395
|
object:
|
|
361
|
-
'
|
|
362
|
-
query: '
|
|
396
|
+
'0x85769d63565ce99c7622f8e336ca1460926ddf29738ad2a39407b5cac29f61fe',
|
|
397
|
+
query: '0x8e0d00f8ff1199d7c5fe56cea0e901a525daeefff0445a1635ace8282ae3302c',
|
|
363
398
|
incentivePools:
|
|
364
|
-
'
|
|
399
|
+
'0x9d564c93128c6ab0c0d3e050a47f11df0b91494f3bb779bdc1301c1c637f15eb',
|
|
365
400
|
incentiveAccounts:
|
|
366
|
-
'
|
|
401
|
+
'0x09e6040e798246de04941bc79a3ba62d3eca6d7a218cc30f21fb07f478fa2926',
|
|
367
402
|
config:
|
|
368
|
-
'
|
|
403
|
+
'0x43d4ca1dfc90b161c4240facd119e74e4b850cca2957f88c2ec289c9380da064',
|
|
369
404
|
},
|
|
370
405
|
referral: {
|
|
371
|
-
id: '
|
|
406
|
+
id: '0x1bf5a8ce77050d8052549d743e16b469f15aa6b81b752b78b6ebb65179665f5a',
|
|
372
407
|
object:
|
|
373
408
|
'0x5658d4bf5ddcba27e4337b4262108b3ad1716643cac8c2054ac341538adc72ec',
|
|
374
409
|
adminCap:
|
|
375
410
|
'0xc5dc06b9074291259f2cac460c940012c781c4430e42125c541cc43101c3bcbd',
|
|
376
411
|
referralBindings:
|
|
377
|
-
'
|
|
412
|
+
'0xcf184487782bed962bf678001efe775d31fb94b9992333a57594cf15d79d5ced',
|
|
378
413
|
bindingTableId:
|
|
379
|
-
'
|
|
414
|
+
'0x41a50e258c0a266ce84e0e1a618dbf70b878cc943909e613089a50afcceb2bc0',
|
|
380
415
|
referralRevenuePool:
|
|
381
|
-
'
|
|
416
|
+
'0xc24e3e5e37032f29a3dd91a9a1f057af8821b7e6c148e9683900ac8b6d30f0c6',
|
|
382
417
|
revenueTableId:
|
|
383
418
|
'0x595baa3654c297bff84ab7786a2d250f019cefc66e8df8e89fd9d41e02bd30dd',
|
|
384
419
|
referralTiers:
|
|
385
|
-
'
|
|
420
|
+
'0x144350f3db9b46d11b140084cd54e6de0b9c3b8d265ce8059b51d0ef58ea464b',
|
|
386
421
|
tiersTableId:
|
|
387
422
|
'0xeac755a7a8b7798530905ac79e8c114f19d0f130f6eab012954f08faac29c75d',
|
|
388
423
|
// authorizedWitnessList:
|
|
@@ -390,21 +425,21 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
390
425
|
authorizedWitnessList:
|
|
391
426
|
'0x9d6223dc52015b8a3986a573590ef2af8f1b8f3e4685513888c052f001b87e7f',
|
|
392
427
|
version:
|
|
393
|
-
'
|
|
428
|
+
'0x3545849eb97723e676a476ec9d4fe5f2eb0eb2c6b78972851114fd4c7ed4639f',
|
|
394
429
|
},
|
|
395
430
|
vesca: {
|
|
396
|
-
id: '
|
|
431
|
+
id: '0x1158813b32962c2d22888fae257d5f2365b03631f0cd5d5b912ccdf51ff4e2f2',
|
|
397
432
|
object:
|
|
398
|
-
'
|
|
433
|
+
'0x1158813b32962c2d22888fae257d5f2365b03631f0cd5d5b912ccdf51ff4e2f2',
|
|
399
434
|
adminCap:
|
|
400
435
|
'0x8ffa76135c5b85c5fbd73a6448a4a733d826cb63a267ab817656acb77c72d4a5',
|
|
401
436
|
tableId:
|
|
402
|
-
'
|
|
403
|
-
table: '
|
|
437
|
+
'0x0a0b7f749baeb61e3dfee2b42245e32d0e6b484063f0a536b33e771d573d7246',
|
|
438
|
+
table: '0xd3a4632b1080f7d96e1c2487d4dabf2c1196916937c505a69954ac9f393be8d0',
|
|
404
439
|
treasury:
|
|
405
|
-
'
|
|
440
|
+
'0xafa4b6231e49c15a22d641ce33fda761baaf650fa21899dfa2eb1716146e7306',
|
|
406
441
|
config:
|
|
407
|
-
'
|
|
442
|
+
'0x7cbcb0a342179577a117dfdff974cf1ab765d3b571067bf22ddf5f9e3a667922',
|
|
408
443
|
},
|
|
409
444
|
loyaltyProgram: {
|
|
410
445
|
id: '0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907',
|
|
@@ -416,13 +451,13 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
416
451
|
'0x748a80395849ed37db1b0e14f2ab5d1d96458d2359ab3a84eb079d0f4ac7cf2e',
|
|
417
452
|
},
|
|
418
453
|
scoin: {
|
|
419
|
-
id: '
|
|
454
|
+
id: '0x773dab39c90fe05439b06a2d061795e52a974ff92c2aef90b2ee467acf7f33c8',
|
|
420
455
|
coins: {
|
|
421
456
|
ssui: {
|
|
422
457
|
coinType:
|
|
423
|
-
'
|
|
458
|
+
'0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI',
|
|
424
459
|
treasury:
|
|
425
|
-
'
|
|
460
|
+
'0x0e499640a12c38dd9cc44532f5bc5fd1b6da86d2f9a8810357250f4b26e9e5c7',
|
|
426
461
|
},
|
|
427
462
|
scetus: {
|
|
428
463
|
coinType:
|
|
@@ -432,21 +467,21 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
432
467
|
},
|
|
433
468
|
ssca: {
|
|
434
469
|
coinType:
|
|
435
|
-
'
|
|
470
|
+
'0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA',
|
|
436
471
|
treasury:
|
|
437
|
-
'
|
|
472
|
+
'0x5f1c5de1df7341075d119570269b7b452af50afe8363080638f1ae29a554c038',
|
|
438
473
|
},
|
|
439
474
|
swusdc: {
|
|
440
475
|
coinType:
|
|
441
|
-
'
|
|
476
|
+
'0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
|
|
442
477
|
treasury:
|
|
443
|
-
'
|
|
478
|
+
'0x471fbab72578bab577263006fe32543b6e76153fffa2bef69affe4bc4934258f',
|
|
444
479
|
},
|
|
445
480
|
swusdt: {
|
|
446
481
|
coinType:
|
|
447
|
-
'
|
|
482
|
+
'0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
|
|
448
483
|
treasury:
|
|
449
|
-
'
|
|
484
|
+
'0x921a4ed4bb4b4f11f51a462c83f4c0f6b60a90e441d1bc0d26d6fd893146bf4d',
|
|
450
485
|
},
|
|
451
486
|
sweth: {
|
|
452
487
|
coinType:
|
|
@@ -470,7 +505,13 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
470
505
|
coinType:
|
|
471
506
|
'0x97023a317320c4498cc4cd239dd02fd30c28246e5e8f81325d63f2bd8d70f6b3::scallop_v_sui::SCALLOP_V_SUI',
|
|
472
507
|
treasury:
|
|
473
|
-
'0x327114f0bf3559d7e2de10282147ed76a236c7c6775029165c4db09a6062ead6
|
|
508
|
+
'0x327114f0bf3559d7e2de10282147ed76a236c7c6775029165c4db09a6062ead6',
|
|
509
|
+
},
|
|
510
|
+
ssbeth: {
|
|
511
|
+
coinType:
|
|
512
|
+
'0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH',
|
|
513
|
+
treasury:
|
|
514
|
+
'0xfd0f02def6358a1f266acfa1493d4707ee8387460d434fb667d63d755ff907ed',
|
|
474
515
|
},
|
|
475
516
|
},
|
|
476
517
|
},
|
|
@@ -99,10 +99,9 @@ export class ScallopBuilder {
|
|
|
99
99
|
* @param address - ScallopAddress instance.
|
|
100
100
|
*/
|
|
101
101
|
public async init(force: boolean = false, address?: ScallopAddress) {
|
|
102
|
-
if (
|
|
102
|
+
if (address && !this.address) this.address = address;
|
|
103
|
+
if (force || !this.address.getAddresses()) {
|
|
103
104
|
await this.address.read();
|
|
104
|
-
} else {
|
|
105
|
-
this.address = address;
|
|
106
105
|
}
|
|
107
106
|
await this.query.init(force, this.address);
|
|
108
107
|
await this.utils.init(force, this.address);
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { SuiKit } from '@scallop-io/sui-kit';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ADDRESSES_ID,
|
|
4
|
+
SUPPORT_POOLS,
|
|
5
|
+
SUPPORT_SPOOLS,
|
|
6
|
+
DEFAULT_CACHE_OPTIONS,
|
|
7
|
+
} from '../constants';
|
|
3
8
|
import {
|
|
4
9
|
queryMarket,
|
|
5
10
|
getObligations,
|
|
@@ -34,6 +39,14 @@ import {
|
|
|
34
39
|
getFlashLoanFees,
|
|
35
40
|
getVeSca,
|
|
36
41
|
getBorrowIncentivePools,
|
|
42
|
+
getBorrowLimit,
|
|
43
|
+
getIsolatedAssets,
|
|
44
|
+
isIsolatedAsset,
|
|
45
|
+
getSupplyLimit,
|
|
46
|
+
getSCoinAmount,
|
|
47
|
+
getSCoinAmounts,
|
|
48
|
+
getSCoinSwapRate,
|
|
49
|
+
getSCoinTotalSupply,
|
|
37
50
|
} from '../queries';
|
|
38
51
|
import {
|
|
39
52
|
ScallopQueryParams,
|
|
@@ -55,23 +68,10 @@ import { ScallopAddress } from './scallopAddress';
|
|
|
55
68
|
import { ScallopUtils } from './scallopUtils';
|
|
56
69
|
import { ScallopIndexer } from './scallopIndexer';
|
|
57
70
|
import { ScallopCache } from './scallopCache';
|
|
58
|
-
import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
|
|
59
71
|
import { SuiObjectData } from '@mysten/sui/client';
|
|
60
|
-
import {
|
|
61
|
-
getSCoinAmount,
|
|
62
|
-
getSCoinAmounts,
|
|
63
|
-
getSCoinSwapRate,
|
|
64
|
-
getSCoinTotalSupply,
|
|
65
|
-
} from 'src/queries/sCoinQuery';
|
|
66
72
|
import { normalizeSuiAddress } from '@mysten/sui/utils';
|
|
67
|
-
import {
|
|
68
|
-
getSupplyLimit,
|
|
69
|
-
getIsolatedAssets,
|
|
70
|
-
isIsolatedAsset,
|
|
71
|
-
} from 'src/queries';
|
|
72
73
|
import { withIndexerFallback } from 'src/utils/indexer';
|
|
73
74
|
import { newSuiKit } from './suiKit';
|
|
74
|
-
|
|
75
75
|
/**
|
|
76
76
|
* @description
|
|
77
77
|
* It provides methods for getting on-chain data from the Scallop contract.
|
|
@@ -174,11 +174,12 @@ export class ScallopQuery {
|
|
|
174
174
|
* @param address - ScallopAddress instance.
|
|
175
175
|
*/
|
|
176
176
|
public async init(force: boolean = false, address?: ScallopAddress) {
|
|
177
|
-
if (
|
|
178
|
-
await this.address.read();
|
|
179
|
-
} else {
|
|
177
|
+
if (address && !this.address) {
|
|
180
178
|
this.address = address;
|
|
181
179
|
}
|
|
180
|
+
if (force || !this.address.getAddresses()) {
|
|
181
|
+
await this.address.read();
|
|
182
|
+
}
|
|
182
183
|
|
|
183
184
|
await this.utils.init(force, this.address);
|
|
184
185
|
}
|
|
@@ -781,12 +782,19 @@ export class ScallopQuery {
|
|
|
781
782
|
}
|
|
782
783
|
|
|
783
784
|
/**
|
|
784
|
-
* Get supply limit of
|
|
785
|
+
* Get supply limit of lending pool
|
|
785
786
|
*/
|
|
786
787
|
public async getPoolSupplyLimit(poolName: SupportPoolCoins) {
|
|
787
788
|
return await getSupplyLimit(this.utils, poolName);
|
|
788
789
|
}
|
|
789
790
|
|
|
791
|
+
/**
|
|
792
|
+
* Get borrow limit of borrow pool
|
|
793
|
+
*/
|
|
794
|
+
public async getPoolBorrowLimit(poolName: SupportPoolCoins) {
|
|
795
|
+
return await getBorrowLimit(this.utils, poolName);
|
|
796
|
+
}
|
|
797
|
+
|
|
790
798
|
/**
|
|
791
799
|
* Get list of isolated assets
|
|
792
800
|
*/
|
|
@@ -130,10 +130,9 @@ export class ScallopUtils {
|
|
|
130
130
|
* @param address - ScallopAddress instance.
|
|
131
131
|
*/
|
|
132
132
|
public async init(force: boolean = false, address?: ScallopAddress) {
|
|
133
|
-
if (
|
|
133
|
+
if (address && !this.address) this.address = address;
|
|
134
|
+
if (force || !this.address.getAddresses()) {
|
|
134
135
|
await this.address.read();
|
|
135
|
-
} else {
|
|
136
|
-
this.address = address;
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
138
|
|
|
@@ -537,9 +536,9 @@ export class ScallopUtils {
|
|
|
537
536
|
for (const endpoint of endpoints) {
|
|
538
537
|
const priceIdPairs = Array.from(failedRequests.values()).reduce(
|
|
539
538
|
(acc, coinName) => {
|
|
540
|
-
const priceId =
|
|
541
|
-
`core.coins.${coinName}.oracle.pyth.feed`
|
|
542
|
-
|
|
539
|
+
const priceId =
|
|
540
|
+
this.address.get(`core.coins.${coinName}.oracle.pyth.feed`) ??
|
|
541
|
+
PYTH_FEED_IDS[coinName];
|
|
543
542
|
acc.push([coinName, priceId]);
|
|
544
543
|
return acc;
|
|
545
544
|
},
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ScallopUtils } from 'src/models';
|
|
2
|
+
import { SupportPoolCoins } from 'src/types';
|
|
3
|
+
import { z as zod } from 'zod';
|
|
4
|
+
|
|
5
|
+
const borrowLimitZod = 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 borrowLimitKeyType = `${protocolObject}::market_dynamic_keys::BorrowLimitKey`;
|
|
21
|
+
// TODO: use prod value
|
|
22
|
+
const borrowLimitKeyType = `0xb784ea287d944e478a3ceaa071f8885072cce6b7224cf245914dc2f9963f460e::market_dynamic_keys::BorrowLimitKey`;
|
|
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 getBorrowLimit = async (
|
|
30
|
+
utils: ScallopUtils,
|
|
31
|
+
poolName: SupportPoolCoins
|
|
32
|
+
) => {
|
|
33
|
+
try {
|
|
34
|
+
const poolCoinType = utils.parseCoinType(poolName).slice(2);
|
|
35
|
+
const marketObject = utils.address.get('core.market');
|
|
36
|
+
if (!marketObject) return null;
|
|
37
|
+
|
|
38
|
+
const object = await utils.cache.queryGetDynamicFieldObject({
|
|
39
|
+
parentId: marketObject,
|
|
40
|
+
name: {
|
|
41
|
+
type: borrowLimitKeyType,
|
|
42
|
+
value: poolCoinType,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const parsedData = borrowLimitZod.safeParse(object?.data?.content);
|
|
47
|
+
if (!parsedData.success) return null;
|
|
48
|
+
return parsedData.data.fields.value;
|
|
49
|
+
} catch (e: any) {
|
|
50
|
+
console.error(`Error in getBorrowLimit for ${poolName}: ${e.message}`);
|
|
51
|
+
return '0';
|
|
52
|
+
}
|
|
53
|
+
};
|