@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.js
CHANGED
|
@@ -2555,19 +2555,29 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer
|
|
|
2555
2555
|
const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
|
|
2556
2556
|
const borrowIncentivePoolsQueryData = queryResult.events[0].parsedJson;
|
|
2557
2557
|
const borrowIncentivePools = {};
|
|
2558
|
+
const coinPrices = await query.utils.getCoinPrices(
|
|
2559
|
+
[
|
|
2560
|
+
.../* @__PURE__ */ new Set([
|
|
2561
|
+
...borrowIncentiveCoinNames,
|
|
2562
|
+
...SUPPORT_BORROW_INCENTIVE_REWARDS
|
|
2563
|
+
])
|
|
2564
|
+
]
|
|
2565
|
+
);
|
|
2558
2566
|
if (indexer) {
|
|
2567
|
+
const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
|
|
2568
|
+
for (const borrowIncentivePool of Object.values(
|
|
2569
|
+
borrowIncentivePoolsIndexer
|
|
2570
|
+
)) {
|
|
2571
|
+
if (!borrowIncentiveCoinNames.includes(borrowIncentivePool.coinName))
|
|
2572
|
+
continue;
|
|
2573
|
+
borrowIncentivePool.coinPrice = coinPrices[borrowIncentivePool.coinName] || borrowIncentivePool.coinPrice;
|
|
2574
|
+
borrowIncentivePools[borrowIncentivePool.coinName] = borrowIncentivePool;
|
|
2575
|
+
}
|
|
2576
|
+
return borrowIncentivePools;
|
|
2559
2577
|
}
|
|
2560
2578
|
for (const pool of borrowIncentivePoolsQueryData.incentive_pools) {
|
|
2561
2579
|
const borrowIncentivePoolPoints = {};
|
|
2562
2580
|
const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(pool);
|
|
2563
|
-
const coinPrices = await query.utils.getCoinPrices(
|
|
2564
|
-
[
|
|
2565
|
-
.../* @__PURE__ */ new Set([
|
|
2566
|
-
...borrowIncentiveCoinNames,
|
|
2567
|
-
...SUPPORT_BORROW_INCENTIVE_REWARDS
|
|
2568
|
-
])
|
|
2569
|
-
]
|
|
2570
|
-
);
|
|
2571
2581
|
const poolCoinType = (0, import_utils6.normalizeStructTag)(pool.pool_type.name);
|
|
2572
2582
|
const poolCoinName = query.utils.parseCoinNameFromType(
|
|
2573
2583
|
poolCoinType
|
|
@@ -2926,17 +2936,19 @@ var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
|
|
|
2926
2936
|
const coinAmounts = await query.getCoinAmounts(void 0, ownerAddress);
|
|
2927
2937
|
const obligations = await query.getObligations(ownerAddress);
|
|
2928
2938
|
const obligationAccounts = {};
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2939
|
+
await Promise.allSettled(
|
|
2940
|
+
obligations.map(async (obligation) => {
|
|
2941
|
+
obligationAccounts[obligation.keyId] = await getObligationAccount(
|
|
2942
|
+
query,
|
|
2943
|
+
obligation.id,
|
|
2944
|
+
ownerAddress,
|
|
2945
|
+
indexer,
|
|
2946
|
+
market,
|
|
2947
|
+
coinPrices,
|
|
2948
|
+
coinAmounts
|
|
2949
|
+
);
|
|
2950
|
+
})
|
|
2951
|
+
);
|
|
2940
2952
|
return obligationAccounts;
|
|
2941
2953
|
};
|
|
2942
2954
|
var getObligationAccount = async (query, obligationId, ownerAddress, indexer = false, market, coinPrices, coinAmounts) => {
|
|
@@ -3300,7 +3312,7 @@ var getVeScas = async (query, ownerAddress) => {
|
|
|
3300
3312
|
}
|
|
3301
3313
|
});
|
|
3302
3314
|
await Promise.allSettled(tasks);
|
|
3303
|
-
return veScas.filter(Boolean).sort((a, b) =>
|
|
3315
|
+
return veScas.filter(Boolean).sort((a, b) => b.currentVeScaBalance - a.currentVeScaBalance);
|
|
3304
3316
|
};
|
|
3305
3317
|
var getVeSca = async (query, veScaKeyId, ownerAddress) => {
|
|
3306
3318
|
const tableId = query.address.get(`vesca.tableId`);
|
|
@@ -3523,6 +3535,15 @@ var ScallopIndexer = class {
|
|
|
3523
3535
|
if (response.status === 200) {
|
|
3524
3536
|
return response.data.borrowIncentivePools.reduce(
|
|
3525
3537
|
(borrowIncentivePools, borrowIncentivePool) => {
|
|
3538
|
+
if (Array.isArray(borrowIncentivePool.points)) {
|
|
3539
|
+
borrowIncentivePool.points = borrowIncentivePool.points.reduce(
|
|
3540
|
+
(prev, curr) => {
|
|
3541
|
+
prev[curr.coinName] = curr;
|
|
3542
|
+
return prev;
|
|
3543
|
+
},
|
|
3544
|
+
{}
|
|
3545
|
+
);
|
|
3546
|
+
}
|
|
3526
3547
|
borrowIncentivePools[borrowIncentivePool.coinName] = borrowIncentivePool;
|
|
3527
3548
|
return borrowIncentivePools;
|
|
3528
3549
|
},
|
|
@@ -5180,11 +5201,6 @@ var generateQuickVeScaMethod = ({
|
|
|
5180
5201
|
newUnlockAt,
|
|
5181
5202
|
veSca?.unlockAt
|
|
5182
5203
|
);
|
|
5183
|
-
console.log(
|
|
5184
|
-
new Date(newUnlockAt * 1e3).toLocaleString("en-CA", {
|
|
5185
|
-
hour12: true
|
|
5186
|
-
})
|
|
5187
|
-
);
|
|
5188
5204
|
const isInitialLock = !veSca?.unlockAt;
|
|
5189
5205
|
const isLockExpired = !isInitialLock && veSca.unlockAt * 1e3 <= (/* @__PURE__ */ new Date()).getTime();
|
|
5190
5206
|
if (isInitialLock || isLockExpired) {
|