@scallop-io/sui-scallop-sdk 0.46.3 → 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 +40 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -24
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scallop-io/sui-scallop-sdk",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.31",
|
|
4
4
|
"description": "Typescript sdk for interacting with Scallop contract on SUI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sui",
|
|
@@ -76,7 +76,8 @@
|
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@mysten/sui.js": "0.49.1",
|
|
79
|
-
"@scallop-io/sui-kit": "^0.44.2"
|
|
79
|
+
"@scallop-io/sui-kit": "^0.44.2",
|
|
80
|
+
"bn.js": "^5.2.1"
|
|
80
81
|
},
|
|
81
82
|
"lint-staged": {
|
|
82
83
|
"**/*.ts": [
|
|
@@ -219,11 +219,6 @@ const generateQuickVeScaMethod: GenerateVeScaQuickMethod = ({
|
|
|
219
219
|
newUnlockAt,
|
|
220
220
|
veSca?.unlockAt
|
|
221
221
|
);
|
|
222
|
-
console.log(
|
|
223
|
-
new Date(newUnlockAt * 1000).toLocaleString('en-CA', {
|
|
224
|
-
hour12: true,
|
|
225
|
-
})
|
|
226
|
-
);
|
|
227
222
|
|
|
228
223
|
const isInitialLock = !veSca?.unlockAt;
|
|
229
224
|
const isLockExpired =
|
|
@@ -18,6 +18,8 @@ import type {
|
|
|
18
18
|
ScallopQueryParams,
|
|
19
19
|
ScallopParams,
|
|
20
20
|
ScallopInstanceParams,
|
|
21
|
+
BorrowIncentivePoolPoints,
|
|
22
|
+
SupportBorrowIncentiveRewardCoins,
|
|
21
23
|
} from '../types';
|
|
22
24
|
import { ScallopCache } from './scallopCache';
|
|
23
25
|
|
|
@@ -185,6 +187,20 @@ export class ScallopIndexer {
|
|
|
185
187
|
if (response.status === 200) {
|
|
186
188
|
return response.data.borrowIncentivePools.reduce(
|
|
187
189
|
(borrowIncentivePools, borrowIncentivePool) => {
|
|
190
|
+
if (Array.isArray(borrowIncentivePool.points)) {
|
|
191
|
+
borrowIncentivePool.points = (
|
|
192
|
+
borrowIncentivePool.points as BorrowIncentivePoolPoints[]
|
|
193
|
+
).reduce(
|
|
194
|
+
(prev, curr) => {
|
|
195
|
+
prev[curr.coinName] = curr;
|
|
196
|
+
return prev;
|
|
197
|
+
},
|
|
198
|
+
{} as Record<
|
|
199
|
+
SupportBorrowIncentiveRewardCoins,
|
|
200
|
+
BorrowIncentivePoolPoints
|
|
201
|
+
>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
188
204
|
borrowIncentivePools[borrowIncentivePool.coinName] =
|
|
189
205
|
borrowIncentivePool;
|
|
190
206
|
return borrowIncentivePools;
|
|
@@ -47,23 +47,31 @@ export const queryBorrowIncentivePools = async (
|
|
|
47
47
|
|
|
48
48
|
const borrowIncentivePools: BorrowIncentivePools = {};
|
|
49
49
|
|
|
50
|
+
const coinPrices = await query.utils.getCoinPrices(
|
|
51
|
+
[
|
|
52
|
+
...new Set([
|
|
53
|
+
...borrowIncentiveCoinNames,
|
|
54
|
+
...SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
55
|
+
]),
|
|
56
|
+
] ?? []
|
|
57
|
+
);
|
|
58
|
+
|
|
50
59
|
if (indexer) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// return borrowIncentivePools;
|
|
60
|
+
const borrowIncentivePoolsIndexer =
|
|
61
|
+
await query.indexer.getBorrowIncentivePools();
|
|
62
|
+
for (const borrowIncentivePool of Object.values(
|
|
63
|
+
borrowIncentivePoolsIndexer
|
|
64
|
+
)) {
|
|
65
|
+
if (!borrowIncentiveCoinNames.includes(borrowIncentivePool.coinName))
|
|
66
|
+
continue;
|
|
67
|
+
borrowIncentivePool.coinPrice =
|
|
68
|
+
coinPrices[borrowIncentivePool.coinName] ||
|
|
69
|
+
borrowIncentivePool.coinPrice;
|
|
70
|
+
// borrowIncentivePool.rewardCoinPrice =
|
|
71
|
+
// coinPrices[rewardCoinName] || borrowIncentivePool.rewardCoinPrice;
|
|
72
|
+
borrowIncentivePools[borrowIncentivePool.coinName] = borrowIncentivePool;
|
|
73
|
+
}
|
|
74
|
+
return borrowIncentivePools;
|
|
67
75
|
}
|
|
68
76
|
|
|
69
77
|
for (const pool of borrowIncentivePoolsQueryData.incentive_pools) {
|
|
@@ -73,15 +81,6 @@ export const queryBorrowIncentivePools = async (
|
|
|
73
81
|
const parsedBorrowIncentivePoolData =
|
|
74
82
|
parseOriginBorrowIncentivePoolData(pool);
|
|
75
83
|
|
|
76
|
-
const coinPrices = await query.utils.getCoinPrices(
|
|
77
|
-
[
|
|
78
|
-
...new Set([
|
|
79
|
-
...borrowIncentiveCoinNames,
|
|
80
|
-
...SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
81
|
-
]),
|
|
82
|
-
] ?? []
|
|
83
|
-
);
|
|
84
|
-
|
|
85
84
|
const poolCoinType = normalizeStructTag(pool.pool_type.name);
|
|
86
85
|
const poolCoinName =
|
|
87
86
|
query.utils.parseCoinNameFromType<SupportBorrowIncentiveCoins>(
|
|
@@ -280,17 +280,19 @@ export const getObligationAccounts = async (
|
|
|
280
280
|
const obligations = await query.getObligations(ownerAddress);
|
|
281
281
|
|
|
282
282
|
const obligationAccounts: ObligationAccounts = {};
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
283
|
+
await Promise.allSettled(
|
|
284
|
+
obligations.map(async (obligation) => {
|
|
285
|
+
obligationAccounts[obligation.keyId] = await getObligationAccount(
|
|
286
|
+
query,
|
|
287
|
+
obligation.id,
|
|
288
|
+
ownerAddress,
|
|
289
|
+
indexer,
|
|
290
|
+
market,
|
|
291
|
+
coinPrices,
|
|
292
|
+
coinAmounts
|
|
293
|
+
);
|
|
294
|
+
})
|
|
295
|
+
);
|
|
294
296
|
|
|
295
297
|
return obligationAccounts;
|
|
296
298
|
};
|