@usherlabs/cex-broker 0.1.2 → 0.1.3
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/commands/cli.js +2 -2
- package/dist/index.d.ts +40 -0
- package/dist/index.js +2 -2
- package/dist/types.d.ts +66 -0
- package/package.json +3 -1
package/dist/commands/cli.js
CHANGED
|
@@ -14985,7 +14985,7 @@ var require_src2 = __commonJS((exports) => {
|
|
|
14985
14985
|
|
|
14986
14986
|
// node_modules/@grpc/grpc-js/build/src/channelz.js
|
|
14987
14987
|
var require_channelz = __commonJS((exports) => {
|
|
14988
|
-
var __dirname = "/home/
|
|
14988
|
+
var __dirname = "/home/xlassix/code/fietCexBroker/node_modules/@grpc/grpc-js/build/src";
|
|
14989
14989
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14990
14990
|
exports.registerChannelzSocket = exports.registerChannelzServer = exports.registerChannelzSubchannel = exports.registerChannelzChannel = exports.ChannelzCallTrackerStub = exports.ChannelzCallTracker = exports.ChannelzChildrenTrackerStub = exports.ChannelzChildrenTracker = exports.ChannelzTrace = exports.ChannelzTraceStub = undefined;
|
|
14991
14991
|
exports.unregisterChannelzRef = unregisterChannelzRef;
|
|
@@ -289751,7 +289751,7 @@ var SubscriptionType = {
|
|
|
289751
289751
|
|
|
289752
289752
|
// src/server.ts
|
|
289753
289753
|
var import_joi2 = __toESM(require_lib4(), 1);
|
|
289754
|
-
var __dirname = "/home/
|
|
289754
|
+
var __dirname = "/home/xlassix/code/fietCexBroker/src";
|
|
289755
289755
|
var PROTO_FILE = "../proto/node.proto";
|
|
289756
289756
|
var packageDef = protoLoader.loadSync(path.resolve(__dirname, PROTO_FILE));
|
|
289757
289757
|
var grpcObj = grpc.loadPackageDefinition(packageDef);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ExchangeCredentials, type PolicyConfig } from "./types";
|
|
2
|
+
export default class CEXBroker {
|
|
3
|
+
#private;
|
|
4
|
+
port: number;
|
|
5
|
+
private policy;
|
|
6
|
+
private brokers;
|
|
7
|
+
private whitelistIps;
|
|
8
|
+
private server;
|
|
9
|
+
private useVerity;
|
|
10
|
+
/**
|
|
11
|
+
* Loads environment variables prefixed with CEX_BROKER_
|
|
12
|
+
* Expected format:
|
|
13
|
+
* CEX_BROKER_<BROKER_NAME>_API_KEY
|
|
14
|
+
* CEX_BROKER_<BROKER_NAME>_API_SECRET
|
|
15
|
+
*/
|
|
16
|
+
loadEnvConfig(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Validates an exchange credential object structure.
|
|
19
|
+
*/
|
|
20
|
+
loadExchangeCredentials(creds: unknown): asserts creds is ExchangeCredentials;
|
|
21
|
+
constructor(apiCredentials: ExchangeCredentials, policies: string | PolicyConfig, config?: {
|
|
22
|
+
port?: number;
|
|
23
|
+
whitelistIps?: string[];
|
|
24
|
+
useVerity?: boolean;
|
|
25
|
+
verityProverUrl?: string;
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Watches the policy JSON file for changes, reloads policies, and reruns broker.
|
|
29
|
+
* @param filePath
|
|
30
|
+
*/
|
|
31
|
+
private watchPolicyFile;
|
|
32
|
+
/**
|
|
33
|
+
* Stops Server and Stop watching the policy file, if applicable.
|
|
34
|
+
*/
|
|
35
|
+
stop(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Starts the broker, applying policies then running appropriate tasks.
|
|
38
|
+
*/
|
|
39
|
+
run(): Promise<CEXBroker>;
|
|
40
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -12890,7 +12890,7 @@ var require_src2 = __commonJS((exports) => {
|
|
|
12890
12890
|
|
|
12891
12891
|
// node_modules/@grpc/grpc-js/build/src/channelz.js
|
|
12892
12892
|
var require_channelz = __commonJS((exports) => {
|
|
12893
|
-
var __dirname = "/home/
|
|
12893
|
+
var __dirname = "/home/xlassix/code/fietCexBroker/node_modules/@grpc/grpc-js/build/src";
|
|
12894
12894
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12895
12895
|
exports.registerChannelzSocket = exports.registerChannelzServer = exports.registerChannelzSubchannel = exports.registerChannelzChannel = exports.ChannelzCallTrackerStub = exports.ChannelzCallTracker = exports.ChannelzChildrenTrackerStub = exports.ChannelzChildrenTracker = exports.ChannelzTrace = exports.ChannelzTraceStub = undefined;
|
|
12896
12896
|
exports.unregisterChannelzRef = unregisterChannelzRef;
|
|
@@ -287640,7 +287640,7 @@ var SubscriptionType = {
|
|
|
287640
287640
|
|
|
287641
287641
|
// src/server.ts
|
|
287642
287642
|
var import_joi2 = __toESM(require_lib4(), 1);
|
|
287643
|
-
var __dirname = "/home/
|
|
287643
|
+
var __dirname = "/home/xlassix/code/fietCexBroker/src";
|
|
287644
287644
|
var PROTO_FILE = "../proto/node.proto";
|
|
287645
287645
|
var packageDef = protoLoader.loadSync(path.resolve(__dirname, PROTO_FILE));
|
|
287646
287646
|
var grpcObj = grpc.loadPackageDefinition(packageDef);
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type ccxt from "@usherlabs/ccxt";
|
|
2
|
+
export type WithdrawRule = {
|
|
3
|
+
networks: string[];
|
|
4
|
+
whitelist: string[];
|
|
5
|
+
amounts: {
|
|
6
|
+
ticker: string;
|
|
7
|
+
max: number;
|
|
8
|
+
min: number;
|
|
9
|
+
}[];
|
|
10
|
+
};
|
|
11
|
+
export type OrderRule = {
|
|
12
|
+
markets: string[];
|
|
13
|
+
limits: Array<{
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
min: number;
|
|
17
|
+
max: number;
|
|
18
|
+
}>;
|
|
19
|
+
};
|
|
20
|
+
export type PolicyConfig = {
|
|
21
|
+
withdraw: {
|
|
22
|
+
rule: WithdrawRule;
|
|
23
|
+
};
|
|
24
|
+
deposit: Record<string, null>;
|
|
25
|
+
order: {
|
|
26
|
+
rule: OrderRule;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export type Policy = {
|
|
30
|
+
isActive: boolean;
|
|
31
|
+
permissions: Array<"withdraw" | "transfer" | "convert">;
|
|
32
|
+
limits: {
|
|
33
|
+
dailyWithdrawLimit?: number;
|
|
34
|
+
dailyTransferredAmount?: number;
|
|
35
|
+
perTxTransferLimit?: number;
|
|
36
|
+
};
|
|
37
|
+
networks: string[];
|
|
38
|
+
conversionLimits: Array<{
|
|
39
|
+
from: string;
|
|
40
|
+
to: string;
|
|
41
|
+
min: number;
|
|
42
|
+
max: number;
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
45
|
+
type BrokerInstanceMap = {
|
|
46
|
+
[K in ISupportedBroker]: InstanceType<(typeof ccxt)[K]>;
|
|
47
|
+
};
|
|
48
|
+
export type BrokerMap = Partial<{
|
|
49
|
+
[K in ISupportedBroker]: BrokerInstanceMap[K];
|
|
50
|
+
}>;
|
|
51
|
+
export declare const BrokerList: readonly ["alpaca", "apex", "ascendex", "bequant", "bigone", "binance", "binancecoinm", "binanceus", "binanceusdm", "bingx", "bit2c", "bitbank", "bitbns", "bitfinex", "bitflyer", "bitget", "bithumb", "bitmart", "bitmex", "bitopro", "bitrue", "bitso", "bitstamp", "bitteam", "bittrade", "bitvavo", "blockchaincom", "blofin", "btcalpha", "btcbox", "btcmarkets", "btcturk", "bybit", "cex", "coinbase", "coinbaseadvanced", "coinbaseexchange", "coinbaseinternational", "coincatch", "coincheck", "coinex", "coinmate", "coinmetro", "coinone", "coinsph", "coinspot", "cryptocom", "cryptomus", "defx", "delta", "deribit", "derive", "digifinex", "ellipx", "exmo", "fmfwio", "gate", "gateio", "gemini", "hashkey", "hitbtc", "hollaex", "htx", "huobi", "hyperliquid", "independentreserve", "indodax", "kraken", "krakenfutures", "kucoin", "kucoinfutures", "latoken", "lbank", "luno", "mercado", "mexc", "modetrade", "myokx", "ndax", "novadax", "oceanex", "okcoin", "okx", "okxus", "onetrading", "oxfun", "p2b", "paradex", "paymium", "phemex", "poloniex", "probit", "timex", "tokocrypto", "tradeogre", "upbit", "vertex", "wavesexchange", "whitebit", "woo", "woofipro", "xt", "yobit", "zaif", "zonda"];
|
|
52
|
+
export type brokers = Required<BrokerMap>;
|
|
53
|
+
export type ISupportedBroker = (typeof BrokerList)[number];
|
|
54
|
+
export type SupportedBrokers = (typeof BrokerList)[number];
|
|
55
|
+
export declare const SupportedBroker: Record<"alpaca" | "apex" | "ascendex" | "bequant" | "bigone" | "binance" | "binancecoinm" | "binanceus" | "binanceusdm" | "bingx" | "bit2c" | "bitbank" | "bitbns" | "bitfinex" | "bitflyer" | "bitget" | "bithumb" | "bitmart" | "bitmex" | "bitopro" | "bitrue" | "bitso" | "bitstamp" | "bitteam" | "bittrade" | "bitvavo" | "blockchaincom" | "blofin" | "btcalpha" | "btcbox" | "btcmarkets" | "btcturk" | "bybit" | "cex" | "coinbase" | "coinbaseadvanced" | "coinbaseexchange" | "coinbaseinternational" | "coincatch" | "coincheck" | "coinex" | "coinmate" | "coinmetro" | "coinone" | "coinsph" | "coinspot" | "cryptocom" | "cryptomus" | "defx" | "delta" | "deribit" | "derive" | "digifinex" | "ellipx" | "exmo" | "fmfwio" | "gate" | "gateio" | "gemini" | "hashkey" | "hitbtc" | "hollaex" | "htx" | "huobi" | "hyperliquid" | "independentreserve" | "indodax" | "kraken" | "krakenfutures" | "kucoin" | "kucoinfutures" | "latoken" | "lbank" | "luno" | "mercado" | "mexc" | "modetrade" | "myokx" | "ndax" | "novadax" | "oceanex" | "okcoin" | "okx" | "okxus" | "onetrading" | "oxfun" | "p2b" | "paradex" | "paymium" | "phemex" | "poloniex" | "probit" | "timex" | "tokocrypto" | "tradeogre" | "upbit" | "vertex" | "wavesexchange" | "whitebit" | "woo" | "woofipro" | "xt" | "yobit" | "zaif" | "zonda", string>;
|
|
56
|
+
export type BrokerCredentials = {
|
|
57
|
+
apiKey: string;
|
|
58
|
+
apiSecret: string;
|
|
59
|
+
};
|
|
60
|
+
export type SecondaryKeys<T> = {
|
|
61
|
+
secondaryKeys: Array<T>;
|
|
62
|
+
};
|
|
63
|
+
export interface ExchangeCredentials {
|
|
64
|
+
[exchange: string]: BrokerCredentials & SecondaryKeys<BrokerCredentials>;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usherlabs/cex-broker",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Unified gRPC API to CEXs by Usher Labs",
|
|
5
5
|
"repository": "git@gitlab.com:usherlabs/cex-broker.git",
|
|
6
6
|
"homepage": "https://usher.so/",
|
|
@@ -27,6 +27,8 @@
|
|
|
27
27
|
"scripts": {
|
|
28
28
|
"proto-gen": "./proto-gen.sh",
|
|
29
29
|
"start": "bun run ./src/index.ts",
|
|
30
|
+
"build": "bun run ./build.ts",
|
|
31
|
+
"build:ts": "bunx tsc",
|
|
30
32
|
"test": "bun test",
|
|
31
33
|
"format": "bunx biome format --write",
|
|
32
34
|
"lint": "bunx biome lint",
|