Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@usherlabs/cex-broker",
"version": "0.1.10",
"version": "0.1.11",
"description": "Unified gRPC API to CEXs by Usher Labs.",
"repository": "git@gitlab.com:usherlabs/cex-broker.git",
"homepage": "https://usher.so/",
Expand Down Expand Up @@ -30,7 +30,7 @@
"start": "bun run ./src/index.ts",
"build": "bun run ./build.ts && bun run build:ts && bun run copy:dts && bun run copy:proto",
"start-broker": "bun run ./src/cli.ts",
"start-broker-server": " bun run start-broker --policy policy/policy.json --port 8086 --whitelist 127.0.0.1 192.168.1.100 --verityProverUrl http://localhost:8080",
"start-broker-server": "bunx nodemon --watch src --watch policy --ext ts,js,json --exec 'bun run start-broker --policy policy/policy.json --port 8086 --whitelist * --verityProverUrl http://localhost:8080'",
"build:ts": "bunx tsc",
"test": "bun test",
"format": "bunx biome format --write",
Expand Down
17 changes: 17 additions & 0 deletions src/client.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ client.waitForReady(deadline, (err) => {
});

function onClientReady() {
// Test ExecuteAction for ticker
client.executeAction(
{
cex: "binance",
symbol: "ETHUSDT",
action: Action.FetchTicker,
},
metadata,
(err, result) => {
if (err) {
log.error({ err });
return;
}
log.info("ExecuteAction Ticker Result:", { result });
},
);

// Test ExecuteAction for balance
client.executeAction(
{
Expand Down
1 change: 1 addition & 0 deletions src/proto/node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ enum Action {
FetchBalance=6;
FetchBalances=7;
FetchDepositAddresses=8;
FetchTicker=9;
}
19 changes: 19 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,25 @@ export function getServer(
}
break;

case Action.FetchTicker:
try {
const ticker = await broker.fetchTicker(symbol);
callback(null, {
proof: broker.last_proof || "",
result: JSON.stringify(ticker),
});
} catch (error) {
log.error(`Error fetching ticker from ${cex}:`, error);
callback(
{
code: grpc.status.INTERNAL,
message: `Failed to fetch ticker from ${cex}`,
},
null,
);
}
break;

default:
return callback({
code: grpc.status.INVALID_ARGUMENT,
Expand Down