@carrot-protocol/boost-http-client 0.2.15-group-refactor1-dev-875d3f7 → 0.2.15-group-refactor1-dev-4a94dd5

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/index.js CHANGED
@@ -184,50 +184,50 @@ class Client {
184
184
  }
185
185
  // if no clend accounts, return empty array
186
186
  const clendAccounts = [];
187
- if (jsonRawResponse.clendAccounts) {
188
- for (const [address, ca] of Object.entries(jsonRawResponse.clendAccounts)) {
189
- // parse lending account balances
190
- const clendAccountBalances = [];
191
- for (const b of ca.balances) {
192
- // parse liquidation data if exists
193
- const liquidation = b.liquidation
194
- ? {
195
- price: Number(b.liquidation.price),
196
- changePercentage: Number(b.liquidation.changePercentage),
197
- }
198
- : null;
199
- // create clend account balance
200
- clendAccountBalances.push({
201
- mint: new anchor_1.web3.PublicKey(b.mint),
202
- bank: new anchor_1.web3.PublicKey(b.bank),
203
- assetBalance: new anchor_1.BN(b.assetBalance, "hex"),
204
- assetBalanceUi: Number(b.assetBalanceUi),
205
- assetValue: Number(b.assetValue),
206
- liabilityBalance: new anchor_1.BN(b.liabilityBalance, "hex"),
207
- liabilityBalanceUi: Number(b.liabilityBalanceUi),
208
- liabilityValue: Number(b.liabilityValue),
209
- price: Number(b.price),
210
- liquidation,
211
- });
212
- }
213
- // create clend account
214
- const clendAccount = {
215
- balances: clendAccountBalances,
216
- netValue: Number(ca.netValue),
217
- netApy: Number(ca.netApy),
218
- pnl: Number(ca.pnl),
219
- totalAssetValue: Number(ca.totalAssetValue),
220
- totalLiabilityValue: Number(ca.totalLiabilityValue),
221
- healthFactorNotional: Number(ca.healthFactorNotional),
222
- healthFactorRiskAdjusted: Number(ca.healthFactorRiskAdjusted),
223
- notionalLeverage: Number(ca.notionalLeverage),
224
- riskAdjustedLeverage: Number(ca.riskAdjustedLeverage),
225
- notionalLtv: Number(ca.notionalLtv),
226
- riskAdjustedLtv: Number(ca.riskAdjustedLtv),
227
- };
228
- const summary = summaryByAccount.get(address) || [];
229
- clendAccounts.push({ clendAccount, summary });
187
+ for (const accountAndSumary of jsonRawResponse.clendAccounts) {
188
+ const clendAccountBalances = [];
189
+ const ca = accountAndSumary.clendAccount;
190
+ for (const b of ca.balances) {
191
+ // parse liquidation data if exists
192
+ const liquidation = b.liquidation
193
+ ? {
194
+ price: Number(b.liquidation.price),
195
+ changePercentage: Number(b.liquidation.changePercentage),
196
+ }
197
+ : null;
198
+ // create clend account balance
199
+ clendAccountBalances.push({
200
+ mint: new anchor_1.web3.PublicKey(b.mint),
201
+ bank: new anchor_1.web3.PublicKey(b.bank),
202
+ assetBalance: new anchor_1.BN(b.assetBalance, "hex"),
203
+ assetBalanceUi: Number(b.assetBalanceUi),
204
+ assetValue: Number(b.assetValue),
205
+ liabilityBalance: new anchor_1.BN(b.liabilityBalance, "hex"),
206
+ liabilityBalanceUi: Number(b.liabilityBalanceUi),
207
+ liabilityValue: Number(b.liabilityValue),
208
+ price: Number(b.price),
209
+ liquidation,
210
+ });
230
211
  }
212
+ // create clend account
213
+ const clendAccountAddress = new anchor_1.web3.PublicKey(accountAndSumary.clendAccount.key);
214
+ const clendAccount = {
215
+ key: clendAccountAddress,
216
+ balances: clendAccountBalances,
217
+ netValue: Number(ca.netValue),
218
+ netApy: Number(ca.netApy),
219
+ pnl: Number(ca.pnl),
220
+ totalAssetValue: Number(ca.totalAssetValue),
221
+ totalLiabilityValue: Number(ca.totalLiabilityValue),
222
+ healthFactorNotional: Number(ca.healthFactorNotional),
223
+ healthFactorRiskAdjusted: Number(ca.healthFactorRiskAdjusted),
224
+ notionalLeverage: Number(ca.notionalLeverage),
225
+ riskAdjustedLeverage: Number(ca.riskAdjustedLeverage),
226
+ notionalLtv: Number(ca.notionalLtv),
227
+ riskAdjustedLtv: Number(ca.riskAdjustedLtv),
228
+ };
229
+ const summary = summaryByAccount.get(clendAccountAddress.toString()) || [];
230
+ clendAccounts.push({ clendAccount, summary });
231
231
  }
232
232
  return {
233
233
  wallet,
package/dist/types.d.ts CHANGED
@@ -85,6 +85,7 @@ export interface UserBalance {
85
85
  balanceUi: number;
86
86
  }
87
87
  export interface ClendAccount {
88
+ key: web3.PublicKey;
88
89
  balances: ClendAccountBalance[];
89
90
  netValue: number;
90
91
  netApy: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrot-protocol/boost-http-client",
3
- "version": "0.2.15-group-refactor1-dev-875d3f7",
3
+ "version": "0.2.15-group-refactor1-dev-4a94dd5",
4
4
  "description": "HTTP client for Carrot Boost",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -206,57 +206,56 @@ export class Client {
206
206
  clendAccount: ClendAccount;
207
207
  summary: ClendAccountTxSummary[];
208
208
  }[] = [];
209
- if (jsonRawResponse.clendAccounts) {
210
- for (const [address, ca] of Object.entries(
211
- jsonRawResponse.clendAccounts,
212
- )) {
213
- // parse lending account balances
214
- const clendAccountBalances: ClendAccountBalance[] = [];
215
- for (const b of (ca as any).balances) {
216
- // parse liquidation data if exists
217
- const liquidation: ClendAccountAssetLiquidation | null = b.liquidation
218
- ? {
219
- price: Number(b.liquidation.price),
220
- changePercentage: Number(b.liquidation.changePercentage),
221
- }
222
- : null;
223
-
224
- // create clend account balance
225
- clendAccountBalances.push({
226
- mint: new web3.PublicKey(b.mint),
227
- bank: new web3.PublicKey(b.bank),
228
- assetBalance: new BN(b.assetBalance, "hex"),
229
- assetBalanceUi: Number(b.assetBalanceUi),
230
- assetValue: Number(b.assetValue),
231
- liabilityBalance: new BN(b.liabilityBalance, "hex"),
232
- liabilityBalanceUi: Number(b.liabilityBalanceUi),
233
- liabilityValue: Number(b.liabilityValue),
234
- price: Number(b.price),
235
- liquidation,
236
- });
237
- }
238
-
239
- // create clend account
240
- const clendAccount: ClendAccount = {
241
- balances: clendAccountBalances,
242
- netValue: Number((ca as any).netValue),
243
- netApy: Number((ca as any).netApy),
244
- pnl: Number((ca as any).pnl),
245
- totalAssetValue: Number((ca as any).totalAssetValue),
246
- totalLiabilityValue: Number((ca as any).totalLiabilityValue),
247
- healthFactorNotional: Number((ca as any).healthFactorNotional),
248
- healthFactorRiskAdjusted: Number(
249
- (ca as any).healthFactorRiskAdjusted,
250
- ),
251
- notionalLeverage: Number((ca as any).notionalLeverage),
252
- riskAdjustedLeverage: Number((ca as any).riskAdjustedLeverage),
253
- notionalLtv: Number((ca as any).notionalLtv),
254
- riskAdjustedLtv: Number((ca as any).riskAdjustedLtv),
255
- };
256
-
257
- const summary = summaryByAccount.get(address) || [];
258
- clendAccounts.push({ clendAccount, summary });
209
+ for (const accountAndSumary of jsonRawResponse.clendAccounts) {
210
+ const clendAccountBalances: ClendAccountBalance[] = [];
211
+ const ca = accountAndSumary.clendAccount;
212
+ for (const b of ca.balances) {
213
+ // parse liquidation data if exists
214
+ const liquidation: ClendAccountAssetLiquidation | null = b.liquidation
215
+ ? {
216
+ price: Number(b.liquidation.price),
217
+ changePercentage: Number(b.liquidation.changePercentage),
218
+ }
219
+ : null;
220
+
221
+ // create clend account balance
222
+ clendAccountBalances.push({
223
+ mint: new web3.PublicKey(b.mint),
224
+ bank: new web3.PublicKey(b.bank),
225
+ assetBalance: new BN(b.assetBalance, "hex"),
226
+ assetBalanceUi: Number(b.assetBalanceUi),
227
+ assetValue: Number(b.assetValue),
228
+ liabilityBalance: new BN(b.liabilityBalance, "hex"),
229
+ liabilityBalanceUi: Number(b.liabilityBalanceUi),
230
+ liabilityValue: Number(b.liabilityValue),
231
+ price: Number(b.price),
232
+ liquidation,
233
+ });
259
234
  }
235
+
236
+ // create clend account
237
+ const clendAccountAddress = new web3.PublicKey(
238
+ accountAndSumary.clendAccount.key,
239
+ );
240
+ const clendAccount: ClendAccount = {
241
+ key: clendAccountAddress,
242
+ balances: clendAccountBalances,
243
+ netValue: Number(ca.netValue),
244
+ netApy: Number(ca.netApy),
245
+ pnl: Number(ca.pnl),
246
+ totalAssetValue: Number(ca.totalAssetValue),
247
+ totalLiabilityValue: Number(ca.totalLiabilityValue),
248
+ healthFactorNotional: Number(ca.healthFactorNotional),
249
+ healthFactorRiskAdjusted: Number(ca.healthFactorRiskAdjusted),
250
+ notionalLeverage: Number(ca.notionalLeverage),
251
+ riskAdjustedLeverage: Number(ca.riskAdjustedLeverage),
252
+ notionalLtv: Number(ca.notionalLtv),
253
+ riskAdjustedLtv: Number(ca.riskAdjustedLtv),
254
+ };
255
+
256
+ const summary =
257
+ summaryByAccount.get(clendAccountAddress.toString()) || [];
258
+ clendAccounts.push({ clendAccount, summary });
260
259
  }
261
260
 
262
261
  return {
package/src/types.ts CHANGED
@@ -99,6 +99,7 @@ export interface UserBalance {
99
99
  }
100
100
 
101
101
  export interface ClendAccount {
102
+ key: web3.PublicKey;
102
103
  balances: ClendAccountBalance[];
103
104
  netValue: number;
104
105
  netApy: number;