Skip to content

Commit f8e1178

Browse files
authored
Merge pull request #15 from usherlabs/feat/fiet-341
feat: ticker fetcher
2 parents 455038e + e7bf63a commit f8e1178

4 files changed

Lines changed: 39 additions & 2 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@usherlabs/cex-broker",
3-
"version": "0.1.10",
3+
"version": "0.1.11",
44
"description": "Unified gRPC API to CEXs by Usher Labs.",
55
"repository": "git@gitlab.com:usherlabs/cex-broker.git",
66
"homepage": "https://usher.so/",
@@ -30,7 +30,7 @@
3030
"start": "bun run ./src/index.ts",
3131
"build": "bun run ./build.ts && bun run build:ts && bun run copy:dts && bun run copy:proto",
3232
"start-broker": "bun run ./src/cli.ts",
33-
"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",
33+
"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'",
3434
"build:ts": "bunx tsc",
3535
"test": "bun test",
3636
"format": "bunx biome format --write",

src/client.dev.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,23 @@ client.waitForReady(deadline, (err) => {
5151
});
5252

5353
function onClientReady() {
54+
// Test ExecuteAction for ticker
55+
client.executeAction(
56+
{
57+
cex: "binance",
58+
symbol: "ETHUSDT",
59+
action: Action.FetchTicker,
60+
},
61+
metadata,
62+
(err, result) => {
63+
if (err) {
64+
log.error({ err });
65+
return;
66+
}
67+
log.info("ExecuteAction Ticker Result:", { result });
68+
},
69+
);
70+
5471
// Test ExecuteAction for balance
5572
client.executeAction(
5673
{

src/proto/node.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ enum Action {
5353
FetchBalance=6;
5454
FetchBalances=7;
5555
FetchDepositAddresses=8;
56+
FetchTicker=9;
5657
}

src/server.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,25 @@ export function getServer(
529529
}
530530
break;
531531

532+
case Action.FetchTicker:
533+
try {
534+
const ticker = await broker.fetchTicker(symbol);
535+
callback(null, {
536+
proof: broker.last_proof || "",
537+
result: JSON.stringify(ticker),
538+
});
539+
} catch (error) {
540+
log.error(`Error fetching ticker from ${cex}:`, error);
541+
callback(
542+
{
543+
code: grpc.status.INTERNAL,
544+
message: `Failed to fetch ticker from ${cex}`,
545+
},
546+
null,
547+
);
548+
}
549+
break;
550+
532551
default:
533552
return callback({
534553
code: grpc.status.INVALID_ARGUMENT,

0 commit comments

Comments
 (0)