@primuslabs/por-client-sdk 0.1.1 → 0.1.2
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 +74 -40
- package/dist/cli.js +17 -3
- package/dist/cli.js.map +1 -1
- package/dist/client/data_service_client.d.ts +1 -0
- package/dist/client/data_service_client.js +1 -0
- package/dist/client/data_service_client.js.map +1 -1
- package/dist/client/por_client.d.ts +3 -3
- package/dist/client/por_client.js +16 -12
- package/dist/client/por_client.js.map +1 -1
- package/dist/client/prover_client.d.ts +12 -6
- package/dist/client/prover_client.js +14 -17
- package/dist/client/prover_client.js.map +1 -1
- package/dist/client/zktls_client.d.ts +3 -3
- package/dist/client/zktls_client.js +38 -27
- package/dist/client/zktls_client.js.map +1 -1
- package/dist/config_schema.d.ts +167 -0
- package/dist/config_schema.js +88 -0
- package/dist/config_schema.js.map +1 -0
- package/dist/datasource/aster.d.ts +24 -0
- package/dist/datasource/aster.js +51 -0
- package/dist/datasource/aster.js.map +1 -0
- package/dist/datasource/base_exchange.d.ts +9 -0
- package/dist/datasource/base_exchange.js +13 -0
- package/dist/datasource/base_exchange.js.map +1 -0
- package/dist/datasource/binance.d.ts +40 -13
- package/dist/datasource/binance.js +46 -39
- package/dist/datasource/binance.js.map +1 -1
- package/dist/datasource/exchange_manager.d.ts +15 -0
- package/dist/datasource/exchange_manager.js +20 -0
- package/dist/datasource/exchange_manager.js.map +1 -0
- package/dist/datasource/helper.d.ts +1 -0
- package/dist/datasource/helper.js +6 -0
- package/dist/datasource/helper.js.map +1 -1
- package/dist/datasource/index.d.ts +2 -0
- package/dist/datasource/index.js +2 -0
- package/dist/datasource/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +3 -2
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +6 -3
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export type Exchanges = "binance" | "aster";
|
|
3
|
+
declare const BinanceKindSchema: z.ZodEnum<{
|
|
4
|
+
spot: "spot";
|
|
5
|
+
"usds-futures": "usds-futures";
|
|
6
|
+
"coin-futures": "coin-futures";
|
|
7
|
+
unified: "unified";
|
|
8
|
+
}>;
|
|
9
|
+
declare const AsterKindSchema: z.ZodEnum<{
|
|
10
|
+
spot: "spot";
|
|
11
|
+
"usds-futures": "usds-futures";
|
|
12
|
+
}>;
|
|
13
|
+
export type AsterKind = z.infer<typeof AsterKindSchema>;
|
|
14
|
+
export type BinanceKind = z.infer<typeof BinanceKindSchema>;
|
|
15
|
+
export declare const BinanceAccountSchema: z.ZodObject<{
|
|
16
|
+
apiKey: z.ZodString;
|
|
17
|
+
apiSecret: z.ZodString;
|
|
18
|
+
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
19
|
+
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
20
|
+
kind: z.ZodArray<z.ZodEnum<{
|
|
21
|
+
spot: "spot";
|
|
22
|
+
"usds-futures": "usds-futures";
|
|
23
|
+
"coin-futures": "coin-futures";
|
|
24
|
+
unified: "unified";
|
|
25
|
+
}>>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type BinanceAccount = z.infer<typeof BinanceAccountSchema>;
|
|
28
|
+
export declare const AsterAccountSchema: z.ZodObject<{
|
|
29
|
+
apiKey: z.ZodString;
|
|
30
|
+
apiSecret: z.ZodString;
|
|
31
|
+
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
32
|
+
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
33
|
+
kind: z.ZodArray<z.ZodEnum<{
|
|
34
|
+
spot: "spot";
|
|
35
|
+
"usds-futures": "usds-futures";
|
|
36
|
+
}>>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
export type AsterAccount = z.infer<typeof AsterAccountSchema>;
|
|
39
|
+
declare const AppConfigSchema: z.ZodObject<{
|
|
40
|
+
identity: z.ZodObject<{
|
|
41
|
+
token: z.ZodString;
|
|
42
|
+
projectId: z.ZodString;
|
|
43
|
+
programId: z.ZodString;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
runtime: z.ZodObject<{
|
|
46
|
+
version: z.ZodString;
|
|
47
|
+
env: z.ZodDefault<z.ZodEnum<{
|
|
48
|
+
development: "development";
|
|
49
|
+
production: "production";
|
|
50
|
+
}>>;
|
|
51
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
52
|
+
POR: "POR";
|
|
53
|
+
DVC: "DVC";
|
|
54
|
+
}>>;
|
|
55
|
+
logVerbose: z.ZodDefault<z.ZodNumber>;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
services: z.ZodObject<{
|
|
58
|
+
zkvm: z.ZodObject<{
|
|
59
|
+
url: z.ZodURL;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
data: z.ZodObject<{
|
|
62
|
+
url: z.ZodURL;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
blockchain: z.ZodObject<{
|
|
66
|
+
network: z.ZodDefault<z.ZodEnum<{
|
|
67
|
+
base: "base";
|
|
68
|
+
"base-sepolia": "base-sepolia";
|
|
69
|
+
}>>;
|
|
70
|
+
rpcUrl: z.ZodOptional<z.ZodURL>;
|
|
71
|
+
signer: z.ZodOptional<z.ZodObject<{
|
|
72
|
+
privateKey: z.ZodString;
|
|
73
|
+
}, z.core.$strip>>;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
declare const ExchangesConfigSchema: z.ZodObject<{
|
|
77
|
+
binance: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
78
|
+
apiKey: z.ZodString;
|
|
79
|
+
apiSecret: z.ZodString;
|
|
80
|
+
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
81
|
+
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
82
|
+
kind: z.ZodArray<z.ZodEnum<{
|
|
83
|
+
spot: "spot";
|
|
84
|
+
"usds-futures": "usds-futures";
|
|
85
|
+
"coin-futures": "coin-futures";
|
|
86
|
+
unified: "unified";
|
|
87
|
+
}>>;
|
|
88
|
+
}, z.core.$strip>>>;
|
|
89
|
+
aster: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
90
|
+
apiKey: z.ZodString;
|
|
91
|
+
apiSecret: z.ZodString;
|
|
92
|
+
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
93
|
+
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
94
|
+
kind: z.ZodArray<z.ZodEnum<{
|
|
95
|
+
spot: "spot";
|
|
96
|
+
"usds-futures": "usds-futures";
|
|
97
|
+
}>>;
|
|
98
|
+
}, z.core.$strip>>>;
|
|
99
|
+
}, z.core.$strict>;
|
|
100
|
+
declare const ConfigSchema: z.ZodObject<{
|
|
101
|
+
app: z.ZodObject<{
|
|
102
|
+
identity: z.ZodObject<{
|
|
103
|
+
token: z.ZodString;
|
|
104
|
+
projectId: z.ZodString;
|
|
105
|
+
programId: z.ZodString;
|
|
106
|
+
}, z.core.$strip>;
|
|
107
|
+
runtime: z.ZodObject<{
|
|
108
|
+
version: z.ZodString;
|
|
109
|
+
env: z.ZodDefault<z.ZodEnum<{
|
|
110
|
+
development: "development";
|
|
111
|
+
production: "production";
|
|
112
|
+
}>>;
|
|
113
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
114
|
+
POR: "POR";
|
|
115
|
+
DVC: "DVC";
|
|
116
|
+
}>>;
|
|
117
|
+
logVerbose: z.ZodDefault<z.ZodNumber>;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
services: z.ZodObject<{
|
|
120
|
+
zkvm: z.ZodObject<{
|
|
121
|
+
url: z.ZodURL;
|
|
122
|
+
}, z.core.$strip>;
|
|
123
|
+
data: z.ZodObject<{
|
|
124
|
+
url: z.ZodURL;
|
|
125
|
+
}, z.core.$strip>;
|
|
126
|
+
}, z.core.$strip>;
|
|
127
|
+
blockchain: z.ZodObject<{
|
|
128
|
+
network: z.ZodDefault<z.ZodEnum<{
|
|
129
|
+
base: "base";
|
|
130
|
+
"base-sepolia": "base-sepolia";
|
|
131
|
+
}>>;
|
|
132
|
+
rpcUrl: z.ZodOptional<z.ZodURL>;
|
|
133
|
+
signer: z.ZodOptional<z.ZodObject<{
|
|
134
|
+
privateKey: z.ZodString;
|
|
135
|
+
}, z.core.$strip>>;
|
|
136
|
+
}, z.core.$strip>;
|
|
137
|
+
}, z.core.$strip>;
|
|
138
|
+
exchanges: z.ZodObject<{
|
|
139
|
+
binance: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
140
|
+
apiKey: z.ZodString;
|
|
141
|
+
apiSecret: z.ZodString;
|
|
142
|
+
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
143
|
+
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
144
|
+
kind: z.ZodArray<z.ZodEnum<{
|
|
145
|
+
spot: "spot";
|
|
146
|
+
"usds-futures": "usds-futures";
|
|
147
|
+
"coin-futures": "coin-futures";
|
|
148
|
+
unified: "unified";
|
|
149
|
+
}>>;
|
|
150
|
+
}, z.core.$strip>>>;
|
|
151
|
+
aster: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
152
|
+
apiKey: z.ZodString;
|
|
153
|
+
apiSecret: z.ZodString;
|
|
154
|
+
enabled: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
155
|
+
description: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
156
|
+
kind: z.ZodArray<z.ZodEnum<{
|
|
157
|
+
spot: "spot";
|
|
158
|
+
"usds-futures": "usds-futures";
|
|
159
|
+
}>>;
|
|
160
|
+
}, z.core.$strip>>>;
|
|
161
|
+
}, z.core.$strict>;
|
|
162
|
+
}, z.core.$strip>;
|
|
163
|
+
export type AppConfig = z.infer<typeof AppConfigSchema>;
|
|
164
|
+
export type ExchangesConfig = z.infer<typeof ExchangesConfigSchema>;
|
|
165
|
+
export type Config = z.infer<typeof ConfigSchema>;
|
|
166
|
+
export declare function loadConfigFromFile(filePath?: string): Config;
|
|
167
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import yaml from "js-yaml";
|
|
5
|
+
const BinanceKindSchema = z.enum(["spot", "usds-futures", "coin-futures", "unified"]);
|
|
6
|
+
const AsterKindSchema = z.enum(["spot", "usds-futures"]);
|
|
7
|
+
const BaseAccountSchema = z.object({
|
|
8
|
+
apiKey: z.string().min(1),
|
|
9
|
+
apiSecret: z.string().min(1),
|
|
10
|
+
enabled: z.boolean().optional().default(true),
|
|
11
|
+
description: z.string().optional().default(""),
|
|
12
|
+
});
|
|
13
|
+
const AccountSchema = (kind) => BaseAccountSchema.extend({
|
|
14
|
+
kind: z.array(kind).min(1).refine(arr => new Set(arr).size === arr.length, { message: "kind must be unique" }),
|
|
15
|
+
});
|
|
16
|
+
export const BinanceAccountSchema = AccountSchema(BinanceKindSchema);
|
|
17
|
+
export const AsterAccountSchema = AccountSchema(AsterKindSchema);
|
|
18
|
+
const AppIdentitySchema = z.object({
|
|
19
|
+
token: z.string().min(1),
|
|
20
|
+
projectId: z.string().min(1),
|
|
21
|
+
programId: z.string().min(1),
|
|
22
|
+
});
|
|
23
|
+
const AppRuntimeSchema = z.object({
|
|
24
|
+
version: z.string().regex(/^\d+\.\d+\.\d+$/),
|
|
25
|
+
env: z.enum(["development", "production"]).default("production"),
|
|
26
|
+
mode: z.enum(["POR", "DVC"]).default("POR"),
|
|
27
|
+
logVerbose: z.number().int().min(0).max(5).default(0),
|
|
28
|
+
});
|
|
29
|
+
const ZkvmServiceSchema = z.object({
|
|
30
|
+
url: z.url(),
|
|
31
|
+
});
|
|
32
|
+
const DataServiceSchema = z.object({
|
|
33
|
+
url: z.url(),
|
|
34
|
+
});
|
|
35
|
+
const AppServicesSchema = z.object({
|
|
36
|
+
zkvm: ZkvmServiceSchema,
|
|
37
|
+
data: DataServiceSchema,
|
|
38
|
+
});
|
|
39
|
+
const BlockchainSignerSchema = z.object({
|
|
40
|
+
privateKey: z.string(),
|
|
41
|
+
});
|
|
42
|
+
const BlockchainSchema = z.object({
|
|
43
|
+
network: z.enum(["base", "base-sepolia"]).default("base"),
|
|
44
|
+
rpcUrl: z.url().optional(),
|
|
45
|
+
signer: BlockchainSignerSchema.optional(),
|
|
46
|
+
});
|
|
47
|
+
const AppConfigSchema = z.object({
|
|
48
|
+
identity: AppIdentitySchema,
|
|
49
|
+
runtime: AppRuntimeSchema,
|
|
50
|
+
services: AppServicesSchema,
|
|
51
|
+
blockchain: BlockchainSchema,
|
|
52
|
+
});
|
|
53
|
+
const ExchangesConfigSchema = z.object({
|
|
54
|
+
binance: z.array(BinanceAccountSchema).optional(),
|
|
55
|
+
aster: z.array(AsterAccountSchema).optional(),
|
|
56
|
+
}).strict().refine((data) => (data.binance?.length ?? 0) > 0 || (data.aster?.length ?? 0) > 0, {
|
|
57
|
+
message: "At least one exchange account of [binance,aster] must be configured",
|
|
58
|
+
path: ["exchanges"],
|
|
59
|
+
});
|
|
60
|
+
const ConfigSchema = z.object({
|
|
61
|
+
app: AppConfigSchema,
|
|
62
|
+
exchanges: ExchangesConfigSchema,
|
|
63
|
+
}).refine((data) => {
|
|
64
|
+
if (data.app.runtime.mode === "DVC" && !data.app.blockchain.signer) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}, {
|
|
69
|
+
message: "signer is required when mode is DVC",
|
|
70
|
+
path: ["app", "blockchain", "signer"],
|
|
71
|
+
});
|
|
72
|
+
export function loadConfigFromFile(filePath = ".config.yml") {
|
|
73
|
+
const absolutePath = path.resolve(filePath);
|
|
74
|
+
if (!fs.existsSync(absolutePath)) {
|
|
75
|
+
throw new Error(`Config file not found: ${absolutePath}`);
|
|
76
|
+
}
|
|
77
|
+
const raw = fs.readFileSync(absolutePath, "utf-8");
|
|
78
|
+
let parsed;
|
|
79
|
+
try {
|
|
80
|
+
parsed = yaml.load(raw);
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
throw new Error(`Failed to parse JSON config: ${err.message}`);
|
|
84
|
+
}
|
|
85
|
+
const config = ConfigSchema.parse(parsed);
|
|
86
|
+
return config;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=config_schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config_schema.js","sourceRoot":"","sources":["../src/config_schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,IAAI,MAAM,SAAS,CAAC;AAI3B,MAAM,iBAAiB,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC;AACtF,MAAM,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;AAIzD,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACzB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC;IAC7C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;CAC/C,CAA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AC,OAAO,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { VERIFY_TYPE, RequestParamsOutput } from "../types.js";
|
|
2
|
+
import { AsterKind, AsterAccount, ExchangesConfig } from "../config_schema.js";
|
|
3
|
+
import { BaseExchange } from "./base_exchange.js";
|
|
4
|
+
export declare class Aster extends BaseExchange<AsterAccount, AsterKind> {
|
|
5
|
+
constructor(accounts?: ExchangesConfig["aster"]);
|
|
6
|
+
get hasSpot(): boolean;
|
|
7
|
+
get hasUsdSFutures(): boolean;
|
|
8
|
+
get spotAccounts(): {
|
|
9
|
+
apiKey: string;
|
|
10
|
+
apiSecret: string;
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
description: string;
|
|
13
|
+
kind: ("spot" | "usds-futures")[];
|
|
14
|
+
}[];
|
|
15
|
+
get usdSFuturesAccounts(): {
|
|
16
|
+
apiKey: string;
|
|
17
|
+
apiSecret: string;
|
|
18
|
+
enabled: boolean;
|
|
19
|
+
description: string;
|
|
20
|
+
kind: ("spot" | "usds-futures")[];
|
|
21
|
+
}[];
|
|
22
|
+
getSpotAccountRequests(verifyType?: VERIFY_TYPE): RequestParamsOutput;
|
|
23
|
+
getUsdSFutureBalanceRequests(verifyType?: VERIFY_TYPE): RequestParamsOutput;
|
|
24
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { makeHashComparisonParams, signQuery } from "./helper.js";
|
|
2
|
+
import { BaseExchange } from "./base_exchange.js";
|
|
3
|
+
// TODO: make as utility
|
|
4
|
+
function makerAsterOrigRequests(url, accounts, params = {}) {
|
|
5
|
+
const recvWindow = 60; // Number(process.env.RECV_WINDOW) || 60;
|
|
6
|
+
let signParams = { ...params, recvWindow: recvWindow * 1000 };
|
|
7
|
+
let origRequests = [];
|
|
8
|
+
for (const acc of accounts) {
|
|
9
|
+
const timestamp = Date.now();
|
|
10
|
+
const query = signQuery(acc.apiSecret, { ...signParams, timestamp });
|
|
11
|
+
const origRequest = {
|
|
12
|
+
url: `${url}?${query}`,
|
|
13
|
+
headers: { "X-MBX-APIKEY": acc.apiKey }
|
|
14
|
+
};
|
|
15
|
+
origRequests.push(origRequest);
|
|
16
|
+
}
|
|
17
|
+
return origRequests;
|
|
18
|
+
}
|
|
19
|
+
export class Aster extends BaseExchange {
|
|
20
|
+
constructor(accounts) {
|
|
21
|
+
super(accounts);
|
|
22
|
+
}
|
|
23
|
+
get hasSpot() { return this.spotAccounts.length > 0; }
|
|
24
|
+
get hasUsdSFutures() { return this.usdSFuturesAccounts.length > 0; }
|
|
25
|
+
get spotAccounts() { return this.getAccounts("spot"); }
|
|
26
|
+
get usdSFuturesAccounts() { return this.getAccounts("usds-futures"); }
|
|
27
|
+
///
|
|
28
|
+
/// =======================================================================
|
|
29
|
+
///
|
|
30
|
+
/// TODO: more general interfaces
|
|
31
|
+
/// a map for any api
|
|
32
|
+
/// doc: https://github.com/asterdex/api-docs/blob/master/aster-finance-spot-api.md#account-information-user_data
|
|
33
|
+
/// api: https://sapi.asterdex.com/api/v1/account
|
|
34
|
+
getSpotAccountRequests(verifyType = 'HASH_COMPARISON') {
|
|
35
|
+
if (!this.hasSpot)
|
|
36
|
+
return undefined;
|
|
37
|
+
const url = "https://sapi.asterdex.com/api/v1/account";
|
|
38
|
+
const origRequests = makerAsterOrigRequests(url, this.spotAccounts);
|
|
39
|
+
return makeHashComparisonParams(origRequests, verifyType);
|
|
40
|
+
}
|
|
41
|
+
/// doc: https://github.com/asterdex/api-docs/blob/master/aster-finance-futures-api.md#futures-account-balance-v2-user_data
|
|
42
|
+
/// api: https://fapi.asterdex.com/fapi/v2/balance
|
|
43
|
+
getUsdSFutureBalanceRequests(verifyType = 'HASH_COMPARISON') {
|
|
44
|
+
if (!this.hasUsdSFutures)
|
|
45
|
+
return undefined;
|
|
46
|
+
const url = "https://fapi.asterdex.com/fapi/v2/balance";
|
|
47
|
+
const origRequests = makerAsterOrigRequests(url, this.usdSFuturesAccounts);
|
|
48
|
+
return makeHashComparisonParams(origRequests, verifyType);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=aster.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aster.js","sourceRoot":"","sources":["../../src/datasource/aster.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,wBAAwB;AACxB,SAAS,sBAAsB,CAAC,GAAW,EAAE,QAAwB,EAAE,MAAM,GAAG,EAAE;IAChF,MAAM,UAAU,GAAG,EAAE,CAAC,CAAC,yCAAyC;IAChE,IAAI,UAAU,GAAG,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,EAAE,CAAC;IAE9D,IAAI,YAAY,GAAG,EAAE,CAAA;IACrB,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,GAAG,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC;QAErE,MAAM,WAAW,GAAG;YAClB,GAAG,EAAE,GAAG,GAAG,IAAI,KAAK,EAAE;YACtB,OAAO,EAAE,EAAE,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE;SACxC,CAAC;QAEF,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAGD,MAAM,OAAO,KAAM,SAAQ,YAAqC;IAC9D,YAAY,QAAmC;QAC7C,KAAK,CAAC,QAAQ,CAAC,CAA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accounts: readonly T[];
|
|
6
|
+
protected readonly recvWindow: number;
|
|
7
|
+
constructor(accounts?: readonly T[]);
|
|
8
|
+
protected getAccounts(kind?: K): T[];
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class BaseExchange {
|
|
2
|
+
accounts;
|
|
3
|
+
recvWindow = 60;
|
|
4
|
+
constructor(accounts) {
|
|
5
|
+
this.accounts = (accounts ?? []).filter(acc => acc.enabled ?? true); // only enabled account
|
|
6
|
+
}
|
|
7
|
+
getAccounts(kind) {
|
|
8
|
+
if (!kind)
|
|
9
|
+
return [...this.accounts];
|
|
10
|
+
return this.accounts.filter(acc => acc.kind.includes(kind));
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=base_exchange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base_exchange.js","sourceRoot":"","sources":["../../src/datasource/base_exchange.ts"],"names":[],"mappings":"AAAA,MAAM,OAAgB,YAAY;IAIb,QAAQ,CAAe;IACvB,UAAU,GAAW,EAAE,CAAC;IAE3C,YAAY,QAAuB;QACjC,IAAI,CAAC,QAAQ,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,uBAAuB;IAC9F,CAAC;IAES,WAAW,CAAC,IAAQ;QAC5B,IAAI,CAAC,IAAI;YAAE,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF"}
|
|
@@ -1,14 +1,41 @@
|
|
|
1
|
-
import { VERIFY_TYPE,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { VERIFY_TYPE, RequestParamsOutput } from "../types.js";
|
|
2
|
+
import { BinanceKind, BinanceAccount, ExchangesConfig } from "../config_schema.js";
|
|
3
|
+
import { BaseExchange } from "./base_exchange.js";
|
|
4
|
+
export declare class Binance extends BaseExchange<BinanceAccount, BinanceKind> {
|
|
5
|
+
constructor(accounts?: ExchangesConfig["binance"]);
|
|
6
|
+
get hasSpot(): boolean;
|
|
7
|
+
get hasUsdSFutures(): boolean;
|
|
8
|
+
get hasCoinFutures(): boolean;
|
|
9
|
+
get hasUnified(): boolean;
|
|
10
|
+
get spotAccounts(): {
|
|
11
|
+
apiKey: string;
|
|
12
|
+
apiSecret: string;
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
description: string;
|
|
15
|
+
kind: ("spot" | "usds-futures" | "coin-futures" | "unified")[];
|
|
16
|
+
}[];
|
|
17
|
+
get usdSFuturesAccounts(): {
|
|
18
|
+
apiKey: string;
|
|
19
|
+
apiSecret: string;
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
description: string;
|
|
22
|
+
kind: ("spot" | "usds-futures" | "coin-futures" | "unified")[];
|
|
23
|
+
}[];
|
|
24
|
+
get coinFuturesAccounts(): {
|
|
25
|
+
apiKey: string;
|
|
26
|
+
apiSecret: string;
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
description: string;
|
|
29
|
+
kind: ("spot" | "usds-futures" | "coin-futures" | "unified")[];
|
|
30
|
+
}[];
|
|
31
|
+
get unifiedAccounts(): {
|
|
32
|
+
apiKey: string;
|
|
33
|
+
apiSecret: string;
|
|
34
|
+
enabled: boolean;
|
|
35
|
+
description: string;
|
|
36
|
+
kind: ("spot" | "usds-futures" | "coin-futures" | "unified")[];
|
|
37
|
+
}[];
|
|
38
|
+
getSpotAccountInfoRequests(verifyType?: VERIFY_TYPE): RequestParamsOutput;
|
|
39
|
+
getUsdSFutureAccountBalanceV3Requests(verifyType?: VERIFY_TYPE): RequestParamsOutput;
|
|
40
|
+
getUnifiedAccountBalanceRequests(verifyType?: VERIFY_TYPE): RequestParamsOutput;
|
|
14
41
|
}
|
|
@@ -1,55 +1,62 @@
|
|
|
1
1
|
import ccxt from "ccxt";
|
|
2
2
|
import { makeHashComparisonParams } from "./helper.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.recvWindow = Number(process.env.BINANCE_RECV_WINDOW || 60) * 1000;
|
|
8
|
-
this.accounts = this.loadAccounts();
|
|
3
|
+
import { BaseExchange } from "./base_exchange.js";
|
|
4
|
+
export class Binance extends BaseExchange {
|
|
5
|
+
constructor(accounts) {
|
|
6
|
+
super(accounts);
|
|
9
7
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
8
|
+
get hasSpot() { return this.spotAccounts.length > 0; }
|
|
9
|
+
get hasUsdSFutures() { return this.usdSFuturesAccounts.length > 0; }
|
|
10
|
+
get hasCoinFutures() { return this.coinFuturesAccounts.length > 0; }
|
|
11
|
+
get hasUnified() { return this.unifiedAccounts.length > 0; }
|
|
12
|
+
get spotAccounts() { return this.getAccounts("spot"); }
|
|
13
|
+
get usdSFuturesAccounts() { return this.getAccounts("usds-futures"); }
|
|
14
|
+
get coinFuturesAccounts() { return this.getAccounts("coin-futures"); }
|
|
15
|
+
get unifiedAccounts() { return this.getAccounts("unified"); }
|
|
16
|
+
///
|
|
17
|
+
/// =======================================================================
|
|
18
|
+
///
|
|
19
|
+
/// TODO: more general interfaces
|
|
20
|
+
/// a map for any api
|
|
21
|
+
/// doc: https://developers.binance.com/docs/binance-spot-api-docs/rest-api/account-endpoints#account-information-user_data
|
|
22
|
+
/// api: https://api.binance.com/api/v3/account
|
|
23
|
+
getSpotAccountInfoRequests(verifyType = 'HASH_COMPARISON') {
|
|
24
|
+
if (!this.hasSpot)
|
|
25
|
+
return undefined;
|
|
26
|
+
const signParams = { recvWindow: this.recvWindow };
|
|
27
|
+
const origRequests = [];
|
|
28
|
+
for (const acc of this.spotAccounts) {
|
|
29
|
+
const exchange = new ccxt.binance({ apiKey: acc.apiKey, secret: acc.apiSecret });
|
|
30
|
+
origRequests.push(exchange.sign("account", "private", "GET", { ...signParams, omitZeroBalances: true }));
|
|
29
31
|
}
|
|
30
|
-
return
|
|
32
|
+
return makeHashComparisonParams(origRequests, verifyType);
|
|
31
33
|
}
|
|
32
|
-
|
|
34
|
+
/// doc: https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Futures-Account-Balance-V3
|
|
35
|
+
/// api: https://fapi.binance.com/fapi/v3/balance
|
|
36
|
+
getUsdSFutureAccountBalanceV3Requests(verifyType = 'HASH_COMPARISON') {
|
|
37
|
+
if (!this.hasUsdSFutures)
|
|
38
|
+
return undefined;
|
|
33
39
|
const signParams = { recvWindow: this.recvWindow };
|
|
34
40
|
const origRequests = [];
|
|
35
|
-
for (const acc of this.
|
|
36
|
-
const exchange = new ccxt.binance({ apiKey: acc.
|
|
37
|
-
origRequests.push(exchange.sign("
|
|
38
|
-
origRequests.push(exchange.sign("balance", "papi", "GET", signParams));
|
|
41
|
+
for (const acc of this.usdSFuturesAccounts) {
|
|
42
|
+
const exchange = new ccxt.binance({ apiKey: acc.apiKey, secret: acc.apiSecret });
|
|
43
|
+
origRequests.push(exchange.sign("balance", "fapiPrivateV3", "GET", { ...signParams }));
|
|
39
44
|
}
|
|
40
45
|
return makeHashComparisonParams(origRequests, verifyType);
|
|
41
46
|
}
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
/// doc: https://developers.binance.com/docs/derivatives/portfolio-margin/account
|
|
48
|
+
/// api: https://papi.binance.com/papi/v1/balance
|
|
49
|
+
getUnifiedAccountBalanceRequests(verifyType = 'HASH_COMPARISON') {
|
|
50
|
+
if (!this.hasUnified)
|
|
51
|
+
return undefined;
|
|
44
52
|
const signParams = { recvWindow: this.recvWindow };
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
const origRequests = [];
|
|
54
|
+
for (const acc of this.unifiedAccounts) {
|
|
55
|
+
const exchange = new ccxt.binance({ apiKey: acc.apiKey, secret: acc.apiSecret });
|
|
56
|
+
origRequests.push(exchange.sign("um/positionRisk", "papi", "GET", signParams));
|
|
57
|
+
origRequests.push(exchange.sign("balance", "papi", "GET", { ...signParams }));
|
|
48
58
|
}
|
|
49
59
|
return makeHashComparisonParams(origRequests, verifyType);
|
|
50
60
|
}
|
|
51
|
-
getAccounts() {
|
|
52
|
-
return this.accounts;
|
|
53
|
-
}
|
|
54
61
|
}
|
|
55
62
|
//# sourceMappingURL=binance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binance.js","sourceRoot":"","sources":["../../src/datasource/binance.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"binance.js","sourceRoot":"","sources":["../../src/datasource/binance.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAGvD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,MAAM,OAAO,OAAQ,SAAQ,YAAyC;IACpE,YAAY,QAAqC;QAC/C,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,OAAO,KAAK,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;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CAAC,CAAC;YACjF,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;YAC/E,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,GAAG,UAAU,EAAE,CAAC,CAAC,CAAC;QAChF,CAAC;QACD,OAAO,wBAAwB,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ExchangesConfig } from "../config_schema.js";
|
|
2
|
+
import { Binance } from "./binance.js";
|
|
3
|
+
import { Aster } from "./aster.js";
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* const manager = new ExchangeManager(exchange_config);
|
|
8
|
+
* manager.aster?.hasSpot; // boolean
|
|
9
|
+
* manager.binance?.usdSFuturesAccounts; // BinanceAccount[]
|
|
10
|
+
*/
|
|
11
|
+
export declare class ExchangeManager {
|
|
12
|
+
readonly binance?: Binance;
|
|
13
|
+
readonly aster?: Aster;
|
|
14
|
+
constructor(config: ExchangesConfig);
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Binance } from "./binance.js";
|
|
2
|
+
import { Aster } from "./aster.js";
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* const manager = new ExchangeManager(exchange_config);
|
|
7
|
+
* manager.aster?.hasSpot; // boolean
|
|
8
|
+
* manager.binance?.usdSFuturesAccounts; // BinanceAccount[]
|
|
9
|
+
*/
|
|
10
|
+
export class ExchangeManager {
|
|
11
|
+
binance;
|
|
12
|
+
aster;
|
|
13
|
+
constructor(config) {
|
|
14
|
+
if (config.binance)
|
|
15
|
+
this.binance = new Binance(config.binance);
|
|
16
|
+
if (config.aster)
|
|
17
|
+
this.aster = new Aster(config.aster);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=exchange_manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exchange_manager.js","sourceRoot":"","sources":["../../src/datasource/exchange_manager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;IACV,OAAO,CAAW;IAClB,KAAK,CAAS;IAE9B,YAAY,MAAuB;QACjC,IAAI,MAAM,CAAC,OAAO;YAAE,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,MAAM,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACzD,CAAC;CACF"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { createHmac } from "node:crypto";
|
|
2
|
+
export function signQuery(secretKey, params) {
|
|
3
|
+
const query = new URLSearchParams(params).toString();
|
|
4
|
+
const signature = createHmac("sha256", secretKey).update(query).digest("hex");
|
|
5
|
+
return `${query}&signature=${signature}`;
|
|
6
|
+
}
|
|
1
7
|
export function makeHashComparisonParams(origRequests, verifyType) {
|
|
2
8
|
if (!Array.isArray(origRequests)) {
|
|
3
9
|
throw new Error("Invalid input: origRequests must be an array");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../src/datasource/helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../src/datasource/helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,UAAU,SAAS,CAAC,SAAiB,EAAE,MAAW;IAC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H,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC"}
|
package/dist/datasource/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/datasource/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/datasource/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC"}
|