@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/dist/index.mjs
CHANGED
|
@@ -2501,7 +2501,6 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
|
|
|
2501
2501
|
const borrowIncentivePools = {};
|
|
2502
2502
|
marketPools = marketPools ?? await query.getMarketPools(void 0, false, { coinPrices });
|
|
2503
2503
|
coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools });
|
|
2504
|
-
console.log({ coinPrices });
|
|
2505
2504
|
if (indexer) {
|
|
2506
2505
|
const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
|
|
2507
2506
|
const updateBorrowIncentivePool = (pool) => {
|
|
@@ -3709,8 +3708,8 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3709
3708
|
const collateralAssetCoinNames = [
|
|
3710
3709
|
...SUPPORT_COLLATERALS
|
|
3711
3710
|
];
|
|
3712
|
-
|
|
3713
|
-
|
|
3711
|
+
market = market ?? await query.queryMarket(indexer);
|
|
3712
|
+
coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools: market.pools });
|
|
3714
3713
|
coinAmounts = coinAmounts || await query.getCoinAmounts(collateralAssetCoinNames, ownerAddress);
|
|
3715
3714
|
const [obligationQuery, borrowIncentivePools, borrowIncentiveAccounts] = await Promise.all([
|
|
3716
3715
|
query.queryObligation(obligationId),
|
|
@@ -3851,44 +3850,47 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3851
3850
|
const borrowIncentivePool = borrowIncentivePools[coinName];
|
|
3852
3851
|
if (borrowIncentivePool) {
|
|
3853
3852
|
const rewards = [];
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
BigNumber5(
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3853
|
+
Object.entries(borrowIncentiveAccount.pointList).forEach(
|
|
3854
|
+
([key, accountPoint]) => {
|
|
3855
|
+
const poolPoint = borrowIncentivePool.points[key];
|
|
3856
|
+
if (accountPoint && poolPoint) {
|
|
3857
|
+
let availableClaimAmount = BigNumber5(0);
|
|
3858
|
+
let availableClaimCoin = BigNumber5(0);
|
|
3859
|
+
const accountBorrowedAmount = BigNumber5(
|
|
3860
|
+
accountPoint.weightedAmount
|
|
3861
|
+
);
|
|
3862
|
+
const baseIndexRate = 1e9;
|
|
3863
|
+
const increasedPointRate = poolPoint.currentPointIndex ? Math.max(
|
|
3864
|
+
BigNumber5(poolPoint.currentPointIndex - accountPoint.index).dividedBy(baseIndexRate).toNumber(),
|
|
3865
|
+
0
|
|
3866
|
+
) : 1;
|
|
3867
|
+
availableClaimAmount = availableClaimAmount.plus(
|
|
3868
|
+
accountBorrowedAmount.multipliedBy(increasedPointRate).plus(accountPoint.points)
|
|
3869
|
+
);
|
|
3870
|
+
availableClaimCoin = availableClaimAmount.shiftedBy(
|
|
3871
|
+
-1 * poolPoint.coinDecimal
|
|
3872
|
+
);
|
|
3873
|
+
const weightScale = BigNumber5(1e12);
|
|
3874
|
+
const boostValue = BigNumber5(accountPoint.weightedAmount).div(
|
|
3875
|
+
BigNumber5(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
|
|
3876
|
+
).isFinite() ? BigNumber5(accountPoint.weightedAmount).div(
|
|
3877
|
+
BigNumber5(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
|
|
3878
|
+
).toNumber() : 1;
|
|
3879
|
+
if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
|
|
3880
|
+
rewards.push({
|
|
3881
|
+
coinName: poolPoint.coinName,
|
|
3882
|
+
coinType: poolPoint.coinType,
|
|
3883
|
+
symbol: poolPoint.symbol,
|
|
3884
|
+
coinDecimal: poolPoint.coinDecimal,
|
|
3885
|
+
coinPrice: poolPoint.coinPrice,
|
|
3886
|
+
availableClaimAmount: availableClaimAmount.toNumber(),
|
|
3887
|
+
availableClaimCoin: availableClaimCoin.toNumber(),
|
|
3888
|
+
boostValue
|
|
3889
|
+
});
|
|
3890
|
+
}
|
|
3889
3891
|
}
|
|
3890
3892
|
}
|
|
3891
|
-
|
|
3893
|
+
);
|
|
3892
3894
|
if (Object.keys(borrowIncentivePool.points).some((coinName2) => {
|
|
3893
3895
|
const rewardApr = borrowIncentivePool.points[coinName2]?.rewardApr;
|
|
3894
3896
|
return rewardApr !== Infinity && typeof rewardApr == "number" && rewardApr > 0;
|