@carrot-protocol/boost-http-client 0.1.1-api-impl-dev-409753c
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 +41 -0
- package/dist/index.js +137 -0
- package/dist/types.d.ts +57 -0
- package/dist/types.js +2 -0
- package/makefile +16 -0
- package/package.json +25 -0
- package/src/index.ts +160 -0
- package/src/types.ts +65 -0
- package/tsconfig.json +14 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { AnchorProvider, web3 } from "@coral-xyz/anchor";
|
|
2
|
+
import { DepositLeverageRequest, ModifyLeverageRequest, WithdrawLeverageRequest } from "./types";
|
|
3
|
+
export * from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* HTTP Client for Carrot Boost API
|
|
6
|
+
*/
|
|
7
|
+
export declare class Client {
|
|
8
|
+
private readonly baseUrl;
|
|
9
|
+
private readonly http;
|
|
10
|
+
private readonly provider?;
|
|
11
|
+
/**
|
|
12
|
+
* Create a new Carrot Boost API client
|
|
13
|
+
* @param baseUrl Base URL for the API
|
|
14
|
+
*/
|
|
15
|
+
constructor(baseUrl: string, provider?: AnchorProvider);
|
|
16
|
+
private send;
|
|
17
|
+
/**
|
|
18
|
+
* Get obligation details for a wallet
|
|
19
|
+
* @param owner Owner wallet public key
|
|
20
|
+
* @returns Obligation details
|
|
21
|
+
*/
|
|
22
|
+
getObligation(owner: web3.PublicKey): Promise<any>;
|
|
23
|
+
/**
|
|
24
|
+
* Deposit collateral and create a leveraged position
|
|
25
|
+
* @param request Deposit leverage request parameters
|
|
26
|
+
* @returns Deposit leverage operation result
|
|
27
|
+
*/
|
|
28
|
+
depositLeverage(request: DepositLeverageRequest): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Modify the leverage of an existing position
|
|
31
|
+
* @param request Modify leverage request parameters
|
|
32
|
+
* @returns Modify leverage operation result
|
|
33
|
+
*/
|
|
34
|
+
modifyLeverage(request: ModifyLeverageRequest): Promise<any>;
|
|
35
|
+
/**
|
|
36
|
+
* Withdraw from or close a leveraged position
|
|
37
|
+
* @param request Withdraw leverage request parameters
|
|
38
|
+
* @returns Withdraw leverage operation result
|
|
39
|
+
*/
|
|
40
|
+
withdrawLeverage(request: WithdrawLeverageRequest): Promise<any>;
|
|
41
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.Client = void 0;
|
|
21
|
+
const axios_1 = __importDefault(require("axios"));
|
|
22
|
+
const anchor_1 = require("@coral-xyz/anchor");
|
|
23
|
+
const bs58_1 = __importDefault(require("bs58"));
|
|
24
|
+
// Re-export types
|
|
25
|
+
__exportStar(require("./types"), exports);
|
|
26
|
+
/**
|
|
27
|
+
* HTTP Client for Carrot Boost API
|
|
28
|
+
*/
|
|
29
|
+
class Client {
|
|
30
|
+
/**
|
|
31
|
+
* Create a new Carrot Boost API client
|
|
32
|
+
* @param baseUrl Base URL for the API
|
|
33
|
+
*/
|
|
34
|
+
constructor(baseUrl, provider) {
|
|
35
|
+
this.baseUrl = new URL(baseUrl).toString();
|
|
36
|
+
this.http = axios_1.default.create({
|
|
37
|
+
baseURL: this.baseUrl,
|
|
38
|
+
headers: {
|
|
39
|
+
"Content-Type": "application/json",
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
this.provider = provider;
|
|
43
|
+
}
|
|
44
|
+
// sign and send tx to api for sending to network
|
|
45
|
+
async send(base64Tx) {
|
|
46
|
+
// error if provider is undefined
|
|
47
|
+
requireProvider(this.provider);
|
|
48
|
+
// deserialize into tx obj
|
|
49
|
+
const txBytes = Buffer.from(base64Tx, "base64");
|
|
50
|
+
const tx = anchor_1.web3.VersionedTransaction.deserialize(new Uint8Array(txBytes));
|
|
51
|
+
// sign tx
|
|
52
|
+
const signedTx = await this.provider.wallet.signTransaction(tx);
|
|
53
|
+
const txSig = signedTx.signatures[0];
|
|
54
|
+
// encode it back to base64
|
|
55
|
+
const encodedAndSignedTx = Buffer.from(signedTx.serialize()).toString("base64");
|
|
56
|
+
// create request obj
|
|
57
|
+
const sendRequest = {
|
|
58
|
+
tx: encodedAndSignedTx,
|
|
59
|
+
};
|
|
60
|
+
// send to api
|
|
61
|
+
const response = await this.http.post(`${this.baseUrl}/send`, sendRequest);
|
|
62
|
+
handleStatusCode(response.status);
|
|
63
|
+
// return txsig
|
|
64
|
+
return bs58_1.default.encode(txSig);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get obligation details for a wallet
|
|
68
|
+
* @param owner Owner wallet public key
|
|
69
|
+
* @returns Obligation details
|
|
70
|
+
*/
|
|
71
|
+
async getObligation(owner) {
|
|
72
|
+
const response = await this.http.get(`/obligation?owner=${owner.toString()}`);
|
|
73
|
+
handleStatusCode(response.status);
|
|
74
|
+
return JSON.stringify(response.data);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Deposit collateral and create a leveraged position
|
|
78
|
+
* @param request Deposit leverage request parameters
|
|
79
|
+
* @returns Deposit leverage operation result
|
|
80
|
+
*/
|
|
81
|
+
async depositLeverage(request) {
|
|
82
|
+
const response = await this.http.post("/leverage/deposit", request);
|
|
83
|
+
// check http status code
|
|
84
|
+
handleStatusCode(response.status);
|
|
85
|
+
// parse response
|
|
86
|
+
const responseData = JSON.parse(response.data);
|
|
87
|
+
// sign and send signed tx back to api for sending to network
|
|
88
|
+
const txSig = await this.send(responseData.unsignedBase64Tx);
|
|
89
|
+
return txSig;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Modify the leverage of an existing position
|
|
93
|
+
* @param request Modify leverage request parameters
|
|
94
|
+
* @returns Modify leverage operation result
|
|
95
|
+
*/
|
|
96
|
+
async modifyLeverage(request) {
|
|
97
|
+
const response = await this.http.post("/leverage/modify", request);
|
|
98
|
+
// check http status code
|
|
99
|
+
handleStatusCode(response.status);
|
|
100
|
+
// parse response
|
|
101
|
+
const responseData = JSON.parse(response.data);
|
|
102
|
+
// sign and send signed tx back to api for sending to network
|
|
103
|
+
const txSig = await this.send(responseData.unsignedBase64Tx);
|
|
104
|
+
return txSig;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Withdraw from or close a leveraged position
|
|
108
|
+
* @param request Withdraw leverage request parameters
|
|
109
|
+
* @returns Withdraw leverage operation result
|
|
110
|
+
*/
|
|
111
|
+
async withdrawLeverage(request) {
|
|
112
|
+
const response = await this.http.post("/leverage/withdraw", request);
|
|
113
|
+
// check http status code
|
|
114
|
+
handleStatusCode(response.status);
|
|
115
|
+
// parse response
|
|
116
|
+
const responseData = JSON.parse(response.data);
|
|
117
|
+
// sign and send signed tx back to api for sending to network
|
|
118
|
+
const txSig = await this.send(responseData.unsignedBase64Tx);
|
|
119
|
+
return txSig;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.Client = Client;
|
|
123
|
+
function handleStatusCode(statusCode) {
|
|
124
|
+
switch (statusCode) {
|
|
125
|
+
case 200:
|
|
126
|
+
break;
|
|
127
|
+
default:
|
|
128
|
+
throw new Error(`unexpected status code${statusCode}`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// Ensures that a provider is defined
|
|
132
|
+
function requireProvider(provider) {
|
|
133
|
+
if (provider) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
throw new Error(`provider is undefined`);
|
|
137
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { web3 } from "@coral-xyz/anchor";
|
|
2
|
+
import Decimal from "decimal.js";
|
|
3
|
+
export interface SendRequest {
|
|
4
|
+
tx: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Request to deposit collateral and create a leveraged position
|
|
8
|
+
*/
|
|
9
|
+
export interface DepositLeverageRequest {
|
|
10
|
+
owner: web3.PublicKey;
|
|
11
|
+
collateralMint: web3.PublicKey;
|
|
12
|
+
debtMint: web3.PublicKey;
|
|
13
|
+
selectedTokenMint: web3.PublicKey;
|
|
14
|
+
depositAmount: Decimal;
|
|
15
|
+
leverage: number;
|
|
16
|
+
slippagePct: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Response for deposit leverage operation
|
|
20
|
+
*/
|
|
21
|
+
export interface DepositLeverageResponse {
|
|
22
|
+
unsignedBase64Tx: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Request to modify the leverage of an existing position
|
|
26
|
+
*/
|
|
27
|
+
export interface ModifyLeverageRequest {
|
|
28
|
+
owner: web3.PublicKey;
|
|
29
|
+
collateralMint: web3.PublicKey;
|
|
30
|
+
debtMint: web3.PublicKey;
|
|
31
|
+
leverage: number;
|
|
32
|
+
slippagePct: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Response for modify leverage operation
|
|
36
|
+
*/
|
|
37
|
+
export interface ModifyLeverageResponse {
|
|
38
|
+
unsignedBase64Tx: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Request to withdraw from a leveraged position
|
|
42
|
+
*/
|
|
43
|
+
export interface WithdrawLeverageRequest {
|
|
44
|
+
owner: web3.PublicKey;
|
|
45
|
+
collateralMint: web3.PublicKey;
|
|
46
|
+
debtMint: web3.PublicKey;
|
|
47
|
+
selectedTokenMint: web3.PublicKey;
|
|
48
|
+
withdrawAmount: Decimal;
|
|
49
|
+
slippagePct: number;
|
|
50
|
+
closePosition: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Response for withdraw leverage operation
|
|
54
|
+
*/
|
|
55
|
+
export interface WithdrawLeverageResponse {
|
|
56
|
+
unsignedBase64Tx: string;
|
|
57
|
+
}
|
package/dist/types.js
ADDED
package/makefile
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@carrot-protocol/boost-http-client",
|
|
3
|
+
"version": "0.1.1-api-impl-dev-409753c",
|
|
4
|
+
"description": "HTTP client for Carrot Boost API",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"clean": "rm -rf dist node_modules *.tgz package-lock.json",
|
|
9
|
+
"build": "npm run clean && npm i && tsc && npm pack",
|
|
10
|
+
"build:dirty": "npm i && tsc && npm pack",
|
|
11
|
+
"fmt:check": "prettier --check src/",
|
|
12
|
+
"fmt": "prettier --write src/"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@coral-xyz/anchor": "^0.29.0",
|
|
16
|
+
"axios": "^1.8.3",
|
|
17
|
+
"bs58": "^6.0.0",
|
|
18
|
+
"decimal.js": "^10.5.0"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/node": "^20.11.19",
|
|
22
|
+
"prettier": "^3.2.5",
|
|
23
|
+
"typescript": "^5.3.3"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import axios, { AxiosInstance } from "axios";
|
|
2
|
+
import { AnchorProvider, web3 } from "@coral-xyz/anchor";
|
|
3
|
+
import {
|
|
4
|
+
DepositLeverageRequest,
|
|
5
|
+
DepositLeverageResponse,
|
|
6
|
+
ModifyLeverageRequest,
|
|
7
|
+
ModifyLeverageResponse,
|
|
8
|
+
SendRequest,
|
|
9
|
+
WithdrawLeverageRequest,
|
|
10
|
+
WithdrawLeverageResponse,
|
|
11
|
+
} from "./types";
|
|
12
|
+
import encode from "bs58";
|
|
13
|
+
|
|
14
|
+
// Re-export types
|
|
15
|
+
export * from "./types";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* HTTP Client for Carrot Boost API
|
|
19
|
+
*/
|
|
20
|
+
export class Client {
|
|
21
|
+
private readonly baseUrl: string;
|
|
22
|
+
private readonly http: AxiosInstance;
|
|
23
|
+
private readonly provider?: AnchorProvider;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Create a new Carrot Boost API client
|
|
27
|
+
* @param baseUrl Base URL for the API
|
|
28
|
+
*/
|
|
29
|
+
constructor(baseUrl: string, provider?: AnchorProvider) {
|
|
30
|
+
this.baseUrl = new URL(baseUrl).toString();
|
|
31
|
+
this.http = axios.create({
|
|
32
|
+
baseURL: this.baseUrl,
|
|
33
|
+
headers: {
|
|
34
|
+
"Content-Type": "application/json",
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
this.provider = provider;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// sign and send tx to api for sending to network
|
|
41
|
+
private async send(base64Tx: string): Promise<string> {
|
|
42
|
+
// error if provider is undefined
|
|
43
|
+
requireProvider(this.provider);
|
|
44
|
+
|
|
45
|
+
// deserialize into tx obj
|
|
46
|
+
const txBytes = Buffer.from(base64Tx, "base64");
|
|
47
|
+
const tx = web3.VersionedTransaction.deserialize(new Uint8Array(txBytes));
|
|
48
|
+
|
|
49
|
+
// sign tx
|
|
50
|
+
const signedTx = await this.provider!.wallet.signTransaction(tx);
|
|
51
|
+
const txSig = signedTx.signatures[0];
|
|
52
|
+
|
|
53
|
+
// encode it back to base64
|
|
54
|
+
const encodedAndSignedTx = Buffer.from(signedTx.serialize()).toString(
|
|
55
|
+
"base64",
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
// create request obj
|
|
59
|
+
const sendRequest: SendRequest = {
|
|
60
|
+
tx: encodedAndSignedTx,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// send to api
|
|
64
|
+
const response = await this.http.post(`${this.baseUrl}/send`, sendRequest);
|
|
65
|
+
handleStatusCode(response.status);
|
|
66
|
+
|
|
67
|
+
// return txsig
|
|
68
|
+
return encode.encode(txSig);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get obligation details for a wallet
|
|
73
|
+
* @param owner Owner wallet public key
|
|
74
|
+
* @returns Obligation details
|
|
75
|
+
*/
|
|
76
|
+
async getObligation(owner: web3.PublicKey): Promise<any> {
|
|
77
|
+
const response = await this.http.get(
|
|
78
|
+
`/obligation?owner=${owner.toString()}`,
|
|
79
|
+
);
|
|
80
|
+
handleStatusCode(response.status);
|
|
81
|
+
return JSON.stringify(response.data);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Deposit collateral and create a leveraged position
|
|
86
|
+
* @param request Deposit leverage request parameters
|
|
87
|
+
* @returns Deposit leverage operation result
|
|
88
|
+
*/
|
|
89
|
+
async depositLeverage(request: DepositLeverageRequest): Promise<string> {
|
|
90
|
+
const response = await this.http.post("/leverage/deposit", request);
|
|
91
|
+
|
|
92
|
+
// check http status code
|
|
93
|
+
handleStatusCode(response.status);
|
|
94
|
+
|
|
95
|
+
// parse response
|
|
96
|
+
const responseData: DepositLeverageResponse = JSON.parse(response.data);
|
|
97
|
+
|
|
98
|
+
// sign and send signed tx back to api for sending to network
|
|
99
|
+
const txSig = await this.send(responseData.unsignedBase64Tx);
|
|
100
|
+
|
|
101
|
+
return txSig;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Modify the leverage of an existing position
|
|
106
|
+
* @param request Modify leverage request parameters
|
|
107
|
+
* @returns Modify leverage operation result
|
|
108
|
+
*/
|
|
109
|
+
async modifyLeverage(request: ModifyLeverageRequest): Promise<any> {
|
|
110
|
+
const response = await this.http.post("/leverage/modify", request);
|
|
111
|
+
|
|
112
|
+
// check http status code
|
|
113
|
+
handleStatusCode(response.status);
|
|
114
|
+
|
|
115
|
+
// parse response
|
|
116
|
+
const responseData: ModifyLeverageResponse = JSON.parse(response.data);
|
|
117
|
+
|
|
118
|
+
// sign and send signed tx back to api for sending to network
|
|
119
|
+
const txSig = await this.send(responseData.unsignedBase64Tx);
|
|
120
|
+
|
|
121
|
+
return txSig;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Withdraw from or close a leveraged position
|
|
126
|
+
* @param request Withdraw leverage request parameters
|
|
127
|
+
* @returns Withdraw leverage operation result
|
|
128
|
+
*/
|
|
129
|
+
async withdrawLeverage(request: WithdrawLeverageRequest): Promise<any> {
|
|
130
|
+
const response = await this.http.post("/leverage/withdraw", request);
|
|
131
|
+
|
|
132
|
+
// check http status code
|
|
133
|
+
handleStatusCode(response.status);
|
|
134
|
+
|
|
135
|
+
// parse response
|
|
136
|
+
const responseData: WithdrawLeverageResponse = JSON.parse(response.data);
|
|
137
|
+
|
|
138
|
+
// sign and send signed tx back to api for sending to network
|
|
139
|
+
const txSig = await this.send(responseData.unsignedBase64Tx);
|
|
140
|
+
|
|
141
|
+
return txSig;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function handleStatusCode(statusCode: number): void {
|
|
146
|
+
switch (statusCode) {
|
|
147
|
+
case 200:
|
|
148
|
+
break;
|
|
149
|
+
default:
|
|
150
|
+
throw new Error(`unexpected status code${statusCode}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Ensures that a provider is defined
|
|
155
|
+
function requireProvider(provider?: AnchorProvider): void {
|
|
156
|
+
if (provider) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
throw new Error(`provider is undefined`);
|
|
160
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { BN, web3 } from "@coral-xyz/anchor";
|
|
2
|
+
import Decimal from "decimal.js";
|
|
3
|
+
|
|
4
|
+
// Represents a request to send a transaction
|
|
5
|
+
export interface SendRequest {
|
|
6
|
+
tx: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Request to deposit collateral and create a leveraged position
|
|
11
|
+
*/
|
|
12
|
+
export interface DepositLeverageRequest {
|
|
13
|
+
owner: web3.PublicKey;
|
|
14
|
+
collateralMint: web3.PublicKey;
|
|
15
|
+
debtMint: web3.PublicKey;
|
|
16
|
+
selectedTokenMint: web3.PublicKey;
|
|
17
|
+
depositAmount: Decimal;
|
|
18
|
+
leverage: number;
|
|
19
|
+
slippagePct: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Response for deposit leverage operation
|
|
24
|
+
*/
|
|
25
|
+
export interface DepositLeverageResponse {
|
|
26
|
+
unsignedBase64Tx: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Request to modify the leverage of an existing position
|
|
31
|
+
*/
|
|
32
|
+
export interface ModifyLeverageRequest {
|
|
33
|
+
owner: web3.PublicKey;
|
|
34
|
+
collateralMint: web3.PublicKey;
|
|
35
|
+
debtMint: web3.PublicKey;
|
|
36
|
+
leverage: number;
|
|
37
|
+
slippagePct: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Response for modify leverage operation
|
|
42
|
+
*/
|
|
43
|
+
export interface ModifyLeverageResponse {
|
|
44
|
+
unsignedBase64Tx: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Request to withdraw from a leveraged position
|
|
49
|
+
*/
|
|
50
|
+
export interface WithdrawLeverageRequest {
|
|
51
|
+
owner: web3.PublicKey;
|
|
52
|
+
collateralMint: web3.PublicKey;
|
|
53
|
+
debtMint: web3.PublicKey;
|
|
54
|
+
selectedTokenMint: web3.PublicKey;
|
|
55
|
+
withdrawAmount: Decimal;
|
|
56
|
+
slippagePct: number;
|
|
57
|
+
closePosition: boolean;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Response for withdraw leverage operation
|
|
62
|
+
*/
|
|
63
|
+
export interface WithdrawLeverageResponse {
|
|
64
|
+
unsignedBase64Tx: string;
|
|
65
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2020",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true
|
|
11
|
+
},
|
|
12
|
+
"include": ["src/**/*"],
|
|
13
|
+
"exclude": ["node_modules", "dist"]
|
|
14
|
+
}
|