@carrot-protocol/boost-http-client 0.4.4-handoff-dev-9a1c50a → 0.4.4-handoff-dev-6fafd92

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 CHANGED
@@ -67,13 +67,13 @@ export declare class Client extends ApiClient {
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, useJito: boolean): Promise<string>;
70
+ adjustLeverage(clendAccount: web3.PublicKey, assetTokenMint: web3.PublicKey, liabilityTokenMint: web3.PublicKey, leverage: number, slippageBps: number, useJito: boolean, isHandoff: 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, useJito: 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, isHandoff: boolean): Promise<string>;
77
77
  /**
78
78
  * Withdraw emissions from a bank
79
79
  * @returns Withdraw emissions operation result
package/dist/index.js CHANGED
@@ -80,6 +80,9 @@ class Client extends api_1.ApiClient {
80
80
  console.log("dry run enabled, exiting before sending tx");
81
81
  return "";
82
82
  }
83
+ console.log("unsignedBase64Tx", unsignedBase64Tx);
84
+ if (handoffTxns.length > 0)
85
+ console.log("handoffTxns", handoffTxns);
83
86
  // 1. Sign the primary transaction (User Transaction)
84
87
  const txBytes = Buffer.from(unsignedBase64Tx, "base64");
85
88
  const tx = anchor_1.web3.VersionedTransaction.deserialize(new Uint8Array(txBytes));
@@ -340,7 +343,7 @@ class Client extends api_1.ApiClient {
340
343
  };
341
344
  const body = await this.handleApiCall(() => this.http.post("deposit", JSON.stringify(req)));
342
345
  const depositResponse = JSON.parse(body);
343
- const txSig = await this.send(depositResponse.unsignedBase64Tx, depositResponse.userRequestId, false);
346
+ const txSig = await this.send(depositResponse.unsignedBase64Tx, depositResponse.userRequestId, req.useJito);
344
347
  return txSig;
345
348
  }
346
349
  async withdraw(clendAccount, outputTokenMint, uiAmount, withdrawAll, useJito) {
@@ -353,7 +356,7 @@ class Client extends api_1.ApiClient {
353
356
  };
354
357
  const body = await this.handleApiCall(() => this.http.post("withdraw", JSON.stringify(req)));
355
358
  const withdrawResponse = JSON.parse(body);
356
- const txSig = await this.send(withdrawResponse.unsignedBase64Tx, withdrawResponse.userRequestId, false);
359
+ const txSig = await this.send(withdrawResponse.unsignedBase64Tx, withdrawResponse.userRequestId, req.useJito);
357
360
  return txSig;
358
361
  }
359
362
  /**
@@ -384,14 +387,13 @@ class Client extends api_1.ApiClient {
384
387
  const userTx = depositLeverageResponse.txns[0];
385
388
  const txSig = await this.send(userTx, depositLeverageResponse.userRequestId, req.useJito, handoffTxns);
386
389
  return txSig;
387
- return txSig;
388
390
  }
389
391
  /**
390
392
  * Adjust the leverage of an existing position
391
393
  * @param request Adjust leverage request parameters
392
394
  * @returns Adjust leverage operation result
393
395
  */
394
- async adjustLeverage(clendAccount, assetTokenMint, liabilityTokenMint, leverage, slippageBps, useJito) {
396
+ async adjustLeverage(clendAccount, assetTokenMint, liabilityTokenMint, leverage, slippageBps, useJito, isHandoff) {
395
397
  const req = {
396
398
  clendAccount,
397
399
  assetTokenMint,
@@ -399,10 +401,16 @@ class Client extends api_1.ApiClient {
399
401
  leverage,
400
402
  slippageBps,
401
403
  useJito,
404
+ isHandoff,
402
405
  };
403
406
  const body = await this.handleApiCall(() => this.http.post("leverage/adjust", JSON.stringify(req)));
404
407
  const adjustLeverageResponse = JSON.parse(body);
405
- const txSig = await this.send(adjustLeverageResponse.unsignedBase64Tx, adjustLeverageResponse.userRequestId, false);
408
+ let handoffTxns = [];
409
+ if (adjustLeverageResponse.txns.length > 1) {
410
+ handoffTxns = adjustLeverageResponse.txns.slice(1);
411
+ }
412
+ const userTx = adjustLeverageResponse.txns[0];
413
+ const txSig = await this.send(userTx, adjustLeverageResponse.userRequestId, req.useJito, handoffTxns);
406
414
  return txSig;
407
415
  }
408
416
  /**
@@ -410,7 +418,7 @@ class Client extends api_1.ApiClient {
410
418
  * @param request Withdraw leverage request parameters
411
419
  * @returns Withdraw leverage operation result
412
420
  */
413
- async withdrawLeverage(clendAccount, outputTokenMint, assetTokenMint, liabilityTokenMint, uiAmount, slippageBps, withdrawAll, useJito) {
421
+ async withdrawLeverage(clendAccount, outputTokenMint, assetTokenMint, liabilityTokenMint, uiAmount, slippageBps, withdrawAll, useJito, isHandoff) {
414
422
  const req = {
415
423
  clendAccount,
416
424
  outputTokenMint,
@@ -420,10 +428,16 @@ class Client extends api_1.ApiClient {
420
428
  slippageBps,
421
429
  withdrawAll,
422
430
  useJito,
431
+ isHandoff,
423
432
  };
424
433
  const body = await this.handleApiCall(() => this.http.post("leverage/withdraw", JSON.stringify(req)));
425
434
  const withdrawLeverageResponse = JSON.parse(body);
426
- const txSig = await this.send(withdrawLeverageResponse.unsignedBase64Tx, withdrawLeverageResponse.userRequestId, true);
435
+ let handoffTxns = [];
436
+ if (withdrawLeverageResponse.txns.length > 1) {
437
+ handoffTxns = withdrawLeverageResponse.txns.slice(1);
438
+ }
439
+ const userTx = withdrawLeverageResponse.txns[0];
440
+ const txSig = await this.send(userTx, withdrawLeverageResponse.userRequestId, req.useJito, handoffTxns);
427
441
  return txSig;
428
442
  }
429
443
  /**
@@ -437,7 +451,7 @@ class Client extends api_1.ApiClient {
437
451
  };
438
452
  const body = await this.handleApiCall(() => this.http.post("emissions/withdraw", JSON.stringify(req)));
439
453
  const withdrawEmissionsResponse = JSON.parse(body);
440
- const txSig = await this.send(withdrawEmissionsResponse.unsignedBase64Tx, withdrawEmissionsResponse.userRequestId, false);
454
+ const txSig = await this.send(withdrawEmissionsResponse.unsignedBase64Tx, withdrawEmissionsResponse.userRequestId, req.useJito);
441
455
  return txSig;
442
456
  }
443
457
  async getPerformanceChartingExtension(clendAccount) {
package/dist/types.d.ts CHANGED
@@ -70,13 +70,14 @@ export interface AdjustLeverageRequest {
70
70
  leverage: number;
71
71
  slippageBps: number;
72
72
  useJito: boolean;
73
+ isHandoff: boolean;
73
74
  }
74
75
  /**
75
76
  * Response for adjust leverage operation
76
77
  */
77
78
  export interface AdjustLeverageResponse {
78
79
  userRequestId: string;
79
- unsignedBase64Tx: string;
80
+ txns: string[];
80
81
  }
81
82
  /**
82
83
  * Request to withdraw from a leveraged position
@@ -90,13 +91,14 @@ export interface WithdrawLeverageRequest {
90
91
  slippageBps: number;
91
92
  withdrawAll: boolean;
92
93
  useJito: boolean;
94
+ isHandoff: boolean;
93
95
  }
94
96
  /**
95
97
  * Response for withdraw leverage operation
96
98
  */
97
99
  export interface WithdrawLeverageResponse {
98
100
  userRequestId: string;
99
- unsignedBase64Tx: string;
101
+ txns: string[];
100
102
  }
101
103
  /**
102
104
  * Request to withdraw emissions from a bank
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@carrot-protocol/boost-http-client",
3
- "version": "0.4.4-handoff-dev-9a1c50a",
3
+ "version": "0.4.4-handoff-dev-6fafd92",
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
@@ -84,6 +84,8 @@ export class Client extends ApiClient {
84
84
  console.log("dry run enabled, exiting before sending tx");
85
85
  return "";
86
86
  }
87
+ console.log("unsignedBase64Tx", unsignedBase64Tx);
88
+ if (handoffTxns.length > 0) console.log("handoffTxns", handoffTxns);
87
89
 
88
90
  // 1. Sign the primary transaction (User Transaction)
89
91
  const txBytes = Buffer.from(unsignedBase64Tx, "base64");
@@ -435,7 +437,7 @@ export class Client extends ApiClient {
435
437
  const txSig = await this.send(
436
438
  depositResponse.unsignedBase64Tx,
437
439
  depositResponse.userRequestId,
438
- false,
440
+ req.useJito,
439
441
  );
440
442
 
441
443
  return txSig;
@@ -465,7 +467,7 @@ export class Client extends ApiClient {
465
467
  const txSig = await this.send(
466
468
  withdrawResponse.unsignedBase64Tx,
467
469
  withdrawResponse.userRequestId,
468
- false,
470
+ req.useJito,
469
471
  );
470
472
 
471
473
  return txSig;
@@ -521,8 +523,6 @@ export class Client extends ApiClient {
521
523
  );
522
524
 
523
525
  return txSig;
524
-
525
- return txSig;
526
526
  }
527
527
 
528
528
  /**
@@ -537,6 +537,7 @@ export class Client extends ApiClient {
537
537
  leverage: number,
538
538
  slippageBps: number,
539
539
  useJito: boolean,
540
+ isHandoff: boolean,
540
541
  ): Promise<string> {
541
542
  const req: AdjustLeverageRequest = {
542
543
  clendAccount,
@@ -545,6 +546,7 @@ export class Client extends ApiClient {
545
546
  leverage,
546
547
  slippageBps,
547
548
  useJito,
549
+ isHandoff,
548
550
  };
549
551
  const body = await this.handleApiCall(() =>
550
552
  this.http.post("leverage/adjust", JSON.stringify(req)),
@@ -552,10 +554,17 @@ export class Client extends ApiClient {
552
554
 
553
555
  const adjustLeverageResponse: AdjustLeverageResponse = JSON.parse(body);
554
556
 
557
+ let handoffTxns: string[] = [];
558
+ if (adjustLeverageResponse.txns.length > 1) {
559
+ handoffTxns = adjustLeverageResponse.txns.slice(1);
560
+ }
561
+ const userTx = adjustLeverageResponse.txns[0];
562
+
555
563
  const txSig = await this.send(
556
- adjustLeverageResponse.unsignedBase64Tx,
564
+ userTx,
557
565
  adjustLeverageResponse.userRequestId,
558
- false,
566
+ req.useJito,
567
+ handoffTxns,
559
568
  );
560
569
 
561
570
  return txSig;
@@ -575,6 +584,7 @@ export class Client extends ApiClient {
575
584
  slippageBps: number,
576
585
  withdrawAll: boolean,
577
586
  useJito: boolean,
587
+ isHandoff: boolean,
578
588
  ): Promise<string> {
579
589
  const req: WithdrawLeverageRequest = {
580
590
  clendAccount,
@@ -585,6 +595,7 @@ export class Client extends ApiClient {
585
595
  slippageBps,
586
596
  withdrawAll,
587
597
  useJito,
598
+ isHandoff,
588
599
  };
589
600
  const body = await this.handleApiCall(() =>
590
601
  this.http.post("leverage/withdraw", JSON.stringify(req)),
@@ -592,10 +603,17 @@ export class Client extends ApiClient {
592
603
 
593
604
  const withdrawLeverageResponse: WithdrawLeverageResponse = JSON.parse(body);
594
605
 
606
+ let handoffTxns: string[] = [];
607
+ if (withdrawLeverageResponse.txns.length > 1) {
608
+ handoffTxns = withdrawLeverageResponse.txns.slice(1);
609
+ }
610
+ const userTx = withdrawLeverageResponse.txns[0];
611
+
595
612
  const txSig = await this.send(
596
- withdrawLeverageResponse.unsignedBase64Tx,
613
+ userTx,
597
614
  withdrawLeverageResponse.userRequestId,
598
- true,
615
+ req.useJito,
616
+ handoffTxns,
599
617
  );
600
618
 
601
619
  return txSig;
@@ -621,7 +639,7 @@ export class Client extends ApiClient {
621
639
  const txSig = await this.send(
622
640
  withdrawEmissionsResponse.unsignedBase64Tx,
623
641
  withdrawEmissionsResponse.userRequestId,
624
- false,
642
+ req.useJito,
625
643
  );
626
644
 
627
645
  return txSig;
package/src/types.ts CHANGED
@@ -79,6 +79,7 @@ export interface AdjustLeverageRequest {
79
79
  leverage: number;
80
80
  slippageBps: number;
81
81
  useJito: boolean;
82
+ isHandoff: boolean;
82
83
  }
83
84
 
84
85
  /**
@@ -86,7 +87,7 @@ export interface AdjustLeverageRequest {
86
87
  */
87
88
  export interface AdjustLeverageResponse {
88
89
  userRequestId: string;
89
- unsignedBase64Tx: string;
90
+ txns: string[];
90
91
  }
91
92
 
92
93
  /**
@@ -101,6 +102,7 @@ export interface WithdrawLeverageRequest {
101
102
  slippageBps: number;
102
103
  withdrawAll: boolean;
103
104
  useJito: boolean;
105
+ isHandoff: boolean;
104
106
  }
105
107
 
106
108
  /**
@@ -108,7 +110,7 @@ export interface WithdrawLeverageRequest {
108
110
  */
109
111
  export interface WithdrawLeverageResponse {
110
112
  userRequestId: string;
111
- unsignedBase64Tx: string;
113
+ txns: string[];
112
114
  }
113
115
 
114
116
  /**