Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
14 changes: 13 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,16 @@ OTEL_SERVICE_NAME=cex-broker
# Or use legacy host/port configuration
# CEX_BROKER_OTEL_HOST=otel-collector
# CEX_BROKER_OTEL_PORT=4318
# CEX_BROKER_OTEL_PROTOCOL=http
# CEX_BROKER_OTEL_PROTOCOL=http

# Travel-rule deposit auto-clear reconciler (only used when a policy has
# travelRule.rule[].deposits.enabled). One RPC URL per Binance network code
# (suffix must match the deposit's `network`, e.g. ARBITRUM), used to prove a
# frozen deposit's on-chain sender before auto-submitting its questionnaire. A
# frozen deposit on a network with no RPC configured is left frozen (fail-closed).
# These are intentionally NOT CEX_BROKER_-prefixed so the credential scan skips them.
# TRAVEL_RULE_RPC_URL_ARBITRUM=https://arb1.arbitrum.io/rpc
# Optional overrides (defaults shown):
# TRAVEL_RULE_DEPOSIT_POLL_ACTIVE_SECS=60
# TRAVEL_RULE_DEPOSIT_POLL_IDLE_SECS=600
# TRAVEL_RULE_QUESTIONNAIRE_COUNTRY=AU
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@usherlabs/cex-broker",
"version": "0.2.16",
"version": "0.2.17",
"description": "Unified gRPC API to CEXs by Usher Labs.",
"repository": {
"type": "git",
Expand Down
11 changes: 7 additions & 4 deletions patches/@usherlabs%2Fccxt@0.0.14.patch
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
diff --git a/node_modules/@usherlabs/ccxt/.bun-tag-a296b4edbb70d359 b/.bun-tag-a296b4edbb70d359
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/node_modules/@usherlabs/ccxt/.bun-tag-e1eca9fb87d1075f b/.bun-tag-e1eca9fb87d1075f
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/dist/cjs/src/binance.js b/dist/cjs/src/binance.js
index 40b4c4e8989fcbcdc693216cdb0d43bf0f553a88..2d1083354341ee778318c53332c03897558b5137 100644
index 40b4c4e8989fcbcdc693216cdb0d43bf0f553a88..6c7cda095c614de0527fa225ed321671488cbef9 100644
--- a/dist/cjs/src/binance.js
+++ b/dist/cjs/src/binance.js
@@ -12045,7 +12045,7 @@ class binance extends binance$1 {
if ((api === 'sapi') && (path === 'asset/dust')) {
query = this.urlencodeWithArrayRepeat(extendedParams);
}
- else if ((path === 'batchOrders') || (path.indexOf('sub-account') >= 0) || (path === 'capital/withdraw/apply') || (path.indexOf('staking') >= 0) || (path.indexOf('simple-earn') >= 0)) {
+ else if ((path === 'batchOrders') || (path.indexOf('sub-account') >= 0) || (path === 'capital/withdraw/apply') || (path === 'localentity/withdraw/apply') || (path.indexOf('staking') >= 0) || (path.indexOf('simple-earn') >= 0)) {
+ else if ((path === 'batchOrders') || (path.indexOf('sub-account') >= 0) || (path === 'capital/withdraw/apply') || (path === 'localentity/withdraw/apply') || (path === 'localentity/deposit/provide-info') || (path.indexOf('staking') >= 0) || (path.indexOf('simple-earn') >= 0)) {
if ((method === 'DELETE') && (path === 'batchOrders')) {
const orderidlist = this.safeList(extendedParams, 'orderidlist', []);
const origclientorderidlist = this.safeList(extendedParams, 'origclientorderidlist', []);
diff --git a/js/src/binance.js b/js/src/binance.js
index 9a472db82ff35f67c16bfde11b34831f503d00f9..70b1cd355fe31be954f0bd673f9b5896081a8ddc 100644
index 9a472db82ff35f67c16bfde11b34831f503d00f9..7e7696cac61e08ac469d4d7c2b9c6fb861c84b3c 100644
--- a/js/src/binance.js
+++ b/js/src/binance.js
@@ -12048,7 +12048,7 @@ export default class binance extends Exchange {
if ((api === 'sapi') && (path === 'asset/dust')) {
query = this.urlencodeWithArrayRepeat(extendedParams);
}
- else if ((path === 'batchOrders') || (path.indexOf('sub-account') >= 0) || (path === 'capital/withdraw/apply') || (path.indexOf('staking') >= 0) || (path.indexOf('simple-earn') >= 0)) {
+ else if ((path === 'batchOrders') || (path.indexOf('sub-account') >= 0) || (path === 'capital/withdraw/apply') || (path === 'localentity/withdraw/apply') || (path.indexOf('staking') >= 0) || (path.indexOf('simple-earn') >= 0)) {
+ else if ((path === 'batchOrders') || (path.indexOf('sub-account') >= 0) || (path === 'capital/withdraw/apply') || (path === 'localentity/withdraw/apply') || (path === 'localentity/deposit/provide-info') || (path.indexOf('staking') >= 0) || (path.indexOf('simple-earn') >= 0)) {
if ((method === 'DELETE') && (path === 'batchOrders')) {
const orderidlist = this.safeList(extendedParams, 'orderidlist', []);
const origclientorderidlist = this.safeList(extendedParams, 'origclientorderidlist', []);
11 changes: 9 additions & 2 deletions src/helpers/broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import ccxt from "@usherlabs/ccxt";
import type { BrokerAccountRole, BrokerCredentials } from "../types";
import { buildCcxtConfig } from "./exchange-credentials";
import { log } from "./logger";
import { registerBinanceTravelRuleWithdrawEndpoint } from "./travel-rule";
import {
registerBinanceTravelRuleDepositEndpoints,
registerBinanceTravelRuleWithdrawEndpoint,
} from "./travel-rule";

export type BrokerAccount = {
exchange: Exchange;
Expand Down Expand Up @@ -52,8 +55,12 @@ export function applyCommonExchangeConfig(exchange: Exchange) {
recvWindow: 60000,
adjustForTimeDifference: true,
});
// Register Binance's travel-rule withdraw endpoint (no-op for other exchanges).
// Register Binance's travel-rule endpoints (no-op for other exchanges): the
// withdraw apply endpoint and the deposit reconciler's read/provide-info
// endpoints. Registered here so every account instance carries them before the
// reconciler's first tick.
registerBinanceTravelRuleWithdrawEndpoint(exchange);
registerBinanceTravelRuleDepositEndpoints(exchange);
}

export function createBroker(
Expand Down
29 changes: 28 additions & 1 deletion src/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import {
parseMarketPattern,
parseMarketType,
} from "./market-type";
import { australiaQuestionnaireSchema } from "./travel-rule";
import {
australiaDepositQuestionnaireSchema,
australiaQuestionnaireSchema,
} from "./travel-rule";

export { authenticateRequest } from "./auth";
export {
Expand All @@ -31,12 +34,21 @@ export {
selectBrokerAccount,
} from "./broker";
export {
australiaDepositQuestionnaireSchema,
australiaQuestionnaireSchema,
getEnabledTravelRuleDepositConfig,
registerBinanceTravelRuleDepositEndpoints,
registerBinanceTravelRuleWithdrawEndpoint,
resolveDepositOriginatorQuestionnaire,
resolveTravelRuleDecision,
type TravelRuleDecision,
withdrawViaLocalEntity,
} from "./travel-rule";
export {
loadTravelRuleDepositReconcilerConfigFromEnv,
resolveOnChainSender,
TravelRuleDepositReconciler,
} from "./travel-rule-deposit-reconciler";
export {
buildHttpClientOverrideFromMetadata,
createVerityHttpClientOverride,
Expand Down Expand Up @@ -97,6 +109,21 @@ export function loadPolicy(policyPath: string): PolicyConfig {
}),
)
.required(),
// Deposit auto-clear config, keyed by on-chain sender (originator). Uses
// the deposit questionnaire schema, which is deliberately distinct from
// the withdraw one so a copy-paste of the wrong shape fails at load time.
deposits: Joi.object({
enabled: Joi.boolean().required(),
description: Joi.string().optional(),
originators: Joi.object()
.pattern(
Joi.string(),
Joi.object({
questionnaire: australiaDepositQuestionnaireSchema.required(),
}),
)
.required(),
}).optional(),
});

// Full PolicyConfig schema
Expand Down
Loading
Loading