@scallop-io/sui-scallop-sdk 1.4.16 → 1.4.18

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.
@@ -3,10 +3,10 @@ import { partitionArray } from 'src/utils';
3
3
 
4
4
  export const queryMultipleObjects = async (
5
5
  cache: ScallopCache,
6
- objectIds: string[],
6
+ rawObjectIds: string[],
7
7
  partitionSize = 50
8
8
  ) => {
9
- const objectIdsPartition = partitionArray(objectIds, partitionSize);
9
+ const objectIdsPartition = partitionArray(rawObjectIds, partitionSize);
10
10
 
11
11
  const objects = [];
12
12
  for (const objectIds of objectIdsPartition) {
@@ -7,12 +7,16 @@ export const getAllAddresses = async (query: ScallopQuery) => {
7
7
  Record<
8
8
  SupportPoolCoins,
9
9
  {
10
+ coinName: string;
11
+ symbol: string;
10
12
  lendingPoolAddress?: string;
11
13
  collateralPoolAddress?: string; // not all pool has collateral
12
14
  borrowDynamic?: string;
13
15
  spoolReward?: string;
14
16
  spool?: string;
15
17
  sCoinType?: string;
18
+ sCoinName?: string;
19
+ sCoinSymbol?: string;
16
20
  sCoinTreasury?: string;
17
21
  interestModel?: string;
18
22
  riskModel?: string;
@@ -23,6 +27,8 @@ export const getAllAddresses = async (query: ScallopQuery) => {
23
27
  coinMetadataId?: string;
24
28
  borrowIncentivePoolId?: string;
25
29
  coinType?: string;
30
+ sCoinMetadataId?: string;
31
+ spoolName?: string;
26
32
  }
27
33
  >
28
34
  > = {};
@@ -116,6 +122,12 @@ export const getAllAddresses = async (query: ScallopQuery) => {
116
122
  );
117
123
  // @ts-ignore
118
124
  const sCoinType = query.address.get(`scoin.coins.s${coinName}.coinType`);
125
+ const sCoinName = sCoinType
126
+ ? query.utils.parseSCoinName(coinName)
127
+ : undefined;
128
+ const sCoinSymbol = sCoinName
129
+ ? query.utils.parseSymbol(sCoinName)
130
+ : undefined;
119
131
  const sCoinTreasury = query.address.get(
120
132
  // @ts-ignore
121
133
  `scoin.coins.s${coinName}.treasury`
@@ -123,7 +135,14 @@ export const getAllAddresses = async (query: ScallopQuery) => {
123
135
  const coinMetadataId = query.address.get(
124
136
  `core.coins.${coinName}.metaData`
125
137
  );
138
+ const sCoinMetadataId = query.address.get(
139
+ // @ts-ignore
140
+ `scoin.coins.s${coinName}.metaData`
141
+ );
142
+ const spoolName = spool ? `s${coinName}` : undefined;
126
143
  results[coinName as SupportPoolCoins] = {
144
+ coinName,
145
+ symbol: query.utils.parseSymbol(coinName),
127
146
  lendingPoolAddress: addresses[0],
128
147
  collateralPoolAddress: addresses[1],
129
148
  borrowDynamic: addresses[2],
@@ -137,8 +156,12 @@ export const getAllAddresses = async (query: ScallopQuery) => {
137
156
  spoolReward: rewardPool,
138
157
  sCoinTreasury,
139
158
  sCoinType,
159
+ sCoinName,
160
+ sCoinSymbol,
140
161
  coinMetadataId,
141
162
  coinType: `0x${coinType}`,
163
+ sCoinMetadataId,
164
+ spoolName,
142
165
  };
143
166
 
144
167
  await new Promise((resolve) => setTimeout(resolve, 500));
@@ -650,7 +650,10 @@ export const getObligationAccount = async (
650
650
  }
651
651
 
652
652
  let riskLevel = totalRequiredCollateralValue.isZero()
653
- ? BigNumber(0)
653
+ ? // Note: when there is no collateral and debt is not zero, then it's a bad-debt situation.
654
+ totalBorrowedValueWithWeight.isGreaterThan(0)
655
+ ? BigNumber(100)
656
+ : BigNumber(0)
654
657
  : totalBorrowedValueWithWeight.dividedBy(totalRequiredCollateralValue);
655
658
  // Note: 100% represents the safety upper limit. Even if it exceeds 100% before it is liquidated, it will only display 100%.
656
659
  riskLevel = riskLevel.isLessThan(1) ? riskLevel : BigNumber(1);