@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 +43 -43
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/index.ts +49 -50
- package/src/types.ts +1 -0
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
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
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -206,57 +206,56 @@ export class Client {
|
|
|
206
206
|
clendAccount: ClendAccount;
|
|
207
207
|
summary: ClendAccountTxSummary[];
|
|
208
208
|
}[] = [];
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
)
|
|
213
|
-
// parse
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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 {
|