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
5 changes: 3 additions & 2 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.18",
"version": "0.1.19",
"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 @@ -50,7 +50,7 @@
"dependencies": {
"@grpc/grpc-js": "^1.13.4",
"@grpc/proto-loader": "^0.7.15",
"@usherlabs/ccxt": "^0.0.12",
"@usherlabs/ccxt": "^0.0.13",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Script executed:

npm view @usherlabs/ccxt@0.0.13 version 2>/dev/null || echo "Version 0.0.13 not found"

Repository: usherlabs/cex-broker


<shell_result>
Repository: usherlabs/cex-broker
Exit code: 0

stdout:

Version 0.0.13 not found

</shell_result>


@usherlabs/ccxt@0.0.13 does not exist on npm registry.

The version specified in this PR is not available for download. As this change depends on the deployment of ccxt 0.0.13 (per the PR description), the package must be published to npm before this PR can be merged. Verify with the maintainers that the version has been released or coordinate the publication.

🤖 Prompt for AI Agents
In package.json around line 53, the dependency entry "@usherlabs/ccxt":
"^0.0.13" refers to a package version that does not exist on the npm registry;
update this to a valid published version or revert the version change. Ask the
maintainers to publish v0.0.13 before merging or change the dependency to an
existing released version (or a temporary fork/path) and update package.json
accordingly, then run npm install/npm ci and verify lockfile updates and CI
passes.

"@usherlabs/verity-client": "^0.1.1",
"commander": "^14.0.0",
"joi": "^17.13.3",
Expand Down
28 changes: 22 additions & 6 deletions src/client.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,37 @@ function onClientReady() {
},
);

// Test ExecuteAction for balance
// Test ExecuteAction for Account ID
client.executeAction(
{
cex: "binance",
symbol: "USDT,BTC,ETH",
payload: { type: "spot" },
action: Action.FetchBalances,
cex: "mexc",
action: Action.FetchAccountId,
},
metadata,
(err, result) => {
if (err) {
log.error({ err });
return;
}
log.info("ExecuteAction Balance Result:", { result });
log.info("ExecuteAction Result:", { result: result?.result });
},
);

// // Test ExecuteAction for balance
// client.executeAction(
// {
// cex: "binance",
// symbol: "USDT,BTC,ETH",
// payload: { type: "spot" },
// action: Action.FetchBalances,
// },
// metadata,
// (err, result) => {
// if (err) {
// log.error({ err });
// return;
// }
// log.info("ExecuteAction Balance Result:", { result });
// },
// );
}
1 change: 1 addition & 0 deletions src/helpers/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export const CCXT_METHODS_WITH_VERITY = [
"fetchFundingHistory",
"fetchWithdrawals",
"fetchWithdrawal",
"fetchAccountId",
];
1 change: 1 addition & 0 deletions src/proto/node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ enum Action {
FetchTicker=8;
FetchCurrency=9;
Call=10;
FetchAccountId=11;
}
70 changes: 63 additions & 7 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,62 @@ export function getServer(
}
break;
}
case Action.FetchAccountId: {
Comment thread
xlassix marked this conversation as resolved.
try {
let accountId: string | undefined;
let uid: string | undefined;

const temp_broker = broker as any;

// 1. Bybit-style method?
if (typeof temp_broker.privateGetV5UserQueryApi === "function") {
const query = await temp_broker.privateGetV5UserQueryApi();
if (!query?.id || !query?.userID) {
throw new Error("Invalid response structure from privateGetV5UserQueryApi");
}
accountId = query.id;
uid = query.userID;
// 2. MEXC-style method?
} else if (typeof temp_broker.spotPrivateGetUid === "function") {
const query = await temp_broker.spotPrivateGetUid();
accountId = query.uid;
uid = query.uid;

// 3. Binance-style method?
} else if (typeof temp_broker.privateGetAccount === "function") {
const query = await temp_broker.privateGetAccount();
accountId = query.uid;
uid = query.uid;

// 4. None matched → unsupported exchange
} else {
return callback(
{
code: grpc.status.INTERNAL,
message:
"Error: fetching account ID not supported for this broker",
},
null,
);
}

// Return normalized response
return callback(null, {
proof: verityProof,
result: JSON.stringify({ accountId, uid }),
});
} catch (error) {
log.error(`Error fetching account ID ${cex}:`, error);
callback(
{
code: grpc.status.INTERNAL,
message: `Error fetching account ID from ${cex}`,
},
null,
);
}
break;
}

case Action.Call: {
const callSchema = Joi.object({
Expand Down Expand Up @@ -374,15 +430,15 @@ export function getServer(
const depositAddresses =
broker.has.fetchDepositAddress === true
? [
await broker.fetchDepositAddress(symbol, {
network: fetchDepositAddresses.chain,
...(fetchDepositAddresses.params ?? {}),
}),
]
: await broker.fetchDepositAddressesByNetwork(symbol, {
await broker.fetchDepositAddress(symbol, {
network: fetchDepositAddresses.chain,
...(fetchDepositAddresses.params ?? {}),
});
}),
]
: await broker.fetchDepositAddressesByNetwork(symbol, {
network: fetchDepositAddresses.chain,
...(fetchDepositAddresses.params ?? {}),
});

if (depositAddresses.length > 0) {
return callback(null, {
Expand Down