@scallop-io/sui-scallop-sdk 1.3.5-alpha.1 → 1.3.5-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +41 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/queries/borrowIncentiveQuery.ts +0 -1
- package/src/queries/portfolioQuery.ts +64 -58
package/package.json
CHANGED
|
@@ -69,7 +69,6 @@ export const getBorrowIncentivePools = async (
|
|
|
69
69
|
(await query.getMarketPools(undefined, false, { coinPrices }));
|
|
70
70
|
coinPrices = coinPrices ?? (await query.getAllCoinPrices({ marketPools }));
|
|
71
71
|
|
|
72
|
-
console.log({ coinPrices });
|
|
73
72
|
if (indexer) {
|
|
74
73
|
const borrowIncentivePoolsIndexer =
|
|
75
74
|
await query.indexer.getBorrowIncentivePools();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import {
|
|
3
|
-
SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
4
3
|
SUPPORT_COLLATERALS,
|
|
5
4
|
SUPPORT_POOLS,
|
|
6
5
|
SUPPORT_SPOOLS,
|
|
@@ -353,8 +352,9 @@ export const getObligationAccount = async (
|
|
|
353
352
|
const collateralAssetCoinNames: SupportCollateralCoins[] = [
|
|
354
353
|
...SUPPORT_COLLATERALS,
|
|
355
354
|
];
|
|
356
|
-
|
|
357
|
-
|
|
355
|
+
market = market ?? (await query.queryMarket(indexer));
|
|
356
|
+
coinPrices =
|
|
357
|
+
coinPrices ?? (await query.getAllCoinPrices({ marketPools: market.pools }));
|
|
358
358
|
coinAmounts =
|
|
359
359
|
coinAmounts ||
|
|
360
360
|
(await query.getCoinAmounts(collateralAssetCoinNames, ownerAddress));
|
|
@@ -522,64 +522,70 @@ export const getObligationAccount = async (
|
|
|
522
522
|
const borrowIncentivePool = borrowIncentivePools[coinName];
|
|
523
523
|
if (borrowIncentivePool) {
|
|
524
524
|
const rewards: ObligationBorrowIcentiveReward[] = [];
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
.plus(accountPoint.points)
|
|
546
|
-
);
|
|
547
|
-
availableClaimCoin = availableClaimAmount.shiftedBy(
|
|
548
|
-
-1 * poolPoint.coinDecimal
|
|
549
|
-
);
|
|
550
|
-
|
|
551
|
-
// for veSCA
|
|
552
|
-
const weightScale = BigNumber(1_000_000_000_000);
|
|
553
|
-
const boostValue = BigNumber(accountPoint.weightedAmount)
|
|
554
|
-
.div(
|
|
555
|
-
BigNumber(borrowIncentiveAccount.debtAmount)
|
|
556
|
-
.multipliedBy(poolPoint.baseWeight)
|
|
557
|
-
.dividedBy(weightScale)
|
|
558
|
-
)
|
|
559
|
-
.isFinite()
|
|
560
|
-
? BigNumber(accountPoint.weightedAmount)
|
|
561
|
-
.div(
|
|
562
|
-
BigNumber(borrowIncentiveAccount.debtAmount)
|
|
563
|
-
.multipliedBy(poolPoint.baseWeight)
|
|
564
|
-
.dividedBy(weightScale)
|
|
525
|
+
Object.entries(borrowIncentiveAccount.pointList).forEach(
|
|
526
|
+
([key, accountPoint]) => {
|
|
527
|
+
const poolPoint =
|
|
528
|
+
borrowIncentivePool.points[
|
|
529
|
+
key as SupportBorrowIncentiveRewardCoins
|
|
530
|
+
];
|
|
531
|
+
|
|
532
|
+
if (accountPoint && poolPoint) {
|
|
533
|
+
let availableClaimAmount = BigNumber(0);
|
|
534
|
+
let availableClaimCoin = BigNumber(0);
|
|
535
|
+
const accountBorrowedAmount = BigNumber(
|
|
536
|
+
accountPoint.weightedAmount
|
|
537
|
+
);
|
|
538
|
+
const baseIndexRate = 1_000_000_000;
|
|
539
|
+
const increasedPointRate = poolPoint.currentPointIndex
|
|
540
|
+
? Math.max(
|
|
541
|
+
BigNumber(poolPoint.currentPointIndex - accountPoint.index)
|
|
542
|
+
.dividedBy(baseIndexRate)
|
|
543
|
+
.toNumber(),
|
|
544
|
+
0
|
|
565
545
|
)
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
546
|
+
: 1;
|
|
547
|
+
availableClaimAmount = availableClaimAmount.plus(
|
|
548
|
+
accountBorrowedAmount
|
|
549
|
+
.multipliedBy(increasedPointRate)
|
|
550
|
+
.plus(accountPoint.points)
|
|
551
|
+
);
|
|
552
|
+
availableClaimCoin = availableClaimAmount.shiftedBy(
|
|
553
|
+
-1 * poolPoint.coinDecimal
|
|
554
|
+
);
|
|
555
|
+
|
|
556
|
+
// for veSCA
|
|
557
|
+
const weightScale = BigNumber(1_000_000_000_000);
|
|
558
|
+
const boostValue = BigNumber(accountPoint.weightedAmount)
|
|
559
|
+
.div(
|
|
560
|
+
BigNumber(borrowIncentiveAccount.debtAmount)
|
|
561
|
+
.multipliedBy(poolPoint.baseWeight)
|
|
562
|
+
.dividedBy(weightScale)
|
|
563
|
+
)
|
|
564
|
+
.isFinite()
|
|
565
|
+
? BigNumber(accountPoint.weightedAmount)
|
|
566
|
+
.div(
|
|
567
|
+
BigNumber(borrowIncentiveAccount.debtAmount)
|
|
568
|
+
.multipliedBy(poolPoint.baseWeight)
|
|
569
|
+
.dividedBy(weightScale)
|
|
570
|
+
)
|
|
571
|
+
.toNumber()
|
|
572
|
+
: 1;
|
|
573
|
+
|
|
574
|
+
if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
|
|
575
|
+
rewards.push({
|
|
576
|
+
coinName: poolPoint.coinName,
|
|
577
|
+
coinType: poolPoint.coinType,
|
|
578
|
+
symbol: poolPoint.symbol,
|
|
579
|
+
coinDecimal: poolPoint.coinDecimal,
|
|
580
|
+
coinPrice: poolPoint.coinPrice,
|
|
581
|
+
availableClaimAmount: availableClaimAmount.toNumber(),
|
|
582
|
+
availableClaimCoin: availableClaimCoin.toNumber(),
|
|
583
|
+
boostValue,
|
|
584
|
+
});
|
|
585
|
+
}
|
|
580
586
|
}
|
|
581
587
|
}
|
|
582
|
-
|
|
588
|
+
);
|
|
583
589
|
|
|
584
590
|
if (
|
|
585
591
|
Object.keys(borrowIncentivePool.points).some((coinName: any) => {
|