@carrot-protocol/boost-http-client 0.2.0 → 0.2.1-data-fixes-dev-ec9782e
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.d.ts +4 -4
- package/dist/index.js +63 -43
- package/dist/types.d.ts +17 -8
- package/makefile +2 -0
- package/package.json +3 -2
- package/src/index.ts +85 -21
- package/src/types.ts +18 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnchorProvider, web3 } from "@coral-xyz/anchor";
|
|
2
|
-
import {
|
|
2
|
+
import { GetBankResponse, GetUserResponse, GetGroupResponse } from "./types";
|
|
3
3
|
export * from "./types";
|
|
4
4
|
/**
|
|
5
5
|
* HTTP Client for Carrot Boost API
|
|
@@ -43,17 +43,17 @@ export declare class Client {
|
|
|
43
43
|
* @param request Deposit leverage request parameters
|
|
44
44
|
* @returns Deposit leverage operation result
|
|
45
45
|
*/
|
|
46
|
-
depositLeverage(
|
|
46
|
+
depositLeverage(selectedTokenMint: web3.PublicKey, uiAmount: number, leverage: number, slippageBps: number): Promise<string>;
|
|
47
47
|
/**
|
|
48
48
|
* Adjust the leverage of an existing position
|
|
49
49
|
* @param request Adjust leverage request parameters
|
|
50
50
|
* @returns Adjust leverage operation result
|
|
51
51
|
*/
|
|
52
|
-
adjustLeverage(
|
|
52
|
+
adjustLeverage(leverage: number, slippageBps: number): Promise<any>;
|
|
53
53
|
/**
|
|
54
54
|
* Withdraw from or close a leveraged position
|
|
55
55
|
* @param request Withdraw leverage request parameters
|
|
56
56
|
* @returns Withdraw leverage operation result
|
|
57
57
|
*/
|
|
58
|
-
withdrawLeverage(
|
|
58
|
+
withdrawLeverage(selectedTokenMint: web3.PublicKey, uiAmount: number, slippageBps: number, withdrawAll: boolean): Promise<any>;
|
|
59
59
|
}
|
package/dist/index.js
CHANGED
|
@@ -10,28 +10,6 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
15
|
};
|
|
@@ -40,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
18
|
};
|
|
41
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
20
|
exports.Client = void 0;
|
|
43
|
-
const axios_1 =
|
|
21
|
+
const axios_1 = __importDefault(require("axios"));
|
|
44
22
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
45
23
|
const bs58_1 = __importDefault(require("bs58"));
|
|
46
24
|
// Re-export types
|
|
@@ -121,6 +99,7 @@ class Client {
|
|
|
121
99
|
return {
|
|
122
100
|
wallet,
|
|
123
101
|
clendAccount: undefined,
|
|
102
|
+
events: [],
|
|
124
103
|
};
|
|
125
104
|
}
|
|
126
105
|
// parse lending account balances
|
|
@@ -151,9 +130,33 @@ class Client {
|
|
|
151
130
|
notionalLeverage: Number(jsonRawResponse.clendAccount.notionalLeverage),
|
|
152
131
|
riskAdjustedLeverage: Number(jsonRawResponse.clendAccount.riskAdjustedLeverage),
|
|
153
132
|
};
|
|
133
|
+
// get events for account
|
|
134
|
+
const events = [];
|
|
135
|
+
for (const event of jsonRawResponse.clendAccount.events) {
|
|
136
|
+
let closeBalance = null;
|
|
137
|
+
if (event.closeBalance !== null) {
|
|
138
|
+
closeBalance = Boolean(event.closeBalance);
|
|
139
|
+
}
|
|
140
|
+
const clendAccountEvent = {
|
|
141
|
+
txSig: event.txSig,
|
|
142
|
+
eventIndex: event.eventIndex,
|
|
143
|
+
time: event.time,
|
|
144
|
+
eventName: event.eventName,
|
|
145
|
+
clendAccount: new anchor_1.web3.PublicKey(event.clendAccount),
|
|
146
|
+
signer: event.signer ? new anchor_1.web3.PublicKey(event.signer) : null,
|
|
147
|
+
clendAccountAuthority: new anchor_1.web3.PublicKey(event.clendAccountAuthority),
|
|
148
|
+
clendGroup: new anchor_1.web3.PublicKey(event.clendGroup),
|
|
149
|
+
bank: event.bank ? new anchor_1.web3.PublicKey(event.bank) : null,
|
|
150
|
+
mint: event.mint ? new anchor_1.web3.PublicKey(event.mint) : null,
|
|
151
|
+
amount: event.amount ? new anchor_1.BN(event.amount, "hex") : null,
|
|
152
|
+
closeBalance,
|
|
153
|
+
};
|
|
154
|
+
events.push(clendAccountEvent);
|
|
155
|
+
}
|
|
154
156
|
return {
|
|
155
157
|
wallet,
|
|
156
158
|
clendAccount,
|
|
159
|
+
events,
|
|
157
160
|
};
|
|
158
161
|
}
|
|
159
162
|
/**
|
|
@@ -193,8 +196,15 @@ class Client {
|
|
|
193
196
|
* @param request Deposit leverage request parameters
|
|
194
197
|
* @returns Deposit leverage operation result
|
|
195
198
|
*/
|
|
196
|
-
async depositLeverage(
|
|
197
|
-
const
|
|
199
|
+
async depositLeverage(selectedTokenMint, uiAmount, leverage, slippageBps) {
|
|
200
|
+
const req = {
|
|
201
|
+
owner: this.address(),
|
|
202
|
+
selectedTokenMint,
|
|
203
|
+
depositAmountUi: uiAmount,
|
|
204
|
+
leverage,
|
|
205
|
+
slippageBps,
|
|
206
|
+
};
|
|
207
|
+
const body = await handleApiCall(() => this.http.post("leverage/deposit", JSON.stringify(req)));
|
|
198
208
|
const depositLeverageResponse = JSON.parse(body);
|
|
199
209
|
const txSig = await this.send(depositLeverageResponse.unsignedBase64Tx);
|
|
200
210
|
return txSig;
|
|
@@ -204,8 +214,13 @@ class Client {
|
|
|
204
214
|
* @param request Adjust leverage request parameters
|
|
205
215
|
* @returns Adjust leverage operation result
|
|
206
216
|
*/
|
|
207
|
-
async adjustLeverage(
|
|
208
|
-
const
|
|
217
|
+
async adjustLeverage(leverage, slippageBps) {
|
|
218
|
+
const req = {
|
|
219
|
+
owner: this.address(),
|
|
220
|
+
leverage,
|
|
221
|
+
slippageBps,
|
|
222
|
+
};
|
|
223
|
+
const body = await handleApiCall(() => this.http.post("leverage/adjust", JSON.stringify(req)));
|
|
209
224
|
const adjustLeverageResponse = JSON.parse(body);
|
|
210
225
|
const txSig = await this.send(adjustLeverageResponse.unsignedBase64Tx);
|
|
211
226
|
return txSig;
|
|
@@ -215,8 +230,15 @@ class Client {
|
|
|
215
230
|
* @param request Withdraw leverage request parameters
|
|
216
231
|
* @returns Withdraw leverage operation result
|
|
217
232
|
*/
|
|
218
|
-
async withdrawLeverage(
|
|
219
|
-
const
|
|
233
|
+
async withdrawLeverage(selectedTokenMint, uiAmount, slippageBps, withdrawAll) {
|
|
234
|
+
const req = {
|
|
235
|
+
owner: this.address(),
|
|
236
|
+
selectedTokenMint,
|
|
237
|
+
withdrawAmountUi: uiAmount,
|
|
238
|
+
slippageBps,
|
|
239
|
+
withdrawAll,
|
|
240
|
+
};
|
|
241
|
+
const body = await handleApiCall(() => this.http.post("leverage/withdraw", JSON.stringify(req)));
|
|
220
242
|
const withdrawLeverageResponse = JSON.parse(body);
|
|
221
243
|
const txSig = await this.send(withdrawLeverageResponse.unsignedBase64Tx);
|
|
222
244
|
return txSig;
|
|
@@ -232,23 +254,21 @@ function handleStatusCode(statusCode) {
|
|
|
232
254
|
}
|
|
233
255
|
}
|
|
234
256
|
// Helper function to handle API calls
|
|
235
|
-
async function handleApiCall(
|
|
257
|
+
async function handleApiCall(call) {
|
|
236
258
|
try {
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
return JSON.stringify(response.data);
|
|
259
|
+
const { data } = await call();
|
|
260
|
+
return JSON.stringify(data);
|
|
240
261
|
}
|
|
241
|
-
catch (
|
|
242
|
-
if (
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
throw new Error(JSON.stringify(simplifiedError));
|
|
262
|
+
catch (e) {
|
|
263
|
+
if (axios_1.default.isAxiosError(e)) {
|
|
264
|
+
const res = e.response;
|
|
265
|
+
if (res && typeof res.data === "object") {
|
|
266
|
+
const payload = res.data;
|
|
267
|
+
throw new Error(`${payload.error}${payload.details ? ` ${payload.details}` : ""}`);
|
|
268
|
+
}
|
|
269
|
+
throw new Error(`${e.message}`);
|
|
250
270
|
}
|
|
251
|
-
throw
|
|
271
|
+
throw e;
|
|
252
272
|
}
|
|
253
273
|
}
|
|
254
274
|
function getDummyProvider() {
|
package/dist/types.d.ts
CHANGED
|
@@ -2,19 +2,13 @@ import { BN, web3 } from "@coral-xyz/anchor";
|
|
|
2
2
|
export interface SendRequest {
|
|
3
3
|
txns: string[];
|
|
4
4
|
}
|
|
5
|
-
export interface CreateObligationRequest {
|
|
6
|
-
owner: web3.PublicKey;
|
|
7
|
-
}
|
|
8
|
-
export interface CreateObligationResponse {
|
|
9
|
-
unsignedBase64Tx: string;
|
|
10
|
-
}
|
|
11
5
|
/**
|
|
12
6
|
* Request to deposit collateral and create a leveraged position
|
|
13
7
|
*/
|
|
14
8
|
export interface DepositLeverageRequest {
|
|
15
9
|
owner: web3.PublicKey;
|
|
16
10
|
selectedTokenMint: web3.PublicKey;
|
|
17
|
-
|
|
11
|
+
depositAmountUi: number;
|
|
18
12
|
leverage: number;
|
|
19
13
|
slippageBps: number;
|
|
20
14
|
}
|
|
@@ -44,7 +38,7 @@ export interface AdjustLeverageResponse {
|
|
|
44
38
|
export interface WithdrawLeverageRequest {
|
|
45
39
|
owner: web3.PublicKey;
|
|
46
40
|
selectedTokenMint: web3.PublicKey;
|
|
47
|
-
|
|
41
|
+
withdrawAmountUi: number;
|
|
48
42
|
slippageBps: number;
|
|
49
43
|
withdrawAll: boolean;
|
|
50
44
|
}
|
|
@@ -60,6 +54,7 @@ export interface GetGroupResponse {
|
|
|
60
54
|
export interface GetUserResponse {
|
|
61
55
|
wallet: UserWallet;
|
|
62
56
|
clendAccount: ClendAccount | undefined;
|
|
57
|
+
events: ClendAccountEvent[];
|
|
63
58
|
}
|
|
64
59
|
export interface UserWallet {
|
|
65
60
|
usdcBalance: BN;
|
|
@@ -108,3 +103,17 @@ export interface Bank {
|
|
|
108
103
|
liabilityAmountUi: number;
|
|
109
104
|
price: number;
|
|
110
105
|
}
|
|
106
|
+
export interface ClendAccountEvent {
|
|
107
|
+
txSig: string;
|
|
108
|
+
eventIndex: number;
|
|
109
|
+
time: Date;
|
|
110
|
+
eventName: string;
|
|
111
|
+
clendAccount: web3.PublicKey;
|
|
112
|
+
signer: web3.PublicKey | null;
|
|
113
|
+
clendAccountAuthority: web3.PublicKey;
|
|
114
|
+
clendGroup: web3.PublicKey;
|
|
115
|
+
bank: web3.PublicKey | null;
|
|
116
|
+
mint: web3.PublicKey | null;
|
|
117
|
+
amount: BN | null;
|
|
118
|
+
closeBalance: boolean | null;
|
|
119
|
+
}
|
package/makefile
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carrot-protocol/boost-http-client",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1-data-fixes-dev-ec9782e",
|
|
4
4
|
"description": "HTTP client for Carrot Boost API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"build": "npm run clean && npm i && tsc && npm pack",
|
|
10
10
|
"build:dirty": "npm i && tsc && npm pack",
|
|
11
11
|
"fmt:check": "prettier --check src/",
|
|
12
|
-
"fmt": "prettier --write src/"
|
|
12
|
+
"fmt": "prettier --write src/",
|
|
13
|
+
"version-check": "current_version=$(node -p -e \"require('./package.json').version\") && if npm view @carrot-protocol/boost-http-client@$current_version > /dev/null 2>&1; then echo \"Version $current_version already exists. Please bump it in package.json\"; exit 1; fi"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
15
16
|
"@coral-xyz/anchor": "^0.29.0",
|
package/src/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
Balance,
|
|
16
16
|
Bank,
|
|
17
17
|
GetGroupResponse,
|
|
18
|
+
ClendAccountEvent,
|
|
18
19
|
} from "./types";
|
|
19
20
|
import encode from "bs58";
|
|
20
21
|
|
|
@@ -118,6 +119,7 @@ export class Client {
|
|
|
118
119
|
return {
|
|
119
120
|
wallet,
|
|
120
121
|
clendAccount: undefined,
|
|
122
|
+
events: [],
|
|
121
123
|
};
|
|
122
124
|
}
|
|
123
125
|
|
|
@@ -159,9 +161,35 @@ export class Client {
|
|
|
159
161
|
),
|
|
160
162
|
};
|
|
161
163
|
|
|
164
|
+
// get events for account
|
|
165
|
+
const events: ClendAccountEvent[] = [];
|
|
166
|
+
for (const event of jsonRawResponse.clendAccount.events) {
|
|
167
|
+
let closeBalance: boolean | null = null;
|
|
168
|
+
if (event.closeBalance !== null) {
|
|
169
|
+
closeBalance = Boolean(event.closeBalance);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const clendAccountEvent: ClendAccountEvent = {
|
|
173
|
+
txSig: event.txSig,
|
|
174
|
+
eventIndex: event.eventIndex,
|
|
175
|
+
time: event.time,
|
|
176
|
+
eventName: event.eventName,
|
|
177
|
+
clendAccount: new web3.PublicKey(event.clendAccount),
|
|
178
|
+
signer: event.signer ? new web3.PublicKey(event.signer) : null,
|
|
179
|
+
clendAccountAuthority: new web3.PublicKey(event.clendAccountAuthority),
|
|
180
|
+
clendGroup: new web3.PublicKey(event.clendGroup),
|
|
181
|
+
bank: event.bank ? new web3.PublicKey(event.bank) : null,
|
|
182
|
+
mint: event.mint ? new web3.PublicKey(event.mint) : null,
|
|
183
|
+
amount: event.amount ? new BN(event.amount, "hex") : null,
|
|
184
|
+
closeBalance,
|
|
185
|
+
};
|
|
186
|
+
events.push(clendAccountEvent);
|
|
187
|
+
}
|
|
188
|
+
|
|
162
189
|
return {
|
|
163
190
|
wallet,
|
|
164
191
|
clendAccount,
|
|
192
|
+
events,
|
|
165
193
|
};
|
|
166
194
|
}
|
|
167
195
|
|
|
@@ -215,9 +243,21 @@ export class Client {
|
|
|
215
243
|
* @param request Deposit leverage request parameters
|
|
216
244
|
* @returns Deposit leverage operation result
|
|
217
245
|
*/
|
|
218
|
-
async depositLeverage(
|
|
246
|
+
async depositLeverage(
|
|
247
|
+
selectedTokenMint: web3.PublicKey,
|
|
248
|
+
uiAmount: number,
|
|
249
|
+
leverage: number,
|
|
250
|
+
slippageBps: number,
|
|
251
|
+
): Promise<string> {
|
|
252
|
+
const req: DepositLeverageRequest = {
|
|
253
|
+
owner: this.address(),
|
|
254
|
+
selectedTokenMint,
|
|
255
|
+
depositAmountUi: uiAmount,
|
|
256
|
+
leverage,
|
|
257
|
+
slippageBps,
|
|
258
|
+
};
|
|
219
259
|
const body = await handleApiCall(() =>
|
|
220
|
-
this.http.post("leverage/deposit", JSON.stringify(
|
|
260
|
+
this.http.post("leverage/deposit", JSON.stringify(req)),
|
|
221
261
|
);
|
|
222
262
|
|
|
223
263
|
const depositLeverageResponse: DepositLeverageResponse = JSON.parse(body);
|
|
@@ -232,9 +272,14 @@ export class Client {
|
|
|
232
272
|
* @param request Adjust leverage request parameters
|
|
233
273
|
* @returns Adjust leverage operation result
|
|
234
274
|
*/
|
|
235
|
-
async adjustLeverage(
|
|
275
|
+
async adjustLeverage(leverage: number, slippageBps: number): Promise<any> {
|
|
276
|
+
const req: AdjustLeverageRequest = {
|
|
277
|
+
owner: this.address(),
|
|
278
|
+
leverage,
|
|
279
|
+
slippageBps,
|
|
280
|
+
};
|
|
236
281
|
const body = await handleApiCall(() =>
|
|
237
|
-
this.http.post("leverage/adjust", JSON.stringify(
|
|
282
|
+
this.http.post("leverage/adjust", JSON.stringify(req)),
|
|
238
283
|
);
|
|
239
284
|
|
|
240
285
|
const adjustLeverageResponse: AdjustLeverageResponse = JSON.parse(body);
|
|
@@ -249,9 +294,21 @@ export class Client {
|
|
|
249
294
|
* @param request Withdraw leverage request parameters
|
|
250
295
|
* @returns Withdraw leverage operation result
|
|
251
296
|
*/
|
|
252
|
-
async withdrawLeverage(
|
|
297
|
+
async withdrawLeverage(
|
|
298
|
+
selectedTokenMint: web3.PublicKey,
|
|
299
|
+
uiAmount: number,
|
|
300
|
+
slippageBps: number,
|
|
301
|
+
withdrawAll: boolean,
|
|
302
|
+
): Promise<any> {
|
|
303
|
+
const req: WithdrawLeverageRequest = {
|
|
304
|
+
owner: this.address(),
|
|
305
|
+
selectedTokenMint,
|
|
306
|
+
withdrawAmountUi: uiAmount,
|
|
307
|
+
slippageBps,
|
|
308
|
+
withdrawAll,
|
|
309
|
+
};
|
|
253
310
|
const body = await handleApiCall(() =>
|
|
254
|
-
this.http.post("leverage/withdraw", JSON.stringify(
|
|
311
|
+
this.http.post("leverage/withdraw", JSON.stringify(req)),
|
|
255
312
|
);
|
|
256
313
|
|
|
257
314
|
const withdrawLeverageResponse: WithdrawLeverageResponse = JSON.parse(body);
|
|
@@ -262,6 +319,13 @@ export class Client {
|
|
|
262
319
|
}
|
|
263
320
|
}
|
|
264
321
|
|
|
322
|
+
type ApiErrorPayload = {
|
|
323
|
+
error: string;
|
|
324
|
+
details?: unknown;
|
|
325
|
+
path: string;
|
|
326
|
+
timestamp: string;
|
|
327
|
+
};
|
|
328
|
+
|
|
265
329
|
function handleStatusCode(statusCode: number): void {
|
|
266
330
|
switch (statusCode) {
|
|
267
331
|
case 200:
|
|
@@ -273,23 +337,23 @@ function handleStatusCode(statusCode: number): void {
|
|
|
273
337
|
|
|
274
338
|
// Helper function to handle API calls
|
|
275
339
|
async function handleApiCall<T>(
|
|
276
|
-
|
|
277
|
-
): Promise<
|
|
340
|
+
call: () => Promise<AxiosResponse<T>>,
|
|
341
|
+
): Promise<string> {
|
|
278
342
|
try {
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
throw new Error(
|
|
343
|
+
const { data } = await call();
|
|
344
|
+
return JSON.stringify(data);
|
|
345
|
+
} catch (e) {
|
|
346
|
+
if (axios.isAxiosError(e)) {
|
|
347
|
+
const res = e.response;
|
|
348
|
+
if (res && typeof res.data === "object") {
|
|
349
|
+
const payload = res.data as ApiErrorPayload;
|
|
350
|
+
throw new Error(
|
|
351
|
+
`${payload.error}${payload.details ? ` ${payload.details}` : ""}`,
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
throw new Error(`${e.message}`);
|
|
291
355
|
}
|
|
292
|
-
throw
|
|
356
|
+
throw e;
|
|
293
357
|
}
|
|
294
358
|
}
|
|
295
359
|
|
package/src/types.ts
CHANGED
|
@@ -6,21 +6,13 @@ export interface SendRequest {
|
|
|
6
6
|
txns: string[];
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export interface CreateObligationRequest {
|
|
10
|
-
owner: web3.PublicKey;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface CreateObligationResponse {
|
|
14
|
-
unsignedBase64Tx: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
9
|
/**
|
|
18
10
|
* Request to deposit collateral and create a leveraged position
|
|
19
11
|
*/
|
|
20
12
|
export interface DepositLeverageRequest {
|
|
21
13
|
owner: web3.PublicKey;
|
|
22
14
|
selectedTokenMint: web3.PublicKey;
|
|
23
|
-
|
|
15
|
+
depositAmountUi: number;
|
|
24
16
|
leverage: number;
|
|
25
17
|
slippageBps: number;
|
|
26
18
|
}
|
|
@@ -54,7 +46,7 @@ export interface AdjustLeverageResponse {
|
|
|
54
46
|
export interface WithdrawLeverageRequest {
|
|
55
47
|
owner: web3.PublicKey;
|
|
56
48
|
selectedTokenMint: web3.PublicKey;
|
|
57
|
-
|
|
49
|
+
withdrawAmountUi: number;
|
|
58
50
|
slippageBps: number;
|
|
59
51
|
withdrawAll: boolean;
|
|
60
52
|
}
|
|
@@ -73,6 +65,7 @@ export interface GetGroupResponse {
|
|
|
73
65
|
export interface GetUserResponse {
|
|
74
66
|
wallet: UserWallet;
|
|
75
67
|
clendAccount: ClendAccount | undefined;
|
|
68
|
+
events: ClendAccountEvent[];
|
|
76
69
|
}
|
|
77
70
|
|
|
78
71
|
export interface UserWallet {
|
|
@@ -126,3 +119,18 @@ export interface Bank {
|
|
|
126
119
|
liabilityAmountUi: number;
|
|
127
120
|
price: number;
|
|
128
121
|
}
|
|
122
|
+
|
|
123
|
+
export interface ClendAccountEvent {
|
|
124
|
+
txSig: string;
|
|
125
|
+
eventIndex: number;
|
|
126
|
+
time: Date;
|
|
127
|
+
eventName: string;
|
|
128
|
+
clendAccount: web3.PublicKey;
|
|
129
|
+
signer: web3.PublicKey | null;
|
|
130
|
+
clendAccountAuthority: web3.PublicKey;
|
|
131
|
+
clendGroup: web3.PublicKey;
|
|
132
|
+
bank: web3.PublicKey | null;
|
|
133
|
+
mint: web3.PublicKey | null;
|
|
134
|
+
amount: BN | null;
|
|
135
|
+
closeBalance: boolean | null;
|
|
136
|
+
}
|