@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.mjs
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
// src/constants/cache.ts
|
|
2
|
+
var DEFAULT_CACHE_OPTIONS = {
|
|
3
|
+
defaultOptions: {
|
|
4
|
+
queries: {
|
|
5
|
+
staleTime: 5e3,
|
|
6
|
+
gcTime: 5e3
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
// src/constants/coinGecko.ts
|
|
12
|
+
var COIN_GECKGO_IDS = {
|
|
13
|
+
usdc: "usdc-coin",
|
|
14
|
+
sbeth: "ethereum",
|
|
15
|
+
weth: "ethereum",
|
|
16
|
+
wbtc: "bitcoin",
|
|
17
|
+
wusdc: "usdc-coin",
|
|
18
|
+
wusdt: "tether",
|
|
19
|
+
sui: "sui",
|
|
20
|
+
wapt: "aptos",
|
|
21
|
+
wsol: "solana",
|
|
22
|
+
cetus: "cetus-protocol",
|
|
23
|
+
afsui: "sui",
|
|
24
|
+
hasui: "sui",
|
|
25
|
+
vsui: "sui",
|
|
26
|
+
sca: "scallop-2"
|
|
27
|
+
};
|
|
28
|
+
|
|
1
29
|
// src/constants/common.ts
|
|
2
30
|
var API_BASE_URL = "https://sui.apis.scallop.io";
|
|
3
31
|
var SDK_API_BASE_URL = "https://sdk.api.scallop.io";
|
|
@@ -254,11 +282,20 @@ var voloCoinIds = {
|
|
|
254
282
|
var sCoinIds = {
|
|
255
283
|
susdc: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
|
|
256
284
|
ssbeth: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
|
|
257
|
-
|
|
285
|
+
// TODO: Change this to the correct value on production release
|
|
286
|
+
ssui: "0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI",
|
|
287
|
+
// ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
|
|
258
288
|
scetus: "0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS",
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
289
|
+
// TODO: Change this to the correct value on production release
|
|
290
|
+
ssca: "0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA",
|
|
291
|
+
// '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
|
|
292
|
+
// TODO: Change this to the correct value on production release
|
|
293
|
+
swusdc: "0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
|
|
294
|
+
// '0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
|
|
295
|
+
swusdt: (
|
|
296
|
+
// '0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
|
|
297
|
+
"0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT"
|
|
298
|
+
),
|
|
262
299
|
sweth: "0x67540ceb850d418679e69f1fb6b2093d6df78a2a699ffc733f7646096d552e9b::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
|
|
263
300
|
safsui: "0x00671b1fa2a124f5be8bdae8b91ee711462c5d9e31bda232e70fd9607b523c88::scallop_af_sui::SCALLOP_AF_SUI",
|
|
264
301
|
shasui: "0x9a2376943f7d22f88087c259c5889925f332ca4347e669dc37d54c2bf651af3c::scallop_ha_sui::SCALLOP_HA_SUI",
|
|
@@ -283,6 +320,88 @@ var FlashLoanFeeObjectMap = {
|
|
|
283
320
|
wsol: "0xe84bdb35b790fc7bdd1645122ac6ac0fc904531d6772c9e25904fece322c5f34"
|
|
284
321
|
};
|
|
285
322
|
|
|
323
|
+
// src/constants/poolAddress.ts
|
|
324
|
+
var POOL_ADDRESSES = {
|
|
325
|
+
usdc: {
|
|
326
|
+
lendingPoolAddress: "0xd3be98bf540f7603eeb550c0c0a19dbfc78822f25158b5fa84ebd9609def415f",
|
|
327
|
+
collateralPoolAddress: "0x8f0d529ba179c5b3d508213003eab813aaae31f78226099639b9a69d1aec17af"
|
|
328
|
+
},
|
|
329
|
+
sbeth: {
|
|
330
|
+
lendingPoolAddress: "0x5f08c4f71d56dd3342c452cc70ffc47f2f4180146d821941b0b9c04761bb42e7",
|
|
331
|
+
collateralPoolAddress: "0xce0549a1cbe952e734f56646988e6b02bbae14667889a60e24d0d03540a6119f"
|
|
332
|
+
},
|
|
333
|
+
weth: {
|
|
334
|
+
lendingPoolAddress: "0xc8fcdff48efc265740ae0b74aae3faccae9ec00034039a113f3339798035108c",
|
|
335
|
+
collateralPoolAddress: "0xad7ced91ed6e7f2b81805561eee27fa6f3e72fdae561077334c7248583db4dbf"
|
|
336
|
+
},
|
|
337
|
+
wbtc: {
|
|
338
|
+
lendingPoolAddress: "0x65cc08a5aca0a0b8d72e1993ded8d145f06dd102fd0d8f285b92934faed564ab",
|
|
339
|
+
collateralPoolAddress: "0x1aa4e5cf743cd797b4eb8bf1e614f80ae2cf556ced426cddaaf190ffcd0e59c3"
|
|
340
|
+
},
|
|
341
|
+
wusdc: {
|
|
342
|
+
lendingPoolAddress: "0x9c9077abf7a29eebce41e33addbcd6f5246a5221dd733e56ea0f00ae1b25c9e8",
|
|
343
|
+
collateralPoolAddress: "0x75aacfb7dcbf92ee0111fc1bf975b12569e4ba632e81ed7ae5ac090d40cd3acb"
|
|
344
|
+
},
|
|
345
|
+
wusdt: {
|
|
346
|
+
lendingPoolAddress: "0xfbc056f126dd35adc1f8fe985e2cedc8010e687e8e851e1c5b99fdf63cd1c879",
|
|
347
|
+
collateralPoolAddress: "0x2260cb5b24929dd20a1742f37a61ff3ce4fde5cdb023e2d3ce2e0ce2d90719e3"
|
|
348
|
+
},
|
|
349
|
+
sui: {
|
|
350
|
+
lendingPoolAddress: "0x9c9077abf7a29eebce41e33addbcd6f5246a5221dd733e56ea0f00ae1b25c9e8",
|
|
351
|
+
collateralPoolAddress: "0x75aacfb7dcbf92ee0111fc1bf975b12569e4ba632e81ed7ae5ac090d40cd3acb"
|
|
352
|
+
},
|
|
353
|
+
wapt: {
|
|
354
|
+
lendingPoolAddress: "0xca8c14a24e0c32b198eaf479a3317461e3cc339097ce88eaf296a15df8dcfdf5",
|
|
355
|
+
collateralPoolAddress: "0xde33f9ac5bb0ed34598da4e64b4983832716ced65f172fbf267bcfe859c4ad9c"
|
|
356
|
+
},
|
|
357
|
+
wsol: {
|
|
358
|
+
lendingPoolAddress: "0x985682c42984cdfb03f9ff7d8923344c2fe096b1ae4b82ea17721af19d22a21f",
|
|
359
|
+
collateralPoolAddress: "0xdc1cc2c371a043ae8e3c3fe2d013c35f1346960b7dbb4c072982c5b794ed144f"
|
|
360
|
+
},
|
|
361
|
+
cetus: {
|
|
362
|
+
lendingPoolAddress: "0xc09858f60e74a1b671635bec4e8a2c84a0ff313eb87f525fba3258e88c6b6282",
|
|
363
|
+
collateralPoolAddress: "0xe363967e29b7b9c1245d6d46d63e719de8f90b37e3358c545b55d945ea0b676a"
|
|
364
|
+
},
|
|
365
|
+
afsui: {
|
|
366
|
+
lendingPoolAddress: "0x9b942a24ce390b7f5016d34a0217057bf9487b92aa6d7cc9894271dbbe62471a",
|
|
367
|
+
collateralPoolAddress: "0xe5e56f5c0e3072760b21f9d49a5cc793f37d736c412a9065c16e1265c74e6341"
|
|
368
|
+
},
|
|
369
|
+
hasui: {
|
|
370
|
+
lendingPoolAddress: "0x7ebc607f6bdeb659fb6506cb91c5cc1d47bb365cfd5d2e637ea765346ec84ed4",
|
|
371
|
+
collateralPoolAddress: "0xad9ed40d6486e4c26cec7370dffce8dc4821eb79178250b5938a34ccafd61e6d"
|
|
372
|
+
},
|
|
373
|
+
vsui: {
|
|
374
|
+
lendingPoolAddress: "0xda9257c0731d8822e8a438ebced13415850d705b779c79958dcf2aeb21fcb43d",
|
|
375
|
+
collateralPoolAddress: "0x4435e8b8ec2a04094d863aa52deb6ab6f8f47ed8778f4d9f1b27afc4a6e85f1e"
|
|
376
|
+
},
|
|
377
|
+
sca: {
|
|
378
|
+
lendingPoolAddress: "0x6fc7d4211fc7018b6c75e7b908b88f2e0536443239804a3d32af547637bd28d7",
|
|
379
|
+
collateralPoolAddress: "0xff677a5d9e9dc8f08f0a8681ebfc7481d1c7d57bc441f2881974adcdd7b13c31"
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
// src/constants/pyth.ts
|
|
384
|
+
var PYTH_ENDPOINTS = {
|
|
385
|
+
testnet: ["https://hermes-beta.pyth.network"],
|
|
386
|
+
mainnet: ["https://hermes.pyth.network", "https://scallop.rpc.p2p.world"]
|
|
387
|
+
};
|
|
388
|
+
var PYTH_FEED_IDS = {
|
|
389
|
+
usdc: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
390
|
+
sbeth: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
391
|
+
weth: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
392
|
+
wbtc: "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43",
|
|
393
|
+
wusdc: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
394
|
+
wusdt: "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
|
|
395
|
+
sui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
396
|
+
wapt: "03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5",
|
|
397
|
+
wsol: "ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
|
|
398
|
+
cetus: "e5b274b2611143df055d6e7cd8d93fe1961716bcd4dca1cad87a83bc1e78c1ef",
|
|
399
|
+
afsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
400
|
+
hasui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
401
|
+
vsui: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
402
|
+
sca: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc"
|
|
403
|
+
};
|
|
404
|
+
|
|
286
405
|
// src/constants/queryKeys.ts
|
|
287
406
|
var queryKeys = {
|
|
288
407
|
api: {
|
|
@@ -359,234 +478,652 @@ var queryKeys = {
|
|
|
359
478
|
]
|
|
360
479
|
},
|
|
361
480
|
oracle: {
|
|
362
|
-
getPythLatestPriceFeed: (pythPriceId) => [
|
|
481
|
+
getPythLatestPriceFeed: (pythPriceId, endpoint) => [
|
|
363
482
|
"oracle",
|
|
364
483
|
"getPythPriceId",
|
|
365
|
-
{ pythPriceId }
|
|
484
|
+
{ pythPriceId, endpoint }
|
|
366
485
|
]
|
|
367
486
|
}
|
|
368
487
|
};
|
|
369
488
|
|
|
370
|
-
// src/constants/
|
|
371
|
-
var
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
//
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
//
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
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
|
-
|
|
489
|
+
// src/constants/testAddress.ts
|
|
490
|
+
var TEST_ADDRESSES = {
|
|
491
|
+
core: {
|
|
492
|
+
// version:
|
|
493
|
+
// '0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7',
|
|
494
|
+
version: "0xd318de9b0f6873879a82cbfcc2daa1d1591a8b54e7cea9f4b567da63c692a52b",
|
|
495
|
+
versionCap: "0x590a4011cb649b3878f3ea14b3a78674642a9548d79b7e091ef679574b158a07",
|
|
496
|
+
// object:
|
|
497
|
+
// '0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf',
|
|
498
|
+
object: "0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d",
|
|
499
|
+
// market:
|
|
500
|
+
// '0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9',
|
|
501
|
+
market: "0x9d6434e97f3f98fd9b0c0e1dca22632073985abcd22541feae7ee1e34cbe3af2",
|
|
502
|
+
adminCap: "0x09689d018e71c337d9db6d67cbca06b74ed92196103624028ccc3ecea411777c",
|
|
503
|
+
coinDecimalsRegistry: "0x200abe9bf19751cc566ae35aa58e2b7e4ff688fc1130f8d8909ea09bc137d668",
|
|
504
|
+
// obligationAccessStore:
|
|
505
|
+
// '0x733e30b7c94d619d78cb8f5bc4bfbb759ced9a531239028caabb2474e5be59c9',
|
|
506
|
+
obligationAccessStore: "0x46e9b44a77ee9c9d33cc2689ecdfbb8f681935cbc6bdf6ac3df048e396c36c82",
|
|
507
|
+
coins: {
|
|
508
|
+
usdc: {
|
|
509
|
+
id: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7",
|
|
510
|
+
metaData: "0x69b7a7c3c200439c1b5f3b19d7d495d5966d5f08de66c69276152f8db3992ec6",
|
|
511
|
+
treasury: "",
|
|
512
|
+
oracle: {
|
|
513
|
+
supra: "",
|
|
514
|
+
switchboard: "",
|
|
515
|
+
pyth: {
|
|
516
|
+
feed: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
517
|
+
feedObject: "0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab"
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
},
|
|
521
|
+
cetus: {
|
|
522
|
+
id: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b",
|
|
523
|
+
metaData: "0x4c0dce55eff2db5419bbd2d239d1aa22b4a400c01bbb648b058a9883989025da",
|
|
524
|
+
treasury: "",
|
|
525
|
+
oracle: {
|
|
526
|
+
supra: "",
|
|
527
|
+
switchboard: "",
|
|
528
|
+
pyth: {
|
|
529
|
+
feed: "e5b274b2611143df055d6e7cd8d93fe1961716bcd4dca1cad87a83bc1e78c1ef",
|
|
530
|
+
feedObject: "0x24c0247fb22457a719efac7f670cdc79be321b521460bd6bd2ccfa9f80713b14"
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
wapt: {
|
|
535
|
+
id: "0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37",
|
|
536
|
+
metaData: "0xc969c5251f372c0f34c32759f1d315cf1ea0ee5e4454b52aea08778eacfdd0a8",
|
|
537
|
+
treasury: "",
|
|
538
|
+
oracle: {
|
|
539
|
+
supra: "",
|
|
540
|
+
switchboard: "",
|
|
541
|
+
pyth: {
|
|
542
|
+
feed: "03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5",
|
|
543
|
+
feedObject: "0x7c5b7837c44a69b469325463ac0673ac1aa8435ff44ddb4191c9ae380463647f"
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
},
|
|
547
|
+
wsol: {
|
|
548
|
+
id: "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8",
|
|
549
|
+
metaData: "0x4d2c39082b4477e3e79dc4562d939147ab90c42fc5f3e4acf03b94383cd69b6e",
|
|
550
|
+
treasury: "",
|
|
551
|
+
oracle: {
|
|
552
|
+
supra: "",
|
|
553
|
+
switchboard: "",
|
|
554
|
+
pyth: {
|
|
555
|
+
feed: "ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
|
|
556
|
+
feedObject: "0x9d0d275efbd37d8a8855f6f2c761fa5983293dd8ce202ee5196626de8fcd4469"
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
},
|
|
560
|
+
wbtc: {
|
|
561
|
+
id: "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881",
|
|
562
|
+
metaData: "0x5d3c6e60eeff8a05b693b481539e7847dfe33013e7070cdcb387f5c0cac05dfd",
|
|
563
|
+
treasury: "",
|
|
564
|
+
oracle: {
|
|
565
|
+
supra: "",
|
|
566
|
+
switchboard: "",
|
|
567
|
+
pyth: {
|
|
568
|
+
feed: "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43",
|
|
569
|
+
feedObject: "0x9a62b4863bdeaabdc9500fce769cf7e72d5585eeb28a6d26e4cafadc13f76ab2"
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
},
|
|
573
|
+
weth: {
|
|
574
|
+
id: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
|
|
575
|
+
metaData: "0x8900e4ceede3363bef086d6b50ca89d816d0e90bf6bc46efefe1f8455e08f50f",
|
|
576
|
+
treasury: "",
|
|
577
|
+
oracle: {
|
|
578
|
+
supra: "",
|
|
579
|
+
switchboard: "",
|
|
580
|
+
pyth: {
|
|
581
|
+
feed: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
582
|
+
feedObject: "0x9193fd47f9a0ab99b6e365a464c8a9ae30e6150fc37ed2a89c1586631f6fc4ab"
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
},
|
|
586
|
+
wusdc: {
|
|
587
|
+
id: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf",
|
|
588
|
+
metaData: "0x4fbf84f3029bd0c0b77164b587963be957f853eccf834a67bb9ecba6ec80f189",
|
|
589
|
+
treasury: "",
|
|
590
|
+
oracle: {
|
|
591
|
+
supra: "",
|
|
592
|
+
switchboard: "",
|
|
593
|
+
pyth: {
|
|
594
|
+
feed: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
595
|
+
feedObject: "0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab"
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
},
|
|
599
|
+
wusdt: {
|
|
600
|
+
id: "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c",
|
|
601
|
+
metaData: "0xfb0e3eb97dd158a5ae979dddfa24348063843c5b20eb8381dd5fa7c93699e45c",
|
|
602
|
+
treasury: "",
|
|
603
|
+
oracle: {
|
|
604
|
+
supra: "",
|
|
605
|
+
switchboard: "",
|
|
606
|
+
pyth: {
|
|
607
|
+
feed: "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
|
|
608
|
+
feedObject: "0x985e3db9f93f76ee8bace7c3dd5cc676a096accd5d9e09e9ae0fb6e492b14572"
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
},
|
|
612
|
+
sui: {
|
|
613
|
+
id: "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
614
|
+
metaData: "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3",
|
|
615
|
+
treasury: "",
|
|
616
|
+
oracle: {
|
|
617
|
+
supra: "",
|
|
618
|
+
switchboard: "0xbca474133638352ba83ccf7b5c931d50f764b09550e16612c9f70f1e21f3f594",
|
|
619
|
+
pyth: {
|
|
620
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
621
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
},
|
|
625
|
+
afsui: {
|
|
626
|
+
id: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
|
|
627
|
+
metaData: "0x2f9217f533e51334873a39b8026a4aa6919497b47f49d0986a4f1aec66f8a34d",
|
|
628
|
+
treasury: "",
|
|
629
|
+
oracle: {
|
|
630
|
+
supra: "",
|
|
631
|
+
switchboard: "",
|
|
632
|
+
pyth: {
|
|
633
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
634
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
},
|
|
638
|
+
hasui: {
|
|
639
|
+
id: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
|
|
640
|
+
metaData: "0x2c5f33af93f6511df699aaaa5822d823aac6ed99d4a0de2a4a50b3afa0172e24",
|
|
641
|
+
treasury: "",
|
|
642
|
+
oracle: {
|
|
643
|
+
supra: "",
|
|
644
|
+
switchboard: "",
|
|
645
|
+
pyth: {
|
|
646
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
647
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
},
|
|
651
|
+
vsui: {
|
|
652
|
+
id: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
|
|
653
|
+
metaData: "0xabd84a23467b33854ab25cf862006fd97479f8f6f53e50fe732c43a274d939bd",
|
|
654
|
+
treasury: "",
|
|
655
|
+
oracle: {
|
|
656
|
+
supra: "",
|
|
657
|
+
switchboard: "",
|
|
658
|
+
pyth: {
|
|
659
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
660
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
},
|
|
664
|
+
sca: {
|
|
665
|
+
id: "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6",
|
|
666
|
+
metaData: "0x5d26a1e9a55c88147ac870bfa31b729d7f49f8804b8b3adfdf3582d301cca844",
|
|
667
|
+
treasury: "",
|
|
668
|
+
oracle: {
|
|
669
|
+
supra: "",
|
|
670
|
+
switchboard: "",
|
|
671
|
+
pyth: {
|
|
672
|
+
feed: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc",
|
|
673
|
+
feedObject: "0xf6de1d3279a269a597d813cbaca59aa906543ab9a8c64e84a4722f1a20863985"
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
},
|
|
677
|
+
sbeth: {
|
|
678
|
+
id: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29",
|
|
679
|
+
metaData: "0x89b04ba87f8832d4d76e17a1c9dce72eb3e64d372cf02012b8d2de5384faeef0",
|
|
680
|
+
treasury: "",
|
|
681
|
+
oracle: {
|
|
682
|
+
supra: "",
|
|
683
|
+
switchboard: "",
|
|
684
|
+
pyth: {
|
|
685
|
+
feed: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
686
|
+
feedObject: "0x9193fd47f9a0ab99b6e365a464c8a9ae30e6150fc37ed2a89c1586631f6fc4ab"
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
},
|
|
691
|
+
oracles: {
|
|
692
|
+
xOracle: "0x93d5bf0936b71eb27255941e532fac33b5a5c7759e377b4923af0a1359ad494f",
|
|
693
|
+
xOracleCap: "0x1edeae568fde99e090dbdec4bcdbd33a15f53a1ce1f87aeef1a560dedf4b4a90",
|
|
694
|
+
supra: { registry: "", registryCap: "", holder: "" },
|
|
695
|
+
switchboard: { registry: "", registryCap: "" },
|
|
696
|
+
pyth: {
|
|
697
|
+
registry: "0xedc293f9413a5a7a5d53bdba1fd889d0a4030894469228f0acdae4aa3c55a213",
|
|
698
|
+
registryCap: "0xbcb07141eb1f7e01fbda4130ecf5f5adaeabb77f5d9c32158b7532bcd2197acd",
|
|
699
|
+
state: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
|
|
700
|
+
wormhole: "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a",
|
|
701
|
+
wormholeState: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c"
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
packages: {
|
|
705
|
+
coinDecimalsRegistry: {
|
|
706
|
+
id: "0xca5a5a62f01c79a104bf4d31669e29daa387f325c241de4edbe30986a9bc8b0d",
|
|
707
|
+
upgradeCap: "0x34e76a945d29f195bc53ca704fa70877d1cf3a5d7bbfdda1b13e633fff13c0f6"
|
|
708
|
+
},
|
|
709
|
+
math: {
|
|
710
|
+
id: "0xad013d5fde39e15eabda32b3dbdafd67dac32b798ce63237c27a8f73339b9b6f",
|
|
711
|
+
upgradeCap: "0x3a329598231de02e6135c62284b66005b41cad1d9ab7ca2dc79c08293aba2ec6"
|
|
712
|
+
},
|
|
713
|
+
whitelist: {
|
|
714
|
+
id: "0x1318fdc90319ec9c24df1456d960a447521b0a658316155895014a6e39b5482f",
|
|
715
|
+
upgradeCap: "0xf5a22aea23db664f7b69855b6a546747f17c1ec4230319cfc17225e462b05761"
|
|
716
|
+
},
|
|
717
|
+
x: {
|
|
718
|
+
id: "0x779b5c547976899f5474f3a5bc0db36ddf4697ad7e5a901db0415c2281d28162",
|
|
719
|
+
upgradeCap: "0x3f203f6fff6a69d151e4f1cd931f22b68c489ef2759765662fc7baf673943c9e"
|
|
720
|
+
},
|
|
721
|
+
protocol: {
|
|
722
|
+
id: "0x6c23585e940a989588432509107e98bae06dbca4e333f26d0635d401b3c7c76d",
|
|
723
|
+
upgradeCap: "0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a"
|
|
724
|
+
},
|
|
725
|
+
// protocol: {
|
|
726
|
+
// id: '0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e',
|
|
727
|
+
// upgradeCap:
|
|
728
|
+
// '0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a',
|
|
729
|
+
// },
|
|
730
|
+
protocolWhitelist: {
|
|
731
|
+
id: "0x4c262d9343dac53ecb28f482a2a3f62c73d0ebac5b5f03d57383d56ff219acdf",
|
|
732
|
+
upgradeCap: "0x4a5e88a75039b00988f633f811f58117f31b8627a46bf822aa114d9010049449"
|
|
733
|
+
},
|
|
734
|
+
// query: {
|
|
735
|
+
// id: '0xb8d603a39114a5efef3dd0bf84df0bed1be1fbd39b78b7dd6e8a61ccc5e6006f',
|
|
736
|
+
// upgradeCap:
|
|
737
|
+
// '0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f',
|
|
738
|
+
// },
|
|
739
|
+
query: {
|
|
740
|
+
id: "0x89706958f43fb170de134579e3fbc53972b946ee78bd2442d8e1adc36074fbdc",
|
|
741
|
+
upgradeCap: "0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f"
|
|
742
|
+
},
|
|
743
|
+
supra: { id: "", upgradeCap: "" },
|
|
744
|
+
pyth: {
|
|
745
|
+
id: "0x910f30cbc7f601f75a5141a01265cd47c62d468707c5e1aecb32a18f448cb25a",
|
|
746
|
+
upgradeCap: "0xdf0ffbae1ea5bb25fbca5efba433dcf00c7cced65679af2f04728901275c6157"
|
|
747
|
+
},
|
|
748
|
+
switchboard: { id: "", upgradeCap: "" },
|
|
749
|
+
xOracle: {
|
|
750
|
+
id: "0x1478a432123e4b3d61878b629f2c692969fdb375644f1251cd278a4b1e7d7cd6",
|
|
751
|
+
upgradeCap: "0x0f928a6b2e26b73330fecaf9b44acfc9800a4a9794d6415c2a3153bc70e3c1f0"
|
|
752
|
+
},
|
|
753
|
+
testCoin: { id: "", upgradeCap: "" }
|
|
754
|
+
}
|
|
755
|
+
},
|
|
756
|
+
spool: {
|
|
757
|
+
// id: '0x7c4fdabe81c31b19a45d1e572a52a539997a90903fbb5bfab71480abe0fa62c3',
|
|
758
|
+
id: "0x1742655fe5872dfa6456673f9e38612a4965e6979e6cd7696a7f1225f28bae21",
|
|
759
|
+
adminCap: "0xdd8a047cbbf802bfcde5288b8ef1910965d789cc614da11d39af05fca0bd020a",
|
|
760
|
+
// object:
|
|
761
|
+
// '0xe87f1b2d498106a2c61421cec75b7b5c5e348512b0dc263949a0e7a3c256571a',
|
|
762
|
+
object: "0x1742655fe5872dfa6456673f9e38612a4965e6979e6cd7696a7f1225f28bae21",
|
|
763
|
+
pools: {
|
|
764
|
+
sweth: {
|
|
765
|
+
id: "0xeec40beccb07c575bebd842eeaabb835f77cd3dab73add433477e57f583a6787",
|
|
766
|
+
rewardPoolId: "0x957de68a18d87817de8309b30c1ec269a4d87ae513abbeed86b5619cb9ce1077"
|
|
767
|
+
},
|
|
768
|
+
ssui: {
|
|
769
|
+
// id: '0x4f0ba970d3c11db05c8f40c64a15b6a33322db3702d634ced6536960ab6f3ee4',
|
|
770
|
+
id: "0xb9617f83c06ebdeac0a8834782b1015e1cc7ea23739e30c132c4bfb95c37a579",
|
|
771
|
+
rewardPoolId: (
|
|
772
|
+
// '0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9',
|
|
773
|
+
"0xc3206071a8d43212efb6e3b5504f2321f8df97ab122b466c0bc7cfdf398dc13a"
|
|
774
|
+
)
|
|
775
|
+
},
|
|
776
|
+
susdc: {
|
|
777
|
+
id: "0x0b5f5f413bd3799e4052c37311966c77f3a4545eb125d2e93e67a68478021918",
|
|
778
|
+
rewardPoolId: "0x85ed6ed72ea97c35dbf0cdc7ed6fbc48d8ec15de9b17c74bf4512df8a6d7f166"
|
|
779
|
+
},
|
|
780
|
+
swusdc: {
|
|
781
|
+
// id: '0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0',
|
|
782
|
+
id: "0xf1b383b9cf2e9f515fc69567df1053098f273849d09cd84b0278a773429bd2b2",
|
|
783
|
+
rewardPoolId: (
|
|
784
|
+
// '0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8',
|
|
785
|
+
"0xc71c53ee6505d928ba15bea4fe4f45d98c9c31eced94b72d00a7827d4b7ba3ff"
|
|
786
|
+
)
|
|
787
|
+
},
|
|
788
|
+
swusdt: {
|
|
789
|
+
// id: '0xcb328f7ffa7f9342ed85af3fdb2f22919e1a06dfb2f713c04c73543870d7548f',
|
|
790
|
+
id: "0xb5567dfa5c7fc17a249e959732664c50713dd8c23db1a11376b27df800c17418",
|
|
791
|
+
rewardPoolId: (
|
|
792
|
+
// '0x2c9f934d67a5baa586ceec2cc24163a2f049a6af3d5ba36b84d8ac40f25c4080',
|
|
793
|
+
"0x60768b0687ff0235e376a039709a683e4c436098785e473b67b32dbab47b69ab"
|
|
794
|
+
)
|
|
795
|
+
},
|
|
796
|
+
scetus: {
|
|
797
|
+
id: "0xac1bb13bf4472a637c18c2415fb0e3c1227ea2bcf35242e50563c98215bd298e",
|
|
798
|
+
rewardPoolId: "0x6835c1224126a45086fc6406adc249e3f30df18d779ca4f4e570e38716a17f3f"
|
|
799
|
+
},
|
|
800
|
+
safsui: {
|
|
801
|
+
// id: '0xeedf438abcaa6ce4d9625ffca110920592d5867e4c5637d84ad9f466c4feb800',
|
|
802
|
+
id: "0xc568bb4c991258e839aa54802ecda04fcd9838c826bc3b42b40af81b23c458c8",
|
|
803
|
+
rewardPoolId: (
|
|
804
|
+
// '0x89255a2f86ed7fbfef35ab8b7be48cc7667015975be2685dd9a55a9a64baf76e',
|
|
805
|
+
"0x389a3cbeda742b918941bb24fd00e077bad3367484394d6234f8209b9a6aa03d"
|
|
806
|
+
)
|
|
807
|
+
},
|
|
808
|
+
shasui: {
|
|
809
|
+
// id: '0xa6148bc1b623e936d39a952ceb5bea79e8b37228a8f595067bf1852efd3c34aa',
|
|
810
|
+
id: "0x93f3f4499bf89f2d05ddc1f8b15f51701a7c6c4d0ac0b9c3bc99462cbbd8e321",
|
|
811
|
+
rewardPoolId: (
|
|
812
|
+
// '0x6f3563644d3e2ef13176dbf9d865bd93479df60ccbe07b7e66db57f6309f5a66',
|
|
813
|
+
"0x94cee1be7f5ff34193f3aabef0b14142cb28af4d905fe487a9a7d85a15edb6aa"
|
|
814
|
+
)
|
|
815
|
+
},
|
|
816
|
+
svsui: {
|
|
817
|
+
// id: '0x69ce8e537e750a95381e6040794afa5ab1758353a1a2e1de7760391b01f91670',
|
|
818
|
+
id: "0xa970e9087f80cb59e9299b8e7af7175d977ad6c9af0322aa4440e138fbd7ae00",
|
|
819
|
+
rewardPoolId: (
|
|
820
|
+
// '0xbca914adce058ad0902c7f3cfcd698392a475f00dcfdc3f76001d0370b98777a',
|
|
821
|
+
"0x38eee9699c4fc132a6623e54b865f047df4fc6eb83af807300f44e8f4b235ff0"
|
|
822
|
+
)
|
|
823
|
+
}
|
|
824
|
+
},
|
|
825
|
+
config: ""
|
|
826
|
+
},
|
|
827
|
+
borrowIncentive: {
|
|
828
|
+
id: "0x85769d63565ce99c7622f8e336ca1460926ddf29738ad2a39407b5cac29f61fe",
|
|
829
|
+
adminCap: "0x56ac8e6f2b360b2b35c0168d72cc6cd17d9592afb83709865cb87af24bb2025b",
|
|
830
|
+
object: "0x85769d63565ce99c7622f8e336ca1460926ddf29738ad2a39407b5cac29f61fe",
|
|
831
|
+
query: "0x8e0d00f8ff1199d7c5fe56cea0e901a525daeefff0445a1635ace8282ae3302c",
|
|
832
|
+
incentivePools: "0x9d564c93128c6ab0c0d3e050a47f11df0b91494f3bb779bdc1301c1c637f15eb",
|
|
833
|
+
incentiveAccounts: "0x09e6040e798246de04941bc79a3ba62d3eca6d7a218cc30f21fb07f478fa2926",
|
|
834
|
+
config: "0x43d4ca1dfc90b161c4240facd119e74e4b850cca2957f88c2ec289c9380da064"
|
|
835
|
+
},
|
|
836
|
+
referral: {
|
|
837
|
+
id: "0x1bf5a8ce77050d8052549d743e16b469f15aa6b81b752b78b6ebb65179665f5a",
|
|
838
|
+
object: "0x5658d4bf5ddcba27e4337b4262108b3ad1716643cac8c2054ac341538adc72ec",
|
|
839
|
+
adminCap: "0xc5dc06b9074291259f2cac460c940012c781c4430e42125c541cc43101c3bcbd",
|
|
840
|
+
referralBindings: "0xcf184487782bed962bf678001efe775d31fb94b9992333a57594cf15d79d5ced",
|
|
841
|
+
bindingTableId: "0x41a50e258c0a266ce84e0e1a618dbf70b878cc943909e613089a50afcceb2bc0",
|
|
842
|
+
referralRevenuePool: "0xc24e3e5e37032f29a3dd91a9a1f057af8821b7e6c148e9683900ac8b6d30f0c6",
|
|
843
|
+
revenueTableId: "0x595baa3654c297bff84ab7786a2d250f019cefc66e8df8e89fd9d41e02bd30dd",
|
|
844
|
+
referralTiers: "0x144350f3db9b46d11b140084cd54e6de0b9c3b8d265ce8059b51d0ef58ea464b",
|
|
845
|
+
tiersTableId: "0xeac755a7a8b7798530905ac79e8c114f19d0f130f6eab012954f08faac29c75d",
|
|
846
|
+
// authorizedWitnessList:
|
|
847
|
+
// '0xf21b0ed043c9bb70842c0129159f4943dbcc3c9ef2f2f808af65f8be25cfd20e',
|
|
848
|
+
authorizedWitnessList: "0x9d6223dc52015b8a3986a573590ef2af8f1b8f3e4685513888c052f001b87e7f",
|
|
849
|
+
version: "0x3545849eb97723e676a476ec9d4fe5f2eb0eb2c6b78972851114fd4c7ed4639f"
|
|
850
|
+
},
|
|
851
|
+
vesca: {
|
|
852
|
+
id: "0x1158813b32962c2d22888fae257d5f2365b03631f0cd5d5b912ccdf51ff4e2f2",
|
|
853
|
+
object: "0x1158813b32962c2d22888fae257d5f2365b03631f0cd5d5b912ccdf51ff4e2f2",
|
|
854
|
+
adminCap: "0x8ffa76135c5b85c5fbd73a6448a4a733d826cb63a267ab817656acb77c72d4a5",
|
|
855
|
+
tableId: "0x0a0b7f749baeb61e3dfee2b42245e32d0e6b484063f0a536b33e771d573d7246",
|
|
856
|
+
table: "0xd3a4632b1080f7d96e1c2487d4dabf2c1196916937c505a69954ac9f393be8d0",
|
|
857
|
+
treasury: "0xafa4b6231e49c15a22d641ce33fda761baaf650fa21899dfa2eb1716146e7306",
|
|
858
|
+
config: "0x7cbcb0a342179577a117dfdff974cf1ab765d3b571067bf22ddf5f9e3a667922"
|
|
859
|
+
},
|
|
860
|
+
loyaltyProgram: {
|
|
861
|
+
id: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
862
|
+
object: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
863
|
+
rewardPool: "0xf9c090492ef476bd542109d0913ffe871cbfa28578b7114eca2a8c0e5671786f",
|
|
864
|
+
userRewardTableId: "0x748a80395849ed37db1b0e14f2ab5d1d96458d2359ab3a84eb079d0f4ac7cf2e"
|
|
865
|
+
},
|
|
866
|
+
scoin: {
|
|
867
|
+
id: "0x773dab39c90fe05439b06a2d061795e52a974ff92c2aef90b2ee467acf7f33c8",
|
|
868
|
+
coins: {
|
|
869
|
+
ssui: {
|
|
870
|
+
coinType: "0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI",
|
|
871
|
+
treasury: "0x0e499640a12c38dd9cc44532f5bc5fd1b6da86d2f9a8810357250f4b26e9e5c7"
|
|
872
|
+
},
|
|
873
|
+
scetus: {
|
|
874
|
+
coinType: "0x8b71e6d323ed78515af2bead13bf3d0da1562ba4a99234eb7c4f14fd39ef0427::scallop_cetus::SCALLOP_CETUS",
|
|
875
|
+
treasury: "0xd786f4b2d26278cc7911a3445b1b085eab60f269ef9dbb6b87e803d52f155003"
|
|
876
|
+
},
|
|
877
|
+
ssca: {
|
|
878
|
+
coinType: "0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA",
|
|
879
|
+
treasury: "0x5f1c5de1df7341075d119570269b7b452af50afe8363080638f1ae29a554c038"
|
|
880
|
+
},
|
|
881
|
+
swusdc: {
|
|
882
|
+
coinType: "0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
|
|
883
|
+
treasury: "0x471fbab72578bab577263006fe32543b6e76153fffa2bef69affe4bc4934258f"
|
|
884
|
+
},
|
|
885
|
+
swusdt: {
|
|
886
|
+
coinType: "0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
|
|
887
|
+
treasury: "0x921a4ed4bb4b4f11f51a462c83f4c0f6b60a90e441d1bc0d26d6fd893146bf4d"
|
|
888
|
+
},
|
|
889
|
+
sweth: {
|
|
890
|
+
coinType: "0x27d54f43e3eda701be56b82e5756e41c84467cd202f5cf713d5f9e45a9f1b6bc::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
|
|
891
|
+
treasury: "0x032b4c8fac94c038dbe986f7587e9b1e4ef580b5ee06d2ef249d85459b7ef05d"
|
|
892
|
+
},
|
|
893
|
+
safsui: {
|
|
894
|
+
coinType: "0xb75b46d975d8d80670b53a6bee90baaa8ce2e0b7d397f079447d641eef6b44ad::scallop_af_sui::SCALLOP_AF_SUI",
|
|
895
|
+
treasury: "0x21450ef0570ef3d224ffa3b873ab802e439ece7b93cc7efad10ae0c1e3b3fcfe"
|
|
896
|
+
},
|
|
897
|
+
shasui: {
|
|
898
|
+
coinType: "0xd973a723874e2c7cde196602a79155a1343a933f8cf87d9b1bb7408bc1acbc58::scallop_ha_sui::SCALLOP_HA_SUI",
|
|
899
|
+
treasury: "0xf822fc1402207e47d2e3ba8ff6e1e594bf1de777dc5ebd2744619cd2726e3b0d"
|
|
900
|
+
},
|
|
901
|
+
svsui: {
|
|
902
|
+
coinType: "0x97023a317320c4498cc4cd239dd02fd30c28246e5e8f81325d63f2bd8d70f6b3::scallop_v_sui::SCALLOP_V_SUI",
|
|
903
|
+
treasury: "0x327114f0bf3559d7e2de10282147ed76a236c7c6775029165c4db09a6062ead6"
|
|
904
|
+
},
|
|
905
|
+
ssbeth: {
|
|
906
|
+
coinType: "0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH",
|
|
907
|
+
treasury: "0xfd0f02def6358a1f266acfa1493d4707ee8387460d434fb667d63d755ff907ed"
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
|
|
913
|
+
// src/constants/tokenBucket.ts
|
|
914
|
+
var DEFAULT_TOKENS_PER_INTERVAL = 50;
|
|
915
|
+
var DEFAULT_INTERVAL_IN_MS = 300;
|
|
916
|
+
|
|
917
|
+
// src/constants/vesca.ts
|
|
918
|
+
var UNLOCK_ROUND_DURATION = 60 * 60 * 24;
|
|
919
|
+
var MAX_LOCK_ROUNDS = 1460;
|
|
920
|
+
var MAX_LOCK_DURATION = MAX_LOCK_ROUNDS * UNLOCK_ROUND_DURATION;
|
|
921
|
+
var MIN_INITIAL_LOCK_AMOUNT = 1e10;
|
|
922
|
+
var MIN_TOP_UP_AMOUNT = 1e9;
|
|
923
|
+
|
|
924
|
+
// src/models/scallop.ts
|
|
925
|
+
import { SuiKit as SuiKit7 } from "@scallop-io/sui-kit";
|
|
926
|
+
|
|
927
|
+
// src/models/scallopAddress.ts
|
|
928
|
+
import { SuiKit } from "@scallop-io/sui-kit";
|
|
929
|
+
|
|
930
|
+
// src/models/scallopCache.ts
|
|
931
|
+
import { QueryClient } from "@tanstack/query-core";
|
|
932
|
+
import {
|
|
933
|
+
SuiTxBlock,
|
|
934
|
+
normalizeStructTag as normalizeStructTag2
|
|
935
|
+
} from "@scallop-io/sui-kit";
|
|
936
|
+
|
|
937
|
+
// src/utils/builder.ts
|
|
938
|
+
var requireSender = (txBlock) => {
|
|
939
|
+
const sender = txBlock.blockData.sender;
|
|
940
|
+
if (!sender) {
|
|
941
|
+
throw new Error("Sender is required");
|
|
942
|
+
}
|
|
943
|
+
return sender;
|
|
944
|
+
};
|
|
945
|
+
var checkVesca = (prevUnlockAtInMillisTimestamp) => {
|
|
946
|
+
if (prevUnlockAtInMillisTimestamp === void 0) {
|
|
947
|
+
throw new Error("veSca not found");
|
|
948
|
+
}
|
|
949
|
+
};
|
|
950
|
+
var checkVescaExpired = (prevUnlockAtInMillisTimestamp) => {
|
|
951
|
+
if (prevUnlockAtInMillisTimestamp <= (/* @__PURE__ */ new Date()).getTime()) {
|
|
952
|
+
throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
|
|
953
|
+
}
|
|
954
|
+
};
|
|
955
|
+
var checkExtendLockPeriod = (lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInMillisTimestamp) => {
|
|
956
|
+
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
957
|
+
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
958
|
+
const prevUnlockAtInSecondTimestamp = Math.floor(
|
|
959
|
+
prevUnlockAtInMillisTimestamp / 1e3
|
|
960
|
+
);
|
|
961
|
+
if (lockPeriodInDays < 1) {
|
|
962
|
+
throw new Error("Minimum lock period is 1 day");
|
|
963
|
+
}
|
|
964
|
+
const availableLockPeriodInDays = Math.floor(
|
|
965
|
+
(newUnlockAtInSecondTimestamp - prevUnlockAtInSecondTimestamp) / UNLOCK_ROUND_DURATION
|
|
966
|
+
);
|
|
967
|
+
if (lockPeriodInDays > availableLockPeriodInDays) {
|
|
968
|
+
throw new Error(
|
|
969
|
+
`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}`
|
|
970
|
+
);
|
|
971
|
+
}
|
|
972
|
+
};
|
|
973
|
+
var checkLockSca = (scaAmountOrCoin, lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInMillisTimestamp) => {
|
|
974
|
+
const prevUnlockAtInSecondTimestamp = prevUnlockAtInMillisTimestamp ? Math.floor(prevUnlockAtInMillisTimestamp / 1e3) : void 0;
|
|
975
|
+
const isInitialLock = !prevUnlockAtInSecondTimestamp;
|
|
976
|
+
const isLockExpired = !isInitialLock && prevUnlockAtInSecondTimestamp * 1e3 <= (/* @__PURE__ */ new Date()).getTime();
|
|
977
|
+
if (isInitialLock || isLockExpired) {
|
|
978
|
+
if (scaAmountOrCoin !== void 0 && lockPeriodInDays !== void 0) {
|
|
979
|
+
if (lockPeriodInDays <= 0) {
|
|
980
|
+
throw new Error("Lock period must be greater than 0");
|
|
981
|
+
}
|
|
982
|
+
if (typeof scaAmountOrCoin === "number" && scaAmountOrCoin < MIN_INITIAL_LOCK_AMOUNT) {
|
|
983
|
+
throw new Error(
|
|
984
|
+
`Minimum lock amount for ${isLockExpired ? "renewing expired veSca" : "initial lock"} is 10 SCA`
|
|
985
|
+
);
|
|
986
|
+
}
|
|
987
|
+
const extendLockPeriodInSecond = lockPeriodInDays * UNLOCK_ROUND_DURATION;
|
|
988
|
+
if (extendLockPeriodInSecond > MAX_LOCK_DURATION) {
|
|
989
|
+
throw new Error(
|
|
990
|
+
`Maximum lock period is ~4 years (${MAX_LOCK_ROUNDS} days)`
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
} else {
|
|
994
|
+
throw new Error(
|
|
995
|
+
`SCA amount and lock period is required for ${isLockExpired ? "renewing expired veSca" : "initial lock"}`
|
|
996
|
+
);
|
|
997
|
+
}
|
|
998
|
+
} else {
|
|
999
|
+
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
1000
|
+
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
1001
|
+
if (typeof scaAmountOrCoin === "number" && scaAmountOrCoin < MIN_TOP_UP_AMOUNT) {
|
|
1002
|
+
throw new Error("Minimum top up amount is 1 SCA");
|
|
1003
|
+
}
|
|
1004
|
+
if (newUnlockAtInSecondTimestamp && lockPeriodInDays) {
|
|
1005
|
+
checkExtendLockPeriod(
|
|
1006
|
+
lockPeriodInDays,
|
|
1007
|
+
newUnlockAtInSecondTimestamp,
|
|
1008
|
+
prevUnlockAtInMillisTimestamp
|
|
1009
|
+
);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
};
|
|
1013
|
+
var checkExtendLockAmount = (scaAmount, prevUnlockAtInMillisTimestamp) => {
|
|
1014
|
+
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
1015
|
+
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
1016
|
+
if (scaAmount < MIN_TOP_UP_AMOUNT) {
|
|
1017
|
+
throw new Error("Minimum top up amount is 1 SCA");
|
|
1018
|
+
}
|
|
1019
|
+
const isInitialLock = !prevUnlockAtInMillisTimestamp;
|
|
1020
|
+
const isLockExpired = !isInitialLock && prevUnlockAtInMillisTimestamp <= (/* @__PURE__ */ new Date()).getTime();
|
|
1021
|
+
if (isLockExpired) {
|
|
1022
|
+
throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays, prevUnlockAtInMillisTimestamp) => {
|
|
1026
|
+
if (!prevUnlockAtInMillisTimestamp || prevUnlockAtInMillisTimestamp > (/* @__PURE__ */ new Date()).getTime()) {
|
|
1027
|
+
throw new Error("Renew method can only be used for expired veSca");
|
|
1028
|
+
}
|
|
1029
|
+
if (scaAmount < MIN_INITIAL_LOCK_AMOUNT) {
|
|
1030
|
+
throw new Error("Minimum lock amount for renewing expired vesca 10 SCA");
|
|
1031
|
+
}
|
|
1032
|
+
const extendLockPeriodInSecond = lockPeriodInDays * UNLOCK_ROUND_DURATION;
|
|
1033
|
+
if (extendLockPeriodInSecond >= MAX_LOCK_DURATION - UNLOCK_ROUND_DURATION) {
|
|
1034
|
+
throw new Error(
|
|
1035
|
+
`Maximum lock period is ~4 years (${MAX_LOCK_ROUNDS - 1} days)`
|
|
1036
|
+
);
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
|
|
1040
|
+
// src/utils/query.ts
|
|
1041
|
+
import BigNumber from "bignumber.js";
|
|
1042
|
+
import { normalizeStructTag, parseStructTag } from "@mysten/sui/utils";
|
|
1043
|
+
var parseOriginMarketPoolData = (originMarketPoolData) => {
|
|
1044
|
+
return {
|
|
1045
|
+
coinType: normalizeStructTag(originMarketPoolData.type.name),
|
|
1046
|
+
// Parse origin data required for basic calculations.
|
|
1047
|
+
maxBorrowRate: Number(originMarketPoolData.maxBorrowRate.value) / 2 ** 32,
|
|
1048
|
+
borrowRate: Number(originMarketPoolData.interestRate.value) / 2 ** 32,
|
|
1049
|
+
borrowRateScale: Number(originMarketPoolData.interestRateScale),
|
|
1050
|
+
borrowIndex: Number(originMarketPoolData.borrowIndex),
|
|
1051
|
+
lastUpdated: Number(originMarketPoolData.lastUpdated),
|
|
1052
|
+
cashAmount: Number(originMarketPoolData.cash),
|
|
1053
|
+
debtAmount: Number(originMarketPoolData.debt),
|
|
1054
|
+
marketCoinSupplyAmount: Number(originMarketPoolData.marketCoinSupply),
|
|
1055
|
+
reserveAmount: Number(originMarketPoolData.reserve),
|
|
1056
|
+
reserveFactor: Number(originMarketPoolData.reserveFactor.value) / 2 ** 32,
|
|
1057
|
+
borrowWeight: Number(originMarketPoolData.borrowWeight.value) / 2 ** 32,
|
|
1058
|
+
borrowFee: Number(originMarketPoolData.borrowFeeRate.value) / 2 ** 32,
|
|
1059
|
+
// Parse origin data required for additional display.
|
|
1060
|
+
baseBorrowRate: Number(originMarketPoolData.baseBorrowRatePerSec.value) / 2 ** 32,
|
|
1061
|
+
borrowRateOnHighKink: Number(originMarketPoolData.borrowRateOnHighKink.value) / 2 ** 32,
|
|
1062
|
+
borrowRateOnMidKink: Number(originMarketPoolData.borrowRateOnMidKink.value) / 2 ** 32,
|
|
1063
|
+
highKink: Number(originMarketPoolData.highKink.value) / 2 ** 32,
|
|
1064
|
+
midKink: Number(originMarketPoolData.midKink.value) / 2 ** 32,
|
|
1065
|
+
minBorrowAmount: Number(originMarketPoolData.minBorrowAmount)
|
|
1066
|
+
};
|
|
1067
|
+
};
|
|
1068
|
+
var calculateMarketPoolData = (utils, parsedMarketPoolData) => {
|
|
1069
|
+
const poolCoinName = utils.parseCoinNameFromType(
|
|
1070
|
+
parsedMarketPoolData.coinType
|
|
1071
|
+
);
|
|
1072
|
+
const coinDecimal = utils.getCoinDecimal(poolCoinName);
|
|
1073
|
+
const borrowYearFactor = 24 * 365 * 3600;
|
|
1074
|
+
const baseBorrowApr = parsedMarketPoolData.baseBorrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
1075
|
+
const borrowAprOnHighKink = parsedMarketPoolData.borrowRateOnHighKink * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
1076
|
+
const borrowAprOnMidKink = parsedMarketPoolData.borrowRateOnMidKink * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
1077
|
+
const maxBorrowApr = parsedMarketPoolData.maxBorrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
1078
|
+
const borrowApr = parsedMarketPoolData.borrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
1079
|
+
const timeDelta = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - parsedMarketPoolData.lastUpdated;
|
|
1080
|
+
const borrowIndexDelta = BigNumber(parsedMarketPoolData.borrowIndex).multipliedBy(
|
|
1081
|
+
BigNumber(timeDelta).multipliedBy(parsedMarketPoolData.borrowRate)
|
|
1082
|
+
).dividedBy(parsedMarketPoolData.borrowRateScale);
|
|
1083
|
+
const currentBorrowIndex = BigNumber(parsedMarketPoolData.borrowIndex).plus(
|
|
1084
|
+
borrowIndexDelta
|
|
1085
|
+
);
|
|
1086
|
+
const growthInterest = BigNumber(currentBorrowIndex).dividedBy(parsedMarketPoolData.borrowIndex).minus(1);
|
|
1087
|
+
const increasedDebtAmount = BigNumber(
|
|
1088
|
+
parsedMarketPoolData.debtAmount
|
|
1089
|
+
).multipliedBy(growthInterest);
|
|
1090
|
+
const borrowAmount = increasedDebtAmount.plus(
|
|
1091
|
+
parsedMarketPoolData.debtAmount
|
|
1092
|
+
);
|
|
1093
|
+
const borrowCoin = borrowAmount.shiftedBy(-1 * coinDecimal);
|
|
1094
|
+
const reserveAmount = BigNumber(parsedMarketPoolData.reserveAmount).plus(
|
|
1095
|
+
increasedDebtAmount.multipliedBy(parsedMarketPoolData.reserveFactor)
|
|
1096
|
+
);
|
|
1097
|
+
const reserveCoin = reserveAmount.shiftedBy(-1 * coinDecimal);
|
|
1098
|
+
const supplyAmount = BigNumber(borrowAmount).plus(
|
|
1099
|
+
Math.max(parsedMarketPoolData.cashAmount - reserveAmount.toNumber(), 0)
|
|
1100
|
+
);
|
|
1101
|
+
const supplyCoin = supplyAmount.shiftedBy(-1 * coinDecimal);
|
|
1102
|
+
let utilizationRate = BigNumber(borrowAmount).dividedBy(supplyAmount);
|
|
1103
|
+
utilizationRate = utilizationRate.isFinite() ? utilizationRate : BigNumber(0);
|
|
1104
|
+
let supplyApr = BigNumber(borrowApr).multipliedBy(utilizationRate).multipliedBy(1 - parsedMarketPoolData.reserveFactor);
|
|
1105
|
+
supplyApr = supplyApr.isFinite() ? supplyApr : BigNumber(0);
|
|
1106
|
+
let conversionRate = supplyAmount.dividedBy(
|
|
1107
|
+
parsedMarketPoolData.marketCoinSupplyAmount
|
|
1108
|
+
);
|
|
1109
|
+
conversionRate = conversionRate.isFinite() && !conversionRate.isNaN() ? conversionRate : BigNumber(1);
|
|
1110
|
+
return {
|
|
1111
|
+
baseBorrowApr,
|
|
1112
|
+
baseBorrowApy: utils.parseAprToApy(baseBorrowApr),
|
|
1113
|
+
borrowAprOnHighKink,
|
|
1114
|
+
borrowApyOnHighKink: utils.parseAprToApy(borrowAprOnHighKink),
|
|
1115
|
+
borrowAprOnMidKink,
|
|
1116
|
+
borrowApyOnMidKink: utils.parseAprToApy(borrowAprOnMidKink),
|
|
1117
|
+
maxBorrowApr,
|
|
1118
|
+
maxBorrowApy: utils.parseAprToApy(maxBorrowApr),
|
|
1119
|
+
borrowApr: Math.min(borrowApr, maxBorrowApr),
|
|
1120
|
+
borrowApy: Math.min(
|
|
1121
|
+
utils.parseAprToApy(borrowApr),
|
|
1122
|
+
utils.parseAprToApy(maxBorrowApr)
|
|
1123
|
+
),
|
|
1124
|
+
borrowIndex: currentBorrowIndex.toNumber(),
|
|
1125
|
+
growthInterest: growthInterest.toNumber(),
|
|
1126
|
+
supplyAmount: supplyAmount.toNumber(),
|
|
590
1127
|
supplyCoin: supplyCoin.toNumber(),
|
|
591
1128
|
borrowAmount: borrowAmount.toNumber(),
|
|
592
1129
|
borrowCoin: borrowCoin.toNumber(),
|
|
@@ -823,786 +1360,390 @@ var calculateBorrowIncentivePoolPointData = (parsedBorrowIncentivePoolPointData,
|
|
|
823
1360
|
).dividedBy(weightedStakedValue).toNumber() : Infinity;
|
|
824
1361
|
return {
|
|
825
1362
|
distributedPointPerSec: distributedPointPerSec.toNumber(),
|
|
826
|
-
accumulatedPoints: accumulatedPoints.toNumber(),
|
|
827
|
-
currentPointIndex: currentPointIndex.toNumber(),
|
|
828
|
-
currentTotalDistributedPoint: currentTotalDistributedPoint.toNumber(),
|
|
829
|
-
baseWeight: baseWeight.toNumber(),
|
|
830
|
-
weightedStakedAmount: weightedStakedAmount.toNumber(),
|
|
831
|
-
weightedStakedCoin: weightedStakedCoin.toNumber(),
|
|
832
|
-
weightedStakedValue: weightedStakedValue.toNumber(),
|
|
833
|
-
rewardApr: rewardRate,
|
|
834
|
-
rewardPerSec: rewardPerSec.toNumber()
|
|
835
|
-
};
|
|
836
|
-
};
|
|
837
|
-
var parseOriginBorrowIncentiveAccountPoolPointData = (originBorrowIncentiveAccountPoolPointData) => {
|
|
838
|
-
return {
|
|
839
|
-
pointType: normalizeStructTag(
|
|
840
|
-
originBorrowIncentiveAccountPoolPointData.point_type.name
|
|
841
|
-
),
|
|
842
|
-
weightedAmount: Number(
|
|
843
|
-
originBorrowIncentiveAccountPoolPointData.weighted_amount
|
|
844
|
-
),
|
|
845
|
-
points: Number(originBorrowIncentiveAccountPoolPointData.points),
|
|
846
|
-
totalPoints: Number(originBorrowIncentiveAccountPoolPointData.total_points),
|
|
847
|
-
index: Number(originBorrowIncentiveAccountPoolPointData.index)
|
|
848
|
-
};
|
|
849
|
-
};
|
|
850
|
-
var parseOriginBorrowIncentiveAccountData = (originBorrowIncentiveAccountData) => {
|
|
851
|
-
return {
|
|
852
|
-
poolType: normalizeStructTag(
|
|
853
|
-
originBorrowIncentiveAccountData.pool_type.name
|
|
854
|
-
),
|
|
855
|
-
debtAmount: Number(originBorrowIncentiveAccountData.debt_amount),
|
|
856
|
-
pointList: originBorrowIncentiveAccountData.points_list.reduce(
|
|
857
|
-
(acc, point) => {
|
|
858
|
-
const parsed = parseOriginBorrowIncentiveAccountPoolPointData(point);
|
|
859
|
-
const name = parseStructTag(
|
|
860
|
-
parsed.pointType
|
|
861
|
-
).name.toLowerCase();
|
|
862
|
-
acc[name] = parsed;
|
|
863
|
-
return acc;
|
|
864
|
-
},
|
|
865
|
-
{}
|
|
866
|
-
)
|
|
867
|
-
};
|
|
868
|
-
};
|
|
869
|
-
var minBigNumber = (...args) => {
|
|
870
|
-
return BigNumber(
|
|
871
|
-
args.reduce(
|
|
872
|
-
(min, current) => new BigNumber(current).lt(min) ? current : min
|
|
873
|
-
)
|
|
874
|
-
);
|
|
875
|
-
};
|
|
876
|
-
var estimatedFactor = (amount, scaleStep, type) => {
|
|
877
|
-
const amountOfDigits = Math.max(
|
|
878
|
-
1,
|
|
879
|
-
Math.floor(Math.log10(Math.abs(amount)) + 1)
|
|
880
|
-
);
|
|
881
|
-
const adjustScale = Math.max(Math.floor((amountOfDigits - 1) / scaleStep), 1) + 1;
|
|
882
|
-
let adjustFactor = Math.pow(10, -adjustScale);
|
|
883
|
-
adjustFactor = type === "increase" ? 1 - adjustFactor : 1 + adjustFactor;
|
|
884
|
-
return adjustFactor;
|
|
885
|
-
};
|
|
886
|
-
|
|
887
|
-
// src/utils/util.ts
|
|
888
|
-
var COIN_SET = Array.from(
|
|
889
|
-
/* @__PURE__ */ new Set([
|
|
890
|
-
...SUPPORT_POOLS,
|
|
891
|
-
...SUPPORT_COLLATERALS,
|
|
892
|
-
...SUPPORT_SPOOLS_REWARDS,
|
|
893
|
-
...SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
894
|
-
...SUPPORT_SCOIN
|
|
895
|
-
])
|
|
896
|
-
);
|
|
897
|
-
var isMarketCoin = (coinName) => {
|
|
898
|
-
const assetCoinName = coinName.slice(1).toLowerCase();
|
|
899
|
-
return coinName.charAt(0).toLowerCase() === "s" && COIN_SET.includes(assetCoinName);
|
|
900
|
-
};
|
|
901
|
-
var isSuiBridgeAsset = (coinName) => {
|
|
902
|
-
return SUPPORT_SUI_BRIDGE.includes(coinName);
|
|
903
|
-
};
|
|
904
|
-
var isWormholeAsset = (coinName) => {
|
|
905
|
-
return SUPPORT_WORMHOLE.includes(coinName);
|
|
906
|
-
};
|
|
907
|
-
var parseAssetSymbol = (coinName) => {
|
|
908
|
-
if (isWormholeAsset(coinName)) {
|
|
909
|
-
return `w${coinName.slice(1).toUpperCase()}`;
|
|
910
|
-
}
|
|
911
|
-
if (isSuiBridgeAsset(coinName)) {
|
|
912
|
-
return `sb${coinName.slice(2).toUpperCase()}`;
|
|
913
|
-
}
|
|
914
|
-
if (isMarketCoin(coinName)) {
|
|
915
|
-
const assetCoinName = coinName.slice(1).toLowerCase();
|
|
916
|
-
return coinName.slice(0, 1).toLowerCase() + parseAssetSymbol(assetCoinName);
|
|
917
|
-
}
|
|
918
|
-
switch (coinName) {
|
|
919
|
-
case "afsui":
|
|
920
|
-
return "afSUI";
|
|
921
|
-
case "hasui":
|
|
922
|
-
return "haSUI";
|
|
923
|
-
case "vsui":
|
|
924
|
-
return "vSUI";
|
|
925
|
-
default:
|
|
926
|
-
return coinName.toUpperCase();
|
|
927
|
-
}
|
|
928
|
-
};
|
|
929
|
-
var parseDataFromPythPriceFeed = (feed, address) => {
|
|
930
|
-
const assetCoinNames = COIN_SET;
|
|
931
|
-
const assetCoinName = assetCoinNames.find((assetCoinName2) => {
|
|
932
|
-
return address.get(`core.coins.${assetCoinName2}.oracle.pyth.feed`) === feed.id;
|
|
933
|
-
});
|
|
934
|
-
if (assetCoinName) {
|
|
935
|
-
const price = feed.price.price * 10 ** feed.price.expo;
|
|
936
|
-
return {
|
|
937
|
-
coinName: assetCoinName,
|
|
938
|
-
price,
|
|
939
|
-
publishTime: Number(feed.price.publishTime) * 10 ** 3
|
|
940
|
-
};
|
|
941
|
-
} else {
|
|
942
|
-
throw new Error("Invalid feed id");
|
|
943
|
-
}
|
|
944
|
-
};
|
|
945
|
-
var findClosestUnlockRound = (unlockAtInSecondTimestamp) => {
|
|
946
|
-
const unlockDate = new Date(unlockAtInSecondTimestamp * 1e3);
|
|
947
|
-
const closestTwelveAM = new Date(unlockAtInSecondTimestamp * 1e3);
|
|
948
|
-
closestTwelveAM.setUTCHours(0, 0, 0, 0);
|
|
949
|
-
if (unlockDate.getUTCHours() >= 0) {
|
|
950
|
-
closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() + 1);
|
|
951
|
-
}
|
|
952
|
-
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
953
|
-
if (closestTwelveAM.getTime() - now > MAX_LOCK_DURATION * 1e3) {
|
|
954
|
-
closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() - 1);
|
|
955
|
-
}
|
|
956
|
-
return Math.floor(closestTwelveAM.getTime() / 1e3);
|
|
957
|
-
};
|
|
958
|
-
|
|
959
|
-
// src/constants/tokenBucket.ts
|
|
960
|
-
var DEFAULT_TOKENS_PER_INTERVAL = 50;
|
|
961
|
-
var DEFAULT_INTERVAL_IN_MS = 300;
|
|
962
|
-
|
|
963
|
-
// src/utils/tokenBucket.ts
|
|
964
|
-
var TokenBucket = class {
|
|
965
|
-
constructor(tokensPerInterval, intervalInMs) {
|
|
966
|
-
this.tokensPerInterval = tokensPerInterval;
|
|
967
|
-
this.interval = intervalInMs;
|
|
968
|
-
this.tokens = tokensPerInterval;
|
|
969
|
-
this.lastRefill = Date.now();
|
|
970
|
-
}
|
|
971
|
-
refill() {
|
|
972
|
-
const now = Date.now();
|
|
973
|
-
const elapsed = now - this.lastRefill;
|
|
974
|
-
if (elapsed > this.interval) {
|
|
975
|
-
const tokensToAdd = Math.floor(elapsed / this.interval) * this.tokensPerInterval;
|
|
976
|
-
this.tokens = Math.min(this.tokens + tokensToAdd, this.tokensPerInterval);
|
|
977
|
-
this.lastRefill = now;
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
removeTokens(count) {
|
|
981
|
-
this.refill();
|
|
982
|
-
if (this.tokens >= count) {
|
|
983
|
-
this.tokens -= count;
|
|
984
|
-
return true;
|
|
985
|
-
}
|
|
986
|
-
return false;
|
|
987
|
-
}
|
|
1363
|
+
accumulatedPoints: accumulatedPoints.toNumber(),
|
|
1364
|
+
currentPointIndex: currentPointIndex.toNumber(),
|
|
1365
|
+
currentTotalDistributedPoint: currentTotalDistributedPoint.toNumber(),
|
|
1366
|
+
baseWeight: baseWeight.toNumber(),
|
|
1367
|
+
weightedStakedAmount: weightedStakedAmount.toNumber(),
|
|
1368
|
+
weightedStakedCoin: weightedStakedCoin.toNumber(),
|
|
1369
|
+
weightedStakedValue: weightedStakedValue.toNumber(),
|
|
1370
|
+
rewardApr: rewardRate,
|
|
1371
|
+
rewardPerSec: rewardPerSec.toNumber()
|
|
1372
|
+
};
|
|
988
1373
|
};
|
|
989
|
-
var
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
if (error.message === "Unexpected status code: 429" && retries < maxRetries) {
|
|
1001
|
-
retries++;
|
|
1002
|
-
const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
|
|
1003
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1004
|
-
return tryRequest();
|
|
1005
|
-
} else {
|
|
1006
|
-
console.error("An error occurred:", error.message);
|
|
1007
|
-
return null;
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
} else if (retries < maxRetries) {
|
|
1011
|
-
retries++;
|
|
1012
|
-
const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
|
|
1013
|
-
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1014
|
-
return tryRequest();
|
|
1015
|
-
} else {
|
|
1016
|
-
console.error("Maximum retries reached");
|
|
1017
|
-
return null;
|
|
1018
|
-
}
|
|
1374
|
+
var parseOriginBorrowIncentiveAccountPoolPointData = (originBorrowIncentiveAccountPoolPointData) => {
|
|
1375
|
+
return {
|
|
1376
|
+
pointType: normalizeStructTag(
|
|
1377
|
+
originBorrowIncentiveAccountPoolPointData.point_type.name
|
|
1378
|
+
),
|
|
1379
|
+
weightedAmount: Number(
|
|
1380
|
+
originBorrowIncentiveAccountPoolPointData.weighted_amount
|
|
1381
|
+
),
|
|
1382
|
+
points: Number(originBorrowIncentiveAccountPoolPointData.points),
|
|
1383
|
+
totalPoints: Number(originBorrowIncentiveAccountPoolPointData.total_points),
|
|
1384
|
+
index: Number(originBorrowIncentiveAccountPoolPointData.index)
|
|
1019
1385
|
};
|
|
1020
|
-
return tryRequest();
|
|
1021
1386
|
};
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1387
|
+
var parseOriginBorrowIncentiveAccountData = (originBorrowIncentiveAccountData) => {
|
|
1388
|
+
return {
|
|
1389
|
+
poolType: normalizeStructTag(
|
|
1390
|
+
originBorrowIncentiveAccountData.pool_type.name
|
|
1391
|
+
),
|
|
1392
|
+
debtAmount: Number(originBorrowIncentiveAccountData.debt_amount),
|
|
1393
|
+
pointList: originBorrowIncentiveAccountData.points_list.reduce(
|
|
1394
|
+
(acc, point) => {
|
|
1395
|
+
const parsed = parseOriginBorrowIncentiveAccountPoolPointData(point);
|
|
1396
|
+
const name = parseStructTag(
|
|
1397
|
+
parsed.pointType
|
|
1398
|
+
).name.toLowerCase();
|
|
1399
|
+
acc[name] = parsed;
|
|
1400
|
+
return acc;
|
|
1401
|
+
},
|
|
1402
|
+
{}
|
|
1403
|
+
)
|
|
1039
1404
|
};
|
|
1040
|
-
}
|
|
1405
|
+
};
|
|
1406
|
+
var minBigNumber = (...args) => {
|
|
1407
|
+
return BigNumber(
|
|
1408
|
+
args.reduce(
|
|
1409
|
+
(min, current) => new BigNumber(current).lt(min) ? current : min
|
|
1410
|
+
)
|
|
1411
|
+
);
|
|
1412
|
+
};
|
|
1413
|
+
var estimatedFactor = (amount, scaleStep, type) => {
|
|
1414
|
+
const amountOfDigits = Math.max(
|
|
1415
|
+
1,
|
|
1416
|
+
Math.floor(Math.log10(Math.abs(amount)) + 1)
|
|
1417
|
+
);
|
|
1418
|
+
const adjustScale = Math.max(Math.floor((amountOfDigits - 1) / scaleStep), 1) + 1;
|
|
1419
|
+
let adjustFactor = Math.pow(10, -adjustScale);
|
|
1420
|
+
adjustFactor = type === "increase" ? 1 - adjustFactor : 1 + adjustFactor;
|
|
1421
|
+
return adjustFactor;
|
|
1422
|
+
};
|
|
1041
1423
|
|
|
1042
|
-
// src/
|
|
1043
|
-
var
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
* - `all`: All queries that match the refetch predicate will be refetched in the background.
|
|
1066
|
-
* - `none`: No queries will be refetched. Queries that match the refetch predicate will only be marked as invalid.
|
|
1067
|
-
*/
|
|
1068
|
-
async invalidateAllCache() {
|
|
1069
|
-
return Object.values(queryKeys.rpc).map(
|
|
1070
|
-
(t) => this.queryClient.invalidateQueries({
|
|
1071
|
-
queryKey: t(),
|
|
1072
|
-
type: "all"
|
|
1073
|
-
})
|
|
1074
|
-
);
|
|
1075
|
-
}
|
|
1076
|
-
/**
|
|
1077
|
-
* @description Provides cache for inspectTxn of the SuiKit.
|
|
1078
|
-
* @param QueryInspectTxnParams
|
|
1079
|
-
* @param txBlock
|
|
1080
|
-
* @returns Promise<DevInspectResults>
|
|
1081
|
-
*/
|
|
1082
|
-
async queryInspectTxn({
|
|
1083
|
-
queryTarget,
|
|
1084
|
-
args,
|
|
1085
|
-
typeArgs
|
|
1086
|
-
}) {
|
|
1087
|
-
const txBlock = new SuiTxBlock();
|
|
1088
|
-
txBlock.moveCall(queryTarget, args, typeArgs);
|
|
1089
|
-
const query = await this.queryClient.fetchQuery({
|
|
1090
|
-
queryKey: queryKeys.rpc.getInspectTxn(queryTarget, args, typeArgs),
|
|
1091
|
-
queryFn: async () => {
|
|
1092
|
-
return await callWithRateLimit(
|
|
1093
|
-
this.tokenBucket,
|
|
1094
|
-
() => this.suiKit.inspectTxn(txBlock)
|
|
1095
|
-
);
|
|
1096
|
-
}
|
|
1097
|
-
});
|
|
1098
|
-
return query;
|
|
1099
|
-
}
|
|
1100
|
-
/**
|
|
1101
|
-
* @description Provides cache for getObject of the SuiKit.
|
|
1102
|
-
* @param objectId
|
|
1103
|
-
* @param QueryObjectParams
|
|
1104
|
-
* @returns Promise<SuiObjectResponse>
|
|
1105
|
-
*/
|
|
1106
|
-
async queryGetObject(objectId, options) {
|
|
1107
|
-
return this.queryClient.fetchQuery({
|
|
1108
|
-
queryKey: queryKeys.rpc.getObject(objectId, this.walletAddress, options),
|
|
1109
|
-
queryFn: async () => {
|
|
1110
|
-
return await callWithRateLimit(
|
|
1111
|
-
this.tokenBucket,
|
|
1112
|
-
() => this.client.getObject({
|
|
1113
|
-
id: objectId,
|
|
1114
|
-
options
|
|
1115
|
-
})
|
|
1116
|
-
);
|
|
1117
|
-
}
|
|
1118
|
-
});
|
|
1119
|
-
}
|
|
1120
|
-
/**
|
|
1121
|
-
* @description Provides cache for getObjects of the SuiKit.
|
|
1122
|
-
* @param objectIds
|
|
1123
|
-
* @returns Promise<SuiObjectData[]>
|
|
1124
|
-
*/
|
|
1125
|
-
async queryGetObjects(objectIds, options = {
|
|
1126
|
-
showContent: true
|
|
1127
|
-
}) {
|
|
1128
|
-
if (objectIds.length === 0)
|
|
1129
|
-
return [];
|
|
1130
|
-
return this.queryClient.fetchQuery({
|
|
1131
|
-
queryKey: queryKeys.rpc.getObjects(
|
|
1132
|
-
objectIds,
|
|
1133
|
-
this.walletAddress,
|
|
1134
|
-
options
|
|
1135
|
-
),
|
|
1136
|
-
queryFn: async () => {
|
|
1137
|
-
return await callWithRateLimit(
|
|
1138
|
-
this.tokenBucket,
|
|
1139
|
-
() => this.suiKit.getObjects(objectIds, options)
|
|
1140
|
-
);
|
|
1141
|
-
}
|
|
1142
|
-
});
|
|
1143
|
-
}
|
|
1144
|
-
/**
|
|
1145
|
-
* @description Provides cache for getOwnedObjects of the SuiKit.
|
|
1146
|
-
* @param input
|
|
1147
|
-
* @returns Promise<PaginatedObjectsResponse>
|
|
1148
|
-
*/
|
|
1149
|
-
async queryGetOwnedObjects(input) {
|
|
1150
|
-
return this.queryClient.fetchQuery({
|
|
1151
|
-
queryKey: queryKeys.rpc.getOwnedObjects(input),
|
|
1152
|
-
queryFn: async () => {
|
|
1153
|
-
return await callWithRateLimit(
|
|
1154
|
-
this.tokenBucket,
|
|
1155
|
-
() => this.client.getOwnedObjects(input)
|
|
1156
|
-
);
|
|
1157
|
-
}
|
|
1158
|
-
});
|
|
1159
|
-
}
|
|
1160
|
-
async queryGetDynamicFields(input) {
|
|
1161
|
-
return this.queryClient.fetchQuery({
|
|
1162
|
-
queryKey: queryKeys.rpc.getDynamicFields(input),
|
|
1163
|
-
queryFn: async () => {
|
|
1164
|
-
return await callWithRateLimit(
|
|
1165
|
-
this.tokenBucket,
|
|
1166
|
-
() => this.client.getDynamicFields(input)
|
|
1167
|
-
);
|
|
1168
|
-
}
|
|
1169
|
-
});
|
|
1424
|
+
// src/utils/util.ts
|
|
1425
|
+
var COIN_SET = Array.from(
|
|
1426
|
+
/* @__PURE__ */ new Set([
|
|
1427
|
+
...SUPPORT_POOLS,
|
|
1428
|
+
...SUPPORT_COLLATERALS,
|
|
1429
|
+
...SUPPORT_SPOOLS_REWARDS,
|
|
1430
|
+
...SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
1431
|
+
...SUPPORT_SCOIN
|
|
1432
|
+
])
|
|
1433
|
+
);
|
|
1434
|
+
var isMarketCoin = (coinName) => {
|
|
1435
|
+
const assetCoinName = coinName.slice(1).toLowerCase();
|
|
1436
|
+
return coinName.charAt(0).toLowerCase() === "s" && COIN_SET.includes(assetCoinName);
|
|
1437
|
+
};
|
|
1438
|
+
var isSuiBridgeAsset = (coinName) => {
|
|
1439
|
+
return SUPPORT_SUI_BRIDGE.includes(coinName);
|
|
1440
|
+
};
|
|
1441
|
+
var isWormholeAsset = (coinName) => {
|
|
1442
|
+
return SUPPORT_WORMHOLE.includes(coinName);
|
|
1443
|
+
};
|
|
1444
|
+
var parseAssetSymbol = (coinName) => {
|
|
1445
|
+
if (isWormholeAsset(coinName)) {
|
|
1446
|
+
return `w${coinName.slice(1).toUpperCase()}`;
|
|
1170
1447
|
}
|
|
1171
|
-
|
|
1172
|
-
return
|
|
1173
|
-
queryKey: queryKeys.rpc.getDynamicFieldObject(input),
|
|
1174
|
-
queryFn: async () => {
|
|
1175
|
-
return await callWithRateLimit(
|
|
1176
|
-
this.tokenBucket,
|
|
1177
|
-
() => this.client.getDynamicFieldObject(input)
|
|
1178
|
-
);
|
|
1179
|
-
}
|
|
1180
|
-
});
|
|
1448
|
+
if (isSuiBridgeAsset(coinName)) {
|
|
1449
|
+
return `sb${coinName.slice(2).toUpperCase()}`;
|
|
1181
1450
|
}
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
queryFn: async () => {
|
|
1186
|
-
const allBalances = await callWithRateLimit(
|
|
1187
|
-
this.tokenBucket,
|
|
1188
|
-
() => this.client.getAllBalances({ owner })
|
|
1189
|
-
);
|
|
1190
|
-
if (!allBalances)
|
|
1191
|
-
return {};
|
|
1192
|
-
const balances = allBalances.reduce(
|
|
1193
|
-
(acc, coinBalance) => {
|
|
1194
|
-
if (coinBalance.totalBalance !== "0") {
|
|
1195
|
-
acc[normalizeStructTag2(coinBalance.coinType)] = coinBalance.totalBalance;
|
|
1196
|
-
}
|
|
1197
|
-
return acc;
|
|
1198
|
-
},
|
|
1199
|
-
{}
|
|
1200
|
-
);
|
|
1201
|
-
return balances;
|
|
1202
|
-
}
|
|
1203
|
-
});
|
|
1451
|
+
if (isMarketCoin(coinName)) {
|
|
1452
|
+
const assetCoinName = coinName.slice(1).toLowerCase();
|
|
1453
|
+
return coinName.slice(0, 1).toLowerCase() + parseAssetSymbol(assetCoinName);
|
|
1204
1454
|
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
return "
|
|
1208
|
-
|
|
1455
|
+
switch (coinName) {
|
|
1456
|
+
case "afsui":
|
|
1457
|
+
return "afSUI";
|
|
1458
|
+
case "hasui":
|
|
1459
|
+
return "haSUI";
|
|
1460
|
+
case "vsui":
|
|
1461
|
+
return "vSUI";
|
|
1462
|
+
default:
|
|
1463
|
+
return coinName.toUpperCase();
|
|
1209
1464
|
}
|
|
1210
1465
|
};
|
|
1466
|
+
var parseDataFromPythPriceFeed = (feed, address) => {
|
|
1467
|
+
const assetCoinNames = COIN_SET;
|
|
1468
|
+
const assetCoinName = assetCoinNames.find((assetCoinName2) => {
|
|
1469
|
+
return address.get(`core.coins.${assetCoinName2}.oracle.pyth.feed`) === feed.id;
|
|
1470
|
+
});
|
|
1471
|
+
if (assetCoinName) {
|
|
1472
|
+
const price = feed.price.price * 10 ** feed.price.expo;
|
|
1473
|
+
return {
|
|
1474
|
+
coinName: assetCoinName,
|
|
1475
|
+
price,
|
|
1476
|
+
publishTime: Number(feed.price.publishTime) * 10 ** 3
|
|
1477
|
+
};
|
|
1478
|
+
} else {
|
|
1479
|
+
throw new Error("Invalid feed id");
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1482
|
+
var findClosestUnlockRound = (unlockAtInSecondTimestamp) => {
|
|
1483
|
+
const unlockDate = new Date(unlockAtInSecondTimestamp * 1e3);
|
|
1484
|
+
const closestTwelveAM = new Date(unlockAtInSecondTimestamp * 1e3);
|
|
1485
|
+
closestTwelveAM.setUTCHours(0, 0, 0, 0);
|
|
1486
|
+
if (unlockDate.getUTCHours() >= 0) {
|
|
1487
|
+
closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() + 1);
|
|
1488
|
+
}
|
|
1489
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
1490
|
+
if (closestTwelveAM.getTime() - now > MAX_LOCK_DURATION * 1e3) {
|
|
1491
|
+
closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() - 1);
|
|
1492
|
+
}
|
|
1493
|
+
return Math.floor(closestTwelveAM.getTime() / 1e3);
|
|
1494
|
+
};
|
|
1211
1495
|
|
|
1212
|
-
// src/
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
},
|
|
1247
|
-
wapt: {
|
|
1248
|
-
id: "0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37",
|
|
1249
|
-
metaData: "0xc969c5251f372c0f34c32759f1d315cf1ea0ee5e4454b52aea08778eacfdd0a8",
|
|
1250
|
-
treasury: "",
|
|
1251
|
-
oracle: {
|
|
1252
|
-
supra: "",
|
|
1253
|
-
switchboard: "",
|
|
1254
|
-
pyth: {
|
|
1255
|
-
feed: "03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5",
|
|
1256
|
-
feedObject: "0x7c5b7837c44a69b469325463ac0673ac1aa8435ff44ddb4191c9ae380463647f"
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
},
|
|
1260
|
-
wsol: {
|
|
1261
|
-
id: "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8",
|
|
1262
|
-
metaData: "0x4d2c39082b4477e3e79dc4562d939147ab90c42fc5f3e4acf03b94383cd69b6e",
|
|
1263
|
-
treasury: "",
|
|
1264
|
-
oracle: {
|
|
1265
|
-
supra: "",
|
|
1266
|
-
switchboard: "",
|
|
1267
|
-
pyth: {
|
|
1268
|
-
feed: "ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
|
|
1269
|
-
feedObject: "0x9d0d275efbd37d8a8855f6f2c761fa5983293dd8ce202ee5196626de8fcd4469"
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
},
|
|
1273
|
-
wbtc: {
|
|
1274
|
-
id: "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881",
|
|
1275
|
-
metaData: "0x5d3c6e60eeff8a05b693b481539e7847dfe33013e7070cdcb387f5c0cac05dfd",
|
|
1276
|
-
treasury: "",
|
|
1277
|
-
oracle: {
|
|
1278
|
-
supra: "",
|
|
1279
|
-
switchboard: "",
|
|
1280
|
-
pyth: {
|
|
1281
|
-
feed: "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43",
|
|
1282
|
-
feedObject: "0x9a62b4863bdeaabdc9500fce769cf7e72d5585eeb28a6d26e4cafadc13f76ab2"
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
},
|
|
1286
|
-
weth: {
|
|
1287
|
-
id: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
|
|
1288
|
-
metaData: "0x8900e4ceede3363bef086d6b50ca89d816d0e90bf6bc46efefe1f8455e08f50f",
|
|
1289
|
-
treasury: "",
|
|
1290
|
-
oracle: {
|
|
1291
|
-
supra: "",
|
|
1292
|
-
switchboard: "",
|
|
1293
|
-
pyth: {
|
|
1294
|
-
feed: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
1295
|
-
feedObject: "0x9193fd47f9a0ab99b6e365a464c8a9ae30e6150fc37ed2a89c1586631f6fc4ab"
|
|
1296
|
-
}
|
|
1297
|
-
}
|
|
1298
|
-
},
|
|
1299
|
-
wusdc: {
|
|
1300
|
-
id: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf",
|
|
1301
|
-
metaData: "0x4fbf84f3029bd0c0b77164b587963be957f853eccf834a67bb9ecba6ec80f189",
|
|
1302
|
-
treasury: "",
|
|
1303
|
-
oracle: {
|
|
1304
|
-
supra: "",
|
|
1305
|
-
switchboard: "",
|
|
1306
|
-
pyth: {
|
|
1307
|
-
feed: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
1308
|
-
feedObject: "0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab"
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1311
|
-
},
|
|
1312
|
-
wusdt: {
|
|
1313
|
-
id: "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c",
|
|
1314
|
-
metaData: "0xfb0e3eb97dd158a5ae979dddfa24348063843c5b20eb8381dd5fa7c93699e45c",
|
|
1315
|
-
treasury: "",
|
|
1316
|
-
oracle: {
|
|
1317
|
-
supra: "",
|
|
1318
|
-
switchboard: "",
|
|
1319
|
-
pyth: {
|
|
1320
|
-
feed: "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
|
|
1321
|
-
feedObject: "0x985e3db9f93f76ee8bace7c3dd5cc676a096accd5d9e09e9ae0fb6e492b14572"
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
},
|
|
1325
|
-
sui: {
|
|
1326
|
-
id: "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
1327
|
-
metaData: "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3",
|
|
1328
|
-
treasury: "",
|
|
1329
|
-
oracle: {
|
|
1330
|
-
supra: "",
|
|
1331
|
-
switchboard: "0xbca474133638352ba83ccf7b5c931d50f764b09550e16612c9f70f1e21f3f594",
|
|
1332
|
-
pyth: {
|
|
1333
|
-
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
1334
|
-
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
},
|
|
1338
|
-
afsui: {
|
|
1339
|
-
id: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
|
|
1340
|
-
metaData: "0x2f9217f533e51334873a39b8026a4aa6919497b47f49d0986a4f1aec66f8a34d",
|
|
1341
|
-
treasury: "",
|
|
1342
|
-
oracle: {
|
|
1343
|
-
supra: "",
|
|
1344
|
-
switchboard: "",
|
|
1345
|
-
pyth: {
|
|
1346
|
-
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
1347
|
-
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
},
|
|
1351
|
-
hasui: {
|
|
1352
|
-
id: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
|
|
1353
|
-
metaData: "0x2c5f33af93f6511df699aaaa5822d823aac6ed99d4a0de2a4a50b3afa0172e24",
|
|
1354
|
-
treasury: "",
|
|
1355
|
-
oracle: {
|
|
1356
|
-
supra: "",
|
|
1357
|
-
switchboard: "",
|
|
1358
|
-
pyth: {
|
|
1359
|
-
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
1360
|
-
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
},
|
|
1364
|
-
vsui: {
|
|
1365
|
-
id: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
|
|
1366
|
-
metaData: "0xabd84a23467b33854ab25cf862006fd97479f8f6f53e50fe732c43a274d939bd",
|
|
1367
|
-
treasury: "",
|
|
1368
|
-
oracle: {
|
|
1369
|
-
supra: "",
|
|
1370
|
-
switchboard: "",
|
|
1371
|
-
pyth: {
|
|
1372
|
-
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
1373
|
-
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
1374
|
-
}
|
|
1496
|
+
// src/utils/tokenBucket.ts
|
|
1497
|
+
var TokenBucket = class {
|
|
1498
|
+
constructor(tokensPerInterval, intervalInMs) {
|
|
1499
|
+
this.tokensPerInterval = tokensPerInterval;
|
|
1500
|
+
this.interval = intervalInMs;
|
|
1501
|
+
this.tokens = tokensPerInterval;
|
|
1502
|
+
this.lastRefill = Date.now();
|
|
1503
|
+
}
|
|
1504
|
+
refill() {
|
|
1505
|
+
const now = Date.now();
|
|
1506
|
+
const elapsed = now - this.lastRefill;
|
|
1507
|
+
if (elapsed > this.interval) {
|
|
1508
|
+
const tokensToAdd = Math.floor(elapsed / this.interval) * this.tokensPerInterval;
|
|
1509
|
+
this.tokens = Math.min(this.tokens + tokensToAdd, this.tokensPerInterval);
|
|
1510
|
+
this.lastRefill = now;
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
removeTokens(count) {
|
|
1514
|
+
this.refill();
|
|
1515
|
+
if (this.tokens >= count) {
|
|
1516
|
+
this.tokens -= count;
|
|
1517
|
+
return true;
|
|
1518
|
+
}
|
|
1519
|
+
return false;
|
|
1520
|
+
}
|
|
1521
|
+
};
|
|
1522
|
+
var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVAL_IN_MS, maxRetries = 15, backoffFactor = 1.25) => {
|
|
1523
|
+
let retries = 0;
|
|
1524
|
+
const tryRequest = async () => {
|
|
1525
|
+
if (tokenBucket.removeTokens(1)) {
|
|
1526
|
+
try {
|
|
1527
|
+
const result = await fn();
|
|
1528
|
+
if (result && result.status === 429) {
|
|
1529
|
+
throw new Error("Unexpected status code: 429");
|
|
1375
1530
|
}
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
feedObject: "0xf6de1d3279a269a597d813cbaca59aa906543ab9a8c64e84a4722f1a20863985"
|
|
1387
|
-
}
|
|
1531
|
+
return result;
|
|
1532
|
+
} catch (error) {
|
|
1533
|
+
if (error.message === "Unexpected status code: 429" && retries < maxRetries) {
|
|
1534
|
+
retries++;
|
|
1535
|
+
const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
|
|
1536
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1537
|
+
return tryRequest();
|
|
1538
|
+
} else {
|
|
1539
|
+
console.error("An error occurred:", error.message);
|
|
1540
|
+
return null;
|
|
1388
1541
|
}
|
|
1389
1542
|
}
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
registryCap: "0xbcb07141eb1f7e01fbda4130ecf5f5adaeabb77f5d9c32158b7532bcd2197acd",
|
|
1399
|
-
state: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
|
|
1400
|
-
wormhole: "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a",
|
|
1401
|
-
wormholeState: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c"
|
|
1402
|
-
}
|
|
1403
|
-
},
|
|
1404
|
-
packages: {
|
|
1405
|
-
coinDecimalsRegistry: {
|
|
1406
|
-
id: "0xca5a5a62f01c79a104bf4d31669e29daa387f325c241de4edbe30986a9bc8b0d",
|
|
1407
|
-
upgradeCap: "0x34e76a945d29f195bc53ca704fa70877d1cf3a5d7bbfdda1b13e633fff13c0f6"
|
|
1408
|
-
},
|
|
1409
|
-
math: {
|
|
1410
|
-
id: "0xad013d5fde39e15eabda32b3dbdafd67dac32b798ce63237c27a8f73339b9b6f",
|
|
1411
|
-
upgradeCap: "0x3a329598231de02e6135c62284b66005b41cad1d9ab7ca2dc79c08293aba2ec6"
|
|
1412
|
-
},
|
|
1413
|
-
whitelist: {
|
|
1414
|
-
id: "0x1318fdc90319ec9c24df1456d960a447521b0a658316155895014a6e39b5482f",
|
|
1415
|
-
upgradeCap: "0xf5a22aea23db664f7b69855b6a546747f17c1ec4230319cfc17225e462b05761"
|
|
1416
|
-
},
|
|
1417
|
-
x: {
|
|
1418
|
-
id: "0x779b5c547976899f5474f3a5bc0db36ddf4697ad7e5a901db0415c2281d28162",
|
|
1419
|
-
upgradeCap: "0x3f203f6fff6a69d151e4f1cd931f22b68c489ef2759765662fc7baf673943c9e"
|
|
1420
|
-
},
|
|
1421
|
-
protocol: {
|
|
1422
|
-
id: "0x87ddec2984645dbbe2403a509cc6edf393a43acdba9b77d45da2bcbefcf733c1",
|
|
1423
|
-
upgradeCap: "0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a"
|
|
1424
|
-
},
|
|
1425
|
-
// protocol: {
|
|
1426
|
-
// id: '0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e',
|
|
1427
|
-
// upgradeCap:
|
|
1428
|
-
// '0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a',
|
|
1429
|
-
// },
|
|
1430
|
-
protocolWhitelist: {
|
|
1431
|
-
id: "0x4c262d9343dac53ecb28f482a2a3f62c73d0ebac5b5f03d57383d56ff219acdf",
|
|
1432
|
-
upgradeCap: "0x4a5e88a75039b00988f633f811f58117f31b8627a46bf822aa114d9010049449"
|
|
1433
|
-
},
|
|
1434
|
-
// query: {
|
|
1435
|
-
// id: '0xb8d603a39114a5efef3dd0bf84df0bed1be1fbd39b78b7dd6e8a61ccc5e6006f',
|
|
1436
|
-
// upgradeCap:
|
|
1437
|
-
// '0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f',
|
|
1438
|
-
// },
|
|
1439
|
-
query: {
|
|
1440
|
-
id: "0xe4f9d62d17746d5b9dbf0d5557747430021a71575780b515161210cdba0a4c1c",
|
|
1441
|
-
upgradeCap: "0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f"
|
|
1442
|
-
},
|
|
1443
|
-
supra: { id: "", upgradeCap: "" },
|
|
1444
|
-
pyth: {
|
|
1445
|
-
id: "0x910f30cbc7f601f75a5141a01265cd47c62d468707c5e1aecb32a18f448cb25a",
|
|
1446
|
-
upgradeCap: "0xdf0ffbae1ea5bb25fbca5efba433dcf00c7cced65679af2f04728901275c6157"
|
|
1447
|
-
},
|
|
1448
|
-
switchboard: { id: "", upgradeCap: "" },
|
|
1449
|
-
xOracle: {
|
|
1450
|
-
id: "0x1478a432123e4b3d61878b629f2c692969fdb375644f1251cd278a4b1e7d7cd6",
|
|
1451
|
-
upgradeCap: "0x0f928a6b2e26b73330fecaf9b44acfc9800a4a9794d6415c2a3153bc70e3c1f0"
|
|
1452
|
-
},
|
|
1453
|
-
testCoin: { id: "", upgradeCap: "" }
|
|
1543
|
+
} else if (retries < maxRetries) {
|
|
1544
|
+
retries++;
|
|
1545
|
+
const delay = retryDelayInMs * Math.pow(backoffFactor, retries);
|
|
1546
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
1547
|
+
return tryRequest();
|
|
1548
|
+
} else {
|
|
1549
|
+
console.error("Maximum retries reached");
|
|
1550
|
+
return null;
|
|
1454
1551
|
}
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1552
|
+
};
|
|
1553
|
+
return tryRequest();
|
|
1554
|
+
};
|
|
1555
|
+
|
|
1556
|
+
// src/utils/indexer.ts
|
|
1557
|
+
async function callMethodWithIndexerFallback(method, context, ...args) {
|
|
1558
|
+
const indexer = args[args.length - 1];
|
|
1559
|
+
if (indexer) {
|
|
1560
|
+
try {
|
|
1561
|
+
return await method.apply(context, args);
|
|
1562
|
+
} catch (e) {
|
|
1563
|
+
console.warn(`Indexer requests failed: ${e}. Retrying without indexer..`);
|
|
1564
|
+
return await method.apply(context, [...args.slice(0, -1), false]);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
return await method.apply(context, args);
|
|
1568
|
+
}
|
|
1569
|
+
function withIndexerFallback(method) {
|
|
1570
|
+
return (...args) => {
|
|
1571
|
+
return callMethodWithIndexerFallback(method, this, ...args);
|
|
1572
|
+
};
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
// src/models/scallopCache.ts
|
|
1576
|
+
var ScallopCache = class {
|
|
1577
|
+
constructor(suiKit, walletAddress, cacheOptions, tokenBucket, queryClient) {
|
|
1578
|
+
this.queryClient = queryClient ?? new QueryClient(cacheOptions ?? DEFAULT_CACHE_OPTIONS);
|
|
1579
|
+
this._suiKit = suiKit;
|
|
1580
|
+
this.tokenBucket = tokenBucket ?? new TokenBucket(DEFAULT_TOKENS_PER_INTERVAL, DEFAULT_INTERVAL_IN_MS);
|
|
1581
|
+
this.walletAddress = walletAddress ?? suiKit.currentAddress();
|
|
1582
|
+
}
|
|
1583
|
+
get suiKit() {
|
|
1584
|
+
if (!this._suiKit) {
|
|
1585
|
+
throw new Error("SuiKit instance is not initialized");
|
|
1586
|
+
}
|
|
1587
|
+
return this._suiKit;
|
|
1588
|
+
}
|
|
1589
|
+
get client() {
|
|
1590
|
+
return this.suiKit.client();
|
|
1591
|
+
}
|
|
1592
|
+
/**
|
|
1593
|
+
* @description Invalidate cache based on the refetchType parameter
|
|
1594
|
+
* @param refetchType Determines the type of queries to be refetched. Defaults to `active`.
|
|
1595
|
+
*
|
|
1596
|
+
* - `active`: Only queries that match the refetch predicate and are actively being rendered via useQuery and related functions will be refetched in the background.
|
|
1597
|
+
* - `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.
|
|
1598
|
+
* - `all`: All queries that match the refetch predicate will be refetched in the background.
|
|
1599
|
+
* - `none`: No queries will be refetched. Queries that match the refetch predicate will only be marked as invalid.
|
|
1600
|
+
*/
|
|
1601
|
+
async invalidateAllCache() {
|
|
1602
|
+
return Object.values(queryKeys.rpc).map(
|
|
1603
|
+
(t) => this.queryClient.invalidateQueries({
|
|
1604
|
+
queryKey: t(),
|
|
1605
|
+
type: "all"
|
|
1606
|
+
})
|
|
1607
|
+
);
|
|
1608
|
+
}
|
|
1609
|
+
/**
|
|
1610
|
+
* @description Provides cache for inspectTxn of the SuiKit.
|
|
1611
|
+
* @param QueryInspectTxnParams
|
|
1612
|
+
* @param txBlock
|
|
1613
|
+
* @returns Promise<DevInspectResults>
|
|
1614
|
+
*/
|
|
1615
|
+
async queryInspectTxn({
|
|
1616
|
+
queryTarget,
|
|
1617
|
+
args,
|
|
1618
|
+
typeArgs
|
|
1619
|
+
}) {
|
|
1620
|
+
const txBlock = new SuiTxBlock();
|
|
1621
|
+
txBlock.moveCall(queryTarget, args, typeArgs);
|
|
1622
|
+
const query = await this.queryClient.fetchQuery({
|
|
1623
|
+
queryKey: queryKeys.rpc.getInspectTxn(queryTarget, args, typeArgs),
|
|
1624
|
+
queryFn: async () => {
|
|
1625
|
+
return await callWithRateLimit(
|
|
1626
|
+
this.tokenBucket,
|
|
1627
|
+
() => this.suiKit.inspectTxn(txBlock)
|
|
1628
|
+
);
|
|
1629
|
+
}
|
|
1630
|
+
});
|
|
1631
|
+
return query;
|
|
1632
|
+
}
|
|
1633
|
+
/**
|
|
1634
|
+
* @description Provides cache for getObject of the SuiKit.
|
|
1635
|
+
* @param objectId
|
|
1636
|
+
* @param QueryObjectParams
|
|
1637
|
+
* @returns Promise<SuiObjectResponse>
|
|
1638
|
+
*/
|
|
1639
|
+
async queryGetObject(objectId, options) {
|
|
1640
|
+
return this.queryClient.fetchQuery({
|
|
1641
|
+
queryKey: queryKeys.rpc.getObject(objectId, this.walletAddress, options),
|
|
1642
|
+
queryFn: async () => {
|
|
1643
|
+
return await callWithRateLimit(
|
|
1644
|
+
this.tokenBucket,
|
|
1645
|
+
() => this.client.getObject({
|
|
1646
|
+
id: objectId,
|
|
1647
|
+
options
|
|
1648
|
+
})
|
|
1649
|
+
);
|
|
1519
1650
|
}
|
|
1520
|
-
}
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
// '0xf21b0ed043c9bb70842c0129159f4943dbcc3c9ef2f2f808af65f8be25cfd20e',
|
|
1544
|
-
authorizedWitnessList: "0x9d6223dc52015b8a3986a573590ef2af8f1b8f3e4685513888c052f001b87e7f",
|
|
1545
|
-
version: "0x1bd4b7285f72e11c316b828c7c47b3f4da18dcec9f9b3dba6d8629cbb6f93e5e"
|
|
1546
|
-
},
|
|
1547
|
-
vesca: {
|
|
1548
|
-
id: "0xb15b6e0cdd85afb5028bea851dd249405e734d800a259147bbc24980629723a4",
|
|
1549
|
-
object: "0xb15b6e0cdd85afb5028bea851dd249405e734d800a259147bbc24980629723a4",
|
|
1550
|
-
adminCap: "0x8ffa76135c5b85c5fbd73a6448a4a733d826cb63a267ab817656acb77c72d4a5",
|
|
1551
|
-
tableId: "0xe3153b2bf124be0b86cb8bd468346a861efd0da52fc42197b54d2f616488a311",
|
|
1552
|
-
table: "0x611cb8d9d4d90867467b5ebdf4cc447a0047ed5b01334a28a29fcfe733e3d609",
|
|
1553
|
-
treasury: "0xe8c112c09b88158dc6c8e23d1fbae5b3c7136cdee54b7dafc08e65db28c4a5bc",
|
|
1554
|
-
config: "0xe0a2ff281e73c1d53cfa85807080f87e833e4f1a7f93dcf8800b3865269a76b9"
|
|
1555
|
-
},
|
|
1556
|
-
loyaltyProgram: {
|
|
1557
|
-
id: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
1558
|
-
object: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
1559
|
-
rewardPool: "0xf9c090492ef476bd542109d0913ffe871cbfa28578b7114eca2a8c0e5671786f",
|
|
1560
|
-
userRewardTableId: "0x748a80395849ed37db1b0e14f2ab5d1d96458d2359ab3a84eb079d0f4ac7cf2e"
|
|
1561
|
-
},
|
|
1562
|
-
scoin: {
|
|
1563
|
-
id: "0xad2ca2aa5089df94bb2d444d5eb3520378c2f2dfb3a0bd2a2c994145ac4b0a53",
|
|
1564
|
-
coins: {
|
|
1565
|
-
ssui: {
|
|
1566
|
-
coinType: "0xfac769100bccc0caebcf4f4e2d00ac2f8883f07f724be28940df90605f5e7e9a::scallop_sui::SCALLOP_SUI",
|
|
1567
|
-
treasury: "0x9cb4551b36c17d37e19d700147fa819ea1c487ff8bcf18374de2cceb2e9d4845"
|
|
1568
|
-
},
|
|
1569
|
-
scetus: {
|
|
1570
|
-
coinType: "0x8b71e6d323ed78515af2bead13bf3d0da1562ba4a99234eb7c4f14fd39ef0427::scallop_cetus::SCALLOP_CETUS",
|
|
1571
|
-
treasury: "0xd786f4b2d26278cc7911a3445b1b085eab60f269ef9dbb6b87e803d52f155003"
|
|
1572
|
-
},
|
|
1573
|
-
ssca: {
|
|
1574
|
-
coinType: "0x0a9d3c6c9af9f6e8def82921541bcbd17f73ed31bed3adcb684f2a4c267e42f0::scallop_sca::SCALLOP_SCA",
|
|
1575
|
-
treasury: "0xe818636d1d6c46d6ea1a2dce9d94696d7cbc18ce27451b603eeaa47aba8d75e0"
|
|
1576
|
-
},
|
|
1577
|
-
swusdc: {
|
|
1578
|
-
coinType: "0xaedc3ab75db8680b81a755015fa90124d217be93457b893c05bac033817defaf::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
|
|
1579
|
-
treasury: "0xfc6971648f867f7fd6928d1b873af71577e2eaf2c7543ef8bc82c431d833ae78"
|
|
1580
|
-
},
|
|
1581
|
-
swusdt: {
|
|
1582
|
-
coinType: "0xbf02fc87ddc104b342ad8414c85ceadf5b0c823c055a06fb0ed776272c01a52a::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
|
|
1583
|
-
treasury: "0xb9593e2c3a0ba796ee815012b75ae46468ea78cda0188b9ac6816efe65503521"
|
|
1584
|
-
},
|
|
1585
|
-
sweth: {
|
|
1586
|
-
coinType: "0x27d54f43e3eda701be56b82e5756e41c84467cd202f5cf713d5f9e45a9f1b6bc::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
|
|
1587
|
-
treasury: "0x032b4c8fac94c038dbe986f7587e9b1e4ef580b5ee06d2ef249d85459b7ef05d"
|
|
1588
|
-
},
|
|
1589
|
-
safsui: {
|
|
1590
|
-
coinType: "0xb75b46d975d8d80670b53a6bee90baaa8ce2e0b7d397f079447d641eef6b44ad::scallop_af_sui::SCALLOP_AF_SUI",
|
|
1591
|
-
treasury: "0x21450ef0570ef3d224ffa3b873ab802e439ece7b93cc7efad10ae0c1e3b3fcfe"
|
|
1592
|
-
},
|
|
1593
|
-
shasui: {
|
|
1594
|
-
coinType: "0xd973a723874e2c7cde196602a79155a1343a933f8cf87d9b1bb7408bc1acbc58::scallop_ha_sui::SCALLOP_HA_SUI",
|
|
1595
|
-
treasury: "0xf822fc1402207e47d2e3ba8ff6e1e594bf1de777dc5ebd2744619cd2726e3b0d"
|
|
1596
|
-
},
|
|
1597
|
-
svsui: {
|
|
1598
|
-
coinType: "0x97023a317320c4498cc4cd239dd02fd30c28246e5e8f81325d63f2bd8d70f6b3::scallop_v_sui::SCALLOP_V_SUI",
|
|
1599
|
-
treasury: "0x327114f0bf3559d7e2de10282147ed76a236c7c6775029165c4db09a6062ead6\u0192"
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
/**
|
|
1654
|
+
* @description Provides cache for getObjects of the SuiKit.
|
|
1655
|
+
* @param objectIds
|
|
1656
|
+
* @returns Promise<SuiObjectData[]>
|
|
1657
|
+
*/
|
|
1658
|
+
async queryGetObjects(objectIds, options = {
|
|
1659
|
+
showContent: true
|
|
1660
|
+
}) {
|
|
1661
|
+
if (objectIds.length === 0)
|
|
1662
|
+
return [];
|
|
1663
|
+
return this.queryClient.fetchQuery({
|
|
1664
|
+
queryKey: queryKeys.rpc.getObjects(
|
|
1665
|
+
objectIds,
|
|
1666
|
+
this.walletAddress,
|
|
1667
|
+
options
|
|
1668
|
+
),
|
|
1669
|
+
queryFn: async () => {
|
|
1670
|
+
return await callWithRateLimit(
|
|
1671
|
+
this.tokenBucket,
|
|
1672
|
+
() => this.suiKit.getObjects(objectIds, options)
|
|
1673
|
+
);
|
|
1600
1674
|
}
|
|
1601
|
-
}
|
|
1675
|
+
});
|
|
1676
|
+
}
|
|
1677
|
+
/**
|
|
1678
|
+
* @description Provides cache for getOwnedObjects of the SuiKit.
|
|
1679
|
+
* @param input
|
|
1680
|
+
* @returns Promise<PaginatedObjectsResponse>
|
|
1681
|
+
*/
|
|
1682
|
+
async queryGetOwnedObjects(input) {
|
|
1683
|
+
return this.queryClient.fetchQuery({
|
|
1684
|
+
queryKey: queryKeys.rpc.getOwnedObjects(input),
|
|
1685
|
+
queryFn: async () => {
|
|
1686
|
+
return await callWithRateLimit(
|
|
1687
|
+
this.tokenBucket,
|
|
1688
|
+
() => this.client.getOwnedObjects(input)
|
|
1689
|
+
);
|
|
1690
|
+
}
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1693
|
+
async queryGetDynamicFields(input) {
|
|
1694
|
+
return this.queryClient.fetchQuery({
|
|
1695
|
+
queryKey: queryKeys.rpc.getDynamicFields(input),
|
|
1696
|
+
queryFn: async () => {
|
|
1697
|
+
return await callWithRateLimit(
|
|
1698
|
+
this.tokenBucket,
|
|
1699
|
+
() => this.client.getDynamicFields(input)
|
|
1700
|
+
);
|
|
1701
|
+
}
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
async queryGetDynamicFieldObject(input) {
|
|
1705
|
+
return this.queryClient.fetchQuery({
|
|
1706
|
+
queryKey: queryKeys.rpc.getDynamicFieldObject(input),
|
|
1707
|
+
queryFn: async () => {
|
|
1708
|
+
return await callWithRateLimit(
|
|
1709
|
+
this.tokenBucket,
|
|
1710
|
+
() => this.client.getDynamicFieldObject(input)
|
|
1711
|
+
);
|
|
1712
|
+
}
|
|
1713
|
+
});
|
|
1714
|
+
}
|
|
1715
|
+
async queryGetAllCoinBalances(owner) {
|
|
1716
|
+
return this.queryClient.fetchQuery({
|
|
1717
|
+
queryKey: queryKeys.rpc.getAllCoinBalances(owner),
|
|
1718
|
+
queryFn: async () => {
|
|
1719
|
+
const allBalances = await callWithRateLimit(
|
|
1720
|
+
this.tokenBucket,
|
|
1721
|
+
() => this.client.getAllBalances({ owner })
|
|
1722
|
+
);
|
|
1723
|
+
if (!allBalances)
|
|
1724
|
+
return {};
|
|
1725
|
+
const balances = allBalances.reduce(
|
|
1726
|
+
(acc, coinBalance) => {
|
|
1727
|
+
if (coinBalance.totalBalance !== "0") {
|
|
1728
|
+
acc[normalizeStructTag2(coinBalance.coinType)] = coinBalance.totalBalance;
|
|
1729
|
+
}
|
|
1730
|
+
return acc;
|
|
1731
|
+
},
|
|
1732
|
+
{}
|
|
1733
|
+
);
|
|
1734
|
+
return balances;
|
|
1735
|
+
}
|
|
1736
|
+
});
|
|
1737
|
+
}
|
|
1738
|
+
async queryGetCoinBalance(input) {
|
|
1739
|
+
if (!input.coinType)
|
|
1740
|
+
return "0";
|
|
1741
|
+
return (await this.queryGetAllCoinBalances(input.owner) || {})[normalizeStructTag2(input.coinType)] ?? "0";
|
|
1602
1742
|
}
|
|
1603
1743
|
};
|
|
1604
1744
|
|
|
1605
1745
|
// src/models/scallopAddress.ts
|
|
1746
|
+
import axios from "axios";
|
|
1606
1747
|
var EMPTY_ADDRESSES = {
|
|
1607
1748
|
core: {
|
|
1608
1749
|
version: "",
|
|
@@ -2264,54 +2405,137 @@ var ScallopAddress = class {
|
|
|
2264
2405
|
}
|
|
2265
2406
|
};
|
|
2266
2407
|
|
|
2267
|
-
// src/models/scallopClient.ts
|
|
2268
|
-
import { normalizeSuiAddress as normalizeSuiAddress3 } from "@mysten/sui/utils";
|
|
2269
|
-
import { SuiKit as SuiKit6 } from "@scallop-io/sui-kit";
|
|
2270
|
-
|
|
2271
|
-
// src/models/scallopUtils.ts
|
|
2272
|
-
import { SUI_TYPE_ARG, normalizeStructTag as normalizeStructTag6 } from "@mysten/sui/utils";
|
|
2273
|
-
import { SuiKit as SuiKit2 } from "@scallop-io/sui-kit";
|
|
2274
|
-
import { SuiPriceServiceConnection } from "@pythnetwork/pyth-sui-js";
|
|
2275
|
-
|
|
2276
|
-
// src/queries/coreQuery.ts
|
|
2277
|
-
import { normalizeStructTag as normalizeStructTag3 } from "@mysten/sui/utils";
|
|
2278
|
-
import BigNumber2 from "bignumber.js";
|
|
2279
|
-
|
|
2280
|
-
// src/queries/supplyLimit.ts
|
|
2281
|
-
import { z as zod } from "zod";
|
|
2282
|
-
var supplyLimitZod = zod.object({
|
|
2283
|
-
dataType: zod.string(),
|
|
2284
|
-
type: zod.string(),
|
|
2285
|
-
hasPublicTransfer: zod.boolean(),
|
|
2286
|
-
fields: zod.object({
|
|
2287
|
-
id: zod.object({
|
|
2288
|
-
id: zod.string()
|
|
2289
|
-
}),
|
|
2290
|
-
name: zod.object({
|
|
2291
|
-
type: zod.string()
|
|
2292
|
-
}),
|
|
2293
|
-
value: zod.string()
|
|
2294
|
-
})
|
|
2295
|
-
});
|
|
2296
|
-
var SUPPLY_LIMIT_KEY = "0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey";
|
|
2297
|
-
var getSupplyLimit = async (utils, poolName) => {
|
|
2298
|
-
const poolCoinType = utils.parseCoinType(poolName).slice(2);
|
|
2299
|
-
const marketObject = utils.address.get("core.market");
|
|
2300
|
-
if (!marketObject)
|
|
2301
|
-
return null;
|
|
2302
|
-
const object = await utils.cache.queryGetDynamicFieldObject({
|
|
2303
|
-
parentId: marketObject,
|
|
2304
|
-
name: {
|
|
2305
|
-
type: SUPPLY_LIMIT_KEY,
|
|
2306
|
-
value: poolCoinType
|
|
2307
|
-
}
|
|
2308
|
-
});
|
|
2309
|
-
const parsedData = supplyLimitZod.safeParse(object?.data?.content);
|
|
2310
|
-
if (!parsedData.success)
|
|
2311
|
-
return null;
|
|
2312
|
-
return parsedData.data.fields.value;
|
|
2313
|
-
};
|
|
2314
|
-
|
|
2408
|
+
// src/models/scallopClient.ts
|
|
2409
|
+
import { normalizeSuiAddress as normalizeSuiAddress3 } from "@mysten/sui/utils";
|
|
2410
|
+
import { SuiKit as SuiKit6 } from "@scallop-io/sui-kit";
|
|
2411
|
+
|
|
2412
|
+
// src/models/scallopUtils.ts
|
|
2413
|
+
import { SUI_TYPE_ARG, normalizeStructTag as normalizeStructTag6 } from "@mysten/sui/utils";
|
|
2414
|
+
import { SuiKit as SuiKit2 } from "@scallop-io/sui-kit";
|
|
2415
|
+
import { SuiPriceServiceConnection } from "@pythnetwork/pyth-sui-js";
|
|
2416
|
+
|
|
2417
|
+
// src/queries/coreQuery.ts
|
|
2418
|
+
import { normalizeStructTag as normalizeStructTag3 } from "@mysten/sui/utils";
|
|
2419
|
+
import BigNumber2 from "bignumber.js";
|
|
2420
|
+
|
|
2421
|
+
// src/queries/supplyLimit.ts
|
|
2422
|
+
import { z as zod } from "zod";
|
|
2423
|
+
var supplyLimitZod = zod.object({
|
|
2424
|
+
dataType: zod.string(),
|
|
2425
|
+
type: zod.string(),
|
|
2426
|
+
hasPublicTransfer: zod.boolean(),
|
|
2427
|
+
fields: zod.object({
|
|
2428
|
+
id: zod.object({
|
|
2429
|
+
id: zod.string()
|
|
2430
|
+
}),
|
|
2431
|
+
name: zod.object({
|
|
2432
|
+
type: zod.string()
|
|
2433
|
+
}),
|
|
2434
|
+
value: zod.string()
|
|
2435
|
+
})
|
|
2436
|
+
});
|
|
2437
|
+
var SUPPLY_LIMIT_KEY = "0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::SupplyLimitKey";
|
|
2438
|
+
var getSupplyLimit = async (utils, poolName) => {
|
|
2439
|
+
const poolCoinType = utils.parseCoinType(poolName).slice(2);
|
|
2440
|
+
const marketObject = utils.address.get("core.market");
|
|
2441
|
+
if (!marketObject)
|
|
2442
|
+
return null;
|
|
2443
|
+
const object = await utils.cache.queryGetDynamicFieldObject({
|
|
2444
|
+
parentId: marketObject,
|
|
2445
|
+
name: {
|
|
2446
|
+
type: SUPPLY_LIMIT_KEY,
|
|
2447
|
+
value: poolCoinType
|
|
2448
|
+
}
|
|
2449
|
+
});
|
|
2450
|
+
const parsedData = supplyLimitZod.safeParse(object?.data?.content);
|
|
2451
|
+
if (!parsedData.success)
|
|
2452
|
+
return null;
|
|
2453
|
+
return parsedData.data.fields.value;
|
|
2454
|
+
};
|
|
2455
|
+
|
|
2456
|
+
// src/queries/isolatedAsset.ts
|
|
2457
|
+
import { z as zod2 } from "zod";
|
|
2458
|
+
var isolatedAssetZod = zod2.object({
|
|
2459
|
+
dataType: zod2.string(),
|
|
2460
|
+
type: zod2.string(),
|
|
2461
|
+
hasPublicTransfer: zod2.boolean(),
|
|
2462
|
+
fields: zod2.object({
|
|
2463
|
+
id: zod2.object({
|
|
2464
|
+
id: zod2.string()
|
|
2465
|
+
}),
|
|
2466
|
+
name: zod2.object({
|
|
2467
|
+
type: zod2.string()
|
|
2468
|
+
}),
|
|
2469
|
+
value: zod2.boolean()
|
|
2470
|
+
})
|
|
2471
|
+
});
|
|
2472
|
+
var getIsolatedAssets = async (address) => {
|
|
2473
|
+
try {
|
|
2474
|
+
const marketObject = address.get("core.market");
|
|
2475
|
+
const protocolObject = address.get("core.packages.protocol.id");
|
|
2476
|
+
const ISOLATED_ASSET_KEY = `${protocolObject}::market_dynamic_keys::IsolatedAssetKey`;
|
|
2477
|
+
const isolatedAssets = [];
|
|
2478
|
+
if (!marketObject)
|
|
2479
|
+
return isolatedAssets;
|
|
2480
|
+
let hasNextPage = false;
|
|
2481
|
+
let nextCursor = null;
|
|
2482
|
+
const isIsolatedDynamicField = (dynamicField) => {
|
|
2483
|
+
return dynamicField.name.type === ISOLATED_ASSET_KEY;
|
|
2484
|
+
};
|
|
2485
|
+
do {
|
|
2486
|
+
const response = await address.cache.queryGetDynamicFields({
|
|
2487
|
+
parentId: marketObject,
|
|
2488
|
+
cursor: nextCursor,
|
|
2489
|
+
limit: 10
|
|
2490
|
+
});
|
|
2491
|
+
if (!response)
|
|
2492
|
+
break;
|
|
2493
|
+
const isolatedAssetCoinTypes = response.data.filter(isIsolatedDynamicField).map(({ name }) => `0x${name.value.type.name}`);
|
|
2494
|
+
isolatedAssets.push(...isolatedAssetCoinTypes);
|
|
2495
|
+
if (response && response.hasNextPage && response.nextCursor) {
|
|
2496
|
+
hasNextPage = true;
|
|
2497
|
+
nextCursor = response.nextCursor;
|
|
2498
|
+
} else {
|
|
2499
|
+
hasNextPage = false;
|
|
2500
|
+
}
|
|
2501
|
+
} while (hasNextPage);
|
|
2502
|
+
return isolatedAssets;
|
|
2503
|
+
} catch (e) {
|
|
2504
|
+
console.error(e);
|
|
2505
|
+
return [];
|
|
2506
|
+
}
|
|
2507
|
+
};
|
|
2508
|
+
var isIsolatedAsset = async (utils, coinName) => {
|
|
2509
|
+
try {
|
|
2510
|
+
const marketObject = utils.address.get("core.market");
|
|
2511
|
+
const protocolObject = utils.address.get("core.packages.protocol.id");
|
|
2512
|
+
const ISOLATED_ASSET_KEY = `${protocolObject}::market_dynamic_keys::IsolatedAssetKey`;
|
|
2513
|
+
const cachedData = utils.address.cache.queryClient.getQueryData([
|
|
2514
|
+
"getDynamicFields",
|
|
2515
|
+
marketObject
|
|
2516
|
+
]);
|
|
2517
|
+
if (cachedData) {
|
|
2518
|
+
const coinType2 = utils.parseCoinType(coinName);
|
|
2519
|
+
return cachedData.includes(coinType2);
|
|
2520
|
+
}
|
|
2521
|
+
const coinType = utils.parseCoinType(coinName).slice(2);
|
|
2522
|
+
const object = await utils.cache.queryGetDynamicFieldObject({
|
|
2523
|
+
parentId: marketObject,
|
|
2524
|
+
name: {
|
|
2525
|
+
type: ISOLATED_ASSET_KEY,
|
|
2526
|
+
value: coinType
|
|
2527
|
+
}
|
|
2528
|
+
});
|
|
2529
|
+
const parsedData = isolatedAssetZod.safeParse(object?.data?.content);
|
|
2530
|
+
if (!parsedData.success)
|
|
2531
|
+
return false;
|
|
2532
|
+
return parsedData.data.fields.value;
|
|
2533
|
+
} catch (e) {
|
|
2534
|
+
console.error(e);
|
|
2535
|
+
return false;
|
|
2536
|
+
}
|
|
2537
|
+
};
|
|
2538
|
+
|
|
2315
2539
|
// src/queries/coreQuery.ts
|
|
2316
2540
|
var queryMarket = async (query, indexer = false) => {
|
|
2317
2541
|
const coinPrices = await query.utils.getCoinPrices();
|
|
@@ -2396,8 +2620,8 @@ var queryMarket = async (query, indexer = false) => {
|
|
|
2396
2620
|
borrowFee: parsedMarketPoolData.borrowFee,
|
|
2397
2621
|
marketCoinSupplyAmount: parsedMarketPoolData.marketCoinSupplyAmount,
|
|
2398
2622
|
minBorrowAmount: parsedMarketPoolData.minBorrowAmount,
|
|
2399
|
-
|
|
2400
|
-
isIsolated: false,
|
|
2623
|
+
isIsolated: await isIsolatedAsset(query.utils, poolCoinName),
|
|
2624
|
+
// isIsolated: false,
|
|
2401
2625
|
maxSupplyCoin,
|
|
2402
2626
|
...calculatedMarketPoolData
|
|
2403
2627
|
};
|
|
@@ -2436,6 +2660,7 @@ var queryMarket = async (query, indexer = false) => {
|
|
|
2436
2660
|
liquidationDiscount: parsedMarketCollateralData.liquidationDiscount,
|
|
2437
2661
|
liquidationPanelty: parsedMarketCollateralData.liquidationPanelty,
|
|
2438
2662
|
liquidationReserveFactor: parsedMarketCollateralData.liquidationReserveFactor,
|
|
2663
|
+
isIsolated: await isIsolatedAsset(query.utils, collateralCoinName),
|
|
2439
2664
|
...calculatedMarketCollateralData
|
|
2440
2665
|
};
|
|
2441
2666
|
}
|
|
@@ -2483,79 +2708,73 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
|
|
|
2483
2708
|
return marketPools;
|
|
2484
2709
|
};
|
|
2485
2710
|
var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, coinPrice) => {
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
name: {
|
|
2512
|
-
type: "0x1::type_name::TypeName",
|
|
2513
|
-
value: {
|
|
2514
|
-
name: coinType.substring(2)
|
|
2515
|
-
}
|
|
2711
|
+
try {
|
|
2712
|
+
coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
|
|
2713
|
+
if (indexer) {
|
|
2714
|
+
const marketPoolIndexer = await query.indexer.getMarketPool(poolCoinName);
|
|
2715
|
+
marketPoolIndexer.coinPrice = coinPrice || marketPoolIndexer.coinPrice;
|
|
2716
|
+
marketPoolIndexer.coinWrappedType = query.utils.getCoinWrappedType(
|
|
2717
|
+
marketPoolIndexer.coinName
|
|
2718
|
+
);
|
|
2719
|
+
return marketPoolIndexer;
|
|
2720
|
+
}
|
|
2721
|
+
const marketId = query.address.get("core.market");
|
|
2722
|
+
marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
|
|
2723
|
+
showContent: true
|
|
2724
|
+
}))?.data;
|
|
2725
|
+
if (!(marketObject && marketObject.content?.dataType === "moveObject"))
|
|
2726
|
+
throw new Error(`Failed to fetch marketObject`);
|
|
2727
|
+
const fields = marketObject.content.fields;
|
|
2728
|
+
const coinType = query.utils.parseCoinType(poolCoinName);
|
|
2729
|
+
const balanceSheetParentId = fields.vault.fields.balance_sheets.fields.table.fields.id.id;
|
|
2730
|
+
const balanceSheetDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2731
|
+
parentId: balanceSheetParentId,
|
|
2732
|
+
name: {
|
|
2733
|
+
type: "0x1::type_name::TypeName",
|
|
2734
|
+
value: {
|
|
2735
|
+
name: coinType.substring(2)
|
|
2516
2736
|
}
|
|
2517
|
-
});
|
|
2518
|
-
if (!balanceSheetDynamicFieldObjectResponse)
|
|
2519
|
-
return void 0;
|
|
2520
|
-
const balanceSheetDynamicFieldObject = balanceSheetDynamicFieldObjectResponse.data;
|
|
2521
|
-
if (balanceSheetDynamicFieldObject && balanceSheetDynamicFieldObject.content && "fields" in balanceSheetDynamicFieldObject.content) {
|
|
2522
|
-
const dynamicFields = balanceSheetDynamicFieldObject.content.fields;
|
|
2523
|
-
balanceSheet = dynamicFields.value.fields;
|
|
2524
2737
|
}
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2738
|
+
});
|
|
2739
|
+
const balanceSheetDynamicFieldObject = balanceSheetDynamicFieldObjectResponse?.data;
|
|
2740
|
+
if (!(balanceSheetDynamicFieldObject && balanceSheetDynamicFieldObject.content && "fields" in balanceSheetDynamicFieldObject.content))
|
|
2741
|
+
throw new Error(
|
|
2742
|
+
`Failed to fetch balanceSheetDynamicFieldObject for ${poolCoinName}: ${balanceSheetDynamicFieldObjectResponse?.error?.code.toString()}`
|
|
2743
|
+
);
|
|
2744
|
+
const balanceSheet = balanceSheetDynamicFieldObject.content.fields.value.fields;
|
|
2745
|
+
const borrowIndexParentId = fields.borrow_dynamics.fields.table.fields.id.id;
|
|
2746
|
+
const borrowIndexDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2747
|
+
parentId: borrowIndexParentId,
|
|
2748
|
+
name: {
|
|
2749
|
+
type: "0x1::type_name::TypeName",
|
|
2750
|
+
value: {
|
|
2751
|
+
name: coinType.substring(2)
|
|
2533
2752
|
}
|
|
2534
|
-
});
|
|
2535
|
-
if (!borrowIndexDynamicFieldObjectResponse)
|
|
2536
|
-
return void 0;
|
|
2537
|
-
const borrowIndexDynamicFieldObject = borrowIndexDynamicFieldObjectResponse.data;
|
|
2538
|
-
if (borrowIndexDynamicFieldObject && borrowIndexDynamicFieldObject.content && "fields" in borrowIndexDynamicFieldObject.content) {
|
|
2539
|
-
const dynamicFields = borrowIndexDynamicFieldObject.content.fields;
|
|
2540
|
-
borrowIndex = dynamicFields.value.fields;
|
|
2541
2753
|
}
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2754
|
+
});
|
|
2755
|
+
const borrowIndexDynamicFieldObject = borrowIndexDynamicFieldObjectResponse?.data;
|
|
2756
|
+
if (!(borrowIndexDynamicFieldObject && borrowIndexDynamicFieldObject.content && "fields" in borrowIndexDynamicFieldObject.content))
|
|
2757
|
+
throw new Error(
|
|
2758
|
+
`Failed to fetch borrowIndexDynamicFieldObject for ${poolCoinName}`
|
|
2759
|
+
);
|
|
2760
|
+
const borrowIndex = borrowIndexDynamicFieldObject.content.fields.value.fields;
|
|
2761
|
+
const interestModelParentId = fields.interest_models.fields.table.fields.id.id;
|
|
2762
|
+
const interestModelDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2763
|
+
parentId: interestModelParentId,
|
|
2764
|
+
name: {
|
|
2765
|
+
type: "0x1::type_name::TypeName",
|
|
2766
|
+
value: {
|
|
2767
|
+
name: coinType.substring(2)
|
|
2550
2768
|
}
|
|
2551
|
-
});
|
|
2552
|
-
if (!interestModelDynamicFieldObjectResponse)
|
|
2553
|
-
return void 0;
|
|
2554
|
-
const interestModelDynamicFieldObject = interestModelDynamicFieldObjectResponse.data;
|
|
2555
|
-
if (interestModelDynamicFieldObject && interestModelDynamicFieldObject.content && "fields" in interestModelDynamicFieldObject.content) {
|
|
2556
|
-
const dynamicFields = interestModelDynamicFieldObject.content.fields;
|
|
2557
|
-
interestModel = dynamicFields.value.fields;
|
|
2558
2769
|
}
|
|
2770
|
+
});
|
|
2771
|
+
const interestModelDynamicFieldObject = interestModelDynamicFieldObjectResponse?.data;
|
|
2772
|
+
if (!(interestModelDynamicFieldObject && interestModelDynamicFieldObject.content && "fields" in interestModelDynamicFieldObject.content))
|
|
2773
|
+
throw new Error(
|
|
2774
|
+
`Failed to fetch interestModelDynamicFieldObject for ${poolCoinName}: ${interestModelDynamicFieldObject}`
|
|
2775
|
+
);
|
|
2776
|
+
const interestModel = interestModelDynamicFieldObject.content.fields.value.fields;
|
|
2777
|
+
const getBorrowFee = async () => {
|
|
2559
2778
|
const borrowFeeDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2560
2779
|
parentId: marketId,
|
|
2561
2780
|
name: {
|
|
@@ -2567,16 +2786,11 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2567
2786
|
}
|
|
2568
2787
|
}
|
|
2569
2788
|
});
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
borrowFeeRate = dynamicFields.value.fields;
|
|
2576
|
-
}
|
|
2577
|
-
}
|
|
2578
|
-
}
|
|
2579
|
-
if (balanceSheet && borrowIndex && interestModel && (USE_TEST_ADDRESS || borrowFeeRate)) {
|
|
2789
|
+
const borrowFeeDynamicFieldObject = borrowFeeDynamicFieldObjectResponse?.data;
|
|
2790
|
+
if (!(borrowFeeDynamicFieldObject && borrowFeeDynamicFieldObject.content && "fields" in borrowFeeDynamicFieldObject.content))
|
|
2791
|
+
return { value: "0" };
|
|
2792
|
+
return borrowFeeDynamicFieldObject.content.fields.value.fields;
|
|
2793
|
+
};
|
|
2580
2794
|
const parsedMarketPoolData = parseOriginMarketPoolData({
|
|
2581
2795
|
type: interestModel.type.fields,
|
|
2582
2796
|
maxBorrowRate: interestModel.max_borrow_rate.fields,
|
|
@@ -2590,7 +2804,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2590
2804
|
reserve: balanceSheet.revenue,
|
|
2591
2805
|
reserveFactor: interestModel.revenue_factor.fields,
|
|
2592
2806
|
borrowWeight: interestModel.borrow_weight.fields,
|
|
2593
|
-
borrowFeeRate:
|
|
2807
|
+
borrowFeeRate: await getBorrowFee(),
|
|
2594
2808
|
baseBorrowRatePerSec: interestModel.base_borrow_rate_per_sec.fields,
|
|
2595
2809
|
borrowRateOnHighKink: interestModel.borrow_rate_on_high_kink.fields,
|
|
2596
2810
|
borrowRateOnMidKink: interestModel.borrow_rate_on_mid_kink.fields,
|
|
@@ -2606,7 +2820,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2606
2820
|
const maxSupplyCoin = BigNumber2(
|
|
2607
2821
|
await getSupplyLimit(query.utils, poolCoinName) ?? "0"
|
|
2608
2822
|
).shiftedBy(-coinDecimal).toNumber();
|
|
2609
|
-
|
|
2823
|
+
return {
|
|
2610
2824
|
coinName: poolCoinName,
|
|
2611
2825
|
symbol: query.utils.parseSymbol(poolCoinName),
|
|
2612
2826
|
coinType: query.utils.parseCoinType(poolCoinName),
|
|
@@ -2625,12 +2839,13 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2625
2839
|
marketCoinSupplyAmount: parsedMarketPoolData.marketCoinSupplyAmount,
|
|
2626
2840
|
minBorrowAmount: parsedMarketPoolData.minBorrowAmount,
|
|
2627
2841
|
maxSupplyCoin,
|
|
2628
|
-
|
|
2629
|
-
isIsolated: false,
|
|
2842
|
+
isIsolated: await isIsolatedAsset(query.utils, poolCoinName),
|
|
2843
|
+
// isIsolated: false,
|
|
2630
2844
|
...calculatedMarketPoolData
|
|
2631
2845
|
};
|
|
2846
|
+
} catch (e) {
|
|
2847
|
+
console.error(e);
|
|
2632
2848
|
}
|
|
2633
|
-
return marketPool;
|
|
2634
2849
|
};
|
|
2635
2850
|
var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLATERALS], indexer = false) => {
|
|
2636
2851
|
const marketId = query.address.get("core.market");
|
|
@@ -2679,85 +2894,76 @@ var getMarketCollateral = async (query, collateralCoinName, indexer = false, mar
|
|
|
2679
2894
|
);
|
|
2680
2895
|
return marketCollateralIndexer;
|
|
2681
2896
|
}
|
|
2682
|
-
let marketCollateral;
|
|
2683
|
-
let riskModel;
|
|
2684
|
-
let collateralStat;
|
|
2685
2897
|
const marketId = query.address.get("core.market");
|
|
2686
2898
|
marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
|
|
2687
2899
|
showContent: true
|
|
2688
2900
|
}))?.data;
|
|
2689
|
-
if (marketObject)
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
}
|
|
2701
|
-
}
|
|
2702
|
-
});
|
|
2703
|
-
if (!riskModelDynamicFieldObjectResponse)
|
|
2704
|
-
return void 0;
|
|
2705
|
-
const riskModelDynamicFieldObject = riskModelDynamicFieldObjectResponse.data;
|
|
2706
|
-
if (riskModelDynamicFieldObject && riskModelDynamicFieldObject.content && "fields" in riskModelDynamicFieldObject.content) {
|
|
2707
|
-
const dynamicFields = riskModelDynamicFieldObject.content.fields;
|
|
2708
|
-
riskModel = dynamicFields.value.fields;
|
|
2901
|
+
if (!(marketObject && marketObject.content?.dataType === "moveObject"))
|
|
2902
|
+
throw new Error(`Failed to fetch marketObject`);
|
|
2903
|
+
const fields = marketObject.content.fields;
|
|
2904
|
+
const coinType = query.utils.parseCoinType(collateralCoinName);
|
|
2905
|
+
const riskModelParentId = fields.risk_models.fields.table.fields.id.id;
|
|
2906
|
+
const riskModelDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2907
|
+
parentId: riskModelParentId,
|
|
2908
|
+
name: {
|
|
2909
|
+
type: "0x1::type_name::TypeName",
|
|
2910
|
+
value: {
|
|
2911
|
+
name: coinType.substring(2)
|
|
2709
2912
|
}
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
collateralStat = dynamicFields.value.fields;
|
|
2913
|
+
}
|
|
2914
|
+
});
|
|
2915
|
+
const riskModelDynamicFieldObject = riskModelDynamicFieldObjectResponse?.data;
|
|
2916
|
+
if (!(riskModelDynamicFieldObject && riskModelDynamicFieldObject.content && "fields" in riskModelDynamicFieldObject.content))
|
|
2917
|
+
throw new Error(
|
|
2918
|
+
`Failed to fetch riskModelDynamicFieldObject for ${riskModelDynamicFieldObjectResponse?.error?.code.toString()}: `
|
|
2919
|
+
);
|
|
2920
|
+
const riskModel = riskModelDynamicFieldObject.content.fields.value.fields;
|
|
2921
|
+
const collateralStatParentId = fields.collateral_stats.fields.table.fields.id.id;
|
|
2922
|
+
const collateralStatDynamicFieldObjectResponse = await query.cache.queryGetDynamicFieldObject({
|
|
2923
|
+
parentId: collateralStatParentId,
|
|
2924
|
+
name: {
|
|
2925
|
+
type: "0x1::type_name::TypeName",
|
|
2926
|
+
value: {
|
|
2927
|
+
name: coinType.substring(2)
|
|
2726
2928
|
}
|
|
2727
2929
|
}
|
|
2728
|
-
}
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
liquidationFactor: riskModel.liquidation_factor.fields,
|
|
2734
|
-
liquidationDiscount: riskModel.liquidation_discount.fields,
|
|
2735
|
-
liquidationPanelty: riskModel.liquidation_penalty.fields,
|
|
2736
|
-
liquidationReserveFactor: riskModel.liquidation_revenue_factor.fields,
|
|
2737
|
-
maxCollateralAmount: riskModel.max_collateral_amount,
|
|
2738
|
-
totalCollateralAmount: collateralStat.amount
|
|
2739
|
-
});
|
|
2740
|
-
const calculatedMarketCollateralData = calculateMarketCollateralData(
|
|
2741
|
-
query.utils,
|
|
2742
|
-
parsedMarketCollateralData
|
|
2930
|
+
});
|
|
2931
|
+
const collateralStatDynamicFieldObject = collateralStatDynamicFieldObjectResponse?.data;
|
|
2932
|
+
if (!(collateralStatDynamicFieldObject && collateralStatDynamicFieldObject.content && "fields" in collateralStatDynamicFieldObject.content))
|
|
2933
|
+
throw new Error(
|
|
2934
|
+
`Failed to fetch collateralStatDynamicFieldObject for ${collateralCoinName}: ${collateralStatDynamicFieldObjectResponse?.error?.code.toString()}`
|
|
2743
2935
|
);
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2936
|
+
const collateralStat = collateralStatDynamicFieldObject.content.fields.value.fields;
|
|
2937
|
+
const parsedMarketCollateralData = parseOriginMarketCollateralData({
|
|
2938
|
+
type: riskModel.type.fields,
|
|
2939
|
+
collateralFactor: riskModel.collateral_factor.fields,
|
|
2940
|
+
liquidationFactor: riskModel.liquidation_factor.fields,
|
|
2941
|
+
liquidationDiscount: riskModel.liquidation_discount.fields,
|
|
2942
|
+
liquidationPanelty: riskModel.liquidation_penalty.fields,
|
|
2943
|
+
liquidationReserveFactor: riskModel.liquidation_revenue_factor.fields,
|
|
2944
|
+
maxCollateralAmount: riskModel.max_collateral_amount,
|
|
2945
|
+
totalCollateralAmount: collateralStat.amount
|
|
2946
|
+
});
|
|
2947
|
+
const calculatedMarketCollateralData = calculateMarketCollateralData(
|
|
2948
|
+
query.utils,
|
|
2949
|
+
parsedMarketCollateralData
|
|
2950
|
+
);
|
|
2951
|
+
return {
|
|
2952
|
+
coinName: collateralCoinName,
|
|
2953
|
+
symbol: query.utils.parseSymbol(collateralCoinName),
|
|
2954
|
+
coinType: query.utils.parseCoinType(collateralCoinName),
|
|
2955
|
+
marketCoinType: query.utils.parseMarketCoinType(collateralCoinName),
|
|
2956
|
+
coinWrappedType: query.utils.getCoinWrappedType(collateralCoinName),
|
|
2957
|
+
coinDecimal: query.utils.getCoinDecimal(collateralCoinName),
|
|
2958
|
+
coinPrice: coinPrice ?? 0,
|
|
2959
|
+
collateralFactor: parsedMarketCollateralData.collateralFactor,
|
|
2960
|
+
liquidationFactor: parsedMarketCollateralData.liquidationFactor,
|
|
2961
|
+
liquidationDiscount: parsedMarketCollateralData.liquidationDiscount,
|
|
2962
|
+
liquidationPanelty: parsedMarketCollateralData.liquidationPanelty,
|
|
2963
|
+
liquidationReserveFactor: parsedMarketCollateralData.liquidationReserveFactor,
|
|
2964
|
+
isIsolated: await isIsolatedAsset(query.utils, collateralCoinName),
|
|
2965
|
+
...calculatedMarketCollateralData
|
|
2966
|
+
};
|
|
2761
2967
|
};
|
|
2762
2968
|
var getObligations = async ({
|
|
2763
2969
|
address
|
|
@@ -2989,7 +3195,7 @@ var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPr
|
|
|
2989
3195
|
const coinName = query.utils.parseCoinName(marketCoinName);
|
|
2990
3196
|
marketPool = marketPool || await query.getMarketPool(coinName, indexer);
|
|
2991
3197
|
if (!marketPool) {
|
|
2992
|
-
throw new Error(
|
|
3198
|
+
throw new Error(`Failed to fetch marketPool for ${marketCoinName}`);
|
|
2993
3199
|
}
|
|
2994
3200
|
const poolId = query.address.get(`spool.pools.${marketCoinName}.id`);
|
|
2995
3201
|
const rewardPoolId = query.address.get(
|
|
@@ -3719,12 +3925,8 @@ var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
|
|
|
3719
3925
|
};
|
|
3720
3926
|
var getObligationAccount = async (query, obligationId, ownerAddress, indexer = false, market, coinPrices, coinAmounts) => {
|
|
3721
3927
|
market = market || await query.queryMarket(indexer);
|
|
3722
|
-
const
|
|
3723
|
-
.../* @__PURE__ */ new Set([
|
|
3724
|
-
...Object.values(market.collaterals).map(
|
|
3725
|
-
(collateral) => collateral.coinName
|
|
3726
|
-
)
|
|
3727
|
-
])
|
|
3928
|
+
const poolAssetCoinNames = [
|
|
3929
|
+
.../* @__PURE__ */ new Set([...Object.values(market.pools).map((pool) => pool.coinName)])
|
|
3728
3930
|
];
|
|
3729
3931
|
const obligationQuery = await query.queryObligation(obligationId);
|
|
3730
3932
|
const borrowIncentivePools = await query.getBorrowIncentivePools(
|
|
@@ -3732,8 +3934,9 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3732
3934
|
indexer
|
|
3733
3935
|
);
|
|
3734
3936
|
const borrowIncentiveAccounts = await query.getBorrowIncentiveAccounts(obligationId);
|
|
3735
|
-
coinPrices = coinPrices || await query.utils.getCoinPrices(
|
|
3736
|
-
coinAmounts = coinAmounts || await query.getCoinAmounts(
|
|
3937
|
+
coinPrices = coinPrices || await query.utils.getCoinPrices(poolAssetCoinNames);
|
|
3938
|
+
coinAmounts = coinAmounts || await query.getCoinAmounts(poolAssetCoinNames, ownerAddress);
|
|
3939
|
+
console.log(coinPrices);
|
|
3737
3940
|
const collaterals = {};
|
|
3738
3941
|
const debts = {};
|
|
3739
3942
|
const borrowIncentives = {};
|
|
@@ -3745,7 +3948,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3745
3948
|
let totalRewardedPools = 0;
|
|
3746
3949
|
let totalBorrowedValue = BigNumber4(0);
|
|
3747
3950
|
let totalBorrowedValueWithWeight = BigNumber4(0);
|
|
3748
|
-
for (const assetCoinName of
|
|
3951
|
+
for (const assetCoinName of poolAssetCoinNames) {
|
|
3749
3952
|
const collateral = obligationQuery?.collaterals.find((collateral2) => {
|
|
3750
3953
|
const collateralCoinName = query.utils.parseCoinNameFromType(
|
|
3751
3954
|
collateral2.type.name
|
|
@@ -4050,7 +4253,7 @@ var getTotalValueLocked = async (query, indexer = false) => {
|
|
|
4050
4253
|
import BigNumber5 from "bignumber.js";
|
|
4051
4254
|
import { SUI_CLOCK_OBJECT_ID, SuiTxBlock as SuiTxBlock2 } from "@scallop-io/sui-kit";
|
|
4052
4255
|
import { bcs } from "@mysten/sui/bcs";
|
|
4053
|
-
import { z as
|
|
4256
|
+
import { z as zod3 } from "zod";
|
|
4054
4257
|
import assert from "assert";
|
|
4055
4258
|
var getVescaKeys = async (utils, ownerAddress) => {
|
|
4056
4259
|
const owner = ownerAddress || utils.suiKit.currentAddress();
|
|
@@ -4099,10 +4302,10 @@ var getVeScas = async ({
|
|
|
4099
4302
|
}
|
|
4100
4303
|
return result;
|
|
4101
4304
|
};
|
|
4102
|
-
var SuiObjectRefZod =
|
|
4103
|
-
objectId:
|
|
4104
|
-
digest:
|
|
4105
|
-
version:
|
|
4305
|
+
var SuiObjectRefZod = zod3.object({
|
|
4306
|
+
objectId: zod3.string(),
|
|
4307
|
+
digest: zod3.string(),
|
|
4308
|
+
version: zod3.string()
|
|
4106
4309
|
});
|
|
4107
4310
|
var getVeSca = async (utils, veScaKey) => {
|
|
4108
4311
|
const tableId = utils.address.get(`vesca.tableId`);
|
|
@@ -4235,16 +4438,16 @@ var queryVeScaKeyIdFromReferralBindings = async (address, refereeAddress) => {
|
|
|
4235
4438
|
|
|
4236
4439
|
// src/queries/loyaltyProgramQuery.ts
|
|
4237
4440
|
import BigNumber6 from "bignumber.js";
|
|
4238
|
-
import { z as
|
|
4239
|
-
var rewardPoolFieldsZod =
|
|
4240
|
-
balance:
|
|
4241
|
-
enable_claim:
|
|
4441
|
+
import { z as zod4 } from "zod";
|
|
4442
|
+
var rewardPoolFieldsZod = zod4.object({
|
|
4443
|
+
balance: zod4.string(),
|
|
4444
|
+
enable_claim: zod4.boolean()
|
|
4242
4445
|
}).transform((value) => ({
|
|
4243
4446
|
totalPoolReward: BigNumber6(value.balance).shiftedBy(-9).toNumber(),
|
|
4244
4447
|
isClaimEnabled: value.enable_claim
|
|
4245
4448
|
}));
|
|
4246
|
-
var userRewardFieldsZod =
|
|
4247
|
-
value:
|
|
4449
|
+
var userRewardFieldsZod = zod4.object({
|
|
4450
|
+
value: zod4.string()
|
|
4248
4451
|
}).transform((value) => BigNumber6(value.value).shiftedBy(-9).toNumber());
|
|
4249
4452
|
var getLoyaltyProgramInformations = async (query, veScaKey) => {
|
|
4250
4453
|
const rewardPool = query.address.get("loyaltyProgram.rewardPool");
|
|
@@ -4284,12 +4487,6 @@ var getLoyaltyProgramInformations = async (query, veScaKey) => {
|
|
|
4284
4487
|
return result;
|
|
4285
4488
|
};
|
|
4286
4489
|
|
|
4287
|
-
// src/constants/pyth.ts
|
|
4288
|
-
var PYTH_ENDPOINTS = {
|
|
4289
|
-
testnet: ["https://hermes-beta.pyth.network"],
|
|
4290
|
-
mainnet: ["https://hermes.pyth.network", "https://scallop.rpc.p2p.world"]
|
|
4291
|
-
};
|
|
4292
|
-
|
|
4293
4490
|
// src/models/scallopUtils.ts
|
|
4294
4491
|
var ScallopUtils = class {
|
|
4295
4492
|
constructor(params, instance) {
|
|
@@ -4355,10 +4552,10 @@ var ScallopUtils = class {
|
|
|
4355
4552
|
* @param address - ScallopAddress instance.
|
|
4356
4553
|
*/
|
|
4357
4554
|
async init(force = false, address) {
|
|
4358
|
-
if (
|
|
4359
|
-
await this.address.read();
|
|
4360
|
-
} else {
|
|
4555
|
+
if (address && !this.address)
|
|
4361
4556
|
this.address = address;
|
|
4557
|
+
if (force || !this.address.getAddresses()) {
|
|
4558
|
+
await this.address.read();
|
|
4362
4559
|
}
|
|
4363
4560
|
}
|
|
4364
4561
|
/**
|
|
@@ -4658,30 +4855,38 @@ var ScallopUtils = class {
|
|
|
4658
4855
|
const priceId = this.address.get(
|
|
4659
4856
|
`core.coins.${coinName}.oracle.pyth.feed`
|
|
4660
4857
|
);
|
|
4661
|
-
|
|
4858
|
+
if (priceId) {
|
|
4859
|
+
acc[coinName] = priceId;
|
|
4860
|
+
}
|
|
4662
4861
|
return acc;
|
|
4663
4862
|
},
|
|
4664
4863
|
{}
|
|
4665
4864
|
);
|
|
4666
4865
|
await Promise.allSettled(
|
|
4667
|
-
Object.entries(priceIds).map(async ([coinName, priceId]) => {
|
|
4866
|
+
Object.entries(priceIds).filter(([_, priceId]) => !!priceId).map(async ([coinName, priceId]) => {
|
|
4668
4867
|
const pythConnection = new SuiPriceServiceConnection(endpoint);
|
|
4669
4868
|
try {
|
|
4670
4869
|
const feed = await this.cache.queryClient.fetchQuery({
|
|
4671
|
-
queryKey: queryKeys.oracle.getPythLatestPriceFeed(
|
|
4870
|
+
queryKey: queryKeys.oracle.getPythLatestPriceFeed(
|
|
4871
|
+
priceId,
|
|
4872
|
+
endpoint
|
|
4873
|
+
),
|
|
4672
4874
|
queryFn: async () => {
|
|
4673
4875
|
return await pythConnection.getLatestPriceFeeds([priceId]) ?? [];
|
|
4674
4876
|
}
|
|
4675
4877
|
});
|
|
4676
4878
|
if (feed[0]) {
|
|
4677
|
-
const data = parseDataFromPythPriceFeed(
|
|
4879
|
+
const data = parseDataFromPythPriceFeed(
|
|
4880
|
+
feed[0],
|
|
4881
|
+
this.address
|
|
4882
|
+
);
|
|
4678
4883
|
this._priceMap.set(coinName, {
|
|
4679
4884
|
price: data.price,
|
|
4680
4885
|
publishTime: data.publishTime
|
|
4681
4886
|
});
|
|
4682
4887
|
coinPrices[coinName] = data.price;
|
|
4888
|
+
failedRequests.delete(coinName);
|
|
4683
4889
|
}
|
|
4684
|
-
failedRequests.delete(coinName);
|
|
4685
4890
|
} catch (e) {
|
|
4686
4891
|
console.warn(
|
|
4687
4892
|
`Failed to get price ${coinName} feeds with endpoint ${endpoint}: ${e}`
|
|
@@ -4759,6 +4964,26 @@ var ScallopUtils = class {
|
|
|
4759
4964
|
}
|
|
4760
4965
|
return findClosestUnlockRound(newUnlockAtInSecondTimestamp);
|
|
4761
4966
|
}
|
|
4967
|
+
/**
|
|
4968
|
+
* Get detailed contract address and price id information for supported pool in Scallop
|
|
4969
|
+
* @returns Supported pool informations
|
|
4970
|
+
*/
|
|
4971
|
+
getSupportedPoolAddresses() {
|
|
4972
|
+
return SUPPORT_POOLS.map((poolName) => {
|
|
4973
|
+
const sCoinName = this.parseSCoinName(poolName);
|
|
4974
|
+
return {
|
|
4975
|
+
name: this.parseSymbol(poolName),
|
|
4976
|
+
coingeckoId: COIN_GECKGO_IDS[poolName],
|
|
4977
|
+
decimal: coinDecimals[poolName],
|
|
4978
|
+
pythFeedId: PYTH_FEED_IDS[poolName],
|
|
4979
|
+
...POOL_ADDRESSES[poolName],
|
|
4980
|
+
sCoinAddress: sCoinIds[sCoinName],
|
|
4981
|
+
marketCoinAddress: this.parseMarketCoinType(poolName),
|
|
4982
|
+
coinAddress: this.parseCoinType(poolName),
|
|
4983
|
+
sCoinName: sCoinName ? this.parseSymbol(sCoinName) : void 0
|
|
4984
|
+
};
|
|
4985
|
+
});
|
|
4986
|
+
}
|
|
4762
4987
|
};
|
|
4763
4988
|
|
|
4764
4989
|
// src/models/scallopBuilder.ts
|
|
@@ -6647,88 +6872,6 @@ var getSCoinSwapRate = async (query, fromSCoin, toSCoin, underlyingCoinPrice) =>
|
|
|
6647
6872
|
|
|
6648
6873
|
// src/models/scallopQuery.ts
|
|
6649
6874
|
import { normalizeSuiAddress } from "@mysten/sui/utils";
|
|
6650
|
-
|
|
6651
|
-
// src/queries/isolatedAsset.ts
|
|
6652
|
-
import { z as zod4 } from "zod";
|
|
6653
|
-
var isolatedAssetZod = zod4.object({
|
|
6654
|
-
dataType: zod4.string(),
|
|
6655
|
-
type: zod4.string(),
|
|
6656
|
-
hasPublicTransfer: zod4.boolean(),
|
|
6657
|
-
fields: zod4.object({
|
|
6658
|
-
id: zod4.object({
|
|
6659
|
-
id: zod4.string()
|
|
6660
|
-
}),
|
|
6661
|
-
name: zod4.object({
|
|
6662
|
-
type: zod4.string()
|
|
6663
|
-
}),
|
|
6664
|
-
value: zod4.boolean()
|
|
6665
|
-
})
|
|
6666
|
-
});
|
|
6667
|
-
var ISOLATED_ASSET_KEY = "0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e::market_dynamic_keys::IsolatedAssetKey";
|
|
6668
|
-
var getIsolatedAssets = async (address) => {
|
|
6669
|
-
try {
|
|
6670
|
-
const marketObject = address.get("core.market");
|
|
6671
|
-
const isolatedAssets = [];
|
|
6672
|
-
if (!marketObject)
|
|
6673
|
-
return isolatedAssets;
|
|
6674
|
-
let hasNextPage = false;
|
|
6675
|
-
let nextCursor = null;
|
|
6676
|
-
const isIsolatedDynamicField = (dynamicField) => {
|
|
6677
|
-
return dynamicField.name.type === ISOLATED_ASSET_KEY;
|
|
6678
|
-
};
|
|
6679
|
-
do {
|
|
6680
|
-
const response = await address.cache.queryGetDynamicFields({
|
|
6681
|
-
parentId: marketObject,
|
|
6682
|
-
cursor: nextCursor,
|
|
6683
|
-
limit: 10
|
|
6684
|
-
});
|
|
6685
|
-
if (!response)
|
|
6686
|
-
break;
|
|
6687
|
-
const isolatedAssetCoinTypes = response.data.filter(isIsolatedDynamicField).map(({ name }) => `0x${name.value.type.name}`);
|
|
6688
|
-
isolatedAssets.push(...isolatedAssetCoinTypes);
|
|
6689
|
-
if (response && response.hasNextPage && response.nextCursor) {
|
|
6690
|
-
hasNextPage = true;
|
|
6691
|
-
nextCursor = response.nextCursor;
|
|
6692
|
-
} else {
|
|
6693
|
-
hasNextPage = false;
|
|
6694
|
-
}
|
|
6695
|
-
} while (hasNextPage);
|
|
6696
|
-
return isolatedAssets;
|
|
6697
|
-
} catch (e) {
|
|
6698
|
-
console.error(e);
|
|
6699
|
-
return [];
|
|
6700
|
-
}
|
|
6701
|
-
};
|
|
6702
|
-
var isIsolatedAsset = async (utils, coinName) => {
|
|
6703
|
-
try {
|
|
6704
|
-
const marketObject = utils.address.get("core.market");
|
|
6705
|
-
const cachedData = utils.address.cache.queryClient.getQueryData([
|
|
6706
|
-
"getDynamicFields",
|
|
6707
|
-
marketObject
|
|
6708
|
-
]);
|
|
6709
|
-
if (cachedData) {
|
|
6710
|
-
const coinType2 = utils.parseCoinType(coinName);
|
|
6711
|
-
return cachedData.includes(coinType2);
|
|
6712
|
-
}
|
|
6713
|
-
const coinType = utils.parseCoinType(coinName).slice(2);
|
|
6714
|
-
const object = await utils.cache.queryGetDynamicFieldObject({
|
|
6715
|
-
parentId: marketObject,
|
|
6716
|
-
name: {
|
|
6717
|
-
type: ISOLATED_ASSET_KEY,
|
|
6718
|
-
value: coinType
|
|
6719
|
-
}
|
|
6720
|
-
});
|
|
6721
|
-
const parsedData = isolatedAssetZod.safeParse(object?.data?.content);
|
|
6722
|
-
if (!parsedData.success)
|
|
6723
|
-
return false;
|
|
6724
|
-
return parsedData.data.fields.value;
|
|
6725
|
-
} catch (e) {
|
|
6726
|
-
console.error(e);
|
|
6727
|
-
return false;
|
|
6728
|
-
}
|
|
6729
|
-
};
|
|
6730
|
-
|
|
6731
|
-
// src/models/scallopQuery.ts
|
|
6732
6875
|
var ScallopQuery = class {
|
|
6733
6876
|
constructor(params, instance) {
|
|
6734
6877
|
this.params = params;
|
|
@@ -6798,11 +6941,12 @@ var ScallopQuery = class {
|
|
|
6798
6941
|
* @param address - ScallopAddress instance.
|
|
6799
6942
|
*/
|
|
6800
6943
|
async init(force = false, address) {
|
|
6801
|
-
if (
|
|
6802
|
-
await this.address.read();
|
|
6803
|
-
} else {
|
|
6944
|
+
if (address && !this.address) {
|
|
6804
6945
|
this.address = address;
|
|
6805
6946
|
}
|
|
6947
|
+
if (force || !this.address.getAddresses()) {
|
|
6948
|
+
await this.address.read();
|
|
6949
|
+
}
|
|
6806
6950
|
await this.utils.init(force, this.address);
|
|
6807
6951
|
}
|
|
6808
6952
|
/* ==================== Core Query Methods ==================== */
|
|
@@ -7318,10 +7462,10 @@ var ScallopBuilder = class {
|
|
|
7318
7462
|
* @param address - ScallopAddress instance.
|
|
7319
7463
|
*/
|
|
7320
7464
|
async init(force = false, address) {
|
|
7321
|
-
if (
|
|
7322
|
-
await this.address.read();
|
|
7323
|
-
} else {
|
|
7465
|
+
if (address && !this.address)
|
|
7324
7466
|
this.address = address;
|
|
7467
|
+
if (force || !this.address.getAddresses()) {
|
|
7468
|
+
await this.address.read();
|
|
7325
7469
|
}
|
|
7326
7470
|
await this.query.init(force, this.address);
|
|
7327
7471
|
await this.utils.init(force, this.address);
|
|
@@ -8206,6 +8350,10 @@ export {
|
|
|
8206
8350
|
ADDRESSES_ID,
|
|
8207
8351
|
API_BASE_URL,
|
|
8208
8352
|
BORROW_FEE_PROTOCOL_ID,
|
|
8353
|
+
COIN_GECKGO_IDS,
|
|
8354
|
+
DEFAULT_CACHE_OPTIONS,
|
|
8355
|
+
DEFAULT_INTERVAL_IN_MS,
|
|
8356
|
+
DEFAULT_TOKENS_PER_INTERVAL,
|
|
8209
8357
|
FlashLoanFeeObjectMap,
|
|
8210
8358
|
IS_VE_SCA_TEST,
|
|
8211
8359
|
MAX_LOCK_DURATION,
|
|
@@ -8213,7 +8361,10 @@ export {
|
|
|
8213
8361
|
MIN_INITIAL_LOCK_AMOUNT,
|
|
8214
8362
|
MIN_TOP_UP_AMOUNT,
|
|
8215
8363
|
OLD_BORROW_INCENTIVE_PROTOCOL_ID,
|
|
8364
|
+
POOL_ADDRESSES,
|
|
8216
8365
|
PROTOCOL_OBJECT_ID,
|
|
8366
|
+
PYTH_ENDPOINTS,
|
|
8367
|
+
PYTH_FEED_IDS,
|
|
8217
8368
|
SCA_COIN_TYPE,
|
|
8218
8369
|
SDK_API_BASE_URL,
|
|
8219
8370
|
SUPPORT_BORROW_INCENTIVE_POOLS,
|
|
@@ -8235,6 +8386,7 @@ export {
|
|
|
8235
8386
|
ScallopIndexer,
|
|
8236
8387
|
ScallopQuery,
|
|
8237
8388
|
ScallopUtils,
|
|
8389
|
+
TEST_ADDRESSES,
|
|
8238
8390
|
UNLOCK_ROUND_DURATION,
|
|
8239
8391
|
USE_TEST_ADDRESS,
|
|
8240
8392
|
assetCoins,
|