@scallop-io/sui-scallop-sdk 1.3.5-rc.1 → 1.4.0
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/constants/enum.d.ts +1 -1
- package/dist/constants/tokenBucket.d.ts +1 -1
- package/dist/index.js +299 -340
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +298 -339
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopClient.d.ts +4 -4
- package/dist/models/scallopQuery.d.ts +35 -57
- package/dist/models/scallopUtils.d.ts +10 -10
- package/dist/queries/borrowIncentiveQuery.d.ts +2 -2
- package/dist/queries/priceQuery.d.ts +2 -36
- package/dist/types/builder/borrowIncentive.d.ts +6 -6
- package/dist/types/constant/common.d.ts +1 -1
- package/dist/types/utils.d.ts +6 -2
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +13 -2
- package/src/constants/common.ts +2 -4
- package/src/constants/enum.ts +16 -11
- package/src/constants/tokenBucket.ts +1 -1
- package/src/models/scallopClient.ts +10 -27
- package/src/models/scallopQuery.ts +38 -44
- package/src/models/scallopUtils.ts +18 -23
- package/src/queries/borrowIncentiveQuery.ts +12 -29
- package/src/queries/coreQuery.ts +191 -191
- package/src/queries/portfolioQuery.ts +78 -80
- package/src/queries/priceQuery.ts +2 -36
- package/src/queries/sCoinQuery.ts +3 -3
- package/src/queries/spoolQuery.ts +6 -4
- package/src/types/builder/borrowIncentive.ts +15 -10
- package/src/types/constant/common.ts +2 -1
- package/src/types/utils.ts +10 -2
- package/src/utils/indexer.ts +9 -3
- package/src/utils/query.ts +87 -0
- package/src/utils/tokenBucket.ts +2 -2
|
@@ -7,7 +7,7 @@ import type { SuiTransactionBlockResponse } from '@mysten/sui/client';
|
|
|
7
7
|
import type { TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
8
8
|
import { ScallopCache } from './scallopCache';
|
|
9
9
|
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
10
|
-
import type { ScallopClientFnReturnType, ScallopClientParams, SupportPoolCoins, SupportCollateralCoins, SupportAssetCoins, SupportStakeCoins, SupportStakeMarketCoins, ScallopTxBlock, ScallopClientVeScaReturnType, ScallopClientInstanceParams } from '../types';
|
|
10
|
+
import type { ScallopClientFnReturnType, ScallopClientParams, SupportPoolCoins, SupportCollateralCoins, SupportAssetCoins, SupportStakeCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, ScallopTxBlock, ScallopClientVeScaReturnType, ScallopClientInstanceParams } from '../types';
|
|
11
11
|
/**
|
|
12
12
|
* @description
|
|
13
13
|
* It provides contract interaction operations for general users.
|
|
@@ -284,16 +284,16 @@ export declare class ScallopClient {
|
|
|
284
284
|
*/
|
|
285
285
|
unstakeObligation<S extends boolean>(obligationId: string, obligationKeyId: string, sign?: S, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
|
|
286
286
|
/**
|
|
287
|
-
*
|
|
287
|
+
* unstake market coin from the specific spool.
|
|
288
288
|
*
|
|
289
|
-
* @param
|
|
289
|
+
* @param marketCoinName - Types of mak coin.
|
|
290
290
|
* @param amount - The amount of coins would deposit.
|
|
291
291
|
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
292
292
|
* @param accountId - The stake account object.
|
|
293
293
|
* @param walletAddress - The wallet address of the owner.
|
|
294
294
|
* @return Transaction block response or transaction block
|
|
295
295
|
*/
|
|
296
|
-
claimBorrowIncentive<S extends boolean>(obligationId: string, obligationKeyId: string, sign?: S, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
|
|
296
|
+
claimBorrowIncentive<S extends boolean>(coinName: SupportBorrowIncentiveCoins, obligationId: string, obligationKeyId: string, sign?: S, walletAddress?: string): Promise<ScallopClientFnReturnType<S>>;
|
|
297
297
|
/**
|
|
298
298
|
* Function to migrate all market coin in user wallet into sCoin
|
|
299
299
|
* @returns Transaction response
|
|
@@ -38,8 +38,9 @@ export declare class ScallopQuery {
|
|
|
38
38
|
* @param indexer - Whether to use indexer.
|
|
39
39
|
* @return Market data.
|
|
40
40
|
*/
|
|
41
|
-
queryMarket(
|
|
42
|
-
coinPrices
|
|
41
|
+
queryMarket(args?: {
|
|
42
|
+
coinPrices?: CoinPrices;
|
|
43
|
+
indexer?: boolean;
|
|
43
44
|
}): Promise<import("../types").Market>;
|
|
44
45
|
/**
|
|
45
46
|
* Get market pools.
|
|
@@ -52,8 +53,9 @@ export declare class ScallopQuery {
|
|
|
52
53
|
* @param indexer - Whether to use indexer.
|
|
53
54
|
* @return Market pools data.
|
|
54
55
|
*/
|
|
55
|
-
getMarketPools(poolCoinNames?: SupportPoolCoins[],
|
|
56
|
+
getMarketPools(poolCoinNames?: SupportPoolCoins[], args?: {
|
|
56
57
|
coinPrices?: CoinPrices;
|
|
58
|
+
indexer?: boolean;
|
|
57
59
|
}): Promise<{
|
|
58
60
|
usdc?: MarketPool | undefined;
|
|
59
61
|
sbeth?: MarketPool | undefined;
|
|
@@ -79,9 +81,10 @@ export declare class ScallopQuery {
|
|
|
79
81
|
* @param indexer - Whether to use indexer.
|
|
80
82
|
* @return Market pool data.
|
|
81
83
|
*/
|
|
82
|
-
getMarketPool(poolCoinName: SupportPoolCoins,
|
|
84
|
+
getMarketPool(poolCoinName: SupportPoolCoins, args?: {
|
|
83
85
|
marketObject?: SuiObjectData | null;
|
|
84
86
|
coinPrice?: number;
|
|
87
|
+
indexer?: boolean;
|
|
85
88
|
}): Promise<MarketPool | undefined>;
|
|
86
89
|
/**
|
|
87
90
|
* Get market collaterals.
|
|
@@ -94,7 +97,9 @@ export declare class ScallopQuery {
|
|
|
94
97
|
* @param indexer - Whether to use indexer.
|
|
95
98
|
* @return Market collaterals data.
|
|
96
99
|
*/
|
|
97
|
-
getMarketCollaterals(collateralCoinNames?: SupportCollateralCoins[],
|
|
100
|
+
getMarketCollaterals(collateralCoinNames?: SupportCollateralCoins[], args?: {
|
|
101
|
+
indexer?: boolean;
|
|
102
|
+
}): Promise<{
|
|
98
103
|
usdc?: import("../types").MarketCollateral | undefined;
|
|
99
104
|
sbeth?: import("../types").MarketCollateral | undefined;
|
|
100
105
|
weth?: import("../types").MarketCollateral | undefined;
|
|
@@ -117,7 +122,9 @@ export declare class ScallopQuery {
|
|
|
117
122
|
* @param indexer - Whether to use indexer.
|
|
118
123
|
* @return Market collateral data.
|
|
119
124
|
*/
|
|
120
|
-
getMarketCollateral(collateralCoinName: SupportCollateralCoins,
|
|
125
|
+
getMarketCollateral(collateralCoinName: SupportCollateralCoins, args?: {
|
|
126
|
+
indexer?: boolean;
|
|
127
|
+
}): Promise<import("../types").MarketCollateral | undefined>;
|
|
121
128
|
/**
|
|
122
129
|
* Get obligations data.
|
|
123
130
|
*
|
|
@@ -185,9 +192,10 @@ export declare class ScallopQuery {
|
|
|
185
192
|
* @param indexer - Whether to use indexer.
|
|
186
193
|
* @return Spools data.
|
|
187
194
|
*/
|
|
188
|
-
getSpools(stakeMarketCoinNames?: SupportStakeMarketCoins[],
|
|
195
|
+
getSpools(stakeMarketCoinNames?: SupportStakeMarketCoins[], args?: {
|
|
189
196
|
marketPools?: MarketPools;
|
|
190
197
|
coinPrices?: CoinPrices;
|
|
198
|
+
indexer?: boolean;
|
|
191
199
|
}): Promise<{
|
|
192
200
|
susdc?: import("../types").Spool | undefined;
|
|
193
201
|
sweth?: import("../types").Spool | undefined;
|
|
@@ -206,9 +214,10 @@ export declare class ScallopQuery {
|
|
|
206
214
|
* @param indexer - Whether to use indexer.
|
|
207
215
|
* @return Spool data.
|
|
208
216
|
*/
|
|
209
|
-
getSpool(stakeMarketCoinName: SupportStakeMarketCoins,
|
|
217
|
+
getSpool(stakeMarketCoinName: SupportStakeMarketCoins, args?: {
|
|
210
218
|
marketPool?: MarketPool;
|
|
211
219
|
coinPrices?: CoinPrices;
|
|
220
|
+
indexer?: boolean;
|
|
212
221
|
}): Promise<import("../types").Spool | undefined>;
|
|
213
222
|
/**
|
|
214
223
|
* Get stake accounts data for all stake pools (spools).
|
|
@@ -296,9 +305,9 @@ export declare class ScallopQuery {
|
|
|
296
305
|
* @param indexer - Whether to use indexer.
|
|
297
306
|
* @return Borrow incentive pools data.
|
|
298
307
|
*/
|
|
299
|
-
getBorrowIncentivePools(coinNames?: SupportBorrowIncentiveCoins[],
|
|
300
|
-
|
|
301
|
-
|
|
308
|
+
getBorrowIncentivePools(coinNames?: SupportBorrowIncentiveCoins[], args?: {
|
|
309
|
+
coinPrices: CoinPrices;
|
|
310
|
+
indexer?: boolean;
|
|
302
311
|
}): Promise<{
|
|
303
312
|
usdc?: import("../types").BorrowIncentivePool | undefined;
|
|
304
313
|
sbeth?: import("../types").BorrowIncentivePool | undefined;
|
|
@@ -338,7 +347,9 @@ export declare class ScallopQuery {
|
|
|
338
347
|
* @param indexer - Whether to use indexer.
|
|
339
348
|
* @return All lending and spool infomation.
|
|
340
349
|
*/
|
|
341
|
-
getLendings(poolCoinNames?: SupportPoolCoins[], ownerAddress?: string,
|
|
350
|
+
getLendings(poolCoinNames?: SupportPoolCoins[], ownerAddress?: string, args?: {
|
|
351
|
+
indexer?: boolean;
|
|
352
|
+
}): Promise<{
|
|
342
353
|
usdc?: import("../types").Lending | undefined;
|
|
343
354
|
sbeth?: import("../types").Lending | undefined;
|
|
344
355
|
weth?: import("../types").Lending | undefined;
|
|
@@ -364,7 +375,9 @@ export declare class ScallopQuery {
|
|
|
364
375
|
* @param indexer - Whether to use indexer.
|
|
365
376
|
* @return Lending pool data.
|
|
366
377
|
*/
|
|
367
|
-
getLending(poolCoinName: SupportPoolCoins, ownerAddress?: string,
|
|
378
|
+
getLending(poolCoinName: SupportPoolCoins, ownerAddress?: string, args?: {
|
|
379
|
+
indexer?: boolean;
|
|
380
|
+
}): Promise<import("../types").Lending>;
|
|
368
381
|
/**
|
|
369
382
|
* Get user all obligation accounts information.
|
|
370
383
|
*
|
|
@@ -375,7 +388,9 @@ export declare class ScallopQuery {
|
|
|
375
388
|
* @param indexer - Whether to use indexer.
|
|
376
389
|
* @return All obligation accounts information.
|
|
377
390
|
*/
|
|
378
|
-
getObligationAccounts(ownerAddress?: string,
|
|
391
|
+
getObligationAccounts(ownerAddress?: string, args?: {
|
|
392
|
+
indexer: boolean;
|
|
393
|
+
}): Promise<{
|
|
379
394
|
[x: string]: import("../types").ObligationAccount | undefined;
|
|
380
395
|
}>;
|
|
381
396
|
/**
|
|
@@ -389,7 +404,9 @@ export declare class ScallopQuery {
|
|
|
389
404
|
* @param indexer - Whether to use indexer.
|
|
390
405
|
* @return Borrowing and collateral information.
|
|
391
406
|
*/
|
|
392
|
-
getObligationAccount(obligationId: string, ownerAddress?: string,
|
|
407
|
+
getObligationAccount(obligationId: string, ownerAddress?: string, args?: {
|
|
408
|
+
indexer?: boolean;
|
|
409
|
+
}): Promise<import("../types").ObligationAccount>;
|
|
393
410
|
/**
|
|
394
411
|
* Get total value locked.
|
|
395
412
|
*
|
|
@@ -399,7 +416,9 @@ export declare class ScallopQuery {
|
|
|
399
416
|
*
|
|
400
417
|
* @return Total value locked.
|
|
401
418
|
*/
|
|
402
|
-
getTvl(
|
|
419
|
+
getTvl(args?: {
|
|
420
|
+
indexer?: boolean;
|
|
421
|
+
}): Promise<import("../types").TotalValueLocked>;
|
|
403
422
|
/**
|
|
404
423
|
* Get veSca data.
|
|
405
424
|
* @param veScaKey
|
|
@@ -495,45 +514,4 @@ export declare class ScallopQuery {
|
|
|
495
514
|
* @returns price data
|
|
496
515
|
*/
|
|
497
516
|
getCoinPriceByIndexer(poolName: SupportPoolCoins): Promise<number>;
|
|
498
|
-
/**
|
|
499
|
-
* Get all coin prices, including sCoin
|
|
500
|
-
* @returns prices data
|
|
501
|
-
*/
|
|
502
|
-
getAllCoinPrices(args?: {
|
|
503
|
-
marketPools?: MarketPools;
|
|
504
|
-
coinPrices?: CoinPrices;
|
|
505
|
-
}): Promise<{
|
|
506
|
-
susdc?: number | undefined;
|
|
507
|
-
ssbeth?: number | undefined;
|
|
508
|
-
sweth?: number | undefined;
|
|
509
|
-
swbtc?: number | undefined;
|
|
510
|
-
swusdc?: number | undefined;
|
|
511
|
-
swusdt?: number | undefined;
|
|
512
|
-
ssui?: number | undefined;
|
|
513
|
-
swsol?: number | undefined;
|
|
514
|
-
scetus?: number | undefined;
|
|
515
|
-
safsui?: number | undefined;
|
|
516
|
-
shasui?: number | undefined;
|
|
517
|
-
svsui?: number | undefined;
|
|
518
|
-
ssca?: number | undefined;
|
|
519
|
-
sfud?: number | undefined;
|
|
520
|
-
sdeep?: number | undefined;
|
|
521
|
-
usdc?: number | undefined;
|
|
522
|
-
sbeth?: number | undefined;
|
|
523
|
-
weth?: number | undefined;
|
|
524
|
-
wbtc?: number | undefined;
|
|
525
|
-
wusdc?: number | undefined;
|
|
526
|
-
wusdt?: number | undefined;
|
|
527
|
-
sui?: number | undefined;
|
|
528
|
-
wapt?: number | undefined;
|
|
529
|
-
wsol?: number | undefined;
|
|
530
|
-
cetus?: number | undefined;
|
|
531
|
-
afsui?: number | undefined;
|
|
532
|
-
hasui?: number | undefined;
|
|
533
|
-
vsui?: number | undefined;
|
|
534
|
-
sca?: number | undefined;
|
|
535
|
-
fud?: number | undefined;
|
|
536
|
-
deep?: number | undefined;
|
|
537
|
-
swapt?: number | undefined;
|
|
538
|
-
}>;
|
|
539
517
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SuiKit } from '@scallop-io/sui-kit';
|
|
2
2
|
import { ScallopAddress } from './scallopAddress';
|
|
3
3
|
import { ScallopCache } from './scallopCache';
|
|
4
|
-
import type { ScallopUtilsParams, SupportCoins, SupportAssetCoins, SupportMarketCoins, SupportStakeMarketCoins, CoinWrappedType, SupportSCoin, ScallopUtilsInstanceParams, SupportSuiBridgeCoins, SupportWormholeCoins, PoolAddressInfo } from '../types';
|
|
4
|
+
import type { ScallopUtilsParams, SupportCoins, SupportAssetCoins, SupportMarketCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, CoinWrappedType, SupportSCoin, ScallopUtilsInstanceParams, SupportSuiBridgeCoins, SupportWormholeCoins, PoolAddressInfo } from '../types';
|
|
5
5
|
import type { SuiObjectArg, SuiTxArg, SuiTxBlock } from '@scallop-io/sui-kit';
|
|
6
6
|
/**
|
|
7
7
|
* @description
|
|
@@ -50,7 +50,7 @@ export declare class ScallopUtils {
|
|
|
50
50
|
* @param coinName - Specific support coin name.
|
|
51
51
|
* @return Coin type.
|
|
52
52
|
*/
|
|
53
|
-
parseCoinType(coinName: SupportCoins
|
|
53
|
+
parseCoinType(coinName: SupportCoins): string;
|
|
54
54
|
/**
|
|
55
55
|
* Convert coin name to sCoin name.
|
|
56
56
|
*
|
|
@@ -58,13 +58,6 @@ export declare class ScallopUtils {
|
|
|
58
58
|
* @return sCoin name.
|
|
59
59
|
*/
|
|
60
60
|
parseSCoinName<T extends SupportSCoin>(coinName: SupportCoins | SupportMarketCoins): T | undefined;
|
|
61
|
-
/**
|
|
62
|
-
* Convert sCoin name to coin name.
|
|
63
|
-
* This function will parse new sCoin name `scallop_...` to its old market coin name which is shorter
|
|
64
|
-
* e.g: `scallop_sui -> ssui
|
|
65
|
-
* @return sCoin name
|
|
66
|
-
*/
|
|
67
|
-
parseCoinNameFromSCoinName(coinName: string): "susdc" | "ssbeth" | "sweth" | "swbtc" | "swusdc" | "swusdt" | "ssui" | "swsol" | "scetus" | "safsui" | "shasui" | "svsui" | "ssca" | "sfud" | "sdeep";
|
|
68
61
|
/**
|
|
69
62
|
* Convert sCoin name into sCoin type
|
|
70
63
|
* @param sCoinName
|
|
@@ -131,6 +124,13 @@ export declare class ScallopUtils {
|
|
|
131
124
|
* @return Spool reward coin name.
|
|
132
125
|
*/
|
|
133
126
|
getSpoolRewardCoinName: (stakeMarketCoinName: SupportStakeMarketCoins) => "sui";
|
|
127
|
+
/**
|
|
128
|
+
* Get reward type of borrow incentive pool.
|
|
129
|
+
*
|
|
130
|
+
* @param borrowIncentiveCoinName - Support borrow incentive coin.
|
|
131
|
+
* @return Borrow incentive reward coin name.
|
|
132
|
+
*/
|
|
133
|
+
getBorrowIncentiveRewardCoinName: (borrowIncentiveCoinName: SupportBorrowIncentiveCoins) => ("sui" | "sca")[];
|
|
134
134
|
/**
|
|
135
135
|
* Get coin decimal.
|
|
136
136
|
*
|
|
@@ -188,7 +188,7 @@ export declare class ScallopUtils {
|
|
|
188
188
|
* @param assetCoinNames - Specific an array of support asset coin name.
|
|
189
189
|
* @return Asset coin price.
|
|
190
190
|
*/
|
|
191
|
-
getCoinPrices(_?: SupportAssetCoins[]): Promise<import("../types").OptionalKeys<Record<
|
|
191
|
+
getCoinPrices(_?: SupportAssetCoins[]): Promise<import("../types").OptionalKeys<Record<SupportAssetCoins, number>>>;
|
|
192
192
|
/**
|
|
193
193
|
* Convert apr to apy.
|
|
194
194
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ScallopAddress, ScallopQuery, ScallopUtils } from '../models';
|
|
2
|
-
import type { BorrowIncentivePoolsQueryInterface, SupportBorrowIncentiveCoins, BorrowIncentivePool, CoinPrices
|
|
2
|
+
import type { BorrowIncentivePoolsQueryInterface, SupportBorrowIncentiveCoins, BorrowIncentivePool, CoinPrices } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Query borrow incentive pools data using moveCall
|
|
5
5
|
* @param address
|
|
@@ -14,7 +14,7 @@ export declare const queryBorrowIncentivePools: (address: ScallopAddress) => Pro
|
|
|
14
14
|
* @param indexer - Whether to use indexer.
|
|
15
15
|
* @return Borrow incentive pools data.
|
|
16
16
|
*/
|
|
17
|
-
export declare const getBorrowIncentivePools: (query: ScallopQuery, borrowIncentiveCoinNames?: SupportBorrowIncentiveCoins[], indexer?: boolean,
|
|
17
|
+
export declare const getBorrowIncentivePools: (query: ScallopQuery, borrowIncentiveCoinNames?: SupportBorrowIncentiveCoins[], indexer?: boolean, coinPrices?: CoinPrices) => Promise<{
|
|
18
18
|
usdc?: BorrowIncentivePool | undefined;
|
|
19
19
|
sbeth?: BorrowIncentivePool | undefined;
|
|
20
20
|
weth?: BorrowIncentivePool | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SuiObjectData } from '@mysten/sui/client';
|
|
2
|
-
import type { ScallopAddress
|
|
3
|
-
import type {
|
|
2
|
+
import type { ScallopAddress } from '../models';
|
|
3
|
+
import type { SupportAssetCoins } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* Get price from pyth fee object.
|
|
6
6
|
*
|
|
@@ -14,37 +14,3 @@ export declare const getPythPrice: ({ address, }: {
|
|
|
14
14
|
export declare const getPythPrices: ({ address, }: {
|
|
15
15
|
address: ScallopAddress;
|
|
16
16
|
}, assetCoinNames: SupportAssetCoins[]) => Promise<Record<SupportAssetCoins, number>>;
|
|
17
|
-
export declare const getAllCoinPrices: (query: ScallopQuery, marketPools?: MarketPools, coinPrices?: CoinPrices) => Promise<{
|
|
18
|
-
susdc?: number | undefined;
|
|
19
|
-
ssbeth?: number | undefined;
|
|
20
|
-
sweth?: number | undefined;
|
|
21
|
-
swbtc?: number | undefined;
|
|
22
|
-
swusdc?: number | undefined;
|
|
23
|
-
swusdt?: number | undefined;
|
|
24
|
-
ssui?: number | undefined;
|
|
25
|
-
swsol?: number | undefined;
|
|
26
|
-
scetus?: number | undefined;
|
|
27
|
-
safsui?: number | undefined;
|
|
28
|
-
shasui?: number | undefined;
|
|
29
|
-
svsui?: number | undefined;
|
|
30
|
-
ssca?: number | undefined;
|
|
31
|
-
sfud?: number | undefined;
|
|
32
|
-
sdeep?: number | undefined;
|
|
33
|
-
usdc?: number | undefined;
|
|
34
|
-
sbeth?: number | undefined;
|
|
35
|
-
weth?: number | undefined;
|
|
36
|
-
wbtc?: number | undefined;
|
|
37
|
-
wusdc?: number | undefined;
|
|
38
|
-
wusdt?: number | undefined;
|
|
39
|
-
sui?: number | undefined;
|
|
40
|
-
wapt?: number | undefined;
|
|
41
|
-
wsol?: number | undefined;
|
|
42
|
-
cetus?: number | undefined;
|
|
43
|
-
afsui?: number | undefined;
|
|
44
|
-
hasui?: number | undefined;
|
|
45
|
-
vsui?: number | undefined;
|
|
46
|
-
sca?: number | undefined;
|
|
47
|
-
fud?: number | undefined;
|
|
48
|
-
deep?: number | undefined;
|
|
49
|
-
swapt?: number | undefined;
|
|
50
|
-
}>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { SuiTxBlock as SuiKitTxBlock, SuiObjectArg } from '@scallop-io/sui-kit';
|
|
2
2
|
import type { TransactionResult } from '@mysten/sui/transactions';
|
|
3
3
|
import type { ScallopBuilder } from '../../models';
|
|
4
|
-
import type { SupportBorrowIncentiveRewardCoins } from '../constant';
|
|
4
|
+
import type { SupportBorrowIncentiveCoins, SupportBorrowIncentiveRewardCoins } from '../constant';
|
|
5
5
|
export type BorrowIncentiveIds = {
|
|
6
6
|
borrowIncentivePkg: string;
|
|
7
7
|
query: string;
|
|
@@ -14,14 +14,14 @@ export type BorrowIncentiveNormalMethods = {
|
|
|
14
14
|
stakeObligation: (obligation: SuiObjectArg, obligationKey: SuiObjectArg) => void;
|
|
15
15
|
stakeObligationWithVesca: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, veScaKey: SuiObjectArg) => void;
|
|
16
16
|
unstakeObligation: (obligation: SuiObjectArg, obligationKey: SuiObjectArg) => void;
|
|
17
|
-
claimBorrowIncentive: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, rewardType: SupportBorrowIncentiveRewardCoins) => TransactionResult;
|
|
17
|
+
claimBorrowIncentive: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, coinName: SupportBorrowIncentiveCoins, rewardType: SupportBorrowIncentiveRewardCoins) => TransactionResult;
|
|
18
18
|
deactivateBoost: (obligation: SuiObjectArg, veScaKey: SuiObjectArg) => void;
|
|
19
19
|
};
|
|
20
20
|
export type BorrowIncentiveQuickMethods = {
|
|
21
|
-
stakeObligationQuick(obligation?:
|
|
22
|
-
stakeObligationWithVeScaQuick(obligation?:
|
|
23
|
-
unstakeObligationQuick(obligation?:
|
|
24
|
-
claimBorrowIncentiveQuick(rewardType: SupportBorrowIncentiveRewardCoins, obligation?:
|
|
21
|
+
stakeObligationQuick(obligation?: SuiObjectArg, obligationKey?: SuiObjectArg): Promise<void>;
|
|
22
|
+
stakeObligationWithVeScaQuick(obligation?: SuiObjectArg, obligationKey?: SuiObjectArg, veScaKey?: SuiObjectArg): Promise<void>;
|
|
23
|
+
unstakeObligationQuick(obligation?: SuiObjectArg, obligationKey?: SuiObjectArg): Promise<void>;
|
|
24
|
+
claimBorrowIncentiveQuick(coinName: SupportBorrowIncentiveCoins, rewardType: SupportBorrowIncentiveRewardCoins, obligation?: SuiObjectArg, obligationKey?: SuiObjectArg): Promise<TransactionResult>;
|
|
25
25
|
};
|
|
26
26
|
export type SuiTxBlockWithBorrowIncentiveNormalMethods = SuiKitTxBlock & BorrowIncentiveNormalMethods;
|
|
27
27
|
export type BorrowIncentiveTxBlock = SuiTxBlockWithBorrowIncentiveNormalMethods & BorrowIncentiveQuickMethods;
|
|
@@ -2,7 +2,7 @@ import { SUPPORT_POOLS, SUPPORT_COLLATERALS, SUPPORT_ORACLES, SUPPORT_PACKAGES,
|
|
|
2
2
|
type ParseMarketCoins<T extends string> = `s${T}`;
|
|
3
3
|
type ParseCoins<T extends string> = T extends `s${infer R}` ? R : never;
|
|
4
4
|
export type SupportCoins = SupportAssetCoins | SupportMarketCoins | SupportStakeMarketCoins | SupportSCoin;
|
|
5
|
-
export type SupportAssetCoins = SupportPoolCoins | SupportCollateralCoins | SupportStakeRewardCoins;
|
|
5
|
+
export type SupportAssetCoins = SupportPoolCoins | SupportCollateralCoins | SupportStakeRewardCoins | SupportBorrowIncentiveRewardCoins;
|
|
6
6
|
export type SupportPoolCoins = (typeof SUPPORT_POOLS)[number];
|
|
7
7
|
export type SupportCollateralCoins = (typeof SUPPORT_COLLATERALS)[number];
|
|
8
8
|
export type SupportMarketCoins = ParseMarketCoins<SupportPoolCoins> | SupportStakeMarketCoins;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SupportAssetCoins } from './constant';
|
|
2
2
|
export type OptionalKeys<T> = {
|
|
3
3
|
[K in keyof T]?: T[K];
|
|
4
4
|
};
|
|
5
|
-
export type CoinPrices = OptionalKeys<Record<
|
|
5
|
+
export type CoinPrices = OptionalKeys<Record<SupportAssetCoins, number>>;
|
|
6
|
+
export type PriceMap = Map<SupportAssetCoins, {
|
|
7
|
+
price: number;
|
|
8
|
+
publishTime: number;
|
|
9
|
+
}>;
|
|
6
10
|
export type PoolAddressInfo = {
|
|
7
11
|
name: string;
|
|
8
12
|
coingeckoId: string;
|
package/package.json
CHANGED
|
@@ -143,7 +143,17 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
143
143
|
]
|
|
144
144
|
);
|
|
145
145
|
},
|
|
146
|
-
claimBorrowIncentive: (
|
|
146
|
+
claimBorrowIncentive: (
|
|
147
|
+
obligationId,
|
|
148
|
+
obligationKey,
|
|
149
|
+
coinName,
|
|
150
|
+
rewardCoinName
|
|
151
|
+
) => {
|
|
152
|
+
const rewardCoinNames =
|
|
153
|
+
builder.utils.getBorrowIncentiveRewardCoinName(coinName);
|
|
154
|
+
if (rewardCoinNames.includes(rewardCoinName) === false) {
|
|
155
|
+
throw new Error(`Invalid reward coin name ${rewardCoinName}`);
|
|
156
|
+
}
|
|
147
157
|
const rewardType = builder.utils.parseCoinType(rewardCoinName);
|
|
148
158
|
return txBlock.moveCall(
|
|
149
159
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::redeem_rewards`,
|
|
@@ -274,11 +284,11 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
274
284
|
}
|
|
275
285
|
},
|
|
276
286
|
claimBorrowIncentiveQuick: async (
|
|
287
|
+
coinName,
|
|
277
288
|
rewardCoinName,
|
|
278
289
|
obligation,
|
|
279
290
|
obligationKey
|
|
280
291
|
) => {
|
|
281
|
-
// check for available reward coin names
|
|
282
292
|
const { obligationId: obligationArg, obligationKey: obligationKeyArg } =
|
|
283
293
|
await requireObligationInfo(
|
|
284
294
|
builder,
|
|
@@ -290,6 +300,7 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
290
300
|
return txBlock.claimBorrowIncentive(
|
|
291
301
|
obligationArg,
|
|
292
302
|
obligationKeyArg,
|
|
303
|
+
coinName,
|
|
293
304
|
rewardCoinName
|
|
294
305
|
);
|
|
295
306
|
},
|
package/src/constants/common.ts
CHANGED
|
@@ -9,6 +9,7 @@ export const ADDRESSES_ID =
|
|
|
9
9
|
? ('65fb07c39c845425d71d7b18' as const)
|
|
10
10
|
: ('675c65cd301dd817ea262e76' as const);
|
|
11
11
|
// : ('66f8e7ed9bb9e07fdfb86bbb' as const);
|
|
12
|
+
// : ('664dfe22898c36c159e28bc8' as const);
|
|
12
13
|
|
|
13
14
|
export const PROTOCOL_OBJECT_ID = IS_VE_SCA_TEST
|
|
14
15
|
? ('0xc9f859f98ca352a11b97a038c4b4162bee437b8df8caa047990fe9cb03d4f778' as const)
|
|
@@ -120,10 +121,7 @@ export const SUPPORT_BORROW_INCENTIVE_POOLS = [
|
|
|
120
121
|
'usdc',
|
|
121
122
|
] as const;
|
|
122
123
|
|
|
123
|
-
export const SUPPORT_BORROW_INCENTIVE_REWARDS = [
|
|
124
|
-
...SUPPORT_POOLS,
|
|
125
|
-
...SUPPORT_SCOIN,
|
|
126
|
-
] as const;
|
|
124
|
+
export const SUPPORT_BORROW_INCENTIVE_REWARDS = ['sui', 'sca'] as const;
|
|
127
125
|
export const SUPPORT_ORACLES = ['supra', 'switchboard', 'pyth'] as const;
|
|
128
126
|
|
|
129
127
|
export const SUPPORT_PACKAGES = [
|
package/src/constants/enum.ts
CHANGED
|
@@ -120,6 +120,19 @@ export const suiBridgeCoins: types.SuiBridgeCoins = {
|
|
|
120
120
|
sbeth: 'sbeth',
|
|
121
121
|
};
|
|
122
122
|
|
|
123
|
+
export const borrowIncentiveRewardCoins: types.BorrowIncentiveRewardCoins = {
|
|
124
|
+
usdc: ['sui', 'sca'],
|
|
125
|
+
sui: ['sui', 'sca'],
|
|
126
|
+
wusdc: ['sui', 'sca'],
|
|
127
|
+
wusdt: ['sui', 'sca'],
|
|
128
|
+
sca: ['sui', 'sca'],
|
|
129
|
+
afsui: ['sui'],
|
|
130
|
+
hasui: ['sui'],
|
|
131
|
+
vsui: ['sui'],
|
|
132
|
+
weth: ['sui'],
|
|
133
|
+
sbeth: ['sui'],
|
|
134
|
+
};
|
|
135
|
+
|
|
123
136
|
export const coinIds: types.AssetCoinIds = {
|
|
124
137
|
usdc: '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7',
|
|
125
138
|
sui: '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
@@ -162,13 +175,13 @@ export const sCoinIds: types.SCoinIds = {
|
|
|
162
175
|
ssbeth:
|
|
163
176
|
'0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH',
|
|
164
177
|
ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
|
|
178
|
+
scetus:
|
|
179
|
+
'0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS',
|
|
180
|
+
ssca: '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
|
|
165
181
|
swusdc:
|
|
166
182
|
'0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
|
|
167
183
|
swusdt:
|
|
168
184
|
'0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
|
|
169
|
-
ssca: '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
|
|
170
|
-
scetus:
|
|
171
|
-
'0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS',
|
|
172
185
|
sweth:
|
|
173
186
|
'0x67540ceb850d418679e69f1fb6b2093d6df78a2a699ffc733f7646096d552e9b::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH',
|
|
174
187
|
safsui:
|
|
@@ -194,14 +207,6 @@ export const sCoinTypeToName = Object.entries(sCoinIds).reduce(
|
|
|
194
207
|
{} as Record<string, types.SupportSCoin>
|
|
195
208
|
);
|
|
196
209
|
|
|
197
|
-
export const sCoinRawNameToName = Object.entries(sCoinIds).reduce(
|
|
198
|
-
(acc, [coinName, coinType]) => {
|
|
199
|
-
acc[coinType.split('::')[2].toLowerCase()] = coinName as types.SupportSCoin;
|
|
200
|
-
return acc;
|
|
201
|
-
},
|
|
202
|
-
{} as Record<string, types.SupportSCoin>
|
|
203
|
-
);
|
|
204
|
-
|
|
205
210
|
// TEST VERSION
|
|
206
211
|
// export const sCoinIds: types.SCoinIds = {
|
|
207
212
|
// ssui: '0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const DEFAULT_TOKENS_PER_INTERVAL = 50;
|
|
2
|
-
export const DEFAULT_INTERVAL_IN_MS =
|
|
2
|
+
export const DEFAULT_INTERVAL_IN_MS = 100;
|
|
@@ -4,6 +4,7 @@ import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
|
|
|
4
4
|
import {
|
|
5
5
|
ADDRESSES_ID,
|
|
6
6
|
SUPPORT_BORROW_INCENTIVE_POOLS,
|
|
7
|
+
SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
7
8
|
SUPPORT_SCOIN,
|
|
8
9
|
SUPPORT_SPOOLS,
|
|
9
10
|
} from '../constants';
|
|
@@ -27,6 +28,7 @@ import type {
|
|
|
27
28
|
SupportAssetCoins,
|
|
28
29
|
SupportStakeCoins,
|
|
29
30
|
SupportStakeMarketCoins,
|
|
31
|
+
SupportBorrowIncentiveCoins,
|
|
30
32
|
ScallopTxBlock,
|
|
31
33
|
SupportSCoin,
|
|
32
34
|
ScallopClientVeScaReturnType,
|
|
@@ -943,9 +945,9 @@ export class ScallopClient {
|
|
|
943
945
|
}
|
|
944
946
|
|
|
945
947
|
/**
|
|
946
|
-
*
|
|
948
|
+
* unstake market coin from the specific spool.
|
|
947
949
|
*
|
|
948
|
-
* @param
|
|
950
|
+
* @param marketCoinName - Types of mak coin.
|
|
949
951
|
* @param amount - The amount of coins would deposit.
|
|
950
952
|
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
951
953
|
* @param accountId - The stake account object.
|
|
@@ -953,6 +955,7 @@ export class ScallopClient {
|
|
|
953
955
|
* @return Transaction block response or transaction block
|
|
954
956
|
*/
|
|
955
957
|
public async claimBorrowIncentive<S extends boolean>(
|
|
958
|
+
coinName: SupportBorrowIncentiveCoins,
|
|
956
959
|
obligationId: string,
|
|
957
960
|
obligationKeyId: string,
|
|
958
961
|
sign: S = true as S,
|
|
@@ -962,37 +965,17 @@ export class ScallopClient {
|
|
|
962
965
|
const sender = walletAddress ?? this.walletAddress;
|
|
963
966
|
txBlock.setSender(sender);
|
|
964
967
|
|
|
965
|
-
const
|
|
966
|
-
const
|
|
967
|
-
await this.query.getObligationAccount(obligationId);
|
|
968
|
-
const rewardCoinNames = Object.values(obligationAccount.borrowIncentives)
|
|
969
|
-
.flatMap(({ rewards }) =>
|
|
970
|
-
rewards.filter(({ availableClaimAmount }) => availableClaimAmount > 0)
|
|
971
|
-
)
|
|
972
|
-
.flatMap(({ coinName }) => coinName);
|
|
973
|
-
for (const rewardCoinName of rewardCoinNames) {
|
|
968
|
+
const rewardCoins = [];
|
|
969
|
+
for (const rewardCoinName of SUPPORT_BORROW_INCENTIVE_REWARDS) {
|
|
974
970
|
const rewardCoin = await txBlock.claimBorrowIncentiveQuick(
|
|
971
|
+
coinName,
|
|
975
972
|
rewardCoinName,
|
|
976
973
|
obligationId,
|
|
977
974
|
obligationKeyId
|
|
978
975
|
);
|
|
979
|
-
|
|
980
|
-
rewardCoinsCollection[rewardCoinName] = [rewardCoin];
|
|
981
|
-
} else {
|
|
982
|
-
rewardCoinsCollection[rewardCoinName].push(rewardCoin);
|
|
983
|
-
}
|
|
976
|
+
rewardCoins.push(rewardCoin);
|
|
984
977
|
}
|
|
985
|
-
|
|
986
|
-
txBlock.transferObjects(
|
|
987
|
-
Object.values(rewardCoinsCollection).map((rewardCoins) => {
|
|
988
|
-
const mergeDest = rewardCoins[0];
|
|
989
|
-
if (rewardCoins.length > 1) {
|
|
990
|
-
txBlock.mergeCoins(mergeDest, rewardCoins.slice(1));
|
|
991
|
-
}
|
|
992
|
-
return mergeDest;
|
|
993
|
-
}),
|
|
994
|
-
sender
|
|
995
|
-
);
|
|
978
|
+
txBlock.transferObjects(rewardCoins, sender);
|
|
996
979
|
|
|
997
980
|
if (sign) {
|
|
998
981
|
return (await this.suiKit.signAndSendTxn(
|