@scallop-io/sui-scallop-sdk 0.46.2 → 0.46.31
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 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
- package/src/builders/vescaBuilder.ts +0 -5
- package/src/models/scallopIndexer.ts +16 -0
- package/src/queries/borrowIncentiveQuery.ts +24 -25
- package/src/queries/portfolioQuery.ts +13 -11
- package/src/queries/vescaQuery.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2482,19 +2482,29 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer
|
|
|
2482
2482
|
const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
|
|
2483
2483
|
const borrowIncentivePoolsQueryData = queryResult.events[0].parsedJson;
|
|
2484
2484
|
const borrowIncentivePools = {};
|
|
2485
|
+
const coinPrices = await query.utils.getCoinPrices(
|
|
2486
|
+
[
|
|
2487
|
+
.../* @__PURE__ */ new Set([
|
|
2488
|
+
...borrowIncentiveCoinNames,
|
|
2489
|
+
...SUPPORT_BORROW_INCENTIVE_REWARDS
|
|
2490
|
+
])
|
|
2491
|
+
]
|
|
2492
|
+
);
|
|
2485
2493
|
if (indexer) {
|
|
2494
|
+
const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
|
|
2495
|
+
for (const borrowIncentivePool of Object.values(
|
|
2496
|
+
borrowIncentivePoolsIndexer
|
|
2497
|
+
)) {
|
|
2498
|
+
if (!borrowIncentiveCoinNames.includes(borrowIncentivePool.coinName))
|
|
2499
|
+
continue;
|
|
2500
|
+
borrowIncentivePool.coinPrice = coinPrices[borrowIncentivePool.coinName] || borrowIncentivePool.coinPrice;
|
|
2501
|
+
borrowIncentivePools[borrowIncentivePool.coinName] = borrowIncentivePool;
|
|
2502
|
+
}
|
|
2503
|
+
return borrowIncentivePools;
|
|
2486
2504
|
}
|
|
2487
2505
|
for (const pool of borrowIncentivePoolsQueryData.incentive_pools) {
|
|
2488
2506
|
const borrowIncentivePoolPoints = {};
|
|
2489
2507
|
const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(pool);
|
|
2490
|
-
const coinPrices = await query.utils.getCoinPrices(
|
|
2491
|
-
[
|
|
2492
|
-
.../* @__PURE__ */ new Set([
|
|
2493
|
-
...borrowIncentiveCoinNames,
|
|
2494
|
-
...SUPPORT_BORROW_INCENTIVE_REWARDS
|
|
2495
|
-
])
|
|
2496
|
-
]
|
|
2497
|
-
);
|
|
2498
2508
|
const poolCoinType = normalizeStructTag5(pool.pool_type.name);
|
|
2499
2509
|
const poolCoinName = query.utils.parseCoinNameFromType(
|
|
2500
2510
|
poolCoinType
|
|
@@ -2853,17 +2863,19 @@ var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
|
|
|
2853
2863
|
const coinAmounts = await query.getCoinAmounts(void 0, ownerAddress);
|
|
2854
2864
|
const obligations = await query.getObligations(ownerAddress);
|
|
2855
2865
|
const obligationAccounts = {};
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2866
|
+
await Promise.allSettled(
|
|
2867
|
+
obligations.map(async (obligation) => {
|
|
2868
|
+
obligationAccounts[obligation.keyId] = await getObligationAccount(
|
|
2869
|
+
query,
|
|
2870
|
+
obligation.id,
|
|
2871
|
+
ownerAddress,
|
|
2872
|
+
indexer,
|
|
2873
|
+
market,
|
|
2874
|
+
coinPrices,
|
|
2875
|
+
coinAmounts
|
|
2876
|
+
);
|
|
2877
|
+
})
|
|
2878
|
+
);
|
|
2867
2879
|
return obligationAccounts;
|
|
2868
2880
|
};
|
|
2869
2881
|
var getObligationAccount = async (query, obligationId, ownerAddress, indexer = false, market, coinPrices, coinAmounts) => {
|
|
@@ -3227,7 +3239,7 @@ var getVeScas = async (query, ownerAddress) => {
|
|
|
3227
3239
|
}
|
|
3228
3240
|
});
|
|
3229
3241
|
await Promise.allSettled(tasks);
|
|
3230
|
-
return veScas.filter(Boolean).sort((a, b) =>
|
|
3242
|
+
return veScas.filter(Boolean).sort((a, b) => b.currentVeScaBalance - a.currentVeScaBalance);
|
|
3231
3243
|
};
|
|
3232
3244
|
var getVeSca = async (query, veScaKeyId, ownerAddress) => {
|
|
3233
3245
|
const tableId = query.address.get(`vesca.tableId`);
|
|
@@ -3450,6 +3462,15 @@ var ScallopIndexer = class {
|
|
|
3450
3462
|
if (response.status === 200) {
|
|
3451
3463
|
return response.data.borrowIncentivePools.reduce(
|
|
3452
3464
|
(borrowIncentivePools, borrowIncentivePool) => {
|
|
3465
|
+
if (Array.isArray(borrowIncentivePool.points)) {
|
|
3466
|
+
borrowIncentivePool.points = borrowIncentivePool.points.reduce(
|
|
3467
|
+
(prev, curr) => {
|
|
3468
|
+
prev[curr.coinName] = curr;
|
|
3469
|
+
return prev;
|
|
3470
|
+
},
|
|
3471
|
+
{}
|
|
3472
|
+
);
|
|
3473
|
+
}
|
|
3453
3474
|
borrowIncentivePools[borrowIncentivePool.coinName] = borrowIncentivePool;
|
|
3454
3475
|
return borrowIncentivePools;
|
|
3455
3476
|
},
|
|
@@ -5114,11 +5135,6 @@ var generateQuickVeScaMethod = ({
|
|
|
5114
5135
|
newUnlockAt,
|
|
5115
5136
|
veSca?.unlockAt
|
|
5116
5137
|
);
|
|
5117
|
-
console.log(
|
|
5118
|
-
new Date(newUnlockAt * 1e3).toLocaleString("en-CA", {
|
|
5119
|
-
hour12: true
|
|
5120
|
-
})
|
|
5121
|
-
);
|
|
5122
5138
|
const isInitialLock = !veSca?.unlockAt;
|
|
5123
5139
|
const isLockExpired = !isInitialLock && veSca.unlockAt * 1e3 <= (/* @__PURE__ */ new Date()).getTime();
|
|
5124
5140
|
if (isInitialLock || isLockExpired) {
|