@carrot-protocol/boost-http-client 0.2.15-group-refactor1-dev-9e002ee → 0.2.15-group-refactor1-dev-a038045
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 +6 -0
- package/dist/index.js +15 -8
- package/dist/types.d.ts +14 -0
- package/package.json +2 -2
- package/src/index.ts +27 -9
- package/src/types.ts +16 -0
package/dist/index.d.ts
CHANGED
|
@@ -59,4 +59,10 @@ export declare class Client {
|
|
|
59
59
|
* @returns Withdraw leverage operation result
|
|
60
60
|
*/
|
|
61
61
|
withdrawLeverage(clendGroup: web3.PublicKey, clendAccount: web3.PublicKey, outputTokenMint: web3.PublicKey, assetTokenMint: web3.PublicKey, liabilityTokenMint: web3.PublicKey, uiAmount: number, slippageBps: number, withdrawAll: boolean): Promise<any>;
|
|
62
|
+
/**
|
|
63
|
+
* Withdraw emissions from a bank
|
|
64
|
+
* @param banks Banks to withdraw emissions, if empty, will withdraw from all banks
|
|
65
|
+
* @returns Withdraw emissions operation result
|
|
66
|
+
*/
|
|
67
|
+
withdrawEmissions(banks: web3.PublicKey[]): Promise<any>;
|
|
62
68
|
}
|
package/dist/index.js
CHANGED
|
@@ -354,16 +354,23 @@ class Client {
|
|
|
354
354
|
const txSig = await this.send(withdrawLeverageResponse.unsignedBase64Tx, withdrawLeverageResponse.userRequestId);
|
|
355
355
|
return txSig;
|
|
356
356
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
357
|
+
/**
|
|
358
|
+
* Withdraw emissions from a bank
|
|
359
|
+
* @param banks Banks to withdraw emissions, if empty, will withdraw from all banks
|
|
360
|
+
* @returns Withdraw emissions operation result
|
|
361
|
+
*/
|
|
362
|
+
async withdrawEmissions(banks) {
|
|
363
|
+
const req = {
|
|
364
|
+
owner: this.address(),
|
|
365
|
+
banks,
|
|
366
|
+
};
|
|
367
|
+
const body = await handleApiCall(() => this.http.post("emissions/withdraw", JSON.stringify(req)));
|
|
368
|
+
const withdrawEmissionsResponse = JSON.parse(body);
|
|
369
|
+
const txSig = await this.send(withdrawEmissionsResponse.unsignedBase64Tx, withdrawEmissionsResponse.userRequestId);
|
|
370
|
+
return txSig;
|
|
365
371
|
}
|
|
366
372
|
}
|
|
373
|
+
exports.Client = Client;
|
|
367
374
|
// Helper function to handle API calls
|
|
368
375
|
async function handleApiCall(call) {
|
|
369
376
|
try {
|
package/dist/types.d.ts
CHANGED
|
@@ -64,6 +64,20 @@ export interface WithdrawLeverageResponse {
|
|
|
64
64
|
userRequestId: string;
|
|
65
65
|
unsignedBase64Tx: string;
|
|
66
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Request to withdraw emissions from a bank
|
|
69
|
+
*/
|
|
70
|
+
export interface WithdrawEmissionsRequest {
|
|
71
|
+
owner: web3.PublicKey;
|
|
72
|
+
banks: web3.PublicKey[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Response for withdraw emissions operation
|
|
76
|
+
*/
|
|
77
|
+
export interface WithdrawEmissionsResponse {
|
|
78
|
+
userRequestId: string;
|
|
79
|
+
unsignedBase64Tx: string;
|
|
80
|
+
}
|
|
67
81
|
export interface GetGroupsResponse {
|
|
68
82
|
groups: GroupAndBanks[];
|
|
69
83
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carrot-protocol/boost-http-client",
|
|
3
|
-
"version": "0.2.15-group-refactor1-dev-
|
|
3
|
+
"version": "0.2.15-group-refactor1-dev-a038045",
|
|
4
4
|
"description": "HTTP client for Carrot Boost",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@coral-xyz/anchor": "^0.29.0",
|
|
17
|
-
"@carrot-protocol/clend-common": "0.1.8-group-refactor1-dev-
|
|
17
|
+
"@carrot-protocol/clend-common": "0.1.8-group-refactor1-dev-7bf1ecf",
|
|
18
18
|
"axios": "^1.8.3",
|
|
19
19
|
"bs58": "^6.0.0",
|
|
20
20
|
"decimal.js": "^10.5.0"
|
package/src/index.ts
CHANGED
|
@@ -25,6 +25,8 @@ import {
|
|
|
25
25
|
GroupAndBanks,
|
|
26
26
|
BankEmissions,
|
|
27
27
|
BankEmissionsMode,
|
|
28
|
+
WithdrawEmissionsRequest,
|
|
29
|
+
WithdrawEmissionsResponse,
|
|
28
30
|
} from "./types";
|
|
29
31
|
import encode from "bs58";
|
|
30
32
|
|
|
@@ -469,6 +471,31 @@ export class Client {
|
|
|
469
471
|
|
|
470
472
|
return txSig;
|
|
471
473
|
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Withdraw emissions from a bank
|
|
477
|
+
* @param banks Banks to withdraw emissions, if empty, will withdraw from all banks
|
|
478
|
+
* @returns Withdraw emissions operation result
|
|
479
|
+
*/
|
|
480
|
+
async withdrawEmissions(banks: web3.PublicKey[]): Promise<any> {
|
|
481
|
+
const req: WithdrawEmissionsRequest = {
|
|
482
|
+
owner: this.address(),
|
|
483
|
+
banks,
|
|
484
|
+
};
|
|
485
|
+
const body = await handleApiCall(() =>
|
|
486
|
+
this.http.post("emissions/withdraw", JSON.stringify(req)),
|
|
487
|
+
);
|
|
488
|
+
|
|
489
|
+
const withdrawEmissionsResponse: WithdrawEmissionsResponse =
|
|
490
|
+
JSON.parse(body);
|
|
491
|
+
|
|
492
|
+
const txSig = await this.send(
|
|
493
|
+
withdrawEmissionsResponse.unsignedBase64Tx,
|
|
494
|
+
withdrawEmissionsResponse.userRequestId,
|
|
495
|
+
);
|
|
496
|
+
|
|
497
|
+
return txSig;
|
|
498
|
+
}
|
|
472
499
|
}
|
|
473
500
|
|
|
474
501
|
type ApiErrorPayload = {
|
|
@@ -478,15 +505,6 @@ type ApiErrorPayload = {
|
|
|
478
505
|
timestamp: string;
|
|
479
506
|
};
|
|
480
507
|
|
|
481
|
-
function handleStatusCode(statusCode: number): void {
|
|
482
|
-
switch (statusCode) {
|
|
483
|
-
case 200:
|
|
484
|
-
break;
|
|
485
|
-
default:
|
|
486
|
-
throw new Error(`unexpected status code: ${statusCode}`);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
|
|
490
508
|
// Helper function to handle API calls
|
|
491
509
|
async function handleApiCall<T>(
|
|
492
510
|
call: () => Promise<AxiosResponse<T>>,
|
package/src/types.ts
CHANGED
|
@@ -73,6 +73,22 @@ export interface WithdrawLeverageResponse {
|
|
|
73
73
|
unsignedBase64Tx: string;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Request to withdraw emissions from a bank
|
|
78
|
+
*/
|
|
79
|
+
export interface WithdrawEmissionsRequest {
|
|
80
|
+
owner: web3.PublicKey;
|
|
81
|
+
banks: web3.PublicKey[];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Response for withdraw emissions operation
|
|
86
|
+
*/
|
|
87
|
+
export interface WithdrawEmissionsResponse {
|
|
88
|
+
userRequestId: string;
|
|
89
|
+
unsignedBase64Tx: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
76
92
|
export interface GetGroupsResponse {
|
|
77
93
|
groups: GroupAndBanks[];
|
|
78
94
|
}
|