@carrot-protocol/boost-http-client 0.2.15-group-refactor1-dev-e792f4d → 0.2.15-group-refactor1-dev-57892a5

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
@@ -112,113 +112,124 @@ class Client {
112
112
  }
113
113
  const body = await handleApiCall(() => this.http.get(`/user?user=${user.toString()}&getClendAccountSummary=${request.getClendAccountSummary}`));
114
114
  const jsonRawResponse = JSON.parse(body);
115
- // get tokens still in user wallet
116
- const wallet = {
117
- usdcBalance: new anchor_1.BN(jsonRawResponse.wallet.usdcBalance, "hex"),
118
- usdcBalanceUi: Number(jsonRawResponse.wallet.usdcBalanceUi),
119
- jlpBalance: new anchor_1.BN(jsonRawResponse.wallet.jlpBalance, "hex"),
120
- jlpBalanceUi: Number(jsonRawResponse.wallet.jlpBalanceUi),
121
- solBalance: new anchor_1.BN(jsonRawResponse.wallet.solBalance, "hex"),
122
- solBalanceUi: Number(jsonRawResponse.wallet.solBalanceUi),
123
- };
124
- // if no clend account, return undefined for clend
125
- if (!jsonRawResponse.clendAccount) {
126
- return {
127
- wallet,
128
- clendAccount: undefined,
129
- summary: [],
130
- };
131
- }
132
- // parse lending account balances
133
- const balances = [];
134
- for (const b of jsonRawResponse.clendAccount.balances) {
135
- balances.push({
115
+ // parse balances
116
+ const walletBalances = [];
117
+ for (const b of jsonRawResponse.wallet.balances) {
118
+ walletBalances.push({
136
119
  mint: new anchor_1.web3.PublicKey(b.mint),
137
- bank: new anchor_1.web3.PublicKey(b.bank),
138
- assetBalance: new anchor_1.BN(b.assetBalance, "hex"),
139
- assetBalanceUi: Number(b.assetBalanceUi),
140
- assetValue: Number(b.assetValue),
141
- liabilityBalance: new anchor_1.BN(b.liabilityBalance, "hex"),
142
- liabilityBalanceUi: Number(b.liabilityBalanceUi),
143
- liabilityValue: Number(b.liabilityValue),
144
- price: Number(b.price),
120
+ balance: new anchor_1.BN(b.balance, "hex"),
121
+ balanceUi: Number(b.balanceUi),
145
122
  });
146
123
  }
147
- // create clend account
148
- const clendAccount = {
149
- balances,
150
- netValue: Number(jsonRawResponse.clendAccount.netValue),
151
- netApy: Number(jsonRawResponse.clendAccount.netApy),
152
- pnl: Number(jsonRawResponse.clendAccount.pnl),
153
- totalAssetValue: Number(jsonRawResponse.clendAccount.totalAssetValue),
154
- totalLiabilityValue: Number(jsonRawResponse.clendAccount.totalLiabilityValue),
155
- healthFactorNotional: Number(jsonRawResponse.clendAccount.healthFactorNotional),
156
- healthFactorRiskAdjusted: Number(jsonRawResponse.clendAccount.healthFactorRiskAdjusted),
157
- notionalLeverage: Number(jsonRawResponse.clendAccount.notionalLeverage),
158
- riskAdjustedLeverage: Number(jsonRawResponse.clendAccount.riskAdjustedLeverage),
159
- liquidationPrice: Number(jsonRawResponse.clendAccount.liquidationPrice),
160
- liquidationPriceChangePercentage: Number(jsonRawResponse.clendAccount.liquidationPriceChangePercentage),
161
- notionalLtv: Number(jsonRawResponse.clendAccount.notionalLtv),
162
- riskAdjustedLtv: Number(jsonRawResponse.clendAccount.riskAdjustedLtv),
124
+ // get tokens still in user wallet
125
+ const wallet = {
126
+ balances: walletBalances,
163
127
  };
164
- // get tx summary for each account
165
- const summary = [];
166
- for (const s of jsonRawResponse.summary) {
167
- const txSummary = {
168
- txSig: s.txSig,
169
- time: s.time,
170
- clendAccount: new anchor_1.web3.PublicKey(s.clendAccount),
171
- clendAccountAuthority: new anchor_1.web3.PublicKey(s.clendAccountAuthority),
172
- clendGroup: new anchor_1.web3.PublicKey(s.clendGroup),
173
- action: s.action,
174
- input: undefined,
175
- events: [],
176
- };
177
- // parse inputs if they exist
178
- if (s.input) {
179
- const input = {
180
- apiPath: s.input.apiPath,
181
- selectedTokenMint: s.input.selectedTokenMint
182
- ? new anchor_1.web3.PublicKey(s.input.selectedTokenMint)
183
- : null,
184
- amountUi: s.input.amountUi ? Number(s.input.amountUi) : null,
185
- leverage: s.input.leverage ? Number(s.input.leverage) : null,
186
- slippageBps: s.input.slippageBps ? Number(s.input.slippageBps) : null,
187
- openPosition: s.input.openPosition
188
- ? Boolean(s.input.openPosition)
189
- : null,
190
- closePosition: s.input.closePosition
191
- ? Boolean(s.input.closePosition)
192
- : null,
128
+ // get tx summary for each account and group them
129
+ const summaryByAccount = new Map();
130
+ if (request.getClendAccountSummary && jsonRawResponse.summary) {
131
+ for (const s of jsonRawResponse.summary) {
132
+ const accountAddress = new anchor_1.web3.PublicKey(s.clendAccount).toBase58();
133
+ if (!summaryByAccount.has(accountAddress)) {
134
+ summaryByAccount.set(accountAddress, []);
135
+ }
136
+ const txSummary = {
137
+ txSig: s.txSig,
138
+ time: s.time,
139
+ clendAccount: new anchor_1.web3.PublicKey(s.clendAccount),
140
+ clendAccountAuthority: new anchor_1.web3.PublicKey(s.clendAccountAuthority),
141
+ clendGroup: new anchor_1.web3.PublicKey(s.clendGroup),
142
+ action: s.action,
143
+ input: undefined,
144
+ events: [],
193
145
  };
194
- txSummary.input = input;
146
+ // parse inputs if they exist
147
+ if (s.input) {
148
+ const input = {
149
+ apiPath: s.input.apiPath,
150
+ selectedTokenMint: s.input.selectedTokenMint
151
+ ? new anchor_1.web3.PublicKey(s.input.selectedTokenMint)
152
+ : null,
153
+ amountUi: s.input.amountUi ? Number(s.input.amountUi) : null,
154
+ leverage: s.input.leverage ? Number(s.input.leverage) : null,
155
+ slippageBps: s.input.slippageBps
156
+ ? Number(s.input.slippageBps)
157
+ : null,
158
+ openPosition: s.input.openPosition
159
+ ? Boolean(s.input.openPosition)
160
+ : null,
161
+ closePosition: s.input.closePosition
162
+ ? Boolean(s.input.closePosition)
163
+ : null,
164
+ };
165
+ txSummary.input = input;
166
+ }
167
+ // get events for each summary
168
+ for (const event of s.events) {
169
+ let closeBalance = null;
170
+ if (event.closeBalance !== null) {
171
+ closeBalance = Boolean(event.closeBalance);
172
+ }
173
+ // parse amount
174
+ const clendAccountEvent = {
175
+ eventIndex: event.eventIndex,
176
+ eventName: event.eventName,
177
+ bank: event.bank ? new anchor_1.web3.PublicKey(event.bank) : null,
178
+ mint: event.mint ? new anchor_1.web3.PublicKey(event.mint) : null,
179
+ amount: event.amount ? new anchor_1.BN(event.amount, "hex") : null,
180
+ amountUi: event.amountUi ? Number(event.amountUi) : null,
181
+ value: event.value ? Number(event.value) : null,
182
+ price: event.price ? Number(event.price) : null,
183
+ closeBalance,
184
+ };
185
+ txSummary.events.push(clendAccountEvent);
186
+ }
187
+ summaryByAccount.get(accountAddress).push(txSummary);
195
188
  }
196
- // get events for each summary
197
- for (const event of s.events) {
198
- let closeBalance = null;
199
- if (event.closeBalance !== null) {
200
- closeBalance = Boolean(event.closeBalance);
189
+ }
190
+ // if no clend account, return undefined for clend
191
+ const clendAccounts = [];
192
+ if (jsonRawResponse.clendAccounts) {
193
+ for (const [address, ca] of Object.entries(jsonRawResponse.clendAccounts)) {
194
+ // parse lending account balances
195
+ const clendAccountBalances = [];
196
+ for (const b of ca.balances) {
197
+ clendAccountBalances.push({
198
+ mint: new anchor_1.web3.PublicKey(b.mint),
199
+ bank: new anchor_1.web3.PublicKey(b.bank),
200
+ assetBalance: new anchor_1.BN(b.assetBalance, "hex"),
201
+ assetBalanceUi: Number(b.assetBalanceUi),
202
+ assetValue: Number(b.assetValue),
203
+ liabilityBalance: new anchor_1.BN(b.liabilityBalance, "hex"),
204
+ liabilityBalanceUi: Number(b.liabilityBalanceUi),
205
+ liabilityValue: Number(b.liabilityValue),
206
+ price: Number(b.price),
207
+ });
201
208
  }
202
- // parse amount
203
- const clendAccountEvent = {
204
- eventIndex: event.eventIndex,
205
- eventName: event.eventName,
206
- bank: event.bank ? new anchor_1.web3.PublicKey(event.bank) : null,
207
- mint: event.mint ? new anchor_1.web3.PublicKey(event.mint) : null,
208
- amount: event.amount ? new anchor_1.BN(event.amount, "hex") : null,
209
- amountUi: event.amountUi ? Number(event.amountUi) : null,
210
- value: event.value ? Number(event.value) : null,
211
- price: event.price ? Number(event.price) : null,
212
- closeBalance,
209
+ // create clend account
210
+ const clendAccount = {
211
+ balances: clendAccountBalances,
212
+ netValue: Number(ca.netValue),
213
+ netApy: Number(ca.netApy),
214
+ pnl: Number(ca.pnl),
215
+ totalAssetValue: Number(ca.totalAssetValue),
216
+ totalLiabilityValue: Number(ca.totalLiabilityValue),
217
+ healthFactorNotional: Number(ca.healthFactorNotional),
218
+ healthFactorRiskAdjusted: Number(ca.healthFactorRiskAdjusted),
219
+ notionalLeverage: Number(ca.notionalLeverage),
220
+ riskAdjustedLeverage: Number(ca.riskAdjustedLeverage),
221
+ liquidationPrice: Number(ca.liquidationPrice),
222
+ liquidationPriceChangePercentage: Number(ca.liquidationPriceChangePercentage),
223
+ notionalLtv: Number(ca.notionalLtv),
224
+ riskAdjustedLtv: Number(ca.riskAdjustedLtv),
213
225
  };
214
- txSummary.events.push(clendAccountEvent);
226
+ const summary = summaryByAccount.get(address) || [];
227
+ clendAccounts.push({ clendAccount, summary });
215
228
  }
216
- summary.push(txSummary);
217
229
  }
218
230
  return {
219
231
  wallet,
220
- clendAccount,
221
- summary,
232
+ clendAccounts,
222
233
  };
223
234
  }
224
235
  /**
package/dist/types.d.ts CHANGED
@@ -70,19 +70,21 @@ export interface GetUserRequest {
70
70
  }
71
71
  export interface GetUserResponse {
72
72
  wallet: UserWallet;
73
- clendAccount: ClendAccount | undefined;
74
- summary: ClendAccountTxSummary[];
73
+ clendAccounts: {
74
+ clendAccount: ClendAccount;
75
+ summary: ClendAccountTxSummary[];
76
+ }[];
75
77
  }
76
78
  export interface UserWallet {
77
- usdcBalance: BN;
78
- usdcBalanceUi: number;
79
- jlpBalance: BN;
80
- jlpBalanceUi: number;
81
- solBalance: BN;
82
- solBalanceUi: number;
79
+ balances: UserBalance[];
80
+ }
81
+ export interface UserBalance {
82
+ mint: web3.PublicKey;
83
+ balance: BN;
84
+ balanceUi: number;
83
85
  }
84
86
  export interface ClendAccount {
85
- balances: Balance[];
87
+ balances: ClendAccountBalance[];
86
88
  netValue: number;
87
89
  netApy: number;
88
90
  pnl: number;
@@ -97,7 +99,7 @@ export interface ClendAccount {
97
99
  notionalLtv: number;
98
100
  riskAdjustedLtv: number;
99
101
  }
100
- export interface Balance {
102
+ export interface ClendAccountBalance {
101
103
  mint: web3.PublicKey;
102
104
  bank: web3.PublicKey;
103
105
  assetBalance: BN;
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-e792f4d",
3
+ "version": "0.2.15-group-refactor1-dev-57892a5",
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
@@ -12,13 +12,14 @@ import {
12
12
  WithdrawLeverageResponse,
13
13
  UserWallet,
14
14
  ClendAccount,
15
- Balance,
15
+ ClendAccountBalance,
16
16
  Bank,
17
17
  GetGroupResponse,
18
18
  ClendAccountEvent,
19
19
  GetUserRequest,
20
20
  ClendAccountTxSummary,
21
21
  UserRequest,
22
+ UserBalance,
22
23
  } from "./types";
23
24
  import encode from "bs58";
24
25
 
@@ -118,131 +119,144 @@ export class Client {
118
119
 
119
120
  const jsonRawResponse: any = JSON.parse(body);
120
121
 
121
- // get tokens still in user wallet
122
- const wallet: UserWallet = {
123
- usdcBalance: new BN(jsonRawResponse.wallet.usdcBalance, "hex"),
124
- usdcBalanceUi: Number(jsonRawResponse.wallet.usdcBalanceUi),
125
- jlpBalance: new BN(jsonRawResponse.wallet.jlpBalance, "hex"),
126
- jlpBalanceUi: Number(jsonRawResponse.wallet.jlpBalanceUi),
127
- solBalance: new BN(jsonRawResponse.wallet.solBalance, "hex"),
128
- solBalanceUi: Number(jsonRawResponse.wallet.solBalanceUi),
129
- };
130
-
131
- // if no clend account, return undefined for clend
132
- if (!jsonRawResponse.clendAccount) {
133
- return {
134
- wallet,
135
- clendAccount: undefined,
136
- summary: [],
137
- };
138
- }
139
-
140
- // parse lending account balances
141
- const balances: Balance[] = [];
142
- for (const b of jsonRawResponse.clendAccount.balances) {
143
- balances.push({
122
+ // parse balances
123
+ const walletBalances: UserBalance[] = [];
124
+ for (const b of jsonRawResponse.wallet.balances) {
125
+ walletBalances.push({
144
126
  mint: new web3.PublicKey(b.mint),
145
- bank: new web3.PublicKey(b.bank),
146
- assetBalance: new BN(b.assetBalance, "hex"),
147
- assetBalanceUi: Number(b.assetBalanceUi),
148
- assetValue: Number(b.assetValue),
149
- liabilityBalance: new BN(b.liabilityBalance, "hex"),
150
- liabilityBalanceUi: Number(b.liabilityBalanceUi),
151
- liabilityValue: Number(b.liabilityValue),
152
- price: Number(b.price),
127
+ balance: new BN(b.balance, "hex"),
128
+ balanceUi: Number(b.balanceUi),
153
129
  });
154
130
  }
155
131
 
156
- // create clend account
157
- const clendAccount: ClendAccount = {
158
- balances,
159
- netValue: Number(jsonRawResponse.clendAccount.netValue),
160
- netApy: Number(jsonRawResponse.clendAccount.netApy),
161
- pnl: Number(jsonRawResponse.clendAccount.pnl),
162
- totalAssetValue: Number(jsonRawResponse.clendAccount.totalAssetValue),
163
- totalLiabilityValue: Number(
164
- jsonRawResponse.clendAccount.totalLiabilityValue,
165
- ),
166
- healthFactorNotional: Number(
167
- jsonRawResponse.clendAccount.healthFactorNotional,
168
- ),
169
- healthFactorRiskAdjusted: Number(
170
- jsonRawResponse.clendAccount.healthFactorRiskAdjusted,
171
- ),
172
- notionalLeverage: Number(jsonRawResponse.clendAccount.notionalLeverage),
173
- riskAdjustedLeverage: Number(
174
- jsonRawResponse.clendAccount.riskAdjustedLeverage,
175
- ),
176
- liquidationPrice: Number(jsonRawResponse.clendAccount.liquidationPrice),
177
- liquidationPriceChangePercentage: Number(
178
- jsonRawResponse.clendAccount.liquidationPriceChangePercentage,
179
- ),
180
- notionalLtv: Number(jsonRawResponse.clendAccount.notionalLtv),
181
- riskAdjustedLtv: Number(jsonRawResponse.clendAccount.riskAdjustedLtv),
132
+ // get tokens still in user wallet
133
+ const wallet: UserWallet = {
134
+ balances: walletBalances,
182
135
  };
183
136
 
184
- // get tx summary for each account
185
- const summary: ClendAccountTxSummary[] = [];
186
- for (const s of jsonRawResponse.summary) {
187
- const txSummary: ClendAccountTxSummary = {
188
- txSig: s.txSig,
189
- time: s.time,
190
- clendAccount: new web3.PublicKey(s.clendAccount),
191
- clendAccountAuthority: new web3.PublicKey(s.clendAccountAuthority),
192
- clendGroup: new web3.PublicKey(s.clendGroup),
193
- action: s.action,
194
- input: undefined,
195
- events: [],
196
- };
197
-
198
- // parse inputs if they exist
199
- if (s.input) {
200
- const input: UserRequest = {
201
- apiPath: s.input.apiPath,
202
- selectedTokenMint: s.input.selectedTokenMint
203
- ? new web3.PublicKey(s.input.selectedTokenMint)
204
- : null,
205
- amountUi: s.input.amountUi ? Number(s.input.amountUi) : null,
206
- leverage: s.input.leverage ? Number(s.input.leverage) : null,
207
- slippageBps: s.input.slippageBps ? Number(s.input.slippageBps) : null,
208
- openPosition: s.input.openPosition
209
- ? Boolean(s.input.openPosition)
210
- : null,
211
- closePosition: s.input.closePosition
212
- ? Boolean(s.input.closePosition)
213
- : null,
137
+ // get tx summary for each account and group them
138
+ const summaryByAccount = new Map<string, ClendAccountTxSummary[]>();
139
+ if (request.getClendAccountSummary && jsonRawResponse.summary) {
140
+ for (const s of jsonRawResponse.summary) {
141
+ const accountAddress = new web3.PublicKey(s.clendAccount).toBase58();
142
+ if (!summaryByAccount.has(accountAddress)) {
143
+ summaryByAccount.set(accountAddress, []);
144
+ }
145
+
146
+ const txSummary: ClendAccountTxSummary = {
147
+ txSig: s.txSig,
148
+ time: s.time,
149
+ clendAccount: new web3.PublicKey(s.clendAccount),
150
+ clendAccountAuthority: new web3.PublicKey(s.clendAccountAuthority),
151
+ clendGroup: new web3.PublicKey(s.clendGroup),
152
+ action: s.action,
153
+ input: undefined,
154
+ events: [],
214
155
  };
215
- txSummary.input = input;
156
+
157
+ // parse inputs if they exist
158
+ if (s.input) {
159
+ const input: UserRequest = {
160
+ apiPath: s.input.apiPath,
161
+ selectedTokenMint: s.input.selectedTokenMint
162
+ ? new web3.PublicKey(s.input.selectedTokenMint)
163
+ : null,
164
+ amountUi: s.input.amountUi ? Number(s.input.amountUi) : null,
165
+ leverage: s.input.leverage ? Number(s.input.leverage) : null,
166
+ slippageBps: s.input.slippageBps
167
+ ? Number(s.input.slippageBps)
168
+ : null,
169
+ openPosition: s.input.openPosition
170
+ ? Boolean(s.input.openPosition)
171
+ : null,
172
+ closePosition: s.input.closePosition
173
+ ? Boolean(s.input.closePosition)
174
+ : null,
175
+ };
176
+ txSummary.input = input;
177
+ }
178
+
179
+ // get events for each summary
180
+ for (const event of s.events) {
181
+ let closeBalance: boolean | null = null;
182
+ if (event.closeBalance !== null) {
183
+ closeBalance = Boolean(event.closeBalance);
184
+ }
185
+
186
+ // parse amount
187
+ const clendAccountEvent: ClendAccountEvent = {
188
+ eventIndex: event.eventIndex,
189
+ eventName: event.eventName,
190
+ bank: event.bank ? new web3.PublicKey(event.bank) : null,
191
+ mint: event.mint ? new web3.PublicKey(event.mint) : null,
192
+ amount: event.amount ? new BN(event.amount, "hex") : null,
193
+ amountUi: event.amountUi ? Number(event.amountUi) : null,
194
+ value: event.value ? Number(event.value) : null,
195
+ price: event.price ? Number(event.price) : null,
196
+ closeBalance,
197
+ };
198
+ txSummary.events.push(clendAccountEvent);
199
+ }
200
+
201
+ summaryByAccount.get(accountAddress)!.push(txSummary);
216
202
  }
203
+ }
217
204
 
218
- // get events for each summary
219
- for (const event of s.events) {
220
- let closeBalance: boolean | null = null;
221
- if (event.closeBalance !== null) {
222
- closeBalance = Boolean(event.closeBalance);
205
+ // if no clend account, return undefined for clend
206
+ const clendAccounts: {
207
+ clendAccount: ClendAccount;
208
+ summary: ClendAccountTxSummary[];
209
+ }[] = [];
210
+ if (jsonRawResponse.clendAccounts) {
211
+ for (const [address, ca] of Object.entries(
212
+ jsonRawResponse.clendAccounts,
213
+ )) {
214
+ // parse lending account balances
215
+ const clendAccountBalances: ClendAccountBalance[] = [];
216
+ for (const b of (ca as any).balances) {
217
+ clendAccountBalances.push({
218
+ mint: new web3.PublicKey(b.mint),
219
+ bank: new web3.PublicKey(b.bank),
220
+ assetBalance: new BN(b.assetBalance, "hex"),
221
+ assetBalanceUi: Number(b.assetBalanceUi),
222
+ assetValue: Number(b.assetValue),
223
+ liabilityBalance: new BN(b.liabilityBalance, "hex"),
224
+ liabilityBalanceUi: Number(b.liabilityBalanceUi),
225
+ liabilityValue: Number(b.liabilityValue),
226
+ price: Number(b.price),
227
+ });
223
228
  }
224
229
 
225
- // parse amount
226
- const clendAccountEvent: ClendAccountEvent = {
227
- eventIndex: event.eventIndex,
228
- eventName: event.eventName,
229
- bank: event.bank ? new web3.PublicKey(event.bank) : null,
230
- mint: event.mint ? new web3.PublicKey(event.mint) : null,
231
- amount: event.amount ? new BN(event.amount, "hex") : null,
232
- amountUi: event.amountUi ? Number(event.amountUi) : null,
233
- value: event.value ? Number(event.value) : null,
234
- price: event.price ? Number(event.price) : null,
235
- closeBalance,
230
+ // create clend account
231
+ const clendAccount: ClendAccount = {
232
+ balances: clendAccountBalances,
233
+ netValue: Number((ca as any).netValue),
234
+ netApy: Number((ca as any).netApy),
235
+ pnl: Number((ca as any).pnl),
236
+ totalAssetValue: Number((ca as any).totalAssetValue),
237
+ totalLiabilityValue: Number((ca as any).totalLiabilityValue),
238
+ healthFactorNotional: Number((ca as any).healthFactorNotional),
239
+ healthFactorRiskAdjusted: Number(
240
+ (ca as any).healthFactorRiskAdjusted,
241
+ ),
242
+ notionalLeverage: Number((ca as any).notionalLeverage),
243
+ riskAdjustedLeverage: Number((ca as any).riskAdjustedLeverage),
244
+ liquidationPrice: Number((ca as any).liquidationPrice),
245
+ liquidationPriceChangePercentage: Number(
246
+ (ca as any).liquidationPriceChangePercentage,
247
+ ),
248
+ notionalLtv: Number((ca as any).notionalLtv),
249
+ riskAdjustedLtv: Number((ca as any).riskAdjustedLtv),
236
250
  };
237
- txSummary.events.push(clendAccountEvent);
251
+
252
+ const summary = summaryByAccount.get(address) || [];
253
+ clendAccounts.push({ clendAccount, summary });
238
254
  }
239
- summary.push(txSummary);
240
255
  }
241
256
 
242
257
  return {
243
258
  wallet,
244
- clendAccount,
245
- summary,
259
+ clendAccounts,
246
260
  };
247
261
  }
248
262
 
package/src/types.ts CHANGED
@@ -81,21 +81,24 @@ export interface GetUserRequest {
81
81
 
82
82
  export interface GetUserResponse {
83
83
  wallet: UserWallet;
84
- clendAccount: ClendAccount | undefined;
85
- summary: ClendAccountTxSummary[];
84
+ clendAccounts: {
85
+ clendAccount: ClendAccount;
86
+ summary: ClendAccountTxSummary[];
87
+ }[];
86
88
  }
87
89
 
88
90
  export interface UserWallet {
89
- usdcBalance: BN;
90
- usdcBalanceUi: number;
91
- jlpBalance: BN;
92
- jlpBalanceUi: number;
93
- solBalance: BN;
94
- solBalanceUi: number;
91
+ balances: UserBalance[];
92
+ }
93
+
94
+ export interface UserBalance {
95
+ mint: web3.PublicKey;
96
+ balance: BN;
97
+ balanceUi: number;
95
98
  }
96
99
 
97
100
  export interface ClendAccount {
98
- balances: Balance[];
101
+ balances: ClendAccountBalance[];
99
102
  netValue: number;
100
103
  netApy: number;
101
104
  pnl: number;
@@ -111,7 +114,7 @@ export interface ClendAccount {
111
114
  riskAdjustedLtv: number;
112
115
  }
113
116
 
114
- export interface Balance {
117
+ export interface ClendAccountBalance {
115
118
  mint: web3.PublicKey;
116
119
  bank: web3.PublicKey;
117
120
  assetBalance: BN;