@scallop-io/sui-scallop-sdk 0.46.31 → 0.46.33
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 +68 -67
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -67
- package/dist/index.mjs.map +1 -1
- package/dist/types/query/borrowIncentive.d.ts +3 -4
- package/dist/utils/query.d.ts +1 -1
- package/package.json +1 -1
- package/src/constants/common.ts +2 -2
- package/src/queries/borrowIncentiveQuery.ts +9 -2
- package/src/queries/portfolioQuery.ts +7 -5
- package/src/types/query/borrowIncentive.ts +3 -4
- package/src/utils/query.ts +1 -9
package/dist/index.mjs
CHANGED
|
@@ -1401,7 +1401,7 @@ var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
|
|
|
1401
1401
|
)
|
|
1402
1402
|
};
|
|
1403
1403
|
};
|
|
1404
|
-
var calculateBorrowIncentivePoolPointData = (
|
|
1404
|
+
var calculateBorrowIncentivePoolPointData = (parsedBorrowIncentivePoolData, parsedBorrowIncentivePoolPointData, rewardCoinPrice, rewardCoinDecimal, poolCoinPrice, poolCoinDecimal) => {
|
|
1405
1405
|
const baseIndexRate = 1e9;
|
|
1406
1406
|
const distributedPointPerSec = BigNumber(
|
|
1407
1407
|
parsedBorrowIncentivePoolPointData.distributedPointPerPeriod
|
|
@@ -1423,9 +1423,6 @@ var calculateBorrowIncentivePoolPointData = (pasredBorrowIncentinvePoolData, par
|
|
|
1423
1423
|
const currentTotalDistributedPoint = BigNumber(
|
|
1424
1424
|
parsedBorrowIncentivePoolPointData.distributedPoint
|
|
1425
1425
|
).plus(accumulatedPoints);
|
|
1426
|
-
const stakedAmount = BigNumber(pasredBorrowIncentinvePoolData.staked);
|
|
1427
|
-
const stakedCoin = stakedAmount.shiftedBy(-1 * poolCoinDecimal);
|
|
1428
|
-
const stakedValue = stakedCoin.multipliedBy(poolCoinPrice);
|
|
1429
1426
|
const baseWeight = BigNumber(parsedBorrowIncentivePoolPointData.baseWeight);
|
|
1430
1427
|
const weightedStakedAmount = BigNumber(
|
|
1431
1428
|
parsedBorrowIncentivePoolPointData.weightedAmount
|
|
@@ -1454,9 +1451,6 @@ var calculateBorrowIncentivePoolPointData = (pasredBorrowIncentinvePoolData, par
|
|
|
1454
1451
|
accumulatedPoints: accumulatedPoints.toNumber(),
|
|
1455
1452
|
currentPointIndex: currentPointIndex.toNumber(),
|
|
1456
1453
|
currentTotalDistributedPoint: currentTotalDistributedPoint.toNumber(),
|
|
1457
|
-
stakedAmount: stakedAmount.toNumber(),
|
|
1458
|
-
stakedCoin: stakedCoin.toNumber(),
|
|
1459
|
-
stakedValue: stakedValue.toNumber(),
|
|
1460
1454
|
baseWeight: baseWeight.toNumber(),
|
|
1461
1455
|
weightedStakedAmount: weightedStakedAmount.toNumber(),
|
|
1462
1456
|
weightedStakedCoin: weightedStakedCoin.toNumber(),
|
|
@@ -2471,6 +2465,7 @@ var getStakeRewardPool = async (query, marketCoinName) => {
|
|
|
2471
2465
|
|
|
2472
2466
|
// src/queries/borrowIncentiveQuery.ts
|
|
2473
2467
|
import { normalizeStructTag as normalizeStructTag5 } from "@mysten/sui.js/utils";
|
|
2468
|
+
import BigNumber3 from "bignumber.js";
|
|
2474
2469
|
var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer = false) => {
|
|
2475
2470
|
borrowIncentiveCoinNames = borrowIncentiveCoinNames || [
|
|
2476
2471
|
...SUPPORT_BORROW_INCENTIVE_POOLS
|
|
@@ -2545,14 +2540,19 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer
|
|
|
2545
2540
|
...calculatedPoolPoint
|
|
2546
2541
|
};
|
|
2547
2542
|
}
|
|
2543
|
+
const stakedAmount = BigNumber3(parsedBorrowIncentivePoolData.staked);
|
|
2544
|
+
const stakedCoin = stakedAmount.shiftedBy(-1 * poolCoinDecimal);
|
|
2545
|
+
const stakedValue = stakedCoin.multipliedBy(poolCoinPrice);
|
|
2548
2546
|
borrowIncentivePools[poolCoinName] = {
|
|
2549
2547
|
coinName: poolCoinName,
|
|
2550
2548
|
symbol: query.utils.parseSymbol(poolCoinName),
|
|
2551
2549
|
coinType: poolCoinType,
|
|
2552
2550
|
coinDecimal: poolCoinDecimal,
|
|
2553
2551
|
coinPrice: poolCoinPrice,
|
|
2554
|
-
|
|
2555
|
-
|
|
2552
|
+
stakedAmount: stakedAmount.toNumber(),
|
|
2553
|
+
stakedCoin: stakedCoin.toNumber(),
|
|
2554
|
+
stakedValue: stakedValue.toNumber(),
|
|
2555
|
+
points: borrowIncentivePoolPoints
|
|
2556
2556
|
};
|
|
2557
2557
|
}
|
|
2558
2558
|
return borrowIncentivePools;
|
|
@@ -2699,7 +2699,7 @@ var getPythPrices = async (query, assetCoinNames) => {
|
|
|
2699
2699
|
};
|
|
2700
2700
|
|
|
2701
2701
|
// src/queries/portfolioQuery.ts
|
|
2702
|
-
import
|
|
2702
|
+
import BigNumber4 from "bignumber.js";
|
|
2703
2703
|
var getLendings = async (query, poolCoinNames, ownerAddress, indexer = false) => {
|
|
2704
2704
|
poolCoinNames = poolCoinNames || [...SUPPORT_POOLS];
|
|
2705
2705
|
const marketCoinNames = poolCoinNames.map(
|
|
@@ -2750,18 +2750,18 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
|
|
|
2750
2750
|
marketCoinAmount = marketCoinAmount || await query.getMarketCoinAmount(marketCoinName, ownerAddress);
|
|
2751
2751
|
coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
|
|
2752
2752
|
const coinDecimal = query.utils.getCoinDecimal(poolCoinName);
|
|
2753
|
-
let stakedMarketAmount =
|
|
2754
|
-
let stakedMarketCoin =
|
|
2755
|
-
let stakedAmount =
|
|
2756
|
-
let stakedCoin =
|
|
2757
|
-
let stakedValue =
|
|
2758
|
-
let availableUnstakeAmount =
|
|
2759
|
-
let availableUnstakeCoin =
|
|
2760
|
-
let availableClaimAmount =
|
|
2761
|
-
let availableClaimCoin =
|
|
2753
|
+
let stakedMarketAmount = BigNumber4(0);
|
|
2754
|
+
let stakedMarketCoin = BigNumber4(0);
|
|
2755
|
+
let stakedAmount = BigNumber4(0);
|
|
2756
|
+
let stakedCoin = BigNumber4(0);
|
|
2757
|
+
let stakedValue = BigNumber4(0);
|
|
2758
|
+
let availableUnstakeAmount = BigNumber4(0);
|
|
2759
|
+
let availableUnstakeCoin = BigNumber4(0);
|
|
2760
|
+
let availableClaimAmount = BigNumber4(0);
|
|
2761
|
+
let availableClaimCoin = BigNumber4(0);
|
|
2762
2762
|
if (spool) {
|
|
2763
2763
|
for (const stakeAccount of stakeAccounts) {
|
|
2764
|
-
const accountStakedMarketCoinAmount =
|
|
2764
|
+
const accountStakedMarketCoinAmount = BigNumber4(stakeAccount.staked);
|
|
2765
2765
|
const accountStakedMarketCoin = accountStakedMarketCoinAmount.shiftedBy(
|
|
2766
2766
|
-1 * spool.coinDecimal
|
|
2767
2767
|
);
|
|
@@ -2788,7 +2788,7 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
|
|
|
2788
2788
|
-1 * spool.coinDecimal
|
|
2789
2789
|
);
|
|
2790
2790
|
const baseIndexRate = 1e9;
|
|
2791
|
-
const increasedPointRate = spool.currentPointIndex ?
|
|
2791
|
+
const increasedPointRate = spool.currentPointIndex ? BigNumber4(spool.currentPointIndex - stakeAccount.index).dividedBy(
|
|
2792
2792
|
baseIndexRate
|
|
2793
2793
|
) : 1;
|
|
2794
2794
|
availableClaimAmount = availableClaimAmount.plus(
|
|
@@ -2799,17 +2799,17 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
|
|
|
2799
2799
|
);
|
|
2800
2800
|
}
|
|
2801
2801
|
}
|
|
2802
|
-
const suppliedAmount =
|
|
2802
|
+
const suppliedAmount = BigNumber4(marketCoinAmount).multipliedBy(
|
|
2803
2803
|
marketPool?.conversionRate ?? 1
|
|
2804
2804
|
);
|
|
2805
2805
|
const suppliedCoin = suppliedAmount.shiftedBy(-1 * coinDecimal);
|
|
2806
2806
|
const suppliedValue = suppliedCoin.multipliedBy(coinPrice ?? 0);
|
|
2807
|
-
const marketCoinPrice =
|
|
2807
|
+
const marketCoinPrice = BigNumber4(coinPrice ?? 0).multipliedBy(
|
|
2808
2808
|
marketPool?.conversionRate ?? 1
|
|
2809
2809
|
);
|
|
2810
|
-
const unstakedMarketAmount =
|
|
2810
|
+
const unstakedMarketAmount = BigNumber4(marketCoinAmount);
|
|
2811
2811
|
const unstakedMarketCoin = unstakedMarketAmount.shiftedBy(-1 * coinDecimal);
|
|
2812
|
-
const availableSupplyAmount =
|
|
2812
|
+
const availableSupplyAmount = BigNumber4(coinAmount);
|
|
2813
2813
|
const availableSupplyCoin = availableSupplyAmount.shiftedBy(-1 * coinDecimal);
|
|
2814
2814
|
const availableWithdrawAmount = minBigNumber(
|
|
2815
2815
|
suppliedAmount,
|
|
@@ -2899,12 +2899,12 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
2899
2899
|
const debts = {};
|
|
2900
2900
|
const borrowIncentives = {};
|
|
2901
2901
|
let totalDepositedPools = 0;
|
|
2902
|
-
let totalDepositedValue =
|
|
2903
|
-
let totalBorrowCapacityValue =
|
|
2904
|
-
let totalRequiredCollateralValue =
|
|
2902
|
+
let totalDepositedValue = BigNumber4(0);
|
|
2903
|
+
let totalBorrowCapacityValue = BigNumber4(0);
|
|
2904
|
+
let totalRequiredCollateralValue = BigNumber4(0);
|
|
2905
2905
|
let totalBorrowedPools = 0;
|
|
2906
|
-
let totalBorrowedValue =
|
|
2907
|
-
let totalBorrowedValueWithWeight =
|
|
2906
|
+
let totalBorrowedValue = BigNumber4(0);
|
|
2907
|
+
let totalBorrowedValueWithWeight = BigNumber4(0);
|
|
2908
2908
|
for (const assetCoinName of collateralAssetCoinNames) {
|
|
2909
2909
|
const collateral = obligationQuery.collaterals.find((collateral2) => {
|
|
2910
2910
|
const collateralCoinName = query.utils.parseCoinNameFromType(
|
|
@@ -2917,7 +2917,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
2917
2917
|
const coinPrice = coinPrices?.[assetCoinName];
|
|
2918
2918
|
const coinAmount = coinAmounts?.[assetCoinName] ?? 0;
|
|
2919
2919
|
if (marketCollateral && coinPrice) {
|
|
2920
|
-
const depositedAmount =
|
|
2920
|
+
const depositedAmount = BigNumber4(collateral?.amount ?? 0);
|
|
2921
2921
|
const depositedCoin = depositedAmount.shiftedBy(-1 * coinDecimal);
|
|
2922
2922
|
const depositedValue = depositedCoin.multipliedBy(coinPrice);
|
|
2923
2923
|
const borrowCapacityValue = depositedValue.multipliedBy(
|
|
@@ -2926,11 +2926,11 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
2926
2926
|
const requiredCollateralValue2 = depositedValue.multipliedBy(
|
|
2927
2927
|
marketCollateral.liquidationFactor
|
|
2928
2928
|
);
|
|
2929
|
-
const poolSizeAmount =
|
|
2929
|
+
const poolSizeAmount = BigNumber4(marketCollateral.maxDepositAmount).minus(
|
|
2930
2930
|
marketCollateral.depositAmount
|
|
2931
2931
|
);
|
|
2932
2932
|
const availableDepositAmount = minBigNumber(
|
|
2933
|
-
|
|
2933
|
+
BigNumber4(coinAmount),
|
|
2934
2934
|
poolSizeAmount
|
|
2935
2935
|
);
|
|
2936
2936
|
const availableDepositCoin = availableDepositAmount.shiftedBy(
|
|
@@ -2978,13 +2978,13 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
2978
2978
|
const coinAmount = coinAmounts?.[assetCoinName] ?? 0;
|
|
2979
2979
|
if (marketPool && coinPrice) {
|
|
2980
2980
|
const increasedRate = debt?.borrowIndex ? marketPool.borrowIndex / Number(debt.borrowIndex) - 1 : 0;
|
|
2981
|
-
const borrowedAmount =
|
|
2981
|
+
const borrowedAmount = BigNumber4(debt?.amount ?? 0);
|
|
2982
2982
|
const borrowedCoin = borrowedAmount.shiftedBy(-1 * coinDecimal);
|
|
2983
2983
|
const requiredRepayAmount = borrowedAmount.multipliedBy(
|
|
2984
2984
|
increasedRate + 1
|
|
2985
2985
|
);
|
|
2986
2986
|
const requiredRepayCoin = requiredRepayAmount.shiftedBy(-1 * coinDecimal);
|
|
2987
|
-
const availableRepayAmount =
|
|
2987
|
+
const availableRepayAmount = BigNumber4(coinAmount);
|
|
2988
2988
|
const availableRepayCoin = availableRepayAmount.shiftedBy(
|
|
2989
2989
|
-1 * coinDecimal
|
|
2990
2990
|
);
|
|
@@ -3030,26 +3030,27 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3030
3030
|
const accountPoint = borrowIncentiveAccount.pointList[rewardCoinName];
|
|
3031
3031
|
const poolPoint = borrowIncentivePool.points[rewardCoinName];
|
|
3032
3032
|
if (accountPoint && poolPoint) {
|
|
3033
|
-
let availableClaimAmount =
|
|
3034
|
-
let availableClaimCoin =
|
|
3035
|
-
const accountBorrowedAmount =
|
|
3033
|
+
let availableClaimAmount = BigNumber4(0);
|
|
3034
|
+
let availableClaimCoin = BigNumber4(0);
|
|
3035
|
+
const accountBorrowedAmount = BigNumber4(accountPoint.weightedAmount);
|
|
3036
3036
|
const baseIndexRate = 1e9;
|
|
3037
|
-
const increasedPointRate = poolPoint.currentPointIndex ?
|
|
3038
|
-
poolPoint.currentPointIndex - accountPoint.index
|
|
3039
|
-
|
|
3037
|
+
const increasedPointRate = poolPoint.currentPointIndex ? Math.max(
|
|
3038
|
+
BigNumber4(poolPoint.currentPointIndex - accountPoint.index).dividedBy(baseIndexRate).toNumber(),
|
|
3039
|
+
0
|
|
3040
|
+
) : 1;
|
|
3040
3041
|
availableClaimAmount = availableClaimAmount.plus(
|
|
3041
3042
|
accountBorrowedAmount.multipliedBy(increasedPointRate).plus(accountPoint.points)
|
|
3042
3043
|
);
|
|
3043
3044
|
availableClaimCoin = availableClaimAmount.shiftedBy(
|
|
3044
3045
|
-1 * poolPoint.coinDecimal
|
|
3045
3046
|
);
|
|
3046
|
-
const weightScale =
|
|
3047
|
-
const boostValue =
|
|
3048
|
-
|
|
3049
|
-
).isFinite() ?
|
|
3050
|
-
|
|
3047
|
+
const weightScale = BigNumber4(1e12);
|
|
3048
|
+
const boostValue = BigNumber4(accountPoint.weightedAmount).div(
|
|
3049
|
+
BigNumber4(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
|
|
3050
|
+
).isFinite() ? BigNumber4(accountPoint.weightedAmount).div(
|
|
3051
|
+
BigNumber4(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
|
|
3051
3052
|
).toNumber() : 1;
|
|
3052
|
-
if (availableClaimAmount.
|
|
3053
|
+
if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
|
|
3053
3054
|
rewards.push({
|
|
3054
3055
|
coinName: poolPoint.coinName,
|
|
3055
3056
|
coinType: poolPoint.coinType,
|
|
@@ -3073,12 +3074,12 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3073
3074
|
};
|
|
3074
3075
|
}
|
|
3075
3076
|
}
|
|
3076
|
-
let riskLevel = totalRequiredCollateralValue.isZero() ?
|
|
3077
|
-
riskLevel = riskLevel.isLessThan(1) ? riskLevel :
|
|
3078
|
-
const accountBalanceValue = totalDepositedValue.minus(totalBorrowedValue).isGreaterThan(0) ? totalDepositedValue.minus(totalBorrowedValue) :
|
|
3079
|
-
const availableCollateralValue = totalBorrowCapacityValue.minus(totalBorrowedValueWithWeight).isGreaterThan(0) ? totalBorrowCapacityValue.minus(totalBorrowedValueWithWeight) :
|
|
3080
|
-
const requiredCollateralValue = totalBorrowedValueWithWeight.isGreaterThan(0) ? totalRequiredCollateralValue :
|
|
3081
|
-
const unhealthyCollateralValue = totalBorrowedValueWithWeight.minus(requiredCollateralValue).isGreaterThan(0) ? totalBorrowedValueWithWeight.minus(requiredCollateralValue) :
|
|
3077
|
+
let riskLevel = totalRequiredCollateralValue.isZero() ? BigNumber4(0) : totalBorrowedValueWithWeight.dividedBy(totalRequiredCollateralValue);
|
|
3078
|
+
riskLevel = riskLevel.isLessThan(1) ? riskLevel : BigNumber4(1);
|
|
3079
|
+
const accountBalanceValue = totalDepositedValue.minus(totalBorrowedValue).isGreaterThan(0) ? totalDepositedValue.minus(totalBorrowedValue) : BigNumber4(0);
|
|
3080
|
+
const availableCollateralValue = totalBorrowCapacityValue.minus(totalBorrowedValueWithWeight).isGreaterThan(0) ? totalBorrowCapacityValue.minus(totalBorrowedValueWithWeight) : BigNumber4(0);
|
|
3081
|
+
const requiredCollateralValue = totalBorrowedValueWithWeight.isGreaterThan(0) ? totalRequiredCollateralValue : BigNumber4(0);
|
|
3082
|
+
const unhealthyCollateralValue = totalBorrowedValueWithWeight.minus(requiredCollateralValue).isGreaterThan(0) ? totalBorrowedValueWithWeight.minus(requiredCollateralValue) : BigNumber4(0);
|
|
3082
3083
|
const obligationAccount = {
|
|
3083
3084
|
obligationId,
|
|
3084
3085
|
// Deposited collateral value (collateral balance)
|
|
@@ -3109,16 +3110,16 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3109
3110
|
)) {
|
|
3110
3111
|
const marketCollateral = market.collaterals[collateralCoinName];
|
|
3111
3112
|
if (marketCollateral) {
|
|
3112
|
-
let estimatedAvailableWithdrawAmount =
|
|
3113
|
+
let estimatedAvailableWithdrawAmount = BigNumber4(
|
|
3113
3114
|
obligationAccount.totalAvailableCollateralValue
|
|
3114
3115
|
).dividedBy(marketCollateral.collateralFactor).dividedBy(marketCollateral.coinPrice).shiftedBy(marketCollateral.coinDecimal);
|
|
3115
3116
|
estimatedAvailableWithdrawAmount = obligationAccount.totalBorrowedValueWithWeight === 0 ? (
|
|
3116
3117
|
// Note: when there is no debt record, there is no need to estimate and the deposited amount is directly used as available withdraw.
|
|
3117
|
-
|
|
3118
|
+
BigNumber4(obligationCollateral.depositedAmount)
|
|
3118
3119
|
) : minBigNumber(
|
|
3119
3120
|
estimatedAvailableWithdrawAmount.multipliedBy(
|
|
3120
3121
|
estimatedFactor(
|
|
3121
|
-
|
|
3122
|
+
BigNumber4(obligationAccount.totalAvailableCollateralValue).dividedBy(marketCollateral.collateralFactor).toNumber(),
|
|
3122
3123
|
3,
|
|
3123
3124
|
"increase"
|
|
3124
3125
|
)
|
|
@@ -3135,12 +3136,12 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3135
3136
|
)) {
|
|
3136
3137
|
const marketPool = market.pools[poolCoinName];
|
|
3137
3138
|
if (marketPool) {
|
|
3138
|
-
const estimatedRequiredRepayAmount =
|
|
3139
|
+
const estimatedRequiredRepayAmount = BigNumber4(
|
|
3139
3140
|
obligationDebt.requiredRepayAmount
|
|
3140
3141
|
).multipliedBy(
|
|
3141
3142
|
estimatedFactor(obligationDebt.borrowedValue, 3, "decrease")
|
|
3142
3143
|
);
|
|
3143
|
-
let estimatedAvailableBorrowAmount =
|
|
3144
|
+
let estimatedAvailableBorrowAmount = BigNumber4(
|
|
3144
3145
|
obligationAccount.totalAvailableCollateralValue
|
|
3145
3146
|
).dividedBy(marketPool.borrowWeight).shiftedBy(marketPool.coinDecimal).dividedBy(marketPool.coinPrice);
|
|
3146
3147
|
estimatedAvailableBorrowAmount = obligationAccount.totalAvailableCollateralValue !== 0 ? minBigNumber(
|
|
@@ -3152,7 +3153,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3152
3153
|
)
|
|
3153
3154
|
).toNumber(),
|
|
3154
3155
|
marketPool.supplyAmount
|
|
3155
|
-
) :
|
|
3156
|
+
) : BigNumber4(0);
|
|
3156
3157
|
obligationDebt.availableBorrowAmount = estimatedAvailableBorrowAmount.toNumber();
|
|
3157
3158
|
obligationDebt.availableBorrowCoin = estimatedAvailableBorrowAmount.shiftedBy(-1 * obligationDebt.coinDecimal).toNumber();
|
|
3158
3159
|
obligationDebt.requiredRepayAmount = estimatedRequiredRepayAmount.toNumber();
|
|
@@ -3163,8 +3164,8 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3163
3164
|
};
|
|
3164
3165
|
var getTotalValueLocked = async (query, indexer = false) => {
|
|
3165
3166
|
const market = await query.queryMarket(indexer);
|
|
3166
|
-
let supplyValue =
|
|
3167
|
-
let borrowValue =
|
|
3167
|
+
let supplyValue = BigNumber4(0);
|
|
3168
|
+
let borrowValue = BigNumber4(0);
|
|
3168
3169
|
if (indexer) {
|
|
3169
3170
|
const tvlIndexer = await query.indexer.getTotalValueLocked();
|
|
3170
3171
|
const tvl2 = {
|
|
@@ -3179,15 +3180,15 @@ var getTotalValueLocked = async (query, indexer = false) => {
|
|
|
3179
3180
|
}
|
|
3180
3181
|
for (const pool of Object.values(market.pools)) {
|
|
3181
3182
|
supplyValue = supplyValue.plus(
|
|
3182
|
-
|
|
3183
|
+
BigNumber4(pool.supplyCoin).multipliedBy(pool.coinPrice)
|
|
3183
3184
|
);
|
|
3184
3185
|
borrowValue = borrowValue.plus(
|
|
3185
|
-
|
|
3186
|
+
BigNumber4(pool.borrowCoin).multipliedBy(pool.coinPrice)
|
|
3186
3187
|
);
|
|
3187
3188
|
}
|
|
3188
3189
|
for (const collateral of Object.values(market.collaterals)) {
|
|
3189
3190
|
supplyValue = supplyValue.plus(
|
|
3190
|
-
|
|
3191
|
+
BigNumber4(collateral.depositCoin).multipliedBy(collateral.coinPrice)
|
|
3191
3192
|
);
|
|
3192
3193
|
}
|
|
3193
3194
|
const tvl = {
|
|
@@ -3199,7 +3200,7 @@ var getTotalValueLocked = async (query, indexer = false) => {
|
|
|
3199
3200
|
};
|
|
3200
3201
|
|
|
3201
3202
|
// src/queries/vescaQuery.ts
|
|
3202
|
-
import
|
|
3203
|
+
import BigNumber5 from "bignumber.js";
|
|
3203
3204
|
import { SUI_CLOCK_OBJECT_ID, SuiTxBlock as SuiTxBlock2 } from "@scallop-io/sui-kit";
|
|
3204
3205
|
import { bcs } from "@mysten/sui.js/bcs";
|
|
3205
3206
|
var getVescaKeys = async (query, ownerAddress) => {
|
|
@@ -3260,7 +3261,7 @@ var getVeSca = async (query, veScaKeyId, ownerAddress) => {
|
|
|
3260
3261
|
0
|
|
3261
3262
|
);
|
|
3262
3263
|
const lockedScaAmount = String(dynamicFields.locked_sca_amount);
|
|
3263
|
-
const lockedScaCoin =
|
|
3264
|
+
const lockedScaCoin = BigNumber5(dynamicFields.locked_sca_amount).shiftedBy(-9).toNumber();
|
|
3264
3265
|
const currentVeScaBalance = lockedScaCoin * (Math.floor(remainingLockPeriodInMilliseconds / 1e3) / MAX_LOCK_DURATION);
|
|
3265
3266
|
vesca = {
|
|
3266
3267
|
id: veScaDynamicFieldObject.objectId,
|
|
@@ -3268,7 +3269,7 @@ var getVeSca = async (query, veScaKeyId, ownerAddress) => {
|
|
|
3268
3269
|
lockedScaAmount,
|
|
3269
3270
|
lockedScaCoin,
|
|
3270
3271
|
currentVeScaBalance,
|
|
3271
|
-
unlockAt:
|
|
3272
|
+
unlockAt: BigNumber5(dynamicFields.unlock_at * 1e3).toNumber()
|
|
3272
3273
|
};
|
|
3273
3274
|
}
|
|
3274
3275
|
return vesca;
|