@usherlabs/cex-broker 0.1.4 → 0.1.6
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 +13 -12
- package/dist/index.js +229 -3068
- package/dist/index.js.map +730 -0
- package/dist/proto/node.proto +53 -0
- package/package.json +4 -3
package/dist/commands/cli.js
CHANGED
|
@@ -290141,9 +290141,8 @@ function validateOrder(policy, fromToken, toToken, amount, broker) {
|
|
|
290141
290141
|
// src/server.ts
|
|
290142
290142
|
var grpc = __toESM(require_src3(), 1);
|
|
290143
290143
|
var protoLoader = __toESM(require_src2(), 1);
|
|
290144
|
-
import path from "path";
|
|
290145
290144
|
|
|
290146
|
-
// proto/
|
|
290145
|
+
// src/proto/cex_broker/Action.ts
|
|
290147
290146
|
var Action = {
|
|
290148
290147
|
NoAction: 0,
|
|
290149
290148
|
Deposit: 1,
|
|
@@ -290155,7 +290154,7 @@ var Action = {
|
|
|
290155
290154
|
FetchDepositAddresses: 7
|
|
290156
290155
|
};
|
|
290157
290156
|
|
|
290158
|
-
// proto/
|
|
290157
|
+
// src/proto/cex_broker/SubscriptionType.ts
|
|
290159
290158
|
var SubscriptionType = {
|
|
290160
290159
|
ORDERBOOK: 0,
|
|
290161
290160
|
TRADES: 1,
|
|
@@ -290167,14 +290166,17 @@ var SubscriptionType = {
|
|
|
290167
290166
|
|
|
290168
290167
|
// src/server.ts
|
|
290169
290168
|
var import_joi2 = __toESM(require_lib4(), 1);
|
|
290170
|
-
|
|
290171
|
-
|
|
290172
|
-
var
|
|
290169
|
+
import path from "path";
|
|
290170
|
+
import { fileURLToPath } from "url";
|
|
290171
|
+
var __filename2 = fileURLToPath(import.meta.url);
|
|
290172
|
+
var __dirname2 = path.dirname(__filename2);
|
|
290173
|
+
var protoPath = path.join(__dirname2, ".", "proto", "node.proto");
|
|
290174
|
+
var packageDef = protoLoader.loadSync(protoPath);
|
|
290173
290175
|
var grpcObj = grpc.loadPackageDefinition(packageDef);
|
|
290174
|
-
var cexNode = grpcObj.
|
|
290176
|
+
var cexNode = grpcObj.cex_broker;
|
|
290175
290177
|
function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
|
|
290176
290178
|
const server = new grpc.Server;
|
|
290177
|
-
server.addService(cexNode.
|
|
290179
|
+
server.addService(cexNode.cex_service.service, {
|
|
290178
290180
|
ExecuteAction: async (call, callback) => {
|
|
290179
290181
|
if (!authenticateRequest(call, whitelistIps)) {
|
|
290180
290182
|
return callback({
|
|
@@ -290354,9 +290356,7 @@ function getServer(policy, brokers, whitelistIps, useVerity, verityProverUrl) {
|
|
|
290354
290356
|
message: `Invalid CEX key: ${cex3}. Supported keys: ${Object.keys(brokers).join(", ")}`
|
|
290355
290357
|
}, null);
|
|
290356
290358
|
}
|
|
290357
|
-
const order = await broker.createOrder(symbol2, orderValue.orderType, from === orderValue.fromToken ? "sell" : "buy", Number(orderValue.amount), Number(orderValue.price), {
|
|
290358
|
-
...orderValue.params
|
|
290359
|
-
});
|
|
290359
|
+
const order = await broker.createOrder(symbol2, orderValue.orderType, from === orderValue.fromToken ? "sell" : "buy", Number(orderValue.amount), Number(orderValue.price), orderValue.params ?? {});
|
|
290360
290360
|
callback(null, { result: JSON.stringify({ ...order }) });
|
|
290361
290361
|
} catch (error) {
|
|
290362
290362
|
log.error({ error });
|
|
@@ -290855,7 +290855,7 @@ class CEXBroker {
|
|
|
290855
290855
|
apiKey: sec.apiKey,
|
|
290856
290856
|
apiSecret: sec.apiSecret
|
|
290857
290857
|
};
|
|
290858
|
-
|
|
290858
|
+
const exchange = new ExchangeClass({
|
|
290859
290859
|
apiKey: sec.apiKey,
|
|
290860
290860
|
secret: sec.apiSecret,
|
|
290861
290861
|
enableRateLimit: true,
|
|
@@ -290868,6 +290868,7 @@ class CEXBroker {
|
|
|
290868
290868
|
recvWindow: 60000
|
|
290869
290869
|
}
|
|
290870
290870
|
});
|
|
290871
|
+
secondaryBrokers[+index2] = exchange;
|
|
290871
290872
|
} else {
|
|
290872
290873
|
log.warn(`⚠️ Incomplete secondary credentials for broker "${broker}" at index ${index2}`);
|
|
290873
290874
|
}
|