@riocrypto/common-server 1.0.2765 → 1.0.2766

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.
@@ -86,7 +86,7 @@ function buildAxiosWithLogging() {
86
86
  }
87
87
  return response;
88
88
  }, (error) => {
89
- var _a, _b, _c;
89
+ var _a, _b, _c, _d;
90
90
  // Combine and log the response error details without headers
91
91
  let logMessage = `Response Error: url=${maskUrl((_a = error.config) === null || _a === void 0 ? void 0 : _a.url)}, message=${error.message}`;
92
92
  if (error.response) {
@@ -96,6 +96,7 @@ function buildAxiosWithLogging() {
96
96
  return Promise.reject({
97
97
  message: logMessage,
98
98
  status: (_c = error.response) === null || _c === void 0 ? void 0 : _c.status,
99
+ data: (_d = error.response) === null || _d === void 0 ? void 0 : _d.data,
99
100
  });
100
101
  });
101
102
  return axiosWithLogging;
@@ -1,4 +1,4 @@
1
- import { Quote, Fiat, Crypto, BitsoBankAccount, Side, Country, Order, CryptoAddress, BankAccount, AuthRole, Auth, ImportOrderData, TreasuryProvider, FXProvider, EmarketsFXTrade, ExternalTradingAlgorithm, ExternalTrade, ExternalTradeType, ExternalTradingProvider, ExternalTradingAlgorithmType, STPMXNWithdrawal, AuthPermission, DeferredPaymentType, TwoWaySettlementType, OrderType, EmarketsSettlementType, EmarketsOrderType, BulkBankPayout, BulkCryptoPayout, BulkBankPayment, BulkCryptoPayment, OrderStatus, TWAPSession, TransnetworkFXTrade, TransnetworkSettlementType, TransnetworkOrderType, AuthMethod } from "@riocrypto/common";
1
+ import { Quote, Fiat, Crypto, BitsoBankAccount, Side, Country, Order, CryptoAddress, BankAccount, AuthRole, Auth, ImportOrderData, TreasuryProvider, FXProvider, EmarketsFXTrade, ExternalTradingAlgorithm, ExternalTrade, ExternalTradeType, ExternalTradingProvider, ExternalTradingAlgorithmType, STPMXNWithdrawal, AuthPermission, DeferredPaymentType, TwoWaySettlementType, OrderType, EmarketsSettlementType, EmarketsOrderType, BulkBankPayout, BulkCryptoPayout, BulkBankPayment, BulkCryptoPayment, OrderStatus, TWAPSession, TransnetworkFXTrade, TransnetworkSettlementType, TransnetworkOrderType, AuthMethod, StonexFXTrade } from "@riocrypto/common";
2
2
  import { STPMXNWithdrawalDoc } from "../models/STP-mxn-withdrawal";
3
3
  declare class ClusterClient {
4
4
  private baseUrl;
@@ -235,6 +235,50 @@ declare class ClusterClient {
235
235
  minClipSize: number;
236
236
  interval: number;
237
237
  }>;
238
+ createStonexTrade(data: {
239
+ symbol: string;
240
+ side: string;
241
+ quantity: number;
242
+ valueDate?: string;
243
+ fiat?: string;
244
+ }): Promise<StonexFXTrade>;
245
+ takeStonexQuote(tradeId: string, side: "buy" | "sell"): Promise<StonexFXTrade>;
246
+ cancelStonexTrade(tradeId: string): Promise<StonexFXTrade>;
247
+ updateStonexOrder(tradeId: string, params: {
248
+ quantity?: number;
249
+ price?: number;
250
+ stopPx?: number;
251
+ timeInForce?: string;
252
+ }): Promise<StonexFXTrade>;
253
+ placeStonexDirectOrder(params: {
254
+ symbol: string;
255
+ side: string;
256
+ quantity: number;
257
+ ordType: string;
258
+ timeInForce: string;
259
+ currency: string;
260
+ price?: number;
261
+ stopPx?: number;
262
+ valueDate?: string;
263
+ execInst?: string;
264
+ }): Promise<StonexFXTrade>;
265
+ getStonexTrade(tradeId: string): Promise<StonexFXTrade>;
266
+ getStonexTrades(offset: number, limit: number): Promise<{
267
+ data: StonexFXTrade[];
268
+ hasMore: boolean;
269
+ }>;
270
+ getValueDates(country?: string): Promise<Record<string, string>>;
271
+ getStonexStatus(): Promise<{
272
+ order: string;
273
+ md: string;
274
+ spotRate: {
275
+ bid?: number;
276
+ offer?: number;
277
+ } | null;
278
+ }>;
279
+ sendStonexCommand(command: string): Promise<{
280
+ message: string;
281
+ }>;
238
282
  }
239
283
  export declare const buildClusterClient: () => Promise<ClusterClient>;
240
284
  export {};
@@ -791,6 +791,72 @@ class ClusterClient {
791
791
  return response.data;
792
792
  });
793
793
  }
794
+ // ─── StoneX FIX ───────────────────────────────────────────────────
795
+ createStonexTrade(data) {
796
+ return __awaiter(this, void 0, void 0, function* () {
797
+ const response = yield this.axios.post(`${this.baseUrl}/api/stonex/create-quote-stream`, data, { headers: { "x-cluster-api-key": this.clusterApiKey } });
798
+ return response.data;
799
+ });
800
+ }
801
+ takeStonexQuote(tradeId, side) {
802
+ return __awaiter(this, void 0, void 0, function* () {
803
+ const response = yield this.axios.post(`${this.baseUrl}/api/stonex/take-quote/${tradeId}`, { side }, { headers: { "x-cluster-api-key": this.clusterApiKey } });
804
+ return response.data;
805
+ });
806
+ }
807
+ cancelStonexTrade(tradeId) {
808
+ return __awaiter(this, void 0, void 0, function* () {
809
+ const response = yield this.axios.post(`${this.baseUrl}/api/stonex/cancel-trade/${tradeId}`, {}, { headers: { "x-cluster-api-key": this.clusterApiKey } });
810
+ return response.data;
811
+ });
812
+ }
813
+ updateStonexOrder(tradeId, params) {
814
+ return __awaiter(this, void 0, void 0, function* () {
815
+ const response = yield this.axios.post(`${this.baseUrl}/api/stonex/update-order/${tradeId}`, params, { headers: { "x-cluster-api-key": this.clusterApiKey } });
816
+ return response.data;
817
+ });
818
+ }
819
+ placeStonexDirectOrder(params) {
820
+ return __awaiter(this, void 0, void 0, function* () {
821
+ const response = yield this.axios.post(`${this.baseUrl}/api/stonex/place-order`, params, { headers: { "x-cluster-api-key": this.clusterApiKey } });
822
+ return response.data;
823
+ });
824
+ }
825
+ getStonexTrade(tradeId) {
826
+ return __awaiter(this, void 0, void 0, function* () {
827
+ const response = yield this.axios.get(`${this.baseUrl}/api/stonex/trades/${tradeId}`, { headers: { "x-cluster-api-key": this.clusterApiKey } });
828
+ return response.data;
829
+ });
830
+ }
831
+ getStonexTrades(offset, limit) {
832
+ return __awaiter(this, void 0, void 0, function* () {
833
+ const response = yield this.axios.get(`${this.baseUrl}/api/stonex/trades?offset=${offset}&limit=${limit}`, { headers: { "x-cluster-api-key": this.clusterApiKey } });
834
+ return response.data;
835
+ });
836
+ }
837
+ getValueDates(country) {
838
+ return __awaiter(this, void 0, void 0, function* () {
839
+ const url = country
840
+ ? `${this.baseUrl}/api/stonex/value-dates?country=${country}`
841
+ : `${this.baseUrl}/api/stonex/value-dates`;
842
+ const response = yield this.axios.get(url, {
843
+ headers: { "x-cluster-api-key": this.clusterApiKey },
844
+ });
845
+ return response.data;
846
+ });
847
+ }
848
+ getStonexStatus() {
849
+ return __awaiter(this, void 0, void 0, function* () {
850
+ const response = yield this.axios.get(`${this.baseUrl}/api/stonex/status`, { headers: { "x-cluster-api-key": this.clusterApiKey } });
851
+ return response.data;
852
+ });
853
+ }
854
+ sendStonexCommand(command) {
855
+ return __awaiter(this, void 0, void 0, function* () {
856
+ const response = yield this.axios.post(`${this.baseUrl}/api/stonex/command`, { command }, { headers: { "x-cluster-api-key": this.clusterApiKey } });
857
+ return response.data;
858
+ });
859
+ }
794
860
  }
795
861
  const buildClusterClient = () => __awaiter(void 0, void 0, void 0, function* () {
796
862
  // Retrieve secrets asynchronously
package/build/index.d.ts CHANGED
@@ -102,6 +102,8 @@ export * from "./models/bulk-bank-payout";
102
102
  export * from "./models/bulk-crypto-payout";
103
103
  export * from "./models/twap-settlement";
104
104
  export * from "./models/transnetwork-fx-trade";
105
+ export * from "./models/stonex-fx-trade";
106
+ export * from "./models/stonex-log";
105
107
  export * from "./models/inbound-bank-deposit";
106
108
  export * from "./models/inbound-crypto-deposit";
107
109
  export * from "./models/order-log";
package/build/index.js CHANGED
@@ -118,6 +118,8 @@ __exportStar(require("./models/bulk-bank-payout"), exports);
118
118
  __exportStar(require("./models/bulk-crypto-payout"), exports);
119
119
  __exportStar(require("./models/twap-settlement"), exports);
120
120
  __exportStar(require("./models/transnetwork-fx-trade"), exports);
121
+ __exportStar(require("./models/stonex-fx-trade"), exports);
122
+ __exportStar(require("./models/stonex-log"), exports);
121
123
  __exportStar(require("./models/inbound-bank-deposit"), exports);
122
124
  __exportStar(require("./models/inbound-crypto-deposit"), exports);
123
125
  __exportStar(require("./models/order-log"), exports);
@@ -21,6 +21,17 @@ interface ExternalTradeAttrs {
21
21
  emarkets?: {
22
22
  settlementType?: EmarketsSettlementType;
23
23
  };
24
+ stonex?: {
25
+ valueDate?: Date;
26
+ quoteReqId?: string;
27
+ bidPx?: number;
28
+ offerPx?: number;
29
+ clOrdId?: string;
30
+ text?: string;
31
+ ordType?: string;
32
+ amountReceived?: number;
33
+ stopPx?: number;
34
+ };
24
35
  };
25
36
  externalTradingAlgorithmId?: string;
26
37
  arbitrageSessionId?: string;
@@ -48,6 +59,17 @@ interface ExternalTradeDoc extends Document {
48
59
  emarkets?: {
49
60
  settlementType?: EmarketsSettlementType;
50
61
  };
62
+ stonex?: {
63
+ valueDate?: Date;
64
+ quoteReqId?: string;
65
+ bidPx?: number;
66
+ offerPx?: number;
67
+ clOrdId?: string;
68
+ text?: string;
69
+ ordType?: string;
70
+ amountReceived?: number;
71
+ stopPx?: number;
72
+ };
51
73
  };
52
74
  externalTradingAlgorithmId?: string;
53
75
  arbitrageSessionId?: string;
@@ -0,0 +1,70 @@
1
+ import { Fiat, Side, StonexFXTradeStatus, StonexSettlementType } from "@riocrypto/common";
2
+ import { Mongoose, Model, Document } from "mongoose";
3
+ interface StonexFXTradeAttrs {
4
+ createdAt: Date;
5
+ status: StonexFXTradeStatus;
6
+ side: Side;
7
+ fiat: Fiat;
8
+ symbol: string;
9
+ amountToTrade: number;
10
+ amountReceived?: number;
11
+ actualPrice?: number;
12
+ limitPrice?: number;
13
+ settlementType?: StonexSettlementType;
14
+ valueDate?: string;
15
+ clOrdId?: string;
16
+ quoteReqId?: string;
17
+ quoteId?: string;
18
+ bidPx?: number;
19
+ offerPx?: number;
20
+ validUntilTime?: string;
21
+ exchangeOrderId?: string;
22
+ execId?: string;
23
+ text?: string;
24
+ ordType?: string;
25
+ timeInForce?: string;
26
+ stopPx?: number;
27
+ execInst?: string;
28
+ minQty?: number;
29
+ maxShow?: number;
30
+ expireTime?: string;
31
+ leavesQty?: number;
32
+ avgPx?: number;
33
+ }
34
+ interface StonexFXTradeDoc extends Document {
35
+ id: string;
36
+ createdAt: Date;
37
+ status: StonexFXTradeStatus;
38
+ side: Side;
39
+ fiat: Fiat;
40
+ symbol: string;
41
+ amountToTrade: number;
42
+ amountReceived?: number;
43
+ actualPrice?: number;
44
+ limitPrice?: number;
45
+ settlementType?: StonexSettlementType;
46
+ valueDate?: string;
47
+ clOrdId?: string;
48
+ quoteReqId?: string;
49
+ quoteId?: string;
50
+ bidPx?: number;
51
+ offerPx?: number;
52
+ validUntilTime?: string;
53
+ exchangeOrderId?: string;
54
+ execId?: string;
55
+ text?: string;
56
+ ordType?: string;
57
+ timeInForce?: string;
58
+ stopPx?: number;
59
+ execInst?: string;
60
+ minQty?: number;
61
+ maxShow?: number;
62
+ expireTime?: string;
63
+ leavesQty?: number;
64
+ avgPx?: number;
65
+ }
66
+ interface StonexFXTradeModel extends Model<StonexFXTradeDoc> {
67
+ build(attrs: StonexFXTradeAttrs): StonexFXTradeDoc;
68
+ }
69
+ declare const buildStonexFXTrade: (mongoose: Mongoose) => StonexFXTradeModel;
70
+ export { buildStonexFXTrade, StonexFXTradeDoc, StonexFXTradeAttrs };
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildStonexFXTrade = void 0;
4
+ const buildStonexFXTrade = (mongoose) => {
5
+ if (mongoose.models.StonexFXTrade) {
6
+ return mongoose.model("StonexFXTrade");
7
+ }
8
+ const StonexFXTradeSchema = new mongoose.Schema({
9
+ createdAt: {
10
+ type: Date,
11
+ required: true,
12
+ },
13
+ status: {
14
+ type: String,
15
+ required: true,
16
+ },
17
+ side: {
18
+ type: String,
19
+ required: true,
20
+ },
21
+ fiat: {
22
+ type: String,
23
+ required: true,
24
+ },
25
+ symbol: {
26
+ type: String,
27
+ required: true,
28
+ },
29
+ amountToTrade: {
30
+ type: Number,
31
+ required: true,
32
+ },
33
+ amountReceived: {
34
+ type: Number,
35
+ },
36
+ actualPrice: {
37
+ type: Number,
38
+ },
39
+ limitPrice: {
40
+ type: Number,
41
+ },
42
+ settlementType: {
43
+ type: String,
44
+ },
45
+ valueDate: {
46
+ type: String,
47
+ },
48
+ clOrdId: {
49
+ type: String,
50
+ },
51
+ quoteReqId: {
52
+ type: String,
53
+ },
54
+ quoteId: {
55
+ type: String,
56
+ },
57
+ bidPx: {
58
+ type: Number,
59
+ },
60
+ offerPx: {
61
+ type: Number,
62
+ },
63
+ validUntilTime: {
64
+ type: String,
65
+ },
66
+ exchangeOrderId: {
67
+ type: String,
68
+ },
69
+ execId: {
70
+ type: String,
71
+ },
72
+ text: {
73
+ type: String,
74
+ },
75
+ ordType: {
76
+ type: String,
77
+ },
78
+ timeInForce: {
79
+ type: String,
80
+ },
81
+ stopPx: {
82
+ type: Number,
83
+ },
84
+ execInst: {
85
+ type: String,
86
+ },
87
+ minQty: {
88
+ type: Number,
89
+ },
90
+ maxShow: {
91
+ type: Number,
92
+ },
93
+ expireTime: {
94
+ type: String,
95
+ },
96
+ leavesQty: {
97
+ type: Number,
98
+ },
99
+ avgPx: {
100
+ type: Number,
101
+ },
102
+ metadata: {
103
+ type: Map,
104
+ of: mongoose.Schema.Types.Mixed,
105
+ },
106
+ }, {
107
+ toJSON: {
108
+ transform(doc, ret) {
109
+ ret.id = ret._id.valueOf();
110
+ delete ret._id;
111
+ delete ret.__v;
112
+ },
113
+ },
114
+ });
115
+ StonexFXTradeSchema.statics.build = (attrs) => {
116
+ return new StonexFXTrade(attrs);
117
+ };
118
+ const StonexFXTrade = mongoose.model("StonexFXTrade", StonexFXTradeSchema);
119
+ return StonexFXTrade;
120
+ };
121
+ exports.buildStonexFXTrade = buildStonexFXTrade;
@@ -0,0 +1,21 @@
1
+ import { Mongoose, Model, Document } from "mongoose";
2
+ interface StonexLogAttrs {
3
+ timestamp: Date;
4
+ direction: "inbound" | "outbound";
5
+ session: "order" | "quote";
6
+ msgType: string;
7
+ data: string;
8
+ }
9
+ interface StonexLogDoc extends Document {
10
+ id: string;
11
+ timestamp: Date;
12
+ direction: "inbound" | "outbound";
13
+ session: "order" | "quote";
14
+ msgType: string;
15
+ data: string;
16
+ }
17
+ interface StonexLogModel extends Model<StonexLogDoc> {
18
+ build(attrs: StonexLogAttrs): StonexLogDoc;
19
+ }
20
+ declare const buildStonexLog: (mongoose: Mongoose) => StonexLogModel;
21
+ export { buildStonexLog, StonexLogDoc, StonexLogAttrs };
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildStonexLog = void 0;
4
+ const buildStonexLog = (mongoose) => {
5
+ if (mongoose.models.StonexLog) {
6
+ return mongoose.model("StonexLog");
7
+ }
8
+ const StonexLogSchema = new mongoose.Schema({
9
+ timestamp: {
10
+ type: Date,
11
+ required: true,
12
+ },
13
+ direction: {
14
+ type: String,
15
+ required: true,
16
+ enum: ["inbound", "outbound"],
17
+ },
18
+ session: {
19
+ type: String,
20
+ required: true,
21
+ enum: ["order", "quote"],
22
+ },
23
+ msgType: {
24
+ type: String,
25
+ required: true,
26
+ },
27
+ data: {
28
+ type: String,
29
+ required: true,
30
+ },
31
+ }, {
32
+ toJSON: {
33
+ transform(doc, ret) {
34
+ ret.id = ret._id.valueOf();
35
+ delete ret._id;
36
+ delete ret.__v;
37
+ },
38
+ },
39
+ });
40
+ StonexLogSchema.statics.build = (attrs) => {
41
+ return new StonexLog(attrs);
42
+ };
43
+ const StonexLog = mongoose.model("StonexLog", StonexLogSchema);
44
+ return StonexLog;
45
+ };
46
+ exports.buildStonexLog = buildStonexLog;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2765",
3
+ "version": "1.0.2766",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "@google-cloud/secret-manager": "^5.6.0",
25
25
  "@google-cloud/storage": "^7.19.0",
26
26
  "@hyperdx/node-opentelemetry": "^0.10.3",
27
- "@riocrypto/common": "1.0.2560",
27
+ "@riocrypto/common": "1.0.2563",
28
28
  "@slack/web-api": "^7.15.0",
29
29
  "@types/express": "^4.17.25",
30
30
  "axios": "1.13.6",