@carrot-protocol/boost-http-client 0.4.7 → 0.4.8
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 +2 -0
- package/dist/index.js +25 -0
- package/dist/types.d.ts +27 -0
- package/package.json +1 -1
- package/src/index.ts +62 -0
- package/src/types.ts +31 -0
package/dist/index.d.ts
CHANGED
|
@@ -56,6 +56,8 @@ export declare class Client extends ApiClient {
|
|
|
56
56
|
getBank(bankAddress: web3.PublicKey): Promise<GetBankResponse>;
|
|
57
57
|
deposit(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey | null, inputTokenMint: web3.PublicKey, uiAmount: number, useJito: boolean): Promise<string>;
|
|
58
58
|
withdraw(clendAccount: web3.PublicKey, outputTokenMint: web3.PublicKey, uiAmount: number, withdrawAll: boolean, useJito: boolean): Promise<string>;
|
|
59
|
+
borrow(clendAccount: web3.PublicKey, bankMint: web3.PublicKey, uiAmount: number, useJito: boolean): Promise<string>;
|
|
60
|
+
repay(clendAccount: web3.PublicKey, bankMint: web3.PublicKey, uiAmount: number, repayAll: boolean, useJito: boolean): Promise<string>;
|
|
59
61
|
/**
|
|
60
62
|
* Deposit collateral and create a leveraged position
|
|
61
63
|
* @param request Deposit leverage request parameters
|
package/dist/index.js
CHANGED
|
@@ -356,6 +356,31 @@ class Client extends api_1.ApiClient {
|
|
|
356
356
|
const txSig = await this.send(withdrawResponse.unsignedBase64Tx, withdrawResponse.userRequestId, req.useJito);
|
|
357
357
|
return txSig;
|
|
358
358
|
}
|
|
359
|
+
async borrow(clendAccount, bankMint, uiAmount, useJito) {
|
|
360
|
+
const req = {
|
|
361
|
+
clendAccount,
|
|
362
|
+
bankMint,
|
|
363
|
+
borrowAmountUi: uiAmount,
|
|
364
|
+
useJito,
|
|
365
|
+
};
|
|
366
|
+
const body = await this.handleApiCall(() => this.http.post("borrow", JSON.stringify(req)));
|
|
367
|
+
const borrowResponse = JSON.parse(body);
|
|
368
|
+
const txSig = await this.send(borrowResponse.unsignedBase64Tx, borrowResponse.userRequestId, req.useJito);
|
|
369
|
+
return txSig;
|
|
370
|
+
}
|
|
371
|
+
async repay(clendAccount, bankMint, uiAmount, repayAll, useJito) {
|
|
372
|
+
const req = {
|
|
373
|
+
clendAccount,
|
|
374
|
+
bankMint,
|
|
375
|
+
repayAmountUi: uiAmount,
|
|
376
|
+
repayAll,
|
|
377
|
+
useJito,
|
|
378
|
+
};
|
|
379
|
+
const body = await this.handleApiCall(() => this.http.post("repay", JSON.stringify(req)));
|
|
380
|
+
const repayResponse = JSON.parse(body);
|
|
381
|
+
const txSig = await this.send(repayResponse.unsignedBase64Tx, repayResponse.userRequestId, req.useJito);
|
|
382
|
+
return txSig;
|
|
383
|
+
}
|
|
359
384
|
/**
|
|
360
385
|
* Deposit collateral and create a leveraged position
|
|
361
386
|
* @param request Deposit leverage request parameters
|
package/dist/types.d.ts
CHANGED
|
@@ -37,6 +37,33 @@ export interface WithdrawResponse {
|
|
|
37
37
|
userRequestId: string;
|
|
38
38
|
unsignedBase64Tx: string;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Request to borrow from a bank
|
|
42
|
+
*/
|
|
43
|
+
export interface BorrowRequest {
|
|
44
|
+
clendAccount: web3.PublicKey;
|
|
45
|
+
bankMint: web3.PublicKey;
|
|
46
|
+
borrowAmountUi: number;
|
|
47
|
+
useJito: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface BorrowResponse {
|
|
50
|
+
userRequestId: string;
|
|
51
|
+
unsignedBase64Tx: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Request to repay a borrow
|
|
55
|
+
*/
|
|
56
|
+
export interface RepayRequest {
|
|
57
|
+
clendAccount: web3.PublicKey;
|
|
58
|
+
bankMint: web3.PublicKey;
|
|
59
|
+
repayAmountUi: number;
|
|
60
|
+
repayAll: boolean;
|
|
61
|
+
useJito: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface RepayResponse {
|
|
64
|
+
userRequestId: string;
|
|
65
|
+
unsignedBase64Tx: string;
|
|
66
|
+
}
|
|
40
67
|
/**
|
|
41
68
|
* Request to deposit collateral and create a leveraged position
|
|
42
69
|
*/
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -30,6 +30,10 @@ import {
|
|
|
30
30
|
DepositResponse,
|
|
31
31
|
WithdrawRequest,
|
|
32
32
|
WithdrawResponse,
|
|
33
|
+
BorrowRequest,
|
|
34
|
+
BorrowResponse,
|
|
35
|
+
RepayRequest,
|
|
36
|
+
RepayResponse,
|
|
33
37
|
GetAccountResponse,
|
|
34
38
|
GetAccountRequest,
|
|
35
39
|
GetWalletBalancesRequest,
|
|
@@ -476,6 +480,64 @@ export class Client extends ApiClient {
|
|
|
476
480
|
return txSig;
|
|
477
481
|
}
|
|
478
482
|
|
|
483
|
+
async borrow(
|
|
484
|
+
clendAccount: web3.PublicKey,
|
|
485
|
+
bankMint: web3.PublicKey,
|
|
486
|
+
uiAmount: number,
|
|
487
|
+
useJito: boolean,
|
|
488
|
+
): Promise<string> {
|
|
489
|
+
const req: BorrowRequest = {
|
|
490
|
+
clendAccount,
|
|
491
|
+
bankMint,
|
|
492
|
+
borrowAmountUi: uiAmount,
|
|
493
|
+
useJito,
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
const body = await this.handleApiCall(() =>
|
|
497
|
+
this.http.post("borrow", JSON.stringify(req)),
|
|
498
|
+
);
|
|
499
|
+
|
|
500
|
+
const borrowResponse: BorrowResponse = JSON.parse(body);
|
|
501
|
+
|
|
502
|
+
const txSig = await this.send(
|
|
503
|
+
borrowResponse.unsignedBase64Tx,
|
|
504
|
+
borrowResponse.userRequestId,
|
|
505
|
+
req.useJito,
|
|
506
|
+
);
|
|
507
|
+
|
|
508
|
+
return txSig;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
async repay(
|
|
512
|
+
clendAccount: web3.PublicKey,
|
|
513
|
+
bankMint: web3.PublicKey,
|
|
514
|
+
uiAmount: number,
|
|
515
|
+
repayAll: boolean,
|
|
516
|
+
useJito: boolean,
|
|
517
|
+
): Promise<string> {
|
|
518
|
+
const req: RepayRequest = {
|
|
519
|
+
clendAccount,
|
|
520
|
+
bankMint,
|
|
521
|
+
repayAmountUi: uiAmount,
|
|
522
|
+
repayAll,
|
|
523
|
+
useJito,
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
const body = await this.handleApiCall(() =>
|
|
527
|
+
this.http.post("repay", JSON.stringify(req)),
|
|
528
|
+
);
|
|
529
|
+
|
|
530
|
+
const repayResponse: RepayResponse = JSON.parse(body);
|
|
531
|
+
|
|
532
|
+
const txSig = await this.send(
|
|
533
|
+
repayResponse.unsignedBase64Tx,
|
|
534
|
+
repayResponse.userRequestId,
|
|
535
|
+
req.useJito,
|
|
536
|
+
);
|
|
537
|
+
|
|
538
|
+
return txSig;
|
|
539
|
+
}
|
|
540
|
+
|
|
479
541
|
/**
|
|
480
542
|
* Deposit collateral and create a leveraged position
|
|
481
543
|
* @param request Deposit leverage request parameters
|
package/src/types.ts
CHANGED
|
@@ -44,6 +44,37 @@ export interface WithdrawResponse {
|
|
|
44
44
|
unsignedBase64Tx: string;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Request to borrow from a bank
|
|
49
|
+
*/
|
|
50
|
+
export interface BorrowRequest {
|
|
51
|
+
clendAccount: web3.PublicKey;
|
|
52
|
+
bankMint: web3.PublicKey;
|
|
53
|
+
borrowAmountUi: number;
|
|
54
|
+
useJito: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface BorrowResponse {
|
|
58
|
+
userRequestId: string;
|
|
59
|
+
unsignedBase64Tx: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Request to repay a borrow
|
|
64
|
+
*/
|
|
65
|
+
export interface RepayRequest {
|
|
66
|
+
clendAccount: web3.PublicKey;
|
|
67
|
+
bankMint: web3.PublicKey;
|
|
68
|
+
repayAmountUi: number;
|
|
69
|
+
repayAll: boolean;
|
|
70
|
+
useJito: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface RepayResponse {
|
|
74
|
+
userRequestId: string;
|
|
75
|
+
unsignedBase64Tx: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
47
78
|
/**
|
|
48
79
|
* Request to deposit collateral and create a leveraged position
|
|
49
80
|
*/
|