@carrot-protocol/boost-http-client 0.4.4-handoff-dev-e67b717 → 0.4.4-handoff-dev-9a1c50a
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 +5 -6
- package/dist/index.js +33 -21
- package/dist/types.d.ts +8 -1
- package/package.json +1 -1
- package/src/index.ts +39 -19
- package/src/types.ts +8 -1
package/dist/index.d.ts
CHANGED
|
@@ -54,32 +54,31 @@ export declare class Client extends ApiClient {
|
|
|
54
54
|
* @returns Bank details
|
|
55
55
|
*/
|
|
56
56
|
getBank(bankAddress: web3.PublicKey): Promise<GetBankResponse>;
|
|
57
|
-
deposit(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey | null, inputTokenMint: web3.PublicKey, uiAmount: number): Promise<string>;
|
|
58
|
-
withdraw(clendAccount: web3.PublicKey, outputTokenMint: web3.PublicKey, uiAmount: number, withdrawAll: boolean): Promise<string>;
|
|
57
|
+
deposit(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey | null, inputTokenMint: web3.PublicKey, uiAmount: number, useJito: boolean): Promise<string>;
|
|
58
|
+
withdraw(clendAccount: web3.PublicKey, outputTokenMint: web3.PublicKey, uiAmount: number, withdrawAll: boolean, useJito: boolean): Promise<string>;
|
|
59
59
|
/**
|
|
60
60
|
* Deposit collateral and create a leveraged position
|
|
61
61
|
* @param request Deposit leverage request parameters
|
|
62
62
|
* @returns Deposit leverage operation result
|
|
63
63
|
*/
|
|
64
|
-
depositLeverage(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey | null, inputTokenMint: web3.PublicKey, assetTokenMint: web3.PublicKey, liabilityTokenMint: web3.PublicKey, uiAmount: number, leverage: number, slippageBps: number): Promise<string>;
|
|
64
|
+
depositLeverage(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey | null, inputTokenMint: web3.PublicKey, assetTokenMint: web3.PublicKey, liabilityTokenMint: web3.PublicKey, uiAmount: number, leverage: number, slippageBps: number, useJito: boolean, isHandoff: boolean): Promise<string>;
|
|
65
65
|
/**
|
|
66
66
|
* Adjust the leverage of an existing position
|
|
67
67
|
* @param request Adjust leverage request parameters
|
|
68
68
|
* @returns Adjust leverage operation result
|
|
69
69
|
*/
|
|
70
|
-
adjustLeverage(clendAccount: web3.PublicKey, assetTokenMint: web3.PublicKey, liabilityTokenMint: web3.PublicKey, leverage: number, slippageBps: number): Promise<string>;
|
|
70
|
+
adjustLeverage(clendAccount: web3.PublicKey, assetTokenMint: web3.PublicKey, liabilityTokenMint: web3.PublicKey, leverage: number, slippageBps: number, useJito: boolean): Promise<string>;
|
|
71
71
|
/**
|
|
72
72
|
* Withdraw from or close a leveraged position
|
|
73
73
|
* @param request Withdraw leverage request parameters
|
|
74
74
|
* @returns Withdraw leverage operation result
|
|
75
75
|
*/
|
|
76
|
-
withdrawLeverage(clendAccount: web3.PublicKey, outputTokenMint: web3.PublicKey, assetTokenMint: web3.PublicKey, liabilityTokenMint: web3.PublicKey, uiAmount: number, slippageBps: number, withdrawAll: boolean): Promise<string>;
|
|
76
|
+
withdrawLeverage(clendAccount: web3.PublicKey, outputTokenMint: web3.PublicKey, assetTokenMint: web3.PublicKey, liabilityTokenMint: web3.PublicKey, uiAmount: number, slippageBps: number, withdrawAll: boolean, useJito: boolean): Promise<string>;
|
|
77
77
|
/**
|
|
78
78
|
* Withdraw emissions from a bank
|
|
79
79
|
* @returns Withdraw emissions operation result
|
|
80
80
|
*/
|
|
81
81
|
withdrawEmissions(clendAccount: web3.PublicKey): Promise<string>;
|
|
82
|
-
handoffDepositLeverage(): Promise<string>;
|
|
83
82
|
getPerformanceChartingExtension(clendAccount: web3.PublicKey): Promise<PositionChartingExtension>;
|
|
84
83
|
getGroupChartingExtension(group: web3.PublicKey): Promise<GroupChartingExtension>;
|
|
85
84
|
getWalletChartingExtension(address?: web3.PublicKey): Promise<WalletChartingExtension>;
|
package/dist/index.js
CHANGED
|
@@ -72,30 +72,32 @@ class Client extends api_1.ApiClient {
|
|
|
72
72
|
return this.provider.wallet.publicKey;
|
|
73
73
|
}
|
|
74
74
|
// sign and send tx to api for sending to network
|
|
75
|
-
async send(unsignedBase64Tx, userRequestId, useJito) {
|
|
75
|
+
async send(unsignedBase64Tx, userRequestId, useJito, handoffTxns = []) {
|
|
76
76
|
if (this.dryRun) {
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
console.log("unsignedBase64Tx", unsignedBase64Tx);
|
|
78
|
+
if (handoffTxns.length > 0)
|
|
79
|
+
console.log("handoffTxns", handoffTxns);
|
|
79
80
|
console.log("dry run enabled, exiting before sending tx");
|
|
80
81
|
return "";
|
|
81
82
|
}
|
|
82
|
-
//
|
|
83
|
+
// 1. Sign the primary transaction (User Transaction)
|
|
83
84
|
const txBytes = Buffer.from(unsignedBase64Tx, "base64");
|
|
84
85
|
const tx = anchor_1.web3.VersionedTransaction.deserialize(new Uint8Array(txBytes));
|
|
85
|
-
// sign tx
|
|
86
86
|
const signedTx = await this.provider.wallet.signTransaction(tx);
|
|
87
|
+
// Grab signature for return value
|
|
87
88
|
const txSig = signedTx.signatures[0];
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
//
|
|
89
|
+
const encodedSignedUserTx = Buffer.from(signedTx.serialize()).toString("base64");
|
|
90
|
+
// 2. Construct the bundle
|
|
91
|
+
// The bundle consists of [UserSignedTx, ...PreSignedHandoffTxs]
|
|
92
|
+
const allTxns = [encodedSignedUserTx, ...handoffTxns];
|
|
93
|
+
// 3. Send to API
|
|
91
94
|
const sendRequest = {
|
|
92
95
|
userRequestId,
|
|
93
|
-
txns:
|
|
96
|
+
txns: allTxns,
|
|
94
97
|
useJito,
|
|
95
98
|
};
|
|
96
|
-
// send to api
|
|
97
99
|
await this.handleApiCall(() => this.http.post(`send`, sendRequest));
|
|
98
|
-
//
|
|
100
|
+
// Return signature of the user's transaction
|
|
99
101
|
return bs58_1.default.encode(txSig);
|
|
100
102
|
}
|
|
101
103
|
/**
|
|
@@ -327,25 +329,27 @@ class Client extends api_1.ApiClient {
|
|
|
327
329
|
};
|
|
328
330
|
return response;
|
|
329
331
|
}
|
|
330
|
-
async deposit(clendGroup, clendAccount, inputTokenMint, uiAmount) {
|
|
332
|
+
async deposit(clendGroup, clendAccount, inputTokenMint, uiAmount, useJito) {
|
|
331
333
|
const req = {
|
|
332
334
|
owner: this.address(),
|
|
333
335
|
clendGroup,
|
|
334
336
|
clendAccount,
|
|
335
337
|
inputTokenMint,
|
|
336
338
|
depositAmountUi: uiAmount,
|
|
339
|
+
useJito,
|
|
337
340
|
};
|
|
338
341
|
const body = await this.handleApiCall(() => this.http.post("deposit", JSON.stringify(req)));
|
|
339
342
|
const depositResponse = JSON.parse(body);
|
|
340
343
|
const txSig = await this.send(depositResponse.unsignedBase64Tx, depositResponse.userRequestId, false);
|
|
341
344
|
return txSig;
|
|
342
345
|
}
|
|
343
|
-
async withdraw(clendAccount, outputTokenMint, uiAmount, withdrawAll) {
|
|
346
|
+
async withdraw(clendAccount, outputTokenMint, uiAmount, withdrawAll, useJito) {
|
|
344
347
|
const req = {
|
|
345
348
|
clendAccount,
|
|
346
349
|
outputTokenMint,
|
|
347
350
|
withdrawAmountUi: uiAmount,
|
|
348
351
|
withdrawAll,
|
|
352
|
+
useJito,
|
|
349
353
|
};
|
|
350
354
|
const body = await this.handleApiCall(() => this.http.post("withdraw", JSON.stringify(req)));
|
|
351
355
|
const withdrawResponse = JSON.parse(body);
|
|
@@ -357,7 +361,7 @@ class Client extends api_1.ApiClient {
|
|
|
357
361
|
* @param request Deposit leverage request parameters
|
|
358
362
|
* @returns Deposit leverage operation result
|
|
359
363
|
*/
|
|
360
|
-
async depositLeverage(clendGroup, clendAccount, inputTokenMint, assetTokenMint, liabilityTokenMint, uiAmount, leverage, slippageBps) {
|
|
364
|
+
async depositLeverage(clendGroup, clendAccount, inputTokenMint, assetTokenMint, liabilityTokenMint, uiAmount, leverage, slippageBps, useJito, isHandoff) {
|
|
361
365
|
const req = {
|
|
362
366
|
owner: this.address(),
|
|
363
367
|
clendGroup,
|
|
@@ -368,10 +372,18 @@ class Client extends api_1.ApiClient {
|
|
|
368
372
|
depositAmountUi: uiAmount,
|
|
369
373
|
leverage,
|
|
370
374
|
slippageBps,
|
|
375
|
+
useJito,
|
|
376
|
+
isHandoff,
|
|
371
377
|
};
|
|
372
378
|
const body = await this.handleApiCall(() => this.http.post("leverage/deposit", JSON.stringify(req)));
|
|
373
379
|
const depositLeverageResponse = JSON.parse(body);
|
|
374
|
-
|
|
380
|
+
let handoffTxns = [];
|
|
381
|
+
if (depositLeverageResponse.txns.length > 1) {
|
|
382
|
+
handoffTxns = depositLeverageResponse.txns.slice(1);
|
|
383
|
+
}
|
|
384
|
+
const userTx = depositLeverageResponse.txns[0];
|
|
385
|
+
const txSig = await this.send(userTx, depositLeverageResponse.userRequestId, req.useJito, handoffTxns);
|
|
386
|
+
return txSig;
|
|
375
387
|
return txSig;
|
|
376
388
|
}
|
|
377
389
|
/**
|
|
@@ -379,13 +391,14 @@ class Client extends api_1.ApiClient {
|
|
|
379
391
|
* @param request Adjust leverage request parameters
|
|
380
392
|
* @returns Adjust leverage operation result
|
|
381
393
|
*/
|
|
382
|
-
async adjustLeverage(clendAccount, assetTokenMint, liabilityTokenMint, leverage, slippageBps) {
|
|
394
|
+
async adjustLeverage(clendAccount, assetTokenMint, liabilityTokenMint, leverage, slippageBps, useJito) {
|
|
383
395
|
const req = {
|
|
384
396
|
clendAccount,
|
|
385
397
|
assetTokenMint,
|
|
386
398
|
liabilityTokenMint,
|
|
387
399
|
leverage,
|
|
388
400
|
slippageBps,
|
|
401
|
+
useJito,
|
|
389
402
|
};
|
|
390
403
|
const body = await this.handleApiCall(() => this.http.post("leverage/adjust", JSON.stringify(req)));
|
|
391
404
|
const adjustLeverageResponse = JSON.parse(body);
|
|
@@ -397,7 +410,7 @@ class Client extends api_1.ApiClient {
|
|
|
397
410
|
* @param request Withdraw leverage request parameters
|
|
398
411
|
* @returns Withdraw leverage operation result
|
|
399
412
|
*/
|
|
400
|
-
async withdrawLeverage(clendAccount, outputTokenMint, assetTokenMint, liabilityTokenMint, uiAmount, slippageBps, withdrawAll) {
|
|
413
|
+
async withdrawLeverage(clendAccount, outputTokenMint, assetTokenMint, liabilityTokenMint, uiAmount, slippageBps, withdrawAll, useJito) {
|
|
401
414
|
const req = {
|
|
402
415
|
clendAccount,
|
|
403
416
|
outputTokenMint,
|
|
@@ -406,10 +419,11 @@ class Client extends api_1.ApiClient {
|
|
|
406
419
|
withdrawAmountUi: uiAmount,
|
|
407
420
|
slippageBps,
|
|
408
421
|
withdrawAll,
|
|
422
|
+
useJito,
|
|
409
423
|
};
|
|
410
424
|
const body = await this.handleApiCall(() => this.http.post("leverage/withdraw", JSON.stringify(req)));
|
|
411
425
|
const withdrawLeverageResponse = JSON.parse(body);
|
|
412
|
-
const txSig = await this.send(withdrawLeverageResponse.unsignedBase64Tx, withdrawLeverageResponse.userRequestId,
|
|
426
|
+
const txSig = await this.send(withdrawLeverageResponse.unsignedBase64Tx, withdrawLeverageResponse.userRequestId, true);
|
|
413
427
|
return txSig;
|
|
414
428
|
}
|
|
415
429
|
/**
|
|
@@ -419,15 +433,13 @@ class Client extends api_1.ApiClient {
|
|
|
419
433
|
async withdrawEmissions(clendAccount) {
|
|
420
434
|
const req = {
|
|
421
435
|
clendAccount,
|
|
436
|
+
useJito: false,
|
|
422
437
|
};
|
|
423
438
|
const body = await this.handleApiCall(() => this.http.post("emissions/withdraw", JSON.stringify(req)));
|
|
424
439
|
const withdrawEmissionsResponse = JSON.parse(body);
|
|
425
440
|
const txSig = await this.send(withdrawEmissionsResponse.unsignedBase64Tx, withdrawEmissionsResponse.userRequestId, false);
|
|
426
441
|
return txSig;
|
|
427
442
|
}
|
|
428
|
-
async handoffDepositLeverage() {
|
|
429
|
-
return "";
|
|
430
|
-
}
|
|
431
443
|
async getPerformanceChartingExtension(clendAccount) {
|
|
432
444
|
return new position_1.PositionChartingExtension(this.baseUrl, clendAccount);
|
|
433
445
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export interface DepositRequest {
|
|
|
17
17
|
clendAccount: web3.PublicKey | null;
|
|
18
18
|
inputTokenMint: web3.PublicKey;
|
|
19
19
|
depositAmountUi: number;
|
|
20
|
+
useJito: boolean;
|
|
20
21
|
}
|
|
21
22
|
export interface DepositResponse {
|
|
22
23
|
userRequestId: string;
|
|
@@ -30,6 +31,7 @@ export interface WithdrawRequest {
|
|
|
30
31
|
outputTokenMint: web3.PublicKey;
|
|
31
32
|
withdrawAmountUi: number;
|
|
32
33
|
withdrawAll: boolean;
|
|
34
|
+
useJito: boolean;
|
|
33
35
|
}
|
|
34
36
|
export interface WithdrawResponse {
|
|
35
37
|
userRequestId: string;
|
|
@@ -48,13 +50,15 @@ export interface DepositLeverageRequest {
|
|
|
48
50
|
depositAmountUi: number;
|
|
49
51
|
leverage: number;
|
|
50
52
|
slippageBps: number;
|
|
53
|
+
useJito: boolean;
|
|
54
|
+
isHandoff: boolean;
|
|
51
55
|
}
|
|
52
56
|
/**
|
|
53
57
|
* Response for deposit leverage operation
|
|
54
58
|
*/
|
|
55
59
|
export interface DepositLeverageResponse {
|
|
56
60
|
userRequestId: string;
|
|
57
|
-
|
|
61
|
+
txns: string[];
|
|
58
62
|
}
|
|
59
63
|
/**
|
|
60
64
|
* Request to adjust the leverage of an existing position
|
|
@@ -65,6 +69,7 @@ export interface AdjustLeverageRequest {
|
|
|
65
69
|
liabilityTokenMint: web3.PublicKey;
|
|
66
70
|
leverage: number;
|
|
67
71
|
slippageBps: number;
|
|
72
|
+
useJito: boolean;
|
|
68
73
|
}
|
|
69
74
|
/**
|
|
70
75
|
* Response for adjust leverage operation
|
|
@@ -84,6 +89,7 @@ export interface WithdrawLeverageRequest {
|
|
|
84
89
|
withdrawAmountUi: number;
|
|
85
90
|
slippageBps: number;
|
|
86
91
|
withdrawAll: boolean;
|
|
92
|
+
useJito: boolean;
|
|
87
93
|
}
|
|
88
94
|
/**
|
|
89
95
|
* Response for withdraw leverage operation
|
|
@@ -97,6 +103,7 @@ export interface WithdrawLeverageResponse {
|
|
|
97
103
|
*/
|
|
98
104
|
export interface WithdrawEmissionsRequest {
|
|
99
105
|
clendAccount: web3.PublicKey;
|
|
106
|
+
useJito: boolean;
|
|
100
107
|
}
|
|
101
108
|
/**
|
|
102
109
|
* Response for withdraw emissions operation
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -76,38 +76,40 @@ export class Client extends ApiClient {
|
|
|
76
76
|
unsignedBase64Tx: string,
|
|
77
77
|
userRequestId: string,
|
|
78
78
|
useJito: boolean,
|
|
79
|
+
handoffTxns: string[] = [], // Optional extra signed txs
|
|
79
80
|
): Promise<string> {
|
|
80
81
|
if (this.dryRun) {
|
|
81
|
-
|
|
82
|
-
console.log("
|
|
82
|
+
console.log("unsignedBase64Tx", unsignedBase64Tx);
|
|
83
|
+
if (handoffTxns.length > 0) console.log("handoffTxns", handoffTxns);
|
|
83
84
|
console.log("dry run enabled, exiting before sending tx");
|
|
84
85
|
return "";
|
|
85
86
|
}
|
|
86
87
|
|
|
87
|
-
//
|
|
88
|
+
// 1. Sign the primary transaction (User Transaction)
|
|
88
89
|
const txBytes = Buffer.from(unsignedBase64Tx, "base64");
|
|
89
90
|
const tx = web3.VersionedTransaction.deserialize(new Uint8Array(txBytes));
|
|
90
|
-
|
|
91
|
-
// sign tx
|
|
92
91
|
const signedTx = await this.provider!.wallet.signTransaction(tx);
|
|
93
|
-
const txSig = signedTx.signatures[0];
|
|
94
92
|
|
|
95
|
-
//
|
|
96
|
-
const
|
|
93
|
+
// Grab signature for return value
|
|
94
|
+
const txSig = signedTx.signatures[0];
|
|
95
|
+
const encodedSignedUserTx = Buffer.from(signedTx.serialize()).toString(
|
|
97
96
|
"base64",
|
|
98
97
|
);
|
|
99
98
|
|
|
100
|
-
//
|
|
99
|
+
// 2. Construct the bundle
|
|
100
|
+
// The bundle consists of [UserSignedTx, ...PreSignedHandoffTxs]
|
|
101
|
+
const allTxns = [encodedSignedUserTx, ...handoffTxns];
|
|
102
|
+
|
|
103
|
+
// 3. Send to API
|
|
101
104
|
const sendRequest: SendRequest = {
|
|
102
105
|
userRequestId,
|
|
103
|
-
txns:
|
|
106
|
+
txns: allTxns,
|
|
104
107
|
useJito,
|
|
105
108
|
};
|
|
106
109
|
|
|
107
|
-
// send to api
|
|
108
110
|
await this.handleApiCall(() => this.http.post(`send`, sendRequest));
|
|
109
111
|
|
|
110
|
-
//
|
|
112
|
+
// Return signature of the user's transaction
|
|
111
113
|
return encode.encode(txSig);
|
|
112
114
|
}
|
|
113
115
|
|
|
@@ -413,6 +415,7 @@ export class Client extends ApiClient {
|
|
|
413
415
|
clendAccount: web3.PublicKey | null,
|
|
414
416
|
inputTokenMint: web3.PublicKey,
|
|
415
417
|
uiAmount: number,
|
|
418
|
+
useJito: boolean,
|
|
416
419
|
): Promise<string> {
|
|
417
420
|
const req: DepositRequest = {
|
|
418
421
|
owner: this.address(),
|
|
@@ -420,6 +423,7 @@ export class Client extends ApiClient {
|
|
|
420
423
|
clendAccount,
|
|
421
424
|
inputTokenMint,
|
|
422
425
|
depositAmountUi: uiAmount,
|
|
426
|
+
useJito,
|
|
423
427
|
};
|
|
424
428
|
|
|
425
429
|
const body = await this.handleApiCall(() =>
|
|
@@ -442,12 +446,14 @@ export class Client extends ApiClient {
|
|
|
442
446
|
outputTokenMint: web3.PublicKey,
|
|
443
447
|
uiAmount: number,
|
|
444
448
|
withdrawAll: boolean,
|
|
449
|
+
useJito: boolean,
|
|
445
450
|
): Promise<string> {
|
|
446
451
|
const req: WithdrawRequest = {
|
|
447
452
|
clendAccount,
|
|
448
453
|
outputTokenMint,
|
|
449
454
|
withdrawAmountUi: uiAmount,
|
|
450
455
|
withdrawAll,
|
|
456
|
+
useJito,
|
|
451
457
|
};
|
|
452
458
|
|
|
453
459
|
const body = await this.handleApiCall(() =>
|
|
@@ -479,6 +485,8 @@ export class Client extends ApiClient {
|
|
|
479
485
|
uiAmount: number,
|
|
480
486
|
leverage: number,
|
|
481
487
|
slippageBps: number,
|
|
488
|
+
useJito: boolean,
|
|
489
|
+
isHandoff: boolean,
|
|
482
490
|
): Promise<string> {
|
|
483
491
|
const req: DepositLeverageRequest = {
|
|
484
492
|
owner: this.address(),
|
|
@@ -490,6 +498,8 @@ export class Client extends ApiClient {
|
|
|
490
498
|
depositAmountUi: uiAmount,
|
|
491
499
|
leverage,
|
|
492
500
|
slippageBps,
|
|
501
|
+
useJito,
|
|
502
|
+
isHandoff,
|
|
493
503
|
};
|
|
494
504
|
const body = await this.handleApiCall(() =>
|
|
495
505
|
this.http.post("leverage/deposit", JSON.stringify(req)),
|
|
@@ -497,13 +507,22 @@ export class Client extends ApiClient {
|
|
|
497
507
|
|
|
498
508
|
const depositLeverageResponse: DepositLeverageResponse = JSON.parse(body);
|
|
499
509
|
|
|
510
|
+
let handoffTxns: string[] = [];
|
|
511
|
+
if (depositLeverageResponse.txns.length > 1) {
|
|
512
|
+
handoffTxns = depositLeverageResponse.txns.slice(1);
|
|
513
|
+
}
|
|
514
|
+
const userTx = depositLeverageResponse.txns[0];
|
|
515
|
+
|
|
500
516
|
const txSig = await this.send(
|
|
501
|
-
|
|
517
|
+
userTx,
|
|
502
518
|
depositLeverageResponse.userRequestId,
|
|
503
|
-
|
|
519
|
+
req.useJito,
|
|
520
|
+
handoffTxns,
|
|
504
521
|
);
|
|
505
522
|
|
|
506
523
|
return txSig;
|
|
524
|
+
|
|
525
|
+
return txSig;
|
|
507
526
|
}
|
|
508
527
|
|
|
509
528
|
/**
|
|
@@ -517,6 +536,7 @@ export class Client extends ApiClient {
|
|
|
517
536
|
liabilityTokenMint: web3.PublicKey,
|
|
518
537
|
leverage: number,
|
|
519
538
|
slippageBps: number,
|
|
539
|
+
useJito: boolean,
|
|
520
540
|
): Promise<string> {
|
|
521
541
|
const req: AdjustLeverageRequest = {
|
|
522
542
|
clendAccount,
|
|
@@ -524,6 +544,7 @@ export class Client extends ApiClient {
|
|
|
524
544
|
liabilityTokenMint,
|
|
525
545
|
leverage,
|
|
526
546
|
slippageBps,
|
|
547
|
+
useJito,
|
|
527
548
|
};
|
|
528
549
|
const body = await this.handleApiCall(() =>
|
|
529
550
|
this.http.post("leverage/adjust", JSON.stringify(req)),
|
|
@@ -553,6 +574,7 @@ export class Client extends ApiClient {
|
|
|
553
574
|
uiAmount: number,
|
|
554
575
|
slippageBps: number,
|
|
555
576
|
withdrawAll: boolean,
|
|
577
|
+
useJito: boolean,
|
|
556
578
|
): Promise<string> {
|
|
557
579
|
const req: WithdrawLeverageRequest = {
|
|
558
580
|
clendAccount,
|
|
@@ -562,6 +584,7 @@ export class Client extends ApiClient {
|
|
|
562
584
|
withdrawAmountUi: uiAmount,
|
|
563
585
|
slippageBps,
|
|
564
586
|
withdrawAll,
|
|
587
|
+
useJito,
|
|
565
588
|
};
|
|
566
589
|
const body = await this.handleApiCall(() =>
|
|
567
590
|
this.http.post("leverage/withdraw", JSON.stringify(req)),
|
|
@@ -572,7 +595,7 @@ export class Client extends ApiClient {
|
|
|
572
595
|
const txSig = await this.send(
|
|
573
596
|
withdrawLeverageResponse.unsignedBase64Tx,
|
|
574
597
|
withdrawLeverageResponse.userRequestId,
|
|
575
|
-
|
|
598
|
+
true,
|
|
576
599
|
);
|
|
577
600
|
|
|
578
601
|
return txSig;
|
|
@@ -585,6 +608,7 @@ export class Client extends ApiClient {
|
|
|
585
608
|
async withdrawEmissions(clendAccount: web3.PublicKey): Promise<string> {
|
|
586
609
|
const req: WithdrawEmissionsRequest = {
|
|
587
610
|
clendAccount,
|
|
611
|
+
useJito: false,
|
|
588
612
|
};
|
|
589
613
|
|
|
590
614
|
const body = await this.handleApiCall(() =>
|
|
@@ -603,10 +627,6 @@ export class Client extends ApiClient {
|
|
|
603
627
|
return txSig;
|
|
604
628
|
}
|
|
605
629
|
|
|
606
|
-
async handoffDepositLeverage(): Promise<string> {
|
|
607
|
-
return "";
|
|
608
|
-
}
|
|
609
|
-
|
|
610
630
|
public async getPerformanceChartingExtension(
|
|
611
631
|
clendAccount: web3.PublicKey,
|
|
612
632
|
): Promise<PositionChartingExtension> {
|
package/src/types.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface DepositRequest {
|
|
|
20
20
|
clendAccount: web3.PublicKey | null;
|
|
21
21
|
inputTokenMint: web3.PublicKey;
|
|
22
22
|
depositAmountUi: number;
|
|
23
|
+
useJito: boolean;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
export interface DepositResponse {
|
|
@@ -35,6 +36,7 @@ export interface WithdrawRequest {
|
|
|
35
36
|
outputTokenMint: web3.PublicKey;
|
|
36
37
|
withdrawAmountUi: number;
|
|
37
38
|
withdrawAll: boolean;
|
|
39
|
+
useJito: boolean;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
export interface WithdrawResponse {
|
|
@@ -55,6 +57,8 @@ export interface DepositLeverageRequest {
|
|
|
55
57
|
depositAmountUi: number;
|
|
56
58
|
leverage: number;
|
|
57
59
|
slippageBps: number;
|
|
60
|
+
useJito: boolean;
|
|
61
|
+
isHandoff: boolean;
|
|
58
62
|
}
|
|
59
63
|
|
|
60
64
|
/**
|
|
@@ -62,7 +66,7 @@ export interface DepositLeverageRequest {
|
|
|
62
66
|
*/
|
|
63
67
|
export interface DepositLeverageResponse {
|
|
64
68
|
userRequestId: string;
|
|
65
|
-
|
|
69
|
+
txns: string[];
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
/**
|
|
@@ -74,6 +78,7 @@ export interface AdjustLeverageRequest {
|
|
|
74
78
|
liabilityTokenMint: web3.PublicKey;
|
|
75
79
|
leverage: number;
|
|
76
80
|
slippageBps: number;
|
|
81
|
+
useJito: boolean;
|
|
77
82
|
}
|
|
78
83
|
|
|
79
84
|
/**
|
|
@@ -95,6 +100,7 @@ export interface WithdrawLeverageRequest {
|
|
|
95
100
|
withdrawAmountUi: number;
|
|
96
101
|
slippageBps: number;
|
|
97
102
|
withdrawAll: boolean;
|
|
103
|
+
useJito: boolean;
|
|
98
104
|
}
|
|
99
105
|
|
|
100
106
|
/**
|
|
@@ -110,6 +116,7 @@ export interface WithdrawLeverageResponse {
|
|
|
110
116
|
*/
|
|
111
117
|
export interface WithdrawEmissionsRequest {
|
|
112
118
|
clendAccount: web3.PublicKey;
|
|
119
|
+
useJito: boolean;
|
|
113
120
|
}
|
|
114
121
|
|
|
115
122
|
/**
|