@carrot-protocol/boost-http-client 0.2.6 → 0.2.7-actions1-dev-ccd7ce6
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 +37 -24
- package/dist/types.d.ts +10 -1
- package/package.json +1 -1
- package/src/index.ts +44 -25
- package/src/types.ts +11 -1
package/dist/index.js
CHANGED
|
@@ -125,7 +125,7 @@ class Client {
|
|
|
125
125
|
return {
|
|
126
126
|
wallet,
|
|
127
127
|
clendAccount: undefined,
|
|
128
|
-
|
|
128
|
+
summary: [],
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
// parse lending account balances
|
|
@@ -159,34 +159,47 @@ class Client {
|
|
|
159
159
|
liquidationPriceChangePercentage: Number(jsonRawResponse.clendAccount.liquidationPriceChangePercentage),
|
|
160
160
|
ltv: Number(jsonRawResponse.clendAccount.ltv),
|
|
161
161
|
};
|
|
162
|
-
// get
|
|
163
|
-
const
|
|
164
|
-
for (const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
time: event.time,
|
|
174
|
-
eventName: event.eventName,
|
|
175
|
-
clendAccount: new anchor_1.web3.PublicKey(event.clendAccount),
|
|
176
|
-
signer: event.signer ? new anchor_1.web3.PublicKey(event.signer) : null,
|
|
177
|
-
clendAccountAuthority: new anchor_1.web3.PublicKey(event.clendAccountAuthority),
|
|
178
|
-
clendGroup: new anchor_1.web3.PublicKey(event.clendGroup),
|
|
179
|
-
bank: event.bank ? new anchor_1.web3.PublicKey(event.bank) : null,
|
|
180
|
-
mint: event.mint ? new anchor_1.web3.PublicKey(event.mint) : null,
|
|
181
|
-
amount: event.amount ? new anchor_1.BN(event.amount) : null,
|
|
182
|
-
closeBalance,
|
|
162
|
+
// get tx summary for each account
|
|
163
|
+
const summary = [];
|
|
164
|
+
for (const summary of jsonRawResponse.summary) {
|
|
165
|
+
const txSummary = {
|
|
166
|
+
txSig: summary.txSig,
|
|
167
|
+
time: summary.time,
|
|
168
|
+
clendAccount: new anchor_1.web3.PublicKey(summary.clendAccount),
|
|
169
|
+
clendAccountAuthority: new anchor_1.web3.PublicKey(summary.clendAccountAuthority),
|
|
170
|
+
clendGroup: new anchor_1.web3.PublicKey(summary.clendGroup),
|
|
171
|
+
action: summary.action,
|
|
172
|
+
events: [],
|
|
183
173
|
};
|
|
184
|
-
events
|
|
174
|
+
// get events for each summary
|
|
175
|
+
for (const event of summary.events) {
|
|
176
|
+
let closeBalance = null;
|
|
177
|
+
if (event.closeBalance !== null) {
|
|
178
|
+
closeBalance = Boolean(event.closeBalance);
|
|
179
|
+
}
|
|
180
|
+
// parse amount
|
|
181
|
+
const clendAccountEvent = {
|
|
182
|
+
txSig: event.txSig,
|
|
183
|
+
eventIndex: event.eventIndex,
|
|
184
|
+
time: event.time,
|
|
185
|
+
eventName: event.eventName,
|
|
186
|
+
clendAccount: new anchor_1.web3.PublicKey(event.clendAccount),
|
|
187
|
+
signer: event.signer ? new anchor_1.web3.PublicKey(event.signer) : null,
|
|
188
|
+
clendAccountAuthority: new anchor_1.web3.PublicKey(event.clendAccountAuthority),
|
|
189
|
+
clendGroup: new anchor_1.web3.PublicKey(event.clendGroup),
|
|
190
|
+
bank: event.bank ? new anchor_1.web3.PublicKey(event.bank) : null,
|
|
191
|
+
mint: event.mint ? new anchor_1.web3.PublicKey(event.mint) : null,
|
|
192
|
+
amount: event.amount ? new anchor_1.BN(event.amount) : null,
|
|
193
|
+
closeBalance,
|
|
194
|
+
};
|
|
195
|
+
txSummary.events.push(clendAccountEvent);
|
|
196
|
+
}
|
|
197
|
+
summary.push(txSummary);
|
|
185
198
|
}
|
|
186
199
|
return {
|
|
187
200
|
wallet,
|
|
188
201
|
clendAccount,
|
|
189
|
-
|
|
202
|
+
summary,
|
|
190
203
|
};
|
|
191
204
|
}
|
|
192
205
|
/**
|
package/dist/types.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ export interface GetUserRequest {
|
|
|
58
58
|
export interface GetUserResponse {
|
|
59
59
|
wallet: UserWallet;
|
|
60
60
|
clendAccount: ClendAccount | undefined;
|
|
61
|
-
|
|
61
|
+
summary: ClendAccountTxSummary[];
|
|
62
62
|
}
|
|
63
63
|
export interface UserWallet {
|
|
64
64
|
usdcBalance: BN;
|
|
@@ -122,6 +122,15 @@ export interface Bank {
|
|
|
122
122
|
borrowLimit: BN;
|
|
123
123
|
borrowLimitUi: number;
|
|
124
124
|
}
|
|
125
|
+
export interface ClendAccountTxSummary {
|
|
126
|
+
txSig: string;
|
|
127
|
+
time: Date;
|
|
128
|
+
clendAccount: web3.PublicKey;
|
|
129
|
+
clendAccountAuthority: web3.PublicKey;
|
|
130
|
+
clendGroup: web3.PublicKey;
|
|
131
|
+
action: string;
|
|
132
|
+
events: ClendAccountEvent[];
|
|
133
|
+
}
|
|
125
134
|
export interface ClendAccountEvent {
|
|
126
135
|
txSig: string;
|
|
127
136
|
eventIndex: number;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
GetGroupResponse,
|
|
18
18
|
ClendAccountEvent,
|
|
19
19
|
GetUserRequest,
|
|
20
|
+
ClendAccountTxSummary,
|
|
20
21
|
} from "./types";
|
|
21
22
|
import encode from "bs58";
|
|
22
23
|
|
|
@@ -127,7 +128,7 @@ export class Client {
|
|
|
127
128
|
return {
|
|
128
129
|
wallet,
|
|
129
130
|
clendAccount: undefined,
|
|
130
|
-
|
|
131
|
+
summary: [],
|
|
131
132
|
};
|
|
132
133
|
}
|
|
133
134
|
|
|
@@ -174,36 +175,54 @@ export class Client {
|
|
|
174
175
|
ltv: Number(jsonRawResponse.clendAccount.ltv),
|
|
175
176
|
};
|
|
176
177
|
|
|
177
|
-
// get
|
|
178
|
-
const
|
|
179
|
-
for (const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
eventName: event.eventName,
|
|
191
|
-
clendAccount: new web3.PublicKey(event.clendAccount),
|
|
192
|
-
signer: event.signer ? new web3.PublicKey(event.signer) : null,
|
|
193
|
-
clendAccountAuthority: new web3.PublicKey(event.clendAccountAuthority),
|
|
194
|
-
clendGroup: new web3.PublicKey(event.clendGroup),
|
|
195
|
-
bank: event.bank ? new web3.PublicKey(event.bank) : null,
|
|
196
|
-
mint: event.mint ? new web3.PublicKey(event.mint) : null,
|
|
197
|
-
amount: event.amount ? new BN(event.amount) : null,
|
|
198
|
-
closeBalance,
|
|
178
|
+
// get tx summary for each account
|
|
179
|
+
const summary: ClendAccountTxSummary[] = [];
|
|
180
|
+
for (const summary of jsonRawResponse.summary) {
|
|
181
|
+
const txSummary: ClendAccountTxSummary = {
|
|
182
|
+
txSig: summary.txSig,
|
|
183
|
+
time: summary.time,
|
|
184
|
+
clendAccount: new web3.PublicKey(summary.clendAccount),
|
|
185
|
+
clendAccountAuthority: new web3.PublicKey(
|
|
186
|
+
summary.clendAccountAuthority,
|
|
187
|
+
),
|
|
188
|
+
clendGroup: new web3.PublicKey(summary.clendGroup),
|
|
189
|
+
action: summary.action,
|
|
190
|
+
events: [],
|
|
199
191
|
};
|
|
200
|
-
|
|
192
|
+
|
|
193
|
+
// get events for each summary
|
|
194
|
+
for (const event of summary.events) {
|
|
195
|
+
let closeBalance: boolean | null = null;
|
|
196
|
+
if (event.closeBalance !== null) {
|
|
197
|
+
closeBalance = Boolean(event.closeBalance);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// parse amount
|
|
201
|
+
const clendAccountEvent: ClendAccountEvent = {
|
|
202
|
+
txSig: event.txSig,
|
|
203
|
+
eventIndex: event.eventIndex,
|
|
204
|
+
time: event.time,
|
|
205
|
+
eventName: event.eventName,
|
|
206
|
+
clendAccount: new web3.PublicKey(event.clendAccount),
|
|
207
|
+
signer: event.signer ? new web3.PublicKey(event.signer) : null,
|
|
208
|
+
clendAccountAuthority: new web3.PublicKey(
|
|
209
|
+
event.clendAccountAuthority,
|
|
210
|
+
),
|
|
211
|
+
clendGroup: new web3.PublicKey(event.clendGroup),
|
|
212
|
+
bank: event.bank ? new web3.PublicKey(event.bank) : null,
|
|
213
|
+
mint: event.mint ? new web3.PublicKey(event.mint) : null,
|
|
214
|
+
amount: event.amount ? new BN(event.amount) : null,
|
|
215
|
+
closeBalance,
|
|
216
|
+
};
|
|
217
|
+
txSummary.events.push(clendAccountEvent);
|
|
218
|
+
}
|
|
219
|
+
summary.push(txSummary);
|
|
201
220
|
}
|
|
202
221
|
|
|
203
222
|
return {
|
|
204
223
|
wallet,
|
|
205
224
|
clendAccount,
|
|
206
|
-
|
|
225
|
+
summary,
|
|
207
226
|
};
|
|
208
227
|
}
|
|
209
228
|
|
package/src/types.ts
CHANGED
|
@@ -70,7 +70,7 @@ export interface GetUserRequest {
|
|
|
70
70
|
export interface GetUserResponse {
|
|
71
71
|
wallet: UserWallet;
|
|
72
72
|
clendAccount: ClendAccount | undefined;
|
|
73
|
-
|
|
73
|
+
summary: ClendAccountTxSummary[];
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
export interface UserWallet {
|
|
@@ -140,6 +140,16 @@ export interface Bank {
|
|
|
140
140
|
borrowLimitUi: number;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
+
export interface ClendAccountTxSummary {
|
|
144
|
+
txSig: string;
|
|
145
|
+
time: Date;
|
|
146
|
+
clendAccount: web3.PublicKey;
|
|
147
|
+
clendAccountAuthority: web3.PublicKey;
|
|
148
|
+
clendGroup: web3.PublicKey;
|
|
149
|
+
action: string;
|
|
150
|
+
events: ClendAccountEvent[];
|
|
151
|
+
}
|
|
152
|
+
|
|
143
153
|
export interface ClendAccountEvent {
|
|
144
154
|
txSig: string;
|
|
145
155
|
eventIndex: number;
|