@scallop-io/sui-scallop-sdk 0.44.1 → 0.44.3
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/builders/borrowIncentiveBuilder.d.ts +12 -0
- package/dist/constants/common.d.ts +5 -3
- package/dist/constants/enum.d.ts +4 -2
- package/dist/index.js +843 -228
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +803 -192
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopClient.d.ts +33 -2
- package/dist/models/scallopQuery.d.ts +36 -10
- package/dist/models/scallopUtils.d.ts +12 -4
- package/dist/queries/borrowIncentiveQuery.d.ts +24 -0
- package/dist/queries/coreQuery.d.ts +12 -0
- package/dist/queries/index.d.ts +1 -0
- package/dist/queries/portfolioQuery.d.ts +1 -0
- package/dist/queries/spoolQuery.d.ts +13 -5
- package/dist/types/address.d.ts +10 -2
- package/dist/types/builder/borrowIncentive.d.ts +31 -0
- package/dist/types/builder/index.d.ts +3 -1
- package/dist/types/constant/common.d.ts +5 -3
- package/dist/types/constant/enum.d.ts +9 -3
- package/dist/types/query/borrowIncentive.d.ts +118 -0
- package/dist/types/query/core.d.ts +1 -0
- package/dist/types/query/index.d.ts +1 -0
- package/dist/types/query/spool.d.ts +12 -13
- package/dist/utils/builder.d.ts +8 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/query.d.ts +33 -10
- package/dist/utils/util.d.ts +15 -1
- package/package.json +12 -12
- package/src/builders/borrowIncentiveBuilder.ts +257 -0
- package/src/builders/coreBuilder.ts +1 -14
- package/src/builders/index.ts +9 -2
- package/src/builders/spoolBuilder.ts +3 -16
- package/src/constants/common.ts +6 -1
- package/src/constants/enum.ts +18 -2
- package/src/models/scallopAddress.ts +47 -0
- package/src/models/scallopClient.ts +104 -2
- package/src/models/scallopQuery.ts +48 -14
- package/src/models/scallopUtils.ts +53 -15
- package/src/queries/borrowIncentiveQuery.ts +166 -0
- package/src/queries/coreQuery.ts +57 -15
- package/src/queries/index.ts +1 -0
- package/src/queries/spoolQuery.ts +78 -62
- package/src/types/address.ts +10 -2
- package/src/types/builder/borrowIncentive.ts +67 -0
- package/src/types/builder/index.ts +5 -1
- package/src/types/builder/spool.ts +0 -1
- package/src/types/constant/common.ts +10 -3
- package/src/types/constant/enum.ts +13 -3
- package/src/types/query/borrowIncentive.ts +150 -0
- package/src/types/query/core.ts +1 -1
- package/src/types/query/index.ts +1 -0
- package/src/types/query/spool.ts +28 -18
- package/src/utils/builder.ts +15 -0
- package/src/utils/index.ts +1 -1
- package/src/utils/query.ts +277 -70
- package/src/utils/util.ts +59 -9
- package/dist/utils/oracle.d.ts +0 -14
- package/src/utils/oracle.ts +0 -36
package/src/queries/coreQuery.ts
CHANGED
|
@@ -59,6 +59,17 @@ export const queryMarket = async (query: ScallopQuery) => {
|
|
|
59
59
|
const collaterals: MarketCollaterals = {};
|
|
60
60
|
|
|
61
61
|
for (const pool of marketData.pools) {
|
|
62
|
+
const coinType = '0x' + pool.type.name;
|
|
63
|
+
const poolCoinName =
|
|
64
|
+
query.utils.parseCoinNameFromType<SupportPoolCoins>(coinType);
|
|
65
|
+
const coinPrice =
|
|
66
|
+
(await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName] ?? 0;
|
|
67
|
+
|
|
68
|
+
// Filter pools not yet supported by the SDK.
|
|
69
|
+
if (!SUPPORT_POOLS.includes(poolCoinName)) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
|
|
62
73
|
const parsedMarketPoolData = parseOriginMarketPoolData({
|
|
63
74
|
type: pool.type,
|
|
64
75
|
maxBorrowRate: pool.maxBorrowRate,
|
|
@@ -85,12 +96,6 @@ export const queryMarket = async (query: ScallopQuery) => {
|
|
|
85
96
|
parsedMarketPoolData
|
|
86
97
|
);
|
|
87
98
|
|
|
88
|
-
const coinType = '0x' + pool.type.name;
|
|
89
|
-
const poolCoinName =
|
|
90
|
-
query.utils.parseCoinNameFromType<SupportPoolCoins>(coinType);
|
|
91
|
-
const coinPrice =
|
|
92
|
-
(await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName] ?? 0;
|
|
93
|
-
|
|
94
99
|
pools[poolCoinName] = {
|
|
95
100
|
coinName: poolCoinName,
|
|
96
101
|
symbol: query.utils.parseSymbol(poolCoinName),
|
|
@@ -110,6 +115,19 @@ export const queryMarket = async (query: ScallopQuery) => {
|
|
|
110
115
|
}
|
|
111
116
|
|
|
112
117
|
for (const collateral of marketData.collaterals) {
|
|
118
|
+
const coinType = '0x' + collateral.type.name;
|
|
119
|
+
const collateralCoinName =
|
|
120
|
+
query.utils.parseCoinNameFromType<SupportCollateralCoins>(coinType);
|
|
121
|
+
const coinPrice =
|
|
122
|
+
(await query.utils.getCoinPrices([collateralCoinName]))?.[
|
|
123
|
+
collateralCoinName
|
|
124
|
+
] ?? 0;
|
|
125
|
+
|
|
126
|
+
// Filter collaterals not yet supported by the SDK.
|
|
127
|
+
if (!SUPPORT_COLLATERALS.includes(collateralCoinName)) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
|
|
113
131
|
const parsedMarketCollateralData = parseOriginMarketCollateralData({
|
|
114
132
|
type: collateral.type,
|
|
115
133
|
collateralFactor: collateral.collateralFactor,
|
|
@@ -126,14 +144,6 @@ export const queryMarket = async (query: ScallopQuery) => {
|
|
|
126
144
|
parsedMarketCollateralData
|
|
127
145
|
);
|
|
128
146
|
|
|
129
|
-
const coinType = '0x' + collateral.type.name;
|
|
130
|
-
const collateralCoinName =
|
|
131
|
-
query.utils.parseCoinNameFromType<SupportCollateralCoins>(coinType);
|
|
132
|
-
const coinPrice =
|
|
133
|
-
(await query.utils.getCoinPrices([collateralCoinName]))?.[
|
|
134
|
-
collateralCoinName
|
|
135
|
-
] ?? 0;
|
|
136
|
-
|
|
137
147
|
collaterals[collateralCoinName] = {
|
|
138
148
|
coinName: collateralCoinName,
|
|
139
149
|
symbol: query.utils.parseSymbol(collateralCoinName),
|
|
@@ -586,12 +596,44 @@ export const getObligations = async (
|
|
|
586
596
|
if (keyObject.content && 'fields' in keyObject.content) {
|
|
587
597
|
const fields = keyObject.content.fields as any;
|
|
588
598
|
const obligationId = String(fields.ownership.fields.of);
|
|
589
|
-
|
|
599
|
+
const locked = await getObligationLocked(query, obligationId);
|
|
600
|
+
obligations.push({ id: obligationId, keyId, locked });
|
|
590
601
|
}
|
|
591
602
|
}
|
|
592
603
|
return obligations;
|
|
593
604
|
};
|
|
594
605
|
|
|
606
|
+
/**
|
|
607
|
+
* Query obligation locked status.
|
|
608
|
+
*
|
|
609
|
+
* @param query - The Scallop query instance.
|
|
610
|
+
* @param obligationId - The obligation id.
|
|
611
|
+
* @return Obligation locked status.
|
|
612
|
+
*/
|
|
613
|
+
export const getObligationLocked = async (
|
|
614
|
+
query: ScallopQuery,
|
|
615
|
+
obligationId: string
|
|
616
|
+
) => {
|
|
617
|
+
const obligationObjectResponse = await query.suiKit.client().getObject({
|
|
618
|
+
id: obligationId,
|
|
619
|
+
options: {
|
|
620
|
+
showContent: true,
|
|
621
|
+
},
|
|
622
|
+
});
|
|
623
|
+
let obligationLocked = false;
|
|
624
|
+
if (
|
|
625
|
+
obligationObjectResponse.data &&
|
|
626
|
+
obligationObjectResponse?.data?.content?.dataType === 'moveObject' &&
|
|
627
|
+
'lock_key' in obligationObjectResponse.data.content.fields
|
|
628
|
+
) {
|
|
629
|
+
obligationLocked = Boolean(
|
|
630
|
+
obligationObjectResponse.data.content.fields.lock_key
|
|
631
|
+
);
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
return obligationLocked;
|
|
635
|
+
};
|
|
636
|
+
|
|
595
637
|
/**
|
|
596
638
|
* Query obligation data.
|
|
597
639
|
*
|
package/src/queries/index.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { normalizeStructTag } from '@mysten/sui.js/utils';
|
|
2
2
|
import { SUPPORT_SPOOLS } from '../constants';
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
parseOriginSpoolData,
|
|
5
|
+
calculateSpoolData,
|
|
6
|
+
parseOriginSpoolRewardPoolData,
|
|
7
|
+
calculateSpoolRewardPoolData,
|
|
8
8
|
isMarketCoin,
|
|
9
9
|
} from '../utils';
|
|
10
10
|
import type { SuiObjectResponse } from '@mysten/sui.js/client';
|
|
@@ -14,7 +14,7 @@ import type {
|
|
|
14
14
|
Spools,
|
|
15
15
|
Spool,
|
|
16
16
|
StakePool,
|
|
17
|
-
|
|
17
|
+
StakeRewardPool,
|
|
18
18
|
StakeAccounts,
|
|
19
19
|
SupportStakeMarketCoins,
|
|
20
20
|
SupportStakeCoins,
|
|
@@ -64,18 +64,17 @@ export const getSpools = async (
|
|
|
64
64
|
*/
|
|
65
65
|
export const getSpool = async (
|
|
66
66
|
query: ScallopQuery,
|
|
67
|
-
|
|
67
|
+
marketCoinName: SupportStakeMarketCoins,
|
|
68
68
|
marketPool?: MarketPool
|
|
69
69
|
) => {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const poolId = query.address.get(`spool.pools.${stakeMarketCoinName}.id`);
|
|
70
|
+
const coinName = query.utils.parseCoinName<SupportStakeCoins>(marketCoinName);
|
|
71
|
+
marketPool = marketPool || (await query.getMarketPool(coinName));
|
|
72
|
+
const poolId = query.address.get(`spool.pools.${marketCoinName}.id`);
|
|
74
73
|
const rewardPoolId = query.address.get(
|
|
75
|
-
`spool.pools.${
|
|
74
|
+
`spool.pools.${marketCoinName}.rewardPoolId`
|
|
76
75
|
);
|
|
77
76
|
let spool: Spool | undefined = undefined;
|
|
78
|
-
const
|
|
77
|
+
const spoolObjectResponse = await query.suiKit.client().multiGetObjects({
|
|
79
78
|
ids: [poolId, rewardPoolId],
|
|
80
79
|
options: {
|
|
81
80
|
showContent: true,
|
|
@@ -84,20 +83,20 @@ export const getSpool = async (
|
|
|
84
83
|
|
|
85
84
|
if (
|
|
86
85
|
marketPool &&
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
spoolObjectResponse[0].data &&
|
|
87
|
+
spoolObjectResponse[1].data
|
|
89
88
|
) {
|
|
90
|
-
const
|
|
89
|
+
const rewardCoinName = query.utils.getSpoolRewardCoinName(marketCoinName);
|
|
91
90
|
const coinPrices = await query.utils.getCoinPrices([
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
coinName,
|
|
92
|
+
rewardCoinName,
|
|
94
93
|
]);
|
|
95
94
|
|
|
96
|
-
const
|
|
97
|
-
const rewardPoolObject =
|
|
98
|
-
if (
|
|
99
|
-
const fields =
|
|
100
|
-
const
|
|
95
|
+
const spoolObject = spoolObjectResponse[0].data;
|
|
96
|
+
const rewardPoolObject = spoolObjectResponse[1].data;
|
|
97
|
+
if (spoolObject.content && 'fields' in spoolObject.content) {
|
|
98
|
+
const fields = spoolObject.content.fields as any;
|
|
99
|
+
const parsedSpoolData = parseOriginSpoolData({
|
|
101
100
|
stakeType: fields.stake_type,
|
|
102
101
|
maxDistributedPoint: fields.max_distributed_point,
|
|
103
102
|
distributedPoint: fields.distributed_point,
|
|
@@ -110,19 +109,18 @@ export const getSpool = async (
|
|
|
110
109
|
lastUpdate: fields.last_update,
|
|
111
110
|
});
|
|
112
111
|
|
|
113
|
-
const
|
|
114
|
-
(coinPrices?.[
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
stakeMarketCoinDecimal
|
|
112
|
+
const marketCoinPrice =
|
|
113
|
+
(coinPrices?.[coinName] ?? 0) * marketPool.conversionRate;
|
|
114
|
+
const marketCoinDecimal = query.utils.getCoinDecimal(marketCoinName);
|
|
115
|
+
const calculatedSpoolData = calculateSpoolData(
|
|
116
|
+
parsedSpoolData,
|
|
117
|
+
marketCoinPrice,
|
|
118
|
+
marketCoinDecimal
|
|
121
119
|
);
|
|
122
120
|
|
|
123
121
|
if (rewardPoolObject.content && 'fields' in rewardPoolObject.content) {
|
|
124
122
|
const fields = rewardPoolObject.content.fields as any;
|
|
125
|
-
const
|
|
123
|
+
const parsedSpoolRewardPoolData = parseOriginSpoolRewardPoolData({
|
|
126
124
|
claimed_rewards: fields.claimed_rewards,
|
|
127
125
|
exchange_rate_numerator: fields.exchange_rate_numerator,
|
|
128
126
|
exchange_rate_denominator: fields.exchange_rate_denominator,
|
|
@@ -130,31 +128,38 @@ export const getSpool = async (
|
|
|
130
128
|
spool_id: fields.spool_id,
|
|
131
129
|
});
|
|
132
130
|
|
|
133
|
-
const rewardCoinPrice = coinPrices?.[
|
|
134
|
-
const rewardCoinDecimal = query.utils.getCoinDecimal(
|
|
131
|
+
const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
|
|
132
|
+
const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
|
|
135
133
|
|
|
136
|
-
const calculatedRewardPoolData =
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
134
|
+
const calculatedRewardPoolData = calculateSpoolRewardPoolData(
|
|
135
|
+
parsedSpoolData,
|
|
136
|
+
parsedSpoolRewardPoolData,
|
|
137
|
+
calculatedSpoolData,
|
|
140
138
|
rewardCoinPrice,
|
|
141
139
|
rewardCoinDecimal
|
|
142
140
|
);
|
|
143
141
|
|
|
144
142
|
spool = {
|
|
145
|
-
marketCoinName:
|
|
146
|
-
symbol: query.utils.parseSymbol(
|
|
147
|
-
coinType: query.utils.parseCoinType(
|
|
148
|
-
marketCoinType: query.utils.parseMarketCoinType(
|
|
149
|
-
rewardCoinType: isMarketCoin(
|
|
150
|
-
? query.utils.parseMarketCoinType(
|
|
151
|
-
: query.utils.parseCoinType(
|
|
152
|
-
coinDecimal: query.utils.getCoinDecimal(
|
|
153
|
-
rewardCoinDecimal: query.utils.getCoinDecimal(
|
|
154
|
-
coinPrice: coinPrices?.[
|
|
155
|
-
marketCoinPrice:
|
|
143
|
+
marketCoinName: marketCoinName,
|
|
144
|
+
symbol: query.utils.parseSymbol(marketCoinName),
|
|
145
|
+
coinType: query.utils.parseCoinType(coinName),
|
|
146
|
+
marketCoinType: query.utils.parseMarketCoinType(coinName),
|
|
147
|
+
rewardCoinType: isMarketCoin(rewardCoinName)
|
|
148
|
+
? query.utils.parseMarketCoinType(rewardCoinName)
|
|
149
|
+
: query.utils.parseCoinType(rewardCoinName),
|
|
150
|
+
coinDecimal: query.utils.getCoinDecimal(coinName),
|
|
151
|
+
rewardCoinDecimal: query.utils.getCoinDecimal(rewardCoinName),
|
|
152
|
+
coinPrice: coinPrices?.[coinName] ?? 0,
|
|
153
|
+
marketCoinPrice: marketCoinPrice,
|
|
156
154
|
rewardCoinPrice: rewardCoinPrice,
|
|
157
|
-
|
|
155
|
+
maxPoint: parsedSpoolData.maxPoint,
|
|
156
|
+
distributedPoint: parsedSpoolData.distributedPoint,
|
|
157
|
+
maxStake: parsedSpoolData.maxStake,
|
|
158
|
+
...calculatedSpoolData,
|
|
159
|
+
exchangeRateNumerator:
|
|
160
|
+
parsedSpoolRewardPoolData.exchangeRateNumerator,
|
|
161
|
+
exchangeRateDenominator:
|
|
162
|
+
parsedSpoolRewardPoolData.exchangeRateDenominator,
|
|
158
163
|
...calculatedRewardPoolData,
|
|
159
164
|
};
|
|
160
165
|
}
|
|
@@ -281,6 +286,10 @@ export const getStakeAccounts = async (
|
|
|
281
286
|
/**
|
|
282
287
|
* Get stake pool data.
|
|
283
288
|
*
|
|
289
|
+
* @description
|
|
290
|
+
* For backward compatible, it is recommended to use `getSpool` method
|
|
291
|
+
* to get stake pool info in spool data.
|
|
292
|
+
*
|
|
284
293
|
* @param query - The Scallop query instance.
|
|
285
294
|
* @param marketCoinName - Specific support stake market coin name.
|
|
286
295
|
* @return Stake pool data.
|
|
@@ -334,39 +343,46 @@ export const getStakePool = async (
|
|
|
334
343
|
};
|
|
335
344
|
|
|
336
345
|
/**
|
|
337
|
-
* Get reward pool of the owner.
|
|
346
|
+
* Get stake reward pool of the owner.
|
|
347
|
+
*
|
|
348
|
+
* @description
|
|
349
|
+
* For backward compatible, it is recommended to use `getSpool` method
|
|
350
|
+
* to get reward info in spool data.
|
|
338
351
|
*
|
|
339
352
|
* @param query - The Scallop query instance.
|
|
340
353
|
* @param marketCoinName - Specific support stake market coin name.
|
|
341
|
-
* @return
|
|
354
|
+
* @return Stake reward pool.
|
|
342
355
|
*/
|
|
343
|
-
export const
|
|
356
|
+
export const getStakeRewardPool = async (
|
|
344
357
|
query: ScallopQuery,
|
|
345
358
|
marketCoinName: SupportStakeMarketCoins
|
|
346
359
|
) => {
|
|
347
360
|
const poolId = query.address.get(
|
|
348
361
|
`spool.pools.${marketCoinName}.rewardPoolId`
|
|
349
362
|
);
|
|
350
|
-
let
|
|
351
|
-
const
|
|
363
|
+
let stakeRewardPool: StakeRewardPool | undefined = undefined;
|
|
364
|
+
const stakeRewardPoolObjectResponse = await query.suiKit.client().getObject({
|
|
352
365
|
id: poolId,
|
|
353
366
|
options: {
|
|
354
367
|
showContent: true,
|
|
355
368
|
showType: true,
|
|
356
369
|
},
|
|
357
370
|
});
|
|
358
|
-
if (
|
|
359
|
-
const
|
|
360
|
-
const id =
|
|
361
|
-
const type =
|
|
362
|
-
if (
|
|
363
|
-
|
|
371
|
+
if (stakeRewardPoolObjectResponse.data) {
|
|
372
|
+
const stakeRewardPoolObject = stakeRewardPoolObjectResponse.data;
|
|
373
|
+
const id = stakeRewardPoolObject.objectId;
|
|
374
|
+
const type = stakeRewardPoolObject.type!;
|
|
375
|
+
if (
|
|
376
|
+
stakeRewardPoolObject.content &&
|
|
377
|
+
'fields' in stakeRewardPoolObject.content
|
|
378
|
+
) {
|
|
379
|
+
const fields = stakeRewardPoolObject.content.fields as any;
|
|
364
380
|
const stakePoolId = String(fields.spool_id);
|
|
365
381
|
const ratioNumerator = Number(fields.exchange_rate_numerator);
|
|
366
382
|
const ratioDenominator = Number(fields.exchange_rate_denominator);
|
|
367
383
|
const rewards = Number(fields.rewards);
|
|
368
384
|
const claimedRewards = Number(fields.claimed_rewards);
|
|
369
|
-
|
|
385
|
+
stakeRewardPool = {
|
|
370
386
|
id,
|
|
371
387
|
type,
|
|
372
388
|
stakePoolId,
|
|
@@ -377,5 +393,5 @@ export const getRewardPool = async (
|
|
|
377
393
|
};
|
|
378
394
|
}
|
|
379
395
|
}
|
|
380
|
-
return
|
|
396
|
+
return stakeRewardPool;
|
|
381
397
|
};
|
package/src/types/address.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SUPPORT_ORACLES } from '../constants';
|
|
2
2
|
import type {
|
|
3
|
-
|
|
3
|
+
SupportAssetCoins,
|
|
4
4
|
SupportOracleType,
|
|
5
5
|
SupportPackageType,
|
|
6
6
|
SupportStakeMarketCoins,
|
|
@@ -13,9 +13,10 @@ export interface AddressesInterface {
|
|
|
13
13
|
market: string;
|
|
14
14
|
adminCap: string;
|
|
15
15
|
coinDecimalsRegistry: string;
|
|
16
|
+
obligationAccessStore: string;
|
|
16
17
|
coins: Partial<
|
|
17
18
|
Record<
|
|
18
|
-
|
|
19
|
+
SupportAssetCoins,
|
|
19
20
|
{
|
|
20
21
|
id: string;
|
|
21
22
|
treasury: string;
|
|
@@ -80,6 +81,13 @@ export interface AddressesInterface {
|
|
|
80
81
|
>
|
|
81
82
|
>;
|
|
82
83
|
};
|
|
84
|
+
borrowIncentive: {
|
|
85
|
+
id: string;
|
|
86
|
+
adminCap: string;
|
|
87
|
+
query: string;
|
|
88
|
+
incentivePools: string;
|
|
89
|
+
incentiveAccounts: string;
|
|
90
|
+
};
|
|
83
91
|
}
|
|
84
92
|
|
|
85
93
|
type AddressPathsProps<T> = T extends string
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SuiTxBlock as SuiKitTxBlock,
|
|
3
|
+
SuiAddressArg,
|
|
4
|
+
} from '@scallop-io/sui-kit';
|
|
5
|
+
import type { TransactionResult } from '@mysten/sui.js/transactions';
|
|
6
|
+
import type { ScallopBuilder } from '../../models';
|
|
7
|
+
import type { SupportBorrowIncentiveCoins } from '../constant';
|
|
8
|
+
|
|
9
|
+
export type BorrowIncentiveIds = {
|
|
10
|
+
borrowIncentivePkg: string;
|
|
11
|
+
query: string;
|
|
12
|
+
incentivePools: string;
|
|
13
|
+
incentiveAccounts: string;
|
|
14
|
+
obligationAccessStore: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type BorrowIncentiveNormalMethods = {
|
|
18
|
+
stakeObligation: (
|
|
19
|
+
obligation: SuiAddressArg,
|
|
20
|
+
obligaionKey: SuiAddressArg,
|
|
21
|
+
coinName: SupportBorrowIncentiveCoins
|
|
22
|
+
) => void;
|
|
23
|
+
unstakeObligation: (
|
|
24
|
+
obligation: SuiAddressArg,
|
|
25
|
+
obligaionKey: SuiAddressArg,
|
|
26
|
+
coinName: SupportBorrowIncentiveCoins
|
|
27
|
+
) => void;
|
|
28
|
+
claimBorrowIncentive: (
|
|
29
|
+
obligation: SuiAddressArg,
|
|
30
|
+
obligaionKey: SuiAddressArg,
|
|
31
|
+
coinName: SupportBorrowIncentiveCoins
|
|
32
|
+
) => TransactionResult;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type BorrowIncentiveQuickMethods = {
|
|
36
|
+
stakeObligationQuick(
|
|
37
|
+
coinName: SupportBorrowIncentiveCoins,
|
|
38
|
+
obligation?: SuiAddressArg,
|
|
39
|
+
obligationKey?: SuiAddressArg
|
|
40
|
+
): Promise<void>;
|
|
41
|
+
unstakeObligationQuick(
|
|
42
|
+
coinName: SupportBorrowIncentiveCoins,
|
|
43
|
+
obligation?: SuiAddressArg,
|
|
44
|
+
obligationKey?: SuiAddressArg
|
|
45
|
+
): Promise<void>;
|
|
46
|
+
claimBorrowIncentiveQuick(
|
|
47
|
+
coinName: SupportBorrowIncentiveCoins,
|
|
48
|
+
obligation?: SuiAddressArg,
|
|
49
|
+
obligationKey?: SuiAddressArg
|
|
50
|
+
): Promise<TransactionResult>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type SuiTxBlockWithBorrowIncentiveNormalMethods = SuiKitTxBlock &
|
|
54
|
+
BorrowIncentiveNormalMethods;
|
|
55
|
+
|
|
56
|
+
export type BorrowIncentiveTxBlock =
|
|
57
|
+
SuiTxBlockWithBorrowIncentiveNormalMethods & BorrowIncentiveQuickMethods;
|
|
58
|
+
|
|
59
|
+
export type GenerateBorrowIncentiveNormalMethod = (params: {
|
|
60
|
+
builder: ScallopBuilder;
|
|
61
|
+
txBlock: SuiKitTxBlock;
|
|
62
|
+
}) => BorrowIncentiveNormalMethods;
|
|
63
|
+
|
|
64
|
+
export type GenerateBorrowIncentiveQuickMethod = (params: {
|
|
65
|
+
builder: ScallopBuilder;
|
|
66
|
+
txBlock: SuiTxBlockWithBorrowIncentiveNormalMethods;
|
|
67
|
+
}) => BorrowIncentiveQuickMethods;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { CoreTxBlock } from './core';
|
|
2
2
|
import type { SpoolTxBlock } from './spool';
|
|
3
|
+
import type { BorrowIncentiveTxBlock } from './borrowIncentive';
|
|
3
4
|
|
|
4
5
|
export type * from './core';
|
|
5
6
|
export type * from './spool';
|
|
7
|
+
export type * from './borrowIncentive';
|
|
6
8
|
|
|
7
|
-
export type ScallopTxBlock = CoreTxBlock &
|
|
9
|
+
export type ScallopTxBlock = CoreTxBlock &
|
|
10
|
+
SpoolTxBlock &
|
|
11
|
+
BorrowIncentiveTxBlock;
|
|
@@ -4,7 +4,9 @@ import {
|
|
|
4
4
|
SUPPORT_ORACLES,
|
|
5
5
|
SUPPORT_PACKAGES,
|
|
6
6
|
SUPPORT_SPOOLS,
|
|
7
|
-
|
|
7
|
+
SUPPORT_SPOOLS_REWARDS,
|
|
8
|
+
SUPPORT_BORROW_INCENTIVE_POOLS,
|
|
9
|
+
SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
8
10
|
} from '../../constants';
|
|
9
11
|
|
|
10
12
|
type ParseMarketCoins<T extends string> = `s${T}`;
|
|
@@ -17,7 +19,8 @@ export type SupportCoins =
|
|
|
17
19
|
export type SupportAssetCoins =
|
|
18
20
|
| SupportPoolCoins
|
|
19
21
|
| SupportCollateralCoins
|
|
20
|
-
|
|
|
22
|
+
| SupportStakeRewardCoins
|
|
23
|
+
| SupportBorrowIncentiveRewardCoins;
|
|
21
24
|
export type SupportPoolCoins = (typeof SUPPORT_POOLS)[number];
|
|
22
25
|
export type SupportCollateralCoins = (typeof SUPPORT_COLLATERALS)[number];
|
|
23
26
|
export type SupportMarketCoins =
|
|
@@ -28,7 +31,11 @@ export type SupportStakeCoins = Extract<
|
|
|
28
31
|
SupportPoolCoins,
|
|
29
32
|
ParseCoins<SupportStakeMarketCoins>
|
|
30
33
|
>;
|
|
31
|
-
export type
|
|
34
|
+
export type SupportStakeRewardCoins = (typeof SUPPORT_SPOOLS_REWARDS)[number];
|
|
35
|
+
export type SupportBorrowIncentiveCoins =
|
|
36
|
+
(typeof SUPPORT_BORROW_INCENTIVE_POOLS)[number];
|
|
37
|
+
export type SupportBorrowIncentiveRewardCoins =
|
|
38
|
+
(typeof SUPPORT_BORROW_INCENTIVE_REWARDS)[number];
|
|
32
39
|
|
|
33
40
|
export type SupportOracleType = (typeof SUPPORT_ORACLES)[number];
|
|
34
41
|
|
|
@@ -3,7 +3,9 @@ import {
|
|
|
3
3
|
SupportAssetCoins,
|
|
4
4
|
SupportMarketCoins,
|
|
5
5
|
SupportStakeMarketCoins,
|
|
6
|
-
|
|
6
|
+
SupportStakeRewardCoins,
|
|
7
|
+
SupportBorrowIncentiveCoins,
|
|
8
|
+
SupportBorrowIncentiveRewardCoins,
|
|
7
9
|
} from './common';
|
|
8
10
|
|
|
9
11
|
export type Coins = {
|
|
@@ -22,8 +24,12 @@ export type StakeMarketCoins = {
|
|
|
22
24
|
[K in SupportStakeMarketCoins]: K;
|
|
23
25
|
};
|
|
24
26
|
|
|
25
|
-
export type
|
|
26
|
-
[key in SupportStakeMarketCoins]:
|
|
27
|
+
export type StakeRewardCoins = {
|
|
28
|
+
[key in SupportStakeMarketCoins]: SupportStakeRewardCoins;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export type BorrowIncentiveRewardCoins = {
|
|
32
|
+
[key in SupportBorrowIncentiveCoins]: SupportBorrowIncentiveRewardCoins;
|
|
27
33
|
};
|
|
28
34
|
|
|
29
35
|
export type AssetCoinIds = {
|
|
@@ -38,3 +44,7 @@ export type WormholeCoinIds = {
|
|
|
38
44
|
'eth' | 'btc' | 'usdc' | 'usdt' | 'apt' | 'sol'
|
|
39
45
|
>]: string;
|
|
40
46
|
};
|
|
47
|
+
|
|
48
|
+
export type VoloCoinIds = {
|
|
49
|
+
[key in PickFromUnion<SupportAssetCoins, 'vsui'>]: string;
|
|
50
|
+
};
|