@riocrypto/common-server 1.0.2864 → 1.0.2865

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.
@@ -108,6 +108,26 @@ declare class ClusterClient {
108
108
  cancelFXTrade(fxTradeId: string): Promise<void>;
109
109
  resetOrderFXData(orderId: string): Promise<void>;
110
110
  resetOrderStatus(orderId: string, status: OrderStatus): Promise<void>;
111
+ confirmBankPayouts({ orderId, payouts, }: {
112
+ orderId: string;
113
+ payouts: {
114
+ amount: number;
115
+ SPEITrackingNumber?: string;
116
+ SPIDTrackingNumber?: string;
117
+ CEPLink?: string;
118
+ reference?: string;
119
+ sentAt: Date;
120
+ }[];
121
+ }): Promise<void>;
122
+ confirmCryptoPayouts({ orderId, payouts, }: {
123
+ orderId: string;
124
+ payouts: {
125
+ amount: number;
126
+ blockchainTxId?: string;
127
+ sentAt: Date;
128
+ }[];
129
+ }): Promise<void>;
130
+ confirmOrderLiquidity(orderId: string): Promise<void>;
111
131
  deleteInvoice(id: string): Promise<void>;
112
132
  deleteRecord(id: string): Promise<void>;
113
133
  createRecord(orderId: string, force: boolean): Promise<void>;
@@ -411,6 +411,33 @@ class ClusterClient {
411
411
  });
412
412
  });
413
413
  }
414
+ confirmBankPayouts({ orderId, payouts, }) {
415
+ return __awaiter(this, void 0, void 0, function* () {
416
+ yield this.axios.post(`${this.baseUrl}/api/payouts/bank/confirm`, { orderId, payouts }, {
417
+ headers: {
418
+ "x-cluster-api-key": this.clusterApiKey,
419
+ },
420
+ });
421
+ });
422
+ }
423
+ confirmCryptoPayouts({ orderId, payouts, }) {
424
+ return __awaiter(this, void 0, void 0, function* () {
425
+ yield this.axios.post(`${this.baseUrl}/api/payouts/crypto/confirm`, { orderId, payouts }, {
426
+ headers: {
427
+ "x-cluster-api-key": this.clusterApiKey,
428
+ },
429
+ });
430
+ });
431
+ }
432
+ confirmOrderLiquidity(orderId) {
433
+ return __awaiter(this, void 0, void 0, function* () {
434
+ yield this.axios.post(`${this.baseUrl}/api/liquidity/confirm`, { orderId }, {
435
+ headers: {
436
+ "x-cluster-api-key": this.clusterApiKey,
437
+ },
438
+ });
439
+ });
440
+ }
414
441
  deleteInvoice(id) {
415
442
  return __awaiter(this, void 0, void 0, function* () {
416
443
  yield this.axios.delete(`${this.baseUrl}/api/invoices/${id}`, {
@@ -23,6 +23,8 @@ const sanitizeOrderDoc = (doc) => {
23
23
  delete obj.actualAssetPriceInUSD;
24
24
  delete obj.previousActiveStatus;
25
25
  delete obj.binanceRFQOrderId;
26
+ delete obj.payoutAutoRetryAt;
27
+ delete obj.payoutAutoRetryCount;
26
28
  if (((_a = obj.paymentsReceived) === null || _a === void 0 ? void 0 : _a.length) > 0) {
27
29
  obj.paymentsReceived = obj.paymentsReceived.map((payment) => {
28
30
  if (payment.fireblocksTransferId) {
@@ -81,6 +81,8 @@ interface OrderAttrs {
81
81
  };
82
82
  payoutTransferLimit?: number;
83
83
  paymentReceivedAt?: Date;
84
+ payoutAutoRetryAt?: Date;
85
+ payoutAutoRetryCount?: number;
84
86
  version: number;
85
87
  invoice?: {
86
88
  PDFLink?: string;
@@ -278,6 +280,8 @@ interface OrderDoc extends Document {
278
280
  }[];
279
281
  payoutTransferLimit?: number;
280
282
  paymentReceivedAt?: Date;
283
+ payoutAutoRetryAt?: Date;
284
+ payoutAutoRetryCount?: number;
281
285
  version: number;
282
286
  informationalFees?: {
283
287
  serviceFeeFiat?: number;
@@ -360,6 +360,14 @@ const buildOrder = (mongoose) => {
360
360
  previousActiveStatus: {
361
361
  type: String,
362
362
  },
363
+ // Set when a failed payout is scheduled for an automated retry; unset
364
+ // once the retry has been claimed for processing.
365
+ payoutAutoRetryAt: {
366
+ type: mongoose.Schema.Types.Date,
367
+ },
368
+ payoutAutoRetryCount: {
369
+ type: Number,
370
+ },
363
371
  TWAP: {
364
372
  type: Object,
365
373
  },
@@ -382,6 +390,9 @@ const buildOrder = (mongoose) => {
382
390
  orderSchema.index({ brokerId: 1, createdAt: 1, side: 1, status: 1 });
383
391
  orderSchema.index({ brokerId: 1, createdAt: 1, country: 1 });
384
392
  orderSchema.index({ "TWAP.sessionId": 1 }, { sparse: true });
393
+ // Sparse: only orders with a pending automated payout retry carry this field,
394
+ // so the retry cron's due query never scans the full collection.
395
+ orderSchema.index({ payoutAutoRetryAt: 1 }, { sparse: true });
385
396
  orderSchema.index({ userId: 1, "TWAP.sessionId": 1, createdAt: 1 });
386
397
  orderSchema.index({ brokerId: 1, "TWAP.sessionId": 1, createdAt: 1 });
387
398
  orderSchema.index({ clientReferenceId: 1 }, { sparse: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2864",
3
+ "version": "1.0.2865",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "@google-cloud/secret-manager": "^5.6.0",
29
29
  "@google-cloud/storage": "^7.19.0",
30
30
  "@hyperdx/node-opentelemetry": "^0.10.3",
31
- "@riocrypto/common": "1.0.2673",
31
+ "@riocrypto/common": "1.0.2676",
32
32
  "@slack/web-api": "^7.15.0",
33
33
  "@types/express": "^4.17.25",
34
34
  "axios": "1.16.0",