@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.js
CHANGED
|
@@ -2591,7 +2591,6 @@ var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
|
|
|
2591
2591
|
const borrowIncentivePools = {};
|
|
2592
2592
|
marketPools = marketPools ?? await query.getMarketPools(void 0, false, { coinPrices });
|
|
2593
2593
|
coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools });
|
|
2594
|
-
console.log({ coinPrices });
|
|
2595
2594
|
if (indexer) {
|
|
2596
2595
|
const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
|
|
2597
2596
|
const updateBorrowIncentivePool = (pool) => {
|
|
@@ -3799,8 +3798,8 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3799
3798
|
const collateralAssetCoinNames = [
|
|
3800
3799
|
...SUPPORT_COLLATERALS
|
|
3801
3800
|
];
|
|
3802
|
-
|
|
3803
|
-
|
|
3801
|
+
market = market ?? await query.queryMarket(indexer);
|
|
3802
|
+
coinPrices = coinPrices ?? await query.getAllCoinPrices({ marketPools: market.pools });
|
|
3804
3803
|
coinAmounts = coinAmounts || await query.getCoinAmounts(collateralAssetCoinNames, ownerAddress);
|
|
3805
3804
|
const [obligationQuery, borrowIncentivePools, borrowIncentiveAccounts] = await Promise.all([
|
|
3806
3805
|
query.queryObligation(obligationId),
|
|
@@ -3941,44 +3940,47 @@ var getObligationAccount = async (query, obligationId, ownerAddress, indexer = f
|
|
|
3941
3940
|
const borrowIncentivePool = borrowIncentivePools[coinName];
|
|
3942
3941
|
if (borrowIncentivePool) {
|
|
3943
3942
|
const rewards = [];
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
(0, import_bignumber5.default)(
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3943
|
+
Object.entries(borrowIncentiveAccount.pointList).forEach(
|
|
3944
|
+
([key, accountPoint]) => {
|
|
3945
|
+
const poolPoint = borrowIncentivePool.points[key];
|
|
3946
|
+
if (accountPoint && poolPoint) {
|
|
3947
|
+
let availableClaimAmount = (0, import_bignumber5.default)(0);
|
|
3948
|
+
let availableClaimCoin = (0, import_bignumber5.default)(0);
|
|
3949
|
+
const accountBorrowedAmount = (0, import_bignumber5.default)(
|
|
3950
|
+
accountPoint.weightedAmount
|
|
3951
|
+
);
|
|
3952
|
+
const baseIndexRate = 1e9;
|
|
3953
|
+
const increasedPointRate = poolPoint.currentPointIndex ? Math.max(
|
|
3954
|
+
(0, import_bignumber5.default)(poolPoint.currentPointIndex - accountPoint.index).dividedBy(baseIndexRate).toNumber(),
|
|
3955
|
+
0
|
|
3956
|
+
) : 1;
|
|
3957
|
+
availableClaimAmount = availableClaimAmount.plus(
|
|
3958
|
+
accountBorrowedAmount.multipliedBy(increasedPointRate).plus(accountPoint.points)
|
|
3959
|
+
);
|
|
3960
|
+
availableClaimCoin = availableClaimAmount.shiftedBy(
|
|
3961
|
+
-1 * poolPoint.coinDecimal
|
|
3962
|
+
);
|
|
3963
|
+
const weightScale = (0, import_bignumber5.default)(1e12);
|
|
3964
|
+
const boostValue = (0, import_bignumber5.default)(accountPoint.weightedAmount).div(
|
|
3965
|
+
(0, import_bignumber5.default)(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
|
|
3966
|
+
).isFinite() ? (0, import_bignumber5.default)(accountPoint.weightedAmount).div(
|
|
3967
|
+
(0, import_bignumber5.default)(borrowIncentiveAccount.debtAmount).multipliedBy(poolPoint.baseWeight).dividedBy(weightScale)
|
|
3968
|
+
).toNumber() : 1;
|
|
3969
|
+
if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
|
|
3970
|
+
rewards.push({
|
|
3971
|
+
coinName: poolPoint.coinName,
|
|
3972
|
+
coinType: poolPoint.coinType,
|
|
3973
|
+
symbol: poolPoint.symbol,
|
|
3974
|
+
coinDecimal: poolPoint.coinDecimal,
|
|
3975
|
+
coinPrice: poolPoint.coinPrice,
|
|
3976
|
+
availableClaimAmount: availableClaimAmount.toNumber(),
|
|
3977
|
+
availableClaimCoin: availableClaimCoin.toNumber(),
|
|
3978
|
+
boostValue
|
|
3979
|
+
});
|
|
3980
|
+
}
|
|
3979
3981
|
}
|
|
3980
3982
|
}
|
|
3981
|
-
|
|
3983
|
+
);
|
|
3982
3984
|
if (Object.keys(borrowIncentivePool.points).some((coinName2) => {
|
|
3983
3985
|
const rewardApr = borrowIncentivePool.points[coinName2]?.rewardApr;
|
|
3984
3986
|
return rewardApr !== Infinity && typeof rewardApr == "number" && rewardApr > 0;
|