@scallop-io/sui-scallop-sdk 0.46.31 → 0.46.32
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 +64 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +64 -64
- 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/queries/borrowIncentiveQuery.ts +9 -2
- package/src/types/query/borrowIncentive.ts +3 -4
- package/src/utils/query.ts +1 -9
package/dist/index.js
CHANGED
|
@@ -1474,7 +1474,7 @@ var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
|
|
|
1474
1474
|
)
|
|
1475
1475
|
};
|
|
1476
1476
|
};
|
|
1477
|
-
var calculateBorrowIncentivePoolPointData = (
|
|
1477
|
+
var calculateBorrowIncentivePoolPointData = (parsedBorrowIncentivePoolData, parsedBorrowIncentivePoolPointData, rewardCoinPrice, rewardCoinDecimal, poolCoinPrice, poolCoinDecimal) => {
|
|
1478
1478
|
const baseIndexRate = 1e9;
|
|
1479
1479
|
const distributedPointPerSec = (0, import_bignumber.default)(
|
|
1480
1480
|
parsedBorrowIncentivePoolPointData.distributedPointPerPeriod
|
|
@@ -1496,9 +1496,6 @@ var calculateBorrowIncentivePoolPointData = (pasredBorrowIncentinvePoolData, par
|
|
|
1496
1496
|
const currentTotalDistributedPoint = (0, import_bignumber.default)(
|
|
1497
1497
|
parsedBorrowIncentivePoolPointData.distributedPoint
|
|
1498
1498
|
).plus(accumulatedPoints);
|
|
1499
|
-
const stakedAmount = (0, import_bignumber.default)(pasredBorrowIncentinvePoolData.staked);
|
|
1500
|
-
const stakedCoin = stakedAmount.shiftedBy(-1 * poolCoinDecimal);
|
|
1501
|
-
const stakedValue = stakedCoin.multipliedBy(poolCoinPrice);
|
|
1502
1499
|
const baseWeight = (0, import_bignumber.default)(parsedBorrowIncentivePoolPointData.baseWeight);
|
|
1503
1500
|
const weightedStakedAmount = (0, import_bignumber.default)(
|
|
1504
1501
|
parsedBorrowIncentivePoolPointData.weightedAmount
|
|
@@ -1527,9 +1524,6 @@ var calculateBorrowIncentivePoolPointData = (pasredBorrowIncentinvePoolData, par
|
|
|
1527
1524
|
accumulatedPoints: accumulatedPoints.toNumber(),
|
|
1528
1525
|
currentPointIndex: currentPointIndex.toNumber(),
|
|
1529
1526
|
currentTotalDistributedPoint: currentTotalDistributedPoint.toNumber(),
|
|
1530
|
-
stakedAmount: stakedAmount.toNumber(),
|
|
1531
|
-
stakedCoin: stakedCoin.toNumber(),
|
|
1532
|
-
stakedValue: stakedValue.toNumber(),
|
|
1533
1527
|
baseWeight: baseWeight.toNumber(),
|
|
1534
1528
|
weightedStakedAmount: weightedStakedAmount.toNumber(),
|
|
1535
1529
|
weightedStakedCoin: weightedStakedCoin.toNumber(),
|
|
@@ -2544,6 +2538,7 @@ var getStakeRewardPool = async (query, marketCoinName) => {
|
|
|
2544
2538
|
|
|
2545
2539
|
// src/queries/borrowIncentiveQuery.ts
|
|
2546
2540
|
var import_utils6 = require("@mysten/sui.js/utils");
|
|
2541
|
+
var import_bignumber3 = __toESM(require("bignumber.js"));
|
|
2547
2542
|
var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer = false) => {
|
|
2548
2543
|
borrowIncentiveCoinNames = borrowIncentiveCoinNames || [
|
|
2549
2544
|
...SUPPORT_BORROW_INCENTIVE_POOLS
|
|
@@ -2618,14 +2613,19 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer
|
|
|
2618
2613
|
...calculatedPoolPoint
|
|
2619
2614
|
};
|
|
2620
2615
|
}
|
|
2616
|
+
const stakedAmount = (0, import_bignumber3.default)(parsedBorrowIncentivePoolData.staked);
|
|
2617
|
+
const stakedCoin = stakedAmount.shiftedBy(-1 * poolCoinDecimal);
|
|
2618
|
+
const stakedValue = stakedCoin.multipliedBy(poolCoinPrice);
|
|
2621
2619
|
borrowIncentivePools[poolCoinName] = {
|
|
2622
2620
|
coinName: poolCoinName,
|
|
2623
2621
|
symbol: query.utils.parseSymbol(poolCoinName),
|
|
2624
2622
|
coinType: poolCoinType,
|
|
2625
2623
|
coinDecimal: poolCoinDecimal,
|
|
2626
2624
|
coinPrice: poolCoinPrice,
|
|
2627
|
-
|
|
2628
|
-
|
|
2625
|
+
stakedAmount: stakedAmount.toNumber(),
|
|
2626
|
+
stakedCoin: stakedCoin.toNumber(),
|
|
2627
|
+
stakedValue: stakedValue.toNumber(),
|
|
2628
|
+
points: borrowIncentivePoolPoints
|
|
2629
2629
|
};
|
|
2630
2630
|
}
|
|
2631
2631
|
return borrowIncentivePools;
|
|
@@ -2772,7 +2772,7 @@ var getPythPrices = async (query, assetCoinNames) => {
|
|
|
2772
2772
|
};
|
|
2773
2773
|
|
|
2774
2774
|
// src/queries/portfolioQuery.ts
|
|
2775
|
-
var
|
|
2775
|
+
var import_bignumber4 = __toESM(require("bignumber.js"));
|
|
2776
2776
|
var getLendings = async (query, poolCoinNames, ownerAddress, indexer = false) => {
|
|
2777
2777
|
poolCoinNames = poolCoinNames || [...SUPPORT_POOLS];
|
|
2778
2778
|
const marketCoinNames = poolCoinNames.map(
|
|
@@ -2823,18 +2823,18 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
|
|
|
2823
2823
|
marketCoinAmount = marketCoinAmount || await query.getMarketCoinAmount(marketCoinName, ownerAddress);
|
|
2824
2824
|
coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
|
|
2825
2825
|
const coinDecimal = query.utils.getCoinDecimal(poolCoinName);
|
|
2826
|
-
let stakedMarketAmount = (0,
|
|
2827
|
-
let stakedMarketCoin = (0,
|
|
2828
|
-
let stakedAmount = (0,
|
|
2829
|
-
let stakedCoin = (0,
|
|
2830
|
-
let stakedValue = (0,
|
|
2831
|
-
let availableUnstakeAmount = (0,
|
|
2832
|
-
let availableUnstakeCoin = (0,
|
|
2833
|
-
let availableClaimAmount = (0,
|
|
2834
|
-
let availableClaimCoin = (0,
|
|
2826
|
+
let stakedMarketAmount = (0, import_bignumber4.default)(0);
|
|
2827
|
+
let stakedMarketCoin = (0, import_bignumber4.default)(0);
|
|
2828
|
+
let stakedAmount = (0, import_bignumber4.default)(0);
|
|
2829
|
+
let stakedCoin = (0, import_bignumber4.default)(0);
|
|
2830
|
+
let stakedValue = (0, import_bignumber4.default)(0);
|
|
2831
|
+
let availableUnstakeAmount = (0, import_bignumber4.default)(0);
|
|
2832
|
+
let availableUnstakeCoin = (0, import_bignumber4.default)(0);
|
|
2833
|
+
let availableClaimAmount = (0, import_bignumber4.default)(0);
|
|
2834
|
+
let availableClaimCoin = (0, import_bignumber4.default)(0);
|
|
2835
2835
|
if (spool) {
|
|
2836
2836
|
for (const stakeAccount of stakeAccounts) {
|
|
2837
|
-
const accountStakedMarketCoinAmount = (0,
|
|
2837
|
+
const accountStakedMarketCoinAmount = (0, import_bignumber4.default)(stakeAccount.staked);
|
|
2838
2838
|
const accountStakedMarketCoin = accountStakedMarketCoinAmount.shiftedBy(
|
|
2839
2839
|
-1 * spool.coinDecimal
|
|
2840
2840
|
);
|
|
@@ -2861,7 +2861,7 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
|
|
|
2861
2861
|
-1 * spool.coinDecimal
|
|
2862
2862
|
);
|
|
2863
2863
|
const baseIndexRate = 1e9;
|
|
2864
|
-
const increasedPointRate = spool.currentPointIndex ? (0,
|
|
2864
|
+
const increasedPointRate = spool.currentPointIndex ? (0, import_bignumber4.default)(spool.currentPointIndex - stakeAccount.index).dividedBy(
|
|
2865
2865
|
baseIndexRate
|
|
2866
2866
|
) : 1;
|
|
2867
2867
|
availableClaimAmount = availableClaimAmount.plus(
|
|
@@ -2872,17 +2872,17 @@ var getLending = async (query, poolCoinName, ownerAddress, indexer = false, mark
|
|
|
2872
2872
|
);
|
|
2873
2873
|
}
|
|
2874
2874
|
}
|
|
2875
|
-
const suppliedAmount = (0,
|
|
2875
|
+
const suppliedAmount = (0, import_bignumber4.default)(marketCoinAmount).multipliedBy(
|
|
2876
2876
|
marketPool?.conversionRate ?? 1
|
|
2877
2877
|
);
|
|
2878
2878
|
const suppliedCoin = suppliedAmount.shiftedBy(-1 * coinDecimal);
|
|
2879
2879
|
const suppliedValue = suppliedCoin.multipliedBy(coinPrice ?? 0);
|
|
2880
|
-
const marketCoinPrice = (0,
|
|
2880
|
+
const marketCoinPrice = (0, import_bignumber4.default)(coinPrice ?? 0).multipliedBy(
|
|
2881
2881
|
marketPool?.conversionRate ?? 1
|
|
2882
2882
|
);
|
|
2883
|
-
const unstakedMarketAmount = (0,
|
|
2883
|
+
const unstakedMarketAmount = (0, import_bignumber4.default)(marketCoinAmount);
|
|
2884
2884
|
const unstakedMarketCoin = unstakedMarketAmount.shiftedBy(-1 * coinDecimal);
|
|
2885
|
-
const availableSupplyAmount = (0,
|
|
2885
|
+
const availableSupplyAmount = (0, import_bignumber4.default)(coinAmount);
|
|
2886
2886
|
const availableSupplyCoin = availableSupplyAmount.shiftedBy(-1 * coinDecimal);
|
|
2887
2887
|
const availableWithdrawAmount = minBigNumber(
|
|
2888
2888
|
suppliedAmount,
|
|
@@ -2972,12 +2972,12 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
2972
2972
|
const debts = {};
|
|
2973
2973
|
const borrowIncentives = {};
|
|
2974
2974
|
let totalDepositedPools = 0;
|
|
2975
|
-
let totalDepositedValue = (0,
|
|
2976
|
-
let totalBorrowCapacityValue = (0,
|
|
2977
|
-
let totalRequiredCollateralValue = (0,
|
|
2975
|
+
let totalDepositedValue = (0, import_bignumber4.default)(0);
|
|
2976
|
+
let totalBorrowCapacityValue = (0, import_bignumber4.default)(0);
|
|
2977
|
+
let totalRequiredCollateralValue = (0, import_bignumber4.default)(0);
|
|
2978
2978
|
let totalBorrowedPools = 0;
|
|
2979
|
-
let totalBorrowedValue = (0,
|
|
2980
|
-
let totalBorrowedValueWithWeight = (0,
|
|
2979
|
+
let totalBorrowedValue = (0, import_bignumber4.default)(0);
|
|
2980
|
+
let totalBorrowedValueWithWeight = (0, import_bignumber4.default)(0);
|
|
2981
2981
|
for (const assetCoinName of collateralAssetCoinNames) {
|
|
2982
2982
|
const collateral = obligationQuery.collaterals.find((collateral2) => {
|
|
2983
2983
|
const collateralCoinName = query.utils.parseCoinNameFromType(
|
|
@@ -2990,7 +2990,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
2990
2990
|
const coinPrice = coinPrices?.[assetCoinName];
|
|
2991
2991
|
const coinAmount = coinAmounts?.[assetCoinName] ?? 0;
|
|
2992
2992
|
if (marketCollateral && coinPrice) {
|
|
2993
|
-
const depositedAmount = (0,
|
|
2993
|
+
const depositedAmount = (0, import_bignumber4.default)(collateral?.amount ?? 0);
|
|
2994
2994
|
const depositedCoin = depositedAmount.shiftedBy(-1 * coinDecimal);
|
|
2995
2995
|
const depositedValue = depositedCoin.multipliedBy(coinPrice);
|
|
2996
2996
|
const borrowCapacityValue = depositedValue.multipliedBy(
|
|
@@ -2999,11 +2999,11 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
2999
2999
|
const requiredCollateralValue2 = depositedValue.multipliedBy(
|
|
3000
3000
|
marketCollateral.liquidationFactor
|
|
3001
3001
|
);
|
|
3002
|
-
const poolSizeAmount = (0,
|
|
3002
|
+
const poolSizeAmount = (0, import_bignumber4.default)(marketCollateral.maxDepositAmount).minus(
|
|
3003
3003
|
marketCollateral.depositAmount
|
|
3004
3004
|
);
|
|
3005
3005
|
const availableDepositAmount = minBigNumber(
|
|
3006
|
-
(0,
|
|
3006
|
+
(0, import_bignumber4.default)(coinAmount),
|
|
3007
3007
|
poolSizeAmount
|
|
3008
3008
|
);
|
|
3009
3009
|
const availableDepositCoin = availableDepositAmount.shiftedBy(
|
|
@@ -3051,13 +3051,13 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3051
3051
|
const coinAmount = coinAmounts?.[assetCoinName] ?? 0;
|
|
3052
3052
|
if (marketPool && coinPrice) {
|
|
3053
3053
|
const increasedRate = debt?.borrowIndex ? marketPool.borrowIndex / Number(debt.borrowIndex) - 1 : 0;
|
|
3054
|
-
const borrowedAmount = (0,
|
|
3054
|
+
const borrowedAmount = (0, import_bignumber4.default)(debt?.amount ?? 0);
|
|
3055
3055
|
const borrowedCoin = borrowedAmount.shiftedBy(-1 * coinDecimal);
|
|
3056
3056
|
const requiredRepayAmount = borrowedAmount.multipliedBy(
|
|
3057
3057
|
increasedRate + 1
|
|
3058
3058
|
);
|
|
3059
3059
|
const requiredRepayCoin = requiredRepayAmount.shiftedBy(-1 * coinDecimal);
|
|
3060
|
-
const availableRepayAmount = (0,
|
|
3060
|
+
const availableRepayAmount = (0, import_bignumber4.default)(coinAmount);
|
|
3061
3061
|
const availableRepayCoin = availableRepayAmount.shiftedBy(
|
|
3062
3062
|
-1 * coinDecimal
|
|
3063
3063
|
);
|
|
@@ -3103,11 +3103,11 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3103
3103
|
const accountPoint = borrowIncentiveAccount.pointList[rewardCoinName];
|
|
3104
3104
|
const poolPoint = borrowIncentivePool.points[rewardCoinName];
|
|
3105
3105
|
if (accountPoint && poolPoint) {
|
|
3106
|
-
let availableClaimAmount = (0,
|
|
3107
|
-
let availableClaimCoin = (0,
|
|
3108
|
-
const accountBorrowedAmount = (0,
|
|
3106
|
+
let availableClaimAmount = (0, import_bignumber4.default)(0);
|
|
3107
|
+
let availableClaimCoin = (0, import_bignumber4.default)(0);
|
|
3108
|
+
const accountBorrowedAmount = (0, import_bignumber4.default)(accountPoint.weightedAmount);
|
|
3109
3109
|
const baseIndexRate = 1e9;
|
|
3110
|
-
const increasedPointRate = poolPoint.currentPointIndex ? (0,
|
|
3110
|
+
const increasedPointRate = poolPoint.currentPointIndex ? (0, import_bignumber4.default)(
|
|
3111
3111
|
poolPoint.currentPointIndex - accountPoint.index
|
|
3112
3112
|
).dividedBy(baseIndexRate) : 1;
|
|
3113
3113
|
availableClaimAmount = availableClaimAmount.plus(
|
|
@@ -3116,11 +3116,11 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3116
3116
|
availableClaimCoin = availableClaimAmount.shiftedBy(
|
|
3117
3117
|
-1 * poolPoint.coinDecimal
|
|
3118
3118
|
);
|
|
3119
|
-
const weightScale = (0,
|
|
3120
|
-
const boostValue = (0,
|
|
3121
|
-
(0,
|
|
3122
|
-
).isFinite() ? (0,
|
|
3123
|
-
(0,
|
|
3119
|
+
const weightScale = (0, import_bignumber4.default)(1e12);
|
|
3120
|
+
const boostValue = (0, import_bignumber4.default)(accountPoint.weightedAmount).div(
|
|
3121
|
+
(0, import_bignumber4.default)(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
|
|
3122
|
+
).isFinite() ? (0, import_bignumber4.default)(accountPoint.weightedAmount).div(
|
|
3123
|
+
(0, import_bignumber4.default)(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
|
|
3124
3124
|
).toNumber() : 1;
|
|
3125
3125
|
if (availableClaimAmount.isGreaterThan(0)) {
|
|
3126
3126
|
rewards.push({
|
|
@@ -3146,12 +3146,12 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3146
3146
|
};
|
|
3147
3147
|
}
|
|
3148
3148
|
}
|
|
3149
|
-
let riskLevel = totalRequiredCollateralValue.isZero() ? (0,
|
|
3150
|
-
riskLevel = riskLevel.isLessThan(1) ? riskLevel : (0,
|
|
3151
|
-
const accountBalanceValue = totalDepositedValue.minus(totalBorrowedValue).isGreaterThan(0) ? totalDepositedValue.minus(totalBorrowedValue) : (0,
|
|
3152
|
-
const availableCollateralValue = totalBorrowCapacityValue.minus(totalBorrowedValueWithWeight).isGreaterThan(0) ? totalBorrowCapacityValue.minus(totalBorrowedValueWithWeight) : (0,
|
|
3153
|
-
const requiredCollateralValue = totalBorrowedValueWithWeight.isGreaterThan(0) ? totalRequiredCollateralValue : (0,
|
|
3154
|
-
const unhealthyCollateralValue = totalBorrowedValueWithWeight.minus(requiredCollateralValue).isGreaterThan(0) ? totalBorrowedValueWithWeight.minus(requiredCollateralValue) : (0,
|
|
3149
|
+
let riskLevel = totalRequiredCollateralValue.isZero() ? (0, import_bignumber4.default)(0) : totalBorrowedValueWithWeight.dividedBy(totalRequiredCollateralValue);
|
|
3150
|
+
riskLevel = riskLevel.isLessThan(1) ? riskLevel : (0, import_bignumber4.default)(1);
|
|
3151
|
+
const accountBalanceValue = totalDepositedValue.minus(totalBorrowedValue).isGreaterThan(0) ? totalDepositedValue.minus(totalBorrowedValue) : (0, import_bignumber4.default)(0);
|
|
3152
|
+
const availableCollateralValue = totalBorrowCapacityValue.minus(totalBorrowedValueWithWeight).isGreaterThan(0) ? totalBorrowCapacityValue.minus(totalBorrowedValueWithWeight) : (0, import_bignumber4.default)(0);
|
|
3153
|
+
const requiredCollateralValue = totalBorrowedValueWithWeight.isGreaterThan(0) ? totalRequiredCollateralValue : (0, import_bignumber4.default)(0);
|
|
3154
|
+
const unhealthyCollateralValue = totalBorrowedValueWithWeight.minus(requiredCollateralValue).isGreaterThan(0) ? totalBorrowedValueWithWeight.minus(requiredCollateralValue) : (0, import_bignumber4.default)(0);
|
|
3155
3155
|
const obligationAccount = {
|
|
3156
3156
|
obligationId,
|
|
3157
3157
|
// Deposited collateral value (collateral balance)
|
|
@@ -3182,16 +3182,16 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3182
3182
|
)) {
|
|
3183
3183
|
const marketCollateral = market.collaterals[collateralCoinName];
|
|
3184
3184
|
if (marketCollateral) {
|
|
3185
|
-
let estimatedAvailableWithdrawAmount = (0,
|
|
3185
|
+
let estimatedAvailableWithdrawAmount = (0, import_bignumber4.default)(
|
|
3186
3186
|
obligationAccount.totalAvailableCollateralValue
|
|
3187
3187
|
).dividedBy(marketCollateral.collateralFactor).dividedBy(marketCollateral.coinPrice).shiftedBy(marketCollateral.coinDecimal);
|
|
3188
3188
|
estimatedAvailableWithdrawAmount = obligationAccount.totalBorrowedValueWithWeight === 0 ? (
|
|
3189
3189
|
// Note: when there is no debt record, there is no need to estimate and the deposited amount is directly used as available withdraw.
|
|
3190
|
-
(0,
|
|
3190
|
+
(0, import_bignumber4.default)(obligationCollateral.depositedAmount)
|
|
3191
3191
|
) : minBigNumber(
|
|
3192
3192
|
estimatedAvailableWithdrawAmount.multipliedBy(
|
|
3193
3193
|
estimatedFactor(
|
|
3194
|
-
(0,
|
|
3194
|
+
(0, import_bignumber4.default)(obligationAccount.totalAvailableCollateralValue).dividedBy(marketCollateral.collateralFactor).toNumber(),
|
|
3195
3195
|
3,
|
|
3196
3196
|
"increase"
|
|
3197
3197
|
)
|
|
@@ -3208,12 +3208,12 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3208
3208
|
)) {
|
|
3209
3209
|
const marketPool = market.pools[poolCoinName];
|
|
3210
3210
|
if (marketPool) {
|
|
3211
|
-
const estimatedRequiredRepayAmount = (0,
|
|
3211
|
+
const estimatedRequiredRepayAmount = (0, import_bignumber4.default)(
|
|
3212
3212
|
obligationDebt.requiredRepayAmount
|
|
3213
3213
|
).multipliedBy(
|
|
3214
3214
|
estimatedFactor(obligationDebt.borrowedValue, 3, "decrease")
|
|
3215
3215
|
);
|
|
3216
|
-
let estimatedAvailableBorrowAmount = (0,
|
|
3216
|
+
let estimatedAvailableBorrowAmount = (0, import_bignumber4.default)(
|
|
3217
3217
|
obligationAccount.totalAvailableCollateralValue
|
|
3218
3218
|
).dividedBy(marketPool.borrowWeight).shiftedBy(marketPool.coinDecimal).dividedBy(marketPool.coinPrice);
|
|
3219
3219
|
estimatedAvailableBorrowAmount = obligationAccount.totalAvailableCollateralValue !== 0 ? minBigNumber(
|
|
@@ -3225,7 +3225,7 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3225
3225
|
)
|
|
3226
3226
|
).toNumber(),
|
|
3227
3227
|
marketPool.supplyAmount
|
|
3228
|
-
) : (0,
|
|
3228
|
+
) : (0, import_bignumber4.default)(0);
|
|
3229
3229
|
obligationDebt.availableBorrowAmount = estimatedAvailableBorrowAmount.toNumber();
|
|
3230
3230
|
obligationDebt.availableBorrowCoin = estimatedAvailableBorrowAmount.shiftedBy(-1 * obligationDebt.coinDecimal).toNumber();
|
|
3231
3231
|
obligationDebt.requiredRepayAmount = estimatedRequiredRepayAmount.toNumber();
|
|
@@ -3236,8 +3236,8 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3236
3236
|
};
|
|
3237
3237
|
var getTotalValueLocked = async (query, indexer = false) => {
|
|
3238
3238
|
const market = await query.queryMarket(indexer);
|
|
3239
|
-
let supplyValue = (0,
|
|
3240
|
-
let borrowValue = (0,
|
|
3239
|
+
let supplyValue = (0, import_bignumber4.default)(0);
|
|
3240
|
+
let borrowValue = (0, import_bignumber4.default)(0);
|
|
3241
3241
|
if (indexer) {
|
|
3242
3242
|
const tvlIndexer = await query.indexer.getTotalValueLocked();
|
|
3243
3243
|
const tvl2 = {
|
|
@@ -3252,15 +3252,15 @@ var getTotalValueLocked = async (query, indexer = false) => {
|
|
|
3252
3252
|
}
|
|
3253
3253
|
for (const pool of Object.values(market.pools)) {
|
|
3254
3254
|
supplyValue = supplyValue.plus(
|
|
3255
|
-
(0,
|
|
3255
|
+
(0, import_bignumber4.default)(pool.supplyCoin).multipliedBy(pool.coinPrice)
|
|
3256
3256
|
);
|
|
3257
3257
|
borrowValue = borrowValue.plus(
|
|
3258
|
-
(0,
|
|
3258
|
+
(0, import_bignumber4.default)(pool.borrowCoin).multipliedBy(pool.coinPrice)
|
|
3259
3259
|
);
|
|
3260
3260
|
}
|
|
3261
3261
|
for (const collateral of Object.values(market.collaterals)) {
|
|
3262
3262
|
supplyValue = supplyValue.plus(
|
|
3263
|
-
(0,
|
|
3263
|
+
(0, import_bignumber4.default)(collateral.depositCoin).multipliedBy(collateral.coinPrice)
|
|
3264
3264
|
);
|
|
3265
3265
|
}
|
|
3266
3266
|
const tvl = {
|
|
@@ -3272,7 +3272,7 @@ var getTotalValueLocked = async (query, indexer = false) => {
|
|
|
3272
3272
|
};
|
|
3273
3273
|
|
|
3274
3274
|
// src/queries/vescaQuery.ts
|
|
3275
|
-
var
|
|
3275
|
+
var import_bignumber5 = __toESM(require("bignumber.js"));
|
|
3276
3276
|
var import_sui_kit2 = require("@scallop-io/sui-kit");
|
|
3277
3277
|
var import_bcs = require("@mysten/sui.js/bcs");
|
|
3278
3278
|
var getVescaKeys = async (query, ownerAddress) => {
|
|
@@ -3333,7 +3333,7 @@ var getVeSca = async (query, veScaKeyId, ownerAddress) => {
|
|
|
3333
3333
|
0
|
|
3334
3334
|
);
|
|
3335
3335
|
const lockedScaAmount = String(dynamicFields.locked_sca_amount);
|
|
3336
|
-
const lockedScaCoin = (0,
|
|
3336
|
+
const lockedScaCoin = (0, import_bignumber5.default)(dynamicFields.locked_sca_amount).shiftedBy(-9).toNumber();
|
|
3337
3337
|
const currentVeScaBalance = lockedScaCoin * (Math.floor(remainingLockPeriodInMilliseconds / 1e3) / MAX_LOCK_DURATION);
|
|
3338
3338
|
vesca = {
|
|
3339
3339
|
id: veScaDynamicFieldObject.objectId,
|
|
@@ -3341,7 +3341,7 @@ var getVeSca = async (query, veScaKeyId, ownerAddress) => {
|
|
|
3341
3341
|
lockedScaAmount,
|
|
3342
3342
|
lockedScaCoin,
|
|
3343
3343
|
currentVeScaBalance,
|
|
3344
|
-
unlockAt: (0,
|
|
3344
|
+
unlockAt: (0, import_bignumber5.default)(dynamicFields.unlock_at * 1e3).toNumber()
|
|
3345
3345
|
};
|
|
3346
3346
|
}
|
|
3347
3347
|
return vesca;
|