@scallop-io/sui-scallop-sdk 2.0.0-alpha.8 → 2.0.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.
@@ -36,6 +36,7 @@ export class ScallopConstants {
36
36
  scoin: new Set(),
37
37
  spool: new Set(),
38
38
  borrowIncentiveRewards: new Set(),
39
+ rewardsAsPoint: new Set(),
39
40
  suiBridge: new Set(),
40
41
  wormhole: new Set(),
41
42
  oracles: new Set(),
@@ -98,10 +99,20 @@ export class ScallopConstants {
98
99
  }
99
100
 
100
101
  get isInitialized() {
102
+ const REQUIRED_WHITELIST_KEYS = [
103
+ 'lending',
104
+ 'collateral',
105
+ 'borrowing',
106
+ 'packages',
107
+ 'scoin',
108
+ 'spool',
109
+ 'oracles',
110
+ 'pythEndpoints',
111
+ ] as const;
101
112
  return (
102
- !this.isEmptyObject(this._poolAddresses) &&
103
- Object.values(this._whitelist).every((t) => t.size > 0) &&
104
- this.isAddressInitialized
113
+ this.isAddressInitialized && // address is initialized
114
+ !this.isEmptyObject(this._poolAddresses) && // poolAddresses is initialized
115
+ REQUIRED_WHITELIST_KEYS.every((t) => this.whitelist[t].size > 0) // whitelist is initialized
105
116
  );
106
117
  }
107
118
 
@@ -554,7 +554,9 @@ export class ScallopUtils {
554
554
  public getSupportedPoolAddresses(): PoolAddress[] {
555
555
  return this.constants.poolAddresses
556
556
  ? Object.values(this.constants.poolAddresses).filter(
557
- (address): address is PoolAddress => address !== undefined
557
+ (poolAddress): poolAddress is PoolAddress =>
558
+ poolAddress !== undefined &&
559
+ this.constants.whitelist.lending.has(poolAddress.coinName)
558
560
  )
559
561
  : [];
560
562
  }
@@ -13,7 +13,7 @@ import type {
13
13
  CoinAmounts,
14
14
  CoinPrices,
15
15
  TotalValueLocked,
16
- ObligationBorrowIcentiveReward,
16
+ ObligationBorrowIncentiveReward,
17
17
  MarketPools,
18
18
  MarketCollaterals,
19
19
  } from '../types';
@@ -534,7 +534,7 @@ export const getObligationAccount = async (
534
534
  const coinName = poolCoinName as string;
535
535
  const borrowIncentivePool = borrowIncentivePools[coinName];
536
536
  if (borrowIncentivePool) {
537
- const rewards: ObligationBorrowIcentiveReward[] = [];
537
+ const rewards: ObligationBorrowIncentiveReward[] = [];
538
538
  Object.entries(borrowIncentiveAccount.pointList).forEach(
539
539
  ([key, accountPoint]) => {
540
540
  const poolPoint =
@@ -590,6 +590,7 @@ export const getObligationAccount = async (
590
590
  symbol: poolPoint.symbol,
591
591
  coinDecimal: poolPoint.coinDecimal,
592
592
  coinPrice: poolPoint.coinPrice,
593
+ weightedBorrowAmount: accountBorrowedAmount.toNumber(),
593
594
  availableClaimAmount: availableClaimAmount.toNumber(),
594
595
  availableClaimCoin: availableClaimCoin.toNumber(),
595
596
  boostValue,
@@ -39,6 +39,7 @@ export type Whitelist = {
39
39
  wormhole: Set<string>;
40
40
  oracles: Set<string>;
41
41
  borrowIncentiveRewards: Set<string>;
42
+ rewardsAsPoint: Set<string>;
42
43
  pythEndpoints: Set<string>;
43
44
  deprecated: Set<string>;
44
45
  };
@@ -108,12 +108,13 @@ export type ObligationDebt = {
108
108
  availableRepayCoin: number;
109
109
  };
110
110
 
111
- export type ObligationBorrowIcentiveReward = {
111
+ export type ObligationBorrowIncentiveReward = {
112
112
  coinName: string;
113
113
  coinType: string;
114
114
  symbol: string;
115
115
  coinDecimal: number;
116
116
  coinPrice: number;
117
+ weightedBorrowAmount: number;
117
118
  availableClaimCoin: number;
118
119
  availableClaimAmount: number;
119
120
  boostValue: number;
@@ -125,7 +126,7 @@ export type ObligationBorrowIncentive = {
125
126
  symbol: string;
126
127
  coinDecimal: number;
127
128
  coinPrice: number;
128
- rewards: ObligationBorrowIcentiveReward[];
129
+ rewards: ObligationBorrowIncentiveReward[];
129
130
  };
130
131
 
131
132
  export type TotalValueLocked = {