@scallop-io/sui-scallop-sdk 0.47.0-alpha.4 → 0.47.0-alpha.6
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/constants/common.d.ts +1 -1
- package/dist/index.js +43 -39
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +43 -39
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopQuery.d.ts +2 -0
- package/dist/queries/borrowIncentiveQuery.d.ts +11 -3
- package/dist/types/query/borrowIncentive.d.ts +2 -1
- package/package.json +1 -1
- package/src/builders/coreBuilder.ts +1 -1
- package/src/constants/common.ts +1 -3
- package/src/constants/enum.ts +3 -1
- package/src/models/scallopQuery.ts +2 -2
- package/src/models/scallopUtils.ts +5 -7
- package/src/queries/borrowIncentiveQuery.ts +32 -19
- package/src/queries/coreQuery.ts +4 -4
- package/src/queries/sCoinQuery.ts +1 -2
- package/src/queries/spoolQuery.ts +4 -3
- package/src/types/query/borrowIncentive.ts +2 -1
- package/src/utils/query.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -73,7 +73,8 @@ var SUPPORT_BORROW_INCENTIVE_POOLS = [
|
|
|
73
73
|
"hasui",
|
|
74
74
|
"vsui",
|
|
75
75
|
"weth",
|
|
76
|
-
"sca"
|
|
76
|
+
"sca",
|
|
77
|
+
"usdc"
|
|
77
78
|
];
|
|
78
79
|
var SUPPORT_BORROW_INCENTIVE_REWARDS = ["sui", "sca"];
|
|
79
80
|
var SUPPORT_ORACLES = ["supra", "switchboard", "pyth"];
|
|
@@ -188,6 +189,7 @@ var spoolRewardCoins = {
|
|
|
188
189
|
susdc: "sui"
|
|
189
190
|
};
|
|
190
191
|
var borrowIncentiveRewardCoins = {
|
|
192
|
+
usdc: ["sui", "sca"],
|
|
191
193
|
sui: ["sui", "sca"],
|
|
192
194
|
wusdc: ["sui", "sca"],
|
|
193
195
|
wusdt: ["sui", "sca"],
|
|
@@ -224,8 +226,7 @@ var voloCoinIds = {
|
|
|
224
226
|
vsui: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55"
|
|
225
227
|
};
|
|
226
228
|
var sCoinIds = {
|
|
227
|
-
susdc: "",
|
|
228
|
-
// TODO: sCoin contract
|
|
229
|
+
susdc: "0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC",
|
|
229
230
|
ssui: "0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI",
|
|
230
231
|
scetus: "0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS",
|
|
231
232
|
ssca: "0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA",
|
|
@@ -641,7 +642,8 @@ var parseOriginBorrowIncentivesPoolPointData = (originBorrowIncentivePoolPointDa
|
|
|
641
642
|
index: Number(originBorrowIncentivePoolPointData.index),
|
|
642
643
|
baseWeight: Number(originBorrowIncentivePoolPointData.base_weight),
|
|
643
644
|
weightedAmount: Number(originBorrowIncentivePoolPointData.weighted_amount),
|
|
644
|
-
lastUpdate: Number(originBorrowIncentivePoolPointData.last_update)
|
|
645
|
+
lastUpdate: Number(originBorrowIncentivePoolPointData.last_update),
|
|
646
|
+
createdAt: Number(originBorrowIncentivePoolPointData.created_at)
|
|
645
647
|
};
|
|
646
648
|
};
|
|
647
649
|
var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
|
|
@@ -650,7 +652,6 @@ var parseOriginBorrowIncentivePoolData = (originBorrowIncentivePoolData) => {
|
|
|
650
652
|
minStakes: Number(originBorrowIncentivePoolData.min_stakes),
|
|
651
653
|
maxStakes: Number(originBorrowIncentivePoolData.max_stakes),
|
|
652
654
|
staked: Number(originBorrowIncentivePoolData.stakes),
|
|
653
|
-
createdAt: Number(originBorrowIncentivePoolData.created_at),
|
|
654
655
|
poolPoints: originBorrowIncentivePoolData.points.reduce(
|
|
655
656
|
(acc, point) => {
|
|
656
657
|
const parsed = parseOriginBorrowIncentivesPoolPointData(point);
|
|
@@ -2383,7 +2384,7 @@ var getMarketPools = async (query, poolCoinNames = [...SUPPORT_POOLS], indexer =
|
|
|
2383
2384
|
const marketObjectResponse = await query.cache.queryGetObject(marketId, {
|
|
2384
2385
|
showContent: true
|
|
2385
2386
|
});
|
|
2386
|
-
const coinPrices = await query.utils.getCoinPrices(poolCoinNames ??
|
|
2387
|
+
const coinPrices = await query.utils.getCoinPrices(poolCoinNames) ?? {};
|
|
2387
2388
|
const marketPools = {};
|
|
2388
2389
|
if (indexer) {
|
|
2389
2390
|
const marketPoolsIndexer = await query.indexer.getMarketPools();
|
|
@@ -2565,7 +2566,7 @@ var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, c
|
|
|
2565
2566
|
};
|
|
2566
2567
|
var getMarketCollaterals = async (query, collateralCoinNames = [...SUPPORT_COLLATERALS], indexer = false) => {
|
|
2567
2568
|
const marketId = query.address.get("core.market");
|
|
2568
|
-
const coinPrices = await query.utils.getCoinPrices(collateralCoinNames ??
|
|
2569
|
+
const coinPrices = await query.utils.getCoinPrices(collateralCoinNames) ?? {};
|
|
2569
2570
|
const marketCollaterals = {};
|
|
2570
2571
|
if (indexer) {
|
|
2571
2572
|
const marketCollateralsIndexer = await query.indexer.getMarketCollaterals();
|
|
@@ -2757,8 +2758,7 @@ var queryObligation = async ({
|
|
|
2757
2758
|
);
|
|
2758
2759
|
return queryResult?.events[0]?.parsedJson;
|
|
2759
2760
|
};
|
|
2760
|
-
var getCoinAmounts = async (query, assetCoinNames, ownerAddress) => {
|
|
2761
|
-
assetCoinNames = assetCoinNames || [...SUPPORT_POOLS];
|
|
2761
|
+
var getCoinAmounts = async (query, assetCoinNames = [...SUPPORT_POOLS], ownerAddress) => {
|
|
2762
2762
|
const owner = ownerAddress || query.suiKit.currentAddress();
|
|
2763
2763
|
const assetCoins2 = {};
|
|
2764
2764
|
await Promise.allSettled(
|
|
@@ -2874,9 +2874,9 @@ var getSpools = async (query, stakeMarketCoinNames = [...SUPPORT_SPOOLS], indexe
|
|
|
2874
2874
|
const rewardCoinName = query.utils.getSpoolRewardCoinName(stakeMarketCoinName);
|
|
2875
2875
|
return rewardCoinName;
|
|
2876
2876
|
});
|
|
2877
|
-
const coinPrices = await query.utils.getCoinPrices(
|
|
2878
|
-
|
|
2879
|
-
);
|
|
2877
|
+
const coinPrices = await query.utils.getCoinPrices([
|
|
2878
|
+
.../* @__PURE__ */ new Set([...stakeCoinNames, ...rewardCoinNames])
|
|
2879
|
+
]) ?? {};
|
|
2880
2880
|
const marketPools = await query.getMarketPools(stakeCoinNames, indexer);
|
|
2881
2881
|
const spools = {};
|
|
2882
2882
|
if (indexer) {
|
|
@@ -3252,18 +3252,28 @@ var getStakeRewardPool = async ({
|
|
|
3252
3252
|
// src/queries/borrowIncentiveQuery.ts
|
|
3253
3253
|
import { normalizeStructTag as normalizeStructTag5 } from "@mysten/sui.js/utils";
|
|
3254
3254
|
import BigNumber3 from "bignumber.js";
|
|
3255
|
-
var queryBorrowIncentivePools = async (
|
|
3255
|
+
var queryBorrowIncentivePools = async (address) => {
|
|
3256
|
+
const queryPkgId = address.get("borrowIncentive.query");
|
|
3257
|
+
const incentivePoolsId = address.get("borrowIncentive.incentivePools");
|
|
3258
|
+
const queryTarget = `${queryPkgId}::incentive_pools_query::incentive_pools_data`;
|
|
3259
|
+
const args = [incentivePoolsId];
|
|
3260
|
+
const queryResult = await address.cache.queryInspectTxn({
|
|
3261
|
+
queryTarget,
|
|
3262
|
+
args
|
|
3263
|
+
});
|
|
3264
|
+
const borrowIncentivePoolsQueryData = queryResult?.events[0].parsedJson;
|
|
3265
|
+
return borrowIncentivePoolsQueryData;
|
|
3266
|
+
};
|
|
3267
|
+
var getBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
|
|
3256
3268
|
...SUPPORT_BORROW_INCENTIVE_POOLS
|
|
3257
3269
|
], indexer = false) => {
|
|
3258
3270
|
const borrowIncentivePools = {};
|
|
3259
|
-
const coinPrices = await query.utils.getCoinPrices(
|
|
3260
|
-
[
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
]
|
|
3266
|
-
);
|
|
3271
|
+
const coinPrices = await query.utils.getCoinPrices([
|
|
3272
|
+
.../* @__PURE__ */ new Set([
|
|
3273
|
+
...borrowIncentiveCoinNames,
|
|
3274
|
+
...SUPPORT_BORROW_INCENTIVE_REWARDS
|
|
3275
|
+
])
|
|
3276
|
+
]) ?? {};
|
|
3267
3277
|
if (indexer) {
|
|
3268
3278
|
const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
|
|
3269
3279
|
const updateBorrowIncentivePool = (pool) => {
|
|
@@ -3277,12 +3287,9 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
|
|
|
3277
3287
|
);
|
|
3278
3288
|
return borrowIncentivePools;
|
|
3279
3289
|
}
|
|
3280
|
-
const
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
const args = [incentivePoolsId];
|
|
3284
|
-
const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
|
|
3285
|
-
const borrowIncentivePoolsQueryData = queryResult?.events[0].parsedJson;
|
|
3290
|
+
const borrowIncentivePoolsQueryData = await queryBorrowIncentivePools(
|
|
3291
|
+
query.address
|
|
3292
|
+
);
|
|
3286
3293
|
for (const pool of borrowIncentivePoolsQueryData?.incentive_pools ?? []) {
|
|
3287
3294
|
const borrowIncentivePoolPoints = {};
|
|
3288
3295
|
const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(pool);
|
|
@@ -3345,10 +3352,9 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames = [
|
|
|
3345
3352
|
};
|
|
3346
3353
|
var queryBorrowIncentiveAccounts = async ({
|
|
3347
3354
|
utils
|
|
3348
|
-
}, obligationId, borrowIncentiveCoinNames
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
];
|
|
3355
|
+
}, obligationId, borrowIncentiveCoinNames = [
|
|
3356
|
+
...SUPPORT_BORROW_INCENTIVE_POOLS
|
|
3357
|
+
]) => {
|
|
3352
3358
|
const queryPkgId = utils.address.get("borrowIncentive.query");
|
|
3353
3359
|
const incentiveAccountsId = utils.address.get(
|
|
3354
3360
|
"borrowIncentive.incentiveAccounts"
|
|
@@ -4570,10 +4576,9 @@ var ScallopUtils = class {
|
|
|
4570
4576
|
* @param assetCoinNames - Specific an array of support asset coin name.
|
|
4571
4577
|
* @return Asset coin price.
|
|
4572
4578
|
*/
|
|
4573
|
-
async getCoinPrices(assetCoinNames
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
];
|
|
4579
|
+
async getCoinPrices(assetCoinNames = [
|
|
4580
|
+
.../* @__PURE__ */ new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS])
|
|
4581
|
+
]) {
|
|
4577
4582
|
const coinPrices = {};
|
|
4578
4583
|
const existPricesCoinNames = [];
|
|
4579
4584
|
const lackPricesCoinNames = [];
|
|
@@ -5157,7 +5162,7 @@ var generateCoreQuickMethod = ({
|
|
|
5157
5162
|
const obligationCoinNames = await builder.utils.getObligationCoinNames(
|
|
5158
5163
|
obligationInfo.obligationId
|
|
5159
5164
|
) ?? [];
|
|
5160
|
-
const updateCoinNames = [...obligationCoinNames
|
|
5165
|
+
const updateCoinNames = [...obligationCoinNames, poolCoinName];
|
|
5161
5166
|
await updateOracles(builder, txBlock, updateCoinNames);
|
|
5162
5167
|
return txBlock.borrow(
|
|
5163
5168
|
obligationInfo.obligationId,
|
|
@@ -6523,8 +6528,7 @@ var getSCoinTotalSupply = async ({
|
|
|
6523
6528
|
};
|
|
6524
6529
|
var getSCoinAmounts = async ({
|
|
6525
6530
|
utils
|
|
6526
|
-
}, sCoinNames, ownerAddress) => {
|
|
6527
|
-
sCoinNames = sCoinNames || [...SUPPORT_SCOIN];
|
|
6531
|
+
}, sCoinNames = [...SUPPORT_SCOIN], ownerAddress) => {
|
|
6528
6532
|
const owner = ownerAddress || utils.suiKit.currentAddress();
|
|
6529
6533
|
const sCoins2 = {};
|
|
6530
6534
|
await Promise.allSettled(
|
|
@@ -6888,7 +6892,7 @@ var ScallopQuery = class {
|
|
|
6888
6892
|
* @return Borrow incentive pools data.
|
|
6889
6893
|
*/
|
|
6890
6894
|
async getBorrowIncentivePools(coinNames, indexer = false) {
|
|
6891
|
-
return await
|
|
6895
|
+
return await getBorrowIncentivePools(this, coinNames, indexer);
|
|
6892
6896
|
}
|
|
6893
6897
|
/**
|
|
6894
6898
|
* Get borrow incentive accounts data.
|