@scallop-io/sui-scallop-sdk 1.3.3 → 1.3.4-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/coinGecko.d.ts +2 -0
- package/dist/constants/index.d.ts +7 -0
- package/dist/constants/poolAddress.d.ts +5 -0
- package/dist/constants/pyth.d.ts +2 -0
- package/dist/constants/queryKeys.d.ts +2 -1
- package/dist/index.js +1471 -1311
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1463 -1311
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopQuery.d.ts +4 -4
- package/dist/models/scallopUtils.d.ts +6 -1
- package/dist/queries/sCoinQuery.d.ts +1 -1
- package/dist/queries/spoolQuery.d.ts +1 -1
- package/dist/types/query/core.d.ts +1 -0
- package/dist/types/utils.d.ts +12 -0
- package/dist/utils/util.d.ts +2 -2
- package/package.json +1 -1
- package/src/constants/coinGecko.ts +18 -0
- package/src/constants/enum.ts +11 -4
- package/src/constants/index.ts +7 -0
- package/src/constants/poolAddress.ts +94 -0
- package/src/constants/pyth.ts +19 -0
- package/src/constants/queryKeys.ts +2 -2
- package/src/constants/testAddress.ts +76 -35
- package/src/models/scallopBuilder.ts +2 -3
- package/src/models/scallopQuery.ts +4 -3
- package/src/models/scallopUtils.ts +64 -29
- package/src/queries/coreQuery.ts +222 -216
- package/src/queries/isolatedAsset.ts +4 -4
- package/src/queries/portfolioQuery.ts +6 -9
- package/src/queries/referralQuery.ts +0 -1
- package/src/queries/spoolQuery.ts +1 -1
- package/src/types/query/core.ts +1 -0
- package/src/types/utils.ts +13 -0
- package/src/utils/util.ts +2 -1
- package/dist/models/scallopPrice.d.ts +0 -0
- package/src/models/scallopPrice.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -33,6 +33,10 @@ __export(src_exports, {
|
|
|
33
33
|
ADDRESSES_ID: () => ADDRESSES_ID,
|
|
34
34
|
API_BASE_URL: () => API_BASE_URL,
|
|
35
35
|
BORROW_FEE_PROTOCOL_ID: () => BORROW_FEE_PROTOCOL_ID,
|
|
36
|
+
COIN_GECKGO_IDS: () => COIN_GECKGO_IDS,
|
|
37
|
+
DEFAULT_CACHE_OPTIONS: () => DEFAULT_CACHE_OPTIONS,
|
|
38
|
+
DEFAULT_INTERVAL_IN_MS: () => DEFAULT_INTERVAL_IN_MS,
|
|
39
|
+
DEFAULT_TOKENS_PER_INTERVAL: () => DEFAULT_TOKENS_PER_INTERVAL,
|
|
36
40
|
FlashLoanFeeObjectMap: () => FlashLoanFeeObjectMap,
|
|
37
41
|
IS_VE_SCA_TEST: () => IS_VE_SCA_TEST,
|
|
38
42
|
MAX_LOCK_DURATION: () => MAX_LOCK_DURATION,
|
|
@@ -40,7 +44,10 @@ __export(src_exports, {
|
|
|
40
44
|
MIN_INITIAL_LOCK_AMOUNT: () => MIN_INITIAL_LOCK_AMOUNT,
|
|
41
45
|
MIN_TOP_UP_AMOUNT: () => MIN_TOP_UP_AMOUNT,
|
|
42
46
|
OLD_BORROW_INCENTIVE_PROTOCOL_ID: () => OLD_BORROW_INCENTIVE_PROTOCOL_ID,
|
|
47
|
+
POOL_ADDRESSES: () => POOL_ADDRESSES,
|
|
43
48
|
PROTOCOL_OBJECT_ID: () => PROTOCOL_OBJECT_ID,
|
|
49
|
+
PYTH_ENDPOINTS: () => PYTH_ENDPOINTS,
|
|
50
|
+
PYTH_FEED_IDS: () => PYTH_FEED_IDS,
|
|
44
51
|
SCA_COIN_TYPE: () => SCA_COIN_TYPE,
|
|
45
52
|
SDK_API_BASE_URL: () => SDK_API_BASE_URL,
|
|
46
53
|
SUPPORT_BORROW_INCENTIVE_POOLS: () => SUPPORT_BORROW_INCENTIVE_POOLS,
|
|
@@ -62,6 +69,7 @@ __export(src_exports, {
|
|
|
62
69
|
ScallopIndexer: () => ScallopIndexer,
|
|
63
70
|
ScallopQuery: () => ScallopQuery,
|
|
64
71
|
ScallopUtils: () => ScallopUtils,
|
|
72
|
+
TEST_ADDRESSES: () => TEST_ADDRESSES,
|
|
65
73
|
UNLOCK_ROUND_DURATION: () => UNLOCK_ROUND_DURATION,
|
|
66
74
|
USE_TEST_ADDRESS: () => USE_TEST_ADDRESS,
|
|
67
75
|
assetCoins: () => assetCoins,
|
|
@@ -80,6 +88,34 @@ __export(src_exports, {
|
|
|
80
88
|
});
|
|
81
89
|
module.exports = __toCommonJS(src_exports);
|
|
82
90
|
|
|
91
|
+
// src/constants/cache.ts
|
|
92
|
+
var DEFAULT_CACHE_OPTIONS = {
|
|
93
|
+
defaultOptions: {
|
|
94
|
+
queries: {
|
|
95
|
+
staleTime: 5e3,
|
|
96
|
+
gcTime: 5e3
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// src/constants/coinGecko.ts
|
|
102
|
+
var COIN_GECKGO_IDS = {
|
|
103
|
+
usdc: "usdc-coin",
|
|
104
|
+
sbeth: "ethereum",
|
|
105
|
+
weth: "ethereum",
|
|
106
|
+
wbtc: "bitcoin",
|
|
107
|
+
wusdc: "usdc-coin",
|
|
108
|
+
wusdt: "tether",
|
|
109
|
+
sui: "sui",
|
|
110
|
+
wapt: "aptos",
|
|
111
|
+
wsol: "solana",
|
|
112
|
+
cetus: "cetus-protocol",
|
|
113
|
+
afsui: "sui",
|
|
114
|
+
hasui: "sui",
|
|
115
|
+
vsui: "sui",
|
|
116
|
+
sca: "scallop-2"
|
|
117
|
+
};
|
|
118
|
+
|
|
83
119
|
// src/constants/common.ts
|
|
84
120
|
var API_BASE_URL = "https://sui.apis.scallop.io";
|
|
85
121
|
var SDK_API_BASE_URL = "https://sdk.api.scallop.io";
|
|
@@ -336,11 +372,20 @@ var voloCoinIds = {
|
|
|
336
372
|
var sCoinIds = {
|
|
337
373
|
susdc: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
|
|
338
374
|
ssbeth: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
|
|
339
|
-
|
|
375
|
+
// TODO: Change this to the correct value on production release
|
|
376
|
+
ssui: "0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI",
|
|
377
|
+
// ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
|
|
340
378
|
scetus: "0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS",
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
379
|
+
// TODO: Change this to the correct value on production release
|
|
380
|
+
ssca: "0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA",
|
|
381
|
+
// '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
|
|
382
|
+
// TODO: Change this to the correct value on production release
|
|
383
|
+
swusdc: "0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
|
|
384
|
+
// '0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
|
|
385
|
+
swusdt: (
|
|
386
|
+
// '0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
|
|
387
|
+
"0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT"
|
|
388
|
+
),
|
|
344
389
|
sweth: "0x67540ceb850d418679e69f1fb6b2093d6df78a2a699ffc733f7646096d552e9b::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
|
|
345
390
|
safsui: "0x00671b1fa2a124f5be8bdae8b91ee711462c5d9e31bda232e70fd9607b523c88::scallop_af_sui::SCALLOP_AF_SUI",
|
|
346
391
|
shasui: "0x9a2376943f7d22f88087c259c5889925f332ca4347e669dc37d54c2bf651af3c::scallop_ha_sui::SCALLOP_HA_SUI",
|
|
@@ -365,6 +410,88 @@ var FlashLoanFeeObjectMap = {
|
|
|
365
410
|
wsol: "0xe84bdb35b790fc7bdd1645122ac6ac0fc904531d6772c9e25904fece322c5f34"
|
|
366
411
|
};
|
|
367
412
|
|
|
413
|
+
// src/constants/poolAddress.ts
|
|
414
|
+
var POOL_ADDRESSES = {
|
|
415
|
+
usdc: {
|
|
416
|
+
lendingPoolAddress: "0xd3be98bf540f7603eeb550c0c0a19dbfc78822f25158b5fa84ebd9609def415f",
|
|
417
|
+
collateralPoolAddress: "0x8f0d529ba179c5b3d508213003eab813aaae31f78226099639b9a69d1aec17af"
|
|
418
|
+
},
|
|
419
|
+
sbeth: {
|
|
420
|
+
lendingPoolAddress: "0x5f08c4f71d56dd3342c452cc70ffc47f2f4180146d821941b0b9c04761bb42e7",
|
|
421
|
+
collateralPoolAddress: "0xce0549a1cbe952e734f56646988e6b02bbae14667889a60e24d0d03540a6119f"
|
|
422
|
+
},
|
|
423
|
+
weth: {
|
|
424
|
+
lendingPoolAddress: "0xc8fcdff48efc265740ae0b74aae3faccae9ec00034039a113f3339798035108c",
|
|
425
|
+
collateralPoolAddress: "0xad7ced91ed6e7f2b81805561eee27fa6f3e72fdae561077334c7248583db4dbf"
|
|
426
|
+
},
|
|
427
|
+
wbtc: {
|
|
428
|
+
lendingPoolAddress: "0x65cc08a5aca0a0b8d72e1993ded8d145f06dd102fd0d8f285b92934faed564ab",
|
|
429
|
+
collateralPoolAddress: "0x1aa4e5cf743cd797b4eb8bf1e614f80ae2cf556ced426cddaaf190ffcd0e59c3"
|
|
430
|
+
},
|
|
431
|
+
wusdc: {
|
|
432
|
+
lendingPoolAddress: "0x9c9077abf7a29eebce41e33addbcd6f5246a5221dd733e56ea0f00ae1b25c9e8",
|
|
433
|
+
collateralPoolAddress: "0x75aacfb7dcbf92ee0111fc1bf975b12569e4ba632e81ed7ae5ac090d40cd3acb"
|
|
434
|
+
},
|
|
435
|
+
wusdt: {
|
|
436
|
+
lendingPoolAddress: "0xfbc056f126dd35adc1f8fe985e2cedc8010e687e8e851e1c5b99fdf63cd1c879",
|
|
437
|
+
collateralPoolAddress: "0x2260cb5b24929dd20a1742f37a61ff3ce4fde5cdb023e2d3ce2e0ce2d90719e3"
|
|
438
|
+
},
|
|
439
|
+
sui: {
|
|
440
|
+
lendingPoolAddress: "0x9c9077abf7a29eebce41e33addbcd6f5246a5221dd733e56ea0f00ae1b25c9e8",
|
|
441
|
+
collateralPoolAddress: "0x75aacfb7dcbf92ee0111fc1bf975b12569e4ba632e81ed7ae5ac090d40cd3acb"
|
|
442
|
+
},
|
|
443
|
+
wapt: {
|
|
444
|
+
lendingPoolAddress: "0xca8c14a24e0c32b198eaf479a3317461e3cc339097ce88eaf296a15df8dcfdf5",
|
|
445
|
+
collateralPoolAddress: "0xde33f9ac5bb0ed34598da4e64b4983832716ced65f172fbf267bcfe859c4ad9c"
|
|
446
|
+
},
|
|
447
|
+
wsol: {
|
|
448
|
+
lendingPoolAddress: "0x985682c42984cdfb03f9ff7d8923344c2fe096b1ae4b82ea17721af19d22a21f",
|
|
449
|
+
collateralPoolAddress: "0xdc1cc2c371a043ae8e3c3fe2d013c35f1346960b7dbb4c072982c5b794ed144f"
|
|
450
|
+
},
|
|
451
|
+
cetus: {
|
|
452
|
+
lendingPoolAddress: "0xc09858f60e74a1b671635bec4e8a2c84a0ff313eb87f525fba3258e88c6b6282",
|
|
453
|
+
collateralPoolAddress: "0xe363967e29b7b9c1245d6d46d63e719de8f90b37e3358c545b55d945ea0b676a"
|
|
454
|
+
},
|
|
455
|
+
afsui: {
|
|
456
|
+
lendingPoolAddress: "0x9b942a24ce390b7f5016d34a0217057bf9487b92aa6d7cc9894271dbbe62471a",
|
|
457
|
+
collateralPoolAddress: "0xe5e56f5c0e3072760b21f9d49a5cc793f37d736c412a9065c16e1265c74e6341"
|
|
458
|
+
},
|
|
459
|
+
hasui: {
|
|
460
|
+
lendingPoolAddress: "0x7ebc607f6bdeb659fb6506cb91c5cc1d47bb365cfd5d2e637ea765346ec84ed4",
|
|
461
|
+
collateralPoolAddress: "0xad9ed40d6486e4c26cec7370dffce8dc4821eb79178250b5938a34ccafd61e6d"
|
|
462
|
+
},
|
|
463
|
+
vsui: {
|
|
464
|
+
lendingPoolAddress: "0xda9257c0731d8822e8a438ebced13415850d705b779c79958dcf2aeb21fcb43d",
|
|
465
|
+
collateralPoolAddress: "0x4435e8b8ec2a04094d863aa52deb6ab6f8f47ed8778f4d9f1b27afc4a6e85f1e"
|
|
466
|
+
},
|
|
467
|
+
sca: {
|
|
468
|
+
lendingPoolAddress: "0x6fc7d4211fc7018b6c75e7b908b88f2e0536443239804a3d32af547637bd28d7",
|
|
469
|
+
collateralPoolAddress: "0xff677a5d9e9dc8f08f0a8681ebfc7481d1c7d57bc441f2881974adcdd7b13c31"
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
|
|
473
|
+
// src/constants/pyth.ts
|
|
474
|
+
var PYTH_ENDPOINTS = {
|
|
475
|
+
testnet: ["https://hermes-beta.pyth.network"],
|
|
476
|
+
mainnet: ["https://hermes.pyth.network", "https://scallop.rpc.p2p.world"]
|
|
477
|
+
};
|
|
478
|
+
var PYTH_FEED_IDS = {
|
|
479
|
+
usdc: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
480
|
+
sbeth: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
481
|
+
weth: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
482
|
+
wbtc: "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43",
|
|
483
|
+
wusdc: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
484
|
+
wusdt: "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
|
|
485
|
+
sui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
486
|
+
wapt: "03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5",
|
|
487
|
+
wsol: "ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
|
|
488
|
+
cetus: "e5b274b2611143df055d6e7cd8d93fe1961716bcd4dca1cad87a83bc1e78c1ef",
|
|
489
|
+
afsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
490
|
+
hasui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
491
|
+
vsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
492
|
+
sca: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc"
|
|
493
|
+
};
|
|
494
|
+
|
|
368
495
|
// src/constants/queryKeys.ts
|
|
369
496
|
var queryKeys = {
|
|
370
497
|
api: {
|
|
@@ -441,234 +568,652 @@ var queryKeys = {
|
|
|
441
568
|
]
|
|
442
569
|
},
|
|
443
570
|
oracle: {
|
|
444
|
-
getPythLatestPriceFeed: (pythPriceId) => [
|
|
571
|
+
getPythLatestPriceFeed: (pythPriceId, endpoint) => [
|
|
445
572
|
"oracle",
|
|
446
573
|
"getPythPriceId",
|
|
447
|
-
{ pythPriceId }
|
|
574
|
+
{ pythPriceId, endpoint }
|
|
448
575
|
]
|
|
449
576
|
}
|
|
450
577
|
};
|
|
451
578
|
|
|
452
|
-
// src/constants/
|
|
453
|
-
var
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
//
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
//
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
579
|
+
// src/constants/testAddress.ts
|
|
580
|
+
var TEST_ADDRESSES = {
|
|
581
|
+
core: {
|
|
582
|
+
// version:
|
|
583
|
+
// '0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7',
|
|
584
|
+
version: "0xd318de9b0f6873879a82cbfcc2daa1d1591a8b54e7cea9f4b567da63c692a52b",
|
|
585
|
+
versionCap: "0x590a4011cb649b3878f3ea14b3a78674642a9548d79b7e091ef679574b158a07",
|
|
586
|
+
// object:
|
|
587
|
+
// '0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf',
|
|
588
|
+
object: "0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d",
|
|
589
|
+
// market:
|
|
590
|
+
// '0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9',
|
|
591
|
+
market: "0x9d6434e97f3f98fd9b0c0e1dca22632073985abcd22541feae7ee1e34cbe3af2",
|
|
592
|
+
adminCap: "0x09689d018e71c337d9db6d67cbca06b74ed92196103624028ccc3ecea411777c",
|
|
593
|
+
coinDecimalsRegistry: "0x200abe9bf19751cc566ae35aa58e2b7e4ff688fc1130f8d8909ea09bc137d668",
|
|
594
|
+
// obligationAccessStore:
|
|
595
|
+
// '0x733e30b7c94d619d78cb8f5bc4bfbb759ced9a531239028caabb2474e5be59c9',
|
|
596
|
+
obligationAccessStore: "0x46e9b44a77ee9c9d33cc2689ecdfbb8f681935cbc6bdf6ac3df048e396c36c82",
|
|
597
|
+
coins: {
|
|
598
|
+
usdc: {
|
|
599
|
+
id: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7",
|
|
600
|
+
metaData: "0x69b7a7c3c200439c1b5f3b19d7d495d5966d5f08de66c69276152f8db3992ec6",
|
|
601
|
+
treasury: "",
|
|
602
|
+
oracle: {
|
|
603
|
+
supra: "",
|
|
604
|
+
switchboard: "",
|
|
605
|
+
pyth: {
|
|
606
|
+
feed: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
607
|
+
feedObject: "0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab"
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
},
|
|
611
|
+
cetus: {
|
|
612
|
+
id: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b",
|
|
613
|
+
metaData: "0x4c0dce55eff2db5419bbd2d239d1aa22b4a400c01bbb648b058a9883989025da",
|
|
614
|
+
treasury: "",
|
|
615
|
+
oracle: {
|
|
616
|
+
supra: "",
|
|
617
|
+
switchboard: "",
|
|
618
|
+
pyth: {
|
|
619
|
+
feed: "e5b274b2611143df055d6e7cd8d93fe1961716bcd4dca1cad87a83bc1e78c1ef",
|
|
620
|
+
feedObject: "0x24c0247fb22457a719efac7f670cdc79be321b521460bd6bd2ccfa9f80713b14"
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
},
|
|
624
|
+
wapt: {
|
|
625
|
+
id: "0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37",
|
|
626
|
+
metaData: "0xc969c5251f372c0f34c32759f1d315cf1ea0ee5e4454b52aea08778eacfdd0a8",
|
|
627
|
+
treasury: "",
|
|
628
|
+
oracle: {
|
|
629
|
+
supra: "",
|
|
630
|
+
switchboard: "",
|
|
631
|
+
pyth: {
|
|
632
|
+
feed: "03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5",
|
|
633
|
+
feedObject: "0x7c5b7837c44a69b469325463ac0673ac1aa8435ff44ddb4191c9ae380463647f"
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
},
|
|
637
|
+
wsol: {
|
|
638
|
+
id: "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8",
|
|
639
|
+
metaData: "0x4d2c39082b4477e3e79dc4562d939147ab90c42fc5f3e4acf03b94383cd69b6e",
|
|
640
|
+
treasury: "",
|
|
641
|
+
oracle: {
|
|
642
|
+
supra: "",
|
|
643
|
+
switchboard: "",
|
|
644
|
+
pyth: {
|
|
645
|
+
feed: "ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
|
|
646
|
+
feedObject: "0x9d0d275efbd37d8a8855f6f2c761fa5983293dd8ce202ee5196626de8fcd4469"
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
},
|
|
650
|
+
wbtc: {
|
|
651
|
+
id: "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881",
|
|
652
|
+
metaData: "0x5d3c6e60eeff8a05b693b481539e7847dfe33013e7070cdcb387f5c0cac05dfd",
|
|
653
|
+
treasury: "",
|
|
654
|
+
oracle: {
|
|
655
|
+
supra: "",
|
|
656
|
+
switchboard: "",
|
|
657
|
+
pyth: {
|
|
658
|
+
feed: "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43",
|
|
659
|
+
feedObject: "0x9a62b4863bdeaabdc9500fce769cf7e72d5585eeb28a6d26e4cafadc13f76ab2"
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
},
|
|
663
|
+
weth: {
|
|
664
|
+
id: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
|
|
665
|
+
metaData: "0x8900e4ceede3363bef086d6b50ca89d816d0e90bf6bc46efefe1f8455e08f50f",
|
|
666
|
+
treasury: "",
|
|
667
|
+
oracle: {
|
|
668
|
+
supra: "",
|
|
669
|
+
switchboard: "",
|
|
670
|
+
pyth: {
|
|
671
|
+
feed: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
672
|
+
feedObject: "0x9193fd47f9a0ab99b6e365a464c8a9ae30e6150fc37ed2a89c1586631f6fc4ab"
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
},
|
|
676
|
+
wusdc: {
|
|
677
|
+
id: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf",
|
|
678
|
+
metaData: "0x4fbf84f3029bd0c0b77164b587963be957f853eccf834a67bb9ecba6ec80f189",
|
|
679
|
+
treasury: "",
|
|
680
|
+
oracle: {
|
|
681
|
+
supra: "",
|
|
682
|
+
switchboard: "",
|
|
683
|
+
pyth: {
|
|
684
|
+
feed: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
685
|
+
feedObject: "0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab"
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
wusdt: {
|
|
690
|
+
id: "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c",
|
|
691
|
+
metaData: "0xfb0e3eb97dd158a5ae979dddfa24348063843c5b20eb8381dd5fa7c93699e45c",
|
|
692
|
+
treasury: "",
|
|
693
|
+
oracle: {
|
|
694
|
+
supra: "",
|
|
695
|
+
switchboard: "",
|
|
696
|
+
pyth: {
|
|
697
|
+
feed: "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
|
|
698
|
+
feedObject: "0x985e3db9f93f76ee8bace7c3dd5cc676a096accd5d9e09e9ae0fb6e492b14572"
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
},
|
|
702
|
+
sui: {
|
|
703
|
+
id: "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
704
|
+
metaData: "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3",
|
|
705
|
+
treasury: "",
|
|
706
|
+
oracle: {
|
|
707
|
+
supra: "",
|
|
708
|
+
switchboard: "0xbca474133638352ba83ccf7b5c931d50f764b09550e16612c9f70f1e21f3f594",
|
|
709
|
+
pyth: {
|
|
710
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
711
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
},
|
|
715
|
+
afsui: {
|
|
716
|
+
id: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
|
|
717
|
+
metaData: "0x2f9217f533e51334873a39b8026a4aa6919497b47f49d0986a4f1aec66f8a34d",
|
|
718
|
+
treasury: "",
|
|
719
|
+
oracle: {
|
|
720
|
+
supra: "",
|
|
721
|
+
switchboard: "",
|
|
722
|
+
pyth: {
|
|
723
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
724
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
},
|
|
728
|
+
hasui: {
|
|
729
|
+
id: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
|
|
730
|
+
metaData: "0x2c5f33af93f6511df699aaaa5822d823aac6ed99d4a0de2a4a50b3afa0172e24",
|
|
731
|
+
treasury: "",
|
|
732
|
+
oracle: {
|
|
733
|
+
supra: "",
|
|
734
|
+
switchboard: "",
|
|
735
|
+
pyth: {
|
|
736
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
737
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
},
|
|
741
|
+
vsui: {
|
|
742
|
+
id: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
|
|
743
|
+
metaData: "0xabd84a23467b33854ab25cf862006fd97479f8f6f53e50fe732c43a274d939bd",
|
|
744
|
+
treasury: "",
|
|
745
|
+
oracle: {
|
|
746
|
+
supra: "",
|
|
747
|
+
switchboard: "",
|
|
748
|
+
pyth: {
|
|
749
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
750
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
},
|
|
754
|
+
sca: {
|
|
755
|
+
id: "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6",
|
|
756
|
+
metaData: "0x5d26a1e9a55c88147ac870bfa31b729d7f49f8804b8b3adfdf3582d301cca844",
|
|
757
|
+
treasury: "",
|
|
758
|
+
oracle: {
|
|
759
|
+
supra: "",
|
|
760
|
+
switchboard: "",
|
|
761
|
+
pyth: {
|
|
762
|
+
feed: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc",
|
|
763
|
+
feedObject: "0xf6de1d3279a269a597d813cbaca59aa906543ab9a8c64e84a4722f1a20863985"
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
},
|
|
767
|
+
sbeth: {
|
|
768
|
+
id: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29",
|
|
769
|
+
metaData: "0x89b04ba87f8832d4d76e17a1c9dce72eb3e64d372cf02012b8d2de5384faeef0",
|
|
770
|
+
treasury: "",
|
|
771
|
+
oracle: {
|
|
772
|
+
supra: "",
|
|
773
|
+
switchboard: "",
|
|
774
|
+
pyth: {
|
|
775
|
+
feed: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
776
|
+
feedObject: "0x9193fd47f9a0ab99b6e365a464c8a9ae30e6150fc37ed2a89c1586631f6fc4ab"
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
},
|
|
781
|
+
oracles: {
|
|
782
|
+
xOracle: "0x93d5bf0936b71eb27255941e532fac33b5a5c7759e377b4923af0a1359ad494f",
|
|
783
|
+
xOracleCap: "0x1edeae568fde99e090dbdec4bcdbd33a15f53a1ce1f87aeef1a560dedf4b4a90",
|
|
784
|
+
supra: { registry: "", registryCap: "", holder: "" },
|
|
785
|
+
switchboard: { registry: "", registryCap: "" },
|
|
786
|
+
pyth: {
|
|
787
|
+
registry: "0xedc293f9413a5a7a5d53bdba1fd889d0a4030894469228f0acdae4aa3c55a213",
|
|
788
|
+
registryCap: "0xbcb07141eb1f7e01fbda4130ecf5f5adaeabb77f5d9c32158b7532bcd2197acd",
|
|
789
|
+
state: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
|
|
790
|
+
wormhole: "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a",
|
|
791
|
+
wormholeState: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c"
|
|
792
|
+
}
|
|
793
|
+
},
|
|
794
|
+
packages: {
|
|
795
|
+
coinDecimalsRegistry: {
|
|
796
|
+
id: "0xca5a5a62f01c79a104bf4d31669e29daa387f325c241de4edbe30986a9bc8b0d",
|
|
797
|
+
upgradeCap: "0x34e76a945d29f195bc53ca704fa70877d1cf3a5d7bbfdda1b13e633fff13c0f6"
|
|
798
|
+
},
|
|
799
|
+
math: {
|
|
800
|
+
id: "0xad013d5fde39e15eabda32b3dbdafd67dac32b798ce63237c27a8f73339b9b6f",
|
|
801
|
+
upgradeCap: "0x3a329598231de02e6135c62284b66005b41cad1d9ab7ca2dc79c08293aba2ec6"
|
|
802
|
+
},
|
|
803
|
+
whitelist: {
|
|
804
|
+
id: "0x1318fdc90319ec9c24df1456d960a447521b0a658316155895014a6e39b5482f",
|
|
805
|
+
upgradeCap: "0xf5a22aea23db664f7b69855b6a546747f17c1ec4230319cfc17225e462b05761"
|
|
806
|
+
},
|
|
807
|
+
x: {
|
|
808
|
+
id: "0x779b5c547976899f5474f3a5bc0db36ddf4697ad7e5a901db0415c2281d28162",
|
|
809
|
+
upgradeCap: "0x3f203f6fff6a69d151e4f1cd931f22b68c489ef2759765662fc7baf673943c9e"
|
|
810
|
+
},
|
|
811
|
+
protocol: {
|
|
812
|
+
id: "0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d",
|
|
813
|
+
upgradeCap: "0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a"
|
|
814
|
+
},
|
|
815
|
+
// protocol: {
|
|
816
|
+
// id: '0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e',
|
|
817
|
+
// upgradeCap:
|
|
818
|
+
// '0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a',
|
|
819
|
+
// },
|
|
820
|
+
protocolWhitelist: {
|
|
821
|
+
id: "0x4c262d9343dac53ecb28f482a2a3f62c73d0ebac5b5f03d57383d56ff219acdf",
|
|
822
|
+
upgradeCap: "0x4a5e88a75039b00988f633f811f58117f31b8627a46bf822aa114d9010049449"
|
|
823
|
+
},
|
|
824
|
+
// query: {
|
|
825
|
+
// id: '0xb8d603a39114a5efef3dd0bf84df0bed1be1fbd39b78b7dd6e8a61ccc5e6006f',
|
|
826
|
+
// upgradeCap:
|
|
827
|
+
// '0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f',
|
|
828
|
+
// },
|
|
829
|
+
query: {
|
|
830
|
+
id: "0x89706958f43fb170de134579e3fbc53972b946ee78bd2442d8e1adc36074fbdc",
|
|
831
|
+
upgradeCap: "0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f"
|
|
832
|
+
},
|
|
833
|
+
supra: { id: "", upgradeCap: "" },
|
|
834
|
+
pyth: {
|
|
835
|
+
id: "0x910f30cbc7f601f75a5141a01265cd47c62d468707c5e1aecb32a18f448cb25a",
|
|
836
|
+
upgradeCap: "0xdf0ffbae1ea5bb25fbca5efba433dcf00c7cced65679af2f04728901275c6157"
|
|
837
|
+
},
|
|
838
|
+
switchboard: { id: "", upgradeCap: "" },
|
|
839
|
+
xOracle: {
|
|
840
|
+
id: "0x1478a432123e4b3d61878b629f2c692969fdb375644f1251cd278a4b1e7d7cd6",
|
|
841
|
+
upgradeCap: "0x0f928a6b2e26b73330fecaf9b44acfc9800a4a9794d6415c2a3153bc70e3c1f0"
|
|
842
|
+
},
|
|
843
|
+
testCoin: { id: "", upgradeCap: "" }
|
|
844
|
+
}
|
|
845
|
+
},
|
|
846
|
+
spool: {
|
|
847
|
+
// id: '0x7c4fdabe81c31b19a45d1e572a52a539997a90903fbb5bfab71480abe0fa62c3',
|
|
848
|
+
id: "0x1742655fe5872dfa6456673f9e38612a4965e6979e6cd7696a7f1225f28bae21",
|
|
849
|
+
adminCap: "0xdd8a047cbbf802bfcde5288b8ef1910965d789cc614da11d39af05fca0bd020a",
|
|
850
|
+
// object:
|
|
851
|
+
// '0xe87f1b2d498106a2c61421cec75b7b5c5e348512b0dc263949a0e7a3c256571a',
|
|
852
|
+
object: "0x1742655fe5872dfa6456673f9e38612a4965e6979e6cd7696a7f1225f28bae21",
|
|
853
|
+
pools: {
|
|
854
|
+
sweth: {
|
|
855
|
+
id: "0xeec40beccb07c575bebd842eeaabb835f77cd3dab73add433477e57f583a6787",
|
|
856
|
+
rewardPoolId: "0x957de68a18d87817de8309b30c1ec269a4d87ae513abbeed86b5619cb9ce1077"
|
|
857
|
+
},
|
|
858
|
+
ssui: {
|
|
859
|
+
// id: '0x4f0ba970d3c11db05c8f40c64a15b6a33322db3702d634ced6536960ab6f3ee4',
|
|
860
|
+
id: "0xb9617f83c06ebdeac0a8834782b1015e1cc7ea23739e30c132c4bfb95c37a579",
|
|
861
|
+
rewardPoolId: (
|
|
862
|
+
// '0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9',
|
|
863
|
+
"0xc3206071a8d43212efb6e3b5504f2321f8df97ab122b466c0bc7cfdf398dc13a"
|
|
864
|
+
)
|
|
865
|
+
},
|
|
866
|
+
susdc: {
|
|
867
|
+
id: "0x0b5f5f413bd3799e4052c37311966c77f3a4545eb125d2e93e67a68478021918",
|
|
868
|
+
rewardPoolId: "0x85ed6ed72ea97c35dbf0cdc7ed6fbc48d8ec15de9b17c74bf4512df8a6d7f166"
|
|
869
|
+
},
|
|
870
|
+
swusdc: {
|
|
871
|
+
// id: '0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0',
|
|
872
|
+
id: "0xf1b383b9cf2e9f515fc69567df1053098f273849d09cd84b0278a773429bd2b2",
|
|
873
|
+
rewardPoolId: (
|
|
874
|
+
// '0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8',
|
|
875
|
+
"0xc71c53ee6505d928ba15bea4fe4f45d98c9c31eced94b72d00a7827d4b7ba3ff"
|
|
876
|
+
)
|
|
877
|
+
},
|
|
878
|
+
swusdt: {
|
|
879
|
+
// id: '0xcb328f7ffa7f9342ed85af3fdb2f22919e1a06dfb2f713c04c73543870d7548f',
|
|
880
|
+
id: "0xb5567dfa5c7fc17a249e959732664c50713dd8c23db1a11376b27df800c17418",
|
|
881
|
+
rewardPoolId: (
|
|
882
|
+
// '0x2c9f934d67a5baa586ceec2cc24163a2f049a6af3d5ba36b84d8ac40f25c4080',
|
|
883
|
+
"0x60768b0687ff0235e376a039709a683e4c436098785e473b67b32dbab47b69ab"
|
|
884
|
+
)
|
|
885
|
+
},
|
|
886
|
+
scetus: {
|
|
887
|
+
id: "0xac1bb13bf4472a637c18c2415fb0e3c1227ea2bcf35242e50563c98215bd298e",
|
|
888
|
+
rewardPoolId: "0x6835c1224126a45086fc6406adc249e3f30df18d779ca4f4e570e38716a17f3f"
|
|
889
|
+
},
|
|
890
|
+
safsui: {
|
|
891
|
+
// id: '0xeedf438abcaa6ce4d9625ffca110920592d5867e4c5637d84ad9f466c4feb800',
|
|
892
|
+
id: "0xc568bb4c991258e839aa54802ecda04fcd9838c826bc3b42b40af81b23c458c8",
|
|
893
|
+
rewardPoolId: (
|
|
894
|
+
// '0x89255a2f86ed7fbfef35ab8b7be48cc7667015975be2685dd9a55a9a64baf76e',
|
|
895
|
+
"0x389a3cbeda742b918941bb24fd00e077bad3367484394d6234f8209b9a6aa03d"
|
|
896
|
+
)
|
|
897
|
+
},
|
|
898
|
+
shasui: {
|
|
899
|
+
// id: '0xa6148bc1b623e936d39a952ceb5bea79e8b37228a8f595067bf1852efd3c34aa',
|
|
900
|
+
id: "0x93f3f4499bf89f2d05ddc1f8b15f51701a7c6c4d0ac0b9c3bc99462cbbd8e321",
|
|
901
|
+
rewardPoolId: (
|
|
902
|
+
// '0x6f3563644d3e2ef13176dbf9d865bd93479df60ccbe07b7e66db57f6309f5a66',
|
|
903
|
+
"0x94cee1be7f5ff34193f3aabef0b14142cb28af4d905fe487a9a7d85a15edb6aa"
|
|
904
|
+
)
|
|
905
|
+
},
|
|
906
|
+
svsui: {
|
|
907
|
+
// id: '0x69ce8e537e750a95381e6040794afa5ab1758353a1a2e1de7760391b01f91670',
|
|
908
|
+
id: "0xa970e9087f80cb59e9299b8e7af7175d977ad6c9af0322aa4440e138fbd7ae00",
|
|
909
|
+
rewardPoolId: (
|
|
910
|
+
// '0xbca914adce058ad0902c7f3cfcd698392a475f00dcfdc3f76001d0370b98777a',
|
|
911
|
+
"0x38eee9699c4fc132a6623e54b865f047df4fc6eb83af807300f44e8f4b235ff0"
|
|
912
|
+
)
|
|
913
|
+
}
|
|
914
|
+
},
|
|
915
|
+
config: ""
|
|
916
|
+
},
|
|
917
|
+
borrowIncentive: {
|
|
918
|
+
id: "0x85769d63565ce99c7622f8e336ca1460926ddf29738ad2a39407b5cac29f61fe",
|
|
919
|
+
adminCap: "0x56ac8e6f2b360b2b35c0168d72cc6cd17d9592afb83709865cb87af24bb2025b",
|
|
920
|
+
object: "0x85769d63565ce99c7622f8e336ca1460926ddf29738ad2a39407b5cac29f61fe",
|
|
921
|
+
query: "0x8e0d00f8ff1199d7c5fe56cea0e901a525daeefff0445a1635ace8282ae3302c",
|
|
922
|
+
incentivePools: "0x9d564c93128c6ab0c0d3e050a47f11df0b91494f3bb779bdc1301c1c637f15eb",
|
|
923
|
+
incentiveAccounts: "0x09e6040e798246de04941bc79a3ba62d3eca6d7a218cc30f21fb07f478fa2926",
|
|
924
|
+
config: "0x43d4ca1dfc90b161c4240facd119e74e4b850cca2957f88c2ec289c9380da064"
|
|
925
|
+
},
|
|
926
|
+
referral: {
|
|
927
|
+
id: "0x1bf5a8ce77050d8052549d743e16b469f15aa6b81b752b78b6ebb65179665f5a",
|
|
928
|
+
object: "0x5658d4bf5ddcba27e4337b4262108b3ad1716643cac8c2054ac341538adc72ec",
|
|
929
|
+
adminCap: "0xc5dc06b9074291259f2cac460c940012c781c4430e42125c541cc43101c3bcbd",
|
|
930
|
+
referralBindings: "0xcf184487782bed962bf678001efe775d31fb94b9992333a57594cf15d79d5ced",
|
|
931
|
+
bindingTableId: "0x41a50e258c0a266ce84e0e1a618dbf70b878cc943909e613089a50afcceb2bc0",
|
|
932
|
+
referralRevenuePool: "0xc24e3e5e37032f29a3dd91a9a1f057af8821b7e6c148e9683900ac8b6d30f0c6",
|
|
933
|
+
revenueTableId: "0x595baa3654c297bff84ab7786a2d250f019cefc66e8df8e89fd9d41e02bd30dd",
|
|
934
|
+
referralTiers: "0x144350f3db9b46d11b140084cd54e6de0b9c3b8d265ce8059b51d0ef58ea464b",
|
|
935
|
+
tiersTableId: "0xeac755a7a8b7798530905ac79e8c114f19d0f130f6eab012954f08faac29c75d",
|
|
936
|
+
// authorizedWitnessList:
|
|
937
|
+
// '0xf21b0ed043c9bb70842c0129159f4943dbcc3c9ef2f2f808af65f8be25cfd20e',
|
|
938
|
+
authorizedWitnessList: "0x9d6223dc52015b8a3986a573590ef2af8f1b8f3e4685513888c052f001b87e7f",
|
|
939
|
+
version: "0x3545849eb97723e676a476ec9d4fe5f2eb0eb2c6b78972851114fd4c7ed4639f"
|
|
940
|
+
},
|
|
941
|
+
vesca: {
|
|
942
|
+
id: "0x1158813b32962c2d22888fae257d5f2365b03631f0cd5d5b912ccdf51ff4e2f2",
|
|
943
|
+
object: "0x1158813b32962c2d22888fae257d5f2365b03631f0cd5d5b912ccdf51ff4e2f2",
|
|
944
|
+
adminCap: "0x8ffa76135c5b85c5fbd73a6448a4a733d826cb63a267ab817656acb77c72d4a5",
|
|
945
|
+
tableId: "0x0a0b7f749baeb61e3dfee2b42245e32d0e6b484063f0a536b33e771d573d7246",
|
|
946
|
+
table: "0xd3a4632b1080f7d96e1c2487d4dabf2c1196916937c505a69954ac9f393be8d0",
|
|
947
|
+
treasury: "0xafa4b6231e49c15a22d641ce33fda761baaf650fa21899dfa2eb1716146e7306",
|
|
948
|
+
config: "0x7cbcb0a342179577a117dfdff974cf1ab765d3b571067bf22ddf5f9e3a667922"
|
|
949
|
+
},
|
|
950
|
+
loyaltyProgram: {
|
|
951
|
+
id: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
952
|
+
object: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
953
|
+
rewardPool: "0xf9c090492ef476bd542109d0913ffe871cbfa28578b7114eca2a8c0e5671786f",
|
|
954
|
+
userRewardTableId: "0x748a80395849ed37db1b0e14f2ab5d1d96458d2359ab3a84eb079d0f4ac7cf2e"
|
|
955
|
+
},
|
|
956
|
+
scoin: {
|
|
957
|
+
id: "0x773dab39c90fe05439b06a2d061795e52a974ff92c2aef90b2ee467acf7f33c8",
|
|
958
|
+
coins: {
|
|
959
|
+
ssui: {
|
|
960
|
+
coinType: "0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI",
|
|
961
|
+
treasury: "0x0e499640a12c38dd9cc44532f5bc5fd1b6da86d2f9a8810357250f4b26e9e5c7"
|
|
962
|
+
},
|
|
963
|
+
scetus: {
|
|
964
|
+
coinType: "0x8b71e6d323ed78515af2bead13bf3d0da1562ba4a99234eb7c4f14fd39ef0427::scallop_cetus::SCALLOP_CETUS",
|
|
965
|
+
treasury: "0xd786f4b2d26278cc7911a3445b1b085eab60f269ef9dbb6b87e803d52f155003"
|
|
966
|
+
},
|
|
967
|
+
ssca: {
|
|
968
|
+
coinType: "0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA",
|
|
969
|
+
treasury: "0x5f1c5de1df7341075d119570269b7b452af50afe8363080638f1ae29a554c038"
|
|
970
|
+
},
|
|
971
|
+
swusdc: {
|
|
972
|
+
coinType: "0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
|
|
973
|
+
treasury: "0x471fbab72578bab577263006fe32543b6e76153fffa2bef69affe4bc4934258f"
|
|
974
|
+
},
|
|
975
|
+
swusdt: {
|
|
976
|
+
coinType: "0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
|
|
977
|
+
treasury: "0x921a4ed4bb4b4f11f51a462c83f4c0f6b60a90e441d1bc0d26d6fd893146bf4d"
|
|
978
|
+
},
|
|
979
|
+
sweth: {
|
|
980
|
+
coinType: "0x27d54f43e3eda701be56b82e5756e41c84467cd202f5cf713d5f9e45a9f1b6bc::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
|
|
981
|
+
treasury: "0x032b4c8fac94c038dbe986f7587e9b1e4ef580b5ee06d2ef249d85459b7ef05d"
|
|
982
|
+
},
|
|
983
|
+
safsui: {
|
|
984
|
+
coinType: "0xb75b46d975d8d80670b53a6bee90baaa8ce2e0b7d397f079447d641eef6b44ad::scallop_af_sui::SCALLOP_AF_SUI",
|
|
985
|
+
treasury: "0x21450ef0570ef3d224ffa3b873ab802e439ece7b93cc7efad10ae0c1e3b3fcfe"
|
|
986
|
+
},
|
|
987
|
+
shasui: {
|
|
988
|
+
coinType: "0xd973a723874e2c7cde196602a79155a1343a933f8cf87d9b1bb7408bc1acbc58::scallop_ha_sui::SCALLOP_HA_SUI",
|
|
989
|
+
treasury: "0xf822fc1402207e47d2e3ba8ff6e1e594bf1de777dc5ebd2744619cd2726e3b0d"
|
|
990
|
+
},
|
|
991
|
+
svsui: {
|
|
992
|
+
coinType: "0x97023a317320c4498cc4cd239dd02fd30c28246e5e8f81325d63f2bd8d70f6b3::scallop_v_sui::SCALLOP_V_SUI",
|
|
993
|
+
treasury: "0x327114f0bf3559d7e2de10282147ed76a236c7c6775029165c4db09a6062ead6"
|
|
994
|
+
},
|
|
995
|
+
ssbeth: {
|
|
996
|
+
coinType: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
|
|
997
|
+
treasury: "0xfd0f02def6358a1f266acfa1493d4707ee8387460d434fb667d63d755ff907ed"
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
// src/constants/tokenBucket.ts
|
|
1004
|
+
var DEFAULT_TOKENS_PER_INTERVAL = 50;
|
|
1005
|
+
var DEFAULT_INTERVAL_IN_MS = 300;
|
|
1006
|
+
|
|
1007
|
+
// src/constants/vesca.ts
|
|
1008
|
+
var UNLOCK_ROUND_DURATION = 60 * 60 * 24;
|
|
1009
|
+
var MAX_LOCK_ROUNDS = 1460;
|
|
1010
|
+
var MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION;
|
|
1011
|
+
var MIN_INITIAL_LOCK_AMOUNT = 1e10;
|
|
1012
|
+
var MIN_TOP_UP_AMOUNT = 1e9;
|
|
1013
|
+
|
|
1014
|
+
// src/models/scallop.ts
|
|
1015
|
+
var import_sui_kit16 = require("@scallop-io/sui-kit");
|
|
1016
|
+
|
|
1017
|
+
// src/models/scallopAddress.ts
|
|
1018
|
+
var import_sui_kit2 = require("@scallop-io/sui-kit");
|
|
1019
|
+
|
|
1020
|
+
// src/models/scallopCache.ts
|
|
1021
|
+
var import_query_core = require("@tanstack/query-core");
|
|
1022
|
+
var import_sui_kit = require("@scallop-io/sui-kit");
|
|
1023
|
+
|
|
1024
|
+
// src/utils/builder.ts
|
|
1025
|
+
var requireSender = (txBlock) => {
|
|
1026
|
+
const sender = txBlock.blockData.sender;
|
|
1027
|
+
if (!sender) {
|
|
1028
|
+
throw new Error("Sender is required");
|
|
1029
|
+
}
|
|
1030
|
+
return sender;
|
|
1031
|
+
};
|
|
1032
|
+
var checkVesca = (prevUnlockAtInMillisTimestamp) => {
|
|
1033
|
+
if (prevUnlockAtInMillisTimestamp === void 0) {
|
|
1034
|
+
throw new Error("veSca not found");
|
|
1035
|
+
}
|
|
1036
|
+
};
|
|
1037
|
+
var checkVescaExpired = (prevUnlockAtInMillisTimestamp) => {
|
|
1038
|
+
if (prevUnlockAtInMillisTimestamp <= (/* @__PURE__ */ new Date()).getTime()) {
|
|
1039
|
+
throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
var checkExtendLockPeriod = (lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInMillisTimestamp) => {
|
|
1043
|
+
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
1044
|
+
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
1045
|
+
const prevUnlockAtInSecondTimestamp = Math.floor(
|
|
1046
|
+
prevUnlockAtInMillisTimestamp / 1e3
|
|
1047
|
+
);
|
|
1048
|
+
if (lockPeriodInDays < 1) {
|
|
1049
|
+
throw new Error("Minimum lock period is 1 day");
|
|
1050
|
+
}
|
|
1051
|
+
const availableLockPeriodInDays = Math.floor(
|
|
1052
|
+
(newUnlockAtInSecondTimestamp - prevUnlockAtInSecondTimestamp) / UNLOCK_ROUND_DURATION
|
|
1053
|
+
);
|
|
1054
|
+
if (lockPeriodInDays > availableLockPeriodInDays) {
|
|
1055
|
+
throw new Error(
|
|
1056
|
+
`Cannot extend lock period by ${lockPeriodInDays} days, maximum lock period is ~4 years (${MAX_LOCK_ROUNDS} days), remaining lock period is ${MAX_LOCK_ROUNDS - availableLockPeriodInDays}`
|
|
1057
|
+
);
|
|
1058
|
+
}
|
|
1059
|
+
};
|
|
1060
|
+
var checkLockSca = (scaAmountOrCoin, lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInMillisTimestamp) => {
|
|
1061
|
+
const prevUnlockAtInSecondTimestamp = prevUnlockAtInMillisTimestamp ? Math.floor(prevUnlockAtInMillisTimestamp / 1e3) : void 0;
|
|
1062
|
+
const isInitialLock = !prevUnlockAtInSecondTimestamp;
|
|
1063
|
+
const isLockExpired = !isInitialLock && prevUnlockAtInSecondTimestamp * 1e3 <= (/* @__PURE__ */ new Date()).getTime();
|
|
1064
|
+
if (isInitialLock || isLockExpired) {
|
|
1065
|
+
if (scaAmountOrCoin !== void 0 && lockPeriodInDays !== void 0) {
|
|
1066
|
+
if (lockPeriodInDays <= 0) {
|
|
1067
|
+
throw new Error("Lock period must be greater than 0");
|
|
1068
|
+
}
|
|
1069
|
+
if (typeof scaAmountOrCoin === "number" && scaAmountOrCoin < MIN_INITIAL_LOCK_AMOUNT) {
|
|
1070
|
+
throw new Error(
|
|
1071
|
+
`Minimum lock amount for ${isLockExpired ? "renewing expired veSca" : "initial lock"} is 10 SCA`
|
|
1072
|
+
);
|
|
1073
|
+
}
|
|
1074
|
+
const extendLockPeriodInSecond = lockPeriodInDays * UNLOCK_ROUND_DURATION;
|
|
1075
|
+
if (extendLockPeriodInSecond > MAX_LOCK_DURATION) {
|
|
1076
|
+
throw new Error(
|
|
1077
|
+
`Maximum lock period is ~4 years (${MAX_LOCK_ROUNDS} days)`
|
|
1078
|
+
);
|
|
1079
|
+
}
|
|
1080
|
+
} else {
|
|
1081
|
+
throw new Error(
|
|
1082
|
+
`SCA amount and lock period is required for ${isLockExpired ? "renewing expired veSca" : "initial lock"}`
|
|
1083
|
+
);
|
|
1084
|
+
}
|
|
1085
|
+
} else {
|
|
1086
|
+
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
1087
|
+
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
1088
|
+
if (typeof scaAmountOrCoin === "number" && scaAmountOrCoin < MIN_TOP_UP_AMOUNT) {
|
|
1089
|
+
throw new Error("Minimum top up amount is 1 SCA");
|
|
1090
|
+
}
|
|
1091
|
+
if (newUnlockAtInSecondTimestamp && lockPeriodInDays) {
|
|
1092
|
+
checkExtendLockPeriod(
|
|
1093
|
+
lockPeriodInDays,
|
|
1094
|
+
newUnlockAtInSecondTimestamp,
|
|
1095
|
+
prevUnlockAtInMillisTimestamp
|
|
1096
|
+
);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
var checkExtendLockAmount = (scaAmount, prevUnlockAtInMillisTimestamp) => {
|
|
1101
|
+
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
1102
|
+
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
1103
|
+
if (scaAmount < MIN_TOP_UP_AMOUNT) {
|
|
1104
|
+
throw new Error("Minimum top up amount is 1 SCA");
|
|
1105
|
+
}
|
|
1106
|
+
const isInitialLock = !prevUnlockAtInMillisTimestamp;
|
|
1107
|
+
const isLockExpired = !isInitialLock && prevUnlockAtInMillisTimestamp <= (/* @__PURE__ */ new Date()).getTime();
|
|
1108
|
+
if (isLockExpired) {
|
|
1109
|
+
throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
|
|
1110
|
+
}
|
|
1111
|
+
};
|
|
1112
|
+
var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays, prevUnlockAtInMillisTimestamp) => {
|
|
1113
|
+
if (!prevUnlockAtInMillisTimestamp || prevUnlockAtInMillisTimestamp > (/* @__PURE__ */ new Date()).getTime()) {
|
|
1114
|
+
throw new Error("Renew method can only be used for expired veSca");
|
|
1115
|
+
}
|
|
1116
|
+
if (scaAmount < MIN_INITIAL_LOCK_AMOUNT) {
|
|
1117
|
+
throw new Error("Minimum lock amount for renewing expired vesca 10 SCA");
|
|
1118
|
+
}
|
|
1119
|
+
const extendLockPeriodInSecond = lockPeriodInDays * UNLOCK_ROUND_DURATION;
|
|
1120
|
+
if (extendLockPeriodInSecond >= MAX_LOCK_DURATION - UNLOCK_ROUND_DURATION) {
|
|
1121
|
+
throw new Error(
|
|
1122
|
+
`Maximum lock period is ~4 years (${MAX_LOCK_ROUNDS - 1} days)`
|
|
1123
|
+
);
|
|
1124
|
+
}
|
|
1125
|
+
};
|
|
1126
|
+
|
|
1127
|
+
// src/utils/query.ts
|
|
1128
|
+
var import_bignumber = __toESM(require("bignumber.js"));
|
|
1129
|
+
var import_utils = require("@mysten/sui/utils");
|
|
1130
|
+
var parseOriginMarketPoolData = (originMarketPoolData) => {
|
|
1131
|
+
return {
|
|
1132
|
+
coinType: (0, import_utils.normalizeStructTag)(originMarketPoolData.type.name),
|
|
1133
|
+
// Parse origin data required for basic calculations.
|
|
1134
|
+
maxBorrowRate: Number(originMarketPoolData.maxBorrowRate.value) / 2 ** 32,
|
|
1135
|
+
borrowRate: Number(originMarketPoolData.interestRate.value) / 2 ** 32,
|
|
1136
|
+
borrowRateScale: Number(originMarketPoolData.interestRateScale),
|
|
1137
|
+
borrowIndex: Number(originMarketPoolData.borrowIndex),
|
|
1138
|
+
lastUpdated: Number(originMarketPoolData.lastUpdated),
|
|
1139
|
+
cashAmount: Number(originMarketPoolData.cash),
|
|
1140
|
+
debtAmount: Number(originMarketPoolData.debt),
|
|
1141
|
+
marketCoinSupplyAmount: Number(originMarketPoolData.marketCoinSupply),
|
|
1142
|
+
reserveAmount: Number(originMarketPoolData.reserve),
|
|
1143
|
+
reserveFactor: Number(originMarketPoolData.reserveFactor.value) / 2 ** 32,
|
|
1144
|
+
borrowWeight: Number(originMarketPoolData.borrowWeight.value) / 2 ** 32,
|
|
1145
|
+
borrowFee: Number(originMarketPoolData.borrowFeeRate.value) / 2 ** 32,
|
|
1146
|
+
// Parse origin data required for additional display.
|
|
1147
|
+
baseBorrowRate: Number(originMarketPoolData.baseBorrowRatePerSec.value) / 2 ** 32,
|
|
1148
|
+
borrowRateOnHighKink: Number(originMarketPoolData.borrowRateOnHighKink.value) / 2 ** 32,
|
|
1149
|
+
borrowRateOnMidKink: Number(originMarketPoolData.borrowRateOnMidKink.value) / 2 ** 32,
|
|
1150
|
+
highKink: Number(originMarketPoolData.highKink.value) / 2 ** 32,
|
|
1151
|
+
midKink: Number(originMarketPoolData.midKink.value) / 2 ** 32,
|
|
1152
|
+
minBorrowAmount: Number(originMarketPoolData.minBorrowAmount)
|
|
1153
|
+
};
|
|
1154
|
+
};
|
|
1155
|
+
var calculateMarketPoolData = (utils, parsedMarketPoolData) => {
|
|
1156
|
+
const poolCoinName = utils.parseCoinNameFromType(
|
|
1157
|
+
parsedMarketPoolData.coinType
|
|
1158
|
+
);
|
|
1159
|
+
const coinDecimal = utils.getCoinDecimal(poolCoinName);
|
|
1160
|
+
const borrowYearFactor = 24 * 365 * 3600;
|
|
1161
|
+
const baseBorrowApr = parsedMarketPoolData.baseBorrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
1162
|
+
const borrowAprOnHighKink = parsedMarketPoolData.borrowRateOnHighKink * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
1163
|
+
const borrowAprOnMidKink = parsedMarketPoolData.borrowRateOnMidKink * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
1164
|
+
const maxBorrowApr = parsedMarketPoolData.maxBorrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
1165
|
+
const borrowApr = parsedMarketPoolData.borrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
1166
|
+
const timeDelta = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - parsedMarketPoolData.lastUpdated;
|
|
1167
|
+
const borrowIndexDelta = (0, import_bignumber.default)(parsedMarketPoolData.borrowIndex).multipliedBy(
|
|
1168
|
+
(0, import_bignumber.default)(timeDelta).multipliedBy(parsedMarketPoolData.borrowRate)
|
|
1169
|
+
).dividedBy(parsedMarketPoolData.borrowRateScale);
|
|
1170
|
+
const currentBorrowIndex = (0, import_bignumber.default)(parsedMarketPoolData.borrowIndex).plus(
|
|
1171
|
+
borrowIndexDelta
|
|
1172
|
+
);
|
|
1173
|
+
const growthInterest = (0, import_bignumber.default)(currentBorrowIndex).dividedBy(parsedMarketPoolData.borrowIndex).minus(1);
|
|
1174
|
+
const increasedDebtAmount = (0, import_bignumber.default)(
|
|
1175
|
+
parsedMarketPoolData.debtAmount
|
|
1176
|
+
).multipliedBy(growthInterest);
|
|
1177
|
+
const borrowAmount = increasedDebtAmount.plus(
|
|
1178
|
+
parsedMarketPoolData.debtAmount
|
|
1179
|
+
);
|
|
1180
|
+
const borrowCoin = borrowAmount.shiftedBy(-1 * coinDecimal);
|
|
1181
|
+
const reserveAmount = (0, import_bignumber.default)(parsedMarketPoolData.reserveAmount).plus(
|
|
1182
|
+
increasedDebtAmount.multipliedBy(parsedMarketPoolData.reserveFactor)
|
|
1183
|
+
);
|
|
1184
|
+
const reserveCoin = reserveAmount.shiftedBy(-1 * coinDecimal);
|
|
1185
|
+
const supplyAmount = (0, import_bignumber.default)(borrowAmount).plus(
|
|
1186
|
+
Math.max(parsedMarketPoolData.cashAmount - reserveAmount.toNumber(), 0)
|
|
1187
|
+
);
|
|
1188
|
+
const supplyCoin = supplyAmount.shiftedBy(-1 * coinDecimal);
|
|
1189
|
+
let utilizationRate = (0, import_bignumber.default)(borrowAmount).dividedBy(supplyAmount);
|
|
1190
|
+
utilizationRate = utilizationRate.isFinite() ? utilizationRate : (0, import_bignumber.default)(0);
|
|
1191
|
+
let supplyApr = (0, import_bignumber.default)(borrowApr).multipliedBy(utilizationRate).multipliedBy(1 - parsedMarketPoolData.reserveFactor);
|
|
1192
|
+
supplyApr = supplyApr.isFinite() ? supplyApr : (0, import_bignumber.default)(0);
|
|
1193
|
+
let conversionRate = supplyAmount.dividedBy(
|
|
1194
|
+
parsedMarketPoolData.marketCoinSupplyAmount
|
|
1195
|
+
);
|
|
1196
|
+
conversionRate = conversionRate.isFinite() && !conversionRate.isNaN() ? conversionRate : (0, import_bignumber.default)(1);
|
|
1197
|
+
return {
|
|
1198
|
+
baseBorrowApr,
|
|
1199
|
+
baseBorrowApy: utils.parseAprToApy(baseBorrowApr),
|
|
1200
|
+
borrowAprOnHighKink,
|
|
1201
|
+
borrowApyOnHighKink: utils.parseAprToApy(borrowAprOnHighKink),
|
|
1202
|
+
borrowAprOnMidKink,
|
|
1203
|
+
borrowApyOnMidKink: utils.parseAprToApy(borrowAprOnMidKink),
|
|
1204
|
+
maxBorrowApr,
|
|
1205
|
+
maxBorrowApy: utils.parseAprToApy(maxBorrowApr),
|
|
1206
|
+
borrowApr: Math.min(borrowApr, maxBorrowApr),
|
|
1207
|
+
borrowApy: Math.min(
|
|
1208
|
+
utils.parseAprToApy(borrowApr),
|
|
1209
|
+
utils.parseAprToApy(maxBorrowApr)
|
|
1210
|
+
),
|
|
1211
|
+
borrowIndex: currentBorrowIndex.toNumber(),
|
|
1212
|
+
growthInterest: growthInterest.toNumber(),
|
|
1213
|
+
supplyAmount: supplyAmount.toNumber(),
|
|
1214
|
+
supplyCoin: supplyCoin.toNumber(),
|
|
1215
|
+
borrowAmount: borrowAmount.toNumber(),
|
|
1216
|
+
borrowCoin: borrowCoin.toNumber(),
|
|
672
1217
|
reserveAmount: reserveAmount.toNumber(),
|
|
673
1218
|
reserveCoin: reserveCoin.toNumber(),
|
|
674
1219
|
utilizationRate: utilizationRate.toNumber(),
|
|
@@ -902,786 +1447,390 @@ var calculateBorrowIncentivePoolPointData = (parsedBorrowIncentivePoolPointData,
|
|
|
902
1447
|
).dividedBy(weightedStakedValue).toNumber() : Infinity;
|
|
903
1448
|
return {
|
|
904
1449
|
distributedPointPerSec: distributedPointPerSec.toNumber(),
|
|
905
|
-
accumulatedPoints: accumulatedPoints.toNumber(),
|
|
906
|
-
currentPointIndex: currentPointIndex.toNumber(),
|
|
907
|
-
currentTotalDistributedPoint: currentTotalDistributedPoint.toNumber(),
|
|
908
|
-
baseWeight: baseWeight.toNumber(),
|
|
909
|
-
weightedStakedAmount: weightedStakedAmount.toNumber(),
|
|
910
|
-
weightedStakedCoin: weightedStakedCoin.toNumber(),
|
|
911
|
-
weightedStakedValue: weightedStakedValue.toNumber(),
|
|
912
|
-
rewardApr: rewardRate,
|
|
913
|
-
rewardPerSec: rewardPerSec.toNumber()
|
|
914
|
-
};
|
|
915
|
-
};
|
|
916
|
-
var parseOriginBorrowIncentiveAccountPoolPointData = (originBorrowIncentiveAccountPoolPointData) => {
|
|
917
|
-
return {
|
|
918
|
-
pointType: (0, import_utils.normalizeStructTag)(
|
|
919
|
-
originBorrowIncentiveAccountPoolPointData.point_type.name
|
|
920
|
-
),
|
|
921
|
-
weightedAmount: Number(
|
|
922
|
-
originBorrowIncentiveAccountPoolPointData.weighted_amount
|
|
923
|
-
),
|
|
924
|
-
points: Number(originBorrowIncentiveAccountPoolPointData.points),
|
|
925
|
-
totalPoints: Number(originBorrowIncentiveAccountPoolPointData.total_points),
|
|
926
|
-
index: Number(originBorrowIncentiveAccountPoolPointData.index)
|
|
927
|
-
};
|
|
928
|
-
};
|
|
929
|
-
var parseOriginBorrowIncentiveAccountData = (originBorrowIncentiveAccountData) => {
|
|
930
|
-
return {
|
|
931
|
-
poolType: (0, import_utils.normalizeStructTag)(
|
|
932
|
-
originBorrowIncentiveAccountData.pool_type.name
|
|
933
|
-
),
|
|
934
|
-
debtAmount: Number(originBorrowIncentiveAccountData.debt_amount),
|
|
935
|
-
pointList: originBorrowIncentiveAccountData.points_list.reduce(
|
|
936
|
-
(acc, point) => {
|
|
937
|
-
const parsed = parseOriginBorrowIncentiveAccountPoolPointData(point);
|
|
938
|
-
const name = (0, import_utils.parseStructTag)(
|
|
939
|
-
parsed.pointType
|
|
940
|
-
).name.toLowerCase();
|
|
941
|
-
acc[name] = parsed;
|
|
942
|
-
return acc;
|
|
943
|
-
},
|
|
944
|
-
{}
|
|
945
|
-
)
|
|
946
|
-
};
|
|
947
|
-
};
|
|
948
|
-
var minBigNumber = (...args) => {
|
|
949
|
-
return (0, import_bignumber.default)(
|
|
950
|
-
args.reduce(
|
|
951
|
-
(min, current) => new import_bignumber.default(current).lt(min) ? current : min
|
|
952
|
-
)
|
|
953
|
-
);
|
|
954
|
-
};
|
|
955
|
-
var estimatedFactor = (amount, scaleStep, type) => {
|
|
956
|
-
const amountOfDigits = Math.max(
|
|
957
|
-
1,
|
|
958
|
-
Math.floor(Math.log10(Math.abs(amount)) + 1)
|
|
959
|
-
);
|
|
960
|
-
const adjustScale = Math.max(Math.floor((amountOfDigits - 1) / scaleStep), 1) + 1;
|
|
961
|
-
let adjustFactor = Math.pow(10, -adjustScale);
|
|
962
|
-
adjustFactor = type === "increase" ? 1 - adjustFactor : 1 + adjustFactor;
|
|
963
|
-
return adjustFactor;
|
|
964
|
-
};
|
|
965
|
-
|
|
966
|
-
// src/utils/util.ts
|
|
967
|
-
var COIN_SET = Array.from(
|
|
968
|
-
/* @__PURE__ */ new Set([
|
|
969
|
-
...SUPPORT_POOLS,
|
|
970
|
-
...SUPPORT_COLLATERALS,
|
|
971
|
-
...SUPPORT_SPOOLS_REWARDS,
|
|
972
|
-
...SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
973
|
-
...SUPPORT_SCOIN
|
|
974
|
-
])
|
|
975
|
-
);
|
|
976
|
-
var isMarketCoin = (coinName) => {
|
|
977
|
-
const assetCoinName = coinName.slice(1).toLowerCase();
|
|
978
|
-
return coinName.charAt(0).toLowerCase() === "s" && COIN_SET.includes(assetCoinName);
|
|
979
|
-
};
|
|
980
|
-
var isSuiBridgeAsset = (coinName) => {
|
|
981
|
-
return SUPPORT_SUI_BRIDGE.includes(coinName);
|
|
982
|
-
};
|
|
983
|
-
var isWormholeAsset = (coinName) => {
|
|
984
|
-
return SUPPORT_WORMHOLE.includes(coinName);
|
|
985
|
-
};
|
|
986
|
-
var parseAssetSymbol = (coinName) => {
|
|
987
|
-
if (isWormholeAsset(coinName)) {
|
|
988
|
-
return `w${coinName.slice(1).toUpperCase()}`;
|
|
989
|
-
}
|
|
990
|
-
if (isSuiBridgeAsset(coinName)) {
|
|
991
|
-
return `sb${coinName.slice(2).toUpperCase()}`;
|
|
992
|
-
}
|
|
993
|
-
if (isMarketCoin(coinName)) {
|
|
994
|
-
const assetCoinName = coinName.slice(1).toLowerCase();
|
|
995
|
-
return coinName.slice(0, 1).toLowerCase() + parseAssetSymbol(assetCoinName);
|
|
996
|
-
}
|
|
997
|
-
switch (coinName) {
|
|
998
|
-
case "afsui":
|
|
999
|
-
return "afSUI";
|
|
1000
|
-
case "hasui":
|
|
1001
|
-
return "haSUI";
|
|
1002
|
-
case "vsui":
|
|
1003
|
-
return "vSUI";
|
|
1004
|
-
default:
|
|
1005
|
-
return coinName.toUpperCase();
|
|
1006
|
-
}
|
|
1007
|
-
};
|
|
1008
|
-
var parseDataFromPythPriceFeed = (feed, address) => {
|
|
1009
|
-
const assetCoinNames = COIN_SET;
|
|
1010
|
-
const assetCoinName = assetCoinNames.find((assetCoinName2) => {
|
|
1011
|
-
return address.get(`core.coins.${assetCoinName2}.oracle.pyth.feed`) === feed.id;
|
|
1012
|
-
});
|
|
1013
|
-
if (assetCoinName) {
|
|
1014
|
-
const price = feed.price.price * 10 ** feed.price.expo;
|
|
1015
|
-
return {
|
|
1016
|
-
coinName: assetCoinName,
|
|
1017
|
-
price,
|
|
1018
|
-
publishTime: Number(feed.price.publishTime) * 10 ** 3
|
|
1019
|
-
};
|
|
1020
|
-
} else {
|
|
1021
|
-
throw new Error("Invalid feed id");
|
|
1022
|
-
}
|
|
1023
|
-
};
|
|
1024
|
-
var findClosestUnlockRound = (unlockAtInSecondTimestamp) => {
|
|
1025
|
-
const unlockDate = new Date(unlockAtInSecondTimestamp * 1e3);
|
|
1026
|
-
const closestTwelveAM = new Date(unlockAtInSecondTimestamp * 1e3);
|
|
1027
|
-
closestTwelveAM.setUTCHours(0, 0, 0, 0);
|
|
1028
|
-
if (unlockDate.getUTCHours() >= 0) {
|
|
1029
|
-
closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() + 1);
|
|
1030
|
-
}
|
|
1031
|
-
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
1032
|
-
if (closestTwelveAM.getTime() - now > MAX_LOCK_DURATION * 1e3) {
|
|
1033
|
-
closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() - 1);
|
|
1034
|
-
}
|
|
1035
|
-
return Math.floor(closestTwelveAM.getTime() / 1e3);
|
|
1036
|
-
};
|
|
1037
|
-
|
|
1038
|
-
// src/constants/tokenBucket.ts
|
|
1039
|
-
var DEFAULT_TOKENS_PER_INTERVAL = 50;
|
|
1040
|
-
var DEFAULT_INTERVAL_IN_MS = 300;
|
|
1041
|
-
|
|
1042
|
-
// src/utils/tokenBucket.ts
|
|
1043
|
-
var TokenBucket = class {
|
|
1044
|
-
constructor(tokensPerInterval, intervalInMs) {
|
|
1045
|
-
this.tokensPerInterval = tokensPerInterval;
|
|
1046
|
-
this.interval = intervalInMs;
|
|
1047
|
-
this.tokens = tokensPerInterval;
|
|
1048
|
-
this.lastRefill = Date.now();
|
|
1049
|
-
}
|
|
1050
|
-
refill() {
|
|
1051
|
-
const now = Date.now();
|
|
1052
|
-
const elapsed = now - this.lastRefill;
|
|
1053
|
-
if (elapsed > this.interval) {
|
|
1054
|
-
const tokensToAdd = Math.floor(elapsed / this.interval) * this.tokensPerInterval;
|
|
1055
|
-
this.tokens = Math.min(this.tokens + tokensToAdd, this.tokensPerInterval);
|
|
1056
|
-
this.lastRefill = now;
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
removeTokens(count) {
|
|
1060
|
-
this.refill();
|
|
1061
|
-
if (this.tokens >= count) {
|
|
1062
|
-
this.tokens -= count;
|
|
1063
|
-
return true;
|
|
1064
|
-
}
|
|
1065
|
-
return false;
|
|
1066
|
-
}
|
|
1450
|
+
accumulatedPoints: accumulatedPoints.toNumber(),
|
|
1451
|
+
currentPointIndex: currentPointIndex.toNumber(),
|
|
1452
|
+
currentTotalDistributedPoint: currentTotalDistributedPoint.toNumber(),
|
|
1453
|
+
baseWeight: baseWeight.toNumber(),
|
|
1454
|
+
weightedStakedAmount: weightedStakedAmount.toNumber(),
|
|
1455
|
+
weightedStakedCoin: weightedStakedCoin.toNumber(),
|
|
1456
|
+
weightedStakedValue: weightedStakedValue.toNumber(),
|
|
1457
|
+
rewardApr: rewardRate,
|
|
1458
|
+
rewardPerSec: rewardPerSec.toNumber()
|
|
1459
|
+
};
|
|
1067
1460
|
};
|
|
1068
|
-
var
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
if (error.message === "Unexpected status code: 429" && retries < maxRetries) {
|
|
1080
|
-
retries++;
|
|
1081
|
-
const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
|
|
1082
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1083
|
-
return tryRequest();
|
|
1084
|
-
} else {
|
|
1085
|
-
console.error("An error occurred:", error.message);
|
|
1086
|
-
return null;
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
} else if (retries < maxRetries) {
|
|
1090
|
-
retries++;
|
|
1091
|
-
const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
|
|
1092
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1093
|
-
return tryRequest();
|
|
1094
|
-
} else {
|
|
1095
|
-
console.error("Maximum retries reached");
|
|
1096
|
-
return null;
|
|
1097
|
-
}
|
|
1461
|
+
var parseOriginBorrowIncentiveAccountPoolPointData = (originBorrowIncentiveAccountPoolPointData) => {
|
|
1462
|
+
return {
|
|
1463
|
+
pointType: (0, import_utils.normalizeStructTag)(
|
|
1464
|
+
originBorrowIncentiveAccountPoolPointData.point_type.name
|
|
1465
|
+
),
|
|
1466
|
+
weightedAmount: Number(
|
|
1467
|
+
originBorrowIncentiveAccountPoolPointData.weighted_amount
|
|
1468
|
+
),
|
|
1469
|
+
points: Number(originBorrowIncentiveAccountPoolPointData.points),
|
|
1470
|
+
totalPoints: Number(originBorrowIncentiveAccountPoolPointData.total_points),
|
|
1471
|
+
index: Number(originBorrowIncentiveAccountPoolPointData.index)
|
|
1098
1472
|
};
|
|
1099
|
-
return tryRequest();
|
|
1100
1473
|
};
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1474
|
+
var parseOriginBorrowIncentiveAccountData = (originBorrowIncentiveAccountData) => {
|
|
1475
|
+
return {
|
|
1476
|
+
poolType: (0, import_utils.normalizeStructTag)(
|
|
1477
|
+
originBorrowIncentiveAccountData.pool_type.name
|
|
1478
|
+
),
|
|
1479
|
+
debtAmount: Number(originBorrowIncentiveAccountData.debt_amount),
|
|
1480
|
+
pointList: originBorrowIncentiveAccountData.points_list.reduce(
|
|
1481
|
+
(acc, point) => {
|
|
1482
|
+
const parsed = parseOriginBorrowIncentiveAccountPoolPointData(point);
|
|
1483
|
+
const name = (0, import_utils.parseStructTag)(
|
|
1484
|
+
parsed.pointType
|
|
1485
|
+
).name.toLowerCase();
|
|
1486
|
+
acc[name] = parsed;
|
|
1487
|
+
return acc;
|
|
1488
|
+
},
|
|
1489
|
+
{}
|
|
1490
|
+
)
|
|
1118
1491
|
};
|
|
1119
|
-
}
|
|
1492
|
+
};
|
|
1493
|
+
var minBigNumber = (...args) => {
|
|
1494
|
+
return (0, import_bignumber.default)(
|
|
1495
|
+
args.reduce(
|
|
1496
|
+
(min, current) => new import_bignumber.default(current).lt(min) ? current : min
|
|
1497
|
+
)
|
|
1498
|
+
);
|
|
1499
|
+
};
|
|
1500
|
+
var estimatedFactor = (amount, scaleStep, type) => {
|
|
1501
|
+
const amountOfDigits = Math.max(
|
|
1502
|
+
1,
|
|
1503
|
+
Math.floor(Math.log10(Math.abs(amount)) + 1)
|
|
1504
|
+
);
|
|
1505
|
+
const adjustScale = Math.max(Math.floor((amountOfDigits - 1) / scaleStep), 1) + 1;
|
|
1506
|
+
let adjustFactor = Math.pow(10, -adjustScale);
|
|
1507
|
+
adjustFactor = type === "increase" ? 1 - adjustFactor : 1 + adjustFactor;
|
|
1508
|
+
return adjustFactor;
|
|
1509
|
+
};
|
|
1120
1510
|
|
|
1121
|
-
// src/
|
|
1122
|
-
var
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
* - `all`: All queries that match the refetch predicate will be refetched in the background.
|
|
1145
|
-
* - `none`: No queries will be refetched. Queries that match the refetch predicate will only be marked as invalid.
|
|
1146
|
-
*/
|
|
1147
|
-
async invalidateAllCache() {
|
|
1148
|
-
return Object.values(queryKeys.rpc).map(
|
|
1149
|
-
(t) => this.queryClient.invalidateQueries({
|
|
1150
|
-
queryKey: t(),
|
|
1151
|
-
type: "all"
|
|
1152
|
-
})
|
|
1153
|
-
);
|
|
1154
|
-
}
|
|
1155
|
-
/**
|
|
1156
|
-
* @description Provides cache for inspectTxn of the SuiKit.
|
|
1157
|
-
* @param QueryInspectTxnParams
|
|
1158
|
-
* @param txBlock
|
|
1159
|
-
* @returns Promise<DevInspectResults>
|
|
1160
|
-
*/
|
|
1161
|
-
async queryInspectTxn({
|
|
1162
|
-
queryTarget,
|
|
1163
|
-
args,
|
|
1164
|
-
typeArgs
|
|
1165
|
-
}) {
|
|
1166
|
-
const txBlock = new import_sui_kit.SuiTxBlock();
|
|
1167
|
-
txBlock.moveCall(queryTarget, args, typeArgs);
|
|
1168
|
-
const query = await this.queryClient.fetchQuery({
|
|
1169
|
-
queryKey: queryKeys.rpc.getInspectTxn(queryTarget, args, typeArgs),
|
|
1170
|
-
queryFn: async () => {
|
|
1171
|
-
return await callWithRateLimit(
|
|
1172
|
-
this.tokenBucket,
|
|
1173
|
-
() => this.suiKit.inspectTxn(txBlock)
|
|
1174
|
-
);
|
|
1175
|
-
}
|
|
1176
|
-
});
|
|
1177
|
-
return query;
|
|
1178
|
-
}
|
|
1179
|
-
/**
|
|
1180
|
-
* @description Provides cache for getObject of the SuiKit.
|
|
1181
|
-
* @param objectId
|
|
1182
|
-
* @param QueryObjectParams
|
|
1183
|
-
* @returns Promise<SuiObjectResponse>
|
|
1184
|
-
*/
|
|
1185
|
-
async queryGetObject(objectId, options) {
|
|
1186
|
-
return this.queryClient.fetchQuery({
|
|
1187
|
-
queryKey: queryKeys.rpc.getObject(objectId, this.walletAddress, options),
|
|
1188
|
-
queryFn: async () => {
|
|
1189
|
-
return await callWithRateLimit(
|
|
1190
|
-
this.tokenBucket,
|
|
1191
|
-
() => this.client.getObject({
|
|
1192
|
-
id: objectId,
|
|
1193
|
-
options
|
|
1194
|
-
})
|
|
1195
|
-
);
|
|
1196
|
-
}
|
|
1197
|
-
});
|
|
1198
|
-
}
|
|
1199
|
-
/**
|
|
1200
|
-
* @description Provides cache for getObjects of the SuiKit.
|
|
1201
|
-
* @param objectIds
|
|
1202
|
-
* @returns Promise<SuiObjectData[]>
|
|
1203
|
-
*/
|
|
1204
|
-
async queryGetObjects(objectIds, options = {
|
|
1205
|
-
showContent: true
|
|
1206
|
-
}) {
|
|
1207
|
-
if (objectIds.length === 0)
|
|
1208
|
-
return [];
|
|
1209
|
-
return this.queryClient.fetchQuery({
|
|
1210
|
-
queryKey: queryKeys.rpc.getObjects(
|
|
1211
|
-
objectIds,
|
|
1212
|
-
this.walletAddress,
|
|
1213
|
-
options
|
|
1214
|
-
),
|
|
1215
|
-
queryFn: async () => {
|
|
1216
|
-
return await callWithRateLimit(
|
|
1217
|
-
this.tokenBucket,
|
|
1218
|
-
() => this.suiKit.getObjects(objectIds, options)
|
|
1219
|
-
);
|
|
1220
|
-
}
|
|
1221
|
-
});
|
|
1222
|
-
}
|
|
1223
|
-
/**
|
|
1224
|
-
* @description Provides cache for getOwnedObjects of the SuiKit.
|
|
1225
|
-
* @param input
|
|
1226
|
-
* @returns Promise<PaginatedObjectsResponse>
|
|
1227
|
-
*/
|
|
1228
|
-
async queryGetOwnedObjects(input) {
|
|
1229
|
-
return this.queryClient.fetchQuery({
|
|
1230
|
-
queryKey: queryKeys.rpc.getOwnedObjects(input),
|
|
1231
|
-
queryFn: async () => {
|
|
1232
|
-
return await callWithRateLimit(
|
|
1233
|
-
this.tokenBucket,
|
|
1234
|
-
() => this.client.getOwnedObjects(input)
|
|
1235
|
-
);
|
|
1236
|
-
}
|
|
1237
|
-
});
|
|
1238
|
-
}
|
|
1239
|
-
async queryGetDynamicFields(input) {
|
|
1240
|
-
return this.queryClient.fetchQuery({
|
|
1241
|
-
queryKey: queryKeys.rpc.getDynamicFields(input),
|
|
1242
|
-
queryFn: async () => {
|
|
1243
|
-
return await callWithRateLimit(
|
|
1244
|
-
this.tokenBucket,
|
|
1245
|
-
() => this.client.getDynamicFields(input)
|
|
1246
|
-
);
|
|
1247
|
-
}
|
|
1248
|
-
});
|
|
1511
|
+
// src/utils/util.ts
|
|
1512
|
+
var COIN_SET = Array.from(
|
|
1513
|
+
/* @__PURE__ */ new Set([
|
|
1514
|
+
...SUPPORT_POOLS,
|
|
1515
|
+
...SUPPORT_COLLATERALS,
|
|
1516
|
+
...SUPPORT_SPOOLS_REWARDS,
|
|
1517
|
+
...SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
1518
|
+
...SUPPORT_SCOIN
|
|
1519
|
+
])
|
|
1520
|
+
);
|
|
1521
|
+
var isMarketCoin = (coinName) => {
|
|
1522
|
+
const assetCoinName = coinName.slice(1).toLowerCase();
|
|
1523
|
+
return coinName.charAt(0).toLowerCase() === "s" && COIN_SET.includes(assetCoinName);
|
|
1524
|
+
};
|
|
1525
|
+
var isSuiBridgeAsset = (coinName) => {
|
|
1526
|
+
return SUPPORT_SUI_BRIDGE.includes(coinName);
|
|
1527
|
+
};
|
|
1528
|
+
var isWormholeAsset = (coinName) => {
|
|
1529
|
+
return SUPPORT_WORMHOLE.includes(coinName);
|
|
1530
|
+
};
|
|
1531
|
+
var parseAssetSymbol = (coinName) => {
|
|
1532
|
+
if (isWormholeAsset(coinName)) {
|
|
1533
|
+
return `w${coinName.slice(1).toUpperCase()}`;
|
|
1249
1534
|
}
|
|
1250
|
-
|
|
1251
|
-
return
|
|
1252
|
-
queryKey: queryKeys.rpc.getDynamicFieldObject(input),
|
|
1253
|
-
queryFn: async () => {
|
|
1254
|
-
return await callWithRateLimit(
|
|
1255
|
-
this.tokenBucket,
|
|
1256
|
-
() => this.client.getDynamicFieldObject(input)
|
|
1257
|
-
);
|
|
1258
|
-
}
|
|
1259
|
-
});
|
|
1535
|
+
if (isSuiBridgeAsset(coinName)) {
|
|
1536
|
+
return `sb${coinName.slice(2).toUpperCase()}`;
|
|
1260
1537
|
}
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
queryFn: async () => {
|
|
1265
|
-
const allBalances = await callWithRateLimit(
|
|
1266
|
-
this.tokenBucket,
|
|
1267
|
-
() => this.client.getAllBalances({ owner })
|
|
1268
|
-
);
|
|
1269
|
-
if (!allBalances)
|
|
1270
|
-
return {};
|
|
1271
|
-
const balances = allBalances.reduce(
|
|
1272
|
-
(acc, coinBalance) => {
|
|
1273
|
-
if (coinBalance.totalBalance !== "0") {
|
|
1274
|
-
acc[(0, import_sui_kit.normalizeStructTag)(coinBalance.coinType)] = coinBalance.totalBalance;
|
|
1275
|
-
}
|
|
1276
|
-
return acc;
|
|
1277
|
-
},
|
|
1278
|
-
{}
|
|
1279
|
-
);
|
|
1280
|
-
return balances;
|
|
1281
|
-
}
|
|
1282
|
-
});
|
|
1538
|
+
if (isMarketCoin(coinName)) {
|
|
1539
|
+
const assetCoinName = coinName.slice(1).toLowerCase();
|
|
1540
|
+
return coinName.slice(0, 1).toLowerCase() + parseAssetSymbol(assetCoinName);
|
|
1283
1541
|
}
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
return "
|
|
1287
|
-
|
|
1542
|
+
switch (coinName) {
|
|
1543
|
+
case "afsui":
|
|
1544
|
+
return "afSUI";
|
|
1545
|
+
case "hasui":
|
|
1546
|
+
return "haSUI";
|
|
1547
|
+
case "vsui":
|
|
1548
|
+
return "vSUI";
|
|
1549
|
+
default:
|
|
1550
|
+
return coinName.toUpperCase();
|
|
1288
1551
|
}
|
|
1289
1552
|
};
|
|
1553
|
+
var parseDataFromPythPriceFeed = (feed, address) => {
|
|
1554
|
+
const assetCoinNames = COIN_SET;
|
|
1555
|
+
const assetCoinName = assetCoinNames.find((assetCoinName2) => {
|
|
1556
|
+
return address.get(`core.coins.${assetCoinName2}.oracle.pyth.feed`) === feed.id;
|
|
1557
|
+
});
|
|
1558
|
+
if (assetCoinName) {
|
|
1559
|
+
const price = feed.price.price * 10 ** feed.price.expo;
|
|
1560
|
+
return {
|
|
1561
|
+
coinName: assetCoinName,
|
|
1562
|
+
price,
|
|
1563
|
+
publishTime: Number(feed.price.publishTime) * 10 ** 3
|
|
1564
|
+
};
|
|
1565
|
+
} else {
|
|
1566
|
+
throw new Error("Invalid feed id");
|
|
1567
|
+
}
|
|
1568
|
+
};
|
|
1569
|
+
var findClosestUnlockRound = (unlockAtInSecondTimestamp) => {
|
|
1570
|
+
const unlockDate = new Date(unlockAtInSecondTimestamp * 1e3);
|
|
1571
|
+
const closestTwelveAM = new Date(unlockAtInSecondTimestamp * 1e3);
|
|
1572
|
+
closestTwelveAM.setUTCHours(0, 0, 0, 0);
|
|
1573
|
+
if (unlockDate.getUTCHours() >= 0) {
|
|
1574
|
+
closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() + 1);
|
|
1575
|
+
}
|
|
1576
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
1577
|
+
if (closestTwelveAM.getTime() - now > MAX_LOCK_DURATION * 1e3) {
|
|
1578
|
+
closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() - 1);
|
|
1579
|
+
}
|
|
1580
|
+
return Math.floor(closestTwelveAM.getTime() / 1e3);
|
|
1581
|
+
};
|
|
1290
1582
|
|
|
1291
|
-
// src/
|
|
1292
|
-
var
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
},
|
|
1326
|
-
wapt: {
|
|
1327
|
-
id: "0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37",
|
|
1328
|
-
metaData: "0xc969c5251f372c0f34c32759f1d315cf1ea0ee5e4454b52aea08778eacfdd0a8",
|
|
1329
|
-
treasury: "",
|
|
1330
|
-
oracle: {
|
|
1331
|
-
supra: "",
|
|
1332
|
-
switchboard: "",
|
|
1333
|
-
pyth: {
|
|
1334
|
-
feed: "03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5",
|
|
1335
|
-
feedObject: "0x7c5b7837c44a69b469325463ac0673ac1aa8435ff44ddb4191c9ae380463647f"
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
},
|
|
1339
|
-
wsol: {
|
|
1340
|
-
id: "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8",
|
|
1341
|
-
metaData: "0x4d2c39082b4477e3e79dc4562d939147ab90c42fc5f3e4acf03b94383cd69b6e",
|
|
1342
|
-
treasury: "",
|
|
1343
|
-
oracle: {
|
|
1344
|
-
supra: "",
|
|
1345
|
-
switchboard: "",
|
|
1346
|
-
pyth: {
|
|
1347
|
-
feed: "ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
|
|
1348
|
-
feedObject: "0x9d0d275efbd37d8a8855f6f2c761fa5983293dd8ce202ee5196626de8fcd4469"
|
|
1349
|
-
}
|
|
1350
|
-
}
|
|
1351
|
-
},
|
|
1352
|
-
wbtc: {
|
|
1353
|
-
id: "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881",
|
|
1354
|
-
metaData: "0x5d3c6e60eeff8a05b693b481539e7847dfe33013e7070cdcb387f5c0cac05dfd",
|
|
1355
|
-
treasury: "",
|
|
1356
|
-
oracle: {
|
|
1357
|
-
supra: "",
|
|
1358
|
-
switchboard: "",
|
|
1359
|
-
pyth: {
|
|
1360
|
-
feed: "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43",
|
|
1361
|
-
feedObject: "0x9a62b4863bdeaabdc9500fce769cf7e72d5585eeb28a6d26e4cafadc13f76ab2"
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
},
|
|
1365
|
-
weth: {
|
|
1366
|
-
id: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
|
|
1367
|
-
metaData: "0x8900e4ceede3363bef086d6b50ca89d816d0e90bf6bc46efefe1f8455e08f50f",
|
|
1368
|
-
treasury: "",
|
|
1369
|
-
oracle: {
|
|
1370
|
-
supra: "",
|
|
1371
|
-
switchboard: "",
|
|
1372
|
-
pyth: {
|
|
1373
|
-
feed: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
1374
|
-
feedObject: "0x9193fd47f9a0ab99b6e365a464c8a9ae30e6150fc37ed2a89c1586631f6fc4ab"
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
},
|
|
1378
|
-
wusdc: {
|
|
1379
|
-
id: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf",
|
|
1380
|
-
metaData: "0x4fbf84f3029bd0c0b77164b587963be957f853eccf834a67bb9ecba6ec80f189",
|
|
1381
|
-
treasury: "",
|
|
1382
|
-
oracle: {
|
|
1383
|
-
supra: "",
|
|
1384
|
-
switchboard: "",
|
|
1385
|
-
pyth: {
|
|
1386
|
-
feed: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
1387
|
-
feedObject: "0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab"
|
|
1388
|
-
}
|
|
1389
|
-
}
|
|
1390
|
-
},
|
|
1391
|
-
wusdt: {
|
|
1392
|
-
id: "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c",
|
|
1393
|
-
metaData: "0xfb0e3eb97dd158a5ae979dddfa24348063843c5b20eb8381dd5fa7c93699e45c",
|
|
1394
|
-
treasury: "",
|
|
1395
|
-
oracle: {
|
|
1396
|
-
supra: "",
|
|
1397
|
-
switchboard: "",
|
|
1398
|
-
pyth: {
|
|
1399
|
-
feed: "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
|
|
1400
|
-
feedObject: "0x985e3db9f93f76ee8bace7c3dd5cc676a096accd5d9e09e9ae0fb6e492b14572"
|
|
1401
|
-
}
|
|
1402
|
-
}
|
|
1403
|
-
},
|
|
1404
|
-
sui: {
|
|
1405
|
-
id: "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
1406
|
-
metaData: "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3",
|
|
1407
|
-
treasury: "",
|
|
1408
|
-
oracle: {
|
|
1409
|
-
supra: "",
|
|
1410
|
-
switchboard: "0xbca474133638352ba83ccf7b5c931d50f764b09550e16612c9f70f1e21f3f594",
|
|
1411
|
-
pyth: {
|
|
1412
|
-
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
1413
|
-
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
1414
|
-
}
|
|
1415
|
-
}
|
|
1416
|
-
},
|
|
1417
|
-
afsui: {
|
|
1418
|
-
id: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
|
|
1419
|
-
metaData: "0x2f9217f533e51334873a39b8026a4aa6919497b47f49d0986a4f1aec66f8a34d",
|
|
1420
|
-
treasury: "",
|
|
1421
|
-
oracle: {
|
|
1422
|
-
supra: "",
|
|
1423
|
-
switchboard: "",
|
|
1424
|
-
pyth: {
|
|
1425
|
-
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
1426
|
-
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
},
|
|
1430
|
-
hasui: {
|
|
1431
|
-
id: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
|
|
1432
|
-
metaData: "0x2c5f33af93f6511df699aaaa5822d823aac6ed99d4a0de2a4a50b3afa0172e24",
|
|
1433
|
-
treasury: "",
|
|
1434
|
-
oracle: {
|
|
1435
|
-
supra: "",
|
|
1436
|
-
switchboard: "",
|
|
1437
|
-
pyth: {
|
|
1438
|
-
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
1439
|
-
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
},
|
|
1443
|
-
vsui: {
|
|
1444
|
-
id: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
|
|
1445
|
-
metaData: "0xabd84a23467b33854ab25cf862006fd97479f8f6f53e50fe732c43a274d939bd",
|
|
1446
|
-
treasury: "",
|
|
1447
|
-
oracle: {
|
|
1448
|
-
supra: "",
|
|
1449
|
-
switchboard: "",
|
|
1450
|
-
pyth: {
|
|
1451
|
-
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
1452
|
-
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
1453
|
-
}
|
|
1583
|
+
// src/utils/tokenBucket.ts
|
|
1584
|
+
var TokenBucket = class {
|
|
1585
|
+
constructor(tokensPerInterval, intervalInMs) {
|
|
1586
|
+
this.tokensPerInterval = tokensPerInterval;
|
|
1587
|
+
this.interval = intervalInMs;
|
|
1588
|
+
this.tokens = tokensPerInterval;
|
|
1589
|
+
this.lastRefill = Date.now();
|
|
1590
|
+
}
|
|
1591
|
+
refill() {
|
|
1592
|
+
const now = Date.now();
|
|
1593
|
+
const elapsed = now - this.lastRefill;
|
|
1594
|
+
if (elapsed > this.interval) {
|
|
1595
|
+
const tokensToAdd = Math.floor(elapsed / this.interval) * this.tokensPerInterval;
|
|
1596
|
+
this.tokens = Math.min(this.tokens + tokensToAdd, this.tokensPerInterval);
|
|
1597
|
+
this.lastRefill = now;
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
removeTokens(count) {
|
|
1601
|
+
this.refill();
|
|
1602
|
+
if (this.tokens >= count) {
|
|
1603
|
+
this.tokens -= count;
|
|
1604
|
+
return true;
|
|
1605
|
+
}
|
|
1606
|
+
return false;
|
|
1607
|
+
}
|
|
1608
|
+
};
|
|
1609
|
+
var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVAL_IN_MS, maxRetries = 15, backoffFactor = 1.25) => {
|
|
1610
|
+
let retries = 0;
|
|
1611
|
+
const tryRequest = async () => {
|
|
1612
|
+
if (tokenBucket.removeTokens(1)) {
|
|
1613
|
+
try {
|
|
1614
|
+
const result = await fn();
|
|
1615
|
+
if (result && result.status === 429) {
|
|
1616
|
+
throw new Error("Unexpected status code: 429");
|
|
1454
1617
|
}
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
feedObject: "0xf6de1d3279a269a597d813cbaca59aa906543ab9a8c64e84a4722f1a20863985"
|
|
1466
|
-
}
|
|
1618
|
+
return result;
|
|
1619
|
+
} catch (error) {
|
|
1620
|
+
if (error.message === "Unexpected status code: 429" && retries < maxRetries) {
|
|
1621
|
+
retries++;
|
|
1622
|
+
const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
|
|
1623
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1624
|
+
return tryRequest();
|
|
1625
|
+
} else {
|
|
1626
|
+
console.error("An error occurred:", error.message);
|
|
1627
|
+
return null;
|
|
1467
1628
|
}
|
|
1468
1629
|
}
|
|
1469
|
-
}
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
registryCap: "0xbcb07141eb1f7e01fbda4130ecf5f5adaeabb77f5d9c32158b7532bcd2197acd",
|
|
1478
|
-
state: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
|
|
1479
|
-
wormhole: "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a",
|
|
1480
|
-
wormholeState: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c"
|
|
1481
|
-
}
|
|
1482
|
-
},
|
|
1483
|
-
packages: {
|
|
1484
|
-
coinDecimalsRegistry: {
|
|
1485
|
-
id: "0xca5a5a62f01c79a104bf4d31669e29daa387f325c241de4edbe30986a9bc8b0d",
|
|
1486
|
-
upgradeCap: "0x34e76a945d29f195bc53ca704fa70877d1cf3a5d7bbfdda1b13e633fff13c0f6"
|
|
1487
|
-
},
|
|
1488
|
-
math: {
|
|
1489
|
-
id: "0xad013d5fde39e15eabda32b3dbdafd67dac32b798ce63237c27a8f73339b9b6f",
|
|
1490
|
-
upgradeCap: "0x3a329598231de02e6135c62284b66005b41cad1d9ab7ca2dc79c08293aba2ec6"
|
|
1491
|
-
},
|
|
1492
|
-
whitelist: {
|
|
1493
|
-
id: "0x1318fdc90319ec9c24df1456d960a447521b0a658316155895014a6e39b5482f",
|
|
1494
|
-
upgradeCap: "0xf5a22aea23db664f7b69855b6a546747f17c1ec4230319cfc17225e462b05761"
|
|
1495
|
-
},
|
|
1496
|
-
x: {
|
|
1497
|
-
id: "0x779b5c547976899f5474f3a5bc0db36ddf4697ad7e5a901db0415c2281d28162",
|
|
1498
|
-
upgradeCap: "0x3f203f6fff6a69d151e4f1cd931f22b68c489ef2759765662fc7baf673943c9e"
|
|
1499
|
-
},
|
|
1500
|
-
protocol: {
|
|
1501
|
-
id: "0x87ddec2984645dbbe2403a509cc6edf393a43acdba9b77d45da2bcbefcf733c1",
|
|
1502
|
-
upgradeCap: "0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a"
|
|
1503
|
-
},
|
|
1504
|
-
// protocol: {
|
|
1505
|
-
// id: '0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e',
|
|
1506
|
-
// upgradeCap:
|
|
1507
|
-
// '0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a',
|
|
1508
|
-
// },
|
|
1509
|
-
protocolWhitelist: {
|
|
1510
|
-
id: "0x4c262d9343dac53ecb28f482a2a3f62c73d0ebac5b5f03d57383d56ff219acdf",
|
|
1511
|
-
upgradeCap: "0x4a5e88a75039b00988f633f811f58117f31b8627a46bf822aa114d9010049449"
|
|
1512
|
-
},
|
|
1513
|
-
// query: {
|
|
1514
|
-
// id: '0xb8d603a39114a5efef3dd0bf84df0bed1be1fbd39b78b7dd6e8a61ccc5e6006f',
|
|
1515
|
-
// upgradeCap:
|
|
1516
|
-
// '0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f',
|
|
1517
|
-
// },
|
|
1518
|
-
query: {
|
|
1519
|
-
id: "0xe4f9d62d17746d5b9dbf0d5557747430021a71575780b515161210cdba0a4c1c",
|
|
1520
|
-
upgradeCap: "0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f"
|
|
1521
|
-
},
|
|
1522
|
-
supra: { id: "", upgradeCap: "" },
|
|
1523
|
-
pyth: {
|
|
1524
|
-
id: "0x910f30cbc7f601f75a5141a01265cd47c62d468707c5e1aecb32a18f448cb25a",
|
|
1525
|
-
upgradeCap: "0xdf0ffbae1ea5bb25fbca5efba433dcf00c7cced65679af2f04728901275c6157"
|
|
1526
|
-
},
|
|
1527
|
-
switchboard: { id: "", upgradeCap: "" },
|
|
1528
|
-
xOracle: {
|
|
1529
|
-
id: "0x1478a432123e4b3d61878b629f2c692969fdb375644f1251cd278a4b1e7d7cd6",
|
|
1530
|
-
upgradeCap: "0x0f928a6b2e26b73330fecaf9b44acfc9800a4a9794d6415c2a3153bc70e3c1f0"
|
|
1531
|
-
},
|
|
1532
|
-
testCoin: { id: "", upgradeCap: "" }
|
|
1630
|
+
} else if (retries < maxRetries) {
|
|
1631
|
+
retries++;
|
|
1632
|
+
const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
|
|
1633
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1634
|
+
return tryRequest();
|
|
1635
|
+
} else {
|
|
1636
|
+
console.error("Maximum retries reached");
|
|
1637
|
+
return null;
|
|
1533
1638
|
}
|
|
1534
|
-
}
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1639
|
+
};
|
|
1640
|
+
return tryRequest();
|
|
1641
|
+
};
|
|
1642
|
+
|
|
1643
|
+
// src/utils/indexer.ts
|
|
1644
|
+
async function callMethodWithIndexerFallback(method, context, ...args) {
|
|
1645
|
+
const indexer = args[args.length - 1];
|
|
1646
|
+
if (indexer) {
|
|
1647
|
+
try {
|
|
1648
|
+
return await method.apply(context, args);
|
|
1649
|
+
} catch (e) {
|
|
1650
|
+
console.warn(`Indexer requests failed: ${e}. Retrying without indexer..`);
|
|
1651
|
+
return await method.apply(context, [...args.slice(0, -1), false]);
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
return await method.apply(context, args);
|
|
1655
|
+
}
|
|
1656
|
+
function withIndexerFallback(method) {
|
|
1657
|
+
return (...args) => {
|
|
1658
|
+
return callMethodWithIndexerFallback(method, this, ...args);
|
|
1659
|
+
};
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
// src/models/scallopCache.ts
|
|
1663
|
+
var ScallopCache = class {
|
|
1664
|
+
constructor(suiKit, walletAddress, cacheOptions, tokenBucket, queryClient) {
|
|
1665
|
+
this.queryClient = queryClient ?? new import_query_core.QueryClient(cacheOptions ?? DEFAULT_CACHE_OPTIONS);
|
|
1666
|
+
this._suiKit = suiKit;
|
|
1667
|
+
this.tokenBucket = tokenBucket ?? new TokenBucket(DEFAULT_TOKENS_PER_INTERVAL, DEFAULT_INTERVAL_IN_MS);
|
|
1668
|
+
this.walletAddress = walletAddress ?? suiKit.currentAddress();
|
|
1669
|
+
}
|
|
1670
|
+
get suiKit() {
|
|
1671
|
+
if (!this._suiKit) {
|
|
1672
|
+
throw new Error("SuiKit instance is not initialized");
|
|
1673
|
+
}
|
|
1674
|
+
return this._suiKit;
|
|
1675
|
+
}
|
|
1676
|
+
get client() {
|
|
1677
|
+
return this.suiKit.client();
|
|
1678
|
+
}
|
|
1679
|
+
/**
|
|
1680
|
+
* @description Invalidate cache based on the refetchType parameter
|
|
1681
|
+
* @param refetchType Determines the type of queries to be refetched. Defaults to `active`.
|
|
1682
|
+
*
|
|
1683
|
+
* - `active`: Only queries that match the refetch predicate and are actively being rendered via useQuery and related functions will be refetched in the background.
|
|
1684
|
+
* - `inactive`: Only queries that match the refetch predicate and are NOT actively being rendered via useQuery and related functions will be refetched in the background.
|
|
1685
|
+
* - `all`: All queries that match the refetch predicate will be refetched in the background.
|
|
1686
|
+
* - `none`: No queries will be refetched. Queries that match the refetch predicate will only be marked as invalid.
|
|
1687
|
+
*/
|
|
1688
|
+
async invalidateAllCache() {
|
|
1689
|
+
return Object.values(queryKeys.rpc).map(
|
|
1690
|
+
(t) => this.queryClient.invalidateQueries({
|
|
1691
|
+
queryKey: t(),
|
|
1692
|
+
type: "all"
|
|
1693
|
+
})
|
|
1694
|
+
);
|
|
1695
|
+
}
|
|
1696
|
+
/**
|
|
1697
|
+
* @description Provides cache for inspectTxn of the SuiKit.
|
|
1698
|
+
* @param QueryInspectTxnParams
|
|
1699
|
+
* @param txBlock
|
|
1700
|
+
* @returns Promise<DevInspectResults>
|
|
1701
|
+
*/
|
|
1702
|
+
async queryInspectTxn({
|
|
1703
|
+
queryTarget,
|
|
1704
|
+
args,
|
|
1705
|
+
typeArgs
|
|
1706
|
+
}) {
|
|
1707
|
+
const txBlock = new import_sui_kit.SuiTxBlock();
|
|
1708
|
+
txBlock.moveCall(queryTarget, args, typeArgs);
|
|
1709
|
+
const query = await this.queryClient.fetchQuery({
|
|
1710
|
+
queryKey: queryKeys.rpc.getInspectTxn(queryTarget, args, typeArgs),
|
|
1711
|
+
queryFn: async () => {
|
|
1712
|
+
return await callWithRateLimit(
|
|
1713
|
+
this.tokenBucket,
|
|
1714
|
+
() => this.suiKit.inspectTxn(txBlock)
|
|
1715
|
+
);
|
|
1716
|
+
}
|
|
1717
|
+
});
|
|
1718
|
+
return query;
|
|
1719
|
+
}
|
|
1720
|
+
/**
|
|
1721
|
+
* @description Provides cache for getObject of the SuiKit.
|
|
1722
|
+
* @param objectId
|
|
1723
|
+
* @param QueryObjectParams
|
|
1724
|
+
* @returns Promise<SuiObjectResponse>
|
|
1725
|
+
*/
|
|
1726
|
+
async queryGetObject(objectId, options) {
|
|
1727
|
+
return this.queryClient.fetchQuery({
|
|
1728
|
+
queryKey: queryKeys.rpc.getObject(objectId, this.walletAddress, options),
|
|
1729
|
+
queryFn: async () => {
|
|
1730
|
+
return await callWithRateLimit(
|
|
1731
|
+
this.tokenBucket,
|
|
1732
|
+
() => this.client.getObject({
|
|
1733
|
+
id: objectId,
|
|
1734
|
+
options
|
|
1735
|
+
})
|
|
1736
|
+
);
|
|
1598
1737
|
}
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
// '0xf21b0ed043c9bb70842c0129159f4943dbcc3c9ef2f2f808af65f8be25cfd20e',
|
|
1623
|
-
authorizedWitnessList: "0x9d6223dc52015b8a3986a573590ef2af8f1b8f3e4685513888c052f001b87e7f",
|
|
1624
|
-
version: "0x1bd4b7285f72e11c316b828c7c47b3f4da18dcec9f9b3dba6d8629cbb6f93e5e"
|
|
1625
|
-
},
|
|
1626
|
-
vesca: {
|
|
1627
|
-
id: "0xb15b6e0cdd85afb5028bea851dd249405e734d800a259147bbc24980629723a4",
|
|
1628
|
-
object: "0xb15b6e0cdd85afb5028bea851dd249405e734d800a259147bbc24980629723a4",
|
|
1629
|
-
adminCap: "0x8ffa76135c5b85c5fbd73a6448a4a733d826cb63a267ab817656acb77c72d4a5",
|
|
1630
|
-
tableId: "0xe3153b2bf124be0b86cb8bd468346a861efd0da52fc42197b54d2f616488a311",
|
|
1631
|
-
table: "0x611cb8d9d4d90867467b5ebdf4cc447a0047ed5b01334a28a29fcfe733e3d609",
|
|
1632
|
-
treasury: "0xe8c112c09b88158dc6c8e23d1fbae5b3c7136cdee54b7dafc08e65db28c4a5bc",
|
|
1633
|
-
config: "0xe0a2ff281e73c1d53cfa85807080f87e833e4f1a7f93dcf8800b3865269a76b9"
|
|
1634
|
-
},
|
|
1635
|
-
loyaltyProgram: {
|
|
1636
|
-
id: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
1637
|
-
object: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
1638
|
-
rewardPool: "0xf9c090492ef476bd542109d0913ffe871cbfa28578b7114eca2a8c0e5671786f",
|
|
1639
|
-
userRewardTableId: "0x748a80395849ed37db1b0e14f2ab5d1d96458d2359ab3a84eb079d0f4ac7cf2e"
|
|
1640
|
-
},
|
|
1641
|
-
scoin: {
|
|
1642
|
-
id: "0xad2ca2aa5089df94bb2d444d5eb3520378c2f2dfb3a0bd2a2c994145ac4b0a53",
|
|
1643
|
-
coins: {
|
|
1644
|
-
ssui: {
|
|
1645
|
-
coinType: "0xfac769100bccc0caebcf4f4e2d00ac2f8883f07f724be28940df90605f5e7e9a::scallop_sui::SCALLOP_SUI",
|
|
1646
|
-
treasury: "0x9cb4551b36c17d37e19d700147fa819ea1c487ff8bcf18374de2cceb2e9d4845"
|
|
1647
|
-
},
|
|
1648
|
-
scetus: {
|
|
1649
|
-
coinType: "0x8b71e6d323ed78515af2bead13bf3d0da1562ba4a99234eb7c4f14fd39ef0427::scallop_cetus::SCALLOP_CETUS",
|
|
1650
|
-
treasury: "0xd786f4b2d26278cc7911a3445b1b085eab60f269ef9dbb6b87e803d52f155003"
|
|
1651
|
-
},
|
|
1652
|
-
ssca: {
|
|
1653
|
-
coinType: "0x0a9d3c6c9af9f6e8def82921541bcbd17f73ed31bed3adcb684f2a4c267e42f0::scallop_sca::SCALLOP_SCA",
|
|
1654
|
-
treasury: "0xe818636d1d6c46d6ea1a2dce9d94696d7cbc18ce27451b603eeaa47aba8d75e0"
|
|
1655
|
-
},
|
|
1656
|
-
swusdc: {
|
|
1657
|
-
coinType: "0xaedc3ab75db8680b81a755015fa90124d217be93457b893c05bac033817defaf::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
|
|
1658
|
-
treasury: "0xfc6971648f867f7fd6928d1b873af71577e2eaf2c7543ef8bc82c431d833ae78"
|
|
1659
|
-
},
|
|
1660
|
-
swusdt: {
|
|
1661
|
-
coinType: "0xbf02fc87ddc104b342ad8414c85ceadf5b0c823c055a06fb0ed776272c01a52a::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
|
|
1662
|
-
treasury: "0xb9593e2c3a0ba796ee815012b75ae46468ea78cda0188b9ac6816efe65503521"
|
|
1663
|
-
},
|
|
1664
|
-
sweth: {
|
|
1665
|
-
coinType: "0x27d54f43e3eda701be56b82e5756e41c84467cd202f5cf713d5f9e45a9f1b6bc::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
|
|
1666
|
-
treasury: "0x032b4c8fac94c038dbe986f7587e9b1e4ef580b5ee06d2ef249d85459b7ef05d"
|
|
1667
|
-
},
|
|
1668
|
-
safsui: {
|
|
1669
|
-
coinType: "0xb75b46d975d8d80670b53a6bee90baaa8ce2e0b7d397f079447d641eef6b44ad::scallop_af_sui::SCALLOP_AF_SUI",
|
|
1670
|
-
treasury: "0x21450ef0570ef3d224ffa3b873ab802e439ece7b93cc7efad10ae0c1e3b3fcfe"
|
|
1671
|
-
},
|
|
1672
|
-
shasui: {
|
|
1673
|
-
coinType: "0xd973a723874e2c7cde196602a79155a1343a933f8cf87d9b1bb7408bc1acbc58::scallop_ha_sui::SCALLOP_HA_SUI",
|
|
1674
|
-
treasury: "0xf822fc1402207e47d2e3ba8ff6e1e594bf1de777dc5ebd2744619cd2726e3b0d"
|
|
1675
|
-
},
|
|
1676
|
-
svsui: {
|
|
1677
|
-
coinType: "0x97023a317320c4498cc4cd239dd02fd30c28246e5e8f81325d63f2bd8d70f6b3::scallop_v_sui::SCALLOP_V_SUI",
|
|
1678
|
-
treasury: "0x327114f0bf3559d7e2de10282147ed76a236c7c6775029165c4db09a6062ead6\u0192"
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1740
|
+
/**
|
|
1741
|
+
* @description Provides cache for getObjects of the SuiKit.
|
|
1742
|
+
* @param objectIds
|
|
1743
|
+
* @returns Promise<SuiObjectData[]>
|
|
1744
|
+
*/
|
|
1745
|
+
async queryGetObjects(objectIds, options = {
|
|
1746
|
+
showContent: true
|
|
1747
|
+
}) {
|
|
1748
|
+
if (objectIds.length === 0)
|
|
1749
|
+
return [];
|
|
1750
|
+
return this.queryClient.fetchQuery({
|
|
1751
|
+
queryKey: queryKeys.rpc.getObjects(
|
|
1752
|
+
objectIds,
|
|
1753
|
+
this.walletAddress,
|
|
1754
|
+
options
|
|
1755
|
+
),
|
|
1756
|
+
queryFn: async () => {
|
|
1757
|
+
return await callWithRateLimit(
|
|
1758
|
+
this.tokenBucket,
|
|
1759
|
+
() => this.suiKit.getObjects(objectIds, options)
|
|
1760
|
+
);
|
|
1679
1761
|
}
|
|
1680
|
-
}
|
|
1762
|
+
});
|
|
1763
|
+
}
|
|
1764
|
+
/**
|
|
1765
|
+
* @description Provides cache for getOwnedObjects of the SuiKit.
|
|
1766
|
+
* @param input
|
|
1767
|
+
* @returns Promise<PaginatedObjectsResponse>
|
|
1768
|
+
*/
|
|
1769
|
+
async queryGetOwnedObjects(input) {
|
|
1770
|
+
return this.queryClient.fetchQuery({
|
|
1771
|
+
queryKey: queryKeys.rpc.getOwnedObjects(input),
|
|
1772
|
+
queryFn: async () => {
|
|
1773
|
+
return await callWithRateLimit(
|
|
1774
|
+
this.tokenBucket,
|
|
1775
|
+
() => this.client.getOwnedObjects(input)
|
|
1776
|
+
);
|
|
1777
|
+
}
|
|
1778
|
+
});
|
|
1779
|
+
}
|
|
1780
|
+
async queryGetDynamicFields(input) {
|
|
1781
|
+
return this.queryClient.fetchQuery({
|
|
1782
|
+
queryKey: queryKeys.rpc.getDynamicFields(input),
|
|
1783
|
+
queryFn: async () => {
|
|
1784
|
+
return await callWithRateLimit(
|
|
1785
|
+
this.tokenBucket,
|
|
1786
|
+
() => this.client.getDynamicFields(input)
|
|
1787
|
+
);
|
|
1788
|
+
}
|
|
1789
|
+
});
|
|
1790
|
+
}
|
|
1791
|
+
async queryGetDynamicFieldObject(input) {
|
|
1792
|
+
return this.queryClient.fetchQuery({
|
|
1793
|
+
queryKey: queryKeys.rpc.getDynamicFieldObject(input),
|
|
1794
|
+
queryFn: async () => {
|
|
1795
|
+
return await callWithRateLimit(
|
|
1796
|
+
this.tokenBucket,
|
|
1797
|
+
() => this.client.getDynamicFieldObject(input)
|
|
1798
|
+
);
|
|
1799
|
+
}
|
|
1800
|
+
});
|
|
1801
|
+
}
|
|
1802
|
+
async queryGetAllCoinBalances(owner) {
|
|
1803
|
+
return this.queryClient.fetchQuery({
|
|
1804
|
+
queryKey: queryKeys.rpc.getAllCoinBalances(owner),
|
|
1805
|
+
queryFn: async () => {
|
|
1806
|
+
const allBalances = await callWithRateLimit(
|
|
1807
|
+
this.tokenBucket,
|
|
1808
|
+
() => this.client.getAllBalances({ owner })
|
|
1809
|
+
);
|
|
1810
|
+
if (!allBalances)
|
|
1811
|
+
return {};
|
|
1812
|
+
const balances = allBalances.reduce(
|
|
1813
|
+
(acc, coinBalance) => {
|
|
1814
|
+
if (coinBalance.totalBalance !== "0") {
|
|
1815
|
+
acc[(0, import_sui_kit.normalizeStructTag)(coinBalance.coinType)] = coinBalance.totalBalance;
|
|
1816
|
+
}
|
|
1817
|
+
return acc;
|
|
1818
|
+
},
|
|
1819
|
+
{}
|
|
1820
|
+
);
|
|
1821
|
+
return balances;
|
|
1822
|
+
}
|
|
1823
|
+
});
|
|
1824
|
+
}
|
|
1825
|
+
async queryGetCoinBalance(input) {
|
|
1826
|
+
if (!input.coinType)
|
|
1827
|
+
return "0";
|
|
1828
|
+
return (await this.queryGetAllCoinBalances(input.owner) || {})[(0, import_sui_kit.normalizeStructTag)(input.coinType)] ?? "0";
|
|
1681
1829
|
}
|
|
1682
1830
|
};
|
|
1683
1831
|
|
|
1684
1832
|
// src/models/scallopAddress.ts
|
|
1833
|
+
var import_axios = __toESM(require("axios"));
|
|
1685
1834
|
var EMPTY_ADDRESSES = {
|
|
1686
1835
|
core: {
|
|
1687
1836
|
version: "",
|
|
@@ -2343,54 +2492,137 @@ var ScallopAddress = class {
|
|
|
2343
2492
|
}
|
|
2344
2493
|
};
|
|
2345
2494
|
|
|
2346
|
-
// src/models/scallopClient.ts
|
|
2347
|
-
var import_utils25 = require("@mysten/sui/utils");
|
|
2348
|
-
var import_sui_kit15 = require("@scallop-io/sui-kit");
|
|
2349
|
-
|
|
2350
|
-
// src/models/scallopUtils.ts
|
|
2351
|
-
var import_utils10 = require("@mysten/sui/utils");
|
|
2352
|
-
var import_sui_kit4 = require("@scallop-io/sui-kit");
|
|
2353
|
-
var import_pyth_sui_js = require("@pythnetwork/pyth-sui-js");
|
|
2354
|
-
|
|
2355
|
-
// src/queries/coreQuery.ts
|
|
2356
|
-
var import_utils3 = require("@mysten/sui/utils");
|
|
2357
|
-
var import_bignumber2 = __toESM(require("bignumber.js"));
|
|
2358
|
-
|
|
2359
|
-
// src/queries/supplyLimit.ts
|
|
2360
|
-
var import_zod = require("zod");
|
|
2361
|
-
var supplyLimitZod = import_zod.z.object({
|
|
2362
|
-
dataType: import_zod.z.string(),
|
|
2363
|
-
type: import_zod.z.string(),
|
|
2364
|
-
hasPublicTransfer: import_zod.z.boolean(),
|
|
2365
|
-
fields: import_zod.z.object({
|
|
2366
|
-
id: import_zod.z.object({
|
|
2367
|
-
id: import_zod.z.string()
|
|
2368
|
-
}),
|
|
2369
|
-
name: import_zod.z.object({
|
|
2370
|
-
type: import_zod.z.string()
|
|
2371
|
-
}),
|
|
2372
|
-
value: import_zod.z.string()
|
|
2373
|
-
})
|
|
2374
|
-
});
|
|
2375
|
-
var SUPPLY_LIMIT_KEY = "0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey";
|
|
2376
|
-
var getSupplyLimit = async (utils, poolName) => {
|
|
2377
|
-
const poolCoinType = utils.parseCoinType(poolName).slice(2);
|
|
2378
|
-
const marketObject = utils.address.get("core.market");
|
|
2379
|
-
if (!marketObject)
|
|
2380
|
-
return null;
|
|
2381
|
-
const object = await utils.cache.queryGetDynamicFieldObject({
|
|
2382
|
-
parentId: marketObject,
|
|
2383
|
-
name: {
|
|
2384
|
-
type: SUPPLY_LIMIT_KEY,
|
|
2385
|
-
value: poolCoinType
|
|
2386
|
-
}
|
|
2387
|
-
});
|
|
2388
|
-
const parsedData = supplyLimitZod.safeParse(object?.data?.content);
|
|
2389
|
-
if (!parsedData.success)
|
|
2390
|
-
return null;
|
|
2391
|
-
return parsedData.data.fields.value;
|
|
2392
|
-
};
|
|
2393
|
-
|
|
2495
|
+
// src/models/scallopClient.ts
|
|
2496
|
+
var import_utils25 = require("@mysten/sui/utils");
|
|
2497
|
+
var import_sui_kit15 = require("@scallop-io/sui-kit");
|
|
2498
|
+
|
|
2499
|
+
// src/models/scallopUtils.ts
|
|
2500
|
+
var import_utils10 = require("@mysten/sui/utils");
|
|
2501
|
+
var import_sui_kit4 = require("@scallop-io/sui-kit");
|
|
2502
|
+
var import_pyth_sui_js = require("@pythnetwork/pyth-sui-js");
|
|
2503
|
+
|
|
2504
|
+
// src/queries/coreQuery.ts
|
|
2505
|
+
var import_utils3 = require("@mysten/sui/utils");
|
|
2506
|
+
var import_bignumber2 = __toESM(require("bignumber.js"));
|
|
2507
|
+
|
|
2508
|
+
// src/queries/supplyLimit.ts
|
|
2509
|
+
var import_zod = require("zod");
|
|
2510
|
+
var supplyLimitZod = import_zod.z.object({
|
|
2511
|
+
dataType: import_zod.z.string(),
|
|
2512
|
+
type: import_zod.z.string(),
|
|
2513
|
+
hasPublicTransfer: import_zod.z.boolean(),
|
|
2514
|
+
fields: import_zod.z.object({
|
|
2515
|
+
id: import_zod.z.object({
|
|
2516
|
+
id: import_zod.z.string()
|
|
2517
|
+
}),
|
|
2518
|
+
name: import_zod.z.object({
|
|
2519
|
+
type: import_zod.z.string()
|
|
2520
|
+
}),
|
|
2521
|
+
value: import_zod.z.string()
|
|
2522
|
+
})
|
|
2523
|
+
});
|
|
2524
|
+
var SUPPLY_LIMIT_KEY = "0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey";
|
|
2525
|
+
var getSupplyLimit = async (utils, poolName) => {
|
|
2526
|
+
const poolCoinType = utils.parseCoinType(poolName).slice(2);
|
|
2527
|
+
const marketObject = utils.address.get("core.market");
|
|
2528
|
+
if (!marketObject)
|
|
2529
|
+
return null;
|
|
2530
|
+
const object = await utils.cache.queryGetDynamicFieldObject({
|
|
2531
|
+
parentId: marketObject,
|
|
2532
|
+
name: {
|
|
2533
|
+
type: SUPPLY_LIMIT_KEY,
|
|
2534
|
+
value: poolCoinType
|
|
2535
|
+
}
|
|
2536
|
+
});
|
|
2537
|
+
const parsedData = supplyLimitZod.safeParse(object?.data?.content);
|
|
2538
|
+
if (!parsedData.success)
|
|
2539
|
+
return null;
|
|
2540
|
+
return parsedData.data.fields.value;
|
|
2541
|
+
};
|
|
2542
|
+
|
|
2543
|
+
// src/queries/isolatedAsset.ts
|
|
2544
|
+
var import_zod2 = require("zod");
|
|
2545
|
+
var isolatedAssetZod = import_zod2.z.object({
|
|
2546
|
+
dataType: import_zod2.z.string(),
|
|
2547
|
+
type: import_zod2.z.string(),
|
|
2548
|
+
hasPublicTransfer: import_zod2.z.boolean(),
|
|
2549
|
+
fields: import_zod2.z.object({
|
|
2550
|
+
id: import_zod2.z.object({
|
|
2551
|
+
id: import_zod2.z.string()
|
|
2552
|
+
}),
|
|
2553
|
+
name: import_zod2.z.object({
|
|
2554
|
+
type: import_zod2.z.string()
|
|
2555
|
+
}),
|
|
2556
|
+
value: import_zod2.z.boolean()
|
|
2557
|
+
})
|
|
2558
|
+
});
|
|
2559
|
+
var getIsolatedAssets = async (address) => {
|
|
2560
|
+
try {
|
|
2561
|
+
const marketObject = address.get("core.market");
|
|
2562
|
+
const protocolObject = address.get("core.packages.protocol.id");
|
|
2563
|
+
const ISOLATED_ASSET_KEY = `${protocolObject}::market_dynamic_keys::IsolatedAssetKey`;
|
|
2564
|
+
const isolatedAssets = [];
|
|
2565
|
+
if (!marketObject)
|
|
2566
|
+
return isolatedAssets;
|
|
2567
|
+
let hasNextPage = false;
|
|
2568
|
+
let nextCursor = null;
|
|
2569
|
+
const isIsolatedDynamicField = (dynamicField) => {
|
|
2570
|
+
return dynamicField.name.type === ISOLATED_ASSET_KEY;
|
|
2571
|
+
};
|
|
2572
|
+
do {
|
|
2573
|
+
const response = await address.cache.queryGetDynamicFields({
|
|
2574
|
+
parentId: marketObject,
|
|
2575
|
+
cursor: nextCursor,
|
|
2576
|
+
limit: 10
|
|
2577
|
+
});
|
|
2578
|
+
if (!response)
|
|
2579
|
+
break;
|
|
2580
|
+
const isolatedAssetCoinTypes = response.data.filter(isIsolatedDynamicField).map(({ name }) => `0x${name.value.type.name}`);
|
|
2581
|
+
isolatedAssets.push(...isolatedAssetCoinTypes);
|
|
2582
|
+
if (response && response.hasNextPage && response.nextCursor) {
|
|
2583
|
+
hasNextPage = true;
|
|
2584
|
+
nextCursor = response.nextCursor;
|
|
2585
|
+
} else {
|
|
2586
|
+
hasNextPage = false;
|
|
2587
|
+
}
|
|
2588
|
+
} while (hasNextPage);
|
|
2589
|
+
return isolatedAssets;
|
|
2590
|
+
} catch (e) {
|
|
2591
|
+
console.error(e);
|
|
2592
|
+
return [];
|
|
2593
|
+
}
|
|
2594
|
+
};
|
|
2595
|
+
var isIsolatedAsset = async (utils, coinName) => {
|
|
2596
|
+
try {
|
|
2597
|
+
const marketObject = utils.address.get("core.market");
|
|
2598
|
+
const protocolObject = utils.address.get("core.packages.protocol.id");
|
|
2599
|
+
const ISOLATED_ASSET_KEY = `${protocolObject}::market_dynamic_keys::IsolatedAssetKey`;
|
|
2600
|
+
const cachedData = utils.address.cache.queryClient.getQueryData([
|
|
2601
|
+
"getDynamicFields",
|
|
2602
|
+
marketObject
|
|
2603
|
+
]);
|
|
2604
|
+
if (cachedData) {
|
|
2605
|
+
const coinType2 = utils.parseCoinType(coinName);
|
|
2606
|
+
return cachedData.includes(coinType2);
|
|
2607
|
+
}
|
|
2608
|
+
const coinType = utils.parseCoinType(coinName).slice(2);
|
|
2609
|
+
const object = await utils.cache.queryGetDynamicFieldObject({
|
|
2610
|
+
parentId: marketObject,
|
|
2611
|
+
name: {
|
|
2612
|
+
type: ISOLATED_ASSET_KEY,
|
|
2613
|
+
value: coinType
|
|
2614
|
+
}
|
|
2615
|
+
});
|
|
2616
|
+
const parsedData = isolatedAssetZod.safeParse(object?.data?.content);
|
|
2617
|
+
if (!parsedData.success)
|
|
2618
|
+
return false;
|
|
2619
|
+
return parsedData.data.fields.value;
|
|
2620
|
+
} catch (e) {
|
|
2621
|
+
console.error(e);
|
|
2622
|
+
return false;
|
|
2623
|
+
}
|
|
2624
|
+
};
|
|
2625
|
+
|
|
2394
2626
|
// src/queries/coreQuery.ts
|
|
2395
2627
|
var queryMarket = async (query, indexer = false) => {
|
|
2396
2628
|
const coinPrices = await query.utils.getCoinPrices();
|
|
@@ -2475,8 +2707,8 @@ var queryMarket = async (query, indexer = false) => {
|
|
|
2475
2707
|
borrowFee: parsedMarketPoolData.borrowFee,
|
|
2476
2708
|
marketCoinSupplyAmount: parsedMarketPoolData.marketCoinSupplyAmount,
|
|
2477
2709
|
minBorrowAmount: parsedMarketPoolData.minBorrowAmount,
|
|
2478
|
-
|
|
2479
|
-
isIsolated: false,
|
|
2710
|
+
isIsolated: await isIsolatedAsset(query.utils, poolCoinName),
|
|
2711
|
+
// isIsolated: false,
|
|
2480
2712
|
maxSupplyCoin,
|
|
2481
2713
|
...calculatedMarketPoolData
|
|
2482
2714
|
};
|
|
@@ -2515,6 +2747,7 @@ var queryMarket = async (query, indexer = false) => {
|
|
|
2515
2747
|
liquidationDiscount: parsedMarketCollateralData.liquidationDiscount,
|
|
2516
2748
|
liquidationPanelty: parsedMarketCollateralData.liquidationPanelty,
|
|
2517
2749
|
liquidationReserveFactor: parsedMarketCollateralData.liquidationReserveFactor,
|
|
2750
|
+
isIsolated: await isIsolatedAsset(query.utils, collateralCoinName),
|
|
2518
2751
|
...calculatedMarketCollateralData
|
|
2519
2752
|
};
|
|
2520
2753
|
}
|
|
@@ -2562,79 +2795,73 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
|
|
|
2562
2795
|
return marketPools;
|
|
2563
2796
|
};
|
|
2564
2797
|
var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, coinPrice) => {
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
name: {
|
|
2591
|
-
type: "0x1::type_name::TypeName",
|
|
2592
|
-
value: {
|
|
2593
|
-
name: coinType.substring(2)
|
|
2594
|
-
}
|
|
2798
|
+
try {
|
|
2799
|
+
coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
|
|
2800
|
+
if (indexer) {
|
|
2801
|
+
const marketPoolIndexer = await query.indexer.getMarketPool(poolCoinName);
|
|
2802
|
+
marketPoolIndexer.coinPrice = coinPrice || marketPoolIndexer.coinPrice;
|
|
2803
|
+
marketPoolIndexer.coinWrappedType = query.utils.getCoinWrappedType(
|
|
2804
|
+
marketPoolIndexer.coinName
|
|
2805
|
+
);
|
|
2806
|
+
return marketPoolIndexer;
|
|
2807
|
+
}
|
|
2808
|
+
const marketId = query.address.get("core.market");
|
|
2809
|
+
marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
|
|
2810
|
+
showContent: true
|
|
2811
|
+
}))?.data;
|
|
2812
|
+
if (!(marketObject && marketObject.content?.dataType === "moveObject"))
|
|
2813
|
+
throw new Error(`Failed to fetch marketObject`);
|
|
2814
|
+
const fields = marketObject.content.fields;
|
|
2815
|
+
const coinType = query.utils.parseCoinType(poolCoinName);
|
|
2816
|
+
const balanceSheetParentId = fields.vault.fields.balance_sheets.fields.table.fields.id.id;
|
|
2817
|
+
const balanceSheetDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2818
|
+
parentId: balanceSheetParentId,
|
|
2819
|
+
name: {
|
|
2820
|
+
type: "0x1::type_name::TypeName",
|
|
2821
|
+
value: {
|
|
2822
|
+
name: coinType.substring(2)
|
|
2595
2823
|
}
|
|
2596
|
-
});
|
|
2597
|
-
if (!balanceSheetDynamicFieldObjectResponse)
|
|
2598
|
-
return void 0;
|
|
2599
|
-
const balanceSheetDynamicFieldObject = balanceSheetDynamicFieldObjectResponse.data;
|
|
2600
|
-
if (balanceSheetDynamicFieldObject && balanceSheetDynamicFieldObject.content && "fields" in balanceSheetDynamicFieldObject.content) {
|
|
2601
|
-
const dynamicFields = balanceSheetDynamicFieldObject.content.fields;
|
|
2602
|
-
balanceSheet = dynamicFields.value.fields;
|
|
2603
2824
|
}
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2825
|
+
});
|
|
2826
|
+
const balanceSheetDynamicFieldObject = balanceSheetDynamicFieldObjectResponse?.data;
|
|
2827
|
+
if (!(balanceSheetDynamicFieldObject && balanceSheetDynamicFieldObject.content && "fields" in balanceSheetDynamicFieldObject.content))
|
|
2828
|
+
throw new Error(
|
|
2829
|
+
`Failed to fetch balanceSheetDynamicFieldObject for ${poolCoinName}: ${balanceSheetDynamicFieldObjectResponse?.error?.code.toString()}`
|
|
2830
|
+
);
|
|
2831
|
+
const balanceSheet = balanceSheetDynamicFieldObject.content.fields.value.fields;
|
|
2832
|
+
const borrowIndexParentId = fields.borrow_dynamics.fields.table.fields.id.id;
|
|
2833
|
+
const borrowIndexDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2834
|
+
parentId: borrowIndexParentId,
|
|
2835
|
+
name: {
|
|
2836
|
+
type: "0x1::type_name::TypeName",
|
|
2837
|
+
value: {
|
|
2838
|
+
name: coinType.substring(2)
|
|
2612
2839
|
}
|
|
2613
|
-
});
|
|
2614
|
-
if (!borrowIndexDynamicFieldObjectResponse)
|
|
2615
|
-
return void 0;
|
|
2616
|
-
const borrowIndexDynamicFieldObject = borrowIndexDynamicFieldObjectResponse.data;
|
|
2617
|
-
if (borrowIndexDynamicFieldObject && borrowIndexDynamicFieldObject.content && "fields" in borrowIndexDynamicFieldObject.content) {
|
|
2618
|
-
const dynamicFields = borrowIndexDynamicFieldObject.content.fields;
|
|
2619
|
-
borrowIndex = dynamicFields.value.fields;
|
|
2620
2840
|
}
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2841
|
+
});
|
|
2842
|
+
const borrowIndexDynamicFieldObject = borrowIndexDynamicFieldObjectResponse?.data;
|
|
2843
|
+
if (!(borrowIndexDynamicFieldObject && borrowIndexDynamicFieldObject.content && "fields" in borrowIndexDynamicFieldObject.content))
|
|
2844
|
+
throw new Error(
|
|
2845
|
+
`Failed to fetch borrowIndexDynamicFieldObject for ${poolCoinName}`
|
|
2846
|
+
);
|
|
2847
|
+
const borrowIndex = borrowIndexDynamicFieldObject.content.fields.value.fields;
|
|
2848
|
+
const interestModelParentId = fields.interest_models.fields.table.fields.id.id;
|
|
2849
|
+
const interestModelDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2850
|
+
parentId: interestModelParentId,
|
|
2851
|
+
name: {
|
|
2852
|
+
type: "0x1::type_name::TypeName",
|
|
2853
|
+
value: {
|
|
2854
|
+
name: coinType.substring(2)
|
|
2629
2855
|
}
|
|
2630
|
-
});
|
|
2631
|
-
if (!interestModelDynamicFieldObjectResponse)
|
|
2632
|
-
return void 0;
|
|
2633
|
-
const interestModelDynamicFieldObject = interestModelDynamicFieldObjectResponse.data;
|
|
2634
|
-
if (interestModelDynamicFieldObject && interestModelDynamicFieldObject.content && "fields" in interestModelDynamicFieldObject.content) {
|
|
2635
|
-
const dynamicFields = interestModelDynamicFieldObject.content.fields;
|
|
2636
|
-
interestModel = dynamicFields.value.fields;
|
|
2637
2856
|
}
|
|
2857
|
+
});
|
|
2858
|
+
const interestModelDynamicFieldObject = interestModelDynamicFieldObjectResponse?.data;
|
|
2859
|
+
if (!(interestModelDynamicFieldObject && interestModelDynamicFieldObject.content && "fields" in interestModelDynamicFieldObject.content))
|
|
2860
|
+
throw new Error(
|
|
2861
|
+
`Failed to fetch interestModelDynamicFieldObject for ${poolCoinName}: ${interestModelDynamicFieldObject}`
|
|
2862
|
+
);
|
|
2863
|
+
const interestModel = interestModelDynamicFieldObject.content.fields.value.fields;
|
|
2864
|
+
const getBorrowFee = async () => {
|
|
2638
2865
|
const borrowFeeDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2639
2866
|
parentId: marketId,
|
|
2640
2867
|
name: {
|
|
@@ -2646,16 +2873,11 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2646
2873
|
}
|
|
2647
2874
|
}
|
|
2648
2875
|
});
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
borrowFeeRate = dynamicFields.value.fields;
|
|
2655
|
-
}
|
|
2656
|
-
}
|
|
2657
|
-
}
|
|
2658
|
-
if (balanceSheet && borrowIndex && interestModel && (USE_TEST_ADDRESS || borrowFeeRate)) {
|
|
2876
|
+
const borrowFeeDynamicFieldObject = borrowFeeDynamicFieldObjectResponse?.data;
|
|
2877
|
+
if (!(borrowFeeDynamicFieldObject && borrowFeeDynamicFieldObject.content && "fields" in borrowFeeDynamicFieldObject.content))
|
|
2878
|
+
return { value: "0" };
|
|
2879
|
+
return borrowFeeDynamicFieldObject.content.fields.value.fields;
|
|
2880
|
+
};
|
|
2659
2881
|
const parsedMarketPoolData = parseOriginMarketPoolData({
|
|
2660
2882
|
type: interestModel.type.fields,
|
|
2661
2883
|
maxBorrowRate: interestModel.max_borrow_rate.fields,
|
|
@@ -2669,7 +2891,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2669
2891
|
reserve: balanceSheet.revenue,
|
|
2670
2892
|
reserveFactor: interestModel.revenue_factor.fields,
|
|
2671
2893
|
borrowWeight: interestModel.borrow_weight.fields,
|
|
2672
|
-
borrowFeeRate:
|
|
2894
|
+
borrowFeeRate: await getBorrowFee(),
|
|
2673
2895
|
baseBorrowRatePerSec: interestModel.base_borrow_rate_per_sec.fields,
|
|
2674
2896
|
borrowRateOnHighKink: interestModel.borrow_rate_on_high_kink.fields,
|
|
2675
2897
|
borrowRateOnMidKink: interestModel.borrow_rate_on_mid_kink.fields,
|
|
@@ -2685,7 +2907,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2685
2907
|
const maxSupplyCoin = (0, import_bignumber2.default)(
|
|
2686
2908
|
await getSupplyLimit(query.utils, poolCoinName) ?? "0"
|
|
2687
2909
|
).shiftedBy(-coinDecimal).toNumber();
|
|
2688
|
-
|
|
2910
|
+
return {
|
|
2689
2911
|
coinName: poolCoinName,
|
|
2690
2912
|
symbol: query.utils.parseSymbol(poolCoinName),
|
|
2691
2913
|
coinType: query.utils.parseCoinType(poolCoinName),
|
|
@@ -2704,12 +2926,13 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2704
2926
|
marketCoinSupplyAmount: parsedMarketPoolData.marketCoinSupplyAmount,
|
|
2705
2927
|
minBorrowAmount: parsedMarketPoolData.minBorrowAmount,
|
|
2706
2928
|
maxSupplyCoin,
|
|
2707
|
-
|
|
2708
|
-
isIsolated: false,
|
|
2929
|
+
isIsolated: await isIsolatedAsset(query.utils, poolCoinName),
|
|
2930
|
+
// isIsolated: false,
|
|
2709
2931
|
...calculatedMarketPoolData
|
|
2710
2932
|
};
|
|
2933
|
+
} catch (e) {
|
|
2934
|
+
console.error(e);
|
|
2711
2935
|
}
|
|
2712
|
-
return marketPool;
|
|
2713
2936
|
};
|
|
2714
2937
|
var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLATERALS], indexer = false) => {
|
|
2715
2938
|
const marketId = query.address.get("core.market");
|
|
@@ -2758,85 +2981,76 @@ var getMarketCollateral = async (query, collateralCoinName, indexer = false, mar
|
|
|
2758
2981
|
);
|
|
2759
2982
|
return marketCollateralIndexer;
|
|
2760
2983
|
}
|
|
2761
|
-
let marketCollateral;
|
|
2762
|
-
let riskModel;
|
|
2763
|
-
let collateralStat;
|
|
2764
2984
|
const marketId = query.address.get("core.market");
|
|
2765
2985
|
marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
|
|
2766
2986
|
showContent: true
|
|
2767
2987
|
}))?.data;
|
|
2768
|
-
if (marketObject)
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
}
|
|
2780
|
-
}
|
|
2781
|
-
});
|
|
2782
|
-
if (!riskModelDynamicFieldObjectResponse)
|
|
2783
|
-
return void 0;
|
|
2784
|
-
const riskModelDynamicFieldObject = riskModelDynamicFieldObjectResponse.data;
|
|
2785
|
-
if (riskModelDynamicFieldObject && riskModelDynamicFieldObject.content && "fields" in riskModelDynamicFieldObject.content) {
|
|
2786
|
-
const dynamicFields = riskModelDynamicFieldObject.content.fields;
|
|
2787
|
-
riskModel = dynamicFields.value.fields;
|
|
2988
|
+
if (!(marketObject && marketObject.content?.dataType === "moveObject"))
|
|
2989
|
+
throw new Error(`Failed to fetch marketObject`);
|
|
2990
|
+
const fields = marketObject.content.fields;
|
|
2991
|
+
const coinType = query.utils.parseCoinType(collateralCoinName);
|
|
2992
|
+
const riskModelParentId = fields.risk_models.fields.table.fields.id.id;
|
|
2993
|
+
const riskModelDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2994
|
+
parentId: riskModelParentId,
|
|
2995
|
+
name: {
|
|
2996
|
+
type: "0x1::type_name::TypeName",
|
|
2997
|
+
value: {
|
|
2998
|
+
name: coinType.substring(2)
|
|
2788
2999
|
}
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
collateralStat = dynamicFields.value.fields;
|
|
3000
|
+
}
|
|
3001
|
+
});
|
|
3002
|
+
const riskModelDynamicFieldObject = riskModelDynamicFieldObjectResponse?.data;
|
|
3003
|
+
if (!(riskModelDynamicFieldObject && riskModelDynamicFieldObject.content && "fields" in riskModelDynamicFieldObject.content))
|
|
3004
|
+
throw new Error(
|
|
3005
|
+
`Failed to fetch riskModelDynamicFieldObject for ${riskModelDynamicFieldObjectResponse?.error?.code.toString()}: `
|
|
3006
|
+
);
|
|
3007
|
+
const riskModel = riskModelDynamicFieldObject.content.fields.value.fields;
|
|
3008
|
+
const collateralStatParentId = fields.collateral_stats.fields.table.fields.id.id;
|
|
3009
|
+
const collateralStatDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
3010
|
+
parentId: collateralStatParentId,
|
|
3011
|
+
name: {
|
|
3012
|
+
type: "0x1::type_name::TypeName",
|
|
3013
|
+
value: {
|
|
3014
|
+
name: coinType.substring(2)
|
|
2805
3015
|
}
|
|
2806
3016
|
}
|
|
2807
|
-
}
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
liquidationFactor: riskModel.liquidation_factor.fields,
|
|
2813
|
-
liquidationDiscount: riskModel.liquidation_discount.fields,
|
|
2814
|
-
liquidationPanelty: riskModel.liquidation_penalty.fields,
|
|
2815
|
-
liquidationReserveFactor: riskModel.liquidation_revenue_factor.fields,
|
|
2816
|
-
maxCollateralAmount: riskModel.max_collateral_amount,
|
|
2817
|
-
totalCollateralAmount: collateralStat.amount
|
|
2818
|
-
});
|
|
2819
|
-
const calculatedMarketCollateralData = calculateMarketCollateralData(
|
|
2820
|
-
query.utils,
|
|
2821
|
-
parsedMarketCollateralData
|
|
3017
|
+
});
|
|
3018
|
+
const collateralStatDynamicFieldObject = collateralStatDynamicFieldObjectResponse?.data;
|
|
3019
|
+
if (!(collateralStatDynamicFieldObject && collateralStatDynamicFieldObject.content && "fields" in collateralStatDynamicFieldObject.content))
|
|
3020
|
+
throw new Error(
|
|
3021
|
+
`Failed to fetch collateralStatDynamicFieldObject for ${collateralCoinName}: ${collateralStatDynamicFieldObjectResponse?.error?.code.toString()}`
|
|
2822
3022
|
);
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
3023
|
+
const collateralStat = collateralStatDynamicFieldObject.content.fields.value.fields;
|
|
3024
|
+
const parsedMarketCollateralData = parseOriginMarketCollateralData({
|
|
3025
|
+
type: riskModel.type.fields,
|
|
3026
|
+
collateralFactor: riskModel.collateral_factor.fields,
|
|
3027
|
+
liquidationFactor: riskModel.liquidation_factor.fields,
|
|
3028
|
+
liquidationDiscount: riskModel.liquidation_discount.fields,
|
|
3029
|
+
liquidationPanelty: riskModel.liquidation_penalty.fields,
|
|
3030
|
+
liquidationReserveFactor: riskModel.liquidation_revenue_factor.fields,
|
|
3031
|
+
maxCollateralAmount: riskModel.max_collateral_amount,
|
|
3032
|
+
totalCollateralAmount: collateralStat.amount
|
|
3033
|
+
});
|
|
3034
|
+
const calculatedMarketCollateralData = calculateMarketCollateralData(
|
|
3035
|
+
query.utils,
|
|
3036
|
+
parsedMarketCollateralData
|
|
3037
|
+
);
|
|
3038
|
+
return {
|
|
3039
|
+
coinName: collateralCoinName,
|
|
3040
|
+
symbol: query.utils.parseSymbol(collateralCoinName),
|
|
3041
|
+
coinType: query.utils.parseCoinType(collateralCoinName),
|
|
3042
|
+
marketCoinType: query.utils.parseMarketCoinType(collateralCoinName),
|
|
3043
|
+
coinWrappedType: query.utils.getCoinWrappedType(collateralCoinName),
|
|
3044
|
+
coinDecimal: query.utils.getCoinDecimal(collateralCoinName),
|
|
3045
|
+
coinPrice: coinPrice ?? 0,
|
|
3046
|
+
collateralFactor: parsedMarketCollateralData.collateralFactor,
|
|
3047
|
+
liquidationFactor: parsedMarketCollateralData.liquidationFactor,
|
|
3048
|
+
liquidationDiscount: parsedMarketCollateralData.liquidationDiscount,
|
|
3049
|
+
liquidationPanelty: parsedMarketCollateralData.liquidationPanelty,
|
|
3050
|
+
liquidationReserveFactor: parsedMarketCollateralData.liquidationReserveFactor,
|
|
3051
|
+
isIsolated: await isIsolatedAsset(query.utils, collateralCoinName),
|
|
3052
|
+
...calculatedMarketCollateralData
|
|
3053
|
+
};
|
|
2840
3054
|
};
|
|
2841
3055
|
var getObligations = async ({
|
|
2842
3056
|
address
|
|
@@ -3068,7 +3282,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
|
|
|
3068
3282
|
const coinName = query.utils.parseCoinName(marketCoinName);
|
|
3069
3283
|
marketPool = marketPool || await query.getMarketPool(coinName, indexer);
|
|
3070
3284
|
if (!marketPool) {
|
|
3071
|
-
throw new Error(
|
|
3285
|
+
throw new Error(`Failed to fetch marketPool for ${marketCoinName}`);
|
|
3072
3286
|
}
|
|
3073
3287
|
const poolId = query.address.get(`spool.pools.${marketCoinName}.id`);
|
|
3074
3288
|
const rewardPoolId = query.address.get(
|
|
@@ -3798,12 +4012,8 @@ var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
|
|
|
3798
4012
|
};
|
|
3799
4013
|
var getObligationAccount = async (query, obligationId, ownerAddress, indexer = false, market, coinPrices, coinAmounts) => {
|
|
3800
4014
|
market = market || await query.queryMarket(indexer);
|
|
3801
|
-
const
|
|
3802
|
-
.../* @__PURE__ */ new Set([
|
|
3803
|
-
...Object.values(market.collaterals).map(
|
|
3804
|
-
(collateral) => collateral.coinName
|
|
3805
|
-
)
|
|
3806
|
-
])
|
|
4015
|
+
const poolAssetCoinNames = [
|
|
4016
|
+
.../* @__PURE__ */ new Set([...Object.values(market.pools).map((pool) => pool.coinName)])
|
|
3807
4017
|
];
|
|
3808
4018
|
const obligationQuery = await query.queryObligation(obligationId);
|
|
3809
4019
|
const borrowIncentivePools = await query.getBorrowIncentivePools(
|
|
@@ -3811,8 +4021,9 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3811
4021
|
indexer
|
|
3812
4022
|
);
|
|
3813
4023
|
const borrowIncentiveAccounts = await query.getBorrowIncentiveAccounts(obligationId);
|
|
3814
|
-
coinPrices = coinPrices || await query.utils.getCoinPrices(
|
|
3815
|
-
coinAmounts = coinAmounts || await query.getCoinAmounts(
|
|
4024
|
+
coinPrices = coinPrices || await query.utils.getCoinPrices(poolAssetCoinNames);
|
|
4025
|
+
coinAmounts = coinAmounts || await query.getCoinAmounts(poolAssetCoinNames, ownerAddress);
|
|
4026
|
+
console.log(coinPrices);
|
|
3816
4027
|
const collaterals = {};
|
|
3817
4028
|
const debts = {};
|
|
3818
4029
|
const borrowIncentives = {};
|
|
@@ -3824,7 +4035,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3824
4035
|
let totalRewardedPools = 0;
|
|
3825
4036
|
let totalBorrowedValue = (0, import_bignumber4.default)(0);
|
|
3826
4037
|
let totalBorrowedValueWithWeight = (0, import_bignumber4.default)(0);
|
|
3827
|
-
for (const assetCoinName of
|
|
4038
|
+
for (const assetCoinName of poolAssetCoinNames) {
|
|
3828
4039
|
const collateral = obligationQuery?.collaterals.find((collateral2) => {
|
|
3829
4040
|
const collateralCoinName = query.utils.parseCoinNameFromType(
|
|
3830
4041
|
collateral2.type.name
|
|
@@ -4129,7 +4340,7 @@ var getTotalValueLocked = async (query, indexer = false) => {
|
|
|
4129
4340
|
var import_bignumber5 = __toESM(require("bignumber.js"));
|
|
4130
4341
|
var import_sui_kit3 = require("@scallop-io/sui-kit");
|
|
4131
4342
|
var import_bcs = require("@mysten/sui/bcs");
|
|
4132
|
-
var
|
|
4343
|
+
var import_zod3 = require("zod");
|
|
4133
4344
|
var import_assert = __toESM(require("assert"));
|
|
4134
4345
|
var getVescaKeys = async (utils, ownerAddress) => {
|
|
4135
4346
|
const owner = ownerAddress || utils.suiKit.currentAddress();
|
|
@@ -4178,10 +4389,10 @@ var getVeScas = async ({
|
|
|
4178
4389
|
}
|
|
4179
4390
|
return result;
|
|
4180
4391
|
};
|
|
4181
|
-
var SuiObjectRefZod =
|
|
4182
|
-
objectId:
|
|
4183
|
-
digest:
|
|
4184
|
-
version:
|
|
4392
|
+
var SuiObjectRefZod = import_zod3.z.object({
|
|
4393
|
+
objectId: import_zod3.z.string(),
|
|
4394
|
+
digest: import_zod3.z.string(),
|
|
4395
|
+
version: import_zod3.z.string()
|
|
4185
4396
|
});
|
|
4186
4397
|
var getVeSca = async (utils, veScaKey) => {
|
|
4187
4398
|
const tableId = utils.address.get(`vesca.tableId`);
|
|
@@ -4314,16 +4525,16 @@ var queryVeScaKeyIdFromReferralBindings = async (address, refereeAddress) => {
|
|
|
4314
4525
|
|
|
4315
4526
|
// src/queries/loyaltyProgramQuery.ts
|
|
4316
4527
|
var import_bignumber6 = __toESM(require("bignumber.js"));
|
|
4317
|
-
var
|
|
4318
|
-
var rewardPoolFieldsZod =
|
|
4319
|
-
balance:
|
|
4320
|
-
enable_claim:
|
|
4528
|
+
var import_zod4 = require("zod");
|
|
4529
|
+
var rewardPoolFieldsZod = import_zod4.z.object({
|
|
4530
|
+
balance: import_zod4.z.string(),
|
|
4531
|
+
enable_claim: import_zod4.z.boolean()
|
|
4321
4532
|
}).transform((value) => ({
|
|
4322
4533
|
totalPoolReward: (0, import_bignumber6.default)(value.balance).shiftedBy(-9).toNumber(),
|
|
4323
4534
|
isClaimEnabled: value.enable_claim
|
|
4324
4535
|
}));
|
|
4325
|
-
var userRewardFieldsZod =
|
|
4326
|
-
value:
|
|
4536
|
+
var userRewardFieldsZod = import_zod4.z.object({
|
|
4537
|
+
value: import_zod4.z.string()
|
|
4327
4538
|
}).transform((value) => (0, import_bignumber6.default)(value.value).shiftedBy(-9).toNumber());
|
|
4328
4539
|
var getLoyaltyProgramInformations = async (query, veScaKey) => {
|
|
4329
4540
|
const rewardPool = query.address.get("loyaltyProgram.rewardPool");
|
|
@@ -4363,12 +4574,6 @@ var getLoyaltyProgramInformations = async (query, veScaKey) => {
|
|
|
4363
4574
|
return result;
|
|
4364
4575
|
};
|
|
4365
4576
|
|
|
4366
|
-
// src/constants/pyth.ts
|
|
4367
|
-
var PYTH_ENDPOINTS = {
|
|
4368
|
-
testnet: ["https://hermes-beta.pyth.network"],
|
|
4369
|
-
mainnet: ["https://hermes.pyth.network", "https://scallop.rpc.p2p.world"]
|
|
4370
|
-
};
|
|
4371
|
-
|
|
4372
4577
|
// src/models/scallopUtils.ts
|
|
4373
4578
|
var ScallopUtils = class {
|
|
4374
4579
|
constructor(params, instance) {
|
|
@@ -4434,10 +4639,10 @@ var ScallopUtils = class {
|
|
|
4434
4639
|
* @param address - ScallopAddress instance.
|
|
4435
4640
|
*/
|
|
4436
4641
|
async init(force = false, address) {
|
|
4437
|
-
if (
|
|
4438
|
-
await this.address.read();
|
|
4439
|
-
} else {
|
|
4642
|
+
if (address && !this.address)
|
|
4440
4643
|
this.address = address;
|
|
4644
|
+
if (force || !this.address.getAddresses()) {
|
|
4645
|
+
await this.address.read();
|
|
4441
4646
|
}
|
|
4442
4647
|
}
|
|
4443
4648
|
/**
|
|
@@ -4737,30 +4942,38 @@ var ScallopUtils = class {
|
|
|
4737
4942
|
const priceId = this.address.get(
|
|
4738
4943
|
`core.coins.${coinName}.oracle.pyth.feed`
|
|
4739
4944
|
);
|
|
4740
|
-
|
|
4945
|
+
if (priceId) {
|
|
4946
|
+
acc[coinName] = priceId;
|
|
4947
|
+
}
|
|
4741
4948
|
return acc;
|
|
4742
4949
|
},
|
|
4743
4950
|
{}
|
|
4744
4951
|
);
|
|
4745
4952
|
await Promise.allSettled(
|
|
4746
|
-
Object.entries(priceIds).map(async ([coinName, priceId]) => {
|
|
4953
|
+
Object.entries(priceIds).filter(([_, priceId]) => !!priceId).map(async ([coinName, priceId]) => {
|
|
4747
4954
|
const pythConnection = new import_pyth_sui_js.SuiPriceServiceConnection(endpoint);
|
|
4748
4955
|
try {
|
|
4749
4956
|
const feed = await this.cache.queryClient.fetchQuery({
|
|
4750
|
-
queryKey: queryKeys.oracle.getPythLatestPriceFeed(
|
|
4957
|
+
queryKey: queryKeys.oracle.getPythLatestPriceFeed(
|
|
4958
|
+
priceId,
|
|
4959
|
+
endpoint
|
|
4960
|
+
),
|
|
4751
4961
|
queryFn: async () => {
|
|
4752
4962
|
return await pythConnection.getLatestPriceFeeds([priceId]) ?? [];
|
|
4753
4963
|
}
|
|
4754
4964
|
});
|
|
4755
4965
|
if (feed[0]) {
|
|
4756
|
-
const data = parseDataFromPythPriceFeed(
|
|
4966
|
+
const data = parseDataFromPythPriceFeed(
|
|
4967
|
+
feed[0],
|
|
4968
|
+
this.address
|
|
4969
|
+
);
|
|
4757
4970
|
this._priceMap.set(coinName, {
|
|
4758
4971
|
price: data.price,
|
|
4759
4972
|
publishTime: data.publishTime
|
|
4760
4973
|
});
|
|
4761
4974
|
coinPrices[coinName] = data.price;
|
|
4975
|
+
failedRequests.delete(coinName);
|
|
4762
4976
|
}
|
|
4763
|
-
failedRequests.delete(coinName);
|
|
4764
4977
|
} catch (e) {
|
|
4765
4978
|
console.warn(
|
|
4766
4979
|
`Failed to get price ${coinName} feeds with endpoint ${endpoint}: ${e}`
|
|
@@ -4838,6 +5051,26 @@ var ScallopUtils = class {
|
|
|
4838
5051
|
}
|
|
4839
5052
|
return findClosestUnlockRound(newUnlockAtInSecondTimestamp);
|
|
4840
5053
|
}
|
|
5054
|
+
/**
|
|
5055
|
+
* Get detailed contract address and price id information for supported pool in Scallop
|
|
5056
|
+
* @returns Supported pool informations
|
|
5057
|
+
*/
|
|
5058
|
+
getSupportedPoolAddresses() {
|
|
5059
|
+
return SUPPORT_POOLS.map((poolName) => {
|
|
5060
|
+
const sCoinName = this.parseSCoinName(poolName);
|
|
5061
|
+
return {
|
|
5062
|
+
name: this.parseSymbol(poolName),
|
|
5063
|
+
coingeckoId: COIN_GECKGO_IDS[poolName],
|
|
5064
|
+
decimal: coinDecimals[poolName],
|
|
5065
|
+
pythFeedId: PYTH_FEED_IDS[poolName],
|
|
5066
|
+
...POOL_ADDRESSES[poolName],
|
|
5067
|
+
sCoinAddress: sCoinIds[sCoinName],
|
|
5068
|
+
marketCoinAddress: this.parseMarketCoinType(poolName),
|
|
5069
|
+
coinAddress: this.parseCoinType(poolName),
|
|
5070
|
+
sCoinName: sCoinName ? this.parseSymbol(sCoinName) : void 0
|
|
5071
|
+
};
|
|
5072
|
+
});
|
|
5073
|
+
}
|
|
4841
5074
|
};
|
|
4842
5075
|
|
|
4843
5076
|
// src/models/scallopBuilder.ts
|
|
@@ -6715,88 +6948,6 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
|
|
|
6715
6948
|
|
|
6716
6949
|
// src/models/scallopQuery.ts
|
|
6717
6950
|
var import_utils23 = require("@mysten/sui/utils");
|
|
6718
|
-
|
|
6719
|
-
// src/queries/isolatedAsset.ts
|
|
6720
|
-
var import_zod4 = require("zod");
|
|
6721
|
-
var isolatedAssetZod = import_zod4.z.object({
|
|
6722
|
-
dataType: import_zod4.z.string(),
|
|
6723
|
-
type: import_zod4.z.string(),
|
|
6724
|
-
hasPublicTransfer: import_zod4.z.boolean(),
|
|
6725
|
-
fields: import_zod4.z.object({
|
|
6726
|
-
id: import_zod4.z.object({
|
|
6727
|
-
id: import_zod4.z.string()
|
|
6728
|
-
}),
|
|
6729
|
-
name: import_zod4.z.object({
|
|
6730
|
-
type: import_zod4.z.string()
|
|
6731
|
-
}),
|
|
6732
|
-
value: import_zod4.z.boolean()
|
|
6733
|
-
})
|
|
6734
|
-
});
|
|
6735
|
-
var ISOLATED_ASSET_KEY = "0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::IsolatedAssetKey";
|
|
6736
|
-
var getIsolatedAssets = async (address) => {
|
|
6737
|
-
try {
|
|
6738
|
-
const marketObject = address.get("core.market");
|
|
6739
|
-
const isolatedAssets = [];
|
|
6740
|
-
if (!marketObject)
|
|
6741
|
-
return isolatedAssets;
|
|
6742
|
-
let hasNextPage = false;
|
|
6743
|
-
let nextCursor = null;
|
|
6744
|
-
const isIsolatedDynamicField = (dynamicField) => {
|
|
6745
|
-
return dynamicField.name.type === ISOLATED_ASSET_KEY;
|
|
6746
|
-
};
|
|
6747
|
-
do {
|
|
6748
|
-
const response = await address.cache.queryGetDynamicFields({
|
|
6749
|
-
parentId: marketObject,
|
|
6750
|
-
cursor: nextCursor,
|
|
6751
|
-
limit: 10
|
|
6752
|
-
});
|
|
6753
|
-
if (!response)
|
|
6754
|
-
break;
|
|
6755
|
-
const isolatedAssetCoinTypes = response.data.filter(isIsolatedDynamicField).map(({ name }) => `0x${name.value.type.name}`);
|
|
6756
|
-
isolatedAssets.push(...isolatedAssetCoinTypes);
|
|
6757
|
-
if (response && response.hasNextPage && response.nextCursor) {
|
|
6758
|
-
hasNextPage = true;
|
|
6759
|
-
nextCursor = response.nextCursor;
|
|
6760
|
-
} else {
|
|
6761
|
-
hasNextPage = false;
|
|
6762
|
-
}
|
|
6763
|
-
} while (hasNextPage);
|
|
6764
|
-
return isolatedAssets;
|
|
6765
|
-
} catch (e) {
|
|
6766
|
-
console.error(e);
|
|
6767
|
-
return [];
|
|
6768
|
-
}
|
|
6769
|
-
};
|
|
6770
|
-
var isIsolatedAsset = async (utils, coinName) => {
|
|
6771
|
-
try {
|
|
6772
|
-
const marketObject = utils.address.get("core.market");
|
|
6773
|
-
const cachedData = utils.address.cache.queryClient.getQueryData([
|
|
6774
|
-
"getDynamicFields",
|
|
6775
|
-
marketObject
|
|
6776
|
-
]);
|
|
6777
|
-
if (cachedData) {
|
|
6778
|
-
const coinType2 = utils.parseCoinType(coinName);
|
|
6779
|
-
return cachedData.includes(coinType2);
|
|
6780
|
-
}
|
|
6781
|
-
const coinType = utils.parseCoinType(coinName).slice(2);
|
|
6782
|
-
const object = await utils.cache.queryGetDynamicFieldObject({
|
|
6783
|
-
parentId: marketObject,
|
|
6784
|
-
name: {
|
|
6785
|
-
type: ISOLATED_ASSET_KEY,
|
|
6786
|
-
value: coinType
|
|
6787
|
-
}
|
|
6788
|
-
});
|
|
6789
|
-
const parsedData = isolatedAssetZod.safeParse(object?.data?.content);
|
|
6790
|
-
if (!parsedData.success)
|
|
6791
|
-
return false;
|
|
6792
|
-
return parsedData.data.fields.value;
|
|
6793
|
-
} catch (e) {
|
|
6794
|
-
console.error(e);
|
|
6795
|
-
return false;
|
|
6796
|
-
}
|
|
6797
|
-
};
|
|
6798
|
-
|
|
6799
|
-
// src/models/scallopQuery.ts
|
|
6800
6951
|
var ScallopQuery = class {
|
|
6801
6952
|
constructor(params, instance) {
|
|
6802
6953
|
this.params = params;
|
|
@@ -6866,11 +7017,12 @@ var ScallopQuery = class {
|
|
|
6866
7017
|
* @param address - ScallopAddress instance.
|
|
6867
7018
|
*/
|
|
6868
7019
|
async init(force = false, address) {
|
|
6869
|
-
if (
|
|
6870
|
-
await this.address.read();
|
|
6871
|
-
} else {
|
|
7020
|
+
if (address && !this.address) {
|
|
6872
7021
|
this.address = address;
|
|
6873
7022
|
}
|
|
7023
|
+
if (force || !this.address.getAddresses()) {
|
|
7024
|
+
await this.address.read();
|
|
7025
|
+
}
|
|
6874
7026
|
await this.utils.init(force, this.address);
|
|
6875
7027
|
}
|
|
6876
7028
|
/* ==================== Core Query Methods ==================== */
|
|
@@ -7386,10 +7538,10 @@ var ScallopBuilder = class {
|
|
|
7386
7538
|
* @param address - ScallopAddress instance.
|
|
7387
7539
|
*/
|
|
7388
7540
|
async init(force = false, address) {
|
|
7389
|
-
if (
|
|
7390
|
-
await this.address.read();
|
|
7391
|
-
} else {
|
|
7541
|
+
if (address && !this.address)
|
|
7392
7542
|
this.address = address;
|
|
7543
|
+
if (force || !this.address.getAddresses()) {
|
|
7544
|
+
await this.address.read();
|
|
7393
7545
|
}
|
|
7394
7546
|
await this.query.init(force, this.address);
|
|
7395
7547
|
await this.utils.init(force, this.address);
|
|
@@ -8275,6 +8427,10 @@ var Scallop = class {
|
|
|
8275
8427
|
ADDRESSES_ID,
|
|
8276
8428
|
API_BASE_URL,
|
|
8277
8429
|
BORROW_FEE_PROTOCOL_ID,
|
|
8430
|
+
COIN_GECKGO_IDS,
|
|
8431
|
+
DEFAULT_CACHE_OPTIONS,
|
|
8432
|
+
DEFAULT_INTERVAL_IN_MS,
|
|
8433
|
+
DEFAULT_TOKENS_PER_INTERVAL,
|
|
8278
8434
|
FlashLoanFeeObjectMap,
|
|
8279
8435
|
IS_VE_SCA_TEST,
|
|
8280
8436
|
MAX_LOCK_DURATION,
|
|
@@ -8282,7 +8438,10 @@ var Scallop = class {
|
|
|
8282
8438
|
MIN_INITIAL_LOCK_AMOUNT,
|
|
8283
8439
|
MIN_TOP_UP_AMOUNT,
|
|
8284
8440
|
OLD_BORROW_INCENTIVE_PROTOCOL_ID,
|
|
8441
|
+
POOL_ADDRESSES,
|
|
8285
8442
|
PROTOCOL_OBJECT_ID,
|
|
8443
|
+
PYTH_ENDPOINTS,
|
|
8444
|
+
PYTH_FEED_IDS,
|
|
8286
8445
|
SCA_COIN_TYPE,
|
|
8287
8446
|
SDK_API_BASE_URL,
|
|
8288
8447
|
SUPPORT_BORROW_INCENTIVE_POOLS,
|
|
@@ -8304,6 +8463,7 @@ var Scallop = class {
|
|
|
8304
8463
|
ScallopIndexer,
|
|
8305
8464
|
ScallopQuery,
|
|
8306
8465
|
ScallopUtils,
|
|
8466
|
+
TEST_ADDRESSES,
|
|
8307
8467
|
UNLOCK_ROUND_DURATION,
|
|
8308
8468
|
USE_TEST_ADDRESS,
|
|
8309
8469
|
assetCoins,
|