@fereai/sdk 0.4.0 → 0.5.0-dev.45
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/README.md +5 -5
- package/dist/client.d.ts +18 -4
- package/dist/client.js +50 -3
- package/dist/index.d.ts +1 -1
- package/dist/low-level.d.ts +30 -4
- package/dist/low-level.js +42 -3
- package/dist/types.d.ts +35 -7
- package/package.json +17 -3
package/README.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @fereai/sdk
|
|
2
2
|
|
|
3
3
|
TypeScript SDK for the FereAI Gateway API.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @
|
|
8
|
+
npm install @fereai/sdk
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { FereClient } from "@
|
|
14
|
+
import { FereClient } from "@fereai/sdk";
|
|
15
15
|
|
|
16
|
-
const client = new FereClient({ apiKey: "your-api-key", baseUrl: "https://api.
|
|
16
|
+
const client = new FereClient({ apiKey: "your-api-key", baseUrl: "https://api.fereai.xyz" });
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
See the [FereAI docs](https://api.
|
|
19
|
+
See the [FereAI docs](https://api.fereai.xyz) for full API reference.
|
package/dist/client.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* });
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
import type { ChatEvent, SwapRequest, LimitOrderRequest, HooksRequest, DepositRequest, WithdrawRequest, SecurityCheckResponse, TokenToCheck, UserResponse } from "./types.js";
|
|
16
|
+
import type { ChatEvent, SwapRequest, LimitOrderRequest, HooksRequest, DepositRequest, WithdrawRequest, PerpOpenRequest, PerpCloseRequest, PerpCancelRequest, PerpFundRequest, PerpWithdrawRequest, SecurityCheckResponse, TokenToCheck, UserResponse } from "./types.js";
|
|
17
17
|
export declare class FereClient {
|
|
18
18
|
private readonly api;
|
|
19
19
|
private constructor();
|
|
@@ -30,17 +30,28 @@ export declare class FereClient {
|
|
|
30
30
|
threadId?: string;
|
|
31
31
|
agent?: string;
|
|
32
32
|
}): AsyncGenerator<ChatEvent>;
|
|
33
|
+
/**
|
|
34
|
+
* Execute a swap and wait for completion.
|
|
35
|
+
*
|
|
36
|
+
* Fully gasless for the user (no native gas token needed on any
|
|
37
|
+
* chain). One call handles same-chain, cross-chain, and EVM↔Solana
|
|
38
|
+
* bridge swaps, with bridging built in.
|
|
39
|
+
*/
|
|
33
40
|
swap(request: SwapRequest, timeout?: number): Promise<Record<string, unknown>>;
|
|
34
41
|
limitOrder(request: LimitOrderRequest, timeout?: number): Promise<Record<string, unknown>>;
|
|
35
42
|
setHooks(request: HooksRequest): Promise<unknown>;
|
|
36
43
|
/**
|
|
37
|
-
* Pre-check tokens for honeypot / scam / rug-pull flags.
|
|
38
|
-
* token is flagged and the user still wants to proceed, call
|
|
39
|
-
* `swap({ ..., bypass_security_check: true })`.
|
|
44
|
+
* Pre-check tokens for honeypot / scam / rug-pull flags.
|
|
40
45
|
*/
|
|
41
46
|
checkTokenSecurity(tokens: TokenToCheck[]): Promise<SecurityCheckResponse>;
|
|
42
47
|
deposit(request: DepositRequest, timeout?: number): Promise<Record<string, unknown>>;
|
|
43
48
|
withdraw(request: WithdrawRequest, timeout?: number): Promise<Record<string, unknown>>;
|
|
49
|
+
perpOpen(request: PerpOpenRequest, timeout?: number): Promise<Record<string, unknown>>;
|
|
50
|
+
perpClose(request: PerpCloseRequest, timeout?: number): Promise<Record<string, unknown>>;
|
|
51
|
+
perpCancelOrder(request: PerpCancelRequest, timeout?: number): Promise<Record<string, unknown>>;
|
|
52
|
+
perpSetup(forceRerun?: boolean, timeout?: number): Promise<Record<string, unknown>>;
|
|
53
|
+
perpFund(request: PerpFundRequest, timeout?: number): Promise<Record<string, unknown>>;
|
|
54
|
+
perpWithdraw(request: PerpWithdrawRequest, timeout?: number): Promise<Record<string, unknown>>;
|
|
44
55
|
getWallets: () => Promise<unknown>;
|
|
45
56
|
getHoldings: () => Promise<unknown>;
|
|
46
57
|
getCredits: () => Promise<import("./types.js").CreditsInfo>;
|
|
@@ -48,6 +59,9 @@ export declare class FereClient {
|
|
|
48
59
|
getChains: () => Promise<unknown>;
|
|
49
60
|
getEarnInfo: () => Promise<unknown>;
|
|
50
61
|
getPositions: () => Promise<unknown>;
|
|
62
|
+
getPerpMarkets: (searchText?: string) => Promise<unknown>;
|
|
63
|
+
getPerpSetupStatus: () => Promise<unknown>;
|
|
64
|
+
getPerpOrders: () => Promise<unknown>;
|
|
51
65
|
getThreads: (skip?: number, limit?: number) => Promise<unknown[]>;
|
|
52
66
|
getLimitOrders: (status?: string) => Promise<unknown[]>;
|
|
53
67
|
getNotifications: (opts?: {
|
package/dist/client.js
CHANGED
|
@@ -63,6 +63,13 @@ class FereClient {
|
|
|
63
63
|
// ----------------------------------------------------------
|
|
64
64
|
// Trading (blocks until complete)
|
|
65
65
|
// ----------------------------------------------------------
|
|
66
|
+
/**
|
|
67
|
+
* Execute a swap and wait for completion.
|
|
68
|
+
*
|
|
69
|
+
* Fully gasless for the user (no native gas token needed on any
|
|
70
|
+
* chain). One call handles same-chain, cross-chain, and EVM↔Solana
|
|
71
|
+
* bridge swaps, with bridging built in.
|
|
72
|
+
*/
|
|
66
73
|
async swap(request, timeout = DEFAULT_TIMEOUT) {
|
|
67
74
|
return this.api.createSwap(request, {
|
|
68
75
|
wait: true,
|
|
@@ -79,9 +86,7 @@ class FereClient {
|
|
|
79
86
|
return this.api.setHooks(request);
|
|
80
87
|
}
|
|
81
88
|
/**
|
|
82
|
-
* Pre-check tokens for honeypot / scam / rug-pull flags.
|
|
83
|
-
* token is flagged and the user still wants to proceed, call
|
|
84
|
-
* `swap({ ..., bypass_security_check: true })`.
|
|
89
|
+
* Pre-check tokens for honeypot / scam / rug-pull flags.
|
|
85
90
|
*/
|
|
86
91
|
async checkTokenSecurity(tokens) {
|
|
87
92
|
return this.api.checkTokenSecurity(tokens);
|
|
@@ -102,6 +107,45 @@ class FereClient {
|
|
|
102
107
|
});
|
|
103
108
|
}
|
|
104
109
|
// ----------------------------------------------------------
|
|
110
|
+
// Perp — venue-neutral perpetual futures (blocks until complete)
|
|
111
|
+
// ----------------------------------------------------------
|
|
112
|
+
async perpOpen(request, timeout = DEFAULT_TIMEOUT) {
|
|
113
|
+
return this.api.perpOpen(request, {
|
|
114
|
+
wait: true,
|
|
115
|
+
timeout,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
async perpClose(request, timeout = DEFAULT_TIMEOUT) {
|
|
119
|
+
return this.api.perpClose(request, {
|
|
120
|
+
wait: true,
|
|
121
|
+
timeout,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async perpCancelOrder(request, timeout = DEFAULT_TIMEOUT) {
|
|
125
|
+
return this.api.perpCancelOrder(request, {
|
|
126
|
+
wait: true,
|
|
127
|
+
timeout,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
async perpSetup(forceRerun = false, timeout = DEFAULT_TIMEOUT) {
|
|
131
|
+
return this.api.perpSetup(forceRerun, {
|
|
132
|
+
wait: true,
|
|
133
|
+
timeout,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
async perpFund(request, timeout = DEFAULT_TIMEOUT) {
|
|
137
|
+
return this.api.perpFund(request, {
|
|
138
|
+
wait: true,
|
|
139
|
+
timeout,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async perpWithdraw(request, timeout = DEFAULT_TIMEOUT) {
|
|
143
|
+
return this.api.perpWithdraw(request, {
|
|
144
|
+
wait: true,
|
|
145
|
+
timeout,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
// ----------------------------------------------------------
|
|
105
149
|
// Read-only (pass-through)
|
|
106
150
|
// ----------------------------------------------------------
|
|
107
151
|
getWallets = () => this.api.getWallets();
|
|
@@ -111,6 +155,9 @@ class FereClient {
|
|
|
111
155
|
getChains = () => this.api.getChains();
|
|
112
156
|
getEarnInfo = () => this.api.getEarnInfo();
|
|
113
157
|
getPositions = () => this.api.getPositions();
|
|
158
|
+
getPerpMarkets = (searchText) => this.api.getPerpMarkets(searchText);
|
|
159
|
+
getPerpSetupStatus = () => this.api.getPerpSetupStatus();
|
|
160
|
+
getPerpOrders = () => this.api.getPerpOrders();
|
|
114
161
|
getThreads = (skip, limit) => this.api.getThreads(skip, limit);
|
|
115
162
|
getLimitOrders = (status) => this.api.getLimitOrders(status);
|
|
116
163
|
getNotifications = (opts) => this.api.getNotifications(opts);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { FereAPI } from "./low-level.js";
|
|
2
2
|
export { FereClient } from "./client.js";
|
|
3
3
|
export { AuthManager } from "./auth.js";
|
|
4
|
-
export type { ChatEvent, TaskResponse, TaskStatusResponse, SwapRequest, LimitOrderRequest, HooksRequest, DepositRequest, WithdrawRequest, CreditsInfo, WalletInfo, UserResponse, TokenToCheck, SecurityCheckRequest, TokenSecurityResult, SecurityCheckSummary, SecurityCheckResponse, } from "./types.js";
|
|
4
|
+
export type { ChatEvent, TaskResponse, TaskStatusResponse, SwapRequest, LimitOrderRequest, HooksRequest, DepositRequest, WithdrawRequest, PerpOpenRequest, PerpCloseRequest, PerpCancelRequest, PerpFundRequest, PerpWithdrawRequest, CreditsInfo, WalletInfo, UserResponse, TokenToCheck, SecurityCheckRequest, TokenSecurityResult, SecurityCheckSummary, SecurityCheckResponse, } from "./types.js";
|
|
5
5
|
export { TaskTimeoutError } from "./types.js";
|
package/dist/low-level.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Low-level SDK — 1:1 typed wrappers around every gateway endpoint.
|
|
3
3
|
*/
|
|
4
|
-
import type { ChatEvent, CreditsInfo, DepositRequest, HooksRequest, LimitOrderRequest, SecurityCheckResponse, SwapRequest, TaskResponse, TaskStatusResponse, TokenToCheck, UserResponse, WithdrawRequest } from "./types.js";
|
|
4
|
+
import type { ChatEvent, CreditsInfo, DepositRequest, HooksRequest, LimitOrderRequest, PerpCancelRequest, PerpCloseRequest, PerpFundRequest, PerpOpenRequest, PerpWithdrawRequest, SecurityCheckResponse, SwapRequest, TaskResponse, TaskStatusResponse, TokenToCheck, UserResponse, WithdrawRequest } from "./types.js";
|
|
5
5
|
export declare class FereAPI {
|
|
6
6
|
private readonly baseUrl;
|
|
7
7
|
private readonly auth;
|
|
@@ -35,9 +35,7 @@ export declare class FereAPI {
|
|
|
35
35
|
setHooks(request: HooksRequest): Promise<unknown>;
|
|
36
36
|
/**
|
|
37
37
|
* Pre-check whether output tokens have been flagged by Honeypot.is
|
|
38
|
-
* (EVM) or RugCheck.xyz (Solana) before submitting a swap.
|
|
39
|
-
* token is flagged and the user still wants to proceed, set
|
|
40
|
-
* `bypass_security_check: true` on the swap request.
|
|
38
|
+
* (EVM) or RugCheck.xyz (Solana) before submitting a swap.
|
|
41
39
|
*/
|
|
42
40
|
checkTokenSecurity(tokens: TokenToCheck[]): Promise<SecurityCheckResponse>;
|
|
43
41
|
getWallets(): Promise<unknown>;
|
|
@@ -52,6 +50,34 @@ export declare class FereAPI {
|
|
|
52
50
|
timeout?: number;
|
|
53
51
|
}): Promise<TaskResponse | Record<string, unknown>>;
|
|
54
52
|
getPositions(): Promise<unknown>;
|
|
53
|
+
getPerpMarkets(searchText?: string): Promise<unknown>;
|
|
54
|
+
getPerpSetupStatus(): Promise<unknown>;
|
|
55
|
+
getPerpOrders(): Promise<unknown>;
|
|
56
|
+
perpSetup(forceRerun?: boolean, opts?: {
|
|
57
|
+
wait?: boolean;
|
|
58
|
+
timeout?: number;
|
|
59
|
+
}): Promise<TaskResponse | Record<string, unknown>>;
|
|
60
|
+
perpOpen(request: PerpOpenRequest, opts?: {
|
|
61
|
+
wait?: boolean;
|
|
62
|
+
timeout?: number;
|
|
63
|
+
}): Promise<TaskResponse | Record<string, unknown>>;
|
|
64
|
+
perpClose(request: PerpCloseRequest, opts?: {
|
|
65
|
+
wait?: boolean;
|
|
66
|
+
timeout?: number;
|
|
67
|
+
}): Promise<TaskResponse | Record<string, unknown>>;
|
|
68
|
+
perpCancelOrder(request: PerpCancelRequest, opts?: {
|
|
69
|
+
wait?: boolean;
|
|
70
|
+
timeout?: number;
|
|
71
|
+
}): Promise<TaskResponse | Record<string, unknown>>;
|
|
72
|
+
perpFund(request: PerpFundRequest, opts?: {
|
|
73
|
+
wait?: boolean;
|
|
74
|
+
timeout?: number;
|
|
75
|
+
}): Promise<TaskResponse | Record<string, unknown>>;
|
|
76
|
+
perpWithdraw(request: PerpWithdrawRequest, opts?: {
|
|
77
|
+
wait?: boolean;
|
|
78
|
+
timeout?: number;
|
|
79
|
+
}): Promise<TaskResponse | Record<string, unknown>>;
|
|
80
|
+
private perpTask;
|
|
55
81
|
getTask(taskId: string): Promise<TaskStatusResponse>;
|
|
56
82
|
getNotifications(opts?: {
|
|
57
83
|
limit?: number;
|
package/dist/low-level.js
CHANGED
|
@@ -179,9 +179,7 @@ class FereAPI {
|
|
|
179
179
|
// ----------------------------------------------------------
|
|
180
180
|
/**
|
|
181
181
|
* Pre-check whether output tokens have been flagged by Honeypot.is
|
|
182
|
-
* (EVM) or RugCheck.xyz (Solana) before submitting a swap.
|
|
183
|
-
* token is flagged and the user still wants to proceed, set
|
|
184
|
-
* `bypass_security_check: true` on the swap request.
|
|
182
|
+
* (EVM) or RugCheck.xyz (Solana) before submitting a swap.
|
|
185
183
|
*/
|
|
186
184
|
async checkTokenSecurity(tokens) {
|
|
187
185
|
return this.authedPost("/v1/security/check", {
|
|
@@ -226,6 +224,47 @@ class FereAPI {
|
|
|
226
224
|
return this.authedGet("/v1/earn/positions");
|
|
227
225
|
}
|
|
228
226
|
// ----------------------------------------------------------
|
|
227
|
+
// Perp (venue-neutral perpetual futures)
|
|
228
|
+
// ----------------------------------------------------------
|
|
229
|
+
async getPerpMarkets(searchText) {
|
|
230
|
+
const params = {};
|
|
231
|
+
if (searchText)
|
|
232
|
+
params.search_text = searchText;
|
|
233
|
+
return this.authedGet("/v1/perp/markets", params);
|
|
234
|
+
}
|
|
235
|
+
async getPerpSetupStatus() {
|
|
236
|
+
return this.authedGet("/v1/perp/setup");
|
|
237
|
+
}
|
|
238
|
+
async getPerpOrders() {
|
|
239
|
+
return this.authedGet("/v1/perp/orders");
|
|
240
|
+
}
|
|
241
|
+
async perpSetup(forceRerun = false, opts) {
|
|
242
|
+
return this.perpTask("/v1/perp/setup", { force_rerun: forceRerun }, opts);
|
|
243
|
+
}
|
|
244
|
+
async perpOpen(request, opts) {
|
|
245
|
+
return this.perpTask("/v1/perp/open", request, opts);
|
|
246
|
+
}
|
|
247
|
+
async perpClose(request, opts) {
|
|
248
|
+
return this.perpTask("/v1/perp/close", request, opts);
|
|
249
|
+
}
|
|
250
|
+
async perpCancelOrder(request, opts) {
|
|
251
|
+
return this.perpTask("/v1/perp/orders/cancel", request, opts);
|
|
252
|
+
}
|
|
253
|
+
async perpFund(request, opts) {
|
|
254
|
+
return this.perpTask("/v1/perp/fund", request, opts);
|
|
255
|
+
}
|
|
256
|
+
async perpWithdraw(request, opts) {
|
|
257
|
+
return this.perpTask("/v1/perp/withdraw", request, opts);
|
|
258
|
+
}
|
|
259
|
+
async perpTask(path, body, opts) {
|
|
260
|
+
const params = {};
|
|
261
|
+
if (opts?.wait) {
|
|
262
|
+
params.wait = "true";
|
|
263
|
+
params.timeout = String(opts.timeout ?? 120);
|
|
264
|
+
}
|
|
265
|
+
return this.authedPost(path, body, params);
|
|
266
|
+
}
|
|
267
|
+
// ----------------------------------------------------------
|
|
229
268
|
// Tasks
|
|
230
269
|
// ----------------------------------------------------------
|
|
231
270
|
async getTask(taskId) {
|
package/dist/types.d.ts
CHANGED
|
@@ -55,13 +55,6 @@ export interface SwapRequest {
|
|
|
55
55
|
sell_percentage: number;
|
|
56
56
|
};
|
|
57
57
|
cancel_conditional_orders?: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Skip the in-task rug-check entirely. Set true only after
|
|
60
|
-
* pre-checking the output token via checkTokenSecurity and
|
|
61
|
-
* surfacing the verdict to your end user. Has no effect on
|
|
62
|
-
* scheduled trades.
|
|
63
|
-
*/
|
|
64
|
-
bypass_security_check?: boolean;
|
|
65
58
|
}
|
|
66
59
|
export interface TokenToCheck {
|
|
67
60
|
token_address: string;
|
|
@@ -127,6 +120,41 @@ export interface WithdrawRequest {
|
|
|
127
120
|
position_id: string;
|
|
128
121
|
amount_usdc: number;
|
|
129
122
|
}
|
|
123
|
+
export interface PerpOpenRequest {
|
|
124
|
+
asset: string;
|
|
125
|
+
is_buy: boolean;
|
|
126
|
+
size: number;
|
|
127
|
+
leverage?: number;
|
|
128
|
+
is_cross?: boolean;
|
|
129
|
+
order_type?: "market" | "limit";
|
|
130
|
+
limit_price?: number;
|
|
131
|
+
slippage_pct?: number;
|
|
132
|
+
reduce_only?: boolean;
|
|
133
|
+
tp_price?: number;
|
|
134
|
+
sl_price?: number;
|
|
135
|
+
tp_is_market?: boolean;
|
|
136
|
+
sl_is_market?: boolean;
|
|
137
|
+
}
|
|
138
|
+
export interface PerpCloseRequest {
|
|
139
|
+
asset: string;
|
|
140
|
+
size?: number;
|
|
141
|
+
slippage_pct?: number;
|
|
142
|
+
}
|
|
143
|
+
export interface PerpCancelRequest {
|
|
144
|
+
asset: string;
|
|
145
|
+
order_id: number;
|
|
146
|
+
}
|
|
147
|
+
export interface PerpFundRequest {
|
|
148
|
+
amount: string;
|
|
149
|
+
source_chain_id: number;
|
|
150
|
+
source_token?: string;
|
|
151
|
+
display_amount_usd?: number;
|
|
152
|
+
}
|
|
153
|
+
export interface PerpWithdrawRequest {
|
|
154
|
+
amount_usd: number;
|
|
155
|
+
destination_chain_id: number;
|
|
156
|
+
destination_token?: string;
|
|
157
|
+
}
|
|
130
158
|
export declare class TaskTimeoutError extends Error {
|
|
131
159
|
readonly taskId: string;
|
|
132
160
|
readonly timeout: number;
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fereai/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-dev.45",
|
|
4
4
|
"description": "TypeScript SDK for the FereAI Gateway API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
8
10
|
"scripts": {
|
|
9
11
|
"build": "tsc",
|
|
10
12
|
"prepublishOnly": "tsc"
|
|
@@ -16,6 +18,18 @@
|
|
|
16
18
|
"@types/node": "^22.0",
|
|
17
19
|
"typescript": "^5.5"
|
|
18
20
|
},
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": "22.x"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/fere-ai/all-in-one.git",
|
|
27
|
+
"directory": "gateway_service/sdks/typescript"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public",
|
|
31
|
+
"registry": "https://registry.npmjs.org/"
|
|
32
|
+
},
|
|
19
33
|
"license": "MIT",
|
|
20
|
-
"author": "Fere AI <
|
|
34
|
+
"author": "Fere AI <hello@fereai.xyz>"
|
|
21
35
|
}
|