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

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.
@@ -322,9 +322,10 @@ export declare class ScallopQuery {
322
322
  * borrowing and obligation information for specific pool.
323
323
  *
324
324
  * @param obligationId - The obligation id.
325
+ * @param ownerAddress - The owner address.
325
326
  * @return Borrowing and collateral information.
326
327
  */
327
- getObligationAccount(obligationId: string): Promise<import("../types").ObligationAccount>;
328
+ getObligationAccount(obligationId: string, ownerAddress?: string): Promise<import("../types").ObligationAccount>;
328
329
  /**
329
330
  * Get total value locked.
330
331
  *
@@ -4,6 +4,7 @@ export interface AddressesInterface {
4
4
  core: {
5
5
  version: string;
6
6
  versionCap: string;
7
+ object: string;
7
8
  market: string;
8
9
  adminCap: string;
9
10
  coinDecimalsRegistry: string;
@@ -46,6 +47,7 @@ export interface AddressesInterface {
46
47
  spool: {
47
48
  id: string;
48
49
  adminCap: string;
50
+ object: string;
49
51
  pools: Partial<Record<SupportStakeMarketCoins, {
50
52
  id: string;
51
53
  rewardPoolId: string;
@@ -54,6 +56,7 @@ export interface AddressesInterface {
54
56
  borrowIncentive: {
55
57
  id: string;
56
58
  adminCap: string;
59
+ object: string;
57
60
  query: string;
58
61
  incentivePools: string;
59
62
  incentiveAccounts: string;
@@ -59,6 +59,8 @@ export type OriginBorrowIncentiveRewardPoolData = {
59
59
  claimed_rewards: string;
60
60
  exchange_rate_denominator: string;
61
61
  exchange_rate_numerator: string;
62
+ rewards_fee_rate_denominator: string;
63
+ rewards_fee_rate_numerator: string;
62
64
  remaining_reward: string;
63
65
  reward_type: {
64
66
  name: string;
@@ -67,8 +69,10 @@ export type OriginBorrowIncentiveRewardPoolData = {
67
69
  export type ParsedBorrowIncentiveRewardPoolData = {
68
70
  rewardType: string;
69
71
  claimedRewards: number;
70
- exchangeRateNumerator: number;
71
72
  exchangeRateDenominator: number;
73
+ exchangeRateNumerator: number;
74
+ rewardsFeeRateDenominator: number;
75
+ rewardsFeeRateNumerator: number;
72
76
  remainingRewards: number;
73
77
  };
74
78
  export type CalculatedBorrowIncentiveRewardPoolData = {
@@ -83,6 +87,7 @@ export type CalculatedBorrowIncentiveRewardPoolData = {
83
87
  claimedRewardCoin: number;
84
88
  claimedRewardValue: number;
85
89
  rewardPerSec: number;
90
+ rewardFee: number;
86
91
  };
87
92
  export type BorrowIncentiveAccounts = OptionalKeys<Record<SupportBorrowIncentiveCoins, ParsedBorrowIncentiveAccountData>>;
88
93
  export type OriginBorrowIncentiveAccountData = {
@@ -43,6 +43,11 @@ export type InterestModel = {
43
43
  value: string;
44
44
  };
45
45
  };
46
+ borrow_fee_rate: {
47
+ fields: {
48
+ value: string;
49
+ };
50
+ };
46
51
  high_kink: {
47
52
  fields: {
48
53
  value: string;
@@ -115,7 +120,7 @@ export type MarketPool = {
115
120
  coinWrappedType: CoinWrappedType;
116
121
  coinDecimal: number;
117
122
  coinPrice: number;
118
- } & Required<Pick<ParsedMarketPoolData, 'highKink' | 'midKink' | 'reserveFactor' | 'borrowWeight' | 'marketCoinSupplyAmount' | 'minBorrowAmount'>> & CalculatedMarketPoolData;
123
+ } & Required<Pick<ParsedMarketPoolData, 'highKink' | 'midKink' | 'reserveFactor' | 'borrowWeight' | 'borrowFee' | 'marketCoinSupplyAmount' | 'minBorrowAmount'>> & CalculatedMarketPoolData;
119
124
  export type MarketCollateral = {
120
125
  coinName: SupportCollateralCoins;
121
126
  symbol: string;
@@ -148,6 +153,9 @@ export type OriginMarketPoolData = {
148
153
  borrowWeight: {
149
154
  value: string;
150
155
  };
156
+ borrowFeeRate: {
157
+ value: string;
158
+ };
151
159
  baseBorrowRatePerSec: {
152
160
  value: string;
153
161
  };
@@ -178,6 +186,7 @@ export type ParsedMarketPoolData = {
178
186
  reserveAmount: number;
179
187
  reserveFactor: number;
180
188
  borrowWeight: number;
189
+ borrowFee: number;
181
190
  baseBorrowRate: number;
182
191
  borrowRateOnHighKink: number;
183
192
  borrowRateOnMidKink: number;
@@ -319,6 +328,9 @@ export interface MarketQueryInterface {
319
328
  borrowWeight: {
320
329
  value: string;
321
330
  };
331
+ borrowFeeRate: {
332
+ value: string;
333
+ };
322
334
  type: {
323
335
  name: string;
324
336
  };
@@ -59,13 +59,17 @@ export type OriginSpoolRewardPoolData = {
59
59
  claimed_rewards: string;
60
60
  exchange_rate_denominator: string;
61
61
  exchange_rate_numerator: string;
62
+ fee_rate_denominator: string;
63
+ fee_rate_numerator: string;
62
64
  rewards: string;
63
65
  spool_id: string;
64
66
  };
65
67
  export type ParsedSpoolRewardPoolData = {
66
68
  claimedRewards: number;
67
- exchangeRateNumerator: number;
68
69
  exchangeRateDenominator: number;
70
+ exchangeRateNumerator: number;
71
+ feeRateDenominator: number;
72
+ feeRateNumerator: number;
69
73
  rewards: number;
70
74
  spoolId: string;
71
75
  };
@@ -81,6 +85,7 @@ export type CalculatedSpoolRewardPoolData = {
81
85
  claimedRewardCoin: number;
82
86
  claimedRewardValue: number;
83
87
  rewardPerSec: number;
88
+ rewardFee: number;
84
89
  };
85
90
  export type StakePools = OptionalKeys<Record<SupportStakeMarketCoins, StakePool>>;
86
91
  export type StakeRewardPools = OptionalKeys<Record<SupportStakeMarketCoins, StakeRewardPool>>;
@@ -113,8 +118,10 @@ export interface StakeRewardPool {
113
118
  id: string;
114
119
  type: string;
115
120
  stakePoolId: string;
116
- ratioNumerator: number;
117
121
  ratioDenominator: number;
122
+ ratioNumerator: number;
123
+ feeRateDenominator: number;
124
+ feeRateNumerator: number;
118
125
  rewards: number;
119
126
  claimedRewards: number;
120
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "0.44.4",
3
+ "version": "0.44.6",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -5,6 +5,9 @@ export const ADDRESSES_ID = '6462a088a7ace142bb6d7e9b';
5
5
  export const PROTOCOL_OBJECT_ID =
6
6
  '0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf';
7
7
 
8
+ export const BORROW_FEE_PROTOCOL_ID =
9
+ '0xc38f849e81cfe46d4e4320f508ea7dda42934a329d5a6571bb4c3cb6ea63f5da';
10
+
8
11
  export const SUPPORT_POOLS = [
9
12
  'eth',
10
13
  'btc',
@@ -11,6 +11,7 @@ const EMPTY_ADDRESSES: AddressesInterface = {
11
11
  core: {
12
12
  version: '',
13
13
  versionCap: '',
14
+ object: '',
14
15
  market: '',
15
16
  adminCap: '',
16
17
  coinDecimalsRegistry: '',
@@ -188,6 +189,7 @@ const EMPTY_ADDRESSES: AddressesInterface = {
188
189
  spool: {
189
190
  id: '',
190
191
  adminCap: '',
192
+ object: '',
191
193
  pools: {
192
194
  ssui: {
193
195
  id: '',
@@ -202,6 +204,7 @@ const EMPTY_ADDRESSES: AddressesInterface = {
202
204
  borrowIncentive: {
203
205
  id: '',
204
206
  adminCap: '',
207
+ object: '',
205
208
  query: '',
206
209
  incentivePools: '',
207
210
  incentiveAccounts: '',
@@ -444,10 +444,14 @@ export class ScallopQuery {
444
444
  * borrowing and obligation information for specific pool.
445
445
  *
446
446
  * @param obligationId - The obligation id.
447
+ * @param ownerAddress - The owner address.
447
448
  * @return Borrowing and collateral information.
448
449
  */
449
- public async getObligationAccount(obligationId: string) {
450
- return await getObligationAccount(this, obligationId);
450
+ public async getObligationAccount(
451
+ obligationId: string,
452
+ ownerAddress?: string
453
+ ) {
454
+ return await getObligationAccount(this, obligationId, ownerAddress);
451
455
  }
452
456
 
453
457
  /**
@@ -159,8 +159,10 @@ export class ScallopUtils {
159
159
  * @return Market coin type.
160
160
  */
161
161
  public parseMarketCoinType(coinName: SupportCoins) {
162
+ const protocolObjectId =
163
+ this._address.get('core.object') || PROTOCOL_OBJECT_ID;
162
164
  const coinType = this.parseCoinType(coinName);
163
- return `${PROTOCOL_OBJECT_ID}::reserve::MarketCoin<${coinType}>`;
165
+ return `${protocolObjectId}::reserve::MarketCoin<${coinType}>`;
164
166
  }
165
167
 
166
168
  /**
@@ -5,6 +5,7 @@ import {
5
5
  SUPPORT_POOLS,
6
6
  PROTOCOL_OBJECT_ID,
7
7
  SUPPORT_COLLATERALS,
8
+ BORROW_FEE_PROTOCOL_ID,
8
9
  } from '../constants';
9
10
  import {
10
11
  parseOriginMarketPoolData,
@@ -84,6 +85,7 @@ export const queryMarket = async (query: ScallopQuery) => {
84
85
  reserve: pool.reserve,
85
86
  reserveFactor: pool.reserveFactor,
86
87
  borrowWeight: pool.borrowWeight,
88
+ borrowFeeRate: pool.borrowFeeRate,
87
89
  baseBorrowRatePerSec: pool.baseBorrowRatePerSec,
88
90
  borrowRateOnHighKink: pool.borrowRateOnHighKink,
89
91
  borrowRateOnMidKink: pool.borrowRateOnMidKink,
@@ -109,6 +111,7 @@ export const queryMarket = async (query: ScallopQuery) => {
109
111
  midKink: parsedMarketPoolData.midKink,
110
112
  reserveFactor: parsedMarketPoolData.reserveFactor,
111
113
  borrowWeight: parsedMarketPoolData.borrowWeight,
114
+ borrowFee: parsedMarketPoolData.borrowFee,
112
115
  marketCoinSupplyAmount: parsedMarketPoolData.marketCoinSupplyAmount,
113
116
  minBorrowAmount: parsedMarketPoolData.minBorrowAmount,
114
117
  ...calculatedMarketPoolData,
@@ -243,6 +246,7 @@ export const getMarketPool = async (
243
246
  let balanceSheet: BalanceSheet | undefined;
244
247
  let borrowIndex: BorrowIndex | undefined;
245
248
  let interestModel: InterestModel | undefined;
249
+ let borrowFeeRate: { value: string } | undefined;
246
250
  if (marketObject) {
247
251
  if (marketObject.content && 'fields' in marketObject.content) {
248
252
  const fields = marketObject.content.fields as any;
@@ -325,10 +329,36 @@ export const getMarketPool = async (
325
329
  .fields as any;
326
330
  interestModel = dynamicFields.value.fields;
327
331
  }
332
+
333
+ // Get borrow fee.
334
+ const borrowFeeDynamicFieldObjectResponse = await query.suiKit
335
+ .client()
336
+ .getDynamicFieldObject({
337
+ parentId: marketId,
338
+ name: {
339
+ type: `${BORROW_FEE_PROTOCOL_ID}::market_dynamic_keys::BorrowFeeKey`,
340
+ value: {
341
+ type: {
342
+ name: coinType.substring(2),
343
+ },
344
+ },
345
+ },
346
+ });
347
+
348
+ const borrowFeeDynamicFieldObject =
349
+ borrowFeeDynamicFieldObjectResponse.data;
350
+ if (
351
+ borrowFeeDynamicFieldObject &&
352
+ borrowFeeDynamicFieldObject.content &&
353
+ 'fields' in borrowFeeDynamicFieldObject.content
354
+ ) {
355
+ const dynamicFields = borrowFeeDynamicFieldObject.content.fields as any;
356
+ borrowFeeRate = dynamicFields.value.fields;
357
+ }
328
358
  }
329
359
  }
330
360
 
331
- if (balanceSheet && borrowIndex && interestModel) {
361
+ if (balanceSheet && borrowIndex && interestModel && borrowFeeRate) {
332
362
  const parsedMarketPoolData = parseOriginMarketPoolData({
333
363
  type: interestModel.type.fields,
334
364
  maxBorrowRate: interestModel.max_borrow_rate.fields,
@@ -342,6 +372,7 @@ export const getMarketPool = async (
342
372
  reserve: balanceSheet.revenue,
343
373
  reserveFactor: interestModel.revenue_factor.fields,
344
374
  borrowWeight: interestModel.borrow_weight.fields,
375
+ borrowFeeRate: borrowFeeRate,
345
376
  baseBorrowRatePerSec: interestModel.base_borrow_rate_per_sec.fields,
346
377
  borrowRateOnHighKink: interestModel.borrow_rate_on_high_kink.fields,
347
378
  borrowRateOnMidKink: interestModel.borrow_rate_on_mid_kink.fields,
@@ -370,6 +401,7 @@ export const getMarketPool = async (
370
401
  midKink: parsedMarketPoolData.midKink,
371
402
  reserveFactor: parsedMarketPoolData.reserveFactor,
372
403
  borrowWeight: parsedMarketPoolData.borrowWeight,
404
+ borrowFee: parsedMarketPoolData.borrowFee,
373
405
  marketCoinSupplyAmount: parsedMarketPoolData.marketCoinSupplyAmount,
374
406
  minBorrowAmount: parsedMarketPoolData.minBorrowAmount,
375
407
  ...calculatedMarketPoolData,
@@ -564,6 +596,8 @@ export const getObligations = async (
564
596
  ownerAddress?: string
565
597
  ) => {
566
598
  const owner = ownerAddress || query.suiKit.currentAddress();
599
+ const protocolObjectId =
600
+ query.address.get('core.object') || PROTOCOL_OBJECT_ID;
567
601
  const keyObjectsResponse: SuiObjectResponse[] = [];
568
602
  let hasNextPage = false;
569
603
  let nextCursor: string | null = null;
@@ -573,7 +607,7 @@ export const getObligations = async (
573
607
  .getOwnedObjects({
574
608
  owner,
575
609
  filter: {
576
- StructType: `${PROTOCOL_OBJECT_ID}::obligation::ObligationKey`,
610
+ StructType: `${protocolObjectId}::obligation::ObligationKey`,
577
611
  },
578
612
  cursor: nextCursor,
579
613
  });
@@ -321,18 +321,22 @@ export const getObligationAccount = async (
321
321
  let totalBorrowedValue = BigNumber(0);
322
322
  let totalBorrowedValueWithWeight = BigNumber(0);
323
323
 
324
- for (const collateral of obligationQuery.collaterals) {
325
- const collateralCoinName =
326
- query.utils.parseCoinNameFromType<SupportCollateralCoins>(
327
- collateral.type.name
328
- );
329
- const coinDecimal = query.utils.getCoinDecimal(collateralCoinName);
330
- const marketCollateral = market.collaterals[collateralCoinName];
331
- const coinPrice = coinPrices?.[collateralCoinName];
332
- const coinAmount = coinAmounts?.[collateralCoinName] ?? 0;
324
+ for (const assetCoinName of assetCoinNames) {
325
+ const collateral = obligationQuery.collaterals.find((collateral) => {
326
+ const collateralCoinName =
327
+ query.utils.parseCoinNameFromType<SupportCollateralCoins>(
328
+ collateral.type.name
329
+ );
330
+ return assetCoinName === collateralCoinName;
331
+ });
332
+
333
+ const coinDecimal = query.utils.getCoinDecimal(assetCoinName);
334
+ const marketCollateral = market.collaterals[assetCoinName];
335
+ const coinPrice = coinPrices?.[assetCoinName];
336
+ const coinAmount = coinAmounts?.[assetCoinName] ?? 0;
333
337
 
334
338
  if (marketCollateral && coinPrice) {
335
- const depositedAmount = BigNumber(collateral.amount);
339
+ const depositedAmount = BigNumber(collateral?.amount ?? 0);
336
340
  const depositedCoin = depositedAmount.shiftedBy(-1 * coinDecimal);
337
341
  const depositedValue = depositedCoin.multipliedBy(coinPrice);
338
342
  const borrowCapacityValue = depositedValue.multipliedBy(
@@ -357,10 +361,10 @@ export const getObligationAccount = async (
357
361
  totalDepositedPools++;
358
362
  }
359
363
 
360
- collaterals[collateralCoinName] = {
361
- coinName: collateralCoinName,
362
- coinType: collateral.type.name,
363
- symbol: query.utils.parseSymbol(collateralCoinName),
364
+ collaterals[assetCoinName] = {
365
+ coinName: assetCoinName,
366
+ coinType: query.utils.parseCoinType(assetCoinName),
367
+ symbol: query.utils.parseSymbol(assetCoinName),
364
368
  coinDecimal: coinDecimal,
365
369
  coinPrice: coinPrice,
366
370
  depositedAmount: depositedAmount.toNumber(),
@@ -376,18 +380,23 @@ export const getObligationAccount = async (
376
380
  }
377
381
  }
378
382
 
379
- for (const debt of obligationQuery.debts) {
380
- const poolCoinName = query.utils.parseCoinNameFromType<SupportPoolCoins>(
381
- debt.type.name
382
- );
383
- const coinDecimal = query.utils.getCoinDecimal(poolCoinName);
384
- const marketPool = market.pools[poolCoinName];
385
- const coinPrice = coinPrices?.[poolCoinName];
383
+ for (const assetCoinName of assetCoinNames) {
384
+ const debt = obligationQuery.debts.find((debt) => {
385
+ const poolCoinName = query.utils.parseCoinNameFromType<SupportPoolCoins>(
386
+ debt.type.name
387
+ );
388
+ return assetCoinName === poolCoinName;
389
+ });
390
+
391
+ const coinDecimal = query.utils.getCoinDecimal(assetCoinName);
392
+ const marketPool = market.pools[assetCoinName];
393
+ const coinPrice = coinPrices?.[assetCoinName];
386
394
 
387
395
  if (marketPool && coinPrice) {
388
- const increasedRate =
389
- marketPool.borrowIndex / Number(debt.borrowIndex) - 1;
390
- const borrowedAmount = BigNumber(debt.amount);
396
+ const increasedRate = debt?.borrowIndex
397
+ ? marketPool.borrowIndex / Number(debt.borrowIndex) - 1
398
+ : 0;
399
+ const borrowedAmount = BigNumber(debt?.amount ?? 0);
391
400
  const borrowedCoin = borrowedAmount.shiftedBy(-1 * coinDecimal);
392
401
  const availableRepayAmount = borrowedAmount.multipliedBy(
393
402
  increasedRate + 1
@@ -409,17 +418,17 @@ export const getObligationAccount = async (
409
418
  totalBorrowedPools++;
410
419
  }
411
420
 
412
- debts[poolCoinName] = {
413
- coinName: poolCoinName,
414
- coinType: debt.type.name,
415
- symbol: query.utils.parseSymbol(poolCoinName),
421
+ debts[assetCoinName] = {
422
+ coinName: assetCoinName,
423
+ coinType: query.utils.parseCoinType(assetCoinName),
424
+ symbol: query.utils.parseSymbol(assetCoinName),
416
425
  coinDecimal: coinDecimal,
417
426
  coinPrice: coinPrice,
418
427
  borrowedAmount: borrowedAmount.toNumber(),
419
428
  borrowedCoin: borrowedCoin.toNumber(),
420
429
  borrowedValue: borrowedValue.toNumber(),
421
430
  borrowedValueWithWeight: borrowedValueWithWeight.toNumber(),
422
- borrowIndex: Number(debt.borrowIndex),
431
+ borrowIndex: Number(debt?.borrowIndex ?? 0),
423
432
  availableBorrowAmount: 0,
424
433
  availableBorrowCoin: 0,
425
434
  availableRepayAmount: availableRepayAmount.toNumber(),
@@ -69,6 +69,7 @@ export const getSpool = async (
69
69
  ) => {
70
70
  const coinName = query.utils.parseCoinName<SupportStakeCoins>(marketCoinName);
71
71
  marketPool = marketPool || (await query.getMarketPool(coinName));
72
+ const spoolPkgId = query.address.get(`spool.id`);
72
73
  const poolId = query.address.get(`spool.pools.${marketCoinName}.id`);
73
74
  const rewardPoolId = query.address.get(
74
75
  `spool.pools.${marketCoinName}.rewardPoolId`
@@ -80,6 +81,15 @@ export const getSpool = async (
80
81
  showContent: true,
81
82
  },
82
83
  });
84
+ const spoolRewardFeeDynamicFieldsResponse = await query.suiKit
85
+ .client()
86
+ .getDynamicFieldObject({
87
+ parentId: rewardPoolId,
88
+ name: {
89
+ type: `${spoolPkgId}::rewards_pool::RewardsPoolFeeKey`,
90
+ value: { dummy_field: false },
91
+ },
92
+ });
83
93
 
84
94
  if (
85
95
  marketPool &&
@@ -94,19 +104,20 @@ export const getSpool = async (
94
104
 
95
105
  const spoolObject = spoolObjectResponse[0].data;
96
106
  const rewardPoolObject = spoolObjectResponse[1].data;
107
+ const rewardFeeObject = spoolRewardFeeDynamicFieldsResponse.data;
97
108
  if (spoolObject.content && 'fields' in spoolObject.content) {
98
- const fields = spoolObject.content.fields as any;
109
+ const spoolFields = spoolObject.content.fields as any;
99
110
  const parsedSpoolData = parseOriginSpoolData({
100
- stakeType: fields.stake_type,
101
- maxDistributedPoint: fields.max_distributed_point,
102
- distributedPoint: fields.distributed_point,
103
- distributedPointPerPeriod: fields.distributed_point_per_period,
104
- pointDistributionTime: fields.point_distribution_time,
105
- maxStake: fields.max_stakes,
106
- stakes: fields.stakes,
107
- index: fields.index,
108
- createdAt: fields.created_at,
109
- lastUpdate: fields.last_update,
111
+ stakeType: spoolFields.stake_type,
112
+ maxDistributedPoint: spoolFields.max_distributed_point,
113
+ distributedPoint: spoolFields.distributed_point,
114
+ distributedPointPerPeriod: spoolFields.distributed_point_per_period,
115
+ pointDistributionTime: spoolFields.point_distribution_time,
116
+ maxStake: spoolFields.max_stakes,
117
+ stakes: spoolFields.stakes,
118
+ index: spoolFields.index,
119
+ createdAt: spoolFields.created_at,
120
+ lastUpdate: spoolFields.last_update,
110
121
  });
111
122
 
112
123
  const marketCoinPrice =
@@ -118,14 +129,23 @@ export const getSpool = async (
118
129
  marketCoinDecimal
119
130
  );
120
131
 
121
- if (rewardPoolObject.content && 'fields' in rewardPoolObject.content) {
122
- const fields = rewardPoolObject.content.fields as any;
132
+ if (
133
+ rewardPoolObject.content &&
134
+ rewardFeeObject?.content &&
135
+ 'fields' in rewardPoolObject.content &&
136
+ 'fields' in rewardFeeObject.content
137
+ ) {
138
+ const rewardPoolFields = rewardPoolObject.content.fields as any;
139
+ const rewardFeeFields = (rewardFeeObject.content.fields as any).value
140
+ .fields;
123
141
  const parsedSpoolRewardPoolData = parseOriginSpoolRewardPoolData({
124
- claimed_rewards: fields.claimed_rewards,
125
- exchange_rate_numerator: fields.exchange_rate_numerator,
126
- exchange_rate_denominator: fields.exchange_rate_denominator,
127
- rewards: fields.rewards,
128
- spool_id: fields.spool_id,
142
+ claimed_rewards: rewardPoolFields.claimed_rewards,
143
+ exchange_rate_numerator: rewardPoolFields.exchange_rate_numerator,
144
+ exchange_rate_denominator: rewardPoolFields.exchange_rate_denominator,
145
+ fee_rate_numerator: rewardFeeFields.fee_rate_numerator,
146
+ fee_rate_denominator: rewardFeeFields.fee_rate_denominator,
147
+ rewards: rewardPoolFields.rewards,
148
+ spool_id: rewardPoolFields.spool_id,
129
149
  });
130
150
 
131
151
  const rewardCoinPrice = coinPrices?.[rewardCoinName] ?? 0;
@@ -181,8 +201,8 @@ export const getStakeAccounts = async (
181
201
  ownerAddress?: string
182
202
  ) => {
183
203
  const owner = ownerAddress || query.suiKit.currentAddress();
184
- const spoolPkgId = query.address.get('spool.id');
185
- const stakeAccountType = `${spoolPkgId}::spool_account::SpoolAccount`;
204
+ const spoolObjectId = query.address.get('spool.object');
205
+ const stakeAccountType = `${spoolObjectId}::spool_account::SpoolAccount`;
186
206
  const stakeObjectsResponse: SuiObjectResponse[] = [];
187
207
  let hasNextPage = false;
188
208
  let nextCursor: string | null = null;
@@ -223,7 +243,7 @@ export const getStakeAccounts = async (
223
243
 
224
244
  types[
225
245
  stakeMarketCoinName as SupportStakeMarketCoins
226
- ] = `${spoolPkgId}::spool_account::SpoolAccount<${marketCoinType}>`;
246
+ ] = `${spoolObjectId}::spool_account::SpoolAccount<${marketCoinType}>`;
227
247
  return types;
228
248
  },
229
249
  {} as Record<SupportStakeMarketCoins, string>
@@ -357,6 +377,7 @@ export const getStakeRewardPool = async (
357
377
  query: ScallopQuery,
358
378
  marketCoinName: SupportStakeMarketCoins
359
379
  ) => {
380
+ const spoolPkgId = query.address.get('spool.id');
360
381
  const poolId = query.address.get(
361
382
  `spool.pools.${marketCoinName}.rewardPoolId`
362
383
  );
@@ -368,26 +389,52 @@ export const getStakeRewardPool = async (
368
389
  showType: true,
369
390
  },
370
391
  });
371
- if (stakeRewardPoolObjectResponse.data) {
392
+ const stakeRewardFeeDynamicFieldsResponse = await query.suiKit
393
+ .client()
394
+ .getDynamicFieldObject({
395
+ parentId: poolId,
396
+ name: {
397
+ type: `${spoolPkgId}::rewards_pool::RewardsPoolFeeKey`,
398
+ value: { dummy_field: false },
399
+ },
400
+ });
401
+ if (
402
+ stakeRewardPoolObjectResponse.data &&
403
+ stakeRewardFeeDynamicFieldsResponse.data
404
+ ) {
372
405
  const stakeRewardPoolObject = stakeRewardPoolObjectResponse.data;
406
+ const stakeRewardFeeDynamicFieldObject =
407
+ stakeRewardFeeDynamicFieldsResponse.data;
373
408
  const id = stakeRewardPoolObject.objectId;
374
409
  const type = stakeRewardPoolObject.type!;
375
410
  if (
376
411
  stakeRewardPoolObject.content &&
377
- 'fields' in stakeRewardPoolObject.content
412
+ stakeRewardFeeDynamicFieldObject.content &&
413
+ 'fields' in stakeRewardPoolObject.content &&
414
+ 'fields' in stakeRewardFeeDynamicFieldObject.content
378
415
  ) {
379
- const fields = stakeRewardPoolObject.content.fields as any;
380
- const stakePoolId = String(fields.spool_id);
381
- const ratioNumerator = Number(fields.exchange_rate_numerator);
382
- const ratioDenominator = Number(fields.exchange_rate_denominator);
383
- const rewards = Number(fields.rewards);
384
- const claimedRewards = Number(fields.claimed_rewards);
416
+ const rewardPoolFields = stakeRewardPoolObject.content.fields as any;
417
+ const rewardFeeFields = (
418
+ stakeRewardFeeDynamicFieldObject.content.fields as any
419
+ ).value.fields;
420
+ const stakePoolId = String(rewardPoolFields.spool_id);
421
+ const ratioNumerator = Number(rewardPoolFields.exchange_rate_numerator);
422
+ const ratioDenominator = Number(
423
+ rewardPoolFields.exchange_rate_denominator
424
+ );
425
+ const rewards = Number(rewardPoolFields.rewards);
426
+ const claimedRewards = Number(rewardPoolFields.claimed_rewards);
427
+ const feeRateNumerator = Number(rewardFeeFields.fee_rate_numerator);
428
+ const feeRateDenominator = Number(rewardFeeFields.fee_rate_denominator);
429
+
385
430
  stakeRewardPool = {
386
431
  id,
387
432
  type: normalizeStructTag(type),
388
433
  stakePoolId,
389
434
  ratioNumerator,
390
435
  ratioDenominator,
436
+ feeRateNumerator,
437
+ feeRateDenominator,
391
438
  rewards,
392
439
  claimedRewards,
393
440
  };
@@ -10,6 +10,7 @@ export interface AddressesInterface {
10
10
  core: {
11
11
  version: string;
12
12
  versionCap: string;
13
+ object: string;
13
14
  market: string;
14
15
  adminCap: string;
15
16
  coinDecimalsRegistry: string;
@@ -71,6 +72,7 @@ export interface AddressesInterface {
71
72
  spool: {
72
73
  id: string;
73
74
  adminCap: string;
75
+ object: string;
74
76
  pools: Partial<
75
77
  Record<
76
78
  SupportStakeMarketCoins,
@@ -84,6 +86,7 @@ export interface AddressesInterface {
84
86
  borrowIncentive: {
85
87
  id: string;
86
88
  adminCap: string;
89
+ object: string;
87
90
  query: string;
88
91
  incentivePools: string;
89
92
  incentiveAccounts: string;
@@ -83,6 +83,8 @@ export type OriginBorrowIncentiveRewardPoolData = {
83
83
  claimed_rewards: string;
84
84
  exchange_rate_denominator: string;
85
85
  exchange_rate_numerator: string;
86
+ rewards_fee_rate_denominator: string;
87
+ rewards_fee_rate_numerator: string;
86
88
  remaining_reward: string;
87
89
  reward_type: {
88
90
  name: string;
@@ -92,8 +94,10 @@ export type OriginBorrowIncentiveRewardPoolData = {
92
94
  export type ParsedBorrowIncentiveRewardPoolData = {
93
95
  rewardType: string;
94
96
  claimedRewards: number;
95
- exchangeRateNumerator: number;
96
97
  exchangeRateDenominator: number;
98
+ exchangeRateNumerator: number;
99
+ rewardsFeeRateDenominator: number;
100
+ rewardsFeeRateNumerator: number;
97
101
  remainingRewards: number;
98
102
  };
99
103
 
@@ -109,6 +113,7 @@ export type CalculatedBorrowIncentiveRewardPoolData = {
109
113
  claimedRewardCoin: number;
110
114
  claimedRewardValue: number;
111
115
  rewardPerSec: number;
116
+ rewardFee: number;
112
117
  };
113
118
 
114
119
  export type BorrowIncentiveAccounts = OptionalKeys<