@scallop-io/sui-scallop-sdk 1.3.5-alpha.1 → 1.3.5-alpha.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/constants/enum.d.ts +0 -1
- package/dist/index.js +70 -77
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -76
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopClient.d.ts +4 -4
- package/dist/models/scallopUtils.d.ts +1 -8
- package/dist/types/builder/borrowIncentive.d.ts +6 -6
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +2 -13
- package/src/constants/enum.ts +0 -13
- package/src/models/scallopClient.ts +27 -10
- package/src/models/scallopUtils.ts +4 -14
- package/src/queries/borrowIncentiveQuery.ts +0 -1
- package/src/queries/portfolioQuery.ts +64 -58
- package/src/types/builder/borrowIncentive.ts +10 -15
|
@@ -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,
|
|
10
|
+
import type { ScallopClientFnReturnType, ScallopClientParams, SupportPoolCoins, SupportCollateralCoins, SupportAssetCoins, SupportStakeCoins, SupportStakeMarketCoins, 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
|
+
* Claim borrow incentive reward.
|
|
288
288
|
*
|
|
289
|
-
* @param
|
|
289
|
+
* @param poolName
|
|
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>(
|
|
296
|
+
claimBorrowIncentive<S extends boolean>(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
|
|
@@ -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,
|
|
4
|
+
import type { ScallopUtilsParams, SupportCoins, SupportAssetCoins, SupportMarketCoins, SupportStakeMarketCoins, 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
|
|
@@ -131,13 +131,6 @@ export declare class ScallopUtils {
|
|
|
131
131
|
* @return Spool reward coin name.
|
|
132
132
|
*/
|
|
133
133
|
getSpoolRewardCoinName: (stakeMarketCoinName: SupportStakeMarketCoins) => "sui";
|
|
134
|
-
/**
|
|
135
|
-
* Get reward type of borrow incentive pool.
|
|
136
|
-
*
|
|
137
|
-
* @param borrowIncentiveCoinName - Support borrow incentive coin.
|
|
138
|
-
* @return Borrow incentive reward coin name.
|
|
139
|
-
*/
|
|
140
|
-
getBorrowIncentiveRewardCoinName: (borrowIncentiveCoinName: SupportBorrowIncentiveCoins) => ("usdc" | "sbeth" | "weth" | "wbtc" | "wusdc" | "wusdt" | "sui" | "wapt" | "wsol" | "cetus" | "afsui" | "hasui" | "vsui" | "sca" | "susdc" | "ssbeth" | "sweth" | "swbtc" | "swusdc" | "swusdt" | "ssui" | "swsol" | "scetus" | "safsui" | "shasui" | "svsui" | "ssca")[];
|
|
141
134
|
/**
|
|
142
135
|
* Get coin decimal.
|
|
143
136
|
*
|
|
@@ -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 {
|
|
4
|
+
import type { 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,
|
|
17
|
+
claimBorrowIncentive: (obligation: SuiObjectArg, obligationKey: SuiObjectArg, 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(
|
|
21
|
+
stakeObligationQuick(obligation?: string, obligationKey?: string): Promise<void>;
|
|
22
|
+
stakeObligationWithVeScaQuick(obligation?: string, obligationKey?: string, veScaKey?: string): Promise<void>;
|
|
23
|
+
unstakeObligationQuick(obligation?: string, obligationKey?: string): Promise<void>;
|
|
24
|
+
claimBorrowIncentiveQuick(rewardType: SupportBorrowIncentiveRewardCoins, obligation?: string, obligationKey?: string): Promise<TransactionResult>;
|
|
25
25
|
};
|
|
26
26
|
export type SuiTxBlockWithBorrowIncentiveNormalMethods = SuiKitTxBlock & BorrowIncentiveNormalMethods;
|
|
27
27
|
export type BorrowIncentiveTxBlock = SuiTxBlockWithBorrowIncentiveNormalMethods & BorrowIncentiveQuickMethods;
|
package/package.json
CHANGED
|
@@ -143,17 +143,7 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
|
|
|
143
143
|
]
|
|
144
144
|
);
|
|
145
145
|
},
|
|
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
|
-
}
|
|
146
|
+
claimBorrowIncentive: (obligationId, obligationKey, rewardCoinName) => {
|
|
157
147
|
const rewardType = builder.utils.parseCoinType(rewardCoinName);
|
|
158
148
|
return txBlock.moveCall(
|
|
159
149
|
`${borrowIncentiveIds.borrowIncentivePkg}::user::redeem_rewards`,
|
|
@@ -284,11 +274,11 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
284
274
|
}
|
|
285
275
|
},
|
|
286
276
|
claimBorrowIncentiveQuick: async (
|
|
287
|
-
coinName,
|
|
288
277
|
rewardCoinName,
|
|
289
278
|
obligation,
|
|
290
279
|
obligationKey
|
|
291
280
|
) => {
|
|
281
|
+
// check for available reward coin names
|
|
292
282
|
const { obligationId: obligationArg, obligationKey: obligationKeyArg } =
|
|
293
283
|
await requireObligationInfo(
|
|
294
284
|
builder,
|
|
@@ -300,7 +290,6 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
|
|
|
300
290
|
return txBlock.claimBorrowIncentive(
|
|
301
291
|
obligationArg,
|
|
302
292
|
obligationKeyArg,
|
|
303
|
-
coinName,
|
|
304
293
|
rewardCoinName
|
|
305
294
|
);
|
|
306
295
|
},
|
package/src/constants/enum.ts
CHANGED
|
@@ -125,19 +125,6 @@ export const suiBridgeCoins: types.SuiBridgeCoins = {
|
|
|
125
125
|
sbeth: 'sbeth',
|
|
126
126
|
};
|
|
127
127
|
|
|
128
|
-
export const borrowIncentiveRewardCoins: types.BorrowIncentiveRewardCoins = {
|
|
129
|
-
usdc: ['ssui', 'ssca'],
|
|
130
|
-
sui: ['ssui', 'ssca'],
|
|
131
|
-
wusdc: ['ssui', 'ssca'],
|
|
132
|
-
wusdt: ['ssui', 'ssca'],
|
|
133
|
-
sca: ['ssui', 'ssca'],
|
|
134
|
-
afsui: ['ssui'],
|
|
135
|
-
hasui: ['ssui'],
|
|
136
|
-
vsui: ['ssui'],
|
|
137
|
-
weth: ['ssui'],
|
|
138
|
-
sbeth: ['ssui'],
|
|
139
|
-
};
|
|
140
|
-
|
|
141
128
|
export const coinIds: types.AssetCoinIds = {
|
|
142
129
|
usdc: '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7',
|
|
143
130
|
sui: '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
@@ -4,7 +4,6 @@ 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,
|
|
8
7
|
SUPPORT_SCOIN,
|
|
9
8
|
SUPPORT_SPOOLS,
|
|
10
9
|
} from '../constants';
|
|
@@ -28,7 +27,6 @@ import type {
|
|
|
28
27
|
SupportAssetCoins,
|
|
29
28
|
SupportStakeCoins,
|
|
30
29
|
SupportStakeMarketCoins,
|
|
31
|
-
SupportBorrowIncentiveCoins,
|
|
32
30
|
ScallopTxBlock,
|
|
33
31
|
SupportSCoin,
|
|
34
32
|
ScallopClientVeScaReturnType,
|
|
@@ -945,9 +943,9 @@ export class ScallopClient {
|
|
|
945
943
|
}
|
|
946
944
|
|
|
947
945
|
/**
|
|
948
|
-
*
|
|
946
|
+
* Claim borrow incentive reward.
|
|
949
947
|
*
|
|
950
|
-
* @param
|
|
948
|
+
* @param poolName
|
|
951
949
|
* @param amount - The amount of coins would deposit.
|
|
952
950
|
* @param sign - Decide to directly sign the transaction or return the transaction block.
|
|
953
951
|
* @param accountId - The stake account object.
|
|
@@ -955,7 +953,6 @@ export class ScallopClient {
|
|
|
955
953
|
* @return Transaction block response or transaction block
|
|
956
954
|
*/
|
|
957
955
|
public async claimBorrowIncentive<S extends boolean>(
|
|
958
|
-
coinName: SupportBorrowIncentiveCoins,
|
|
959
956
|
obligationId: string,
|
|
960
957
|
obligationKeyId: string,
|
|
961
958
|
sign: S = true as S,
|
|
@@ -965,17 +962,37 @@ export class ScallopClient {
|
|
|
965
962
|
const sender = walletAddress ?? this.walletAddress;
|
|
966
963
|
txBlock.setSender(sender);
|
|
967
964
|
|
|
968
|
-
const
|
|
969
|
-
|
|
965
|
+
const rewardCoinsCollection: Record<string, TransactionResult[]> = {};
|
|
966
|
+
const obligationAccount =
|
|
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) {
|
|
970
974
|
const rewardCoin = await txBlock.claimBorrowIncentiveQuick(
|
|
971
|
-
coinName,
|
|
972
975
|
rewardCoinName,
|
|
973
976
|
obligationId,
|
|
974
977
|
obligationKeyId
|
|
975
978
|
);
|
|
976
|
-
|
|
979
|
+
if (!rewardCoinsCollection[rewardCoinName]) {
|
|
980
|
+
rewardCoinsCollection[rewardCoinName] = [rewardCoin];
|
|
981
|
+
} else {
|
|
982
|
+
rewardCoinsCollection[rewardCoinName].push(rewardCoin);
|
|
983
|
+
}
|
|
977
984
|
}
|
|
978
|
-
|
|
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
|
+
);
|
|
979
996
|
|
|
980
997
|
if (sign) {
|
|
981
998
|
return (await this.suiKit.signAndSendTxn(
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
SUPPORT_POOLS,
|
|
9
9
|
SUPPORT_COLLATERALS,
|
|
10
10
|
spoolRewardCoins,
|
|
11
|
-
borrowIncentiveRewardCoins,
|
|
12
11
|
coinDecimals,
|
|
13
12
|
wormholeCoinIds,
|
|
14
13
|
voloCoinIds,
|
|
@@ -41,7 +40,6 @@ import type {
|
|
|
41
40
|
SupportAssetCoins,
|
|
42
41
|
SupportMarketCoins,
|
|
43
42
|
SupportStakeMarketCoins,
|
|
44
|
-
SupportBorrowIncentiveCoins,
|
|
45
43
|
CoinPrices,
|
|
46
44
|
CoinWrappedType,
|
|
47
45
|
SupportSCoin,
|
|
@@ -159,6 +157,10 @@ export class ScallopUtils {
|
|
|
159
157
|
* @return Coin type.
|
|
160
158
|
*/
|
|
161
159
|
public parseCoinType(coinName: SupportCoins) {
|
|
160
|
+
// try parse scoin first
|
|
161
|
+
if (sCoinIds[coinName as SupportSCoin]) {
|
|
162
|
+
return sCoinIds[coinName as SupportSCoin];
|
|
163
|
+
}
|
|
162
164
|
coinName = isMarketCoin(coinName) ? this.parseCoinName(coinName) : coinName;
|
|
163
165
|
const coinPackageId =
|
|
164
166
|
this.address.get(`core.coins.${coinName}.id`) ||
|
|
@@ -395,18 +397,6 @@ export class ScallopUtils {
|
|
|
395
397
|
return spoolRewardCoins[stakeMarketCoinName];
|
|
396
398
|
};
|
|
397
399
|
|
|
398
|
-
/**
|
|
399
|
-
* Get reward type of borrow incentive pool.
|
|
400
|
-
*
|
|
401
|
-
* @param borrowIncentiveCoinName - Support borrow incentive coin.
|
|
402
|
-
* @return Borrow incentive reward coin name.
|
|
403
|
-
*/
|
|
404
|
-
public getBorrowIncentiveRewardCoinName = (
|
|
405
|
-
borrowIncentiveCoinName: SupportBorrowIncentiveCoins
|
|
406
|
-
) => {
|
|
407
|
-
return borrowIncentiveRewardCoins[borrowIncentiveCoinName];
|
|
408
|
-
};
|
|
409
|
-
|
|
410
400
|
/**
|
|
411
401
|
* Get coin decimal.
|
|
412
402
|
*
|
|
@@ -69,7 +69,6 @@ export const getBorrowIncentivePools = async (
|
|
|
69
69
|
(await query.getMarketPools(undefined, false, { coinPrices }));
|
|
70
70
|
coinPrices = coinPrices ?? (await query.getAllCoinPrices({ marketPools }));
|
|
71
71
|
|
|
72
|
-
console.log({ coinPrices });
|
|
73
72
|
if (indexer) {
|
|
74
73
|
const borrowIncentivePoolsIndexer =
|
|
75
74
|
await query.indexer.getBorrowIncentivePools();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import {
|
|
3
|
-
SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
4
3
|
SUPPORT_COLLATERALS,
|
|
5
4
|
SUPPORT_POOLS,
|
|
6
5
|
SUPPORT_SPOOLS,
|
|
@@ -353,8 +352,9 @@ export const getObligationAccount = async (
|
|
|
353
352
|
const collateralAssetCoinNames: SupportCollateralCoins[] = [
|
|
354
353
|
...SUPPORT_COLLATERALS,
|
|
355
354
|
];
|
|
356
|
-
|
|
357
|
-
|
|
355
|
+
market = market ?? (await query.queryMarket(indexer));
|
|
356
|
+
coinPrices =
|
|
357
|
+
coinPrices ?? (await query.getAllCoinPrices({ marketPools: market.pools }));
|
|
358
358
|
coinAmounts =
|
|
359
359
|
coinAmounts ||
|
|
360
360
|
(await query.getCoinAmounts(collateralAssetCoinNames, ownerAddress));
|
|
@@ -522,64 +522,70 @@ export const getObligationAccount = async (
|
|
|
522
522
|
const borrowIncentivePool = borrowIncentivePools[coinName];
|
|
523
523
|
if (borrowIncentivePool) {
|
|
524
524
|
const rewards: ObligationBorrowIcentiveReward[] = [];
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
.plus(accountPoint.points)
|
|
546
|
-
);
|
|
547
|
-
availableClaimCoin = availableClaimAmount.shiftedBy(
|
|
548
|
-
-1 * poolPoint.coinDecimal
|
|
549
|
-
);
|
|
550
|
-
|
|
551
|
-
// for veSCA
|
|
552
|
-
const weightScale = BigNumber(1_000_000_000_000);
|
|
553
|
-
const boostValue = BigNumber(accountPoint.weightedAmount)
|
|
554
|
-
.div(
|
|
555
|
-
BigNumber(borrowIncentiveAccount.debtAmount)
|
|
556
|
-
.multipliedBy(poolPoint.baseWeight)
|
|
557
|
-
.dividedBy(weightScale)
|
|
558
|
-
)
|
|
559
|
-
.isFinite()
|
|
560
|
-
? BigNumber(accountPoint.weightedAmount)
|
|
561
|
-
.div(
|
|
562
|
-
BigNumber(borrowIncentiveAccount.debtAmount)
|
|
563
|
-
.multipliedBy(poolPoint.baseWeight)
|
|
564
|
-
.dividedBy(weightScale)
|
|
525
|
+
Object.entries(borrowIncentiveAccount.pointList).forEach(
|
|
526
|
+
([key, accountPoint]) => {
|
|
527
|
+
const poolPoint =
|
|
528
|
+
borrowIncentivePool.points[
|
|
529
|
+
key as SupportBorrowIncentiveRewardCoins
|
|
530
|
+
];
|
|
531
|
+
|
|
532
|
+
if (accountPoint && poolPoint) {
|
|
533
|
+
let availableClaimAmount = BigNumber(0);
|
|
534
|
+
let availableClaimCoin = BigNumber(0);
|
|
535
|
+
const accountBorrowedAmount = BigNumber(
|
|
536
|
+
accountPoint.weightedAmount
|
|
537
|
+
);
|
|
538
|
+
const baseIndexRate = 1_000_000_000;
|
|
539
|
+
const increasedPointRate = poolPoint.currentPointIndex
|
|
540
|
+
? Math.max(
|
|
541
|
+
BigNumber(poolPoint.currentPointIndex - accountPoint.index)
|
|
542
|
+
.dividedBy(baseIndexRate)
|
|
543
|
+
.toNumber(),
|
|
544
|
+
0
|
|
565
545
|
)
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
546
|
+
: 1;
|
|
547
|
+
availableClaimAmount = availableClaimAmount.plus(
|
|
548
|
+
accountBorrowedAmount
|
|
549
|
+
.multipliedBy(increasedPointRate)
|
|
550
|
+
.plus(accountPoint.points)
|
|
551
|
+
);
|
|
552
|
+
availableClaimCoin = availableClaimAmount.shiftedBy(
|
|
553
|
+
-1 * poolPoint.coinDecimal
|
|
554
|
+
);
|
|
555
|
+
|
|
556
|
+
// for veSCA
|
|
557
|
+
const weightScale = BigNumber(1_000_000_000_000);
|
|
558
|
+
const boostValue = BigNumber(accountPoint.weightedAmount)
|
|
559
|
+
.div(
|
|
560
|
+
BigNumber(borrowIncentiveAccount.debtAmount)
|
|
561
|
+
.multipliedBy(poolPoint.baseWeight)
|
|
562
|
+
.dividedBy(weightScale)
|
|
563
|
+
)
|
|
564
|
+
.isFinite()
|
|
565
|
+
? BigNumber(accountPoint.weightedAmount)
|
|
566
|
+
.div(
|
|
567
|
+
BigNumber(borrowIncentiveAccount.debtAmount)
|
|
568
|
+
.multipliedBy(poolPoint.baseWeight)
|
|
569
|
+
.dividedBy(weightScale)
|
|
570
|
+
)
|
|
571
|
+
.toNumber()
|
|
572
|
+
: 1;
|
|
573
|
+
|
|
574
|
+
if (availableClaimAmount.isGreaterThanOrEqualTo(0)) {
|
|
575
|
+
rewards.push({
|
|
576
|
+
coinName: poolPoint.coinName,
|
|
577
|
+
coinType: poolPoint.coinType,
|
|
578
|
+
symbol: poolPoint.symbol,
|
|
579
|
+
coinDecimal: poolPoint.coinDecimal,
|
|
580
|
+
coinPrice: poolPoint.coinPrice,
|
|
581
|
+
availableClaimAmount: availableClaimAmount.toNumber(),
|
|
582
|
+
availableClaimCoin: availableClaimCoin.toNumber(),
|
|
583
|
+
boostValue,
|
|
584
|
+
});
|
|
585
|
+
}
|
|
580
586
|
}
|
|
581
587
|
}
|
|
582
|
-
|
|
588
|
+
);
|
|
583
589
|
|
|
584
590
|
if (
|
|
585
591
|
Object.keys(borrowIncentivePool.points).some((coinName: any) => {
|
|
@@ -4,10 +4,7 @@ import type {
|
|
|
4
4
|
} from '@scallop-io/sui-kit';
|
|
5
5
|
import type { TransactionResult } from '@mysten/sui/transactions';
|
|
6
6
|
import type { ScallopBuilder } from '../../models';
|
|
7
|
-
import type {
|
|
8
|
-
SupportBorrowIncentiveCoins,
|
|
9
|
-
SupportBorrowIncentiveRewardCoins,
|
|
10
|
-
} from '../constant';
|
|
7
|
+
import type { SupportBorrowIncentiveRewardCoins } from '../constant';
|
|
11
8
|
|
|
12
9
|
export type BorrowIncentiveIds = {
|
|
13
10
|
borrowIncentivePkg: string;
|
|
@@ -35,7 +32,6 @@ export type BorrowIncentiveNormalMethods = {
|
|
|
35
32
|
claimBorrowIncentive: (
|
|
36
33
|
obligation: SuiObjectArg,
|
|
37
34
|
obligationKey: SuiObjectArg,
|
|
38
|
-
coinName: SupportBorrowIncentiveCoins,
|
|
39
35
|
rewardType: SupportBorrowIncentiveRewardCoins
|
|
40
36
|
) => TransactionResult;
|
|
41
37
|
deactivateBoost: (obligation: SuiObjectArg, veScaKey: SuiObjectArg) => void;
|
|
@@ -43,23 +39,22 @@ export type BorrowIncentiveNormalMethods = {
|
|
|
43
39
|
|
|
44
40
|
export type BorrowIncentiveQuickMethods = {
|
|
45
41
|
stakeObligationQuick(
|
|
46
|
-
obligation?:
|
|
47
|
-
obligationKey?:
|
|
42
|
+
obligation?: string,
|
|
43
|
+
obligationKey?: string
|
|
48
44
|
): Promise<void>;
|
|
49
45
|
stakeObligationWithVeScaQuick(
|
|
50
|
-
obligation?:
|
|
51
|
-
obligationKey?:
|
|
52
|
-
veScaKey?:
|
|
46
|
+
obligation?: string,
|
|
47
|
+
obligationKey?: string,
|
|
48
|
+
veScaKey?: string
|
|
53
49
|
): Promise<void>;
|
|
54
50
|
unstakeObligationQuick(
|
|
55
|
-
obligation?:
|
|
56
|
-
obligationKey?:
|
|
51
|
+
obligation?: string,
|
|
52
|
+
obligationKey?: string
|
|
57
53
|
): Promise<void>;
|
|
58
54
|
claimBorrowIncentiveQuick(
|
|
59
|
-
coinName: SupportBorrowIncentiveCoins,
|
|
60
55
|
rewardType: SupportBorrowIncentiveRewardCoins,
|
|
61
|
-
obligation?:
|
|
62
|
-
obligationKey?:
|
|
56
|
+
obligation?: string,
|
|
57
|
+
obligationKey?: string
|
|
63
58
|
): Promise<TransactionResult>;
|
|
64
59
|
};
|
|
65
60
|
|