@scallop-io/sui-scallop-sdk 0.44.2 → 0.44.4

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.
Files changed (61) hide show
  1. package/dist/builders/borrowIncentiveBuilder.d.ts +12 -0
  2. package/dist/constants/common.d.ts +3 -1
  3. package/dist/constants/enum.d.ts +3 -2
  4. package/dist/index.js +815 -228
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +776 -192
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/models/scallopClient.d.ts +33 -2
  9. package/dist/models/scallopQuery.d.ts +31 -10
  10. package/dist/models/scallopUtils.d.ts +11 -4
  11. package/dist/queries/borrowIncentiveQuery.d.ts +24 -0
  12. package/dist/queries/coreQuery.d.ts +8 -0
  13. package/dist/queries/index.d.ts +1 -0
  14. package/dist/queries/spoolQuery.d.ts +13 -5
  15. package/dist/types/address.d.ts +8 -0
  16. package/dist/types/builder/borrowIncentive.d.ts +31 -0
  17. package/dist/types/builder/index.d.ts +3 -1
  18. package/dist/types/constant/common.d.ts +5 -3
  19. package/dist/types/constant/enum.d.ts +6 -3
  20. package/dist/types/query/borrowIncentive.d.ts +118 -0
  21. package/dist/types/query/core.d.ts +1 -0
  22. package/dist/types/query/index.d.ts +1 -0
  23. package/dist/types/query/portfolio.d.ts +13 -0
  24. package/dist/types/query/spool.d.ts +12 -13
  25. package/dist/utils/builder.d.ts +8 -0
  26. package/dist/utils/index.d.ts +1 -1
  27. package/dist/utils/query.d.ts +33 -10
  28. package/dist/utils/util.d.ts +13 -0
  29. package/package.json +1 -1
  30. package/src/builders/borrowIncentiveBuilder.ts +257 -0
  31. package/src/builders/coreBuilder.ts +1 -14
  32. package/src/builders/index.ts +9 -2
  33. package/src/builders/spoolBuilder.ts +3 -16
  34. package/src/constants/common.ts +4 -1
  35. package/src/constants/enum.ts +8 -2
  36. package/src/models/scallopAddress.ts +8 -0
  37. package/src/models/scallopClient.ts +104 -2
  38. package/src/models/scallopQuery.ts +48 -14
  39. package/src/models/scallopUtils.ts +21 -5
  40. package/src/queries/borrowIncentiveQuery.ts +167 -0
  41. package/src/queries/coreQuery.ts +58 -15
  42. package/src/queries/index.ts +1 -0
  43. package/src/queries/portfolioQuery.ts +59 -5
  44. package/src/queries/spoolQuery.ts +87 -71
  45. package/src/types/address.ts +8 -0
  46. package/src/types/builder/borrowIncentive.ts +67 -0
  47. package/src/types/builder/index.ts +5 -1
  48. package/src/types/builder/spool.ts +0 -1
  49. package/src/types/constant/common.ts +10 -3
  50. package/src/types/constant/enum.ts +9 -3
  51. package/src/types/query/borrowIncentive.ts +150 -0
  52. package/src/types/query/core.ts +1 -1
  53. package/src/types/query/index.ts +1 -0
  54. package/src/types/query/portfolio.ts +16 -0
  55. package/src/types/query/spool.ts +28 -18
  56. package/src/utils/builder.ts +15 -0
  57. package/src/utils/index.ts +1 -1
  58. package/src/utils/query.ts +279 -72
  59. package/src/utils/util.ts +36 -2
  60. package/dist/utils/oracle.d.ts +0 -14
  61. package/src/utils/oracle.ts +0 -36
@@ -1,10 +1,10 @@
1
1
  import { normalizeStructTag } from '@mysten/sui.js/utils';
2
2
  import { SUPPORT_SPOOLS } from '../constants';
3
3
  import {
4
- parseOriginStakePoolData,
5
- calculateStakePoolData,
6
- parseOriginRewardPoolData,
7
- calculateRewardPoolData,
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
- RewardPool,
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
- stakeMarketCoinName: SupportStakeMarketCoins,
67
+ marketCoinName: SupportStakeMarketCoins,
68
68
  marketPool?: MarketPool
69
69
  ) => {
70
- const stakeCoinName =
71
- query.utils.parseCoinName<SupportStakeCoins>(stakeMarketCoinName);
72
- marketPool = marketPool || (await query.getMarketPool(stakeCoinName));
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.${stakeMarketCoinName}.rewardPoolId`
74
+ `spool.pools.${marketCoinName}.rewardPoolId`
76
75
  );
77
76
  let spool: Spool | undefined = undefined;
78
- const stakePoolObjectResponse = await query.suiKit.client().multiGetObjects({
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
- stakePoolObjectResponse[0].data &&
88
- stakePoolObjectResponse[1].data
86
+ spoolObjectResponse[0].data &&
87
+ spoolObjectResponse[1].data
89
88
  ) {
90
- const rewardCoin = query.utils.getRewardCoinName(stakeMarketCoinName);
89
+ const rewardCoinName = query.utils.getSpoolRewardCoinName(marketCoinName);
91
90
  const coinPrices = await query.utils.getCoinPrices([
92
- stakeCoinName,
93
- rewardCoin,
91
+ coinName,
92
+ rewardCoinName,
94
93
  ]);
95
94
 
96
- const stakePoolObject = stakePoolObjectResponse[0].data;
97
- const rewardPoolObject = stakePoolObjectResponse[1].data;
98
- if (stakePoolObject.content && 'fields' in stakePoolObject.content) {
99
- const fields = stakePoolObject.content.fields as any;
100
- const parsedStakePoolData = parseOriginStakePoolData({
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 stakeMarketCoinPrice =
114
- (coinPrices?.[stakeCoinName] ?? 0) * marketPool.conversionRate;
115
- const stakeMarketCoinDecimal =
116
- query.utils.getCoinDecimal(stakeMarketCoinName);
117
- const calculatedStakePoolData = calculateStakePoolData(
118
- parsedStakePoolData,
119
- stakeMarketCoinPrice,
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 parsedRewardPoolData = parseOriginRewardPoolData({
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?.[rewardCoin] ?? 0;
134
- const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoin);
131
+ const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
132
+ const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName);
135
133
 
136
- const calculatedRewardPoolData = calculateRewardPoolData(
137
- parsedStakePoolData,
138
- parsedRewardPoolData,
139
- calculatedStakePoolData,
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: stakeMarketCoinName,
146
- symbol: query.utils.parseSymbol(stakeMarketCoinName),
147
- coinType: query.utils.parseCoinType(stakeCoinName),
148
- marketCoinType: query.utils.parseMarketCoinType(stakeCoinName),
149
- rewardCoinType: isMarketCoin(rewardCoin)
150
- ? query.utils.parseMarketCoinType(rewardCoin)
151
- : query.utils.parseCoinType(rewardCoin),
152
- coinDecimal: query.utils.getCoinDecimal(stakeCoinName),
153
- rewardCoinDecimal: query.utils.getCoinDecimal(rewardCoin),
154
- coinPrice: coinPrices?.[stakeCoinName] ?? 0,
155
- marketCoinPrice: stakeMarketCoinPrice,
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
- ...calculatedStakePoolData,
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
  }
@@ -242,9 +247,9 @@ export const getStakeAccounts = async (
242
247
  if (normalizeStructTag(type) === stakeMarketCoinTypes.ssui) {
243
248
  stakeAccounts.ssui.push({
244
249
  id,
245
- type,
250
+ type: normalizeStructTag(type),
246
251
  stakePoolId,
247
- stakeType,
252
+ stakeType: normalizeStructTag(stakeType),
248
253
  staked,
249
254
  index,
250
255
  points,
@@ -253,9 +258,9 @@ export const getStakeAccounts = async (
253
258
  } else if (normalizeStructTag(type) === stakeMarketCoinTypes.susdc) {
254
259
  stakeAccounts.susdc.push({
255
260
  id,
256
- type,
261
+ type: normalizeStructTag(type),
257
262
  stakePoolId,
258
- stakeType,
263
+ stakeType: normalizeStructTag(stakeType),
259
264
  staked,
260
265
  index,
261
266
  points,
@@ -264,9 +269,9 @@ export const getStakeAccounts = async (
264
269
  } else if (normalizeStructTag(type) === stakeMarketCoinTypes.susdt) {
265
270
  stakeAccounts.susdt.push({
266
271
  id,
267
- type,
272
+ type: normalizeStructTag(type),
268
273
  stakePoolId,
269
- stakeType,
274
+ stakeType: normalizeStructTag(stakeType),
270
275
  staked,
271
276
  index,
272
277
  points,
@@ -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.
@@ -316,13 +325,13 @@ export const getStakePool = async (
316
325
  const lastUpdate = Number(fields.last_update);
317
326
  stakePool = {
318
327
  id,
319
- type,
328
+ type: normalizeStructTag(type),
320
329
  maxPoint,
321
330
  distributedPoint,
322
331
  pointPerPeriod,
323
332
  period,
324
333
  maxStake,
325
- stakeType,
334
+ stakeType: normalizeStructTag(stakeType),
326
335
  totalStaked,
327
336
  index,
328
337
  createdAt,
@@ -334,41 +343,48 @@ 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 Reward pool.
354
+ * @return Stake reward pool.
342
355
  */
343
- export const getRewardPool = async (
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 rewardPool: RewardPool | undefined = undefined;
351
- const rewardPoolObjectResponse = await query.suiKit.client().getObject({
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 (rewardPoolObjectResponse.data) {
359
- const rewardPoolObject = rewardPoolObjectResponse.data;
360
- const id = rewardPoolObject.objectId;
361
- const type = rewardPoolObject.type!;
362
- if (rewardPoolObject.content && 'fields' in rewardPoolObject.content) {
363
- const fields = rewardPoolObject.content.fields as any;
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
- rewardPool = {
385
+ stakeRewardPool = {
370
386
  id,
371
- type,
387
+ type: normalizeStructTag(type),
372
388
  stakePoolId,
373
389
  ratioNumerator,
374
390
  ratioDenominator,
@@ -377,5 +393,5 @@ export const getRewardPool = async (
377
393
  };
378
394
  }
379
395
  }
380
- return rewardPool;
396
+ return stakeRewardPool;
381
397
  };
@@ -13,6 +13,7 @@ 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,
@@ -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 & SpoolTxBlock;
9
+ export type ScallopTxBlock = CoreTxBlock &
10
+ SpoolTxBlock &
11
+ BorrowIncentiveTxBlock;
@@ -38,7 +38,6 @@ export type SpoolQuickMethods = {
38
38
  stakeMarketCoinName: SupportStakeMarketCoins,
39
39
  stakeAccountId?: SuiAddressArg
40
40
  ): Promise<void>;
41
-
42
41
  unstakeQuick(
43
42
  amount: number,
44
43
  stakeMarketCoinName: SupportStakeMarketCoins,
@@ -4,7 +4,9 @@ import {
4
4
  SUPPORT_ORACLES,
5
5
  SUPPORT_PACKAGES,
6
6
  SUPPORT_SPOOLS,
7
- SUPPORT_REWARD_POOLS,
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
- | SupportRewardCoins;
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 SupportRewardCoins = (typeof SUPPORT_REWARD_POOLS)[number];
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
- SupportRewardCoins,
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 RewardCoins = {
26
- [key in SupportStakeMarketCoins]: SupportRewardCoins;
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 = {
@@ -0,0 +1,150 @@
1
+ import type { SupportBorrowIncentiveCoins } from '../constant';
2
+
3
+ export interface BorrowIncentiveAccountKey {
4
+ id: string;
5
+ onwerId: string;
6
+ }
7
+
8
+ type OptionalKeys<T> = {
9
+ [K in keyof T]?: T[K];
10
+ };
11
+
12
+ export type BorrowIncentivePools = OptionalKeys<
13
+ Record<SupportBorrowIncentiveCoins, BorrowIncentivePool>
14
+ >;
15
+
16
+ export type BorrowIncentivePool = {
17
+ coinName: SupportBorrowIncentiveCoins;
18
+ symbol: string;
19
+ coinType: string;
20
+ rewardCoinType: string;
21
+ coinDecimal: number;
22
+ rewardCoinDecimal: number;
23
+ coinPrice: number;
24
+ rewardCoinPrice: number;
25
+ } & Required<
26
+ Pick<
27
+ ParsedBorrowIncentivePoolData,
28
+ 'maxPoint' | 'distributedPoint' | 'maxStake'
29
+ >
30
+ > &
31
+ CalculatedBorrowIncentivePoolData &
32
+ BorrowIncentiveRewardPool;
33
+
34
+ export type OriginBorrowIncentivePoolData = {
35
+ created_at: string;
36
+ distributed_point: string;
37
+ distributed_point_per_period: string;
38
+ index: string;
39
+ last_update: string;
40
+ max_distributed_point: string;
41
+ max_stakes: string;
42
+ point_distribution_time: string;
43
+ pool_type: {
44
+ name: string;
45
+ };
46
+ stakes: string;
47
+ };
48
+
49
+ export type ParsedBorrowIncentivePoolData = {
50
+ poolType: string;
51
+ maxPoint: number;
52
+ distributedPoint: number;
53
+ pointPerPeriod: number;
54
+ period: number;
55
+ maxStake: number;
56
+ staked: number;
57
+ index: number;
58
+ createdAt: number;
59
+ lastUpdate: number;
60
+ };
61
+
62
+ export type CalculatedBorrowIncentivePoolData = {
63
+ stakedAmount: number;
64
+ stakedCoin: number;
65
+ stakedValue: number;
66
+ distributedPointPerSec: number;
67
+ accumulatedPoints: number;
68
+ currentPointIndex: number;
69
+ currentTotalDistributedPoint: number;
70
+ startDate: Date;
71
+ endDate: Date;
72
+ };
73
+
74
+ export type BorrowIncentiveRewardPool = Required<
75
+ Pick<
76
+ ParsedBorrowIncentiveRewardPoolData,
77
+ 'exchangeRateNumerator' | 'exchangeRateDenominator'
78
+ >
79
+ > &
80
+ CalculatedBorrowIncentiveRewardPoolData;
81
+
82
+ export type OriginBorrowIncentiveRewardPoolData = {
83
+ claimed_rewards: string;
84
+ exchange_rate_denominator: string;
85
+ exchange_rate_numerator: string;
86
+ remaining_reward: string;
87
+ reward_type: {
88
+ name: string;
89
+ };
90
+ };
91
+
92
+ export type ParsedBorrowIncentiveRewardPoolData = {
93
+ rewardType: string;
94
+ claimedRewards: number;
95
+ exchangeRateNumerator: number;
96
+ exchangeRateDenominator: number;
97
+ remainingRewards: number;
98
+ };
99
+
100
+ export type CalculatedBorrowIncentiveRewardPoolData = {
101
+ rewardApr: number;
102
+ totalRewardAmount: number;
103
+ totalRewardCoin: number;
104
+ totalRewardValue: number;
105
+ remaindRewardAmount: number;
106
+ remaindRewardCoin: number;
107
+ remaindRewardValue: number;
108
+ claimedRewardAmount: number;
109
+ claimedRewardCoin: number;
110
+ claimedRewardValue: number;
111
+ rewardPerSec: number;
112
+ };
113
+
114
+ export type BorrowIncentiveAccounts = OptionalKeys<
115
+ Record<SupportBorrowIncentiveCoins, ParsedBorrowIncentiveAccountData>
116
+ >;
117
+
118
+ export type OriginBorrowIncentiveAccountData = {
119
+ amount: string;
120
+ index: string;
121
+ points: string;
122
+ pool_type: {
123
+ name: string;
124
+ };
125
+ total_points: string;
126
+ };
127
+
128
+ export type ParsedBorrowIncentiveAccountData = {
129
+ poolType: string;
130
+ amount: number;
131
+ index: number;
132
+ points: number;
133
+ totalPoints: number;
134
+ };
135
+
136
+ /**
137
+ * The query interface for `incentive_pools_query::incentive_pools_data` inspectTxn.
138
+ */
139
+ export interface BorrowIncentivePoolsQueryInterface {
140
+ incentive_pools: OriginBorrowIncentivePoolData[];
141
+ reward_pool: OriginBorrowIncentiveRewardPoolData;
142
+ }
143
+
144
+ /**
145
+ * The query interface for `incentive_account_query::incentive_account_data` inspectTxn.
146
+ */
147
+ export interface BorrowIncentiveAccountsQueryInterface {
148
+ incentive_states: OriginBorrowIncentiveAccountData[];
149
+ total_points: string;
150
+ }
@@ -255,7 +255,7 @@ export type Market = {
255
255
  data?: MarketQueryInterface;
256
256
  };
257
257
 
258
- export type Obligation = { id: string; keyId: string };
258
+ export type Obligation = { id: string; keyId: string; locked: boolean };
259
259
 
260
260
  /**
261
261
  * The query interface for `market_query::market_data` inspectTxn.
@@ -1,3 +1,4 @@
1
1
  export type * from './core';
2
2
  export type * from './spool';
3
+ export type * from './borrowIncentive';
3
4
  export type * from './portfolio';
@@ -66,6 +66,9 @@ export type ObligationAccount = {
66
66
  Record<SupportCollateralCoins, ObligationCollateral>
67
67
  >;
68
68
  debts: OptionalKeys<Record<SupportPoolCoins, ObligationDebt>>;
69
+ borrowIncentives: OptionalKeys<
70
+ Record<SupportPoolCoins, ObligationBorrowIncentive>
71
+ >;
69
72
  };
70
73
 
71
74
  export type ObligationCollateral = {
@@ -102,6 +105,19 @@ export type ObligationDebt = {
102
105
  availableRepayCoin: number;
103
106
  };
104
107
 
108
+ export type ObligationBorrowIncentive = {
109
+ coinName: SupportPoolCoins;
110
+ coinType: string;
111
+ rewardCoinType: string;
112
+ symbol: string;
113
+ coinDecimal: number;
114
+ rewardCoinDecimal: number;
115
+ coinPrice: number;
116
+ rewardCoinPrice: number;
117
+ availableClaimAmount: number;
118
+ availableClaimCoin: number;
119
+ };
120
+
105
121
  export type TotalValueLocked = {
106
122
  supplyValue: number;
107
123
  borrowValue: number;