@scallop-io/sui-scallop-sdk 0.46.53 → 0.46.54
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/tokenBucket.d.ts +2 -0
- package/dist/index.js +1981 -1884
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1932 -1835
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallop.d.ts +2 -1
- package/dist/models/scallopCache.d.ts +11 -8
- package/dist/models/scallopClient.d.ts +2 -2
- package/dist/models/scallopQuery.d.ts +1 -1
- package/dist/models/scallopUtils.d.ts +9 -1
- package/dist/queries/coreQuery.d.ts +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/tokenBucket.d.ts +11 -0
- package/package.json +1 -1
- package/src/builders/loyaltyProgramBuilder.ts +6 -12
- package/src/builders/spoolBuilder.ts +1 -33
- package/src/constants/tokenBucket.ts +2 -0
- package/src/models/scallop.ts +13 -2
- package/src/models/scallopCache.ts +55 -25
- package/src/models/scallopClient.ts +28 -13
- package/src/models/scallopUtils.ts +42 -10
- package/src/queries/borrowIncentiveQuery.ts +12 -10
- package/src/queries/coreQuery.ts +33 -16
- package/src/queries/loyaltyProgramQuery.ts +2 -2
- package/src/queries/portfolioQuery.ts +2 -2
- package/src/queries/priceQuery.ts +1 -1
- package/src/queries/referralQuery.ts +1 -1
- package/src/queries/sCoinQuery.ts +1 -1
- package/src/queries/spoolQuery.ts +4 -2
- package/src/queries/vescaQuery.ts +8 -3
- package/src/utils/index.ts +1 -0
- package/src/utils/tokenBucket.ts +63 -0
package/dist/index.js
CHANGED
|
@@ -335,1831 +335,1906 @@ var DEFAULT_CACHE_OPTIONS = {
|
|
|
335
335
|
}
|
|
336
336
|
};
|
|
337
337
|
|
|
338
|
-
// src/
|
|
339
|
-
var
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
338
|
+
// src/utils/builder.ts
|
|
339
|
+
var requireSender = (txBlock) => {
|
|
340
|
+
const sender = txBlock.blockData.sender;
|
|
341
|
+
if (!sender) {
|
|
342
|
+
throw new Error("Sender is required");
|
|
343
343
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
344
|
+
return sender;
|
|
345
|
+
};
|
|
346
|
+
var checkVesca = (prevUnlockAtInMillisTimestamp) => {
|
|
347
|
+
if (prevUnlockAtInMillisTimestamp === void 0) {
|
|
348
|
+
throw new Error("veSca not found");
|
|
349
349
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
* - `active`: Only queries that match the refetch predicate and are actively being rendered via useQuery and related functions will be refetched in the background.
|
|
355
|
-
* - `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.
|
|
356
|
-
* - `all`: All queries that match the refetch predicate will be refetched in the background.
|
|
357
|
-
* - `none`: No queries will be refetched. Queries that match the refetch predicate will only be marked as invalid.
|
|
358
|
-
*/
|
|
359
|
-
invalidateAndRefetchAllCache(refetchType) {
|
|
360
|
-
return this.queryClient.invalidateQueries({
|
|
361
|
-
refetchType
|
|
362
|
-
});
|
|
350
|
+
};
|
|
351
|
+
var checkVescaExpired = (prevUnlockAtInMillisTimestamp) => {
|
|
352
|
+
if (prevUnlockAtInMillisTimestamp <= (/* @__PURE__ */ new Date()).getTime()) {
|
|
353
|
+
throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
|
|
363
354
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
},
|
|
374
|
-
staleTime: 3e4
|
|
375
|
-
});
|
|
355
|
+
};
|
|
356
|
+
var checkExtendLockPeriod = (lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInMillisTimestamp) => {
|
|
357
|
+
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
358
|
+
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
359
|
+
const prevUnlockAtInSecondTimestamp = Math.floor(
|
|
360
|
+
prevUnlockAtInMillisTimestamp / 1e3
|
|
361
|
+
);
|
|
362
|
+
if (lockPeriodInDays < 1) {
|
|
363
|
+
throw new Error("Minimum lock period is 1 day");
|
|
376
364
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
async queryInspectTxn({
|
|
384
|
-
queryTarget,
|
|
385
|
-
args,
|
|
386
|
-
typeArgs
|
|
387
|
-
}) {
|
|
388
|
-
const txBlock = new import_sui_kit.SuiTxBlock();
|
|
389
|
-
const resolvedArgs = await Promise.all(
|
|
390
|
-
args.map(async (arg) => {
|
|
391
|
-
if (typeof arg === "string") {
|
|
392
|
-
return (await this.queryGetObject(arg, { showContent: true })).data;
|
|
393
|
-
}
|
|
394
|
-
return arg;
|
|
395
|
-
})
|
|
365
|
+
const availableLockPeriodInDays = Math.floor(
|
|
366
|
+
(newUnlockAtInSecondTimestamp - prevUnlockAtInSecondTimestamp) / UNLOCK_ROUND_DURATION
|
|
367
|
+
);
|
|
368
|
+
if (lockPeriodInDays > availableLockPeriodInDays) {
|
|
369
|
+
throw new Error(
|
|
370
|
+
`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}`
|
|
396
371
|
);
|
|
397
|
-
txBlock.moveCall(queryTarget, resolvedArgs, typeArgs);
|
|
398
|
-
const txBytes = await txBlock.txBlock.build({
|
|
399
|
-
client: this.suiKit.client(),
|
|
400
|
-
onlyTransactionKind: true,
|
|
401
|
-
protocolConfig: await this.getProtocolConfig()
|
|
402
|
-
});
|
|
403
|
-
const query = await this.queryClient.fetchQuery({
|
|
404
|
-
queryKey: typeArgs ? ["inspectTxn", queryTarget, JSON.stringify(args)] : [
|
|
405
|
-
"inspectTxn",
|
|
406
|
-
queryTarget,
|
|
407
|
-
JSON.stringify(args),
|
|
408
|
-
JSON.stringify(typeArgs)
|
|
409
|
-
],
|
|
410
|
-
queryFn: async () => {
|
|
411
|
-
return await this.suiKit.inspectTxn(txBytes);
|
|
412
|
-
}
|
|
413
|
-
});
|
|
414
|
-
return query;
|
|
415
372
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
queryKey.push(JSON.stringify(options));
|
|
426
|
-
}
|
|
427
|
-
return this.queryClient.fetchQuery({
|
|
428
|
-
queryKey,
|
|
429
|
-
queryFn: async () => {
|
|
430
|
-
return await this.suiKit.client().getObject({
|
|
431
|
-
id: objectId,
|
|
432
|
-
options
|
|
433
|
-
});
|
|
373
|
+
};
|
|
374
|
+
var checkLockSca = (scaAmountOrCoin, lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInMillisTimestamp) => {
|
|
375
|
+
const prevUnlockAtInSecondTimestamp = prevUnlockAtInMillisTimestamp ? Math.floor(prevUnlockAtInMillisTimestamp / 1e3) : void 0;
|
|
376
|
+
const isInitialLock = !prevUnlockAtInSecondTimestamp;
|
|
377
|
+
const isLockExpired = !isInitialLock && prevUnlockAtInSecondTimestamp * 1e3 <= (/* @__PURE__ */ new Date()).getTime();
|
|
378
|
+
if (isInitialLock || isLockExpired) {
|
|
379
|
+
if (scaAmountOrCoin !== void 0 && lockPeriodInDays !== void 0) {
|
|
380
|
+
if (lockPeriodInDays <= 0) {
|
|
381
|
+
throw new Error("Lock period must be greater than 0");
|
|
434
382
|
}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
* @param objectIds
|
|
440
|
-
* @returns Promise<SuiObjectData[]>
|
|
441
|
-
*/
|
|
442
|
-
async queryGetObjects(objectIds, options) {
|
|
443
|
-
if (objectIds.length === 0)
|
|
444
|
-
return [];
|
|
445
|
-
const queryKey = [
|
|
446
|
-
"getObjects",
|
|
447
|
-
JSON.stringify(objectIds),
|
|
448
|
-
this.suiKit.currentAddress()
|
|
449
|
-
];
|
|
450
|
-
if (options) {
|
|
451
|
-
queryKey.push(JSON.stringify(options));
|
|
452
|
-
}
|
|
453
|
-
return this.queryClient.fetchQuery({
|
|
454
|
-
queryKey,
|
|
455
|
-
queryFn: async () => {
|
|
456
|
-
return await this.suiKit.getObjects(objectIds, options);
|
|
383
|
+
if (typeof scaAmountOrCoin === "number" && scaAmountOrCoin < MIN_INITIAL_LOCK_AMOUNT) {
|
|
384
|
+
throw new Error(
|
|
385
|
+
`Minimum lock amount for ${isLockExpired ? "renewing expired veSca" : "initial lock"} is 10 SCA`
|
|
386
|
+
);
|
|
457
387
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
queryKey.push(JSON.stringify(input.cursor));
|
|
469
|
-
}
|
|
470
|
-
if (input.options) {
|
|
471
|
-
queryKey.push(JSON.stringify(input.options));
|
|
388
|
+
const extendLockPeriodInSecond = lockPeriodInDays * UNLOCK_ROUND_DURATION;
|
|
389
|
+
if (extendLockPeriodInSecond > MAX_LOCK_DURATION) {
|
|
390
|
+
throw new Error(
|
|
391
|
+
`Maximum lock period is ~4 years (${MAX_LOCK_ROUNDS} days)`
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
} else {
|
|
395
|
+
throw new Error(
|
|
396
|
+
`SCA amount and lock period is required for ${isLockExpired ? "renewing expired veSca" : "initial lock"}`
|
|
397
|
+
);
|
|
472
398
|
}
|
|
473
|
-
|
|
474
|
-
|
|
399
|
+
} else {
|
|
400
|
+
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
401
|
+
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
402
|
+
if (typeof scaAmountOrCoin === "number" && scaAmountOrCoin < MIN_TOP_UP_AMOUNT) {
|
|
403
|
+
throw new Error("Minimum top up amount is 1 SCA");
|
|
475
404
|
}
|
|
476
|
-
if (
|
|
477
|
-
|
|
405
|
+
if (newUnlockAtInSecondTimestamp && lockPeriodInDays) {
|
|
406
|
+
checkExtendLockPeriod(
|
|
407
|
+
lockPeriodInDays,
|
|
408
|
+
newUnlockAtInSecondTimestamp,
|
|
409
|
+
prevUnlockAtInMillisTimestamp
|
|
410
|
+
);
|
|
478
411
|
}
|
|
479
|
-
return this.queryClient.fetchQuery({
|
|
480
|
-
queryKey,
|
|
481
|
-
queryFn: async () => {
|
|
482
|
-
return await this.suiKit.client().getOwnedObjects(input);
|
|
483
|
-
}
|
|
484
|
-
});
|
|
485
412
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
queryKey.push(JSON.stringify(input.limit));
|
|
493
|
-
}
|
|
494
|
-
return this.queryClient.fetchQuery({
|
|
495
|
-
queryKey,
|
|
496
|
-
queryFn: async () => {
|
|
497
|
-
return await this.suiKit.client().getDynamicFields(input);
|
|
498
|
-
}
|
|
499
|
-
});
|
|
413
|
+
};
|
|
414
|
+
var checkExtendLockAmount = (scaAmount, prevUnlockAtInMillisTimestamp) => {
|
|
415
|
+
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
416
|
+
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
417
|
+
if (scaAmount < MIN_TOP_UP_AMOUNT) {
|
|
418
|
+
throw new Error("Minimum top up amount is 1 SCA");
|
|
500
419
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
input.name.type,
|
|
506
|
-
input.name.value
|
|
507
|
-
];
|
|
508
|
-
return this.queryClient.fetchQuery({
|
|
509
|
-
queryKey,
|
|
510
|
-
queryFn: async () => {
|
|
511
|
-
return await this.suiKit.client().getDynamicFieldObject(input);
|
|
512
|
-
}
|
|
513
|
-
});
|
|
420
|
+
const isInitialLock = !prevUnlockAtInMillisTimestamp;
|
|
421
|
+
const isLockExpired = !isInitialLock && prevUnlockAtInMillisTimestamp <= (/* @__PURE__ */ new Date()).getTime();
|
|
422
|
+
if (isLockExpired) {
|
|
423
|
+
throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
|
|
514
424
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
queryFn: async () => {
|
|
520
|
-
const allBalances = await this.suiKit.client().getAllBalances({ owner });
|
|
521
|
-
const balances = allBalances.reduce(
|
|
522
|
-
(acc, coinBalance) => {
|
|
523
|
-
if (coinBalance.totalBalance !== "0") {
|
|
524
|
-
acc[(0, import_sui_kit.normalizeStructTag)(coinBalance.coinType)] = coinBalance.totalBalance;
|
|
525
|
-
}
|
|
526
|
-
return acc;
|
|
527
|
-
},
|
|
528
|
-
{}
|
|
529
|
-
);
|
|
530
|
-
for (const coinType in balances) {
|
|
531
|
-
const coinBalanceQueryKey = [
|
|
532
|
-
"getCoinBalance",
|
|
533
|
-
(0, import_sui_kit.normalizeSuiAddress)(owner),
|
|
534
|
-
(0, import_sui_kit.normalizeStructTag)(coinType)
|
|
535
|
-
];
|
|
536
|
-
this.queryClient.setQueryData(
|
|
537
|
-
coinBalanceQueryKey,
|
|
538
|
-
balances[coinType]
|
|
539
|
-
);
|
|
540
|
-
}
|
|
541
|
-
return balances;
|
|
542
|
-
}
|
|
543
|
-
});
|
|
425
|
+
};
|
|
426
|
+
var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays, prevUnlockAtInMillisTimestamp) => {
|
|
427
|
+
if (!prevUnlockAtInMillisTimestamp || prevUnlockAtInMillisTimestamp > (/* @__PURE__ */ new Date()).getTime()) {
|
|
428
|
+
throw new Error("Renew method can only be used for expired veSca");
|
|
544
429
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
(
|
|
552
|
-
|
|
553
|
-
return this.queryClient.fetchQuery({
|
|
554
|
-
queryKey,
|
|
555
|
-
queryFn: async () => {
|
|
556
|
-
if (!input.coinType)
|
|
557
|
-
return "0";
|
|
558
|
-
return (await this.queryGetAllCoinBalances(input.owner))[(0, import_sui_kit.normalizeStructTag)(input.coinType)] ?? "0";
|
|
559
|
-
}
|
|
560
|
-
});
|
|
430
|
+
if (scaAmount < MIN_INITIAL_LOCK_AMOUNT) {
|
|
431
|
+
throw new Error("Minimum lock amount for renewing expired vesca 10 SCA");
|
|
432
|
+
}
|
|
433
|
+
const extendLockPeriodInSecond = lockPeriodInDays * UNLOCK_ROUND_DURATION;
|
|
434
|
+
if (extendLockPeriodInSecond >= MAX_LOCK_DURATION - UNLOCK_ROUND_DURATION) {
|
|
435
|
+
throw new Error(
|
|
436
|
+
`Maximum lock period is ~4 years (${MAX_LOCK_ROUNDS - 1} days)`
|
|
437
|
+
);
|
|
561
438
|
}
|
|
562
439
|
};
|
|
563
440
|
|
|
564
|
-
// src/
|
|
565
|
-
var
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
//
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
//
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
supra: "",
|
|
592
|
-
switchboard: "",
|
|
593
|
-
pyth: {
|
|
594
|
-
feed: "e5b274b2611143df055d6e7cd8d93fe1961716bcd4dca1cad87a83bc1e78c1ef",
|
|
595
|
-
feedObject: "0x24c0247fb22457a719efac7f670cdc79be321b521460bd6bd2ccfa9f80713b14"
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
},
|
|
599
|
-
apt: {
|
|
600
|
-
id: "0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37",
|
|
601
|
-
metaData: "0xc969c5251f372c0f34c32759f1d315cf1ea0ee5e4454b52aea08778eacfdd0a8",
|
|
602
|
-
treasury: "",
|
|
603
|
-
oracle: {
|
|
604
|
-
supra: "",
|
|
605
|
-
switchboard: "",
|
|
606
|
-
pyth: {
|
|
607
|
-
feed: "03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5",
|
|
608
|
-
feedObject: "0x7c5b7837c44a69b469325463ac0673ac1aa8435ff44ddb4191c9ae380463647f"
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
},
|
|
612
|
-
sol: {
|
|
613
|
-
id: "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8",
|
|
614
|
-
metaData: "0x4d2c39082b4477e3e79dc4562d939147ab90c42fc5f3e4acf03b94383cd69b6e",
|
|
615
|
-
treasury: "",
|
|
616
|
-
oracle: {
|
|
617
|
-
supra: "",
|
|
618
|
-
switchboard: "",
|
|
619
|
-
pyth: {
|
|
620
|
-
feed: "ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
|
|
621
|
-
feedObject: "0x9d0d275efbd37d8a8855f6f2c761fa5983293dd8ce202ee5196626de8fcd4469"
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
},
|
|
625
|
-
btc: {
|
|
626
|
-
id: "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881",
|
|
627
|
-
metaData: "0x5d3c6e60eeff8a05b693b481539e7847dfe33013e7070cdcb387f5c0cac05dfd",
|
|
628
|
-
treasury: "",
|
|
629
|
-
oracle: {
|
|
630
|
-
supra: "",
|
|
631
|
-
switchboard: "",
|
|
632
|
-
pyth: {
|
|
633
|
-
feed: "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43",
|
|
634
|
-
feedObject: "0x9a62b4863bdeaabdc9500fce769cf7e72d5585eeb28a6d26e4cafadc13f76ab2"
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
},
|
|
638
|
-
eth: {
|
|
639
|
-
id: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
|
|
640
|
-
metaData: "0x8900e4ceede3363bef086d6b50ca89d816d0e90bf6bc46efefe1f8455e08f50f",
|
|
641
|
-
treasury: "",
|
|
642
|
-
oracle: {
|
|
643
|
-
supra: "",
|
|
644
|
-
switchboard: "",
|
|
645
|
-
pyth: {
|
|
646
|
-
feed: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
647
|
-
feedObject: "0x9193fd47f9a0ab99b6e365a464c8a9ae30e6150fc37ed2a89c1586631f6fc4ab"
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
},
|
|
651
|
-
usdc: {
|
|
652
|
-
id: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf",
|
|
653
|
-
metaData: "0x4fbf84f3029bd0c0b77164b587963be957f853eccf834a67bb9ecba6ec80f189",
|
|
654
|
-
treasury: "",
|
|
655
|
-
oracle: {
|
|
656
|
-
supra: "",
|
|
657
|
-
switchboard: "",
|
|
658
|
-
pyth: {
|
|
659
|
-
feed: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
660
|
-
feedObject: "0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab"
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
},
|
|
664
|
-
usdt: {
|
|
665
|
-
id: "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c",
|
|
666
|
-
metaData: "0xfb0e3eb97dd158a5ae979dddfa24348063843c5b20eb8381dd5fa7c93699e45c",
|
|
667
|
-
treasury: "",
|
|
668
|
-
oracle: {
|
|
669
|
-
supra: "",
|
|
670
|
-
switchboard: "",
|
|
671
|
-
pyth: {
|
|
672
|
-
feed: "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
|
|
673
|
-
feedObject: "0x985e3db9f93f76ee8bace7c3dd5cc676a096accd5d9e09e9ae0fb6e492b14572"
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
},
|
|
677
|
-
sui: {
|
|
678
|
-
id: "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
679
|
-
metaData: "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3",
|
|
680
|
-
treasury: "",
|
|
681
|
-
oracle: {
|
|
682
|
-
supra: "",
|
|
683
|
-
switchboard: "0xbca474133638352ba83ccf7b5c931d50f764b09550e16612c9f70f1e21f3f594",
|
|
684
|
-
pyth: {
|
|
685
|
-
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
686
|
-
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
},
|
|
690
|
-
afsui: {
|
|
691
|
-
id: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
|
|
692
|
-
metaData: "0x2f9217f533e51334873a39b8026a4aa6919497b47f49d0986a4f1aec66f8a34d",
|
|
693
|
-
treasury: "",
|
|
694
|
-
oracle: {
|
|
695
|
-
supra: "",
|
|
696
|
-
switchboard: "",
|
|
697
|
-
pyth: {
|
|
698
|
-
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
699
|
-
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
},
|
|
703
|
-
hasui: {
|
|
704
|
-
id: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
|
|
705
|
-
metaData: "0x2c5f33af93f6511df699aaaa5822d823aac6ed99d4a0de2a4a50b3afa0172e24",
|
|
706
|
-
treasury: "",
|
|
707
|
-
oracle: {
|
|
708
|
-
supra: "",
|
|
709
|
-
switchboard: "",
|
|
710
|
-
pyth: {
|
|
711
|
-
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
712
|
-
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
},
|
|
716
|
-
vsui: {
|
|
717
|
-
id: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
|
|
718
|
-
metaData: "0xabd84a23467b33854ab25cf862006fd97479f8f6f53e50fe732c43a274d939bd",
|
|
719
|
-
treasury: "",
|
|
720
|
-
oracle: {
|
|
721
|
-
supra: "",
|
|
722
|
-
switchboard: "",
|
|
723
|
-
pyth: {
|
|
724
|
-
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
725
|
-
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
},
|
|
729
|
-
sca: {
|
|
730
|
-
id: "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6",
|
|
731
|
-
metaData: "0x5d26a1e9a55c88147ac870bfa31b729d7f49f8804b8b3adfdf3582d301cca844",
|
|
732
|
-
treasury: "",
|
|
733
|
-
oracle: {
|
|
734
|
-
supra: "",
|
|
735
|
-
switchboard: "",
|
|
736
|
-
pyth: {
|
|
737
|
-
feed: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc",
|
|
738
|
-
feedObject: "0xf6de1d3279a269a597d813cbaca59aa906543ab9a8c64e84a4722f1a20863985"
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
},
|
|
743
|
-
oracles: {
|
|
744
|
-
xOracle: "0x93d5bf0936b71eb27255941e532fac33b5a5c7759e377b4923af0a1359ad494f",
|
|
745
|
-
xOracleCap: "0x1edeae568fde99e090dbdec4bcdbd33a15f53a1ce1f87aeef1a560dedf4b4a90",
|
|
746
|
-
supra: { registry: "", registryCap: "", holder: "" },
|
|
747
|
-
switchboard: { registry: "", registryCap: "" },
|
|
748
|
-
pyth: {
|
|
749
|
-
registry: "0xedc293f9413a5a7a5d53bdba1fd889d0a4030894469228f0acdae4aa3c55a213",
|
|
750
|
-
registryCap: "0xbcb07141eb1f7e01fbda4130ecf5f5adaeabb77f5d9c32158b7532bcd2197acd",
|
|
751
|
-
state: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
|
|
752
|
-
wormhole: "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a",
|
|
753
|
-
wormholeState: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c"
|
|
754
|
-
}
|
|
755
|
-
},
|
|
756
|
-
packages: {
|
|
757
|
-
coinDecimalsRegistry: {
|
|
758
|
-
id: "0xca5a5a62f01c79a104bf4d31669e29daa387f325c241de4edbe30986a9bc8b0d",
|
|
759
|
-
upgradeCap: "0x34e76a945d29f195bc53ca704fa70877d1cf3a5d7bbfdda1b13e633fff13c0f6"
|
|
760
|
-
},
|
|
761
|
-
math: {
|
|
762
|
-
id: "0xad013d5fde39e15eabda32b3dbdafd67dac32b798ce63237c27a8f73339b9b6f",
|
|
763
|
-
upgradeCap: "0x3a329598231de02e6135c62284b66005b41cad1d9ab7ca2dc79c08293aba2ec6"
|
|
764
|
-
},
|
|
765
|
-
whitelist: {
|
|
766
|
-
id: "0x1318fdc90319ec9c24df1456d960a447521b0a658316155895014a6e39b5482f",
|
|
767
|
-
upgradeCap: "0xf5a22aea23db664f7b69855b6a546747f17c1ec4230319cfc17225e462b05761"
|
|
768
|
-
},
|
|
769
|
-
x: {
|
|
770
|
-
id: "0x779b5c547976899f5474f3a5bc0db36ddf4697ad7e5a901db0415c2281d28162",
|
|
771
|
-
upgradeCap: "0x3f203f6fff6a69d151e4f1cd931f22b68c489ef2759765662fc7baf673943c9e"
|
|
772
|
-
},
|
|
773
|
-
protocol: {
|
|
774
|
-
id: "0x87ddec2984645dbbe2403a509cc6edf393a43acdba9b77d45da2bcbefcf733c1",
|
|
775
|
-
upgradeCap: "0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a"
|
|
776
|
-
},
|
|
777
|
-
// protocol: {
|
|
778
|
-
// id: '0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e',
|
|
779
|
-
// upgradeCap:
|
|
780
|
-
// '0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a',
|
|
781
|
-
// },
|
|
782
|
-
protocolWhitelist: {
|
|
783
|
-
id: "0x4c262d9343dac53ecb28f482a2a3f62c73d0ebac5b5f03d57383d56ff219acdf",
|
|
784
|
-
upgradeCap: "0x4a5e88a75039b00988f633f811f58117f31b8627a46bf822aa114d9010049449"
|
|
785
|
-
},
|
|
786
|
-
// query: {
|
|
787
|
-
// id: '0xb8d603a39114a5efef3dd0bf84df0bed1be1fbd39b78b7dd6e8a61ccc5e6006f',
|
|
788
|
-
// upgradeCap:
|
|
789
|
-
// '0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f',
|
|
790
|
-
// },
|
|
791
|
-
query: {
|
|
792
|
-
id: "0xe4f9d62d17746d5b9dbf0d5557747430021a71575780b515161210cdba0a4c1c",
|
|
793
|
-
upgradeCap: "0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f"
|
|
794
|
-
},
|
|
795
|
-
supra: { id: "", upgradeCap: "" },
|
|
796
|
-
pyth: {
|
|
797
|
-
id: "0x910f30cbc7f601f75a5141a01265cd47c62d468707c5e1aecb32a18f448cb25a",
|
|
798
|
-
upgradeCap: "0xdf0ffbae1ea5bb25fbca5efba433dcf00c7cced65679af2f04728901275c6157"
|
|
799
|
-
},
|
|
800
|
-
switchboard: { id: "", upgradeCap: "" },
|
|
801
|
-
xOracle: {
|
|
802
|
-
id: "0x1478a432123e4b3d61878b629f2c692969fdb375644f1251cd278a4b1e7d7cd6",
|
|
803
|
-
upgradeCap: "0x0f928a6b2e26b73330fecaf9b44acfc9800a4a9794d6415c2a3153bc70e3c1f0"
|
|
804
|
-
},
|
|
805
|
-
testCoin: { id: "", upgradeCap: "" }
|
|
806
|
-
}
|
|
807
|
-
},
|
|
808
|
-
spool: {
|
|
809
|
-
// id: '0x7c4fdabe81c31b19a45d1e572a52a539997a90903fbb5bfab71480abe0fa62c3',
|
|
810
|
-
id: "0x1742655fe5872dfa6456673f9e38612a4965e6979e6cd7696a7f1225f28bae21",
|
|
811
|
-
adminCap: "0xdd8a047cbbf802bfcde5288b8ef1910965d789cc614da11d39af05fca0bd020a",
|
|
812
|
-
// object:
|
|
813
|
-
// '0xe87f1b2d498106a2c61421cec75b7b5c5e348512b0dc263949a0e7a3c256571a',
|
|
814
|
-
object: "0x1742655fe5872dfa6456673f9e38612a4965e6979e6cd7696a7f1225f28bae21",
|
|
815
|
-
pools: {
|
|
816
|
-
seth: {
|
|
817
|
-
id: "0xeec40beccb07c575bebd842eeaabb835f77cd3dab73add433477e57f583a6787",
|
|
818
|
-
rewardPoolId: "0x957de68a18d87817de8309b30c1ec269a4d87ae513abbeed86b5619cb9ce1077"
|
|
819
|
-
},
|
|
820
|
-
ssui: {
|
|
821
|
-
// id: '0x4f0ba970d3c11db05c8f40c64a15b6a33322db3702d634ced6536960ab6f3ee4',
|
|
822
|
-
id: "0xb9617f83c06ebdeac0a8834782b1015e1cc7ea23739e30c132c4bfb95c37a579",
|
|
823
|
-
rewardPoolId: (
|
|
824
|
-
// '0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9',
|
|
825
|
-
"0xc3206071a8d43212efb6e3b5504f2321f8df97ab122b466c0bc7cfdf398dc13a"
|
|
826
|
-
)
|
|
827
|
-
},
|
|
828
|
-
susdc: {
|
|
829
|
-
// id: '0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0',
|
|
830
|
-
id: "0xf1b383b9cf2e9f515fc69567df1053098f273849d09cd84b0278a773429bd2b2",
|
|
831
|
-
rewardPoolId: (
|
|
832
|
-
// '0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8',
|
|
833
|
-
"0xc71c53ee6505d928ba15bea4fe4f45d98c9c31eced94b72d00a7827d4b7ba3ff"
|
|
834
|
-
)
|
|
835
|
-
},
|
|
836
|
-
susdt: {
|
|
837
|
-
// id: '0xcb328f7ffa7f9342ed85af3fdb2f22919e1a06dfb2f713c04c73543870d7548f',
|
|
838
|
-
id: "0xb5567dfa5c7fc17a249e959732664c50713dd8c23db1a11376b27df800c17418",
|
|
839
|
-
rewardPoolId: (
|
|
840
|
-
// '0x2c9f934d67a5baa586ceec2cc24163a2f049a6af3d5ba36b84d8ac40f25c4080',
|
|
841
|
-
"0x60768b0687ff0235e376a039709a683e4c436098785e473b67b32dbab47b69ab"
|
|
842
|
-
)
|
|
843
|
-
},
|
|
844
|
-
scetus: {
|
|
845
|
-
id: "0xac1bb13bf4472a637c18c2415fb0e3c1227ea2bcf35242e50563c98215bd298e",
|
|
846
|
-
rewardPoolId: "0x6835c1224126a45086fc6406adc249e3f30df18d779ca4f4e570e38716a17f3f"
|
|
847
|
-
},
|
|
848
|
-
safsui: {
|
|
849
|
-
// id: '0xeedf438abcaa6ce4d9625ffca110920592d5867e4c5637d84ad9f466c4feb800',
|
|
850
|
-
id: "0xc568bb4c991258e839aa54802ecda04fcd9838c826bc3b42b40af81b23c458c8",
|
|
851
|
-
rewardPoolId: (
|
|
852
|
-
// '0x89255a2f86ed7fbfef35ab8b7be48cc7667015975be2685dd9a55a9a64baf76e',
|
|
853
|
-
"0x389a3cbeda742b918941bb24fd00e077bad3367484394d6234f8209b9a6aa03d"
|
|
854
|
-
)
|
|
855
|
-
},
|
|
856
|
-
shasui: {
|
|
857
|
-
// id: '0xa6148bc1b623e936d39a952ceb5bea79e8b37228a8f595067bf1852efd3c34aa',
|
|
858
|
-
id: "0x93f3f4499bf89f2d05ddc1f8b15f51701a7c6c4d0ac0b9c3bc99462cbbd8e321",
|
|
859
|
-
rewardPoolId: (
|
|
860
|
-
// '0x6f3563644d3e2ef13176dbf9d865bd93479df60ccbe07b7e66db57f6309f5a66',
|
|
861
|
-
"0x94cee1be7f5ff34193f3aabef0b14142cb28af4d905fe487a9a7d85a15edb6aa"
|
|
862
|
-
)
|
|
863
|
-
},
|
|
864
|
-
svsui: {
|
|
865
|
-
// id: '0x69ce8e537e750a95381e6040794afa5ab1758353a1a2e1de7760391b01f91670',
|
|
866
|
-
id: "0xa970e9087f80cb59e9299b8e7af7175d977ad6c9af0322aa4440e138fbd7ae00",
|
|
867
|
-
rewardPoolId: (
|
|
868
|
-
// '0xbca914adce058ad0902c7f3cfcd698392a475f00dcfdc3f76001d0370b98777a',
|
|
869
|
-
"0x38eee9699c4fc132a6623e54b865f047df4fc6eb83af807300f44e8f4b235ff0"
|
|
870
|
-
)
|
|
871
|
-
}
|
|
872
|
-
},
|
|
873
|
-
config: ""
|
|
874
|
-
},
|
|
875
|
-
borrowIncentive: {
|
|
876
|
-
id: "0x6152f696fc3a658f33c4b891764731a59153125ffedfa8bff7167c42823f58a9",
|
|
877
|
-
adminCap: "0xc486afa253646f4d381e81d7f1df8aa4723b845a6bb356f69bad635ffefffe2c",
|
|
878
|
-
object: "0x002875153e09f8145ab63527bc85c00f2bd102e12f9573c47f8cdf1a1cb62934",
|
|
879
|
-
query: "0x529edc54a3dce2207703ceebbccb0ac14133f7825c1f528775ba0d85a4063489",
|
|
880
|
-
incentivePools: "0x6547e143d406b5ccd5f46aae482497de279cc1a68c406f701df70a05f9212ab4",
|
|
881
|
-
incentiveAccounts: "0xc4701fdbc1c92f9a636d334d66012b3027659e9fb8aff27279a82edfb6b77d02",
|
|
882
|
-
config: "0xdf5d04b4691cc67e82fd4db8394d89ff44823a9de29716c924f74bb4f11cc1f7"
|
|
883
|
-
},
|
|
884
|
-
referral: {
|
|
885
|
-
id: "0xa3654ebb63eb06c0f4ff52f8aa6512df9f164f7772bdf15dac3709bd3798dda9",
|
|
886
|
-
object: "0x5658d4bf5ddcba27e4337b4262108b3ad1716643cac8c2054ac341538adc72ec",
|
|
887
|
-
adminCap: "0xc5dc06b9074291259f2cac460c940012c781c4430e42125c541cc43101c3bcbd",
|
|
888
|
-
referralBindings: "0xf63299d58789d99de94092b9011323466e55ca0c1ea1a7a3786a589af46e1c09",
|
|
889
|
-
bindingTableId: "0x1c8202b17267ec8d6cf97ca013615354181a04f179570e42601ff2dae19294b1",
|
|
890
|
-
referralRevenuePool: "0x6abd852caf90769c1b185cdf636d841673fa95528f0550f018b8a138bd283c07",
|
|
891
|
-
revenueTableId: "0x595baa3654c297bff84ab7786a2d250f019cefc66e8df8e89fd9d41e02bd30dd",
|
|
892
|
-
referralTiers: "0x962cb903d8d7346190c5204785ccbb91b61086aa764f674c8145df82335cf83e",
|
|
893
|
-
tiersTableId: "0xeac755a7a8b7798530905ac79e8c114f19d0f130f6eab012954f08faac29c75d",
|
|
894
|
-
// authorizedWitnessList:
|
|
895
|
-
// '0xf21b0ed043c9bb70842c0129159f4943dbcc3c9ef2f2f808af65f8be25cfd20e',
|
|
896
|
-
authorizedWitnessList: "0x9d6223dc52015b8a3986a573590ef2af8f1b8f3e4685513888c052f001b87e7f",
|
|
897
|
-
version: "0x1bd4b7285f72e11c316b828c7c47b3f4da18dcec9f9b3dba6d8629cbb6f93e5e"
|
|
898
|
-
},
|
|
899
|
-
vesca: {
|
|
900
|
-
id: "0xb15b6e0cdd85afb5028bea851dd249405e734d800a259147bbc24980629723a4",
|
|
901
|
-
object: "0xb15b6e0cdd85afb5028bea851dd249405e734d800a259147bbc24980629723a4",
|
|
902
|
-
adminCap: "0x8ffa76135c5b85c5fbd73a6448a4a733d826cb63a267ab817656acb77c72d4a5",
|
|
903
|
-
tableId: "0xe3153b2bf124be0b86cb8bd468346a861efd0da52fc42197b54d2f616488a311",
|
|
904
|
-
table: "0x611cb8d9d4d90867467b5ebdf4cc447a0047ed5b01334a28a29fcfe733e3d609",
|
|
905
|
-
treasury: "0xe8c112c09b88158dc6c8e23d1fbae5b3c7136cdee54b7dafc08e65db28c4a5bc",
|
|
906
|
-
config: "0xe0a2ff281e73c1d53cfa85807080f87e833e4f1a7f93dcf8800b3865269a76b9"
|
|
907
|
-
},
|
|
908
|
-
loyaltyProgram: {
|
|
909
|
-
id: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
910
|
-
object: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
911
|
-
rewardPool: "0xf9c090492ef476bd542109d0913ffe871cbfa28578b7114eca2a8c0e5671786f",
|
|
912
|
-
userRewardTableId: "0x748a80395849ed37db1b0e14f2ab5d1d96458d2359ab3a84eb079d0f4ac7cf2e"
|
|
913
|
-
},
|
|
914
|
-
scoin: {
|
|
915
|
-
id: "0xad2ca2aa5089df94bb2d444d5eb3520378c2f2dfb3a0bd2a2c994145ac4b0a53",
|
|
916
|
-
coins: {
|
|
917
|
-
ssui: {
|
|
918
|
-
coinType: "0xfac769100bccc0caebcf4f4e2d00ac2f8883f07f724be28940df90605f5e7e9a::scallop_sui::SCALLOP_SUI",
|
|
919
|
-
treasury: "0x9cb4551b36c17d37e19d700147fa819ea1c487ff8bcf18374de2cceb2e9d4845"
|
|
920
|
-
},
|
|
921
|
-
scetus: {
|
|
922
|
-
coinType: "0x8b71e6d323ed78515af2bead13bf3d0da1562ba4a99234eb7c4f14fd39ef0427::scallop_cetus::SCALLOP_CETUS",
|
|
923
|
-
treasury: "0xd786f4b2d26278cc7911a3445b1b085eab60f269ef9dbb6b87e803d52f155003"
|
|
924
|
-
},
|
|
925
|
-
ssca: {
|
|
926
|
-
coinType: "0x0a9d3c6c9af9f6e8def82921541bcbd17f73ed31bed3adcb684f2a4c267e42f0::scallop_sca::SCALLOP_SCA",
|
|
927
|
-
treasury: "0xe818636d1d6c46d6ea1a2dce9d94696d7cbc18ce27451b603eeaa47aba8d75e0"
|
|
928
|
-
},
|
|
929
|
-
susdc: {
|
|
930
|
-
coinType: "0xaedc3ab75db8680b81a755015fa90124d217be93457b893c05bac033817defaf::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
|
|
931
|
-
treasury: "0xfc6971648f867f7fd6928d1b873af71577e2eaf2c7543ef8bc82c431d833ae78"
|
|
932
|
-
},
|
|
933
|
-
susdt: {
|
|
934
|
-
coinType: "0xbf02fc87ddc104b342ad8414c85ceadf5b0c823c055a06fb0ed776272c01a52a::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
|
|
935
|
-
treasury: "0xb9593e2c3a0ba796ee815012b75ae46468ea78cda0188b9ac6816efe65503521"
|
|
936
|
-
},
|
|
937
|
-
seth: {
|
|
938
|
-
coinType: "0x27d54f43e3eda701be56b82e5756e41c84467cd202f5cf713d5f9e45a9f1b6bc::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
|
|
939
|
-
treasury: "0x032b4c8fac94c038dbe986f7587e9b1e4ef580b5ee06d2ef249d85459b7ef05d"
|
|
940
|
-
},
|
|
941
|
-
safsui: {
|
|
942
|
-
coinType: "0xb75b46d975d8d80670b53a6bee90baaa8ce2e0b7d397f079447d641eef6b44ad::scallop_af_sui::SCALLOP_AF_SUI",
|
|
943
|
-
treasury: "0x21450ef0570ef3d224ffa3b873ab802e439ece7b93cc7efad10ae0c1e3b3fcfe"
|
|
944
|
-
},
|
|
945
|
-
shasui: {
|
|
946
|
-
coinType: "0xd973a723874e2c7cde196602a79155a1343a933f8cf87d9b1bb7408bc1acbc58::scallop_ha_sui::SCALLOP_HA_SUI",
|
|
947
|
-
treasury: "0xf822fc1402207e47d2e3ba8ff6e1e594bf1de777dc5ebd2744619cd2726e3b0d"
|
|
948
|
-
},
|
|
949
|
-
svsui: {
|
|
950
|
-
coinType: "0x97023a317320c4498cc4cd239dd02fd30c28246e5e8f81325d63f2bd8d70f6b3::scallop_v_sui::SCALLOP_V_SUI",
|
|
951
|
-
treasury: "0x327114f0bf3559d7e2de10282147ed76a236c7c6775029165c4db09a6062ead6\u0192"
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
}
|
|
441
|
+
// src/utils/query.ts
|
|
442
|
+
var import_bignumber = __toESM(require("bignumber.js"));
|
|
443
|
+
var import_utils = require("@mysten/sui.js/utils");
|
|
444
|
+
var parseOriginMarketPoolData = (originMarketPoolData) => {
|
|
445
|
+
return {
|
|
446
|
+
coinType: (0, import_utils.normalizeStructTag)(originMarketPoolData.type.name),
|
|
447
|
+
// Parse origin data required for basic calculations.
|
|
448
|
+
maxBorrowRate: Number(originMarketPoolData.maxBorrowRate.value) / 2 ** 32,
|
|
449
|
+
borrowRate: Number(originMarketPoolData.interestRate.value) / 2 ** 32,
|
|
450
|
+
borrowRateScale: Number(originMarketPoolData.interestRateScale),
|
|
451
|
+
borrowIndex: Number(originMarketPoolData.borrowIndex),
|
|
452
|
+
lastUpdated: Number(originMarketPoolData.lastUpdated),
|
|
453
|
+
cashAmount: Number(originMarketPoolData.cash),
|
|
454
|
+
debtAmount: Number(originMarketPoolData.debt),
|
|
455
|
+
marketCoinSupplyAmount: Number(originMarketPoolData.marketCoinSupply),
|
|
456
|
+
reserveAmount: Number(originMarketPoolData.reserve),
|
|
457
|
+
reserveFactor: Number(originMarketPoolData.reserveFactor.value) / 2 ** 32,
|
|
458
|
+
borrowWeight: Number(originMarketPoolData.borrowWeight.value) / 2 ** 32,
|
|
459
|
+
borrowFee: Number(originMarketPoolData.borrowFeeRate.value) / 2 ** 32,
|
|
460
|
+
// Parse origin data required for additional display.
|
|
461
|
+
baseBorrowRate: Number(originMarketPoolData.baseBorrowRatePerSec.value) / 2 ** 32,
|
|
462
|
+
borrowRateOnHighKink: Number(originMarketPoolData.borrowRateOnHighKink.value) / 2 ** 32,
|
|
463
|
+
borrowRateOnMidKink: Number(originMarketPoolData.borrowRateOnMidKink.value) / 2 ** 32,
|
|
464
|
+
highKink: Number(originMarketPoolData.highKink.value) / 2 ** 32,
|
|
465
|
+
midKink: Number(originMarketPoolData.midKink.value) / 2 ** 32,
|
|
466
|
+
minBorrowAmount: Number(originMarketPoolData.minBorrowAmount)
|
|
467
|
+
};
|
|
955
468
|
};
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
469
|
+
var calculateMarketPoolData = (utils, parsedMarketPoolData) => {
|
|
470
|
+
const poolCoinName = utils.parseCoinNameFromType(
|
|
471
|
+
parsedMarketPoolData.coinType
|
|
472
|
+
);
|
|
473
|
+
const coinDecimal = utils.getCoinDecimal(poolCoinName);
|
|
474
|
+
const borrowYearFactor = 24 * 365 * 3600;
|
|
475
|
+
const baseBorrowApr = parsedMarketPoolData.baseBorrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
476
|
+
const borrowAprOnHighKink = parsedMarketPoolData.borrowRateOnHighKink * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
477
|
+
const borrowAprOnMidKink = parsedMarketPoolData.borrowRateOnMidKink * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
478
|
+
const maxBorrowApr = parsedMarketPoolData.maxBorrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
479
|
+
const borrowApr = parsedMarketPoolData.borrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
480
|
+
const timeDelta = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - parsedMarketPoolData.lastUpdated;
|
|
481
|
+
const borrowIndexDelta = (0, import_bignumber.default)(parsedMarketPoolData.borrowIndex).multipliedBy(
|
|
482
|
+
(0, import_bignumber.default)(timeDelta).multipliedBy(parsedMarketPoolData.borrowRate)
|
|
483
|
+
).dividedBy(parsedMarketPoolData.borrowRateScale);
|
|
484
|
+
const currentBorrowIndex = (0, import_bignumber.default)(parsedMarketPoolData.borrowIndex).plus(
|
|
485
|
+
borrowIndexDelta
|
|
486
|
+
);
|
|
487
|
+
const growthInterest = (0, import_bignumber.default)(currentBorrowIndex).dividedBy(parsedMarketPoolData.borrowIndex).minus(1);
|
|
488
|
+
const increasedDebtAmount = (0, import_bignumber.default)(
|
|
489
|
+
parsedMarketPoolData.debtAmount
|
|
490
|
+
).multipliedBy(growthInterest);
|
|
491
|
+
const borrowAmount = increasedDebtAmount.plus(
|
|
492
|
+
parsedMarketPoolData.debtAmount
|
|
493
|
+
);
|
|
494
|
+
const borrowCoin = borrowAmount.shiftedBy(-1 * coinDecimal);
|
|
495
|
+
const reserveAmount = (0, import_bignumber.default)(parsedMarketPoolData.reserveAmount).plus(
|
|
496
|
+
increasedDebtAmount.multipliedBy(parsedMarketPoolData.reserveFactor)
|
|
497
|
+
);
|
|
498
|
+
const reserveCoin = reserveAmount.shiftedBy(-1 * coinDecimal);
|
|
499
|
+
const supplyAmount = (0, import_bignumber.default)(borrowAmount).plus(
|
|
500
|
+
Math.max(parsedMarketPoolData.cashAmount - reserveAmount.toNumber(), 0)
|
|
501
|
+
);
|
|
502
|
+
const supplyCoin = supplyAmount.shiftedBy(-1 * coinDecimal);
|
|
503
|
+
let utilizationRate = (0, import_bignumber.default)(borrowAmount).dividedBy(supplyAmount);
|
|
504
|
+
utilizationRate = utilizationRate.isFinite() ? utilizationRate : (0, import_bignumber.default)(0);
|
|
505
|
+
let supplyApr = (0, import_bignumber.default)(borrowApr).multipliedBy(utilizationRate).multipliedBy(1 - parsedMarketPoolData.reserveFactor);
|
|
506
|
+
supplyApr = supplyApr.isFinite() ? supplyApr : (0, import_bignumber.default)(0);
|
|
507
|
+
let conversionRate = supplyAmount.dividedBy(
|
|
508
|
+
parsedMarketPoolData.marketCoinSupplyAmount
|
|
509
|
+
);
|
|
510
|
+
conversionRate = conversionRate.isFinite() && !conversionRate.isNaN() ? conversionRate : (0, import_bignumber.default)(1);
|
|
511
|
+
return {
|
|
512
|
+
baseBorrowApr,
|
|
513
|
+
baseBorrowApy: utils.parseAprToApy(baseBorrowApr),
|
|
514
|
+
borrowAprOnHighKink,
|
|
515
|
+
borrowApyOnHighKink: utils.parseAprToApy(borrowAprOnHighKink),
|
|
516
|
+
borrowAprOnMidKink,
|
|
517
|
+
borrowApyOnMidKink: utils.parseAprToApy(borrowAprOnMidKink),
|
|
518
|
+
maxBorrowApr,
|
|
519
|
+
maxBorrowApy: utils.parseAprToApy(maxBorrowApr),
|
|
520
|
+
borrowApr: Math.min(borrowApr, maxBorrowApr),
|
|
521
|
+
borrowApy: Math.min(
|
|
522
|
+
utils.parseAprToApy(borrowApr),
|
|
523
|
+
utils.parseAprToApy(maxBorrowApr)
|
|
524
|
+
),
|
|
525
|
+
borrowIndex: currentBorrowIndex.toNumber(),
|
|
526
|
+
growthInterest: growthInterest.toNumber(),
|
|
527
|
+
supplyAmount: supplyAmount.toNumber(),
|
|
528
|
+
supplyCoin: supplyCoin.toNumber(),
|
|
529
|
+
borrowAmount: borrowAmount.toNumber(),
|
|
530
|
+
borrowCoin: borrowCoin.toNumber(),
|
|
531
|
+
reserveAmount: reserveAmount.toNumber(),
|
|
532
|
+
reserveCoin: reserveCoin.toNumber(),
|
|
533
|
+
utilizationRate: utilizationRate.toNumber(),
|
|
534
|
+
supplyApr: supplyApr.toNumber(),
|
|
535
|
+
supplyApy: utils.parseAprToApy(supplyApr.toNumber()),
|
|
536
|
+
conversionRate: conversionRate.toNumber()
|
|
537
|
+
};
|
|
538
|
+
};
|
|
539
|
+
var parseOriginMarketCollateralData = (originMarketCollateralData) => {
|
|
540
|
+
const divisor = 2 ** 32;
|
|
541
|
+
return {
|
|
542
|
+
coinType: (0, import_utils.normalizeStructTag)(originMarketCollateralData.type.name),
|
|
543
|
+
collateralFactor: Number(originMarketCollateralData.collateralFactor.value) / divisor,
|
|
544
|
+
liquidationFactor: Number(originMarketCollateralData.liquidationFactor.value) / divisor,
|
|
545
|
+
liquidationDiscount: Number(originMarketCollateralData.liquidationDiscount.value) / divisor,
|
|
546
|
+
liquidationPanelty: Number(originMarketCollateralData.liquidationPanelty.value) / divisor,
|
|
547
|
+
liquidationReserveFactor: Number(originMarketCollateralData.liquidationReserveFactor.value) / divisor,
|
|
548
|
+
maxCollateralAmount: Number(originMarketCollateralData.maxCollateralAmount),
|
|
549
|
+
totalCollateralAmount: Number(
|
|
550
|
+
originMarketCollateralData.totalCollateralAmount
|
|
551
|
+
)
|
|
552
|
+
};
|
|
553
|
+
};
|
|
554
|
+
var calculateMarketCollateralData = (utils, parsedMarketCollateralData) => {
|
|
555
|
+
const collateralCoinName = utils.parseCoinNameFromType(
|
|
556
|
+
parsedMarketCollateralData.coinType
|
|
557
|
+
);
|
|
558
|
+
const coinDecimal = utils.getCoinDecimal(collateralCoinName);
|
|
559
|
+
const maxCollateralCoin = (0, import_bignumber.default)(
|
|
560
|
+
parsedMarketCollateralData.maxCollateralAmount
|
|
561
|
+
).shiftedBy(-1 * coinDecimal);
|
|
562
|
+
const depositCoin = (0, import_bignumber.default)(
|
|
563
|
+
parsedMarketCollateralData.totalCollateralAmount
|
|
564
|
+
).shiftedBy(-1 * coinDecimal);
|
|
565
|
+
return {
|
|
566
|
+
maxDepositAmount: parsedMarketCollateralData.maxCollateralAmount,
|
|
567
|
+
maxDepositCoin: maxCollateralCoin.toNumber(),
|
|
568
|
+
depositAmount: parsedMarketCollateralData.totalCollateralAmount,
|
|
569
|
+
depositCoin: depositCoin.toNumber()
|
|
570
|
+
};
|
|
571
|
+
};
|
|
572
|
+
var parseOriginSpoolData = (originSpoolData) => {
|
|
573
|
+
return {
|
|
574
|
+
stakeType: (0, import_utils.normalizeStructTag)(originSpoolData.stakeType.fields.name),
|
|
575
|
+
maxPoint: Number(originSpoolData.maxDistributedPoint),
|
|
576
|
+
distributedPoint: Number(originSpoolData.distributedPoint),
|
|
577
|
+
pointPerPeriod: Number(originSpoolData.distributedPointPerPeriod),
|
|
578
|
+
period: Number(originSpoolData.pointDistributionTime),
|
|
579
|
+
maxStake: Number(originSpoolData.maxStake),
|
|
580
|
+
staked: Number(originSpoolData.stakes),
|
|
581
|
+
index: Number(originSpoolData.index),
|
|
582
|
+
createdAt: Number(originSpoolData.createdAt),
|
|
583
|
+
lastUpdate: Number(originSpoolData.lastUpdate)
|
|
584
|
+
};
|
|
585
|
+
};
|
|
586
|
+
var calculateSpoolData = (parsedSpoolData, stakeMarketCoinPrice, stakeMarketCoinDecimal) => {
|
|
587
|
+
const baseIndexRate = 1e9;
|
|
588
|
+
const distributedPointPerSec = (0, import_bignumber.default)(
|
|
589
|
+
parsedSpoolData.pointPerPeriod
|
|
590
|
+
).dividedBy(parsedSpoolData.period);
|
|
591
|
+
const pointPerSec = (0, import_bignumber.default)(parsedSpoolData.pointPerPeriod).dividedBy(
|
|
592
|
+
parsedSpoolData.period
|
|
593
|
+
);
|
|
594
|
+
const remainingPeriod = pointPerSec.gt(0) ? (0, import_bignumber.default)(parsedSpoolData.maxPoint).minus(parsedSpoolData.distributedPoint).dividedBy(pointPerSec) : (0, import_bignumber.default)(0);
|
|
595
|
+
const startDate = parsedSpoolData.createdAt;
|
|
596
|
+
const endDate = remainingPeriod.plus(parsedSpoolData.lastUpdate).integerValue().toNumber();
|
|
597
|
+
const timeDelta = (0, import_bignumber.default)(
|
|
598
|
+
Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - parsedSpoolData.lastUpdate
|
|
599
|
+
).dividedBy(parsedSpoolData.period).toFixed(0);
|
|
600
|
+
const remainingPoints = (0, import_bignumber.default)(parsedSpoolData.maxPoint).minus(
|
|
601
|
+
parsedSpoolData.distributedPoint
|
|
602
|
+
);
|
|
603
|
+
const accumulatedPoints = import_bignumber.default.minimum(
|
|
604
|
+
(0, import_bignumber.default)(timeDelta).multipliedBy(parsedSpoolData.pointPerPeriod),
|
|
605
|
+
remainingPoints
|
|
606
|
+
);
|
|
607
|
+
const currentPointIndex = (0, import_bignumber.default)(parsedSpoolData.index).plus(
|
|
608
|
+
accumulatedPoints.dividedBy(parsedSpoolData.staked).isFinite() ? (0, import_bignumber.default)(baseIndexRate).multipliedBy(accumulatedPoints).dividedBy(parsedSpoolData.staked) : 0
|
|
609
|
+
);
|
|
610
|
+
const currentTotalDistributedPoint = (0, import_bignumber.default)(
|
|
611
|
+
parsedSpoolData.distributedPoint
|
|
612
|
+
).plus(accumulatedPoints);
|
|
613
|
+
const stakedAmount = (0, import_bignumber.default)(parsedSpoolData.staked);
|
|
614
|
+
const stakedCoin = stakedAmount.shiftedBy(-1 * stakeMarketCoinDecimal);
|
|
615
|
+
const stakedValue = stakedCoin.multipliedBy(stakeMarketCoinPrice);
|
|
616
|
+
return {
|
|
617
|
+
distributedPointPerSec: distributedPointPerSec.toNumber(),
|
|
618
|
+
accumulatedPoints: accumulatedPoints.toNumber(),
|
|
619
|
+
currentPointIndex: currentPointIndex.toNumber(),
|
|
620
|
+
currentTotalDistributedPoint: currentTotalDistributedPoint.toNumber(),
|
|
621
|
+
startDate: new Date(startDate * 1e3),
|
|
622
|
+
endDate: new Date(endDate * 1e3),
|
|
623
|
+
stakedAmount: stakedAmount.toNumber(),
|
|
624
|
+
stakedCoin: stakedCoin.toNumber(),
|
|
625
|
+
stakedValue: stakedValue.toNumber()
|
|
626
|
+
};
|
|
627
|
+
};
|
|
628
|
+
var parseOriginSpoolRewardPoolData = (originSpoolRewardPoolData) => {
|
|
629
|
+
return {
|
|
630
|
+
claimedRewards: Number(originSpoolRewardPoolData.claimed_rewards),
|
|
631
|
+
exchangeRateDenominator: Number(
|
|
632
|
+
originSpoolRewardPoolData.exchange_rate_denominator
|
|
633
|
+
),
|
|
634
|
+
exchangeRateNumerator: Number(
|
|
635
|
+
originSpoolRewardPoolData.exchange_rate_numerator
|
|
636
|
+
),
|
|
637
|
+
rewards: Number(originSpoolRewardPoolData.rewards),
|
|
638
|
+
spoolId: String(originSpoolRewardPoolData.spool_id)
|
|
639
|
+
};
|
|
640
|
+
};
|
|
641
|
+
var calculateSpoolRewardPoolData = (parsedSpoolData, parsedSpoolRewardPoolData, calculatedSpoolData, rewardCoinPrice, rewardCoinDecimal) => {
|
|
642
|
+
const rateYearFactor = 365 * 24 * 60 * 60;
|
|
643
|
+
const rewardPerSec = (0, import_bignumber.default)(calculatedSpoolData.distributedPointPerSec).multipliedBy(parsedSpoolRewardPoolData.exchangeRateNumerator).dividedBy(parsedSpoolRewardPoolData.exchangeRateDenominator);
|
|
644
|
+
const totalRewardAmount = (0, import_bignumber.default)(parsedSpoolData.maxPoint).multipliedBy(parsedSpoolRewardPoolData.exchangeRateNumerator).dividedBy(parsedSpoolRewardPoolData.exchangeRateDenominator);
|
|
645
|
+
const totalRewardCoin = totalRewardAmount.shiftedBy(-1 * rewardCoinDecimal);
|
|
646
|
+
const totalRewardValue = totalRewardCoin.multipliedBy(rewardCoinPrice);
|
|
647
|
+
const remaindRewardAmount = (0, import_bignumber.default)(parsedSpoolRewardPoolData.rewards);
|
|
648
|
+
const remaindRewardCoin = remaindRewardAmount.shiftedBy(
|
|
649
|
+
-1 * rewardCoinDecimal
|
|
650
|
+
);
|
|
651
|
+
const remaindRewardValue = remaindRewardCoin.multipliedBy(rewardCoinPrice);
|
|
652
|
+
const claimedRewardAmount = (0, import_bignumber.default)(
|
|
653
|
+
parsedSpoolRewardPoolData.claimedRewards
|
|
654
|
+
);
|
|
655
|
+
const claimedRewardCoin = claimedRewardAmount.shiftedBy(
|
|
656
|
+
-1 * rewardCoinDecimal
|
|
657
|
+
);
|
|
658
|
+
const claimedRewardValue = claimedRewardCoin.multipliedBy(rewardCoinPrice);
|
|
659
|
+
const rewardValueForYear = (0, import_bignumber.default)(rewardPerSec).shiftedBy(-1 * rewardCoinDecimal).multipliedBy(rateYearFactor).multipliedBy(rewardCoinPrice);
|
|
660
|
+
let rewardRate = rewardValueForYear.dividedBy(calculatedSpoolData.stakedValue).isFinite() ? rewardValueForYear.dividedBy(calculatedSpoolData.stakedValue).toNumber() : Infinity;
|
|
661
|
+
if (parsedSpoolData.maxPoint <= parsedSpoolData.distributedPoint || parsedSpoolData.pointPerPeriod === 0) {
|
|
662
|
+
rewardRate = Infinity;
|
|
663
|
+
}
|
|
664
|
+
return {
|
|
665
|
+
rewardApr: rewardRate,
|
|
666
|
+
totalRewardAmount: totalRewardAmount.toNumber(),
|
|
667
|
+
totalRewardCoin: totalRewardCoin.toNumber(),
|
|
668
|
+
totalRewardValue: totalRewardValue.toNumber(),
|
|
669
|
+
remaindRewardAmount: remaindRewardAmount.toNumber(),
|
|
670
|
+
remaindRewardCoin: remaindRewardCoin.toNumber(),
|
|
671
|
+
remaindRewardValue: remaindRewardValue.toNumber(),
|
|
672
|
+
claimedRewardAmount: claimedRewardAmount.toNumber(),
|
|
673
|
+
claimedRewardCoin: claimedRewardCoin.toNumber(),
|
|
674
|
+
claimedRewardValue: claimedRewardValue.toNumber(),
|
|
675
|
+
rewardPerSec: rewardPerSec.toNumber()
|
|
676
|
+
};
|
|
677
|
+
};
|
|
678
|
+
var parseOriginBorrowIncentivesPoolPointData = (originBorrowIncentivePoolPointData) => {
|
|
679
|
+
return {
|
|
680
|
+
pointType: (0, import_utils.normalizeStructTag)(
|
|
681
|
+
originBorrowIncentivePoolPointData.point_type.name
|
|
682
|
+
),
|
|
683
|
+
distributedPointPerPeriod: Number(
|
|
684
|
+
originBorrowIncentivePoolPointData.distributed_point_per_period
|
|
685
|
+
),
|
|
686
|
+
period: Number(originBorrowIncentivePoolPointData.point_distribution_time),
|
|
687
|
+
distributedPoint: Number(
|
|
688
|
+
originBorrowIncentivePoolPointData.distributed_point
|
|
689
|
+
),
|
|
690
|
+
points: Number(originBorrowIncentivePoolPointData.points),
|
|
691
|
+
index: Number(originBorrowIncentivePoolPointData.index),
|
|
692
|
+
baseWeight: Number(originBorrowIncentivePoolPointData.base_weight),
|
|
693
|
+
weightedAmount: Number(originBorrowIncentivePoolPointData.weighted_amount),
|
|
694
|
+
lastUpdate: Number(originBorrowIncentivePoolPointData.last_update)
|
|
695
|
+
};
|
|
696
|
+
};
|
|
697
|
+
var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
|
|
698
|
+
return {
|
|
699
|
+
poolType: (0, import_utils.normalizeStructTag)(originBorrowIncentivePoolData.pool_type.name),
|
|
700
|
+
minStakes: Number(originBorrowIncentivePoolData.min_stakes),
|
|
701
|
+
maxStakes: Number(originBorrowIncentivePoolData.max_stakes),
|
|
702
|
+
staked: Number(originBorrowIncentivePoolData.stakes),
|
|
703
|
+
createdAt: Number(originBorrowIncentivePoolData.created_at),
|
|
704
|
+
poolPoints: originBorrowIncentivePoolData.points.reduce(
|
|
705
|
+
(acc, point) => {
|
|
706
|
+
const parsed = parseOriginBorrowIncentivesPoolPointData(point);
|
|
707
|
+
const name = (0, import_utils.parseStructTag)(
|
|
708
|
+
parsed.pointType
|
|
709
|
+
).name.toLowerCase();
|
|
710
|
+
acc[name] = parsed;
|
|
711
|
+
return acc;
|
|
1032
712
|
},
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
713
|
+
{}
|
|
714
|
+
)
|
|
715
|
+
};
|
|
716
|
+
};
|
|
717
|
+
var calculateBorrowIncentivePoolPointData = (parsedBorrowIncentivePoolData, parsedBorrowIncentivePoolPointData, rewardCoinPrice, rewardCoinDecimal, poolCoinPrice, poolCoinDecimal) => {
|
|
718
|
+
const baseIndexRate = 1e9;
|
|
719
|
+
const distributedPointPerSec = (0, import_bignumber.default)(
|
|
720
|
+
parsedBorrowIncentivePoolPointData.distributedPointPerPeriod
|
|
721
|
+
).dividedBy(parsedBorrowIncentivePoolPointData.period);
|
|
722
|
+
const timeDelta = (0, import_bignumber.default)(
|
|
723
|
+
Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - parsedBorrowIncentivePoolPointData.lastUpdate
|
|
724
|
+
).dividedBy(parsedBorrowIncentivePoolPointData.period).toFixed(0);
|
|
725
|
+
const accumulatedPoints = import_bignumber.default.minimum(
|
|
726
|
+
(0, import_bignumber.default)(timeDelta).multipliedBy(
|
|
727
|
+
parsedBorrowIncentivePoolPointData.distributedPointPerPeriod
|
|
728
|
+
),
|
|
729
|
+
(0, import_bignumber.default)(parsedBorrowIncentivePoolPointData.points)
|
|
730
|
+
);
|
|
731
|
+
const currentPointIndex = (0, import_bignumber.default)(
|
|
732
|
+
parsedBorrowIncentivePoolPointData.index
|
|
733
|
+
).plus(
|
|
734
|
+
accumulatedPoints.dividedBy(parsedBorrowIncentivePoolPointData.weightedAmount).isFinite() ? (0, import_bignumber.default)(baseIndexRate).multipliedBy(accumulatedPoints).dividedBy(parsedBorrowIncentivePoolPointData.weightedAmount) : 0
|
|
735
|
+
);
|
|
736
|
+
const currentTotalDistributedPoint = (0, import_bignumber.default)(
|
|
737
|
+
parsedBorrowIncentivePoolPointData.distributedPoint
|
|
738
|
+
).plus(accumulatedPoints);
|
|
739
|
+
const baseWeight = (0, import_bignumber.default)(parsedBorrowIncentivePoolPointData.baseWeight);
|
|
740
|
+
const weightedStakedAmount = (0, import_bignumber.default)(
|
|
741
|
+
parsedBorrowIncentivePoolPointData.weightedAmount
|
|
742
|
+
);
|
|
743
|
+
const weightedStakedCoin = weightedStakedAmount.shiftedBy(
|
|
744
|
+
-1 * poolCoinDecimal
|
|
745
|
+
);
|
|
746
|
+
const weightedStakedValue = weightedStakedCoin.multipliedBy(poolCoinPrice);
|
|
747
|
+
const rateYearFactor = 365 * 24 * 60 * 60;
|
|
748
|
+
const rewardPerSec = (0, import_bignumber.default)(distributedPointPerSec).shiftedBy(
|
|
749
|
+
-1 * rewardCoinDecimal
|
|
750
|
+
);
|
|
751
|
+
const rewardValueForYear = (0, import_bignumber.default)(rewardPerSec).multipliedBy(rateYearFactor).multipliedBy(rewardCoinPrice);
|
|
752
|
+
const weightScale = (0, import_bignumber.default)(1e12);
|
|
753
|
+
const rewardRate = rewardValueForYear.multipliedBy(
|
|
754
|
+
(0, import_bignumber.default)(parsedBorrowIncentivePoolPointData.baseWeight).dividedBy(
|
|
755
|
+
weightScale
|
|
756
|
+
)
|
|
757
|
+
).dividedBy(weightedStakedValue).isFinite() && parsedBorrowIncentivePoolPointData.points > 0 ? rewardValueForYear.multipliedBy(
|
|
758
|
+
(0, import_bignumber.default)(parsedBorrowIncentivePoolPointData.baseWeight).dividedBy(
|
|
759
|
+
weightScale
|
|
760
|
+
)
|
|
761
|
+
).dividedBy(weightedStakedValue).toNumber() : Infinity;
|
|
762
|
+
return {
|
|
763
|
+
distributedPointPerSec: distributedPointPerSec.toNumber(),
|
|
764
|
+
accumulatedPoints: accumulatedPoints.toNumber(),
|
|
765
|
+
currentPointIndex: currentPointIndex.toNumber(),
|
|
766
|
+
currentTotalDistributedPoint: currentTotalDistributedPoint.toNumber(),
|
|
767
|
+
baseWeight: baseWeight.toNumber(),
|
|
768
|
+
weightedStakedAmount: weightedStakedAmount.toNumber(),
|
|
769
|
+
weightedStakedCoin: weightedStakedCoin.toNumber(),
|
|
770
|
+
weightedStakedValue: weightedStakedValue.toNumber(),
|
|
771
|
+
rewardApr: rewardRate,
|
|
772
|
+
rewardPerSec: rewardPerSec.toNumber()
|
|
773
|
+
};
|
|
774
|
+
};
|
|
775
|
+
var parseOriginBorrowIncentiveAccountPoolPointData = (originBorrowIncentiveAccountPoolPointData) => {
|
|
776
|
+
return {
|
|
777
|
+
pointType: (0, import_utils.normalizeStructTag)(
|
|
778
|
+
originBorrowIncentiveAccountPoolPointData.point_type.name
|
|
779
|
+
),
|
|
780
|
+
weightedAmount: Number(
|
|
781
|
+
originBorrowIncentiveAccountPoolPointData.weighted_amount
|
|
782
|
+
),
|
|
783
|
+
points: Number(originBorrowIncentiveAccountPoolPointData.points),
|
|
784
|
+
totalPoints: Number(originBorrowIncentiveAccountPoolPointData.total_points),
|
|
785
|
+
index: Number(originBorrowIncentiveAccountPoolPointData.index)
|
|
786
|
+
};
|
|
787
|
+
};
|
|
788
|
+
var parseOriginBorrowIncentiveAccountData = (originBorrowIncentiveAccountData) => {
|
|
789
|
+
return {
|
|
790
|
+
poolType: (0, import_utils.normalizeStructTag)(
|
|
791
|
+
originBorrowIncentiveAccountData.pool_type.name
|
|
792
|
+
),
|
|
793
|
+
debtAmount: Number(originBorrowIncentiveAccountData.debt_amount),
|
|
794
|
+
pointList: originBorrowIncentiveAccountData.points_list.reduce(
|
|
795
|
+
(acc, point) => {
|
|
796
|
+
const parsed = parseOriginBorrowIncentiveAccountPoolPointData(point);
|
|
797
|
+
const name = (0, import_utils.parseStructTag)(
|
|
798
|
+
parsed.pointType
|
|
799
|
+
).name.toLowerCase();
|
|
800
|
+
acc[name] = parsed;
|
|
801
|
+
return acc;
|
|
1045
802
|
},
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
803
|
+
{}
|
|
804
|
+
)
|
|
805
|
+
};
|
|
806
|
+
};
|
|
807
|
+
var minBigNumber = (...args) => {
|
|
808
|
+
return (0, import_bignumber.default)(
|
|
809
|
+
args.reduce(
|
|
810
|
+
(min, current) => new import_bignumber.default(current).lt(min) ? current : min
|
|
811
|
+
)
|
|
812
|
+
);
|
|
813
|
+
};
|
|
814
|
+
var estimatedFactor = (amount, scaleStep, type) => {
|
|
815
|
+
const amountOfDigits = Math.max(
|
|
816
|
+
1,
|
|
817
|
+
Math.floor(Math.log10(Math.abs(amount)) + 1)
|
|
818
|
+
);
|
|
819
|
+
const adjustScale = Math.max(Math.floor((amountOfDigits - 1) / scaleStep), 1) + 1;
|
|
820
|
+
let adjustFactor = Math.pow(10, -adjustScale);
|
|
821
|
+
adjustFactor = type === "increase" ? 1 - adjustFactor : 1 + adjustFactor;
|
|
822
|
+
return adjustFactor;
|
|
823
|
+
};
|
|
824
|
+
|
|
825
|
+
// src/utils/util.ts
|
|
826
|
+
var COIN_SET = Array.from(
|
|
827
|
+
/* @__PURE__ */ new Set([
|
|
828
|
+
...SUPPORT_POOLS,
|
|
829
|
+
...SUPPORT_COLLATERALS,
|
|
830
|
+
...SUPPORT_SPOOLS_REWARDS,
|
|
831
|
+
...SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
832
|
+
...SUPPORT_SCOIN
|
|
833
|
+
])
|
|
834
|
+
);
|
|
835
|
+
var isMarketCoin = (coinName) => {
|
|
836
|
+
const assetCoinName = coinName.slice(1).toLowerCase();
|
|
837
|
+
return coinName.charAt(0).toLowerCase() === "s" && COIN_SET.includes(assetCoinName);
|
|
838
|
+
};
|
|
839
|
+
var parseAssetSymbol = (coinName) => {
|
|
840
|
+
switch (coinName) {
|
|
841
|
+
case "afsui":
|
|
842
|
+
return "afSUI";
|
|
843
|
+
case "hasui":
|
|
844
|
+
return "haSUI";
|
|
845
|
+
case "vsui":
|
|
846
|
+
return "vSUI";
|
|
847
|
+
default:
|
|
848
|
+
return coinName.toUpperCase();
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
var parseDataFromPythPriceFeed = (feed, address) => {
|
|
852
|
+
const assetCoinNames = COIN_SET;
|
|
853
|
+
const assetCoinName = assetCoinNames.find((assetCoinName2) => {
|
|
854
|
+
return address.get(`core.coins.${assetCoinName2}.oracle.pyth.feed`) === feed.id;
|
|
855
|
+
});
|
|
856
|
+
if (assetCoinName) {
|
|
857
|
+
const price = feed.price.price * 10 ** feed.price.expo;
|
|
858
|
+
return {
|
|
859
|
+
coinName: assetCoinName,
|
|
860
|
+
price,
|
|
861
|
+
publishTime: Number(feed.price.publishTime) * 10 ** 3
|
|
862
|
+
};
|
|
863
|
+
} else {
|
|
864
|
+
throw new Error("Invalid feed id");
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
var findClosestUnlockRound = (unlockAtInSecondTimestamp) => {
|
|
868
|
+
const unlockDate = new Date(unlockAtInSecondTimestamp * 1e3);
|
|
869
|
+
const closestTwelveAM = new Date(unlockAtInSecondTimestamp * 1e3);
|
|
870
|
+
closestTwelveAM.setUTCHours(0, 0, 0, 0);
|
|
871
|
+
if (unlockDate.getUTCHours() >= 0) {
|
|
872
|
+
closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() + 1);
|
|
873
|
+
}
|
|
874
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
875
|
+
if (closestTwelveAM.getTime() - now > MAX_LOCK_DURATION * 1e3) {
|
|
876
|
+
closestTwelveAM.setUTCDate(closestTwelveAM.getUTCDate() - 1);
|
|
877
|
+
}
|
|
878
|
+
return Math.floor(closestTwelveAM.getTime() / 1e3);
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
// src/constants/tokenBucket.ts
|
|
882
|
+
var DEFAULT_TOKENS_PER_INTERVAL = 10;
|
|
883
|
+
var DEFAULT_INTERVAL_IN_MS = 1e3;
|
|
884
|
+
|
|
885
|
+
// src/utils/tokenBucket.ts
|
|
886
|
+
var TokenBucket = class {
|
|
887
|
+
constructor(tokensPerInterval, intervalInMs) {
|
|
888
|
+
this.tokensPerInterval = tokensPerInterval;
|
|
889
|
+
this.interval = intervalInMs;
|
|
890
|
+
this.tokens = tokensPerInterval;
|
|
891
|
+
this.lastRefill = Date.now();
|
|
892
|
+
}
|
|
893
|
+
refill() {
|
|
894
|
+
const now = Date.now();
|
|
895
|
+
const elapsed = now - this.lastRefill;
|
|
896
|
+
if (elapsed > this.interval) {
|
|
897
|
+
const tokensToAdd = Math.floor(elapsed / this.interval) * this.tokensPerInterval;
|
|
898
|
+
this.tokens = Math.min(this.tokens + tokensToAdd, this.tokensPerInterval);
|
|
899
|
+
this.lastRefill = now;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
removeTokens(count) {
|
|
903
|
+
this.refill();
|
|
904
|
+
if (this.tokens >= count) {
|
|
905
|
+
this.tokens -= count;
|
|
906
|
+
return true;
|
|
907
|
+
}
|
|
908
|
+
return false;
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
var callWithRateLimit = async (tokenBucket, fn, retryDelayInMs = DEFAULT_INTERVAL_IN_MS, maxRetries = 5) => {
|
|
912
|
+
let retries = 0;
|
|
913
|
+
const tryRequest = async () => {
|
|
914
|
+
if (tokenBucket.removeTokens(1)) {
|
|
915
|
+
return await fn();
|
|
916
|
+
} else if (retries < maxRetries) {
|
|
917
|
+
retries++;
|
|
918
|
+
await new Promise((resolve) => setTimeout(resolve, retryDelayInMs));
|
|
919
|
+
return tryRequest();
|
|
920
|
+
} else {
|
|
921
|
+
console.error("Maximum retries reached");
|
|
922
|
+
return null;
|
|
923
|
+
}
|
|
924
|
+
};
|
|
925
|
+
return tryRequest();
|
|
926
|
+
};
|
|
927
|
+
|
|
928
|
+
// src/models/scallopCache.ts
|
|
929
|
+
var ScallopCache = class {
|
|
930
|
+
constructor(cacheOptions, suiKit, tokenBucket) {
|
|
931
|
+
this.queryClient = new import_query_core.QueryClient(cacheOptions ?? DEFAULT_CACHE_OPTIONS);
|
|
932
|
+
this._suiKit = suiKit;
|
|
933
|
+
this.tokenBucket = tokenBucket ?? new TokenBucket(DEFAULT_TOKENS_PER_INTERVAL, DEFAULT_INTERVAL_IN_MS);
|
|
934
|
+
}
|
|
935
|
+
get suiKit() {
|
|
936
|
+
if (!this._suiKit) {
|
|
937
|
+
throw new Error("SuiKit instance is not initialized");
|
|
938
|
+
}
|
|
939
|
+
return this._suiKit;
|
|
940
|
+
}
|
|
941
|
+
get client() {
|
|
942
|
+
return this.suiKit.client();
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* @description Invalidate cache based on the refetchType parameter
|
|
946
|
+
* @param refetchType Determines the type of queries to be refetched. Defaults to `active`.
|
|
947
|
+
*
|
|
948
|
+
* - `active`: Only queries that match the refetch predicate and are actively being rendered via useQuery and related functions will be refetched in the background.
|
|
949
|
+
* - `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.
|
|
950
|
+
* - `all`: All queries that match the refetch predicate will be refetched in the background.
|
|
951
|
+
* - `none`: No queries will be refetched. Queries that match the refetch predicate will only be marked as invalid.
|
|
952
|
+
*/
|
|
953
|
+
invalidateAndRefetchAllCache(refetchType) {
|
|
954
|
+
return this.queryClient.invalidateQueries({
|
|
955
|
+
refetchType
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
/**
|
|
959
|
+
* @description Cache protocol config call for 60 seconds.
|
|
960
|
+
* @returns Promise<ProtocolConfig>
|
|
961
|
+
*/
|
|
962
|
+
async getProtocolConfig() {
|
|
963
|
+
return await this.queryClient.fetchQuery({
|
|
964
|
+
queryKey: ["getProtocolConfig"],
|
|
965
|
+
queryFn: async () => {
|
|
966
|
+
return await callWithRateLimit(
|
|
967
|
+
this.tokenBucket,
|
|
968
|
+
() => this.client.getProtocolConfig()
|
|
969
|
+
);
|
|
1058
970
|
},
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
971
|
+
staleTime: 3e4
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* @description Provides cache for inspectTxn of the SuiKit.
|
|
976
|
+
* @param QueryInspectTxnParams
|
|
977
|
+
* @param txBlock
|
|
978
|
+
* @returns Promise<DevInspectResults>
|
|
979
|
+
*/
|
|
980
|
+
async queryInspectTxn({
|
|
981
|
+
queryTarget,
|
|
982
|
+
args,
|
|
983
|
+
typeArgs
|
|
984
|
+
}) {
|
|
985
|
+
const txBlock = new import_sui_kit.SuiTxBlock();
|
|
986
|
+
const resolvedArgs = await Promise.all(
|
|
987
|
+
args.map(async (arg) => {
|
|
988
|
+
if (typeof arg === "string") {
|
|
989
|
+
return (await this.queryGetObject(arg, { showContent: true }))?.data;
|
|
1070
990
|
}
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
991
|
+
return arg;
|
|
992
|
+
})
|
|
993
|
+
);
|
|
994
|
+
txBlock.moveCall(queryTarget, resolvedArgs, typeArgs);
|
|
995
|
+
const txBytes = await txBlock.txBlock.build({
|
|
996
|
+
client: this.client,
|
|
997
|
+
onlyTransactionKind: true,
|
|
998
|
+
protocolConfig: await this.getProtocolConfig() ?? void 0
|
|
999
|
+
});
|
|
1000
|
+
const query = await this.queryClient.fetchQuery({
|
|
1001
|
+
queryKey: typeArgs ? ["inspectTxn", queryTarget, JSON.stringify(args)] : [
|
|
1002
|
+
"inspectTxn",
|
|
1003
|
+
queryTarget,
|
|
1004
|
+
JSON.stringify(args),
|
|
1005
|
+
JSON.stringify(typeArgs)
|
|
1006
|
+
],
|
|
1007
|
+
queryFn: async () => {
|
|
1008
|
+
return await callWithRateLimit(
|
|
1009
|
+
this.tokenBucket,
|
|
1010
|
+
() => this.suiKit.inspectTxn(txBytes)
|
|
1011
|
+
);
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
return query;
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* @description Provides cache for getObject of the SuiKit.
|
|
1018
|
+
* @param objectId
|
|
1019
|
+
* @param QueryObjectParams
|
|
1020
|
+
* @returns Promise<SuiObjectResponse>
|
|
1021
|
+
*/
|
|
1022
|
+
async queryGetObject(objectId, options) {
|
|
1023
|
+
const queryKey = ["getObject", objectId, this.suiKit.currentAddress()];
|
|
1024
|
+
if (options) {
|
|
1025
|
+
queryKey.push(JSON.stringify(options));
|
|
1026
|
+
}
|
|
1027
|
+
return this.queryClient.fetchQuery({
|
|
1028
|
+
queryKey,
|
|
1029
|
+
queryFn: async () => {
|
|
1030
|
+
return await callWithRateLimit(
|
|
1031
|
+
this.tokenBucket,
|
|
1032
|
+
() => this.client.getObject({
|
|
1033
|
+
id: objectId,
|
|
1034
|
+
options
|
|
1035
|
+
})
|
|
1036
|
+
);
|
|
1037
|
+
}
|
|
1038
|
+
});
|
|
1039
|
+
}
|
|
1040
|
+
/**
|
|
1041
|
+
* @description Provides cache for getObjects of the SuiKit.
|
|
1042
|
+
* @param objectIds
|
|
1043
|
+
* @returns Promise<SuiObjectData[]>
|
|
1044
|
+
*/
|
|
1045
|
+
async queryGetObjects(objectIds, options) {
|
|
1046
|
+
if (objectIds.length === 0)
|
|
1047
|
+
return [];
|
|
1048
|
+
const queryKey = [
|
|
1049
|
+
"getObjects",
|
|
1050
|
+
JSON.stringify(objectIds),
|
|
1051
|
+
this.suiKit.currentAddress()
|
|
1052
|
+
];
|
|
1053
|
+
if (options) {
|
|
1054
|
+
queryKey.push(JSON.stringify(options));
|
|
1055
|
+
}
|
|
1056
|
+
return this.queryClient.fetchQuery({
|
|
1057
|
+
queryKey,
|
|
1058
|
+
queryFn: async () => {
|
|
1059
|
+
return await callWithRateLimit(
|
|
1060
|
+
this.tokenBucket,
|
|
1061
|
+
() => this.suiKit.getObjects(objectIds, options)
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* @description Provides cache for getOwnedObjects of the SuiKit.
|
|
1068
|
+
* @param input
|
|
1069
|
+
* @returns Promise<PaginatedObjectsResponse>
|
|
1070
|
+
*/
|
|
1071
|
+
async queryGetOwnedObjects(input) {
|
|
1072
|
+
const queryKey = ["getOwnedObjects", input.owner];
|
|
1073
|
+
if (input.cursor) {
|
|
1074
|
+
queryKey.push(JSON.stringify(input.cursor));
|
|
1075
|
+
}
|
|
1076
|
+
if (input.options) {
|
|
1077
|
+
queryKey.push(JSON.stringify(input.options));
|
|
1078
|
+
}
|
|
1079
|
+
if (input.filter) {
|
|
1080
|
+
queryKey.push(JSON.stringify(input.filter));
|
|
1081
|
+
}
|
|
1082
|
+
if (input.limit) {
|
|
1083
|
+
queryKey.push(JSON.stringify(input.limit));
|
|
1084
|
+
}
|
|
1085
|
+
return this.queryClient.fetchQuery({
|
|
1086
|
+
queryKey,
|
|
1087
|
+
queryFn: async () => {
|
|
1088
|
+
return await callWithRateLimit(
|
|
1089
|
+
this.tokenBucket,
|
|
1090
|
+
() => this.client.getOwnedObjects(input)
|
|
1091
|
+
);
|
|
1092
|
+
}
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
async queryGetDynamicFields(input) {
|
|
1096
|
+
const queryKey = ["getDynamicFields", input.parentId];
|
|
1097
|
+
if (input.cursor) {
|
|
1098
|
+
queryKey.push(JSON.stringify(input.cursor));
|
|
1099
|
+
}
|
|
1100
|
+
if (input.limit) {
|
|
1101
|
+
queryKey.push(JSON.stringify(input.limit));
|
|
1102
|
+
}
|
|
1103
|
+
return this.queryClient.fetchQuery({
|
|
1104
|
+
queryKey,
|
|
1105
|
+
queryFn: async () => {
|
|
1106
|
+
return await callWithRateLimit(
|
|
1107
|
+
this.tokenBucket,
|
|
1108
|
+
() => this.client.getDynamicFields(input)
|
|
1109
|
+
);
|
|
1110
|
+
}
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
async queryGetDynamicFieldObject(input) {
|
|
1114
|
+
const queryKey = [
|
|
1115
|
+
"getDynamicFieldObject",
|
|
1116
|
+
input.parentId,
|
|
1117
|
+
input.name.type,
|
|
1118
|
+
input.name.value
|
|
1119
|
+
];
|
|
1120
|
+
return this.queryClient.fetchQuery({
|
|
1121
|
+
queryKey,
|
|
1122
|
+
queryFn: async () => {
|
|
1123
|
+
return await callWithRateLimit(
|
|
1124
|
+
this.tokenBucket,
|
|
1125
|
+
() => this.client.getDynamicFieldObject(input)
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
async queryGetAllCoinBalances(owner) {
|
|
1131
|
+
const queryKey = ["getAllCoinBalances", owner];
|
|
1132
|
+
return this.queryClient.fetchQuery({
|
|
1133
|
+
queryKey,
|
|
1134
|
+
queryFn: async () => {
|
|
1135
|
+
const allBalances = await callWithRateLimit(
|
|
1136
|
+
this.tokenBucket,
|
|
1137
|
+
() => this.client.getAllBalances({ owner })
|
|
1138
|
+
);
|
|
1139
|
+
if (!allBalances)
|
|
1140
|
+
return {};
|
|
1141
|
+
const balances = allBalances.reduce(
|
|
1142
|
+
(acc, coinBalance) => {
|
|
1143
|
+
if (coinBalance.totalBalance !== "0") {
|
|
1144
|
+
acc[(0, import_sui_kit.normalizeStructTag)(coinBalance.coinType)] = coinBalance.totalBalance;
|
|
1145
|
+
}
|
|
1146
|
+
return acc;
|
|
1147
|
+
},
|
|
1148
|
+
{}
|
|
1149
|
+
);
|
|
1150
|
+
for (const coinType in balances) {
|
|
1151
|
+
const coinBalanceQueryKey = [
|
|
1152
|
+
"getCoinBalance",
|
|
1153
|
+
(0, import_sui_kit.normalizeSuiAddress)(owner),
|
|
1154
|
+
(0, import_sui_kit.normalizeStructTag)(coinType)
|
|
1155
|
+
];
|
|
1156
|
+
this.queryClient.setQueryData(
|
|
1157
|
+
coinBalanceQueryKey,
|
|
1158
|
+
balances[coinType]
|
|
1159
|
+
);
|
|
1160
|
+
}
|
|
1161
|
+
return balances;
|
|
1162
|
+
}
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
async queryGetCoinBalance(input) {
|
|
1166
|
+
if (!input.coinType)
|
|
1167
|
+
return "0";
|
|
1168
|
+
const queryKey = [
|
|
1169
|
+
"getCoinBalance",
|
|
1170
|
+
(0, import_sui_kit.normalizeSuiAddress)(input.owner),
|
|
1171
|
+
(0, import_sui_kit.normalizeStructTag)(input.coinType)
|
|
1172
|
+
];
|
|
1173
|
+
return this.queryClient.fetchQuery({
|
|
1174
|
+
queryKey,
|
|
1175
|
+
queryFn: async () => {
|
|
1176
|
+
if (!input.coinType)
|
|
1177
|
+
return "0";
|
|
1178
|
+
return (await this.queryGetAllCoinBalances(input.owner))[(0, import_sui_kit.normalizeStructTag)(input.coinType)] ?? "0";
|
|
1179
|
+
}
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1183
|
+
|
|
1184
|
+
// src/models/scallopAddress.ts
|
|
1185
|
+
var import_axios = __toESM(require("axios"));
|
|
1186
|
+
|
|
1187
|
+
// src/constants/testAddress.ts
|
|
1188
|
+
var TEST_ADDRESSES = {
|
|
1189
|
+
core: {
|
|
1190
|
+
// version:
|
|
1191
|
+
// '0x07871c4b3c847a0f674510d4978d5cf6f960452795e8ff6f189fd2088a3f6ac7',
|
|
1192
|
+
version: "0x6156d5cd1538bec8a167a40fe1209a4ec9cf8137921fe0a697f191ac561f0b09",
|
|
1193
|
+
versionCap: "0x590a4011cb649b3878f3ea14b3a78674642a9548d79b7e091ef679574b158a07",
|
|
1194
|
+
// object:
|
|
1195
|
+
// '0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf',
|
|
1196
|
+
object: "0x87ddec2984645dbbe2403a509cc6edf393a43acdba9b77d45da2bcbefcf733c1",
|
|
1197
|
+
// market:
|
|
1198
|
+
// '0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9',
|
|
1199
|
+
market: "0x8606ed145cc887985b8ed793f7753ff5dc762a42c379dac035f568e1bac58490",
|
|
1200
|
+
adminCap: "0x09689d018e71c337d9db6d67cbca06b74ed92196103624028ccc3ecea411777c",
|
|
1201
|
+
coinDecimalsRegistry: "0x200abe9bf19751cc566ae35aa58e2b7e4ff688fc1130f8d8909ea09bc137d668",
|
|
1202
|
+
// obligationAccessStore:
|
|
1203
|
+
// '0x733e30b7c94d619d78cb8f5bc4bfbb759ced9a531239028caabb2474e5be59c9',
|
|
1204
|
+
obligationAccessStore: "0x48b472d68ca910c45f7f3b6c26836b6aa6d2569810d94b1b939023da05ae0a23",
|
|
1205
|
+
coins: {
|
|
1206
|
+
cetus: {
|
|
1207
|
+
id: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b",
|
|
1208
|
+
metaData: "0x4c0dce55eff2db5419bbd2d239d1aa22b4a400c01bbb648b058a9883989025da",
|
|
1075
1209
|
treasury: "",
|
|
1076
1210
|
oracle: {
|
|
1077
1211
|
supra: "",
|
|
1078
1212
|
switchboard: "",
|
|
1079
1213
|
pyth: {
|
|
1080
|
-
feed: "",
|
|
1081
|
-
feedObject: ""
|
|
1214
|
+
feed: "e5b274b2611143df055d6e7cd8d93fe1961716bcd4dca1cad87a83bc1e78c1ef",
|
|
1215
|
+
feedObject: "0x24c0247fb22457a719efac7f670cdc79be321b521460bd6bd2ccfa9f80713b14"
|
|
1082
1216
|
}
|
|
1083
1217
|
}
|
|
1084
1218
|
},
|
|
1085
|
-
|
|
1086
|
-
id: "",
|
|
1087
|
-
metaData: "",
|
|
1219
|
+
apt: {
|
|
1220
|
+
id: "0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37",
|
|
1221
|
+
metaData: "0xc969c5251f372c0f34c32759f1d315cf1ea0ee5e4454b52aea08778eacfdd0a8",
|
|
1088
1222
|
treasury: "",
|
|
1089
1223
|
oracle: {
|
|
1090
1224
|
supra: "",
|
|
1091
1225
|
switchboard: "",
|
|
1092
1226
|
pyth: {
|
|
1093
|
-
feed: "",
|
|
1094
|
-
feedObject: ""
|
|
1227
|
+
feed: "03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5",
|
|
1228
|
+
feedObject: "0x7c5b7837c44a69b469325463ac0673ac1aa8435ff44ddb4191c9ae380463647f"
|
|
1095
1229
|
}
|
|
1096
1230
|
}
|
|
1097
1231
|
},
|
|
1098
|
-
|
|
1099
|
-
id: "",
|
|
1100
|
-
metaData: "",
|
|
1232
|
+
sol: {
|
|
1233
|
+
id: "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8",
|
|
1234
|
+
metaData: "0x4d2c39082b4477e3e79dc4562d939147ab90c42fc5f3e4acf03b94383cd69b6e",
|
|
1101
1235
|
treasury: "",
|
|
1102
1236
|
oracle: {
|
|
1103
1237
|
supra: "",
|
|
1104
1238
|
switchboard: "",
|
|
1105
1239
|
pyth: {
|
|
1106
|
-
feed: "",
|
|
1107
|
-
feedObject: ""
|
|
1240
|
+
feed: "ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
|
|
1241
|
+
feedObject: "0x9d0d275efbd37d8a8855f6f2c761fa5983293dd8ce202ee5196626de8fcd4469"
|
|
1108
1242
|
}
|
|
1109
1243
|
}
|
|
1110
1244
|
},
|
|
1111
|
-
|
|
1112
|
-
id: "",
|
|
1113
|
-
metaData: "",
|
|
1245
|
+
btc: {
|
|
1246
|
+
id: "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881",
|
|
1247
|
+
metaData: "0x5d3c6e60eeff8a05b693b481539e7847dfe33013e7070cdcb387f5c0cac05dfd",
|
|
1114
1248
|
treasury: "",
|
|
1115
1249
|
oracle: {
|
|
1116
1250
|
supra: "",
|
|
1117
1251
|
switchboard: "",
|
|
1118
1252
|
pyth: {
|
|
1119
|
-
feed: "",
|
|
1120
|
-
feedObject: ""
|
|
1253
|
+
feed: "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43",
|
|
1254
|
+
feedObject: "0x9a62b4863bdeaabdc9500fce769cf7e72d5585eeb28a6d26e4cafadc13f76ab2"
|
|
1121
1255
|
}
|
|
1122
1256
|
}
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1257
|
+
},
|
|
1258
|
+
eth: {
|
|
1259
|
+
id: "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5",
|
|
1260
|
+
metaData: "0x8900e4ceede3363bef086d6b50ca89d816d0e90bf6bc46efefe1f8455e08f50f",
|
|
1261
|
+
treasury: "",
|
|
1262
|
+
oracle: {
|
|
1263
|
+
supra: "",
|
|
1264
|
+
switchboard: "",
|
|
1265
|
+
pyth: {
|
|
1266
|
+
feed: "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace",
|
|
1267
|
+
feedObject: "0x9193fd47f9a0ab99b6e365a464c8a9ae30e6150fc37ed2a89c1586631f6fc4ab"
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
},
|
|
1271
|
+
usdc: {
|
|
1272
|
+
id: "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf",
|
|
1273
|
+
metaData: "0x4fbf84f3029bd0c0b77164b587963be957f853eccf834a67bb9ecba6ec80f189",
|
|
1274
|
+
treasury: "",
|
|
1275
|
+
oracle: {
|
|
1276
|
+
supra: "",
|
|
1277
|
+
switchboard: "",
|
|
1278
|
+
pyth: {
|
|
1279
|
+
feed: "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a",
|
|
1280
|
+
feedObject: "0x5dec622733a204ca27f5a90d8c2fad453cc6665186fd5dff13a83d0b6c9027ab"
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
},
|
|
1284
|
+
usdt: {
|
|
1285
|
+
id: "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c",
|
|
1286
|
+
metaData: "0xfb0e3eb97dd158a5ae979dddfa24348063843c5b20eb8381dd5fa7c93699e45c",
|
|
1287
|
+
treasury: "",
|
|
1288
|
+
oracle: {
|
|
1289
|
+
supra: "",
|
|
1290
|
+
switchboard: "",
|
|
1291
|
+
pyth: {
|
|
1292
|
+
feed: "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b",
|
|
1293
|
+
feedObject: "0x985e3db9f93f76ee8bace7c3dd5cc676a096accd5d9e09e9ae0fb6e492b14572"
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
},
|
|
1297
|
+
sui: {
|
|
1298
|
+
id: "0x0000000000000000000000000000000000000000000000000000000000000002",
|
|
1299
|
+
metaData: "0x9258181f5ceac8dbffb7030890243caed69a9599d2886d957a9cb7656af3bdb3",
|
|
1300
|
+
treasury: "",
|
|
1301
|
+
oracle: {
|
|
1302
|
+
supra: "",
|
|
1303
|
+
switchboard: "0xbca474133638352ba83ccf7b5c931d50f764b09550e16612c9f70f1e21f3f594",
|
|
1304
|
+
pyth: {
|
|
1305
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
1306
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
},
|
|
1310
|
+
afsui: {
|
|
1311
|
+
id: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc",
|
|
1312
|
+
metaData: "0x2f9217f533e51334873a39b8026a4aa6919497b47f49d0986a4f1aec66f8a34d",
|
|
1313
|
+
treasury: "",
|
|
1314
|
+
oracle: {
|
|
1315
|
+
supra: "",
|
|
1316
|
+
switchboard: "",
|
|
1317
|
+
pyth: {
|
|
1318
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
1319
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
},
|
|
1323
|
+
hasui: {
|
|
1324
|
+
id: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d",
|
|
1325
|
+
metaData: "0x2c5f33af93f6511df699aaaa5822d823aac6ed99d4a0de2a4a50b3afa0172e24",
|
|
1326
|
+
treasury: "",
|
|
1327
|
+
oracle: {
|
|
1328
|
+
supra: "",
|
|
1329
|
+
switchboard: "",
|
|
1330
|
+
pyth: {
|
|
1331
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
1332
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
},
|
|
1336
|
+
vsui: {
|
|
1337
|
+
id: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55",
|
|
1338
|
+
metaData: "0xabd84a23467b33854ab25cf862006fd97479f8f6f53e50fe732c43a274d939bd",
|
|
1339
|
+
treasury: "",
|
|
1340
|
+
oracle: {
|
|
1341
|
+
supra: "",
|
|
1342
|
+
switchboard: "",
|
|
1343
|
+
pyth: {
|
|
1344
|
+
feed: "23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744",
|
|
1345
|
+
feedObject: "0x801dbc2f0053d34734814b2d6df491ce7807a725fe9a01ad74a07e9c51396c37"
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
},
|
|
1349
|
+
sca: {
|
|
1350
|
+
id: "0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6",
|
|
1351
|
+
metaData: "0x5d26a1e9a55c88147ac870bfa31b729d7f49f8804b8b3adfdf3582d301cca844",
|
|
1352
|
+
treasury: "",
|
|
1353
|
+
oracle: {
|
|
1354
|
+
supra: "",
|
|
1355
|
+
switchboard: "",
|
|
1356
|
+
pyth: {
|
|
1357
|
+
feed: "7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc",
|
|
1358
|
+
feedObject: "0xf6de1d3279a269a597d813cbaca59aa906543ab9a8c64e84a4722f1a20863985"
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
},
|
|
1363
|
+
oracles: {
|
|
1364
|
+
xOracle: "0x93d5bf0936b71eb27255941e532fac33b5a5c7759e377b4923af0a1359ad494f",
|
|
1365
|
+
xOracleCap: "0x1edeae568fde99e090dbdec4bcdbd33a15f53a1ce1f87aeef1a560dedf4b4a90",
|
|
1366
|
+
supra: { registry: "", registryCap: "", holder: "" },
|
|
1367
|
+
switchboard: { registry: "", registryCap: "" },
|
|
1368
|
+
pyth: {
|
|
1369
|
+
registry: "0xedc293f9413a5a7a5d53bdba1fd889d0a4030894469228f0acdae4aa3c55a213",
|
|
1370
|
+
registryCap: "0xbcb07141eb1f7e01fbda4130ecf5f5adaeabb77f5d9c32158b7532bcd2197acd",
|
|
1371
|
+
state: "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8",
|
|
1372
|
+
wormhole: "0x5306f64e312b581766351c07af79c72fcb1cd25147157fdc2f8ad76de9a3fb6a",
|
|
1373
|
+
wormholeState: "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c"
|
|
1374
|
+
}
|
|
1375
|
+
},
|
|
1376
|
+
packages: {
|
|
1377
|
+
coinDecimalsRegistry: {
|
|
1378
|
+
id: "0xca5a5a62f01c79a104bf4d31669e29daa387f325c241de4edbe30986a9bc8b0d",
|
|
1379
|
+
upgradeCap: "0x34e76a945d29f195bc53ca704fa70877d1cf3a5d7bbfdda1b13e633fff13c0f6"
|
|
1380
|
+
},
|
|
1381
|
+
math: {
|
|
1382
|
+
id: "0xad013d5fde39e15eabda32b3dbdafd67dac32b798ce63237c27a8f73339b9b6f",
|
|
1383
|
+
upgradeCap: "0x3a329598231de02e6135c62284b66005b41cad1d9ab7ca2dc79c08293aba2ec6"
|
|
1384
|
+
},
|
|
1385
|
+
whitelist: {
|
|
1386
|
+
id: "0x1318fdc90319ec9c24df1456d960a447521b0a658316155895014a6e39b5482f",
|
|
1387
|
+
upgradeCap: "0xf5a22aea23db664f7b69855b6a546747f17c1ec4230319cfc17225e462b05761"
|
|
1150
1388
|
},
|
|
1151
1389
|
x: {
|
|
1152
|
-
id: "",
|
|
1153
|
-
upgradeCap: ""
|
|
1390
|
+
id: "0x779b5c547976899f5474f3a5bc0db36ddf4697ad7e5a901db0415c2281d28162",
|
|
1391
|
+
upgradeCap: "0x3f203f6fff6a69d151e4f1cd931f22b68c489ef2759765662fc7baf673943c9e"
|
|
1154
1392
|
},
|
|
1155
1393
|
protocol: {
|
|
1156
|
-
id: "",
|
|
1157
|
-
upgradeCap: ""
|
|
1394
|
+
id: "0x87ddec2984645dbbe2403a509cc6edf393a43acdba9b77d45da2bcbefcf733c1",
|
|
1395
|
+
upgradeCap: "0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a"
|
|
1158
1396
|
},
|
|
1397
|
+
// protocol: {
|
|
1398
|
+
// id: '0x6e641f0dca8aedab3101d047e96439178f16301bf0b57fe8745086ff1195eb3e',
|
|
1399
|
+
// upgradeCap:
|
|
1400
|
+
// '0x38527d154618d1fd5a644b90717fe07cf0e9f26b46b63e9568e611a3f86d5c1a',
|
|
1401
|
+
// },
|
|
1159
1402
|
protocolWhitelist: {
|
|
1160
|
-
id: "",
|
|
1161
|
-
upgradeCap: ""
|
|
1403
|
+
id: "0x4c262d9343dac53ecb28f482a2a3f62c73d0ebac5b5f03d57383d56ff219acdf",
|
|
1404
|
+
upgradeCap: "0x4a5e88a75039b00988f633f811f58117f31b8627a46bf822aa114d9010049449"
|
|
1162
1405
|
},
|
|
1406
|
+
// query: {
|
|
1407
|
+
// id: '0xb8d603a39114a5efef3dd0bf84df0bed1be1fbd39b78b7dd6e8a61ccc5e6006f',
|
|
1408
|
+
// upgradeCap:
|
|
1409
|
+
// '0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f',
|
|
1410
|
+
// },
|
|
1163
1411
|
query: {
|
|
1164
|
-
id: "",
|
|
1165
|
-
upgradeCap: ""
|
|
1412
|
+
id: "0xe4f9d62d17746d5b9dbf0d5557747430021a71575780b515161210cdba0a4c1c",
|
|
1413
|
+
upgradeCap: "0x0d535c35f608b9b01b7ccce11acf43b1dd80c1b72bf8b541744a6e28e8d2745f"
|
|
1166
1414
|
},
|
|
1167
1415
|
supra: { id: "", upgradeCap: "" },
|
|
1168
1416
|
pyth: {
|
|
1169
|
-
id: "",
|
|
1170
|
-
upgradeCap: ""
|
|
1417
|
+
id: "0x910f30cbc7f601f75a5141a01265cd47c62d468707c5e1aecb32a18f448cb25a",
|
|
1418
|
+
upgradeCap: "0xdf0ffbae1ea5bb25fbca5efba433dcf00c7cced65679af2f04728901275c6157"
|
|
1171
1419
|
},
|
|
1172
1420
|
switchboard: { id: "", upgradeCap: "" },
|
|
1173
1421
|
xOracle: {
|
|
1174
|
-
id: "",
|
|
1175
|
-
upgradeCap: ""
|
|
1422
|
+
id: "0x1478a432123e4b3d61878b629f2c692969fdb375644f1251cd278a4b1e7d7cd6",
|
|
1423
|
+
upgradeCap: "0x0f928a6b2e26b73330fecaf9b44acfc9800a4a9794d6415c2a3153bc70e3c1f0"
|
|
1176
1424
|
},
|
|
1177
1425
|
testCoin: { id: "", upgradeCap: "" }
|
|
1178
1426
|
}
|
|
1179
1427
|
},
|
|
1180
1428
|
spool: {
|
|
1181
|
-
id:
|
|
1182
|
-
|
|
1183
|
-
|
|
1429
|
+
// id: '0x7c4fdabe81c31b19a45d1e572a52a539997a90903fbb5bfab71480abe0fa62c3',
|
|
1430
|
+
id: "0x1742655fe5872dfa6456673f9e38612a4965e6979e6cd7696a7f1225f28bae21",
|
|
1431
|
+
adminCap: "0xdd8a047cbbf802bfcde5288b8ef1910965d789cc614da11d39af05fca0bd020a",
|
|
1432
|
+
// object:
|
|
1433
|
+
// '0xe87f1b2d498106a2c61421cec75b7b5c5e348512b0dc263949a0e7a3c256571a',
|
|
1434
|
+
object: "0x1742655fe5872dfa6456673f9e38612a4965e6979e6cd7696a7f1225f28bae21",
|
|
1184
1435
|
pools: {
|
|
1185
1436
|
seth: {
|
|
1186
|
-
id: "",
|
|
1187
|
-
rewardPoolId: ""
|
|
1437
|
+
id: "0xeec40beccb07c575bebd842eeaabb835f77cd3dab73add433477e57f583a6787",
|
|
1438
|
+
rewardPoolId: "0x957de68a18d87817de8309b30c1ec269a4d87ae513abbeed86b5619cb9ce1077"
|
|
1188
1439
|
},
|
|
1189
1440
|
ssui: {
|
|
1190
|
-
id:
|
|
1191
|
-
|
|
1441
|
+
// id: '0x4f0ba970d3c11db05c8f40c64a15b6a33322db3702d634ced6536960ab6f3ee4',
|
|
1442
|
+
id: "0xb9617f83c06ebdeac0a8834782b1015e1cc7ea23739e30c132c4bfb95c37a579",
|
|
1443
|
+
rewardPoolId: (
|
|
1444
|
+
// '0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9',
|
|
1445
|
+
"0xc3206071a8d43212efb6e3b5504f2321f8df97ab122b466c0bc7cfdf398dc13a"
|
|
1446
|
+
)
|
|
1192
1447
|
},
|
|
1193
1448
|
susdc: {
|
|
1194
|
-
id:
|
|
1195
|
-
|
|
1449
|
+
// id: '0x4ace6648ddc64e646ba47a957c562c32c9599b3bba8f5ac1aadb2ae23a2f8ca0',
|
|
1450
|
+
id: "0xf1b383b9cf2e9f515fc69567df1053098f273849d09cd84b0278a773429bd2b2",
|
|
1451
|
+
rewardPoolId: (
|
|
1452
|
+
// '0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8',
|
|
1453
|
+
"0xc71c53ee6505d928ba15bea4fe4f45d98c9c31eced94b72d00a7827d4b7ba3ff"
|
|
1454
|
+
)
|
|
1196
1455
|
},
|
|
1197
1456
|
susdt: {
|
|
1198
|
-
id:
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
},
|
|
1205
|
-
|
|
1206
|
-
id: "",
|
|
1207
|
-
rewardPoolId: ""
|
|
1208
|
-
},
|
|
1209
|
-
|
|
1210
|
-
id:
|
|
1211
|
-
|
|
1212
|
-
|
|
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
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
this._addressesMap = USE_TEST_ADDRESS ? /* @__PURE__ */ new Map([["mainnet", TEST_ADDRESSES]]) : /* @__PURE__ */ new Map();
|
|
1316
|
-
if (USE_TEST_ADDRESS)
|
|
1317
|
-
this._currentAddresses = TEST_ADDRESSES;
|
|
1318
|
-
}
|
|
1319
|
-
/**
|
|
1320
|
-
* Get addresses API id.
|
|
1321
|
-
*
|
|
1322
|
-
* @return The addresses API id.
|
|
1323
|
-
*/
|
|
1324
|
-
getId() {
|
|
1325
|
-
return this._id || void 0;
|
|
1326
|
-
}
|
|
1327
|
-
/**
|
|
1328
|
-
* Get the address at the provided path.
|
|
1329
|
-
*
|
|
1330
|
-
* @param path - The path of the address to get.
|
|
1331
|
-
* @return The address at the provided path.
|
|
1332
|
-
*/
|
|
1333
|
-
get(path) {
|
|
1334
|
-
if (this._currentAddresses) {
|
|
1335
|
-
const value = path.split(".").reduce(
|
|
1336
|
-
(nestedAddressObj, key) => typeof nestedAddressObj === "object" ? nestedAddressObj[key] : nestedAddressObj,
|
|
1337
|
-
this._currentAddresses
|
|
1338
|
-
);
|
|
1339
|
-
return value || void 0;
|
|
1340
|
-
} else {
|
|
1341
|
-
return void 0;
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1344
|
-
/**
|
|
1345
|
-
* Sets the address for the specified path, it does not interact with the API.
|
|
1346
|
-
*
|
|
1347
|
-
* @param path - The path of the address to set.
|
|
1348
|
-
* @param address - The address be setted to the tartget path.
|
|
1349
|
-
* @return The addresses.
|
|
1350
|
-
*/
|
|
1351
|
-
set(path, address) {
|
|
1352
|
-
if (this._currentAddresses) {
|
|
1353
|
-
const keys = path.split(".");
|
|
1354
|
-
keys.reduce((nestedAddressObj, key, index) => {
|
|
1355
|
-
if (index === keys.length - 1) {
|
|
1356
|
-
nestedAddressObj[key] = address;
|
|
1357
|
-
} else {
|
|
1358
|
-
return nestedAddressObj[key];
|
|
1359
|
-
}
|
|
1360
|
-
}, this._currentAddresses);
|
|
1361
|
-
}
|
|
1362
|
-
return this._currentAddresses;
|
|
1363
|
-
}
|
|
1364
|
-
/**
|
|
1365
|
-
* Synchronize the specified network addresses from the addresses map to the
|
|
1366
|
-
* current addresses and change the default network to specified network.
|
|
1367
|
-
*
|
|
1368
|
-
* @param network - Specifies which network's addresses you want to get.
|
|
1369
|
-
* @return Current addresses.
|
|
1370
|
-
*/
|
|
1371
|
-
switchCurrentAddresses(network) {
|
|
1372
|
-
if (this._addressesMap.has(network)) {
|
|
1373
|
-
this._currentAddresses = this._addressesMap.get(network);
|
|
1374
|
-
this._network = network;
|
|
1375
|
-
}
|
|
1376
|
-
return this._currentAddresses;
|
|
1377
|
-
}
|
|
1378
|
-
/**
|
|
1379
|
-
* Get the addresses, If `network` is not provided, returns the current
|
|
1380
|
-
* addresses or the default network addresses in the addresses map.
|
|
1381
|
-
*
|
|
1382
|
-
* @param network - Specifies which network's addresses you want to get.
|
|
1383
|
-
*/
|
|
1384
|
-
getAddresses(network) {
|
|
1385
|
-
if (network) {
|
|
1386
|
-
return this._addressesMap.get(network);
|
|
1387
|
-
} else {
|
|
1388
|
-
return this._currentAddresses ?? this._addressesMap.get(this._network);
|
|
1389
|
-
}
|
|
1390
|
-
}
|
|
1391
|
-
/**
|
|
1392
|
-
* Set the addresses into addresses map. If the specified network is the same
|
|
1393
|
-
* as the current network, the current addresses will be updated at the same time.
|
|
1394
|
-
*
|
|
1395
|
-
* @param addresses - The addresses be setted to the tartget network.
|
|
1396
|
-
* @param network - Specifies which network's addresses you want to set.
|
|
1397
|
-
* @return The addresses.
|
|
1398
|
-
*/
|
|
1399
|
-
setAddresses(addresses, network) {
|
|
1400
|
-
const targetNetwork = network || this._network;
|
|
1401
|
-
if (targetNetwork === this._network)
|
|
1402
|
-
this._currentAddresses = addresses;
|
|
1403
|
-
this._addressesMap.set(targetNetwork, addresses);
|
|
1404
|
-
}
|
|
1405
|
-
/**
|
|
1406
|
-
* Get all addresses.
|
|
1407
|
-
*
|
|
1408
|
-
* @return All addresses.
|
|
1409
|
-
*/
|
|
1410
|
-
getAllAddresses() {
|
|
1411
|
-
return Object.fromEntries(this._addressesMap);
|
|
1412
|
-
}
|
|
1413
|
-
/**
|
|
1414
|
-
* Create a new addresses through the API and synchronize it back to the
|
|
1415
|
-
* instance.
|
|
1416
|
-
*
|
|
1417
|
-
* @description
|
|
1418
|
-
* If the `network` is not specified, the mainnet is used by default.
|
|
1419
|
-
* If no `addresses` from instance or parameter is provided, an addresses with
|
|
1420
|
-
* all empty strings is created by default.
|
|
1421
|
-
*
|
|
1422
|
-
* This function only allows for one addresses to be input into a specific network
|
|
1423
|
-
* at a time, and does not provide an addresses map for setting addresses
|
|
1424
|
-
* across all networks at once.
|
|
1425
|
-
*
|
|
1426
|
-
* @param params.addresses - The addresses be setted to the tartget network.
|
|
1427
|
-
* @param params.network - Specifies which network's addresses you want to set.
|
|
1428
|
-
* @param params.auth - The authentication API key.
|
|
1429
|
-
* @param params.memo - Add memo to the addresses created in the API.
|
|
1430
|
-
* @return All addresses.
|
|
1431
|
-
*/
|
|
1432
|
-
async create(params) {
|
|
1433
|
-
const { addresses, network, auth, memo } = params ?? {};
|
|
1434
|
-
const apiKey = auth || this._auth || void 0;
|
|
1435
|
-
const targetNetwork = network || this._network;
|
|
1436
|
-
const targetAddresses = addresses || this._currentAddresses || this._addressesMap.get(targetNetwork) || EMPTY_ADDRESSES;
|
|
1437
|
-
if (apiKey !== void 0) {
|
|
1438
|
-
this._addressesMap.clear();
|
|
1439
|
-
this.setAddresses(targetAddresses, targetNetwork);
|
|
1440
|
-
const response = await this._requestClient.post(
|
|
1441
|
-
`/addresses`,
|
|
1442
|
-
JSON.stringify({ ...Object.fromEntries(this._addressesMap), memo }),
|
|
1443
|
-
{
|
|
1444
|
-
headers: {
|
|
1445
|
-
"Content-Type": "application/json",
|
|
1446
|
-
"api-key": auth || this._auth
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1449
|
-
);
|
|
1450
|
-
if (response.status === 201) {
|
|
1451
|
-
for (const [network2, addresses2] of Object.entries(
|
|
1452
|
-
response.data
|
|
1453
|
-
)) {
|
|
1454
|
-
if (["localnet", "devnet", "testnet", "mainnet"].includes(network2)) {
|
|
1455
|
-
if (network2 === this._network)
|
|
1456
|
-
this._currentAddresses = addresses2;
|
|
1457
|
-
this._addressesMap.set(network2, addresses2);
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
this._id = response.data.id;
|
|
1461
|
-
return this.getAllAddresses();
|
|
1462
|
-
} else {
|
|
1463
|
-
throw Error("Failed to create addresses.");
|
|
1464
|
-
}
|
|
1465
|
-
} else {
|
|
1466
|
-
throw Error("You don't have permission to access this request.");
|
|
1467
|
-
}
|
|
1468
|
-
}
|
|
1469
|
-
/**
|
|
1470
|
-
* Read and synchronizes all addresses from the API into instance.
|
|
1471
|
-
*
|
|
1472
|
-
* @param id - The id of the addresses to get.
|
|
1473
|
-
* @return All addresses.
|
|
1474
|
-
*/
|
|
1475
|
-
async read(id) {
|
|
1476
|
-
const addressesId = id || this._id || void 0;
|
|
1477
|
-
if (addressesId !== void 0) {
|
|
1478
|
-
const response = await this._cache.queryClient.fetchQuery({
|
|
1479
|
-
queryKey: ["api-getAddresses", addressesId],
|
|
1480
|
-
queryFn: async () => {
|
|
1481
|
-
return await this._requestClient.get(`/addresses/${addressesId}`, {
|
|
1482
|
-
headers: {
|
|
1483
|
-
"Content-Type": "application/json"
|
|
1484
|
-
}
|
|
1485
|
-
});
|
|
1486
|
-
}
|
|
1487
|
-
});
|
|
1488
|
-
if (response.status === 200) {
|
|
1489
|
-
for (const [network, addresses] of Object.entries(
|
|
1490
|
-
response.data
|
|
1491
|
-
)) {
|
|
1492
|
-
if (["localnet", "devnet", "testnet", "mainnet"].includes(network)) {
|
|
1493
|
-
if (network === this._network)
|
|
1494
|
-
this._currentAddresses = addresses;
|
|
1495
|
-
this._addressesMap.set(network, addresses);
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
this._id = response.data.id;
|
|
1499
|
-
return this.getAllAddresses();
|
|
1500
|
-
} else {
|
|
1501
|
-
throw Error("Failed to create addresses.");
|
|
1502
|
-
}
|
|
1503
|
-
} else {
|
|
1504
|
-
throw Error("Please provide API addresses id.");
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
/**
|
|
1508
|
-
* Update the addresses through the API and synchronize it back to the
|
|
1509
|
-
* instance.
|
|
1510
|
-
*
|
|
1511
|
-
* @description
|
|
1512
|
-
* If the `network` is not specified, the mainnet is used by default.
|
|
1513
|
-
* If no `addresses` from instance or parameter is provided, an addresses with
|
|
1514
|
-
* all empty strings is created by default.
|
|
1515
|
-
*
|
|
1516
|
-
* This function only allows for one addresses to be input into a specific network
|
|
1517
|
-
* at a time, and does not provide an addresses map for setting addresses
|
|
1518
|
-
* across all networks at once.
|
|
1519
|
-
*
|
|
1520
|
-
* @param params.id - The id of the addresses to update.
|
|
1521
|
-
* @param params.addresses - The addresses be setted to the tartget network.
|
|
1522
|
-
* @param params.network - Specifies which network's addresses you want to set.
|
|
1523
|
-
* @param params.auth - The authentication api key.
|
|
1524
|
-
* @param params.memo - Add memo to the addresses created in the API.
|
|
1525
|
-
* @return All addresses.
|
|
1526
|
-
*/
|
|
1527
|
-
async update(params) {
|
|
1528
|
-
const { id, addresses, network, auth, memo } = params ?? {};
|
|
1529
|
-
const apiKey = auth || this._auth || void 0;
|
|
1530
|
-
const targetId = id || this._id || void 0;
|
|
1531
|
-
const targetNetwork = network || this._network;
|
|
1532
|
-
const targetAddresses = addresses || this._currentAddresses || this._addressesMap.get(targetNetwork) || EMPTY_ADDRESSES;
|
|
1533
|
-
if (targetId === void 0)
|
|
1534
|
-
throw Error("Require specific addresses id to be updated.");
|
|
1535
|
-
if (apiKey !== void 0) {
|
|
1536
|
-
if (id !== this._id) {
|
|
1537
|
-
this._addressesMap.clear();
|
|
1538
|
-
}
|
|
1539
|
-
this.setAddresses(targetAddresses, targetNetwork);
|
|
1540
|
-
const response = await this._requestClient.put(
|
|
1541
|
-
`/addresses/${targetId}`,
|
|
1542
|
-
JSON.stringify({ ...Object.fromEntries(this._addressesMap), memo }),
|
|
1543
|
-
{
|
|
1544
|
-
headers: {
|
|
1545
|
-
"Content-Type": "application/json",
|
|
1546
|
-
"api-key": auth || this._auth
|
|
1547
|
-
}
|
|
1548
|
-
}
|
|
1549
|
-
);
|
|
1550
|
-
if (response.status === 200) {
|
|
1551
|
-
for (const [network2, addresses2] of Object.entries(
|
|
1552
|
-
response.data
|
|
1553
|
-
)) {
|
|
1554
|
-
if (["localnet", "devnet", "testnet", "mainnet"].includes(network2)) {
|
|
1555
|
-
if (network2 === this._network)
|
|
1556
|
-
this._currentAddresses = addresses2;
|
|
1557
|
-
this._addressesMap.set(network2, addresses2);
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
this._id = response.data.id;
|
|
1561
|
-
return this.getAllAddresses();
|
|
1562
|
-
} else {
|
|
1563
|
-
throw Error("Failed to update addresses.");
|
|
1564
|
-
}
|
|
1565
|
-
} else {
|
|
1566
|
-
throw Error("You don't have permission to access this request.");
|
|
1567
|
-
}
|
|
1568
|
-
}
|
|
1569
|
-
/**
|
|
1570
|
-
* Deletes all addresses of a specified id through the API and clear all
|
|
1571
|
-
* addresses in the instance.
|
|
1572
|
-
*
|
|
1573
|
-
* @param id - The id of the addresses to delete.
|
|
1574
|
-
* @param auth - The authentication API key.
|
|
1575
|
-
*/
|
|
1576
|
-
async delete(id, auth) {
|
|
1577
|
-
const apiKey = auth || this._auth || void 0;
|
|
1578
|
-
const targetId = id || this._id || void 0;
|
|
1579
|
-
if (targetId === void 0)
|
|
1580
|
-
throw Error("Require specific addresses id to be deleted.");
|
|
1581
|
-
if (apiKey !== void 0) {
|
|
1582
|
-
const response = await this._requestClient.delete(
|
|
1583
|
-
`/addresses/${targetId}`,
|
|
1584
|
-
{
|
|
1585
|
-
headers: {
|
|
1586
|
-
"Content-Type": "application/json",
|
|
1587
|
-
"api-key": auth || this._auth
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1590
|
-
);
|
|
1591
|
-
if (response.status === 200) {
|
|
1592
|
-
this._id = void 0;
|
|
1593
|
-
this._currentAddresses = void 0;
|
|
1594
|
-
this._addressesMap.clear();
|
|
1595
|
-
} else {
|
|
1596
|
-
throw Error("Failed to delete addresses.");
|
|
1597
|
-
}
|
|
1598
|
-
} else {
|
|
1599
|
-
throw Error("You don't have permission to access this request.");
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
};
|
|
1603
|
-
|
|
1604
|
-
// src/models/scallopClient.ts
|
|
1605
|
-
var import_utils24 = require("@mysten/sui.js/utils");
|
|
1606
|
-
var import_sui_kit13 = require("@scallop-io/sui-kit");
|
|
1607
|
-
|
|
1608
|
-
// src/models/scallopUtils.ts
|
|
1609
|
-
var import_utils10 = require("@mysten/sui.js/utils");
|
|
1610
|
-
var import_sui_kit4 = require("@scallop-io/sui-kit");
|
|
1611
|
-
var import_pyth_sui_js = require("@pythnetwork/pyth-sui-js");
|
|
1612
|
-
|
|
1613
|
-
// src/models/scallopQuery.ts
|
|
1614
|
-
var import_sui_kit3 = require("@scallop-io/sui-kit");
|
|
1615
|
-
|
|
1616
|
-
// src/queries/coreQuery.ts
|
|
1617
|
-
var import_utils2 = require("@mysten/sui.js/utils");
|
|
1618
|
-
|
|
1619
|
-
// src/utils/builder.ts
|
|
1620
|
-
var requireSender = (txBlock) => {
|
|
1621
|
-
const sender = txBlock.blockData.sender;
|
|
1622
|
-
if (!sender) {
|
|
1623
|
-
throw new Error("Sender is required");
|
|
1624
|
-
}
|
|
1625
|
-
return sender;
|
|
1626
|
-
};
|
|
1627
|
-
var checkVesca = (prevUnlockAtInMillisTimestamp) => {
|
|
1628
|
-
if (prevUnlockAtInMillisTimestamp === void 0) {
|
|
1629
|
-
throw new Error("veSca not found");
|
|
1630
|
-
}
|
|
1631
|
-
};
|
|
1632
|
-
var checkVescaExpired = (prevUnlockAtInMillisTimestamp) => {
|
|
1633
|
-
if (prevUnlockAtInMillisTimestamp <= (/* @__PURE__ */ new Date()).getTime()) {
|
|
1634
|
-
throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
|
|
1635
|
-
}
|
|
1636
|
-
};
|
|
1637
|
-
var checkExtendLockPeriod = (lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInMillisTimestamp) => {
|
|
1638
|
-
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
1639
|
-
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
1640
|
-
const prevUnlockAtInSecondTimestamp = Math.floor(
|
|
1641
|
-
prevUnlockAtInMillisTimestamp / 1e3
|
|
1642
|
-
);
|
|
1643
|
-
if (lockPeriodInDays < 1) {
|
|
1644
|
-
throw new Error("Minimum lock period is 1 day");
|
|
1645
|
-
}
|
|
1646
|
-
const availableLockPeriodInDays = Math.floor(
|
|
1647
|
-
(newUnlockAtInSecondTimestamp - prevUnlockAtInSecondTimestamp) / UNLOCK_ROUND_DURATION
|
|
1648
|
-
);
|
|
1649
|
-
if (lockPeriodInDays > availableLockPeriodInDays) {
|
|
1650
|
-
throw new Error(
|
|
1651
|
-
`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}`
|
|
1652
|
-
);
|
|
1653
|
-
}
|
|
1654
|
-
};
|
|
1655
|
-
var checkLockSca = (scaAmountOrCoin, lockPeriodInDays, newUnlockAtInSecondTimestamp, prevUnlockAtInMillisTimestamp) => {
|
|
1656
|
-
const prevUnlockAtInSecondTimestamp = prevUnlockAtInMillisTimestamp ? Math.floor(prevUnlockAtInMillisTimestamp / 1e3) : void 0;
|
|
1657
|
-
const isInitialLock = !prevUnlockAtInSecondTimestamp;
|
|
1658
|
-
const isLockExpired = !isInitialLock && prevUnlockAtInSecondTimestamp * 1e3 <= (/* @__PURE__ */ new Date()).getTime();
|
|
1659
|
-
if (isInitialLock || isLockExpired) {
|
|
1660
|
-
if (scaAmountOrCoin !== void 0 && lockPeriodInDays !== void 0) {
|
|
1661
|
-
if (lockPeriodInDays <= 0) {
|
|
1662
|
-
throw new Error("Lock period must be greater than 0");
|
|
1663
|
-
}
|
|
1664
|
-
if (typeof scaAmountOrCoin === "number" && scaAmountOrCoin < MIN_INITIAL_LOCK_AMOUNT) {
|
|
1665
|
-
throw new Error(
|
|
1666
|
-
`Minimum lock amount for ${isLockExpired ? "renewing expired veSca" : "initial lock"} is 10 SCA`
|
|
1667
|
-
);
|
|
1668
|
-
}
|
|
1669
|
-
const extendLockPeriodInSecond = lockPeriodInDays * UNLOCK_ROUND_DURATION;
|
|
1670
|
-
if (extendLockPeriodInSecond > MAX_LOCK_DURATION) {
|
|
1671
|
-
throw new Error(
|
|
1672
|
-
`Maximum lock period is ~4 years (${MAX_LOCK_ROUNDS} days)`
|
|
1673
|
-
);
|
|
1674
|
-
}
|
|
1675
|
-
} else {
|
|
1676
|
-
throw new Error(
|
|
1677
|
-
`SCA amount and lock period is required for ${isLockExpired ? "renewing expired veSca" : "initial lock"}`
|
|
1678
|
-
);
|
|
1679
|
-
}
|
|
1680
|
-
} else {
|
|
1681
|
-
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
1682
|
-
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
1683
|
-
if (typeof scaAmountOrCoin === "number" && scaAmountOrCoin < MIN_TOP_UP_AMOUNT) {
|
|
1684
|
-
throw new Error("Minimum top up amount is 1 SCA");
|
|
1685
|
-
}
|
|
1686
|
-
if (newUnlockAtInSecondTimestamp && lockPeriodInDays) {
|
|
1687
|
-
checkExtendLockPeriod(
|
|
1688
|
-
lockPeriodInDays,
|
|
1689
|
-
newUnlockAtInSecondTimestamp,
|
|
1690
|
-
prevUnlockAtInMillisTimestamp
|
|
1691
|
-
);
|
|
1692
|
-
}
|
|
1693
|
-
}
|
|
1694
|
-
};
|
|
1695
|
-
var checkExtendLockAmount = (scaAmount, prevUnlockAtInMillisTimestamp) => {
|
|
1696
|
-
checkVesca(prevUnlockAtInMillisTimestamp);
|
|
1697
|
-
checkVescaExpired(prevUnlockAtInMillisTimestamp);
|
|
1698
|
-
if (scaAmount < MIN_TOP_UP_AMOUNT) {
|
|
1699
|
-
throw new Error("Minimum top up amount is 1 SCA");
|
|
1700
|
-
}
|
|
1701
|
-
const isInitialLock = !prevUnlockAtInMillisTimestamp;
|
|
1702
|
-
const isLockExpired = !isInitialLock && prevUnlockAtInMillisTimestamp <= (/* @__PURE__ */ new Date()).getTime();
|
|
1703
|
-
if (isLockExpired) {
|
|
1704
|
-
throw new Error("veSca is expired, use renewExpiredVeScaQuick instead");
|
|
1705
|
-
}
|
|
1706
|
-
};
|
|
1707
|
-
var checkRenewExpiredVeSca = (scaAmount, lockPeriodInDays, prevUnlockAtInMillisTimestamp) => {
|
|
1708
|
-
if (!prevUnlockAtInMillisTimestamp || prevUnlockAtInMillisTimestamp > (/* @__PURE__ */ new Date()).getTime()) {
|
|
1709
|
-
throw new Error("Renew method can only be used for expired veSca");
|
|
1710
|
-
}
|
|
1711
|
-
if (scaAmount < MIN_INITIAL_LOCK_AMOUNT) {
|
|
1712
|
-
throw new Error("Minimum lock amount for renewing expired vesca 10 SCA");
|
|
1713
|
-
}
|
|
1714
|
-
const extendLockPeriodInSecond = lockPeriodInDays * UNLOCK_ROUND_DURATION;
|
|
1715
|
-
if (extendLockPeriodInSecond >= MAX_LOCK_DURATION - UNLOCK_ROUND_DURATION) {
|
|
1716
|
-
throw new Error(
|
|
1717
|
-
`Maximum lock period is ~4 years (${MAX_LOCK_ROUNDS - 1} days)`
|
|
1718
|
-
);
|
|
1719
|
-
}
|
|
1720
|
-
};
|
|
1721
|
-
|
|
1722
|
-
// src/utils/query.ts
|
|
1723
|
-
var import_bignumber = __toESM(require("bignumber.js"));
|
|
1724
|
-
var import_utils = require("@mysten/sui.js/utils");
|
|
1725
|
-
var parseOriginMarketPoolData = (originMarketPoolData) => {
|
|
1726
|
-
return {
|
|
1727
|
-
coinType: (0, import_utils.normalizeStructTag)(originMarketPoolData.type.name),
|
|
1728
|
-
// Parse origin data required for basic calculations.
|
|
1729
|
-
maxBorrowRate: Number(originMarketPoolData.maxBorrowRate.value) / 2 ** 32,
|
|
1730
|
-
borrowRate: Number(originMarketPoolData.interestRate.value) / 2 ** 32,
|
|
1731
|
-
borrowRateScale: Number(originMarketPoolData.interestRateScale),
|
|
1732
|
-
borrowIndex: Number(originMarketPoolData.borrowIndex),
|
|
1733
|
-
lastUpdated: Number(originMarketPoolData.lastUpdated),
|
|
1734
|
-
cashAmount: Number(originMarketPoolData.cash),
|
|
1735
|
-
debtAmount: Number(originMarketPoolData.debt),
|
|
1736
|
-
marketCoinSupplyAmount: Number(originMarketPoolData.marketCoinSupply),
|
|
1737
|
-
reserveAmount: Number(originMarketPoolData.reserve),
|
|
1738
|
-
reserveFactor: Number(originMarketPoolData.reserveFactor.value) / 2 ** 32,
|
|
1739
|
-
borrowWeight: Number(originMarketPoolData.borrowWeight.value) / 2 ** 32,
|
|
1740
|
-
borrowFee: Number(originMarketPoolData.borrowFeeRate.value) / 2 ** 32,
|
|
1741
|
-
// Parse origin data required for additional display.
|
|
1742
|
-
baseBorrowRate: Number(originMarketPoolData.baseBorrowRatePerSec.value) / 2 ** 32,
|
|
1743
|
-
borrowRateOnHighKink: Number(originMarketPoolData.borrowRateOnHighKink.value) / 2 ** 32,
|
|
1744
|
-
borrowRateOnMidKink: Number(originMarketPoolData.borrowRateOnMidKink.value) / 2 ** 32,
|
|
1745
|
-
highKink: Number(originMarketPoolData.highKink.value) / 2 ** 32,
|
|
1746
|
-
midKink: Number(originMarketPoolData.midKink.value) / 2 ** 32,
|
|
1747
|
-
minBorrowAmount: Number(originMarketPoolData.minBorrowAmount)
|
|
1748
|
-
};
|
|
1749
|
-
};
|
|
1750
|
-
var calculateMarketPoolData = (utils, parsedMarketPoolData) => {
|
|
1751
|
-
const poolCoinName = utils.parseCoinNameFromType(
|
|
1752
|
-
parsedMarketPoolData.coinType
|
|
1753
|
-
);
|
|
1754
|
-
const coinDecimal = utils.getCoinDecimal(poolCoinName);
|
|
1755
|
-
const borrowYearFactor = 24 * 365 * 3600;
|
|
1756
|
-
const baseBorrowApr = parsedMarketPoolData.baseBorrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
1757
|
-
const borrowAprOnHighKink = parsedMarketPoolData.borrowRateOnHighKink * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
1758
|
-
const borrowAprOnMidKink = parsedMarketPoolData.borrowRateOnMidKink * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
1759
|
-
const maxBorrowApr = parsedMarketPoolData.maxBorrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
1760
|
-
const borrowApr = parsedMarketPoolData.borrowRate * borrowYearFactor / parsedMarketPoolData.borrowRateScale;
|
|
1761
|
-
const timeDelta = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - parsedMarketPoolData.lastUpdated;
|
|
1762
|
-
const borrowIndexDelta = (0, import_bignumber.default)(parsedMarketPoolData.borrowIndex).multipliedBy(
|
|
1763
|
-
(0, import_bignumber.default)(timeDelta).multipliedBy(parsedMarketPoolData.borrowRate)
|
|
1764
|
-
).dividedBy(parsedMarketPoolData.borrowRateScale);
|
|
1765
|
-
const currentBorrowIndex = (0, import_bignumber.default)(parsedMarketPoolData.borrowIndex).plus(
|
|
1766
|
-
borrowIndexDelta
|
|
1767
|
-
);
|
|
1768
|
-
const growthInterest = (0, import_bignumber.default)(currentBorrowIndex).dividedBy(parsedMarketPoolData.borrowIndex).minus(1);
|
|
1769
|
-
const increasedDebtAmount = (0, import_bignumber.default)(
|
|
1770
|
-
parsedMarketPoolData.debtAmount
|
|
1771
|
-
).multipliedBy(growthInterest);
|
|
1772
|
-
const borrowAmount = increasedDebtAmount.plus(
|
|
1773
|
-
parsedMarketPoolData.debtAmount
|
|
1774
|
-
);
|
|
1775
|
-
const borrowCoin = borrowAmount.shiftedBy(-1 * coinDecimal);
|
|
1776
|
-
const reserveAmount = (0, import_bignumber.default)(parsedMarketPoolData.reserveAmount).plus(
|
|
1777
|
-
increasedDebtAmount.multipliedBy(parsedMarketPoolData.reserveFactor)
|
|
1778
|
-
);
|
|
1779
|
-
const reserveCoin = reserveAmount.shiftedBy(-1 * coinDecimal);
|
|
1780
|
-
const supplyAmount = (0, import_bignumber.default)(borrowAmount).plus(
|
|
1781
|
-
Math.max(parsedMarketPoolData.cashAmount - reserveAmount.toNumber(), 0)
|
|
1782
|
-
);
|
|
1783
|
-
const supplyCoin = supplyAmount.shiftedBy(-1 * coinDecimal);
|
|
1784
|
-
let utilizationRate = (0, import_bignumber.default)(borrowAmount).dividedBy(supplyAmount);
|
|
1785
|
-
utilizationRate = utilizationRate.isFinite() ? utilizationRate : (0, import_bignumber.default)(0);
|
|
1786
|
-
let supplyApr = (0, import_bignumber.default)(borrowApr).multipliedBy(utilizationRate).multipliedBy(1 - parsedMarketPoolData.reserveFactor);
|
|
1787
|
-
supplyApr = supplyApr.isFinite() ? supplyApr : (0, import_bignumber.default)(0);
|
|
1788
|
-
let conversionRate = supplyAmount.dividedBy(
|
|
1789
|
-
parsedMarketPoolData.marketCoinSupplyAmount
|
|
1790
|
-
);
|
|
1791
|
-
conversionRate = conversionRate.isFinite() && !conversionRate.isNaN() ? conversionRate : (0, import_bignumber.default)(1);
|
|
1792
|
-
return {
|
|
1793
|
-
baseBorrowApr,
|
|
1794
|
-
baseBorrowApy: utils.parseAprToApy(baseBorrowApr),
|
|
1795
|
-
borrowAprOnHighKink,
|
|
1796
|
-
borrowApyOnHighKink: utils.parseAprToApy(borrowAprOnHighKink),
|
|
1797
|
-
borrowAprOnMidKink,
|
|
1798
|
-
borrowApyOnMidKink: utils.parseAprToApy(borrowAprOnMidKink),
|
|
1799
|
-
maxBorrowApr,
|
|
1800
|
-
maxBorrowApy: utils.parseAprToApy(maxBorrowApr),
|
|
1801
|
-
borrowApr: Math.min(borrowApr, maxBorrowApr),
|
|
1802
|
-
borrowApy: Math.min(
|
|
1803
|
-
utils.parseAprToApy(borrowApr),
|
|
1804
|
-
utils.parseAprToApy(maxBorrowApr)
|
|
1805
|
-
),
|
|
1806
|
-
borrowIndex: currentBorrowIndex.toNumber(),
|
|
1807
|
-
growthInterest: growthInterest.toNumber(),
|
|
1808
|
-
supplyAmount: supplyAmount.toNumber(),
|
|
1809
|
-
supplyCoin: supplyCoin.toNumber(),
|
|
1810
|
-
borrowAmount: borrowAmount.toNumber(),
|
|
1811
|
-
borrowCoin: borrowCoin.toNumber(),
|
|
1812
|
-
reserveAmount: reserveAmount.toNumber(),
|
|
1813
|
-
reserveCoin: reserveCoin.toNumber(),
|
|
1814
|
-
utilizationRate: utilizationRate.toNumber(),
|
|
1815
|
-
supplyApr: supplyApr.toNumber(),
|
|
1816
|
-
supplyApy: utils.parseAprToApy(supplyApr.toNumber()),
|
|
1817
|
-
conversionRate: conversionRate.toNumber()
|
|
1818
|
-
};
|
|
1819
|
-
};
|
|
1820
|
-
var parseOriginMarketCollateralData = (originMarketCollateralData) => {
|
|
1821
|
-
const divisor = 2 ** 32;
|
|
1822
|
-
return {
|
|
1823
|
-
coinType: (0, import_utils.normalizeStructTag)(originMarketCollateralData.type.name),
|
|
1824
|
-
collateralFactor: Number(originMarketCollateralData.collateralFactor.value) / divisor,
|
|
1825
|
-
liquidationFactor: Number(originMarketCollateralData.liquidationFactor.value) / divisor,
|
|
1826
|
-
liquidationDiscount: Number(originMarketCollateralData.liquidationDiscount.value) / divisor,
|
|
1827
|
-
liquidationPanelty: Number(originMarketCollateralData.liquidationPanelty.value) / divisor,
|
|
1828
|
-
liquidationReserveFactor: Number(originMarketCollateralData.liquidationReserveFactor.value) / divisor,
|
|
1829
|
-
maxCollateralAmount: Number(originMarketCollateralData.maxCollateralAmount),
|
|
1830
|
-
totalCollateralAmount: Number(
|
|
1831
|
-
originMarketCollateralData.totalCollateralAmount
|
|
1832
|
-
)
|
|
1833
|
-
};
|
|
1834
|
-
};
|
|
1835
|
-
var calculateMarketCollateralData = (utils, parsedMarketCollateralData) => {
|
|
1836
|
-
const collateralCoinName = utils.parseCoinNameFromType(
|
|
1837
|
-
parsedMarketCollateralData.coinType
|
|
1838
|
-
);
|
|
1839
|
-
const coinDecimal = utils.getCoinDecimal(collateralCoinName);
|
|
1840
|
-
const maxCollateralCoin = (0, import_bignumber.default)(
|
|
1841
|
-
parsedMarketCollateralData.maxCollateralAmount
|
|
1842
|
-
).shiftedBy(-1 * coinDecimal);
|
|
1843
|
-
const depositCoin = (0, import_bignumber.default)(
|
|
1844
|
-
parsedMarketCollateralData.totalCollateralAmount
|
|
1845
|
-
).shiftedBy(-1 * coinDecimal);
|
|
1846
|
-
return {
|
|
1847
|
-
maxDepositAmount: parsedMarketCollateralData.maxCollateralAmount,
|
|
1848
|
-
maxDepositCoin: maxCollateralCoin.toNumber(),
|
|
1849
|
-
depositAmount: parsedMarketCollateralData.totalCollateralAmount,
|
|
1850
|
-
depositCoin: depositCoin.toNumber()
|
|
1851
|
-
};
|
|
1852
|
-
};
|
|
1853
|
-
var parseOriginSpoolData = (originSpoolData) => {
|
|
1854
|
-
return {
|
|
1855
|
-
stakeType: (0, import_utils.normalizeStructTag)(originSpoolData.stakeType.fields.name),
|
|
1856
|
-
maxPoint: Number(originSpoolData.maxDistributedPoint),
|
|
1857
|
-
distributedPoint: Number(originSpoolData.distributedPoint),
|
|
1858
|
-
pointPerPeriod: Number(originSpoolData.distributedPointPerPeriod),
|
|
1859
|
-
period: Number(originSpoolData.pointDistributionTime),
|
|
1860
|
-
maxStake: Number(originSpoolData.maxStake),
|
|
1861
|
-
staked: Number(originSpoolData.stakes),
|
|
1862
|
-
index: Number(originSpoolData.index),
|
|
1863
|
-
createdAt: Number(originSpoolData.createdAt),
|
|
1864
|
-
lastUpdate: Number(originSpoolData.lastUpdate)
|
|
1865
|
-
};
|
|
1866
|
-
};
|
|
1867
|
-
var calculateSpoolData = (parsedSpoolData, stakeMarketCoinPrice, stakeMarketCoinDecimal) => {
|
|
1868
|
-
const baseIndexRate = 1e9;
|
|
1869
|
-
const distributedPointPerSec = (0, import_bignumber.default)(
|
|
1870
|
-
parsedSpoolData.pointPerPeriod
|
|
1871
|
-
).dividedBy(parsedSpoolData.period);
|
|
1872
|
-
const pointPerSec = (0, import_bignumber.default)(parsedSpoolData.pointPerPeriod).dividedBy(
|
|
1873
|
-
parsedSpoolData.period
|
|
1874
|
-
);
|
|
1875
|
-
const remainingPeriod = pointPerSec.gt(0) ? (0, import_bignumber.default)(parsedSpoolData.maxPoint).minus(parsedSpoolData.distributedPoint).dividedBy(pointPerSec) : (0, import_bignumber.default)(0);
|
|
1876
|
-
const startDate = parsedSpoolData.createdAt;
|
|
1877
|
-
const endDate = remainingPeriod.plus(parsedSpoolData.lastUpdate).integerValue().toNumber();
|
|
1878
|
-
const timeDelta = (0, import_bignumber.default)(
|
|
1879
|
-
Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3) - parsedSpoolData.lastUpdate
|
|
1880
|
-
).dividedBy(parsedSpoolData.period).toFixed(0);
|
|
1881
|
-
const remainingPoints = (0, import_bignumber.default)(parsedSpoolData.maxPoint).minus(
|
|
1882
|
-
parsedSpoolData.distributedPoint
|
|
1883
|
-
);
|
|
1884
|
-
const accumulatedPoints = import_bignumber.default.minimum(
|
|
1885
|
-
(0, import_bignumber.default)(timeDelta).multipliedBy(parsedSpoolData.pointPerPeriod),
|
|
1886
|
-
remainingPoints
|
|
1887
|
-
);
|
|
1888
|
-
const currentPointIndex = (0, import_bignumber.default)(parsedSpoolData.index).plus(
|
|
1889
|
-
accumulatedPoints.dividedBy(parsedSpoolData.staked).isFinite() ? (0, import_bignumber.default)(baseIndexRate).multipliedBy(accumulatedPoints).dividedBy(parsedSpoolData.staked) : 0
|
|
1890
|
-
);
|
|
1891
|
-
const currentTotalDistributedPoint = (0, import_bignumber.default)(
|
|
1892
|
-
parsedSpoolData.distributedPoint
|
|
1893
|
-
).plus(accumulatedPoints);
|
|
1894
|
-
const stakedAmount = (0, import_bignumber.default)(parsedSpoolData.staked);
|
|
1895
|
-
const stakedCoin = stakedAmount.shiftedBy(-1 * stakeMarketCoinDecimal);
|
|
1896
|
-
const stakedValue = stakedCoin.multipliedBy(stakeMarketCoinPrice);
|
|
1897
|
-
return {
|
|
1898
|
-
distributedPointPerSec: distributedPointPerSec.toNumber(),
|
|
1899
|
-
accumulatedPoints: accumulatedPoints.toNumber(),
|
|
1900
|
-
currentPointIndex: currentPointIndex.toNumber(),
|
|
1901
|
-
currentTotalDistributedPoint: currentTotalDistributedPoint.toNumber(),
|
|
1902
|
-
startDate: new Date(startDate * 1e3),
|
|
1903
|
-
endDate: new Date(endDate * 1e3),
|
|
1904
|
-
stakedAmount: stakedAmount.toNumber(),
|
|
1905
|
-
stakedCoin: stakedCoin.toNumber(),
|
|
1906
|
-
stakedValue: stakedValue.toNumber()
|
|
1907
|
-
};
|
|
1908
|
-
};
|
|
1909
|
-
var parseOriginSpoolRewardPoolData = (originSpoolRewardPoolData) => {
|
|
1910
|
-
return {
|
|
1911
|
-
claimedRewards: Number(originSpoolRewardPoolData.claimed_rewards),
|
|
1912
|
-
exchangeRateDenominator: Number(
|
|
1913
|
-
originSpoolRewardPoolData.exchange_rate_denominator
|
|
1914
|
-
),
|
|
1915
|
-
exchangeRateNumerator: Number(
|
|
1916
|
-
originSpoolRewardPoolData.exchange_rate_numerator
|
|
1917
|
-
),
|
|
1918
|
-
rewards: Number(originSpoolRewardPoolData.rewards),
|
|
1919
|
-
spoolId: String(originSpoolRewardPoolData.spool_id)
|
|
1920
|
-
};
|
|
1921
|
-
};
|
|
1922
|
-
var calculateSpoolRewardPoolData = (parsedSpoolData, parsedSpoolRewardPoolData, calculatedSpoolData, rewardCoinPrice, rewardCoinDecimal) => {
|
|
1923
|
-
const rateYearFactor = 365 * 24 * 60 * 60;
|
|
1924
|
-
const rewardPerSec = (0, import_bignumber.default)(calculatedSpoolData.distributedPointPerSec).multipliedBy(parsedSpoolRewardPoolData.exchangeRateNumerator).dividedBy(parsedSpoolRewardPoolData.exchangeRateDenominator);
|
|
1925
|
-
const totalRewardAmount = (0, import_bignumber.default)(parsedSpoolData.maxPoint).multipliedBy(parsedSpoolRewardPoolData.exchangeRateNumerator).dividedBy(parsedSpoolRewardPoolData.exchangeRateDenominator);
|
|
1926
|
-
const totalRewardCoin = totalRewardAmount.shiftedBy(-1 * rewardCoinDecimal);
|
|
1927
|
-
const totalRewardValue = totalRewardCoin.multipliedBy(rewardCoinPrice);
|
|
1928
|
-
const remaindRewardAmount = (0, import_bignumber.default)(parsedSpoolRewardPoolData.rewards);
|
|
1929
|
-
const remaindRewardCoin = remaindRewardAmount.shiftedBy(
|
|
1930
|
-
-1 * rewardCoinDecimal
|
|
1931
|
-
);
|
|
1932
|
-
const remaindRewardValue = remaindRewardCoin.multipliedBy(rewardCoinPrice);
|
|
1933
|
-
const claimedRewardAmount = (0, import_bignumber.default)(
|
|
1934
|
-
parsedSpoolRewardPoolData.claimedRewards
|
|
1935
|
-
);
|
|
1936
|
-
const claimedRewardCoin = claimedRewardAmount.shiftedBy(
|
|
1937
|
-
-1 * rewardCoinDecimal
|
|
1938
|
-
);
|
|
1939
|
-
const claimedRewardValue = claimedRewardCoin.multipliedBy(rewardCoinPrice);
|
|
1940
|
-
const rewardValueForYear = (0, import_bignumber.default)(rewardPerSec).shiftedBy(-1 * rewardCoinDecimal).multipliedBy(rateYearFactor).multipliedBy(rewardCoinPrice);
|
|
1941
|
-
let rewardRate = rewardValueForYear.dividedBy(calculatedSpoolData.stakedValue).isFinite() ? rewardValueForYear.dividedBy(calculatedSpoolData.stakedValue).toNumber() : Infinity;
|
|
1942
|
-
if (parsedSpoolData.maxPoint <= parsedSpoolData.distributedPoint || parsedSpoolData.pointPerPeriod === 0) {
|
|
1943
|
-
rewardRate = Infinity;
|
|
1457
|
+
// id: '0xcb328f7ffa7f9342ed85af3fdb2f22919e1a06dfb2f713c04c73543870d7548f',
|
|
1458
|
+
id: "0xb5567dfa5c7fc17a249e959732664c50713dd8c23db1a11376b27df800c17418",
|
|
1459
|
+
rewardPoolId: (
|
|
1460
|
+
// '0x2c9f934d67a5baa586ceec2cc24163a2f049a6af3d5ba36b84d8ac40f25c4080',
|
|
1461
|
+
"0x60768b0687ff0235e376a039709a683e4c436098785e473b67b32dbab47b69ab"
|
|
1462
|
+
)
|
|
1463
|
+
},
|
|
1464
|
+
scetus: {
|
|
1465
|
+
id: "0xac1bb13bf4472a637c18c2415fb0e3c1227ea2bcf35242e50563c98215bd298e",
|
|
1466
|
+
rewardPoolId: "0x6835c1224126a45086fc6406adc249e3f30df18d779ca4f4e570e38716a17f3f"
|
|
1467
|
+
},
|
|
1468
|
+
safsui: {
|
|
1469
|
+
// id: '0xeedf438abcaa6ce4d9625ffca110920592d5867e4c5637d84ad9f466c4feb800',
|
|
1470
|
+
id: "0xc568bb4c991258e839aa54802ecda04fcd9838c826bc3b42b40af81b23c458c8",
|
|
1471
|
+
rewardPoolId: (
|
|
1472
|
+
// '0x89255a2f86ed7fbfef35ab8b7be48cc7667015975be2685dd9a55a9a64baf76e',
|
|
1473
|
+
"0x389a3cbeda742b918941bb24fd00e077bad3367484394d6234f8209b9a6aa03d"
|
|
1474
|
+
)
|
|
1475
|
+
},
|
|
1476
|
+
shasui: {
|
|
1477
|
+
// id: '0xa6148bc1b623e936d39a952ceb5bea79e8b37228a8f595067bf1852efd3c34aa',
|
|
1478
|
+
id: "0x93f3f4499bf89f2d05ddc1f8b15f51701a7c6c4d0ac0b9c3bc99462cbbd8e321",
|
|
1479
|
+
rewardPoolId: (
|
|
1480
|
+
// '0x6f3563644d3e2ef13176dbf9d865bd93479df60ccbe07b7e66db57f6309f5a66',
|
|
1481
|
+
"0x94cee1be7f5ff34193f3aabef0b14142cb28af4d905fe487a9a7d85a15edb6aa"
|
|
1482
|
+
)
|
|
1483
|
+
},
|
|
1484
|
+
svsui: {
|
|
1485
|
+
// id: '0x69ce8e537e750a95381e6040794afa5ab1758353a1a2e1de7760391b01f91670',
|
|
1486
|
+
id: "0xa970e9087f80cb59e9299b8e7af7175d977ad6c9af0322aa4440e138fbd7ae00",
|
|
1487
|
+
rewardPoolId: (
|
|
1488
|
+
// '0xbca914adce058ad0902c7f3cfcd698392a475f00dcfdc3f76001d0370b98777a',
|
|
1489
|
+
"0x38eee9699c4fc132a6623e54b865f047df4fc6eb83af807300f44e8f4b235ff0"
|
|
1490
|
+
)
|
|
1491
|
+
}
|
|
1492
|
+
},
|
|
1493
|
+
config: ""
|
|
1494
|
+
},
|
|
1495
|
+
borrowIncentive: {
|
|
1496
|
+
id: "0x6152f696fc3a658f33c4b891764731a59153125ffedfa8bff7167c42823f58a9",
|
|
1497
|
+
adminCap: "0xc486afa253646f4d381e81d7f1df8aa4723b845a6bb356f69bad635ffefffe2c",
|
|
1498
|
+
object: "0x002875153e09f8145ab63527bc85c00f2bd102e12f9573c47f8cdf1a1cb62934",
|
|
1499
|
+
query: "0x529edc54a3dce2207703ceebbccb0ac14133f7825c1f528775ba0d85a4063489",
|
|
1500
|
+
incentivePools: "0x6547e143d406b5ccd5f46aae482497de279cc1a68c406f701df70a05f9212ab4",
|
|
1501
|
+
incentiveAccounts: "0xc4701fdbc1c92f9a636d334d66012b3027659e9fb8aff27279a82edfb6b77d02",
|
|
1502
|
+
config: "0xdf5d04b4691cc67e82fd4db8394d89ff44823a9de29716c924f74bb4f11cc1f7"
|
|
1503
|
+
},
|
|
1504
|
+
referral: {
|
|
1505
|
+
id: "0xa3654ebb63eb06c0f4ff52f8aa6512df9f164f7772bdf15dac3709bd3798dda9",
|
|
1506
|
+
object: "0x5658d4bf5ddcba27e4337b4262108b3ad1716643cac8c2054ac341538adc72ec",
|
|
1507
|
+
adminCap: "0xc5dc06b9074291259f2cac460c940012c781c4430e42125c541cc43101c3bcbd",
|
|
1508
|
+
referralBindings: "0xf63299d58789d99de94092b9011323466e55ca0c1ea1a7a3786a589af46e1c09",
|
|
1509
|
+
bindingTableId: "0x1c8202b17267ec8d6cf97ca013615354181a04f179570e42601ff2dae19294b1",
|
|
1510
|
+
referralRevenuePool: "0x6abd852caf90769c1b185cdf636d841673fa95528f0550f018b8a138bd283c07",
|
|
1511
|
+
revenueTableId: "0x595baa3654c297bff84ab7786a2d250f019cefc66e8df8e89fd9d41e02bd30dd",
|
|
1512
|
+
referralTiers: "0x962cb903d8d7346190c5204785ccbb91b61086aa764f674c8145df82335cf83e",
|
|
1513
|
+
tiersTableId: "0xeac755a7a8b7798530905ac79e8c114f19d0f130f6eab012954f08faac29c75d",
|
|
1514
|
+
// authorizedWitnessList:
|
|
1515
|
+
// '0xf21b0ed043c9bb70842c0129159f4943dbcc3c9ef2f2f808af65f8be25cfd20e',
|
|
1516
|
+
authorizedWitnessList: "0x9d6223dc52015b8a3986a573590ef2af8f1b8f3e4685513888c052f001b87e7f",
|
|
1517
|
+
version: "0x1bd4b7285f72e11c316b828c7c47b3f4da18dcec9f9b3dba6d8629cbb6f93e5e"
|
|
1518
|
+
},
|
|
1519
|
+
vesca: {
|
|
1520
|
+
id: "0xb15b6e0cdd85afb5028bea851dd249405e734d800a259147bbc24980629723a4",
|
|
1521
|
+
object: "0xb15b6e0cdd85afb5028bea851dd249405e734d800a259147bbc24980629723a4",
|
|
1522
|
+
adminCap: "0x8ffa76135c5b85c5fbd73a6448a4a733d826cb63a267ab817656acb77c72d4a5",
|
|
1523
|
+
tableId: "0xe3153b2bf124be0b86cb8bd468346a861efd0da52fc42197b54d2f616488a311",
|
|
1524
|
+
table: "0x611cb8d9d4d90867467b5ebdf4cc447a0047ed5b01334a28a29fcfe733e3d609",
|
|
1525
|
+
treasury: "0xe8c112c09b88158dc6c8e23d1fbae5b3c7136cdee54b7dafc08e65db28c4a5bc",
|
|
1526
|
+
config: "0xe0a2ff281e73c1d53cfa85807080f87e833e4f1a7f93dcf8800b3865269a76b9"
|
|
1527
|
+
},
|
|
1528
|
+
loyaltyProgram: {
|
|
1529
|
+
id: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
1530
|
+
object: "0xd17bcf8b5a59652c36225d478564a8593ae0ed7d650bcacdda1d6fe179127907",
|
|
1531
|
+
rewardPool: "0xf9c090492ef476bd542109d0913ffe871cbfa28578b7114eca2a8c0e5671786f",
|
|
1532
|
+
userRewardTableId: "0x748a80395849ed37db1b0e14f2ab5d1d96458d2359ab3a84eb079d0f4ac7cf2e"
|
|
1533
|
+
},
|
|
1534
|
+
scoin: {
|
|
1535
|
+
id: "0xad2ca2aa5089df94bb2d444d5eb3520378c2f2dfb3a0bd2a2c994145ac4b0a53",
|
|
1536
|
+
coins: {
|
|
1537
|
+
ssui: {
|
|
1538
|
+
coinType: "0xfac769100bccc0caebcf4f4e2d00ac2f8883f07f724be28940df90605f5e7e9a::scallop_sui::SCALLOP_SUI",
|
|
1539
|
+
treasury: "0x9cb4551b36c17d37e19d700147fa819ea1c487ff8bcf18374de2cceb2e9d4845"
|
|
1540
|
+
},
|
|
1541
|
+
scetus: {
|
|
1542
|
+
coinType: "0x8b71e6d323ed78515af2bead13bf3d0da1562ba4a99234eb7c4f14fd39ef0427::scallop_cetus::SCALLOP_CETUS",
|
|
1543
|
+
treasury: "0xd786f4b2d26278cc7911a3445b1b085eab60f269ef9dbb6b87e803d52f155003"
|
|
1544
|
+
},
|
|
1545
|
+
ssca: {
|
|
1546
|
+
coinType: "0x0a9d3c6c9af9f6e8def82921541bcbd17f73ed31bed3adcb684f2a4c267e42f0::scallop_sca::SCALLOP_SCA",
|
|
1547
|
+
treasury: "0xe818636d1d6c46d6ea1a2dce9d94696d7cbc18ce27451b603eeaa47aba8d75e0"
|
|
1548
|
+
},
|
|
1549
|
+
susdc: {
|
|
1550
|
+
coinType: "0xaedc3ab75db8680b81a755015fa90124d217be93457b893c05bac033817defaf::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC",
|
|
1551
|
+
treasury: "0xfc6971648f867f7fd6928d1b873af71577e2eaf2c7543ef8bc82c431d833ae78"
|
|
1552
|
+
},
|
|
1553
|
+
susdt: {
|
|
1554
|
+
coinType: "0xbf02fc87ddc104b342ad8414c85ceadf5b0c823c055a06fb0ed776272c01a52a::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT",
|
|
1555
|
+
treasury: "0xb9593e2c3a0ba796ee815012b75ae46468ea78cda0188b9ac6816efe65503521"
|
|
1556
|
+
},
|
|
1557
|
+
seth: {
|
|
1558
|
+
coinType: "0x27d54f43e3eda701be56b82e5756e41c84467cd202f5cf713d5f9e45a9f1b6bc::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH",
|
|
1559
|
+
treasury: "0x032b4c8fac94c038dbe986f7587e9b1e4ef580b5ee06d2ef249d85459b7ef05d"
|
|
1560
|
+
},
|
|
1561
|
+
safsui: {
|
|
1562
|
+
coinType: "0xb75b46d975d8d80670b53a6bee90baaa8ce2e0b7d397f079447d641eef6b44ad::scallop_af_sui::SCALLOP_AF_SUI",
|
|
1563
|
+
treasury: "0x21450ef0570ef3d224ffa3b873ab802e439ece7b93cc7efad10ae0c1e3b3fcfe"
|
|
1564
|
+
},
|
|
1565
|
+
shasui: {
|
|
1566
|
+
coinType: "0xd973a723874e2c7cde196602a79155a1343a933f8cf87d9b1bb7408bc1acbc58::scallop_ha_sui::SCALLOP_HA_SUI",
|
|
1567
|
+
treasury: "0xf822fc1402207e47d2e3ba8ff6e1e594bf1de777dc5ebd2744619cd2726e3b0d"
|
|
1568
|
+
},
|
|
1569
|
+
svsui: {
|
|
1570
|
+
coinType: "0x97023a317320c4498cc4cd239dd02fd30c28246e5e8f81325d63f2bd8d70f6b3::scallop_v_sui::SCALLOP_V_SUI",
|
|
1571
|
+
treasury: "0x327114f0bf3559d7e2de10282147ed76a236c7c6775029165c4db09a6062ead6\u0192"
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1944
1574
|
}
|
|
1945
|
-
return {
|
|
1946
|
-
rewardApr: rewardRate,
|
|
1947
|
-
totalRewardAmount: totalRewardAmount.toNumber(),
|
|
1948
|
-
totalRewardCoin: totalRewardCoin.toNumber(),
|
|
1949
|
-
totalRewardValue: totalRewardValue.toNumber(),
|
|
1950
|
-
remaindRewardAmount: remaindRewardAmount.toNumber(),
|
|
1951
|
-
remaindRewardCoin: remaindRewardCoin.toNumber(),
|
|
1952
|
-
remaindRewardValue: remaindRewardValue.toNumber(),
|
|
1953
|
-
claimedRewardAmount: claimedRewardAmount.toNumber(),
|
|
1954
|
-
claimedRewardCoin: claimedRewardCoin.toNumber(),
|
|
1955
|
-
claimedRewardValue: claimedRewardValue.toNumber(),
|
|
1956
|
-
rewardPerSec: rewardPerSec.toNumber()
|
|
1957
|
-
};
|
|
1958
|
-
};
|
|
1959
|
-
var parseOriginBorrowIncentivesPoolPointData = (originBorrowIncentivePoolPointData) => {
|
|
1960
|
-
return {
|
|
1961
|
-
pointType: (0, import_utils.normalizeStructTag)(
|
|
1962
|
-
originBorrowIncentivePoolPointData.point_type.name
|
|
1963
|
-
),
|
|
1964
|
-
distributedPointPerPeriod: Number(
|
|
1965
|
-
originBorrowIncentivePoolPointData.distributed_point_per_period
|
|
1966
|
-
),
|
|
1967
|
-
period: Number(originBorrowIncentivePoolPointData.point_distribution_time),
|
|
1968
|
-
distributedPoint: Number(
|
|
1969
|
-
originBorrowIncentivePoolPointData.distributed_point
|
|
1970
|
-
),
|
|
1971
|
-
points: Number(originBorrowIncentivePoolPointData.points),
|
|
1972
|
-
index: Number(originBorrowIncentivePoolPointData.index),
|
|
1973
|
-
baseWeight: Number(originBorrowIncentivePoolPointData.base_weight),
|
|
1974
|
-
weightedAmount: Number(originBorrowIncentivePoolPointData.weighted_amount),
|
|
1975
|
-
lastUpdate: Number(originBorrowIncentivePoolPointData.last_update)
|
|
1976
|
-
};
|
|
1977
1575
|
};
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1576
|
+
|
|
1577
|
+
// src/models/scallopAddress.ts
|
|
1578
|
+
var EMPTY_ADDRESSES = {
|
|
1579
|
+
core: {
|
|
1580
|
+
version: "",
|
|
1581
|
+
versionCap: "",
|
|
1582
|
+
object: "",
|
|
1583
|
+
market: "",
|
|
1584
|
+
adminCap: "",
|
|
1585
|
+
coinDecimalsRegistry: "",
|
|
1586
|
+
obligationAccessStore: "",
|
|
1587
|
+
coins: {
|
|
1588
|
+
cetus: {
|
|
1589
|
+
id: "",
|
|
1590
|
+
metaData: "",
|
|
1591
|
+
treasury: "",
|
|
1592
|
+
oracle: {
|
|
1593
|
+
supra: "",
|
|
1594
|
+
switchboard: "",
|
|
1595
|
+
pyth: {
|
|
1596
|
+
feed: "",
|
|
1597
|
+
feedObject: ""
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
},
|
|
1601
|
+
apt: {
|
|
1602
|
+
id: "",
|
|
1603
|
+
metaData: "",
|
|
1604
|
+
treasury: "",
|
|
1605
|
+
oracle: {
|
|
1606
|
+
supra: "",
|
|
1607
|
+
switchboard: "",
|
|
1608
|
+
pyth: {
|
|
1609
|
+
feed: "",
|
|
1610
|
+
feedObject: ""
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
},
|
|
1614
|
+
sol: {
|
|
1615
|
+
id: "",
|
|
1616
|
+
metaData: "",
|
|
1617
|
+
treasury: "",
|
|
1618
|
+
oracle: {
|
|
1619
|
+
supra: "",
|
|
1620
|
+
switchboard: "",
|
|
1621
|
+
pyth: {
|
|
1622
|
+
feed: "",
|
|
1623
|
+
feedObject: ""
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
},
|
|
1627
|
+
btc: {
|
|
1628
|
+
id: "",
|
|
1629
|
+
metaData: "",
|
|
1630
|
+
treasury: "",
|
|
1631
|
+
oracle: {
|
|
1632
|
+
supra: "",
|
|
1633
|
+
switchboard: "",
|
|
1634
|
+
pyth: {
|
|
1635
|
+
feed: "",
|
|
1636
|
+
feedObject: ""
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
},
|
|
1640
|
+
eth: {
|
|
1641
|
+
id: "",
|
|
1642
|
+
metaData: "",
|
|
1643
|
+
treasury: "",
|
|
1644
|
+
oracle: {
|
|
1645
|
+
supra: "",
|
|
1646
|
+
switchboard: "",
|
|
1647
|
+
pyth: {
|
|
1648
|
+
feed: "",
|
|
1649
|
+
feedObject: ""
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
},
|
|
1653
|
+
usdc: {
|
|
1654
|
+
id: "",
|
|
1655
|
+
metaData: "",
|
|
1656
|
+
treasury: "",
|
|
1657
|
+
oracle: {
|
|
1658
|
+
supra: "",
|
|
1659
|
+
switchboard: "",
|
|
1660
|
+
pyth: {
|
|
1661
|
+
feed: "",
|
|
1662
|
+
feedObject: ""
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
},
|
|
1666
|
+
usdt: {
|
|
1667
|
+
id: "",
|
|
1668
|
+
metaData: "",
|
|
1669
|
+
treasury: "",
|
|
1670
|
+
oracle: {
|
|
1671
|
+
supra: "",
|
|
1672
|
+
switchboard: "",
|
|
1673
|
+
pyth: {
|
|
1674
|
+
feed: "",
|
|
1675
|
+
feedObject: ""
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1993
1678
|
},
|
|
1994
|
-
{
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
1679
|
+
sui: {
|
|
1680
|
+
id: "",
|
|
1681
|
+
metaData: "",
|
|
1682
|
+
treasury: "",
|
|
1683
|
+
oracle: {
|
|
1684
|
+
supra: "",
|
|
1685
|
+
switchboard: "",
|
|
1686
|
+
pyth: {
|
|
1687
|
+
feed: "",
|
|
1688
|
+
feedObject: ""
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
},
|
|
1692
|
+
afsui: {
|
|
1693
|
+
id: "",
|
|
1694
|
+
metaData: "",
|
|
1695
|
+
treasury: "",
|
|
1696
|
+
oracle: {
|
|
1697
|
+
supra: "",
|
|
1698
|
+
switchboard: "",
|
|
1699
|
+
pyth: {
|
|
1700
|
+
feed: "",
|
|
1701
|
+
feedObject: ""
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
},
|
|
1705
|
+
hasui: {
|
|
1706
|
+
id: "",
|
|
1707
|
+
metaData: "",
|
|
1708
|
+
treasury: "",
|
|
1709
|
+
oracle: {
|
|
1710
|
+
supra: "",
|
|
1711
|
+
switchboard: "",
|
|
1712
|
+
pyth: {
|
|
1713
|
+
feed: "",
|
|
1714
|
+
feedObject: ""
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
},
|
|
1718
|
+
vsui: {
|
|
1719
|
+
id: "",
|
|
1720
|
+
metaData: "",
|
|
1721
|
+
treasury: "",
|
|
1722
|
+
oracle: {
|
|
1723
|
+
supra: "",
|
|
1724
|
+
switchboard: "",
|
|
1725
|
+
pyth: {
|
|
1726
|
+
feed: "",
|
|
1727
|
+
feedObject: ""
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
},
|
|
1731
|
+
sca: {
|
|
1732
|
+
id: "",
|
|
1733
|
+
metaData: "",
|
|
1734
|
+
treasury: "",
|
|
1735
|
+
oracle: {
|
|
1736
|
+
supra: "",
|
|
1737
|
+
switchboard: "",
|
|
1738
|
+
pyth: {
|
|
1739
|
+
feed: "",
|
|
1740
|
+
feedObject: ""
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
}
|
|
1744
|
+
},
|
|
1745
|
+
oracles: {
|
|
1746
|
+
xOracle: "",
|
|
1747
|
+
xOracleCap: "",
|
|
1748
|
+
supra: { registry: "", registryCap: "", holder: "" },
|
|
1749
|
+
switchboard: { registry: "", registryCap: "" },
|
|
1750
|
+
pyth: {
|
|
1751
|
+
registry: "",
|
|
1752
|
+
registryCap: "",
|
|
1753
|
+
state: "",
|
|
1754
|
+
wormhole: "",
|
|
1755
|
+
wormholeState: ""
|
|
1756
|
+
}
|
|
1757
|
+
},
|
|
1758
|
+
packages: {
|
|
1759
|
+
coinDecimalsRegistry: {
|
|
1760
|
+
id: "",
|
|
1761
|
+
upgradeCap: ""
|
|
1762
|
+
},
|
|
1763
|
+
math: {
|
|
1764
|
+
id: "",
|
|
1765
|
+
upgradeCap: ""
|
|
1766
|
+
},
|
|
1767
|
+
whitelist: {
|
|
1768
|
+
id: "",
|
|
1769
|
+
upgradeCap: ""
|
|
1770
|
+
},
|
|
1771
|
+
x: {
|
|
1772
|
+
id: "",
|
|
1773
|
+
upgradeCap: ""
|
|
1774
|
+
},
|
|
1775
|
+
protocol: {
|
|
1776
|
+
id: "",
|
|
1777
|
+
upgradeCap: ""
|
|
1778
|
+
},
|
|
1779
|
+
protocolWhitelist: {
|
|
1780
|
+
id: "",
|
|
1781
|
+
upgradeCap: ""
|
|
1782
|
+
},
|
|
1783
|
+
query: {
|
|
1784
|
+
id: "",
|
|
1785
|
+
upgradeCap: ""
|
|
1786
|
+
},
|
|
1787
|
+
supra: { id: "", upgradeCap: "" },
|
|
1788
|
+
pyth: {
|
|
1789
|
+
id: "",
|
|
1790
|
+
upgradeCap: ""
|
|
1791
|
+
},
|
|
1792
|
+
switchboard: { id: "", upgradeCap: "" },
|
|
1793
|
+
xOracle: {
|
|
1794
|
+
id: "",
|
|
1795
|
+
upgradeCap: ""
|
|
1796
|
+
},
|
|
1797
|
+
testCoin: { id: "", upgradeCap: "" }
|
|
1798
|
+
}
|
|
1799
|
+
},
|
|
1800
|
+
spool: {
|
|
1801
|
+
id: "",
|
|
1802
|
+
adminCap: "",
|
|
1803
|
+
object: "",
|
|
1804
|
+
pools: {
|
|
1805
|
+
seth: {
|
|
1806
|
+
id: "",
|
|
1807
|
+
rewardPoolId: ""
|
|
1808
|
+
},
|
|
1809
|
+
ssui: {
|
|
1810
|
+
id: "",
|
|
1811
|
+
rewardPoolId: ""
|
|
1812
|
+
},
|
|
1813
|
+
susdc: {
|
|
1814
|
+
id: "",
|
|
1815
|
+
rewardPoolId: ""
|
|
1816
|
+
},
|
|
1817
|
+
susdt: {
|
|
1818
|
+
id: "",
|
|
1819
|
+
rewardPoolId: ""
|
|
1820
|
+
},
|
|
1821
|
+
scetus: {
|
|
1822
|
+
id: "",
|
|
1823
|
+
rewardPoolId: ""
|
|
1824
|
+
},
|
|
1825
|
+
safsui: {
|
|
1826
|
+
id: "",
|
|
1827
|
+
rewardPoolId: ""
|
|
1828
|
+
},
|
|
1829
|
+
shasui: {
|
|
1830
|
+
id: "",
|
|
1831
|
+
rewardPoolId: ""
|
|
1832
|
+
},
|
|
1833
|
+
svsui: {
|
|
1834
|
+
id: "",
|
|
1835
|
+
rewardPoolId: ""
|
|
1836
|
+
}
|
|
1837
|
+
},
|
|
1838
|
+
config: ""
|
|
1839
|
+
},
|
|
1840
|
+
borrowIncentive: {
|
|
1841
|
+
id: "",
|
|
1842
|
+
adminCap: "",
|
|
1843
|
+
object: "",
|
|
1844
|
+
query: "",
|
|
1845
|
+
incentivePools: "",
|
|
1846
|
+
incentiveAccounts: "",
|
|
1847
|
+
config: ""
|
|
1848
|
+
},
|
|
1849
|
+
vesca: {
|
|
1850
|
+
id: "",
|
|
1851
|
+
object: "",
|
|
1852
|
+
adminCap: "",
|
|
1853
|
+
tableId: "",
|
|
1854
|
+
table: "",
|
|
1855
|
+
treasury: "",
|
|
1856
|
+
config: ""
|
|
1857
|
+
},
|
|
1858
|
+
referral: {
|
|
1859
|
+
id: "",
|
|
1860
|
+
version: "",
|
|
1861
|
+
object: "",
|
|
1862
|
+
adminCap: "",
|
|
1863
|
+
referralBindings: "",
|
|
1864
|
+
bindingTableId: "",
|
|
1865
|
+
referralRevenuePool: "",
|
|
1866
|
+
revenueTableId: "",
|
|
1867
|
+
referralTiers: "",
|
|
1868
|
+
tiersTableId: "",
|
|
1869
|
+
authorizedWitnessList: ""
|
|
1870
|
+
},
|
|
1871
|
+
loyaltyProgram: {
|
|
1872
|
+
id: "",
|
|
1873
|
+
object: "",
|
|
1874
|
+
rewardPool: "",
|
|
1875
|
+
userRewardTableId: ""
|
|
1876
|
+
},
|
|
1877
|
+
scoin: {
|
|
1878
|
+
id: "",
|
|
1879
|
+
coins: {
|
|
1880
|
+
ssui: {
|
|
1881
|
+
coinType: "",
|
|
1882
|
+
treasury: ""
|
|
2083
1883
|
},
|
|
2084
|
-
{
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
}
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
return coinName.charAt(0).toLowerCase() === "s" && COIN_SET.includes(assetCoinName);
|
|
1884
|
+
scetus: {
|
|
1885
|
+
coinType: "",
|
|
1886
|
+
treasury: ""
|
|
1887
|
+
},
|
|
1888
|
+
ssca: {
|
|
1889
|
+
coinType: "",
|
|
1890
|
+
treasury: ""
|
|
1891
|
+
},
|
|
1892
|
+
susdc: {
|
|
1893
|
+
coinType: "",
|
|
1894
|
+
treasury: ""
|
|
1895
|
+
},
|
|
1896
|
+
susdt: {
|
|
1897
|
+
coinType: "",
|
|
1898
|
+
treasury: ""
|
|
1899
|
+
},
|
|
1900
|
+
seth: {
|
|
1901
|
+
coinType: "",
|
|
1902
|
+
treasury: ""
|
|
1903
|
+
},
|
|
1904
|
+
safsui: {
|
|
1905
|
+
coinType: "",
|
|
1906
|
+
treasury: ""
|
|
1907
|
+
},
|
|
1908
|
+
shasui: {
|
|
1909
|
+
coinType: "",
|
|
1910
|
+
treasury: ""
|
|
1911
|
+
},
|
|
1912
|
+
svsui: {
|
|
1913
|
+
coinType: "",
|
|
1914
|
+
treasury: ""
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
2119
1918
|
};
|
|
2120
|
-
var
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
1919
|
+
var ScallopAddress = class {
|
|
1920
|
+
constructor(params, cache) {
|
|
1921
|
+
const { id, auth, network } = params;
|
|
1922
|
+
this._cache = cache ?? new ScallopCache(DEFAULT_CACHE_OPTIONS);
|
|
1923
|
+
this._requestClient = import_axios.default.create({
|
|
1924
|
+
baseURL: API_BASE_URL,
|
|
1925
|
+
headers: {
|
|
1926
|
+
"Content-Type": "application/json",
|
|
1927
|
+
Accept: "application/json"
|
|
1928
|
+
},
|
|
1929
|
+
timeout: 3e4
|
|
1930
|
+
});
|
|
1931
|
+
if (auth)
|
|
1932
|
+
this._auth = auth;
|
|
1933
|
+
this._id = id;
|
|
1934
|
+
this._network = network || "mainnet";
|
|
1935
|
+
this._addressesMap = USE_TEST_ADDRESS ? /* @__PURE__ */ new Map([["mainnet", TEST_ADDRESSES]]) : /* @__PURE__ */ new Map();
|
|
1936
|
+
if (USE_TEST_ADDRESS)
|
|
1937
|
+
this._currentAddresses = TEST_ADDRESSES;
|
|
1938
|
+
}
|
|
1939
|
+
/**
|
|
1940
|
+
* Get addresses API id.
|
|
1941
|
+
*
|
|
1942
|
+
* @return The addresses API id.
|
|
1943
|
+
*/
|
|
1944
|
+
getId() {
|
|
1945
|
+
return this._id || void 0;
|
|
1946
|
+
}
|
|
1947
|
+
/**
|
|
1948
|
+
* Get the address at the provided path.
|
|
1949
|
+
*
|
|
1950
|
+
* @param path - The path of the address to get.
|
|
1951
|
+
* @return The address at the provided path.
|
|
1952
|
+
*/
|
|
1953
|
+
get(path) {
|
|
1954
|
+
if (this._currentAddresses) {
|
|
1955
|
+
const value = path.split(".").reduce(
|
|
1956
|
+
(nestedAddressObj, key) => typeof nestedAddressObj === "object" ? nestedAddressObj[key] : nestedAddressObj,
|
|
1957
|
+
this._currentAddresses
|
|
1958
|
+
);
|
|
1959
|
+
return value || void 0;
|
|
1960
|
+
} else {
|
|
1961
|
+
return void 0;
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
/**
|
|
1965
|
+
* Sets the address for the specified path, it does not interact with the API.
|
|
1966
|
+
*
|
|
1967
|
+
* @param path - The path of the address to set.
|
|
1968
|
+
* @param address - The address be setted to the tartget path.
|
|
1969
|
+
* @return The addresses.
|
|
1970
|
+
*/
|
|
1971
|
+
set(path, address) {
|
|
1972
|
+
if (this._currentAddresses) {
|
|
1973
|
+
const keys = path.split(".");
|
|
1974
|
+
keys.reduce((nestedAddressObj, key, index) => {
|
|
1975
|
+
if (index === keys.length - 1) {
|
|
1976
|
+
nestedAddressObj[key] = address;
|
|
1977
|
+
} else {
|
|
1978
|
+
return nestedAddressObj[key];
|
|
1979
|
+
}
|
|
1980
|
+
}, this._currentAddresses);
|
|
1981
|
+
}
|
|
1982
|
+
return this._currentAddresses;
|
|
1983
|
+
}
|
|
1984
|
+
/**
|
|
1985
|
+
* Synchronize the specified network addresses from the addresses map to the
|
|
1986
|
+
* current addresses and change the default network to specified network.
|
|
1987
|
+
*
|
|
1988
|
+
* @param network - Specifies which network's addresses you want to get.
|
|
1989
|
+
* @return Current addresses.
|
|
1990
|
+
*/
|
|
1991
|
+
switchCurrentAddresses(network) {
|
|
1992
|
+
if (this._addressesMap.has(network)) {
|
|
1993
|
+
this._currentAddresses = this._addressesMap.get(network);
|
|
1994
|
+
this._network = network;
|
|
1995
|
+
}
|
|
1996
|
+
return this._currentAddresses;
|
|
1997
|
+
}
|
|
1998
|
+
/**
|
|
1999
|
+
* Get the addresses, If `network` is not provided, returns the current
|
|
2000
|
+
* addresses or the default network addresses in the addresses map.
|
|
2001
|
+
*
|
|
2002
|
+
* @param network - Specifies which network's addresses you want to get.
|
|
2003
|
+
*/
|
|
2004
|
+
getAddresses(network) {
|
|
2005
|
+
if (network) {
|
|
2006
|
+
return this._addressesMap.get(network);
|
|
2007
|
+
} else {
|
|
2008
|
+
return this._currentAddresses ?? this._addressesMap.get(this._network);
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* Set the addresses into addresses map. If the specified network is the same
|
|
2013
|
+
* as the current network, the current addresses will be updated at the same time.
|
|
2014
|
+
*
|
|
2015
|
+
* @param addresses - The addresses be setted to the tartget network.
|
|
2016
|
+
* @param network - Specifies which network's addresses you want to set.
|
|
2017
|
+
* @return The addresses.
|
|
2018
|
+
*/
|
|
2019
|
+
setAddresses(addresses, network) {
|
|
2020
|
+
const targetNetwork = network || this._network;
|
|
2021
|
+
if (targetNetwork === this._network)
|
|
2022
|
+
this._currentAddresses = addresses;
|
|
2023
|
+
this._addressesMap.set(targetNetwork, addresses);
|
|
2024
|
+
}
|
|
2025
|
+
/**
|
|
2026
|
+
* Get all addresses.
|
|
2027
|
+
*
|
|
2028
|
+
* @return All addresses.
|
|
2029
|
+
*/
|
|
2030
|
+
getAllAddresses() {
|
|
2031
|
+
return Object.fromEntries(this._addressesMap);
|
|
2032
|
+
}
|
|
2033
|
+
/**
|
|
2034
|
+
* Create a new addresses through the API and synchronize it back to the
|
|
2035
|
+
* instance.
|
|
2036
|
+
*
|
|
2037
|
+
* @description
|
|
2038
|
+
* If the `network` is not specified, the mainnet is used by default.
|
|
2039
|
+
* If no `addresses` from instance or parameter is provided, an addresses with
|
|
2040
|
+
* all empty strings is created by default.
|
|
2041
|
+
*
|
|
2042
|
+
* This function only allows for one addresses to be input into a specific network
|
|
2043
|
+
* at a time, and does not provide an addresses map for setting addresses
|
|
2044
|
+
* across all networks at once.
|
|
2045
|
+
*
|
|
2046
|
+
* @param params.addresses - The addresses be setted to the tartget network.
|
|
2047
|
+
* @param params.network - Specifies which network's addresses you want to set.
|
|
2048
|
+
* @param params.auth - The authentication API key.
|
|
2049
|
+
* @param params.memo - Add memo to the addresses created in the API.
|
|
2050
|
+
* @return All addresses.
|
|
2051
|
+
*/
|
|
2052
|
+
async create(params) {
|
|
2053
|
+
const { addresses, network, auth, memo } = params ?? {};
|
|
2054
|
+
const apiKey = auth || this._auth || void 0;
|
|
2055
|
+
const targetNetwork = network || this._network;
|
|
2056
|
+
const targetAddresses = addresses || this._currentAddresses || this._addressesMap.get(targetNetwork) || EMPTY_ADDRESSES;
|
|
2057
|
+
if (apiKey !== void 0) {
|
|
2058
|
+
this._addressesMap.clear();
|
|
2059
|
+
this.setAddresses(targetAddresses, targetNetwork);
|
|
2060
|
+
const response = await this._requestClient.post(
|
|
2061
|
+
`/addresses`,
|
|
2062
|
+
JSON.stringify({ ...Object.fromEntries(this._addressesMap), memo }),
|
|
2063
|
+
{
|
|
2064
|
+
headers: {
|
|
2065
|
+
"Content-Type": "application/json",
|
|
2066
|
+
"api-key": auth || this._auth
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
);
|
|
2070
|
+
if (response.status === 201) {
|
|
2071
|
+
for (const [network2, addresses2] of Object.entries(
|
|
2072
|
+
response.data
|
|
2073
|
+
)) {
|
|
2074
|
+
if (["localnet", "devnet", "testnet", "mainnet"].includes(network2)) {
|
|
2075
|
+
if (network2 === this._network)
|
|
2076
|
+
this._currentAddresses = addresses2;
|
|
2077
|
+
this._addressesMap.set(network2, addresses2);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
this._id = response.data.id;
|
|
2081
|
+
return this.getAllAddresses();
|
|
2082
|
+
} else {
|
|
2083
|
+
throw Error("Failed to create addresses.");
|
|
2084
|
+
}
|
|
2085
|
+
} else {
|
|
2086
|
+
throw Error("You don't have permission to access this request.");
|
|
2087
|
+
}
|
|
2130
2088
|
}
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
const
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2089
|
+
/**
|
|
2090
|
+
* Read and synchronizes all addresses from the API into instance.
|
|
2091
|
+
*
|
|
2092
|
+
* @param id - The id of the addresses to get.
|
|
2093
|
+
* @return All addresses.
|
|
2094
|
+
*/
|
|
2095
|
+
async read(id) {
|
|
2096
|
+
const addressesId = id || this._id || void 0;
|
|
2097
|
+
if (addressesId !== void 0) {
|
|
2098
|
+
const response = await this._cache.queryClient.fetchQuery({
|
|
2099
|
+
queryKey: ["api-getAddresses", addressesId],
|
|
2100
|
+
queryFn: async () => {
|
|
2101
|
+
return await this._requestClient.get(`/addresses/${addressesId}`, {
|
|
2102
|
+
headers: {
|
|
2103
|
+
"Content-Type": "application/json"
|
|
2104
|
+
}
|
|
2105
|
+
});
|
|
2106
|
+
}
|
|
2107
|
+
});
|
|
2108
|
+
if (response.status === 200) {
|
|
2109
|
+
for (const [network, addresses] of Object.entries(
|
|
2110
|
+
response.data
|
|
2111
|
+
)) {
|
|
2112
|
+
if (["localnet", "devnet", "testnet", "mainnet"].includes(network)) {
|
|
2113
|
+
if (network === this._network)
|
|
2114
|
+
this._currentAddresses = addresses;
|
|
2115
|
+
this._addressesMap.set(network, addresses);
|
|
2116
|
+
}
|
|
2117
|
+
}
|
|
2118
|
+
this._id = response.data.id;
|
|
2119
|
+
return this.getAllAddresses();
|
|
2120
|
+
} else {
|
|
2121
|
+
throw Error("Failed to create addresses.");
|
|
2122
|
+
}
|
|
2123
|
+
} else {
|
|
2124
|
+
throw Error("Please provide API addresses id.");
|
|
2125
|
+
}
|
|
2146
2126
|
}
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2127
|
+
/**
|
|
2128
|
+
* Update the addresses through the API and synchronize it back to the
|
|
2129
|
+
* instance.
|
|
2130
|
+
*
|
|
2131
|
+
* @description
|
|
2132
|
+
* If the `network` is not specified, the mainnet is used by default.
|
|
2133
|
+
* If no `addresses` from instance or parameter is provided, an addresses with
|
|
2134
|
+
* all empty strings is created by default.
|
|
2135
|
+
*
|
|
2136
|
+
* This function only allows for one addresses to be input into a specific network
|
|
2137
|
+
* at a time, and does not provide an addresses map for setting addresses
|
|
2138
|
+
* across all networks at once.
|
|
2139
|
+
*
|
|
2140
|
+
* @param params.id - The id of the addresses to update.
|
|
2141
|
+
* @param params.addresses - The addresses be setted to the tartget network.
|
|
2142
|
+
* @param params.network - Specifies which network's addresses you want to set.
|
|
2143
|
+
* @param params.auth - The authentication api key.
|
|
2144
|
+
* @param params.memo - Add memo to the addresses created in the API.
|
|
2145
|
+
* @return All addresses.
|
|
2146
|
+
*/
|
|
2147
|
+
async update(params) {
|
|
2148
|
+
const { id, addresses, network, auth, memo } = params ?? {};
|
|
2149
|
+
const apiKey = auth || this._auth || void 0;
|
|
2150
|
+
const targetId = id || this._id || void 0;
|
|
2151
|
+
const targetNetwork = network || this._network;
|
|
2152
|
+
const targetAddresses = addresses || this._currentAddresses || this._addressesMap.get(targetNetwork) || EMPTY_ADDRESSES;
|
|
2153
|
+
if (targetId === void 0)
|
|
2154
|
+
throw Error("Require specific addresses id to be updated.");
|
|
2155
|
+
if (apiKey !== void 0) {
|
|
2156
|
+
if (id !== this._id) {
|
|
2157
|
+
this._addressesMap.clear();
|
|
2158
|
+
}
|
|
2159
|
+
this.setAddresses(targetAddresses, targetNetwork);
|
|
2160
|
+
const response = await this._requestClient.put(
|
|
2161
|
+
`/addresses/${targetId}`,
|
|
2162
|
+
JSON.stringify({ ...Object.fromEntries(this._addressesMap), memo }),
|
|
2163
|
+
{
|
|
2164
|
+
headers: {
|
|
2165
|
+
"Content-Type": "application/json",
|
|
2166
|
+
"api-key": auth || this._auth
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
);
|
|
2170
|
+
if (response.status === 200) {
|
|
2171
|
+
for (const [network2, addresses2] of Object.entries(
|
|
2172
|
+
response.data
|
|
2173
|
+
)) {
|
|
2174
|
+
if (["localnet", "devnet", "testnet", "mainnet"].includes(network2)) {
|
|
2175
|
+
if (network2 === this._network)
|
|
2176
|
+
this._currentAddresses = addresses2;
|
|
2177
|
+
this._addressesMap.set(network2, addresses2);
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
this._id = response.data.id;
|
|
2181
|
+
return this.getAllAddresses();
|
|
2182
|
+
} else {
|
|
2183
|
+
throw Error("Failed to update addresses.");
|
|
2184
|
+
}
|
|
2185
|
+
} else {
|
|
2186
|
+
throw Error("You don't have permission to access this request.");
|
|
2187
|
+
}
|
|
2154
2188
|
}
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2189
|
+
/**
|
|
2190
|
+
* Deletes all addresses of a specified id through the API and clear all
|
|
2191
|
+
* addresses in the instance.
|
|
2192
|
+
*
|
|
2193
|
+
* @param id - The id of the addresses to delete.
|
|
2194
|
+
* @param auth - The authentication API key.
|
|
2195
|
+
*/
|
|
2196
|
+
async delete(id, auth) {
|
|
2197
|
+
const apiKey = auth || this._auth || void 0;
|
|
2198
|
+
const targetId = id || this._id || void 0;
|
|
2199
|
+
if (targetId === void 0)
|
|
2200
|
+
throw Error("Require specific addresses id to be deleted.");
|
|
2201
|
+
if (apiKey !== void 0) {
|
|
2202
|
+
const response = await this._requestClient.delete(
|
|
2203
|
+
`/addresses/${targetId}`,
|
|
2204
|
+
{
|
|
2205
|
+
headers: {
|
|
2206
|
+
"Content-Type": "application/json",
|
|
2207
|
+
"api-key": auth || this._auth
|
|
2208
|
+
}
|
|
2209
|
+
}
|
|
2210
|
+
);
|
|
2211
|
+
if (response.status === 200) {
|
|
2212
|
+
this._id = void 0;
|
|
2213
|
+
this._currentAddresses = void 0;
|
|
2214
|
+
this._addressesMap.clear();
|
|
2215
|
+
} else {
|
|
2216
|
+
throw Error("Failed to delete addresses.");
|
|
2217
|
+
}
|
|
2218
|
+
} else {
|
|
2219
|
+
throw Error("You don't have permission to access this request.");
|
|
2220
|
+
}
|
|
2158
2221
|
}
|
|
2159
|
-
return Math.floor(closestTwelveAM.getTime() / 1e3);
|
|
2160
2222
|
};
|
|
2161
2223
|
|
|
2224
|
+
// src/models/scallopClient.ts
|
|
2225
|
+
var import_utils25 = require("@mysten/sui.js/utils");
|
|
2226
|
+
var import_sui_kit13 = require("@scallop-io/sui-kit");
|
|
2227
|
+
|
|
2228
|
+
// src/models/scallopUtils.ts
|
|
2229
|
+
var import_utils11 = require("@mysten/sui.js/utils");
|
|
2230
|
+
var import_sui_kit4 = require("@scallop-io/sui-kit");
|
|
2231
|
+
var import_pyth_sui_js = require("@pythnetwork/pyth-sui-js");
|
|
2232
|
+
|
|
2233
|
+
// src/models/scallopQuery.ts
|
|
2234
|
+
var import_sui_kit3 = require("@scallop-io/sui-kit");
|
|
2235
|
+
|
|
2162
2236
|
// src/queries/coreQuery.ts
|
|
2237
|
+
var import_utils3 = require("@mysten/sui.js/utils");
|
|
2163
2238
|
var import_bignumber2 = __toESM(require("bignumber.js"));
|
|
2164
2239
|
var queryMarket = async (query, indexer = false) => {
|
|
2165
2240
|
const coinPrices = await query.utils.getCoinPrices();
|
|
@@ -2187,9 +2262,9 @@ var queryMarket = async (query, indexer = false) => {
|
|
|
2187
2262
|
const queryTarget = `${packageId}::market_query::market_data`;
|
|
2188
2263
|
const args = [marketId];
|
|
2189
2264
|
const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
|
|
2190
|
-
const marketData = queryResult
|
|
2191
|
-
for (const pool of marketData
|
|
2192
|
-
const coinType = (0,
|
|
2265
|
+
const marketData = queryResult?.events[0].parsedJson;
|
|
2266
|
+
for (const pool of marketData?.pools ?? []) {
|
|
2267
|
+
const coinType = (0, import_utils3.normalizeStructTag)(pool.type.name);
|
|
2193
2268
|
const poolCoinName = query.utils.parseCoinNameFromType(coinType);
|
|
2194
2269
|
const coinPrice = coinPrices[poolCoinName] ?? 0;
|
|
2195
2270
|
if (!SUPPORT_POOLS.includes(poolCoinName)) {
|
|
@@ -2238,8 +2313,8 @@ var queryMarket = async (query, indexer = false) => {
|
|
|
2238
2313
|
...calculatedMarketPoolData
|
|
2239
2314
|
};
|
|
2240
2315
|
}
|
|
2241
|
-
for (const collateral of marketData
|
|
2242
|
-
const coinType = (0,
|
|
2316
|
+
for (const collateral of marketData?.collaterals ?? []) {
|
|
2317
|
+
const coinType = (0, import_utils3.normalizeStructTag)(collateral.type.name);
|
|
2243
2318
|
const collateralCoinName = query.utils.parseCoinNameFromType(coinType);
|
|
2244
2319
|
const coinPrice = coinPrices[collateralCoinName] ?? 0;
|
|
2245
2320
|
if (!SUPPORT_COLLATERALS.includes(collateralCoinName)) {
|
|
@@ -2308,7 +2383,7 @@ var getMarketPools = async (query, poolCoinNames, indexer = false) => {
|
|
|
2308
2383
|
query,
|
|
2309
2384
|
poolCoinName,
|
|
2310
2385
|
indexer,
|
|
2311
|
-
marketObjectResponse
|
|
2386
|
+
marketObjectResponse?.data,
|
|
2312
2387
|
coinPrices?.[poolCoinName]
|
|
2313
2388
|
);
|
|
2314
2389
|
if (marketPool) {
|
|
@@ -2335,7 +2410,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2335
2410
|
const marketId = query.address.get("core.market");
|
|
2336
2411
|
marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
|
|
2337
2412
|
showContent: true
|
|
2338
|
-
}))
|
|
2413
|
+
}))?.data;
|
|
2339
2414
|
coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
|
|
2340
2415
|
if (marketObject) {
|
|
2341
2416
|
if (marketObject.content && "fields" in marketObject.content) {
|
|
@@ -2351,6 +2426,8 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2351
2426
|
}
|
|
2352
2427
|
}
|
|
2353
2428
|
});
|
|
2429
|
+
if (!balanceSheetDynamicFieldObjectResponse)
|
|
2430
|
+
return void 0;
|
|
2354
2431
|
const balanceSheetDynamicFieldObject = balanceSheetDynamicFieldObjectResponse.data;
|
|
2355
2432
|
if (balanceSheetDynamicFieldObject && balanceSheetDynamicFieldObject.content && "fields" in balanceSheetDynamicFieldObject.content) {
|
|
2356
2433
|
const dynamicFields = balanceSheetDynamicFieldObject.content.fields;
|
|
@@ -2366,6 +2443,8 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2366
2443
|
}
|
|
2367
2444
|
}
|
|
2368
2445
|
});
|
|
2446
|
+
if (!borrowIndexDynamicFieldObjectResponse)
|
|
2447
|
+
return void 0;
|
|
2369
2448
|
const borrowIndexDynamicFieldObject = borrowIndexDynamicFieldObjectResponse.data;
|
|
2370
2449
|
if (borrowIndexDynamicFieldObject && borrowIndexDynamicFieldObject.content && "fields" in borrowIndexDynamicFieldObject.content) {
|
|
2371
2450
|
const dynamicFields = borrowIndexDynamicFieldObject.content.fields;
|
|
@@ -2381,6 +2460,8 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2381
2460
|
}
|
|
2382
2461
|
}
|
|
2383
2462
|
});
|
|
2463
|
+
if (!interestModelDynamicFieldObjectResponse)
|
|
2464
|
+
return void 0;
|
|
2384
2465
|
const interestModelDynamicFieldObject = interestModelDynamicFieldObjectResponse.data;
|
|
2385
2466
|
if (interestModelDynamicFieldObject && interestModelDynamicFieldObject.content && "fields" in interestModelDynamicFieldObject.content) {
|
|
2386
2467
|
const dynamicFields = interestModelDynamicFieldObject.content.fields;
|
|
@@ -2397,6 +2478,8 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2397
2478
|
}
|
|
2398
2479
|
}
|
|
2399
2480
|
});
|
|
2481
|
+
if (!borrowFeeDynamicFieldObjectResponse)
|
|
2482
|
+
return void 0;
|
|
2400
2483
|
const borrowFeeDynamicFieldObject = borrowFeeDynamicFieldObjectResponse.data;
|
|
2401
2484
|
if (borrowFeeDynamicFieldObject && borrowFeeDynamicFieldObject.content && "fields" in borrowFeeDynamicFieldObject.content) {
|
|
2402
2485
|
const dynamicFields = borrowFeeDynamicFieldObject.content.fields;
|
|
@@ -2479,7 +2562,7 @@ var getMarketCollaterals = async (query, collateralCoinNames, indexer = false) =
|
|
|
2479
2562
|
query,
|
|
2480
2563
|
collateralCoinName,
|
|
2481
2564
|
indexer,
|
|
2482
|
-
marketObjectResponse
|
|
2565
|
+
marketObjectResponse?.data,
|
|
2483
2566
|
coinPrices?.[collateralCoinName]
|
|
2484
2567
|
);
|
|
2485
2568
|
if (marketCollateral) {
|
|
@@ -2504,7 +2587,7 @@ var getMarketCollateral = async (query, collateralCoinName, indexer = false, mar
|
|
|
2504
2587
|
const marketId = query.address.get("core.market");
|
|
2505
2588
|
marketObject = marketObject || (await query.cache.queryGetObject(marketId, {
|
|
2506
2589
|
showContent: true
|
|
2507
|
-
}))
|
|
2590
|
+
}))?.data;
|
|
2508
2591
|
coinPrice = coinPrice || (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName];
|
|
2509
2592
|
if (marketObject) {
|
|
2510
2593
|
if (marketObject.content && "fields" in marketObject.content) {
|
|
@@ -2520,6 +2603,8 @@ var getMarketCollateral = async (query, collateralCoinName, indexer = false, mar
|
|
|
2520
2603
|
}
|
|
2521
2604
|
}
|
|
2522
2605
|
});
|
|
2606
|
+
if (!riskModelDynamicFieldObjectResponse)
|
|
2607
|
+
return void 0;
|
|
2523
2608
|
const riskModelDynamicFieldObject = riskModelDynamicFieldObjectResponse.data;
|
|
2524
2609
|
if (riskModelDynamicFieldObject && riskModelDynamicFieldObject.content && "fields" in riskModelDynamicFieldObject.content) {
|
|
2525
2610
|
const dynamicFields = riskModelDynamicFieldObject.content.fields;
|
|
@@ -2535,6 +2620,8 @@ var getMarketCollateral = async (query, collateralCoinName, indexer = false, mar
|
|
|
2535
2620
|
}
|
|
2536
2621
|
}
|
|
2537
2622
|
});
|
|
2623
|
+
if (!collateralStatDynamicFieldObjectResponse)
|
|
2624
|
+
return void 0;
|
|
2538
2625
|
const collateralStatDynamicFieldObject = collateralStatDynamicFieldObjectResponse.data;
|
|
2539
2626
|
if (collateralStatDynamicFieldObject && collateralStatDynamicFieldObject.content && "fields" in collateralStatDynamicFieldObject.content) {
|
|
2540
2627
|
const dynamicFields = collateralStatDynamicFieldObject.content.fields;
|
|
@@ -2589,6 +2676,8 @@ var getObligations = async (query, ownerAddress) => {
|
|
|
2589
2676
|
},
|
|
2590
2677
|
cursor: nextCursor
|
|
2591
2678
|
});
|
|
2679
|
+
if (!paginatedKeyObjectsResponse)
|
|
2680
|
+
continue;
|
|
2592
2681
|
keyObjectsResponse.push(...paginatedKeyObjectsResponse.data);
|
|
2593
2682
|
if (paginatedKeyObjectsResponse.hasNextPage && paginatedKeyObjectsResponse.nextCursor) {
|
|
2594
2683
|
hasNextPage = true;
|
|
@@ -2619,7 +2708,7 @@ var getObligationLocked = async (query, obligationId) => {
|
|
|
2619
2708
|
{ showContent: true }
|
|
2620
2709
|
);
|
|
2621
2710
|
let obligationLocked = false;
|
|
2622
|
-
if (obligationObjectResponse
|
|
2711
|
+
if (obligationObjectResponse?.data && obligationObjectResponse?.data?.content?.dataType === "moveObject" && "lock_key" in obligationObjectResponse.data.content.fields) {
|
|
2623
2712
|
obligationLocked = Boolean(
|
|
2624
2713
|
obligationObjectResponse.data.content.fields.lock_key
|
|
2625
2714
|
);
|
|
@@ -2634,7 +2723,7 @@ var queryObligation = async (query, obligationId) => {
|
|
|
2634
2723
|
{ queryTarget, args }
|
|
2635
2724
|
// txBlock
|
|
2636
2725
|
);
|
|
2637
|
-
return queryResult
|
|
2726
|
+
return queryResult?.events[0].parsedJson;
|
|
2638
2727
|
};
|
|
2639
2728
|
var getCoinAmounts = async (query, assetCoinNames, ownerAddress) => {
|
|
2640
2729
|
assetCoinNames = assetCoinNames || [...SUPPORT_POOLS];
|
|
@@ -2711,7 +2800,7 @@ var getFlashLoanFees = async (query, assetNames) => {
|
|
|
2711
2800
|
const marketObjectRes = await query.cache.queryGetObject(marketObjectId, {
|
|
2712
2801
|
showContent: true
|
|
2713
2802
|
});
|
|
2714
|
-
if (marketObjectRes
|
|
2803
|
+
if (marketObjectRes?.data?.content?.dataType !== "moveObject")
|
|
2715
2804
|
throw new Error("Failed to get market object");
|
|
2716
2805
|
const vault = marketObjectRes.data.content.fields.vault;
|
|
2717
2806
|
const flashloanFeesTableId = vault.fields.flash_loan_fees.fields.table.fields.id.id;
|
|
@@ -2719,10 +2808,10 @@ var getFlashLoanFees = async (query, assetNames) => {
|
|
|
2719
2808
|
parentId: flashloanFeesTableId,
|
|
2720
2809
|
limit: 50
|
|
2721
2810
|
});
|
|
2722
|
-
const dynamicFieldObjectIds = balanceSheetDynamicFields
|
|
2811
|
+
const dynamicFieldObjectIds = balanceSheetDynamicFields?.data.filter((field) => {
|
|
2723
2812
|
const assetType = field.name.value.name;
|
|
2724
2813
|
return !!assetTypeMap[assetType];
|
|
2725
|
-
}).map((field) => field.objectId);
|
|
2814
|
+
}).map((field) => field.objectId) ?? [];
|
|
2726
2815
|
flashloanFeeObjects.push(
|
|
2727
2816
|
...await query.cache.queryGetObjects(dynamicFieldObjectIds, {
|
|
2728
2817
|
showContent: true
|
|
@@ -2744,7 +2833,7 @@ var getFlashLoanFees = async (query, assetNames) => {
|
|
|
2744
2833
|
};
|
|
2745
2834
|
|
|
2746
2835
|
// src/queries/spoolQuery.ts
|
|
2747
|
-
var
|
|
2836
|
+
var import_utils5 = require("@mysten/sui.js/utils");
|
|
2748
2837
|
var getSpools = async (query, stakeMarketCoinNames, indexer = false) => {
|
|
2749
2838
|
stakeMarketCoinNames = stakeMarketCoinNames || [...SUPPORT_SPOOLS];
|
|
2750
2839
|
const stakeCoinNames = stakeMarketCoinNames.map(
|
|
@@ -2901,6 +2990,8 @@ var getStakeAccounts = async (query, ownerAddress) => {
|
|
|
2901
2990
|
},
|
|
2902
2991
|
cursor: nextCursor
|
|
2903
2992
|
});
|
|
2993
|
+
if (!paginatedStakeObjectsResponse)
|
|
2994
|
+
continue;
|
|
2904
2995
|
stakeObjectsResponse.push(...paginatedStakeObjectsResponse.data);
|
|
2905
2996
|
if (paginatedStakeObjectsResponse.hasNextPage && paginatedStakeObjectsResponse.nextCursor) {
|
|
2906
2997
|
hasNextPage = true;
|
|
@@ -2942,89 +3033,89 @@ var getStakeAccounts = async (query, ownerAddress) => {
|
|
|
2942
3033
|
const index = Number(fields.index);
|
|
2943
3034
|
const points = Number(fields.points);
|
|
2944
3035
|
const totalPoints = Number(fields.total_points);
|
|
2945
|
-
if ((0,
|
|
3036
|
+
if ((0, import_utils5.normalizeStructTag)(type) === stakeMarketCoinTypes.seth) {
|
|
2946
3037
|
stakeAccounts.seth.push({
|
|
2947
3038
|
id,
|
|
2948
|
-
type: (0,
|
|
3039
|
+
type: (0, import_utils5.normalizeStructTag)(type),
|
|
2949
3040
|
stakePoolId,
|
|
2950
|
-
stakeType: (0,
|
|
3041
|
+
stakeType: (0, import_utils5.normalizeStructTag)(stakeType),
|
|
2951
3042
|
staked,
|
|
2952
3043
|
index,
|
|
2953
3044
|
points,
|
|
2954
3045
|
totalPoints
|
|
2955
3046
|
});
|
|
2956
|
-
} else if ((0,
|
|
3047
|
+
} else if ((0, import_utils5.normalizeStructTag)(type) === stakeMarketCoinTypes.ssui) {
|
|
2957
3048
|
stakeAccounts.ssui.push({
|
|
2958
3049
|
id,
|
|
2959
|
-
type: (0,
|
|
3050
|
+
type: (0, import_utils5.normalizeStructTag)(type),
|
|
2960
3051
|
stakePoolId,
|
|
2961
|
-
stakeType: (0,
|
|
3052
|
+
stakeType: (0, import_utils5.normalizeStructTag)(stakeType),
|
|
2962
3053
|
staked,
|
|
2963
3054
|
index,
|
|
2964
3055
|
points,
|
|
2965
3056
|
totalPoints
|
|
2966
3057
|
});
|
|
2967
|
-
} else if ((0,
|
|
3058
|
+
} else if ((0, import_utils5.normalizeStructTag)(type) === stakeMarketCoinTypes.susdc) {
|
|
2968
3059
|
stakeAccounts.susdc.push({
|
|
2969
3060
|
id,
|
|
2970
|
-
type: (0,
|
|
3061
|
+
type: (0, import_utils5.normalizeStructTag)(type),
|
|
2971
3062
|
stakePoolId,
|
|
2972
|
-
stakeType: (0,
|
|
3063
|
+
stakeType: (0, import_utils5.normalizeStructTag)(stakeType),
|
|
2973
3064
|
staked,
|
|
2974
3065
|
index,
|
|
2975
3066
|
points,
|
|
2976
3067
|
totalPoints
|
|
2977
3068
|
});
|
|
2978
|
-
} else if ((0,
|
|
3069
|
+
} else if ((0, import_utils5.normalizeStructTag)(type) === stakeMarketCoinTypes.susdt) {
|
|
2979
3070
|
stakeAccounts.susdt.push({
|
|
2980
3071
|
id,
|
|
2981
|
-
type: (0,
|
|
3072
|
+
type: (0, import_utils5.normalizeStructTag)(type),
|
|
2982
3073
|
stakePoolId,
|
|
2983
|
-
stakeType: (0,
|
|
3074
|
+
stakeType: (0, import_utils5.normalizeStructTag)(stakeType),
|
|
2984
3075
|
staked,
|
|
2985
3076
|
index,
|
|
2986
3077
|
points,
|
|
2987
3078
|
totalPoints
|
|
2988
3079
|
});
|
|
2989
|
-
} else if ((0,
|
|
3080
|
+
} else if ((0, import_utils5.normalizeStructTag)(type) === stakeMarketCoinTypes.scetus) {
|
|
2990
3081
|
stakeAccounts.scetus.push({
|
|
2991
3082
|
id,
|
|
2992
|
-
type: (0,
|
|
3083
|
+
type: (0, import_utils5.normalizeStructTag)(type),
|
|
2993
3084
|
stakePoolId,
|
|
2994
|
-
stakeType: (0,
|
|
3085
|
+
stakeType: (0, import_utils5.normalizeStructTag)(stakeType),
|
|
2995
3086
|
staked,
|
|
2996
3087
|
index,
|
|
2997
3088
|
points,
|
|
2998
3089
|
totalPoints
|
|
2999
3090
|
});
|
|
3000
|
-
} else if ((0,
|
|
3091
|
+
} else if ((0, import_utils5.normalizeStructTag)(type) === stakeMarketCoinTypes.safsui) {
|
|
3001
3092
|
stakeAccounts.safsui.push({
|
|
3002
3093
|
id,
|
|
3003
|
-
type: (0,
|
|
3094
|
+
type: (0, import_utils5.normalizeStructTag)(type),
|
|
3004
3095
|
stakePoolId,
|
|
3005
|
-
stakeType: (0,
|
|
3096
|
+
stakeType: (0, import_utils5.normalizeStructTag)(stakeType),
|
|
3006
3097
|
staked,
|
|
3007
3098
|
index,
|
|
3008
3099
|
points,
|
|
3009
3100
|
totalPoints
|
|
3010
3101
|
});
|
|
3011
|
-
} else if ((0,
|
|
3102
|
+
} else if ((0, import_utils5.normalizeStructTag)(type) === stakeMarketCoinTypes.shasui) {
|
|
3012
3103
|
stakeAccounts.shasui.push({
|
|
3013
3104
|
id,
|
|
3014
|
-
type: (0,
|
|
3105
|
+
type: (0, import_utils5.normalizeStructTag)(type),
|
|
3015
3106
|
stakePoolId,
|
|
3016
|
-
stakeType: (0,
|
|
3107
|
+
stakeType: (0, import_utils5.normalizeStructTag)(stakeType),
|
|
3017
3108
|
staked,
|
|
3018
3109
|
index,
|
|
3019
3110
|
points,
|
|
3020
3111
|
totalPoints
|
|
3021
3112
|
});
|
|
3022
|
-
} else if ((0,
|
|
3113
|
+
} else if ((0, import_utils5.normalizeStructTag)(type) === stakeMarketCoinTypes.svsui) {
|
|
3023
3114
|
stakeAccounts.svsui.push({
|
|
3024
3115
|
id,
|
|
3025
|
-
type: (0,
|
|
3116
|
+
type: (0, import_utils5.normalizeStructTag)(type),
|
|
3026
3117
|
stakePoolId,
|
|
3027
|
-
stakeType: (0,
|
|
3118
|
+
stakeType: (0, import_utils5.normalizeStructTag)(stakeType),
|
|
3028
3119
|
staked,
|
|
3029
3120
|
index,
|
|
3030
3121
|
points,
|
|
@@ -3042,7 +3133,7 @@ var getStakePool = async (query, marketCoinName) => {
|
|
|
3042
3133
|
showContent: true,
|
|
3043
3134
|
showType: true
|
|
3044
3135
|
});
|
|
3045
|
-
if (stakePoolObjectResponse
|
|
3136
|
+
if (stakePoolObjectResponse?.data) {
|
|
3046
3137
|
const stakePoolObject = stakePoolObjectResponse.data;
|
|
3047
3138
|
const id = stakePoolObject.objectId;
|
|
3048
3139
|
const type = stakePoolObject.type;
|
|
@@ -3060,13 +3151,13 @@ var getStakePool = async (query, marketCoinName) => {
|
|
|
3060
3151
|
const lastUpdate = Number(fields.last_update);
|
|
3061
3152
|
stakePool = {
|
|
3062
3153
|
id,
|
|
3063
|
-
type: (0,
|
|
3154
|
+
type: (0, import_utils5.normalizeStructTag)(type),
|
|
3064
3155
|
maxPoint,
|
|
3065
3156
|
distributedPoint,
|
|
3066
3157
|
pointPerPeriod,
|
|
3067
3158
|
period,
|
|
3068
3159
|
maxStake,
|
|
3069
|
-
stakeType: (0,
|
|
3160
|
+
stakeType: (0, import_utils5.normalizeStructTag)(stakeType),
|
|
3070
3161
|
totalStaked,
|
|
3071
3162
|
index,
|
|
3072
3163
|
createdAt,
|
|
@@ -3088,7 +3179,7 @@ var getStakeRewardPool = async (query, marketCoinName) => {
|
|
|
3088
3179
|
showType: true
|
|
3089
3180
|
}
|
|
3090
3181
|
);
|
|
3091
|
-
if (stakeRewardPoolObjectResponse
|
|
3182
|
+
if (stakeRewardPoolObjectResponse?.data) {
|
|
3092
3183
|
const stakeRewardPoolObject = stakeRewardPoolObjectResponse.data;
|
|
3093
3184
|
const id = stakeRewardPoolObject.objectId;
|
|
3094
3185
|
const type = stakeRewardPoolObject.type;
|
|
@@ -3103,7 +3194,7 @@ var getStakeRewardPool = async (query, marketCoinName) => {
|
|
|
3103
3194
|
const claimedRewards = Number(rewardPoolFields.claimed_rewards);
|
|
3104
3195
|
stakeRewardPool = {
|
|
3105
3196
|
id,
|
|
3106
|
-
type: (0,
|
|
3197
|
+
type: (0, import_utils5.normalizeStructTag)(type),
|
|
3107
3198
|
stakePoolId,
|
|
3108
3199
|
ratioNumerator,
|
|
3109
3200
|
ratioDenominator,
|
|
@@ -3116,7 +3207,7 @@ var getStakeRewardPool = async (query, marketCoinName) => {
|
|
|
3116
3207
|
};
|
|
3117
3208
|
|
|
3118
3209
|
// src/queries/borrowIncentiveQuery.ts
|
|
3119
|
-
var
|
|
3210
|
+
var import_utils7 = require("@mysten/sui.js/utils");
|
|
3120
3211
|
var import_bignumber3 = __toESM(require("bignumber.js"));
|
|
3121
3212
|
var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer = false) => {
|
|
3122
3213
|
borrowIncentiveCoinNames = borrowIncentiveCoinNames || [
|
|
@@ -3148,11 +3239,11 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer
|
|
|
3148
3239
|
const queryTarget = `${queryPkgId}::incentive_pools_query::incentive_pools_data`;
|
|
3149
3240
|
const args = [incentivePoolsId];
|
|
3150
3241
|
const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
|
|
3151
|
-
const borrowIncentivePoolsQueryData = queryResult
|
|
3152
|
-
for (const pool of borrowIncentivePoolsQueryData
|
|
3242
|
+
const borrowIncentivePoolsQueryData = queryResult?.events[0].parsedJson;
|
|
3243
|
+
for (const pool of borrowIncentivePoolsQueryData?.incentive_pools ?? []) {
|
|
3153
3244
|
const borrowIncentivePoolPoints = {};
|
|
3154
3245
|
const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(pool);
|
|
3155
|
-
const poolCoinType = (0,
|
|
3246
|
+
const poolCoinType = (0, import_utils7.normalizeStructTag)(pool.pool_type.name);
|
|
3156
3247
|
const poolCoinName = query.utils.parseCoinNameFromType(
|
|
3157
3248
|
poolCoinType
|
|
3158
3249
|
);
|
|
@@ -3164,7 +3255,7 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer
|
|
|
3164
3255
|
for (const [coinName, poolPoint] of Object.entries(
|
|
3165
3256
|
parsedBorrowIncentivePoolData.poolPoints
|
|
3166
3257
|
)) {
|
|
3167
|
-
const rewardCoinType = (0,
|
|
3258
|
+
const rewardCoinType = (0, import_utils7.normalizeStructTag)(poolPoint.pointType);
|
|
3168
3259
|
const rewardCoinName = query.utils.parseCoinNameFromType(
|
|
3169
3260
|
rewardCoinType
|
|
3170
3261
|
);
|
|
@@ -3220,9 +3311,9 @@ var queryBorrowIncentiveAccounts = async (query, obligationId, borrowIncentiveCo
|
|
|
3220
3311
|
const queryTarget = `${queryPkgId}::incentive_account_query::incentive_account_data`;
|
|
3221
3312
|
const args = [incentiveAccountsId, obligationId];
|
|
3222
3313
|
const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
|
|
3223
|
-
const borrowIncentiveAccountsQueryData = queryResult
|
|
3314
|
+
const borrowIncentiveAccountsQueryData = queryResult?.events[0].parsedJson;
|
|
3224
3315
|
const borrowIncentiveAccounts = Object.values(
|
|
3225
|
-
borrowIncentiveAccountsQueryData
|
|
3316
|
+
borrowIncentiveAccountsQueryData?.pool_records ?? []
|
|
3226
3317
|
).reduce((accounts, accountData) => {
|
|
3227
3318
|
const parsedBorrowIncentiveAccount = parseOriginBorrowIncentiveAccountData(accountData);
|
|
3228
3319
|
const poolType = parsedBorrowIncentiveAccount.poolType;
|
|
@@ -3244,7 +3335,7 @@ var getBindedObligationId = async (query, veScaKeyId) => {
|
|
|
3244
3335
|
showContent: true
|
|
3245
3336
|
}
|
|
3246
3337
|
);
|
|
3247
|
-
if (incentivePoolsResponse
|
|
3338
|
+
if (incentivePoolsResponse?.data?.content?.dataType !== "moveObject")
|
|
3248
3339
|
return null;
|
|
3249
3340
|
const incentivePoolFields = incentivePoolsResponse.data.content.fields;
|
|
3250
3341
|
const veScaBindTableId = incentivePoolFields.ve_sca_bind.fields.id.id;
|
|
@@ -3256,7 +3347,7 @@ var getBindedObligationId = async (query, veScaKeyId) => {
|
|
|
3256
3347
|
value: veScaKeyId
|
|
3257
3348
|
}
|
|
3258
3349
|
});
|
|
3259
|
-
if (veScaBindTableResponse
|
|
3350
|
+
if (veScaBindTableResponse?.data?.content?.dataType !== "moveObject")
|
|
3260
3351
|
return null;
|
|
3261
3352
|
const veScaBindTableFields = veScaBindTableResponse.data.content.fields;
|
|
3262
3353
|
const obligationId = veScaBindTableFields.value.fields.id;
|
|
@@ -3274,7 +3365,7 @@ var getBindedVeScaKey = async (query, obliationId) => {
|
|
|
3274
3365
|
showContent: true
|
|
3275
3366
|
}
|
|
3276
3367
|
);
|
|
3277
|
-
if (incentiveAccountsObject
|
|
3368
|
+
if (incentiveAccountsObject?.data?.content?.dataType !== "moveObject")
|
|
3278
3369
|
return null;
|
|
3279
3370
|
const incentiveAccountsTableId = incentiveAccountsObject.data.content.fields.accounts.fields.id.id;
|
|
3280
3371
|
const bindedIncentiveAcc = await query.cache.queryGetDynamicFieldObject({
|
|
@@ -3284,7 +3375,7 @@ var getBindedVeScaKey = async (query, obliationId) => {
|
|
|
3284
3375
|
value: obliationId
|
|
3285
3376
|
}
|
|
3286
3377
|
});
|
|
3287
|
-
if (bindedIncentiveAcc
|
|
3378
|
+
if (bindedIncentiveAcc?.data?.content?.dataType !== "moveObject")
|
|
3288
3379
|
return null;
|
|
3289
3380
|
const bindedIncentiveAccFields = bindedIncentiveAcc.data.content.fields;
|
|
3290
3381
|
return bindedIncentiveAccFields.value.fields.binded_ve_sca_key?.fields.id ?? null;
|
|
@@ -3295,7 +3386,7 @@ var getPythPrice = async (query, assetCoinName, priceFeedObject) => {
|
|
|
3295
3386
|
const pythFeedObjectId = query.address.get(
|
|
3296
3387
|
`core.coins.${assetCoinName}.oracle.pyth.feedObject`
|
|
3297
3388
|
);
|
|
3298
|
-
priceFeedObject = priceFeedObject || (await query.cache.queryGetObject(pythFeedObjectId, { showContent: true }))
|
|
3389
|
+
priceFeedObject = priceFeedObject || (await query.cache.queryGetObject(pythFeedObjectId, { showContent: true }))?.data;
|
|
3299
3390
|
if (priceFeedObject) {
|
|
3300
3391
|
const priceFeedPoolObject = priceFeedObject;
|
|
3301
3392
|
if (priceFeedPoolObject.content && "fields" in priceFeedPoolObject.content) {
|
|
@@ -3583,7 +3674,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3583
3674
|
let totalBorrowedValue = (0, import_bignumber4.default)(0);
|
|
3584
3675
|
let totalBorrowedValueWithWeight = (0, import_bignumber4.default)(0);
|
|
3585
3676
|
for (const assetCoinName of collateralAssetCoinNames) {
|
|
3586
|
-
const collateral = obligationQuery
|
|
3677
|
+
const collateral = obligationQuery?.collaterals.find((collateral2) => {
|
|
3587
3678
|
const collateralCoinName = query.utils.parseCoinNameFromType(
|
|
3588
3679
|
collateral2.type.name
|
|
3589
3680
|
);
|
|
@@ -3643,7 +3734,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3643
3734
|
.../* @__PURE__ */ new Set([...Object.values(market.pools).map((pool) => pool.coinName)])
|
|
3644
3735
|
];
|
|
3645
3736
|
for (const assetCoinName of borrowAssetCoinNames) {
|
|
3646
|
-
const debt = obligationQuery
|
|
3737
|
+
const debt = obligationQuery?.debts.find((debt2) => {
|
|
3647
3738
|
const poolCoinName = query.utils.parseCoinNameFromType(
|
|
3648
3739
|
debt2.type.name
|
|
3649
3740
|
);
|
|
@@ -3903,8 +3994,10 @@ var getVescaKeys = async (query, ownerAddress) => {
|
|
|
3903
3994
|
},
|
|
3904
3995
|
cursor: nextCursor
|
|
3905
3996
|
});
|
|
3997
|
+
if (!paginatedKeyObjectsResponse)
|
|
3998
|
+
continue;
|
|
3906
3999
|
keyObjectsResponse.push(...paginatedKeyObjectsResponse.data);
|
|
3907
|
-
if (paginatedKeyObjectsResponse.hasNextPage && paginatedKeyObjectsResponse.nextCursor) {
|
|
4000
|
+
if (paginatedKeyObjectsResponse && paginatedKeyObjectsResponse.hasNextPage && paginatedKeyObjectsResponse.nextCursor) {
|
|
3908
4001
|
hasNextPage = true;
|
|
3909
4002
|
nextCursor = paginatedKeyObjectsResponse.nextCursor;
|
|
3910
4003
|
} else {
|
|
@@ -3947,6 +4040,8 @@ var getVeSca = async (query, veScaKey, ownerAddress) => {
|
|
|
3947
4040
|
value: typeof veScaKey === "string" ? veScaKey : veScaKey.objectId
|
|
3948
4041
|
}
|
|
3949
4042
|
});
|
|
4043
|
+
if (!veScaDynamicFieldObjectResponse)
|
|
4044
|
+
return void 0;
|
|
3950
4045
|
const veScaDynamicFieldObject = veScaDynamicFieldObjectResponse.data;
|
|
3951
4046
|
if (veScaDynamicFieldObject && veScaDynamicFieldObject.content && veScaDynamicFieldObject.content.dataType === "moveObject" && "fields" in veScaDynamicFieldObject.content) {
|
|
3952
4047
|
const dynamicFields = veScaDynamicFieldObject.content.fields.value.fields;
|
|
@@ -3981,7 +4076,7 @@ var getTotalVeScaTreasuryAmount = async (query, veScaTreasury) => {
|
|
|
3981
4076
|
const resolvedRefreshArgs = await Promise.all(
|
|
3982
4077
|
refreshArgs.map(async (arg) => {
|
|
3983
4078
|
if (typeof arg === "string") {
|
|
3984
|
-
return (await query.cache.queryGetObject(arg, { showContent: true }))
|
|
4079
|
+
return (await query.cache.queryGetObject(arg, { showContent: true }))?.data;
|
|
3985
4080
|
}
|
|
3986
4081
|
return arg;
|
|
3987
4082
|
})
|
|
@@ -3989,7 +4084,7 @@ var getTotalVeScaTreasuryAmount = async (query, veScaTreasury) => {
|
|
|
3989
4084
|
const resolvedVeScaAmountArgs = await Promise.all(
|
|
3990
4085
|
veScaAmountArgs.map(async (arg) => {
|
|
3991
4086
|
if (typeof arg === "string") {
|
|
3992
|
-
return (await query.cache.queryGetObject(arg, { showContent: true }))
|
|
4087
|
+
return (await query.cache.queryGetObject(arg, { showContent: true }))?.data;
|
|
3993
4088
|
}
|
|
3994
4089
|
return arg;
|
|
3995
4090
|
})
|
|
@@ -4000,7 +4095,7 @@ var getTotalVeScaTreasuryAmount = async (query, veScaTreasury) => {
|
|
|
4000
4095
|
const txBytes = await txb.txBlock.build({
|
|
4001
4096
|
client: query.suiKit.client(),
|
|
4002
4097
|
onlyTransactionKind: true,
|
|
4003
|
-
protocolConfig: await query.cache.getProtocolConfig()
|
|
4098
|
+
protocolConfig: await query.cache.getProtocolConfig() ?? void 0
|
|
4004
4099
|
});
|
|
4005
4100
|
const res = await query.cache.queryClient.fetchQuery({
|
|
4006
4101
|
queryKey: [
|
|
@@ -4053,7 +4148,7 @@ var queryVeScaKeyIdFromReferralBindings = async (query, refereeAddress) => {
|
|
|
4053
4148
|
value: refereeAddress
|
|
4054
4149
|
}
|
|
4055
4150
|
});
|
|
4056
|
-
if (referralBindResponse
|
|
4151
|
+
if (referralBindResponse?.data?.content?.dataType !== "moveObject")
|
|
4057
4152
|
return null;
|
|
4058
4153
|
const fields = referralBindResponse.data.content.fields;
|
|
4059
4154
|
return fields.value;
|
|
@@ -4077,7 +4172,7 @@ var getLoyaltyProgramInformations = async (query, veScaKey) => {
|
|
|
4077
4172
|
const rewardPoolObject = await query.cache.queryGetObject(rewardPool, {
|
|
4078
4173
|
showContent: true
|
|
4079
4174
|
});
|
|
4080
|
-
if (rewardPoolObject
|
|
4175
|
+
if (rewardPoolObject?.data?.content?.dataType !== "moveObject")
|
|
4081
4176
|
return null;
|
|
4082
4177
|
const rewardPoolFields = rewardPoolObject.data.content.fields;
|
|
4083
4178
|
const { isClaimEnabled, totalPoolReward } = rewardPoolFieldsZod.parse(
|
|
@@ -4101,7 +4196,7 @@ var getLoyaltyProgramInformations = async (query, veScaKey) => {
|
|
|
4101
4196
|
value: typeof veScaKey === "string" ? veScaKey : veScaKey.objectId
|
|
4102
4197
|
}
|
|
4103
4198
|
});
|
|
4104
|
-
if (userRewardObject
|
|
4199
|
+
if (userRewardObject?.data?.content?.dataType !== "moveObject")
|
|
4105
4200
|
return result;
|
|
4106
4201
|
const userRewardFields = userRewardObject.data.content.fields;
|
|
4107
4202
|
result.pendingReward = userRewardFieldsZod.parse(
|
|
@@ -4295,7 +4390,7 @@ var getSCoinTotalSupply = async (query, sCoinName) => {
|
|
|
4295
4390
|
args,
|
|
4296
4391
|
typeArgs
|
|
4297
4392
|
});
|
|
4298
|
-
const results = queryResults
|
|
4393
|
+
const results = queryResults?.results;
|
|
4299
4394
|
if (results && results[0].returnValues) {
|
|
4300
4395
|
const value = Uint8Array.from(results[0].returnValues[0][0]);
|
|
4301
4396
|
const type = results[0].returnValues[0][1];
|
|
@@ -4329,7 +4424,7 @@ var getSCoinAmount = async (query, sCoinName, ownerAddress) => {
|
|
|
4329
4424
|
};
|
|
4330
4425
|
|
|
4331
4426
|
// src/models/scallopQuery.ts
|
|
4332
|
-
var
|
|
4427
|
+
var import_utils10 = require("@mysten/sui.js/utils");
|
|
4333
4428
|
var ScallopQuery = class {
|
|
4334
4429
|
constructor(params, instance) {
|
|
4335
4430
|
this.params = params;
|
|
@@ -4349,7 +4444,7 @@ var ScallopQuery = class {
|
|
|
4349
4444
|
query: this
|
|
4350
4445
|
});
|
|
4351
4446
|
this.indexer = new ScallopIndexer(this.params, { cache: this.cache });
|
|
4352
|
-
this.walletAddress = (0,
|
|
4447
|
+
this.walletAddress = (0, import_utils10.normalizeSuiAddress)(
|
|
4353
4448
|
params?.walletAddress || this.suiKit.currentAddress()
|
|
4354
4449
|
);
|
|
4355
4450
|
}
|
|
@@ -4877,7 +4972,7 @@ var ScallopUtils = class {
|
|
|
4877
4972
|
throw Error(`Coin ${coinName} is not supported`);
|
|
4878
4973
|
}
|
|
4879
4974
|
if (coinName === "sui")
|
|
4880
|
-
return (0,
|
|
4975
|
+
return (0, import_utils11.normalizeStructTag)(`${coinPackageId}::sui::SUI`);
|
|
4881
4976
|
const wormHolePckageIds = [
|
|
4882
4977
|
this._address.get("core.coins.usdc.id") ?? wormholeCoinIds.usdc,
|
|
4883
4978
|
this._address.get("core.coins.usdt.id") ?? wormholeCoinIds.usdt,
|
|
@@ -4952,7 +5047,7 @@ var ScallopUtils = class {
|
|
|
4952
5047
|
return `${protocolObjectId}::reserve::MarketCoin<${coinType}>`;
|
|
4953
5048
|
}
|
|
4954
5049
|
parseCoinNameFromType(coinType) {
|
|
4955
|
-
coinType = (0,
|
|
5050
|
+
coinType = (0, import_utils11.normalizeStructTag)(coinType);
|
|
4956
5051
|
const coinTypeRegex = new RegExp(`((0x[^:]+::[^:]+::[^<>]+))(?![^<>]*<)`);
|
|
4957
5052
|
const coinTypeMatch = coinType.match(coinTypeRegex);
|
|
4958
5053
|
const isMarketCoinType = coinType.includes("reserve::MarketCoin");
|
|
@@ -5016,7 +5111,7 @@ var ScallopUtils = class {
|
|
|
5016
5111
|
* @param coinType - The coin type, default is 0x2::SUI::SUI.
|
|
5017
5112
|
* @return The selected transaction coin arguments.
|
|
5018
5113
|
*/
|
|
5019
|
-
async selectCoins(amount, coinType =
|
|
5114
|
+
async selectCoins(amount, coinType = import_utils11.SUI_TYPE_ARG, ownerAddress) {
|
|
5020
5115
|
ownerAddress = ownerAddress || this._suiKit.currentAddress();
|
|
5021
5116
|
const coins = await this._suiKit.suiInteractor.selectCoins(
|
|
5022
5117
|
ownerAddress,
|
|
@@ -5025,6 +5120,26 @@ var ScallopUtils = class {
|
|
|
5025
5120
|
);
|
|
5026
5121
|
return coins;
|
|
5027
5122
|
}
|
|
5123
|
+
/**
|
|
5124
|
+
* Merge coins with type `coinType` to dest
|
|
5125
|
+
* @param txBlock
|
|
5126
|
+
* @param dest
|
|
5127
|
+
* @param coinType
|
|
5128
|
+
* @param sender
|
|
5129
|
+
*/
|
|
5130
|
+
async mergeSimilarCoins(txBlock, dest, coinType, sender) {
|
|
5131
|
+
try {
|
|
5132
|
+
const existingSCoin = await this.selectCoins(
|
|
5133
|
+
Number.MAX_SAFE_INTEGER,
|
|
5134
|
+
coinType,
|
|
5135
|
+
sender
|
|
5136
|
+
);
|
|
5137
|
+
if (existingSCoin.length > 0) {
|
|
5138
|
+
txBlock.mergeCoins(dest, existingSCoin);
|
|
5139
|
+
}
|
|
5140
|
+
} catch (e) {
|
|
5141
|
+
}
|
|
5142
|
+
}
|
|
5028
5143
|
/**
|
|
5029
5144
|
* Get all asset coin names in the obligation record by obligation id.
|
|
5030
5145
|
*
|
|
@@ -5037,12 +5152,12 @@ var ScallopUtils = class {
|
|
|
5037
5152
|
*/
|
|
5038
5153
|
async getObligationCoinNames(obligationId) {
|
|
5039
5154
|
const obligation = await queryObligation(this._query, obligationId);
|
|
5040
|
-
const collateralCoinTypes = obligation
|
|
5155
|
+
const collateralCoinTypes = obligation?.collaterals.map((collateral) => {
|
|
5041
5156
|
return `0x${collateral.type.name}`;
|
|
5042
|
-
});
|
|
5043
|
-
const debtCoinTypes = obligation
|
|
5157
|
+
}) ?? [];
|
|
5158
|
+
const debtCoinTypes = obligation?.debts.map((debt) => {
|
|
5044
5159
|
return `0x${debt.type.name}`;
|
|
5045
|
-
});
|
|
5160
|
+
}) ?? [];
|
|
5046
5161
|
const obligationCoinTypes = [
|
|
5047
5162
|
.../* @__PURE__ */ new Set([...collateralCoinTypes, ...debtCoinTypes])
|
|
5048
5163
|
];
|
|
@@ -5197,16 +5312,16 @@ var ScallopUtils = class {
|
|
|
5197
5312
|
};
|
|
5198
5313
|
|
|
5199
5314
|
// src/models/scallopBuilder.ts
|
|
5200
|
-
var
|
|
5315
|
+
var import_utils24 = require("@mysten/sui.js/utils");
|
|
5201
5316
|
var import_sui_kit12 = require("@scallop-io/sui-kit");
|
|
5202
5317
|
|
|
5203
5318
|
// src/builders/coreBuilder.ts
|
|
5204
5319
|
var import_transactions = require("@mysten/sui.js/transactions");
|
|
5205
|
-
var
|
|
5320
|
+
var import_utils14 = require("@mysten/sui.js/utils");
|
|
5206
5321
|
var import_sui_kit5 = require("@scallop-io/sui-kit");
|
|
5207
5322
|
|
|
5208
5323
|
// src/builders/oracle.ts
|
|
5209
|
-
var
|
|
5324
|
+
var import_utils13 = require("@mysten/sui.js/utils");
|
|
5210
5325
|
var import_pyth_sui_js2 = require("@pythnetwork/pyth-sui-js");
|
|
5211
5326
|
var updateOracles = async (builder, txBlock, assetCoinNames) => {
|
|
5212
5327
|
assetCoinNames = assetCoinNames ?? [
|
|
@@ -5320,27 +5435,27 @@ var priceUpdateRequest = (txBlock, packageId, xOracleId, coinType) => {
|
|
|
5320
5435
|
var confirmPriceUpdateRequest = (txBlock, packageId, xOracleId, request, coinType) => {
|
|
5321
5436
|
const target = `${packageId}::x_oracle::confirm_price_update_request`;
|
|
5322
5437
|
const typeArgs = [coinType];
|
|
5323
|
-
txBlock.moveCall(target, [xOracleId, request,
|
|
5438
|
+
txBlock.moveCall(target, [xOracleId, request, import_utils13.SUI_CLOCK_OBJECT_ID], typeArgs);
|
|
5324
5439
|
return txBlock;
|
|
5325
5440
|
};
|
|
5326
5441
|
var updateSupraPrice = (txBlock, packageId, request, holderId, registryId, coinType) => {
|
|
5327
5442
|
txBlock.moveCall(
|
|
5328
5443
|
`${packageId}::rule::set_price`,
|
|
5329
|
-
[request, holderId, registryId,
|
|
5444
|
+
[request, holderId, registryId, import_utils13.SUI_CLOCK_OBJECT_ID],
|
|
5330
5445
|
[coinType]
|
|
5331
5446
|
);
|
|
5332
5447
|
};
|
|
5333
5448
|
var updateSwitchboardPrice = (txBlock, packageId, request, aggregatorId, registryId, coinType) => {
|
|
5334
5449
|
txBlock.moveCall(
|
|
5335
5450
|
`${packageId}::rule::set_price`,
|
|
5336
|
-
[request, aggregatorId, registryId,
|
|
5451
|
+
[request, aggregatorId, registryId, import_utils13.SUI_CLOCK_OBJECT_ID],
|
|
5337
5452
|
[coinType]
|
|
5338
5453
|
);
|
|
5339
5454
|
};
|
|
5340
5455
|
var updatePythPrice = (txBlock, packageId, request, stateId, feedObjectId, registryId, coinType) => {
|
|
5341
5456
|
txBlock.moveCall(
|
|
5342
5457
|
`${packageId}::rule::set_price`,
|
|
5343
|
-
[request, stateId, feedObjectId, registryId,
|
|
5458
|
+
[request, stateId, feedObjectId, registryId, import_utils13.SUI_CLOCK_OBJECT_ID],
|
|
5344
5459
|
[coinType]
|
|
5345
5460
|
);
|
|
5346
5461
|
};
|
|
@@ -5411,7 +5526,7 @@ var generateCoreNormalMethod = ({
|
|
|
5411
5526
|
coreIds.coinDecimalsRegistry,
|
|
5412
5527
|
amount,
|
|
5413
5528
|
coreIds.xOracle,
|
|
5414
|
-
|
|
5529
|
+
import_utils14.SUI_CLOCK_OBJECT_ID
|
|
5415
5530
|
],
|
|
5416
5531
|
[coinType]
|
|
5417
5532
|
);
|
|
@@ -5420,7 +5535,7 @@ var generateCoreNormalMethod = ({
|
|
|
5420
5535
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
5421
5536
|
return txBlock.moveCall(
|
|
5422
5537
|
`${coreIds.protocolPkg}::mint::mint`,
|
|
5423
|
-
[coreIds.version, coreIds.market, coin,
|
|
5538
|
+
[coreIds.version, coreIds.market, coin, import_utils14.SUI_CLOCK_OBJECT_ID],
|
|
5424
5539
|
[coinType]
|
|
5425
5540
|
);
|
|
5426
5541
|
},
|
|
@@ -5428,7 +5543,7 @@ var generateCoreNormalMethod = ({
|
|
|
5428
5543
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
5429
5544
|
return txBlock.moveCall(
|
|
5430
5545
|
`${coreIds.protocolPkg}::mint::mint_entry`,
|
|
5431
|
-
[coreIds.version, coreIds.market, coin,
|
|
5546
|
+
[coreIds.version, coreIds.market, coin, import_utils14.SUI_CLOCK_OBJECT_ID],
|
|
5432
5547
|
[coinType]
|
|
5433
5548
|
);
|
|
5434
5549
|
},
|
|
@@ -5436,7 +5551,7 @@ var generateCoreNormalMethod = ({
|
|
|
5436
5551
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
5437
5552
|
return txBlock.moveCall(
|
|
5438
5553
|
`${coreIds.protocolPkg}::redeem::redeem`,
|
|
5439
|
-
[coreIds.version, coreIds.market, marketCoin,
|
|
5554
|
+
[coreIds.version, coreIds.market, marketCoin, import_utils14.SUI_CLOCK_OBJECT_ID],
|
|
5440
5555
|
[coinType]
|
|
5441
5556
|
);
|
|
5442
5557
|
},
|
|
@@ -5444,7 +5559,7 @@ var generateCoreNormalMethod = ({
|
|
|
5444
5559
|
const coinType = builder.utils.parseCoinType(poolCoinName);
|
|
5445
5560
|
return txBlock.moveCall(
|
|
5446
5561
|
`${coreIds.protocolPkg}::redeem::redeem_entry`,
|
|
5447
|
-
[coreIds.version, coreIds.market, marketCoin,
|
|
5562
|
+
[coreIds.version, coreIds.market, marketCoin, import_utils14.SUI_CLOCK_OBJECT_ID],
|
|
5448
5563
|
[coinType]
|
|
5449
5564
|
);
|
|
5450
5565
|
},
|
|
@@ -5460,7 +5575,7 @@ var generateCoreNormalMethod = ({
|
|
|
5460
5575
|
coreIds.coinDecimalsRegistry,
|
|
5461
5576
|
amount,
|
|
5462
5577
|
coreIds.xOracle,
|
|
5463
|
-
|
|
5578
|
+
import_utils14.SUI_CLOCK_OBJECT_ID
|
|
5464
5579
|
],
|
|
5465
5580
|
[coinType]
|
|
5466
5581
|
);
|
|
@@ -5478,7 +5593,7 @@ var generateCoreNormalMethod = ({
|
|
|
5478
5593
|
borrowReferral,
|
|
5479
5594
|
amount,
|
|
5480
5595
|
coreIds.xOracle,
|
|
5481
|
-
|
|
5596
|
+
import_utils14.SUI_CLOCK_OBJECT_ID
|
|
5482
5597
|
],
|
|
5483
5598
|
[coinType, referralWitnessType]
|
|
5484
5599
|
);
|
|
@@ -5495,7 +5610,7 @@ var generateCoreNormalMethod = ({
|
|
|
5495
5610
|
coreIds.coinDecimalsRegistry,
|
|
5496
5611
|
amount,
|
|
5497
5612
|
coreIds.xOracle,
|
|
5498
|
-
|
|
5613
|
+
import_utils14.SUI_CLOCK_OBJECT_ID
|
|
5499
5614
|
],
|
|
5500
5615
|
[coinType]
|
|
5501
5616
|
);
|
|
@@ -5509,7 +5624,7 @@ var generateCoreNormalMethod = ({
|
|
|
5509
5624
|
obligation,
|
|
5510
5625
|
coreIds.market,
|
|
5511
5626
|
coin,
|
|
5512
|
-
|
|
5627
|
+
import_utils14.SUI_CLOCK_OBJECT_ID
|
|
5513
5628
|
],
|
|
5514
5629
|
[coinType]
|
|
5515
5630
|
);
|
|
@@ -5744,7 +5859,7 @@ var newCoreTxBlock = (builder, initTxBlock) => {
|
|
|
5744
5859
|
|
|
5745
5860
|
// src/builders/spoolBuilder.ts
|
|
5746
5861
|
var import_transactions2 = require("@mysten/sui.js/transactions");
|
|
5747
|
-
var
|
|
5862
|
+
var import_utils16 = require("@mysten/sui.js/utils");
|
|
5748
5863
|
var import_sui_kit6 = require("@scallop-io/sui-kit");
|
|
5749
5864
|
var requireStakeAccountIds = async (...params) => {
|
|
5750
5865
|
const [builder, txBlock, stakeMarketCoinName, stakeAccountId] = params;
|
|
@@ -5799,7 +5914,7 @@ var generateSpoolNormalMethod = ({
|
|
|
5799
5914
|
);
|
|
5800
5915
|
return txBlock.moveCall(
|
|
5801
5916
|
`${spoolIds.spoolPkg}::user::new_spool_account`,
|
|
5802
|
-
[stakePoolId,
|
|
5917
|
+
[stakePoolId, import_utils16.SUI_CLOCK_OBJECT_ID],
|
|
5803
5918
|
[marketCoinType]
|
|
5804
5919
|
);
|
|
5805
5920
|
},
|
|
@@ -5810,7 +5925,7 @@ var generateSpoolNormalMethod = ({
|
|
|
5810
5925
|
);
|
|
5811
5926
|
txBlock.moveCall(
|
|
5812
5927
|
`${spoolIds.spoolPkg}::user::stake`,
|
|
5813
|
-
[stakePoolId, stakeAccount, coin,
|
|
5928
|
+
[stakePoolId, stakeAccount, coin, import_utils16.SUI_CLOCK_OBJECT_ID],
|
|
5814
5929
|
[marketCoinType]
|
|
5815
5930
|
);
|
|
5816
5931
|
},
|
|
@@ -5821,7 +5936,7 @@ var generateSpoolNormalMethod = ({
|
|
|
5821
5936
|
);
|
|
5822
5937
|
return txBlock.moveCall(
|
|
5823
5938
|
`${spoolIds.spoolPkg}::user::unstake`,
|
|
5824
|
-
[stakePoolId, stakeAccount, amount,
|
|
5939
|
+
[stakePoolId, stakeAccount, amount, import_utils16.SUI_CLOCK_OBJECT_ID],
|
|
5825
5940
|
[marketCoinType]
|
|
5826
5941
|
);
|
|
5827
5942
|
},
|
|
@@ -5837,7 +5952,7 @@ var generateSpoolNormalMethod = ({
|
|
|
5837
5952
|
const rewardCoinType = builder.utils.parseCoinType(rewardCoinName);
|
|
5838
5953
|
return txBlock.moveCall(
|
|
5839
5954
|
`${spoolIds.spoolPkg}::user::redeem_rewards`,
|
|
5840
|
-
[stakePoolId, rewardPoolId, stakeAccount,
|
|
5955
|
+
[stakePoolId, rewardPoolId, stakeAccount, import_utils16.SUI_CLOCK_OBJECT_ID],
|
|
5841
5956
|
[marketCoinType, rewardCoinType]
|
|
5842
5957
|
);
|
|
5843
5958
|
}
|
|
@@ -5909,7 +6024,7 @@ var generateSpoolQuickMethod = ({
|
|
|
5909
6024
|
toTransfer.push(marketCoin);
|
|
5910
6025
|
}
|
|
5911
6026
|
amount -= amountToUnstake;
|
|
5912
|
-
if (amount
|
|
6027
|
+
if (amount <= 0)
|
|
5913
6028
|
break;
|
|
5914
6029
|
}
|
|
5915
6030
|
if (toTransfer.length > 0) {
|
|
@@ -5917,31 +6032,6 @@ var generateSpoolQuickMethod = ({
|
|
|
5917
6032
|
if (toTransfer.length > 1) {
|
|
5918
6033
|
txBlock.mergeCoins(mergedCoin, toTransfer.slice(1));
|
|
5919
6034
|
}
|
|
5920
|
-
if (returnSCoin) {
|
|
5921
|
-
try {
|
|
5922
|
-
const existingCoins = await builder.utils.selectCoins(
|
|
5923
|
-
Number.MAX_SAFE_INTEGER,
|
|
5924
|
-
builder.utils.parseSCoinType(stakeMarketCoinName),
|
|
5925
|
-
requireSender(txBlock)
|
|
5926
|
-
);
|
|
5927
|
-
if (existingCoins.length > 0) {
|
|
5928
|
-
txBlock.mergeCoins(mergedCoin, existingCoins);
|
|
5929
|
-
}
|
|
5930
|
-
} catch (e) {
|
|
5931
|
-
}
|
|
5932
|
-
} else {
|
|
5933
|
-
try {
|
|
5934
|
-
const existingCoins = await builder.utils.selectCoins(
|
|
5935
|
-
Number.MAX_SAFE_INTEGER,
|
|
5936
|
-
builder.utils.parseMarketCoinType(stakeMarketCoinName),
|
|
5937
|
-
requireSender(txBlock)
|
|
5938
|
-
);
|
|
5939
|
-
if (existingCoins.length > 0) {
|
|
5940
|
-
txBlock.mergeCoins(mergedCoin, existingCoins);
|
|
5941
|
-
}
|
|
5942
|
-
} catch (e) {
|
|
5943
|
-
}
|
|
5944
|
-
}
|
|
5945
6035
|
return mergedCoin;
|
|
5946
6036
|
}
|
|
5947
6037
|
},
|
|
@@ -5991,7 +6081,7 @@ var newSpoolTxBlock = (builder, initTxBlock) => {
|
|
|
5991
6081
|
|
|
5992
6082
|
// src/builders/borrowIncentiveBuilder.ts
|
|
5993
6083
|
var import_transactions3 = require("@mysten/sui.js/transactions");
|
|
5994
|
-
var
|
|
6084
|
+
var import_utils19 = require("@mysten/sui.js/utils");
|
|
5995
6085
|
var import_sui_kit8 = require("@scallop-io/sui-kit");
|
|
5996
6086
|
|
|
5997
6087
|
// src/builders/vescaBuilder.ts
|
|
@@ -6317,7 +6407,7 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
|
|
|
6317
6407
|
obligationKey,
|
|
6318
6408
|
obligationId,
|
|
6319
6409
|
borrowIncentiveIds.obligationAccessStore,
|
|
6320
|
-
|
|
6410
|
+
import_utils19.SUI_CLOCK_OBJECT_ID
|
|
6321
6411
|
]
|
|
6322
6412
|
);
|
|
6323
6413
|
},
|
|
@@ -6335,7 +6425,7 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
|
|
|
6335
6425
|
veScaIds.treasury,
|
|
6336
6426
|
veScaIds.table,
|
|
6337
6427
|
veScaKey,
|
|
6338
|
-
|
|
6428
|
+
import_utils19.SUI_CLOCK_OBJECT_ID
|
|
6339
6429
|
],
|
|
6340
6430
|
[]
|
|
6341
6431
|
);
|
|
@@ -6349,7 +6439,7 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
|
|
|
6349
6439
|
borrowIncentiveIds.incentiveAccounts,
|
|
6350
6440
|
obligationKey,
|
|
6351
6441
|
obligationId,
|
|
6352
|
-
|
|
6442
|
+
import_utils19.SUI_CLOCK_OBJECT_ID
|
|
6353
6443
|
]
|
|
6354
6444
|
);
|
|
6355
6445
|
},
|
|
@@ -6367,7 +6457,7 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
|
|
|
6367
6457
|
borrowIncentiveIds.incentiveAccounts,
|
|
6368
6458
|
obligationKey,
|
|
6369
6459
|
obligationId,
|
|
6370
|
-
|
|
6460
|
+
import_utils19.SUI_CLOCK_OBJECT_ID
|
|
6371
6461
|
],
|
|
6372
6462
|
[rewardType]
|
|
6373
6463
|
);
|
|
@@ -6381,7 +6471,7 @@ var generateBorrowIncentiveNormalMethod = ({ builder, txBlock }) => {
|
|
|
6381
6471
|
borrowIncentiveIds.incentiveAccounts,
|
|
6382
6472
|
obligation,
|
|
6383
6473
|
veScaKey,
|
|
6384
|
-
|
|
6474
|
+
import_utils19.SUI_CLOCK_OBJECT_ID
|
|
6385
6475
|
]
|
|
6386
6476
|
);
|
|
6387
6477
|
}
|
|
@@ -6670,17 +6760,12 @@ var generateLoyaltyProgramQuickMethod = ({
|
|
|
6670
6760
|
throw new Error(`No veScaKey found for user ${sender}`);
|
|
6671
6761
|
const toTransferObject = [];
|
|
6672
6762
|
const rewardCoin = txBlock.claimLoyaltyRevenue(veScaKey);
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6676
|
-
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
txBlock.mergeCoins(rewardCoin, existingScaCoin);
|
|
6680
|
-
} catch (e) {
|
|
6681
|
-
} finally {
|
|
6682
|
-
toTransferObject.push(rewardCoin);
|
|
6683
|
-
}
|
|
6763
|
+
await builder.utils.mergeSimilarCoins(
|
|
6764
|
+
txBlock,
|
|
6765
|
+
rewardCoin,
|
|
6766
|
+
coinIds.sca,
|
|
6767
|
+
requireSender(txBlock)
|
|
6768
|
+
);
|
|
6684
6769
|
if (toTransferObject.length > 0) {
|
|
6685
6770
|
txBlock.transferObjects(toTransferObject, sender);
|
|
6686
6771
|
}
|
|
@@ -6860,7 +6945,7 @@ var ScallopBuilder = class {
|
|
|
6860
6945
|
query: this.query,
|
|
6861
6946
|
cache: this.cache
|
|
6862
6947
|
});
|
|
6863
|
-
this.walletAddress = (0,
|
|
6948
|
+
this.walletAddress = (0, import_utils24.normalizeSuiAddress)(
|
|
6864
6949
|
params?.walletAddress || this.suiKit.currentAddress()
|
|
6865
6950
|
);
|
|
6866
6951
|
this.isTestnet = params.networkType ? params.networkType === "testnet" : false;
|
|
@@ -6995,7 +7080,7 @@ var ScallopClient = class {
|
|
|
6995
7080
|
utils: this.utils,
|
|
6996
7081
|
cache: this.cache
|
|
6997
7082
|
});
|
|
6998
|
-
this.walletAddress = (0,
|
|
7083
|
+
this.walletAddress = (0, import_utils25.normalizeSuiAddress)(
|
|
6999
7084
|
params?.walletAddress || this.suiKit.currentAddress()
|
|
7000
7085
|
);
|
|
7001
7086
|
}
|
|
@@ -7347,6 +7432,14 @@ var ScallopClient = class {
|
|
|
7347
7432
|
stakeMarketCoinName,
|
|
7348
7433
|
stakeAccountId
|
|
7349
7434
|
);
|
|
7435
|
+
if (sCoin) {
|
|
7436
|
+
await this.utils.mergeSimilarCoins(
|
|
7437
|
+
txBlock,
|
|
7438
|
+
sCoin,
|
|
7439
|
+
this.utils.parseSCoinType(stakeMarketCoinName),
|
|
7440
|
+
requireSender(txBlock)
|
|
7441
|
+
);
|
|
7442
|
+
}
|
|
7350
7443
|
txBlock.transferObjects([sCoin], sender);
|
|
7351
7444
|
if (sign) {
|
|
7352
7445
|
return await this.suiKit.signAndSendTxn(
|
|
@@ -7369,6 +7462,12 @@ var ScallopClient = class {
|
|
|
7369
7462
|
const stakeCoinName = this.utils.parseCoinName(stakeMarketCoinName);
|
|
7370
7463
|
if (stakeMarketCoin) {
|
|
7371
7464
|
const coin = txBlock.withdraw(stakeMarketCoin, stakeCoinName);
|
|
7465
|
+
await this.utils.mergeSimilarCoins(
|
|
7466
|
+
txBlock,
|
|
7467
|
+
coin,
|
|
7468
|
+
this.utils.parseCoinType(this.utils.parseCoinName(stakeCoinName)),
|
|
7469
|
+
requireSender(txBlock)
|
|
7470
|
+
);
|
|
7372
7471
|
txBlock.transferObjects([coin], sender);
|
|
7373
7472
|
} else {
|
|
7374
7473
|
throw new Error(`No stake found for ${stakeMarketCoinName}`);
|
|
@@ -7509,15 +7608,12 @@ var ScallopClient = class {
|
|
|
7509
7608
|
sCoinName,
|
|
7510
7609
|
toDestroyMarketCoin
|
|
7511
7610
|
);
|
|
7512
|
-
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
|
|
7517
|
-
|
|
7518
|
-
txBlock.mergeCoins(sCoin, existSCoins);
|
|
7519
|
-
} catch (e) {
|
|
7520
|
-
}
|
|
7611
|
+
await this.utils.mergeSimilarCoins(
|
|
7612
|
+
txBlock,
|
|
7613
|
+
sCoin,
|
|
7614
|
+
this.utils.parseSCoinType(sCoinName),
|
|
7615
|
+
requireSender(txBlock)
|
|
7616
|
+
);
|
|
7521
7617
|
sCoins2.push(sCoin);
|
|
7522
7618
|
}
|
|
7523
7619
|
if (SUPPORT_SPOOLS.includes(sCoinName)) {
|
|
@@ -7576,12 +7672,13 @@ var ScallopClient = class {
|
|
|
7576
7672
|
|
|
7577
7673
|
// src/models/scallop.ts
|
|
7578
7674
|
var Scallop = class {
|
|
7579
|
-
constructor(params, cacheOptions) {
|
|
7675
|
+
constructor(params, cacheOptions, tokenBucket) {
|
|
7580
7676
|
this.params = params;
|
|
7581
7677
|
this.suiKit = new import_sui_kit14.SuiKit(params);
|
|
7582
7678
|
this.cache = new ScallopCache(
|
|
7583
7679
|
cacheOptions ?? DEFAULT_CACHE_OPTIONS,
|
|
7584
|
-
this.suiKit
|
|
7680
|
+
this.suiKit,
|
|
7681
|
+
tokenBucket ?? new TokenBucket(DEFAULT_TOKENS_PER_INTERVAL, DEFAULT_INTERVAL_IN_MS)
|
|
7585
7682
|
);
|
|
7586
7683
|
this._address = new ScallopAddress(
|
|
7587
7684
|
{
|