@carrot-protocol/boost-http-client 0.2.0-mrgn-fork1-dev-be6fd99 → 0.2.0-mrgn-fork1-dev-e3a1df6
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.js +3 -2
- package/dist/types.d.ts +6 -14
- package/package.json +1 -1
- package/src/index.ts +3 -5
- package/src/types.ts +6 -13
package/dist/index.js
CHANGED
|
@@ -70,7 +70,7 @@ class Client {
|
|
|
70
70
|
return this.provider.wallet.publicKey;
|
|
71
71
|
}
|
|
72
72
|
// sign and send tx to api for sending to network
|
|
73
|
-
async send(unsignedBase64Tx
|
|
73
|
+
async send(unsignedBase64Tx) {
|
|
74
74
|
// deserialize into tx obj
|
|
75
75
|
const txBytes = Buffer.from(unsignedBase64Tx, "base64");
|
|
76
76
|
const tx = anchor_1.web3.VersionedTransaction.deserialize(new Uint8Array(txBytes));
|
|
@@ -81,7 +81,7 @@ class Client {
|
|
|
81
81
|
const encodedAndSignedTx = Buffer.from(signedTx.serialize()).toString("base64");
|
|
82
82
|
// create request obj
|
|
83
83
|
const sendRequest = {
|
|
84
|
-
txns: [encodedAndSignedTx
|
|
84
|
+
txns: [encodedAndSignedTx],
|
|
85
85
|
};
|
|
86
86
|
// send to api
|
|
87
87
|
await handleApiCall(() => this.http.post(`send`, sendRequest));
|
|
@@ -106,6 +106,7 @@ class Client {
|
|
|
106
106
|
user = this.address();
|
|
107
107
|
}
|
|
108
108
|
const body = await handleApiCall(() => this.http.get(`/user?user=${user.toString()}`));
|
|
109
|
+
console.log(JSON.stringify(body));
|
|
109
110
|
const response = JSON.parse(body);
|
|
110
111
|
return response;
|
|
111
112
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { BN, web3 } from "@coral-xyz/anchor";
|
|
2
|
-
import Decimal from "decimal.js";
|
|
3
2
|
export interface SendRequest {
|
|
4
3
|
txns: string[];
|
|
5
4
|
}
|
|
@@ -15,9 +14,9 @@ export interface CreateObligationResponse {
|
|
|
15
14
|
export interface DepositLeverageRequest {
|
|
16
15
|
owner: web3.PublicKey;
|
|
17
16
|
selectedTokenMint: web3.PublicKey;
|
|
18
|
-
depositAmount:
|
|
17
|
+
depositAmount: BN;
|
|
19
18
|
leverage: number;
|
|
20
|
-
|
|
19
|
+
slippageBps: number;
|
|
21
20
|
}
|
|
22
21
|
/**
|
|
23
22
|
* Response for deposit leverage operation
|
|
@@ -45,9 +44,9 @@ export interface ModifyLeverageResponse {
|
|
|
45
44
|
export interface WithdrawLeverageRequest {
|
|
46
45
|
owner: web3.PublicKey;
|
|
47
46
|
selectedTokenMint: web3.PublicKey;
|
|
48
|
-
withdrawAmount:
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
withdrawAmount: BN;
|
|
48
|
+
slippageBps: number;
|
|
49
|
+
withdrawAll: boolean;
|
|
51
50
|
}
|
|
52
51
|
/**
|
|
53
52
|
* Response for withdraw leverage operation
|
|
@@ -56,20 +55,13 @@ export interface WithdrawLeverageResponse {
|
|
|
56
55
|
unsignedBase64Tx: string;
|
|
57
56
|
}
|
|
58
57
|
export interface GetUserResponse {
|
|
59
|
-
netValue: number;
|
|
60
|
-
pnl: number;
|
|
61
|
-
netAPY: number;
|
|
62
|
-
leverage: number;
|
|
63
|
-
totalCollateral: number;
|
|
64
|
-
totalDebt: number;
|
|
65
|
-
ltv: number;
|
|
66
|
-
liquidationLtv: number;
|
|
67
58
|
usdcBalance: BN;
|
|
68
59
|
usdcBalanceUi: number;
|
|
69
60
|
jlpBalance: BN;
|
|
70
61
|
jlpBalanceUi: number;
|
|
71
62
|
solBalance: BN;
|
|
72
63
|
solBalanceUi: number;
|
|
64
|
+
clendAccount: any | undefined;
|
|
73
65
|
}
|
|
74
66
|
export interface GetBankResponse {
|
|
75
67
|
totalBorrowTVL: number;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -47,10 +47,7 @@ export class Client {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// sign and send tx to api for sending to network
|
|
50
|
-
private async send(
|
|
51
|
-
unsignedBase64Tx: string,
|
|
52
|
-
...signedBase64Txns: string[]
|
|
53
|
-
): Promise<string> {
|
|
50
|
+
private async send(unsignedBase64Tx: string): Promise<string> {
|
|
54
51
|
// deserialize into tx obj
|
|
55
52
|
const txBytes = Buffer.from(unsignedBase64Tx, "base64");
|
|
56
53
|
const tx = web3.VersionedTransaction.deserialize(new Uint8Array(txBytes));
|
|
@@ -66,7 +63,7 @@ export class Client {
|
|
|
66
63
|
|
|
67
64
|
// create request obj
|
|
68
65
|
const sendRequest: SendRequest = {
|
|
69
|
-
txns: [encodedAndSignedTx
|
|
66
|
+
txns: [encodedAndSignedTx],
|
|
70
67
|
};
|
|
71
68
|
|
|
72
69
|
// send to api
|
|
@@ -98,6 +95,7 @@ export class Client {
|
|
|
98
95
|
const body = await handleApiCall(() =>
|
|
99
96
|
this.http.get(`/user?user=${user.toString()}`),
|
|
100
97
|
);
|
|
98
|
+
console.log(JSON.stringify(body));
|
|
101
99
|
|
|
102
100
|
const response: GetUserResponse = JSON.parse(body);
|
|
103
101
|
|
package/src/types.ts
CHANGED
|
@@ -20,9 +20,9 @@ export interface CreateObligationResponse {
|
|
|
20
20
|
export interface DepositLeverageRequest {
|
|
21
21
|
owner: web3.PublicKey;
|
|
22
22
|
selectedTokenMint: web3.PublicKey;
|
|
23
|
-
depositAmount:
|
|
23
|
+
depositAmount: BN;
|
|
24
24
|
leverage: number;
|
|
25
|
-
|
|
25
|
+
slippageBps: number;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -54,9 +54,9 @@ export interface ModifyLeverageResponse {
|
|
|
54
54
|
export interface WithdrawLeverageRequest {
|
|
55
55
|
owner: web3.PublicKey;
|
|
56
56
|
selectedTokenMint: web3.PublicKey;
|
|
57
|
-
withdrawAmount:
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
withdrawAmount: BN;
|
|
58
|
+
slippageBps: number;
|
|
59
|
+
withdrawAll: boolean;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
@@ -67,20 +67,13 @@ export interface WithdrawLeverageResponse {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
export interface GetUserResponse {
|
|
70
|
-
netValue: number;
|
|
71
|
-
pnl: number;
|
|
72
|
-
netAPY: number;
|
|
73
|
-
leverage: number;
|
|
74
|
-
totalCollateral: number;
|
|
75
|
-
totalDebt: number;
|
|
76
|
-
ltv: number;
|
|
77
|
-
liquidationLtv: number;
|
|
78
70
|
usdcBalance: BN;
|
|
79
71
|
usdcBalanceUi: number;
|
|
80
72
|
jlpBalance: BN;
|
|
81
73
|
jlpBalanceUi: number;
|
|
82
74
|
solBalance: BN;
|
|
83
75
|
solBalanceUi: number;
|
|
76
|
+
clendAccount: any | undefined;
|
|
84
77
|
}
|
|
85
78
|
|
|
86
79
|
export interface GetBankResponse {
|