@scallop-io/sui-scallop-sdk 0.44.17 → 0.44.19
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 +7 -0
- package/dist/builders/vescaBuilder.d.ts +24 -0
- package/dist/constants/common.d.ts +7 -4
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/vesca.d.ts +5 -0
- package/dist/index.js +878 -255
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +867 -248
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopClient.d.ts +7 -7
- package/dist/models/scallopUtils.d.ts +16 -14
- package/dist/queries/index.d.ts +1 -0
- package/dist/queries/vescaQuery.d.ts +28 -0
- package/dist/types/address.d.ts +9 -0
- package/dist/types/builder/borrowIncentive.d.ts +9 -6
- package/dist/types/builder/index.d.ts +3 -1
- package/dist/types/builder/vesca.d.ts +33 -0
- package/dist/types/constant/enum.d.ts +1 -1
- package/dist/types/query/borrowIncentive.d.ts +65 -60
- package/dist/types/query/index.d.ts +1 -0
- package/dist/types/query/portfolio.d.ts +12 -6
- package/dist/types/query/vesca.d.ts +7 -0
- package/dist/types/utils.d.ts +1 -2
- package/dist/utils/builder.d.ts +6 -0
- package/dist/utils/query.d.ts +4 -10
- package/dist/utils/util.d.ts +7 -0
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +174 -25
- package/src/builders/index.ts +6 -2
- package/src/builders/vescaBuilder.ts +392 -0
- package/src/constants/common.ts +19 -6
- package/src/constants/enum.ts +9 -3
- package/src/constants/index.ts +1 -0
- package/src/constants/vesca.ts +7 -0
- package/src/models/scallopAddress.ts +9 -1
- package/src/models/scallopClient.ts +29 -20
- package/src/models/scallopUtils.ts +45 -0
- package/src/queries/borrowIncentiveQuery.ts +93 -83
- package/src/queries/coreQuery.ts +19 -20
- package/src/queries/index.ts +1 -0
- package/src/queries/portfolioQuery.ts +79 -41
- package/src/queries/spoolQuery.ts +1 -1
- package/src/queries/vescaQuery.ts +124 -0
- package/src/types/address.ts +9 -0
- package/src/types/builder/borrowIncentive.ts +22 -5
- package/src/types/builder/index.ts +4 -1
- package/src/types/builder/vesca.ts +73 -0
- package/src/types/constant/enum.ts +1 -1
- package/src/types/query/borrowIncentive.ts +195 -74
- package/src/types/query/index.ts +1 -0
- package/src/types/query/portfolio.ts +17 -6
- package/src/types/query/vesca.ts +7 -0
- package/src/types/utils.ts +1 -1
- package/src/utils/builder.ts +141 -0
- package/src/utils/query.ts +227 -131
- package/src/utils/util.ts +28 -0
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
4
|
+
SUPPORT_POOLS,
|
|
5
|
+
SUPPORT_SPOOLS,
|
|
6
|
+
} from '../constants';
|
|
3
7
|
import { minBigNumber, estimatedFactor } from 'src/utils';
|
|
4
8
|
import type { ScallopQuery } from '../models';
|
|
5
9
|
import type {
|
|
6
10
|
Market,
|
|
7
|
-
SupportAssetCoins,
|
|
8
11
|
SupportPoolCoins,
|
|
9
12
|
MarketPool,
|
|
10
13
|
Spool,
|
|
@@ -20,6 +23,7 @@ import type {
|
|
|
20
23
|
SupportMarketCoins,
|
|
21
24
|
TotalValueLocked,
|
|
22
25
|
SupportBorrowIncentiveCoins,
|
|
26
|
+
ObligationBorrowIcentiveReward,
|
|
23
27
|
} from '../types';
|
|
24
28
|
|
|
25
29
|
/**
|
|
@@ -309,9 +313,8 @@ export const getObligationAccount = async (
|
|
|
309
313
|
coinAmounts?: CoinAmounts
|
|
310
314
|
) => {
|
|
311
315
|
market = market || (await query.queryMarket(indexer));
|
|
312
|
-
const
|
|
316
|
+
const collateralAssetCoinNames: SupportCollateralCoins[] = [
|
|
313
317
|
...new Set([
|
|
314
|
-
...Object.values(market.pools).map((pool) => pool.coinName),
|
|
315
318
|
...Object.values(market.collaterals).map(
|
|
316
319
|
(collateral) => collateral.coinName
|
|
317
320
|
),
|
|
@@ -324,9 +327,11 @@ export const getObligationAccount = async (
|
|
|
324
327
|
);
|
|
325
328
|
const borrowIncentiveAccounts =
|
|
326
329
|
await query.getBorrowIncentiveAccounts(obligationId);
|
|
327
|
-
coinPrices =
|
|
330
|
+
coinPrices =
|
|
331
|
+
coinPrices || (await query.utils.getCoinPrices(collateralAssetCoinNames));
|
|
328
332
|
coinAmounts =
|
|
329
|
-
coinAmounts ||
|
|
333
|
+
coinAmounts ||
|
|
334
|
+
(await query.getCoinAmounts(collateralAssetCoinNames, ownerAddress));
|
|
330
335
|
|
|
331
336
|
const collaterals: ObligationAccount['collaterals'] = {};
|
|
332
337
|
const debts: ObligationAccount['debts'] = {};
|
|
@@ -339,7 +344,7 @@ export const getObligationAccount = async (
|
|
|
339
344
|
let totalBorrowedValue = BigNumber(0);
|
|
340
345
|
let totalBorrowedValueWithWeight = BigNumber(0);
|
|
341
346
|
|
|
342
|
-
for (const assetCoinName of
|
|
347
|
+
for (const assetCoinName of collateralAssetCoinNames) {
|
|
343
348
|
const collateral = obligationQuery.collaterals.find((collateral) => {
|
|
344
349
|
const collateralCoinName =
|
|
345
350
|
query.utils.parseCoinNameFromType<SupportCollateralCoins>(
|
|
@@ -405,7 +410,11 @@ export const getObligationAccount = async (
|
|
|
405
410
|
}
|
|
406
411
|
}
|
|
407
412
|
|
|
408
|
-
|
|
413
|
+
const borrowAssetCoinNames: SupportPoolCoins[] = [
|
|
414
|
+
...new Set([...Object.values(market.pools).map((pool) => pool.coinName)]),
|
|
415
|
+
];
|
|
416
|
+
|
|
417
|
+
for (const assetCoinName of borrowAssetCoinNames) {
|
|
409
418
|
const debt = obligationQuery.debts.find((debt) => {
|
|
410
419
|
const poolCoinName = query.utils.parseCoinNameFromType<SupportPoolCoins>(
|
|
411
420
|
debt.type.name
|
|
@@ -476,41 +485,70 @@ export const getObligationAccount = async (
|
|
|
476
485
|
const coinName = poolCoinName as SupportBorrowIncentiveCoins;
|
|
477
486
|
const borrowIncentivePool = borrowIncentivePools[coinName];
|
|
478
487
|
|
|
479
|
-
let availableClaimAmount = BigNumber(0);
|
|
480
|
-
let availableClaimCoin = BigNumber(0);
|
|
481
488
|
if (borrowIncentivePool) {
|
|
482
|
-
const
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
.
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
489
|
+
const rewards: ObligationBorrowIcentiveReward[] = [];
|
|
490
|
+
for (const rewardCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
|
|
491
|
+
const accountPoint = borrowIncentiveAccount.pointList[rewardCoinName];
|
|
492
|
+
const poolPoint = borrowIncentivePool.points[rewardCoinName];
|
|
493
|
+
|
|
494
|
+
if (accountPoint && poolPoint) {
|
|
495
|
+
let availableClaimAmount = BigNumber(0);
|
|
496
|
+
let availableClaimCoin = BigNumber(0);
|
|
497
|
+
const accountBorrowedAmount = BigNumber(accountPoint.weightedAmount);
|
|
498
|
+
const baseIndexRate = 1_000_000_000;
|
|
499
|
+
const increasedPointRate = poolPoint.currentPointIndex
|
|
500
|
+
? BigNumber(
|
|
501
|
+
poolPoint.currentPointIndex - accountPoint.index
|
|
502
|
+
).dividedBy(baseIndexRate)
|
|
503
|
+
: 1;
|
|
504
|
+
availableClaimAmount = availableClaimAmount.plus(
|
|
505
|
+
accountBorrowedAmount
|
|
506
|
+
.multipliedBy(increasedPointRate)
|
|
507
|
+
.plus(accountPoint.points)
|
|
508
|
+
);
|
|
509
|
+
availableClaimCoin = availableClaimAmount.shiftedBy(
|
|
510
|
+
-1 * poolPoint.coinDecimal
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
// for veSCA
|
|
514
|
+
// console.log('poolPoint.weightedAmount', poolPoint.weightedAmount);
|
|
515
|
+
// console.log(
|
|
516
|
+
// 'borrowIncentiveAccount.amount',
|
|
517
|
+
// borrowIncentiveAccount.debtAmount
|
|
518
|
+
// );
|
|
519
|
+
const weightScale = BigNumber('1000000000000');
|
|
520
|
+
|
|
521
|
+
const boostValue = BigNumber(accountPoint.weightedAmount)
|
|
522
|
+
.div(
|
|
523
|
+
BigNumber(borrowIncentiveAccount.debtAmount)
|
|
524
|
+
.multipliedBy(poolPoint.baseWeight)
|
|
525
|
+
.dividedBy(weightScale)
|
|
526
|
+
)
|
|
527
|
+
.toNumber();
|
|
528
|
+
|
|
529
|
+
if (availableClaimAmount.isGreaterThan(0)) {
|
|
530
|
+
rewards.push({
|
|
531
|
+
coinName: poolPoint.coinName,
|
|
532
|
+
coinType: poolPoint.coinType,
|
|
533
|
+
symbol: poolPoint.symbol,
|
|
534
|
+
coinDecimal: poolPoint.coinDecimal,
|
|
535
|
+
coinPrice: poolPoint.coinPrice,
|
|
536
|
+
availableClaimAmount: availableClaimAmount.toNumber(),
|
|
537
|
+
availableClaimCoin: availableClaimCoin.toNumber(),
|
|
538
|
+
boostValue,
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
}
|
|
513
542
|
}
|
|
543
|
+
|
|
544
|
+
borrowIncentives[coinName] = {
|
|
545
|
+
coinName: borrowIncentivePool.coinName,
|
|
546
|
+
coinType: borrowIncentivePool.coinType,
|
|
547
|
+
symbol: borrowIncentivePool.symbol,
|
|
548
|
+
coinDecimal: borrowIncentivePool.coinDecimal,
|
|
549
|
+
coinPrice: borrowIncentivePool.coinPrice,
|
|
550
|
+
rewards,
|
|
551
|
+
};
|
|
514
552
|
}
|
|
515
553
|
}
|
|
516
554
|
|
|
@@ -243,7 +243,7 @@ export const getStakeAccounts = async (
|
|
|
243
243
|
const stakeAccountType = `${spoolObjectId}::spool_account::SpoolAccount`;
|
|
244
244
|
const stakeObjectsResponse: SuiObjectResponse[] = [];
|
|
245
245
|
let hasNextPage = false;
|
|
246
|
-
let nextCursor: string | null = null;
|
|
246
|
+
let nextCursor: string | null | undefined = null;
|
|
247
247
|
do {
|
|
248
248
|
const paginatedStakeObjectsResponse = await query.suiKit
|
|
249
249
|
.client()
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
import { Vesca } from '../types';
|
|
3
|
+
import type { SuiObjectResponse, SuiObjectData } from '@mysten/sui.js/client';
|
|
4
|
+
import type { ScallopQuery } from '../models';
|
|
5
|
+
import { IS_VE_SCA_TEST } from 'src/constants';
|
|
6
|
+
/**
|
|
7
|
+
* Query all owned veSca key.
|
|
8
|
+
*
|
|
9
|
+
* @param query - The Scallop query instance.
|
|
10
|
+
* @param ownerAddress - The owner address.
|
|
11
|
+
* @return Owned veSca key.
|
|
12
|
+
*/
|
|
13
|
+
export const getVescaKeys = async (
|
|
14
|
+
query: ScallopQuery,
|
|
15
|
+
ownerAddress?: string
|
|
16
|
+
) => {
|
|
17
|
+
const owner = ownerAddress || query.suiKit.currentAddress();
|
|
18
|
+
const veScaPkgId = IS_VE_SCA_TEST
|
|
19
|
+
? '0xb220d034bdf335d77ae5bfbf6daf059c2cc7a1f719b12bfed75d1736fac038c8'
|
|
20
|
+
: query.address.get('vesca.id');
|
|
21
|
+
const veScaKeyType = `${veScaPkgId}::ve_sca::VeScaKey`;
|
|
22
|
+
const keyObjectsResponse: SuiObjectResponse[] = [];
|
|
23
|
+
let hasNextPage = false;
|
|
24
|
+
let nextCursor: string | null | undefined = null;
|
|
25
|
+
do {
|
|
26
|
+
const paginatedKeyObjectsResponse = await query.suiKit
|
|
27
|
+
.client()
|
|
28
|
+
.getOwnedObjects({
|
|
29
|
+
owner,
|
|
30
|
+
filter: {
|
|
31
|
+
StructType: veScaKeyType,
|
|
32
|
+
},
|
|
33
|
+
cursor: nextCursor,
|
|
34
|
+
});
|
|
35
|
+
keyObjectsResponse.push(...paginatedKeyObjectsResponse.data);
|
|
36
|
+
if (
|
|
37
|
+
paginatedKeyObjectsResponse.hasNextPage &&
|
|
38
|
+
paginatedKeyObjectsResponse.nextCursor
|
|
39
|
+
) {
|
|
40
|
+
hasNextPage = true;
|
|
41
|
+
nextCursor = paginatedKeyObjectsResponse.nextCursor;
|
|
42
|
+
} else {
|
|
43
|
+
hasNextPage = false;
|
|
44
|
+
}
|
|
45
|
+
} while (hasNextPage);
|
|
46
|
+
|
|
47
|
+
const keyObjectDatas = keyObjectsResponse
|
|
48
|
+
.map((objResponse) => objResponse.data)
|
|
49
|
+
.filter((data) => !!data) as SuiObjectData[];
|
|
50
|
+
return keyObjectDatas;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Query all owned veSca.
|
|
55
|
+
*
|
|
56
|
+
* @param query - The Scallop query instance.
|
|
57
|
+
* @param ownerAddress - The owner address.
|
|
58
|
+
* @return Owned veScas.
|
|
59
|
+
*/
|
|
60
|
+
export const getVeScas = async (query: ScallopQuery, ownerAddress?: string) => {
|
|
61
|
+
const keyObjectDatas = await getVescaKeys(query, ownerAddress);
|
|
62
|
+
const keyObjectId: string[] = keyObjectDatas.map((data) => data.objectId);
|
|
63
|
+
|
|
64
|
+
const veScas: Vesca[] = [];
|
|
65
|
+
for (const keyId of keyObjectId) {
|
|
66
|
+
const veSca = await getVeSca(query, keyId);
|
|
67
|
+
if (veSca) veScas.push(veSca);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return veScas;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Get veSca data.
|
|
75
|
+
*
|
|
76
|
+
* @param query - The Scallop query instance.
|
|
77
|
+
* @param veScaKeyId - The vesca key id.
|
|
78
|
+
* @param ownerAddress - The owner address.
|
|
79
|
+
* @returns Vesca data.
|
|
80
|
+
*/
|
|
81
|
+
export const getVeSca = async (
|
|
82
|
+
query: ScallopQuery,
|
|
83
|
+
veScaKeyId?: string,
|
|
84
|
+
ownerAddress?: string
|
|
85
|
+
) => {
|
|
86
|
+
const tableId = IS_VE_SCA_TEST
|
|
87
|
+
? '0xc607241e4a679fe376d1170b2fbe07b64917bfe69100d4825241cda20039d4bd'
|
|
88
|
+
: query.address.get(`vesca.tableId`);
|
|
89
|
+
veScaKeyId =
|
|
90
|
+
veScaKeyId || (await getVescaKeys(query, ownerAddress))[0].objectId;
|
|
91
|
+
|
|
92
|
+
let vesca: Vesca | undefined = undefined;
|
|
93
|
+
|
|
94
|
+
const veScaDynamicFieldObjectResponse = await query.suiKit
|
|
95
|
+
.client()
|
|
96
|
+
.getDynamicFieldObject({
|
|
97
|
+
parentId: tableId,
|
|
98
|
+
name: {
|
|
99
|
+
type: '0x2::object::ID',
|
|
100
|
+
value: veScaKeyId,
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
|
+
const veScaDynamicFieldObject = veScaDynamicFieldObjectResponse.data;
|
|
104
|
+
if (
|
|
105
|
+
veScaDynamicFieldObject &&
|
|
106
|
+
veScaDynamicFieldObject.content &&
|
|
107
|
+
veScaDynamicFieldObject.content.dataType === 'moveObject' &&
|
|
108
|
+
'fields' in veScaDynamicFieldObject.content
|
|
109
|
+
) {
|
|
110
|
+
const dynamicFields = (veScaDynamicFieldObject.content.fields as any).value
|
|
111
|
+
.fields;
|
|
112
|
+
vesca = {
|
|
113
|
+
id: veScaDynamicFieldObject.objectId,
|
|
114
|
+
keyId: veScaKeyId,
|
|
115
|
+
lockedScaAmount: BigNumber(dynamicFields.locked_sca_amount).toNumber(),
|
|
116
|
+
lockedScaCoin: BigNumber(dynamicFields.locked_sca_amount)
|
|
117
|
+
.shiftedBy(-9)
|
|
118
|
+
.toNumber(),
|
|
119
|
+
unlockAt: BigNumber(dynamicFields.unlock_at).toNumber(),
|
|
120
|
+
} as Vesca;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return vesca;
|
|
124
|
+
};
|
package/src/types/address.ts
CHANGED
|
@@ -88,9 +88,18 @@ export interface AddressesInterface {
|
|
|
88
88
|
adminCap: string;
|
|
89
89
|
object: string;
|
|
90
90
|
query: string;
|
|
91
|
+
config: string;
|
|
91
92
|
incentivePools: string;
|
|
92
93
|
incentiveAccounts: string;
|
|
93
94
|
};
|
|
95
|
+
vesca: {
|
|
96
|
+
id: string;
|
|
97
|
+
adminCap: string;
|
|
98
|
+
tableId: string;
|
|
99
|
+
table: string;
|
|
100
|
+
treasury: string;
|
|
101
|
+
config: string;
|
|
102
|
+
};
|
|
94
103
|
}
|
|
95
104
|
|
|
96
105
|
type AddressPathsProps<T> = T extends string
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
SuiTxBlock as SuiKitTxBlock,
|
|
3
3
|
SuiAddressArg,
|
|
4
|
+
SuiTxArg,
|
|
4
5
|
} from '@scallop-io/sui-kit';
|
|
5
6
|
import type { TransactionResult } from '@mysten/sui.js/transactions';
|
|
6
7
|
import type { ScallopBuilder } from '../../models';
|
|
7
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
SupportBorrowIncentiveCoins,
|
|
10
|
+
SupportBorrowIncentiveRewardCoins,
|
|
11
|
+
} from '../constant';
|
|
8
12
|
|
|
9
13
|
export type BorrowIncentiveIds = {
|
|
10
14
|
borrowIncentivePkg: string;
|
|
11
15
|
query: string;
|
|
16
|
+
config: string;
|
|
12
17
|
incentivePools: string;
|
|
13
18
|
incentiveAccounts: string;
|
|
14
19
|
obligationAccessStore: string;
|
|
@@ -17,16 +22,22 @@ export type BorrowIncentiveIds = {
|
|
|
17
22
|
export type BorrowIncentiveNormalMethods = {
|
|
18
23
|
stakeObligation: (
|
|
19
24
|
obligation: SuiAddressArg,
|
|
20
|
-
|
|
25
|
+
obligationKey: SuiAddressArg
|
|
26
|
+
) => void;
|
|
27
|
+
stakeObligationWithVesca: (
|
|
28
|
+
obligation: SuiAddressArg,
|
|
29
|
+
obligationKey: SuiAddressArg,
|
|
30
|
+
veScaKey: SuiTxArg
|
|
21
31
|
) => void;
|
|
22
32
|
unstakeObligation: (
|
|
23
33
|
obligation: SuiAddressArg,
|
|
24
|
-
|
|
34
|
+
obligationKey: SuiAddressArg
|
|
25
35
|
) => void;
|
|
26
36
|
claimBorrowIncentive: (
|
|
27
37
|
obligation: SuiAddressArg,
|
|
28
|
-
|
|
29
|
-
coinName: SupportBorrowIncentiveCoins
|
|
38
|
+
obligationKey: SuiAddressArg,
|
|
39
|
+
coinName: SupportBorrowIncentiveCoins,
|
|
40
|
+
rewardType: SupportBorrowIncentiveRewardCoins
|
|
30
41
|
) => TransactionResult;
|
|
31
42
|
};
|
|
32
43
|
|
|
@@ -35,12 +46,18 @@ export type BorrowIncentiveQuickMethods = {
|
|
|
35
46
|
obligation?: SuiAddressArg,
|
|
36
47
|
obligationKey?: SuiAddressArg
|
|
37
48
|
): Promise<void>;
|
|
49
|
+
stakeObligationWithVeScaQuick(
|
|
50
|
+
obligation?: SuiAddressArg,
|
|
51
|
+
obligationKey?: SuiAddressArg,
|
|
52
|
+
veScaKey?: SuiAddressArg
|
|
53
|
+
): Promise<void>;
|
|
38
54
|
unstakeObligationQuick(
|
|
39
55
|
obligation?: SuiAddressArg,
|
|
40
56
|
obligationKey?: SuiAddressArg
|
|
41
57
|
): Promise<void>;
|
|
42
58
|
claimBorrowIncentiveQuick(
|
|
43
59
|
coinName: SupportBorrowIncentiveCoins,
|
|
60
|
+
rewardType: SupportBorrowIncentiveRewardCoins,
|
|
44
61
|
obligation?: SuiAddressArg,
|
|
45
62
|
obligationKey?: SuiAddressArg
|
|
46
63
|
): Promise<TransactionResult>;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { CoreTxBlock } from './core';
|
|
2
2
|
import type { SpoolTxBlock } from './spool';
|
|
3
3
|
import type { BorrowIncentiveTxBlock } from './borrowIncentive';
|
|
4
|
+
import type { VeScaTxBlock } from './vesca';
|
|
4
5
|
|
|
5
6
|
export type * from './core';
|
|
6
7
|
export type * from './spool';
|
|
7
8
|
export type * from './borrowIncentive';
|
|
9
|
+
export type * from './vesca';
|
|
8
10
|
|
|
9
11
|
export type ScallopTxBlock = CoreTxBlock &
|
|
10
12
|
SpoolTxBlock &
|
|
11
|
-
BorrowIncentiveTxBlock
|
|
13
|
+
BorrowIncentiveTxBlock &
|
|
14
|
+
VeScaTxBlock;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SuiTxBlock as SuiKitTxBlock,
|
|
3
|
+
SuiAddressArg,
|
|
4
|
+
SuiObjectArg,
|
|
5
|
+
SuiTxArg,
|
|
6
|
+
} from '@scallop-io/sui-kit';
|
|
7
|
+
import type { TransactionResult } from '@mysten/sui.js/transactions';
|
|
8
|
+
import { ScallopBuilder } from 'src/models';
|
|
9
|
+
|
|
10
|
+
export type VescaIds = {
|
|
11
|
+
pkgId: string;
|
|
12
|
+
table: string;
|
|
13
|
+
treasury: string;
|
|
14
|
+
config: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type VeScaNormalMethods = {
|
|
18
|
+
lockSca: (
|
|
19
|
+
scaCoin: SuiObjectArg,
|
|
20
|
+
unlockAtInSecondTimestamp: SuiTxArg
|
|
21
|
+
) => TransactionResult;
|
|
22
|
+
extendLockPeriod: (
|
|
23
|
+
veScaKey: SuiAddressArg,
|
|
24
|
+
newUnlockAtInSecondTimestamp: SuiTxArg
|
|
25
|
+
) => void;
|
|
26
|
+
extendLockAmount: (veScaKey: SuiAddressArg, scaCoin: SuiObjectArg) => void;
|
|
27
|
+
renewExpiredVeSca: (
|
|
28
|
+
veScaKey: SuiAddressArg,
|
|
29
|
+
scaCoin: SuiObjectArg,
|
|
30
|
+
newUnlockAtInSecondTimestamp: SuiTxArg
|
|
31
|
+
) => void;
|
|
32
|
+
redeemSca: (veScaKey: SuiAddressArg) => TransactionResult;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type VeScaQuickMethods = {
|
|
36
|
+
lockScaQuick(
|
|
37
|
+
amountOrCoin?: SuiObjectArg | number,
|
|
38
|
+
lockPeriodInDays?: number,
|
|
39
|
+
autoCheck?: boolean
|
|
40
|
+
): Promise<void>;
|
|
41
|
+
extendLockPeriodQuick: (
|
|
42
|
+
lockPeriodInDays: number,
|
|
43
|
+
veScaKey?: SuiAddressArg,
|
|
44
|
+
autoCheck?: boolean
|
|
45
|
+
) => Promise<void>;
|
|
46
|
+
extendLockAmountQuick: (
|
|
47
|
+
scaAmount: number,
|
|
48
|
+
veScaKey?: SuiAddressArg,
|
|
49
|
+
autoCheck?: boolean
|
|
50
|
+
) => Promise<void>;
|
|
51
|
+
renewExpiredVeScaQuick: (
|
|
52
|
+
scaAmount: number,
|
|
53
|
+
lockPeriodInDays: number,
|
|
54
|
+
veScaKey?: SuiAddressArg,
|
|
55
|
+
autoCheck?: boolean
|
|
56
|
+
) => Promise<void>;
|
|
57
|
+
redeemScaQuick: (veScaKey?: SuiAddressArg) => Promise<void>;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type SuiTxBlockWithVeScaNormalMethods = SuiKitTxBlock &
|
|
61
|
+
VeScaNormalMethods;
|
|
62
|
+
|
|
63
|
+
export type VeScaTxBlock = SuiTxBlockWithVeScaNormalMethods & VeScaQuickMethods;
|
|
64
|
+
|
|
65
|
+
export type GenerateVeScaNormalMethod = (params: {
|
|
66
|
+
builder: ScallopBuilder;
|
|
67
|
+
txBlock: SuiKitTxBlock;
|
|
68
|
+
}) => VeScaNormalMethods;
|
|
69
|
+
|
|
70
|
+
export type GenerateVeScaQuickMethod = (params: {
|
|
71
|
+
builder: ScallopBuilder;
|
|
72
|
+
txBlock: SuiTxBlockWithVeScaNormalMethods;
|
|
73
|
+
}) => VeScaQuickMethods;
|
|
@@ -29,7 +29,7 @@ export type StakeRewardCoins = {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export type BorrowIncentiveRewardCoins = {
|
|
32
|
-
[key in SupportBorrowIncentiveCoins]: SupportBorrowIncentiveRewardCoins;
|
|
32
|
+
[key in SupportBorrowIncentiveCoins]: SupportBorrowIncentiveRewardCoins[];
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
export type AssetCoinIds = {
|