@fereai/sdk 0.4.0-dev.31 → 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 +17 -1
- package/dist/client.js +49 -0
- package/dist/index.d.ts +1 -1
- package/dist/low-level.d.ts +29 -1
- package/dist/low-level.js +41 -0
- package/dist/types.d.ts +35 -0
- package/package.json +14 -2
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,6 +30,13 @@ 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>;
|
|
@@ -39,6 +46,12 @@ export declare class FereClient {
|
|
|
39
46
|
checkTokenSecurity(tokens: TokenToCheck[]): Promise<SecurityCheckResponse>;
|
|
40
47
|
deposit(request: DepositRequest, timeout?: number): Promise<Record<string, unknown>>;
|
|
41
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>>;
|
|
42
55
|
getWallets: () => Promise<unknown>;
|
|
43
56
|
getHoldings: () => Promise<unknown>;
|
|
44
57
|
getCredits: () => Promise<import("./types.js").CreditsInfo>;
|
|
@@ -46,6 +59,9 @@ export declare class FereClient {
|
|
|
46
59
|
getChains: () => Promise<unknown>;
|
|
47
60
|
getEarnInfo: () => Promise<unknown>;
|
|
48
61
|
getPositions: () => Promise<unknown>;
|
|
62
|
+
getPerpMarkets: (searchText?: string) => Promise<unknown>;
|
|
63
|
+
getPerpSetupStatus: () => Promise<unknown>;
|
|
64
|
+
getPerpOrders: () => Promise<unknown>;
|
|
49
65
|
getThreads: (skip?: number, limit?: number) => Promise<unknown[]>;
|
|
50
66
|
getLimitOrders: (status?: string) => Promise<unknown[]>;
|
|
51
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,
|
|
@@ -100,6 +107,45 @@ class FereClient {
|
|
|
100
107
|
});
|
|
101
108
|
}
|
|
102
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
|
+
// ----------------------------------------------------------
|
|
103
149
|
// Read-only (pass-through)
|
|
104
150
|
// ----------------------------------------------------------
|
|
105
151
|
getWallets = () => this.api.getWallets();
|
|
@@ -109,6 +155,9 @@ class FereClient {
|
|
|
109
155
|
getChains = () => this.api.getChains();
|
|
110
156
|
getEarnInfo = () => this.api.getEarnInfo();
|
|
111
157
|
getPositions = () => this.api.getPositions();
|
|
158
|
+
getPerpMarkets = (searchText) => this.api.getPerpMarkets(searchText);
|
|
159
|
+
getPerpSetupStatus = () => this.api.getPerpSetupStatus();
|
|
160
|
+
getPerpOrders = () => this.api.getPerpOrders();
|
|
112
161
|
getThreads = (skip, limit) => this.api.getThreads(skip, limit);
|
|
113
162
|
getLimitOrders = (status) => this.api.getLimitOrders(status);
|
|
114
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;
|
|
@@ -50,6 +50,34 @@ export declare class FereAPI {
|
|
|
50
50
|
timeout?: number;
|
|
51
51
|
}): Promise<TaskResponse | Record<string, unknown>>;
|
|
52
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;
|
|
53
81
|
getTask(taskId: string): Promise<TaskStatusResponse>;
|
|
54
82
|
getNotifications(opts?: {
|
|
55
83
|
limit?: number;
|
package/dist/low-level.js
CHANGED
|
@@ -224,6 +224,47 @@ class FereAPI {
|
|
|
224
224
|
return this.authedGet("/v1/earn/positions");
|
|
225
225
|
}
|
|
226
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
|
+
// ----------------------------------------------------------
|
|
227
268
|
// Tasks
|
|
228
269
|
// ----------------------------------------------------------
|
|
229
270
|
async getTask(taskId) {
|
package/dist/types.d.ts
CHANGED
|
@@ -120,6 +120,41 @@ export interface WithdrawRequest {
|
|
|
120
120
|
position_id: string;
|
|
121
121
|
amount_usdc: number;
|
|
122
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
|
+
}
|
|
123
158
|
export declare class TaskTimeoutError extends Error {
|
|
124
159
|
readonly taskId: string;
|
|
125
160
|
readonly timeout: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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",
|
|
@@ -18,6 +18,18 @@
|
|
|
18
18
|
"@types/node": "^22.0",
|
|
19
19
|
"typescript": "^5.5"
|
|
20
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
|
+
},
|
|
21
33
|
"license": "MIT",
|
|
22
|
-
"author": "Fere AI <
|
|
34
|
+
"author": "Fere AI <hello@fereai.xyz>"
|
|
23
35
|
}
|