pmxtjs 2.34.1 → 2.34.3
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.
- package/dist/esm/pmxt/client.d.ts +22 -0
- package/dist/esm/pmxt/client.js +386 -88
- package/dist/esm/pmxt/server-manager.js +16 -2
- package/dist/pmxt/client.d.ts +22 -0
- package/dist/pmxt/client.js +386 -88
- package/dist/pmxt/server-manager.js +16 -2
- package/generated/package.json +1 -1
- package/package.json +2 -2
- package/pmxt/client.ts +363 -88
- package/pmxt/server-manager.ts +15 -2
package/dist/pmxt/client.js
CHANGED
|
@@ -338,6 +338,51 @@ class Exchange {
|
|
|
338
338
|
}
|
|
339
339
|
return headers;
|
|
340
340
|
}
|
|
341
|
+
/**
|
|
342
|
+
* Resolve the current sidecar base URL.
|
|
343
|
+
*
|
|
344
|
+
* For hosted mode the configured basePath is returned as-is.
|
|
345
|
+
* For local mode the port is re-read from the lock file on every
|
|
346
|
+
* call so we pick up sidecar restarts that land on a different port.
|
|
347
|
+
*/
|
|
348
|
+
resolveBaseUrl() {
|
|
349
|
+
if (this.isHosted)
|
|
350
|
+
return this.config.basePath;
|
|
351
|
+
const port = this.serverManager.getRunningPort();
|
|
352
|
+
return `http://localhost:${port}`;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Execute a fetch with retry on connection failures.
|
|
356
|
+
*
|
|
357
|
+
* Only retries on connection-level errors (ECONNREFUSED, ECONNRESET) —
|
|
358
|
+
* never on HTTP responses (4xx, 5xx). On first connection failure,
|
|
359
|
+
* attempts to restart the sidecar.
|
|
360
|
+
*/
|
|
361
|
+
async fetchWithRetry(input, init) {
|
|
362
|
+
const delays = [200, 500, 1000];
|
|
363
|
+
let lastError;
|
|
364
|
+
for (let attempt = 0; attempt <= delays.length; attempt++) {
|
|
365
|
+
try {
|
|
366
|
+
return await fetch(input, init);
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
lastError = error;
|
|
370
|
+
if (attempt >= delays.length)
|
|
371
|
+
break;
|
|
372
|
+
// Connection failed — try to restart the sidecar on first failure
|
|
373
|
+
if (attempt === 0 && !this.isHosted) {
|
|
374
|
+
try {
|
|
375
|
+
await this.serverManager.ensureServerRunning();
|
|
376
|
+
}
|
|
377
|
+
catch {
|
|
378
|
+
// Restart failed — continue retrying anyway
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
await new Promise(resolve => setTimeout(resolve, delays[attempt]));
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
throw lastError;
|
|
385
|
+
}
|
|
341
386
|
// Low-Level API Access
|
|
342
387
|
/**
|
|
343
388
|
* Call an exchange-specific REST endpoint by its operationId.
|
|
@@ -357,12 +402,12 @@ class Exchange {
|
|
|
357
402
|
async callApi(operationId, params) {
|
|
358
403
|
await this.initPromise;
|
|
359
404
|
try {
|
|
360
|
-
const url = `${this.
|
|
405
|
+
const url = `${this.resolveBaseUrl()}/api/${this.exchangeName}/callApi`;
|
|
361
406
|
const requestBody = {
|
|
362
407
|
args: [operationId, params],
|
|
363
408
|
credentials: this.getCredentials()
|
|
364
409
|
};
|
|
365
|
-
const response = await
|
|
410
|
+
const response = await this.fetchWithRetry(url, {
|
|
366
411
|
method: 'POST',
|
|
367
412
|
headers: {
|
|
368
413
|
'Content-Type': 'application/json',
|
|
@@ -406,12 +451,13 @@ class Exchange {
|
|
|
406
451
|
* @internal — shared transport used by every generated read method.
|
|
407
452
|
*/
|
|
408
453
|
async sidecarReadRequest(methodName, query, args) {
|
|
409
|
-
const
|
|
454
|
+
const resolvedBase = this.resolveBaseUrl();
|
|
455
|
+
const baseUrl = `${resolvedBase}/api/${this.exchangeName}/${methodName}`;
|
|
410
456
|
const hasCredentials = this.getCredentials() !== undefined;
|
|
411
457
|
if (!hasCredentials && !this._getReadsUnsupported && !queryHasNestedObject(query)) {
|
|
412
458
|
const qs = buildSidecarQueryString(query);
|
|
413
459
|
const getUrl = qs ? `${baseUrl}?${qs}` : baseUrl;
|
|
414
|
-
const response = await
|
|
460
|
+
const response = await this.fetchWithRetry(getUrl, {
|
|
415
461
|
method: 'GET',
|
|
416
462
|
headers: this.getAuthHeaders(),
|
|
417
463
|
});
|
|
@@ -434,7 +480,7 @@ class Exchange {
|
|
|
434
480
|
}
|
|
435
481
|
}
|
|
436
482
|
// POST fallback — identical to the original per-method template.
|
|
437
|
-
const response = await
|
|
483
|
+
const response = await this.fetchWithRetry(baseUrl, {
|
|
438
484
|
method: 'POST',
|
|
439
485
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
440
486
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
@@ -454,14 +500,17 @@ class Exchange {
|
|
|
454
500
|
try {
|
|
455
501
|
const args = [];
|
|
456
502
|
args.push(reload);
|
|
457
|
-
const response = await
|
|
503
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/loadMarkets`, {
|
|
458
504
|
method: 'POST',
|
|
459
505
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
460
506
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
461
507
|
});
|
|
462
508
|
if (!response.ok) {
|
|
463
|
-
const
|
|
464
|
-
|
|
509
|
+
const body = await response.json().catch(() => ({}));
|
|
510
|
+
if (body.error && typeof body.error === "object") {
|
|
511
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
512
|
+
}
|
|
513
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
465
514
|
}
|
|
466
515
|
const json = await response.json();
|
|
467
516
|
const data = this.handleResponse(json);
|
|
@@ -472,7 +521,9 @@ class Exchange {
|
|
|
472
521
|
return result;
|
|
473
522
|
}
|
|
474
523
|
catch (error) {
|
|
475
|
-
|
|
524
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
525
|
+
throw error;
|
|
526
|
+
throw new errors_js_1.PmxtError(`Failed to loadMarkets: ${error}`);
|
|
476
527
|
}
|
|
477
528
|
}
|
|
478
529
|
async fetchMarkets(params) {
|
|
@@ -481,21 +532,26 @@ class Exchange {
|
|
|
481
532
|
const args = [];
|
|
482
533
|
if (params !== undefined)
|
|
483
534
|
args.push(params);
|
|
484
|
-
const response = await
|
|
535
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchMarkets`, {
|
|
485
536
|
method: 'POST',
|
|
486
537
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
487
538
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
488
539
|
});
|
|
489
540
|
if (!response.ok) {
|
|
490
|
-
const
|
|
491
|
-
|
|
541
|
+
const body = await response.json().catch(() => ({}));
|
|
542
|
+
if (body.error && typeof body.error === "object") {
|
|
543
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
544
|
+
}
|
|
545
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
492
546
|
}
|
|
493
547
|
const json = await response.json();
|
|
494
548
|
const data = this.handleResponse(json);
|
|
495
549
|
return data.map(convertMarket);
|
|
496
550
|
}
|
|
497
551
|
catch (error) {
|
|
498
|
-
|
|
552
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
553
|
+
throw error;
|
|
554
|
+
throw new errors_js_1.PmxtError(`Failed to fetchMarkets: ${error}`);
|
|
499
555
|
}
|
|
500
556
|
}
|
|
501
557
|
async fetchMarketsPaginated(params) {
|
|
@@ -504,14 +560,17 @@ class Exchange {
|
|
|
504
560
|
const args = [];
|
|
505
561
|
if (params !== undefined)
|
|
506
562
|
args.push(params);
|
|
507
|
-
const response = await
|
|
563
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchMarketsPaginated`, {
|
|
508
564
|
method: 'POST',
|
|
509
565
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
510
566
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
511
567
|
});
|
|
512
568
|
if (!response.ok) {
|
|
513
|
-
const
|
|
514
|
-
|
|
569
|
+
const body = await response.json().catch(() => ({}));
|
|
570
|
+
if (body.error && typeof body.error === "object") {
|
|
571
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
572
|
+
}
|
|
573
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
515
574
|
}
|
|
516
575
|
const json = await response.json();
|
|
517
576
|
const data = this.handleResponse(json);
|
|
@@ -522,7 +581,9 @@ class Exchange {
|
|
|
522
581
|
};
|
|
523
582
|
}
|
|
524
583
|
catch (error) {
|
|
525
|
-
|
|
584
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
585
|
+
throw error;
|
|
586
|
+
throw new errors_js_1.PmxtError(`Failed to fetchMarketsPaginated: ${error}`);
|
|
526
587
|
}
|
|
527
588
|
}
|
|
528
589
|
async fetchEvents(params) {
|
|
@@ -531,21 +592,26 @@ class Exchange {
|
|
|
531
592
|
const args = [];
|
|
532
593
|
if (params !== undefined)
|
|
533
594
|
args.push(params);
|
|
534
|
-
const response = await
|
|
595
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchEvents`, {
|
|
535
596
|
method: 'POST',
|
|
536
597
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
537
598
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
538
599
|
});
|
|
539
600
|
if (!response.ok) {
|
|
540
|
-
const
|
|
541
|
-
|
|
601
|
+
const body = await response.json().catch(() => ({}));
|
|
602
|
+
if (body.error && typeof body.error === "object") {
|
|
603
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
604
|
+
}
|
|
605
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
542
606
|
}
|
|
543
607
|
const json = await response.json();
|
|
544
608
|
const data = this.handleResponse(json);
|
|
545
609
|
return data.map(convertEvent);
|
|
546
610
|
}
|
|
547
611
|
catch (error) {
|
|
548
|
-
|
|
612
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
613
|
+
throw error;
|
|
614
|
+
throw new errors_js_1.PmxtError(`Failed to fetchEvents: ${error}`);
|
|
549
615
|
}
|
|
550
616
|
}
|
|
551
617
|
async fetchMarket(params) {
|
|
@@ -554,21 +620,26 @@ class Exchange {
|
|
|
554
620
|
const args = [];
|
|
555
621
|
if (params !== undefined)
|
|
556
622
|
args.push(params);
|
|
557
|
-
const response = await
|
|
623
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchMarket`, {
|
|
558
624
|
method: 'POST',
|
|
559
625
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
560
626
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
561
627
|
});
|
|
562
628
|
if (!response.ok) {
|
|
563
|
-
const
|
|
564
|
-
|
|
629
|
+
const body = await response.json().catch(() => ({}));
|
|
630
|
+
if (body.error && typeof body.error === "object") {
|
|
631
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
632
|
+
}
|
|
633
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
565
634
|
}
|
|
566
635
|
const json = await response.json();
|
|
567
636
|
const data = this.handleResponse(json);
|
|
568
637
|
return convertMarket(data);
|
|
569
638
|
}
|
|
570
639
|
catch (error) {
|
|
571
|
-
|
|
640
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
641
|
+
throw error;
|
|
642
|
+
throw new errors_js_1.PmxtError(`Failed to fetchMarket: ${error}`);
|
|
572
643
|
}
|
|
573
644
|
}
|
|
574
645
|
async fetchEvent(params) {
|
|
@@ -577,21 +648,26 @@ class Exchange {
|
|
|
577
648
|
const args = [];
|
|
578
649
|
if (params !== undefined)
|
|
579
650
|
args.push(params);
|
|
580
|
-
const response = await
|
|
651
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchEvent`, {
|
|
581
652
|
method: 'POST',
|
|
582
653
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
583
654
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
584
655
|
});
|
|
585
656
|
if (!response.ok) {
|
|
586
|
-
const
|
|
587
|
-
|
|
657
|
+
const body = await response.json().catch(() => ({}));
|
|
658
|
+
if (body.error && typeof body.error === "object") {
|
|
659
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
660
|
+
}
|
|
661
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
588
662
|
}
|
|
589
663
|
const json = await response.json();
|
|
590
664
|
const data = this.handleResponse(json);
|
|
591
665
|
return convertEvent(data);
|
|
592
666
|
}
|
|
593
667
|
catch (error) {
|
|
594
|
-
|
|
668
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
669
|
+
throw error;
|
|
670
|
+
throw new errors_js_1.PmxtError(`Failed to fetchEvent: ${error}`);
|
|
595
671
|
}
|
|
596
672
|
}
|
|
597
673
|
async fetchOrderBook(id) {
|
|
@@ -599,21 +675,26 @@ class Exchange {
|
|
|
599
675
|
try {
|
|
600
676
|
const args = [];
|
|
601
677
|
args.push(id);
|
|
602
|
-
const response = await
|
|
678
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchOrderBook`, {
|
|
603
679
|
method: 'POST',
|
|
604
680
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
605
681
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
606
682
|
});
|
|
607
683
|
if (!response.ok) {
|
|
608
|
-
const
|
|
609
|
-
|
|
684
|
+
const body = await response.json().catch(() => ({}));
|
|
685
|
+
if (body.error && typeof body.error === "object") {
|
|
686
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
687
|
+
}
|
|
688
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
610
689
|
}
|
|
611
690
|
const json = await response.json();
|
|
612
691
|
const data = this.handleResponse(json);
|
|
613
692
|
return convertOrderBook(data);
|
|
614
693
|
}
|
|
615
694
|
catch (error) {
|
|
616
|
-
|
|
695
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
696
|
+
throw error;
|
|
697
|
+
throw new errors_js_1.PmxtError(`Failed to fetchOrderBook: ${error}`);
|
|
617
698
|
}
|
|
618
699
|
}
|
|
619
700
|
async submitOrder(built) {
|
|
@@ -621,21 +702,26 @@ class Exchange {
|
|
|
621
702
|
try {
|
|
622
703
|
const args = [];
|
|
623
704
|
args.push(built);
|
|
624
|
-
const response = await
|
|
705
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/submitOrder`, {
|
|
625
706
|
method: 'POST',
|
|
626
707
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
627
708
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
628
709
|
});
|
|
629
710
|
if (!response.ok) {
|
|
630
|
-
const
|
|
631
|
-
|
|
711
|
+
const body = await response.json().catch(() => ({}));
|
|
712
|
+
if (body.error && typeof body.error === "object") {
|
|
713
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
714
|
+
}
|
|
715
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
632
716
|
}
|
|
633
717
|
const json = await response.json();
|
|
634
718
|
const data = this.handleResponse(json);
|
|
635
719
|
return convertOrder(data);
|
|
636
720
|
}
|
|
637
721
|
catch (error) {
|
|
638
|
-
|
|
722
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
723
|
+
throw error;
|
|
724
|
+
throw new errors_js_1.PmxtError(`Failed to submitOrder: ${error}`);
|
|
639
725
|
}
|
|
640
726
|
}
|
|
641
727
|
async cancelOrder(orderId) {
|
|
@@ -643,21 +729,26 @@ class Exchange {
|
|
|
643
729
|
try {
|
|
644
730
|
const args = [];
|
|
645
731
|
args.push(orderId);
|
|
646
|
-
const response = await
|
|
732
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/cancelOrder`, {
|
|
647
733
|
method: 'POST',
|
|
648
734
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
649
735
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
650
736
|
});
|
|
651
737
|
if (!response.ok) {
|
|
652
|
-
const
|
|
653
|
-
|
|
738
|
+
const body = await response.json().catch(() => ({}));
|
|
739
|
+
if (body.error && typeof body.error === "object") {
|
|
740
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
741
|
+
}
|
|
742
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
654
743
|
}
|
|
655
744
|
const json = await response.json();
|
|
656
745
|
const data = this.handleResponse(json);
|
|
657
746
|
return convertOrder(data);
|
|
658
747
|
}
|
|
659
748
|
catch (error) {
|
|
660
|
-
|
|
749
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
750
|
+
throw error;
|
|
751
|
+
throw new errors_js_1.PmxtError(`Failed to cancelOrder: ${error}`);
|
|
661
752
|
}
|
|
662
753
|
}
|
|
663
754
|
async fetchOrder(orderId) {
|
|
@@ -665,21 +756,26 @@ class Exchange {
|
|
|
665
756
|
try {
|
|
666
757
|
const args = [];
|
|
667
758
|
args.push(orderId);
|
|
668
|
-
const response = await
|
|
759
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchOrder`, {
|
|
669
760
|
method: 'POST',
|
|
670
761
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
671
762
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
672
763
|
});
|
|
673
764
|
if (!response.ok) {
|
|
674
|
-
const
|
|
675
|
-
|
|
765
|
+
const body = await response.json().catch(() => ({}));
|
|
766
|
+
if (body.error && typeof body.error === "object") {
|
|
767
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
768
|
+
}
|
|
769
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
676
770
|
}
|
|
677
771
|
const json = await response.json();
|
|
678
772
|
const data = this.handleResponse(json);
|
|
679
773
|
return convertOrder(data);
|
|
680
774
|
}
|
|
681
775
|
catch (error) {
|
|
682
|
-
|
|
776
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
777
|
+
throw error;
|
|
778
|
+
throw new errors_js_1.PmxtError(`Failed to fetchOrder: ${error}`);
|
|
683
779
|
}
|
|
684
780
|
}
|
|
685
781
|
async fetchOpenOrders(marketId) {
|
|
@@ -688,21 +784,26 @@ class Exchange {
|
|
|
688
784
|
const args = [];
|
|
689
785
|
if (marketId !== undefined)
|
|
690
786
|
args.push(marketId);
|
|
691
|
-
const response = await
|
|
787
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchOpenOrders`, {
|
|
692
788
|
method: 'POST',
|
|
693
789
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
694
790
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
695
791
|
});
|
|
696
792
|
if (!response.ok) {
|
|
697
|
-
const
|
|
698
|
-
|
|
793
|
+
const body = await response.json().catch(() => ({}));
|
|
794
|
+
if (body.error && typeof body.error === "object") {
|
|
795
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
796
|
+
}
|
|
797
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
699
798
|
}
|
|
700
799
|
const json = await response.json();
|
|
701
800
|
const data = this.handleResponse(json);
|
|
702
801
|
return data.map(convertOrder);
|
|
703
802
|
}
|
|
704
803
|
catch (error) {
|
|
705
|
-
|
|
804
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
805
|
+
throw error;
|
|
806
|
+
throw new errors_js_1.PmxtError(`Failed to fetchOpenOrders: ${error}`);
|
|
706
807
|
}
|
|
707
808
|
}
|
|
708
809
|
async fetchMyTrades(params) {
|
|
@@ -711,21 +812,26 @@ class Exchange {
|
|
|
711
812
|
const args = [];
|
|
712
813
|
if (params !== undefined)
|
|
713
814
|
args.push(params);
|
|
714
|
-
const response = await
|
|
815
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchMyTrades`, {
|
|
715
816
|
method: 'POST',
|
|
716
817
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
717
818
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
718
819
|
});
|
|
719
820
|
if (!response.ok) {
|
|
720
|
-
const
|
|
721
|
-
|
|
821
|
+
const body = await response.json().catch(() => ({}));
|
|
822
|
+
if (body.error && typeof body.error === "object") {
|
|
823
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
824
|
+
}
|
|
825
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
722
826
|
}
|
|
723
827
|
const json = await response.json();
|
|
724
828
|
const data = this.handleResponse(json);
|
|
725
829
|
return data.map(convertUserTrade);
|
|
726
830
|
}
|
|
727
831
|
catch (error) {
|
|
728
|
-
|
|
832
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
833
|
+
throw error;
|
|
834
|
+
throw new errors_js_1.PmxtError(`Failed to fetchMyTrades: ${error}`);
|
|
729
835
|
}
|
|
730
836
|
}
|
|
731
837
|
async fetchClosedOrders(params) {
|
|
@@ -734,21 +840,26 @@ class Exchange {
|
|
|
734
840
|
const args = [];
|
|
735
841
|
if (params !== undefined)
|
|
736
842
|
args.push(params);
|
|
737
|
-
const response = await
|
|
843
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchClosedOrders`, {
|
|
738
844
|
method: 'POST',
|
|
739
845
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
740
846
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
741
847
|
});
|
|
742
848
|
if (!response.ok) {
|
|
743
|
-
const
|
|
744
|
-
|
|
849
|
+
const body = await response.json().catch(() => ({}));
|
|
850
|
+
if (body.error && typeof body.error === "object") {
|
|
851
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
852
|
+
}
|
|
853
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
745
854
|
}
|
|
746
855
|
const json = await response.json();
|
|
747
856
|
const data = this.handleResponse(json);
|
|
748
857
|
return data.map(convertOrder);
|
|
749
858
|
}
|
|
750
859
|
catch (error) {
|
|
751
|
-
|
|
860
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
861
|
+
throw error;
|
|
862
|
+
throw new errors_js_1.PmxtError(`Failed to fetchClosedOrders: ${error}`);
|
|
752
863
|
}
|
|
753
864
|
}
|
|
754
865
|
async fetchAllOrders(params) {
|
|
@@ -757,21 +868,26 @@ class Exchange {
|
|
|
757
868
|
const args = [];
|
|
758
869
|
if (params !== undefined)
|
|
759
870
|
args.push(params);
|
|
760
|
-
const response = await
|
|
871
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchAllOrders`, {
|
|
761
872
|
method: 'POST',
|
|
762
873
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
763
874
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
764
875
|
});
|
|
765
876
|
if (!response.ok) {
|
|
766
|
-
const
|
|
767
|
-
|
|
877
|
+
const body = await response.json().catch(() => ({}));
|
|
878
|
+
if (body.error && typeof body.error === "object") {
|
|
879
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
880
|
+
}
|
|
881
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
768
882
|
}
|
|
769
883
|
const json = await response.json();
|
|
770
884
|
const data = this.handleResponse(json);
|
|
771
885
|
return data.map(convertOrder);
|
|
772
886
|
}
|
|
773
887
|
catch (error) {
|
|
774
|
-
|
|
888
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
889
|
+
throw error;
|
|
890
|
+
throw new errors_js_1.PmxtError(`Failed to fetchAllOrders: ${error}`);
|
|
775
891
|
}
|
|
776
892
|
}
|
|
777
893
|
async fetchPositions(address) {
|
|
@@ -780,21 +896,26 @@ class Exchange {
|
|
|
780
896
|
const args = [];
|
|
781
897
|
if (address !== undefined)
|
|
782
898
|
args.push(address);
|
|
783
|
-
const response = await
|
|
899
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchPositions`, {
|
|
784
900
|
method: 'POST',
|
|
785
901
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
786
902
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
787
903
|
});
|
|
788
904
|
if (!response.ok) {
|
|
789
|
-
const
|
|
790
|
-
|
|
905
|
+
const body = await response.json().catch(() => ({}));
|
|
906
|
+
if (body.error && typeof body.error === "object") {
|
|
907
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
908
|
+
}
|
|
909
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
791
910
|
}
|
|
792
911
|
const json = await response.json();
|
|
793
912
|
const data = this.handleResponse(json);
|
|
794
913
|
return data.map(convertPosition);
|
|
795
914
|
}
|
|
796
915
|
catch (error) {
|
|
797
|
-
|
|
916
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
917
|
+
throw error;
|
|
918
|
+
throw new errors_js_1.PmxtError(`Failed to fetchPositions: ${error}`);
|
|
798
919
|
}
|
|
799
920
|
}
|
|
800
921
|
async fetchBalance(address) {
|
|
@@ -803,21 +924,26 @@ class Exchange {
|
|
|
803
924
|
const args = [];
|
|
804
925
|
if (address !== undefined)
|
|
805
926
|
args.push(address);
|
|
806
|
-
const response = await
|
|
927
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchBalance`, {
|
|
807
928
|
method: 'POST',
|
|
808
929
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
809
930
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
810
931
|
});
|
|
811
932
|
if (!response.ok) {
|
|
812
|
-
const
|
|
813
|
-
|
|
933
|
+
const body = await response.json().catch(() => ({}));
|
|
934
|
+
if (body.error && typeof body.error === "object") {
|
|
935
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
936
|
+
}
|
|
937
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
814
938
|
}
|
|
815
939
|
const json = await response.json();
|
|
816
940
|
const data = this.handleResponse(json);
|
|
817
941
|
return data.map(convertBalance);
|
|
818
942
|
}
|
|
819
943
|
catch (error) {
|
|
820
|
-
|
|
944
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
945
|
+
throw error;
|
|
946
|
+
throw new errors_js_1.PmxtError(`Failed to fetchBalance: ${error}`);
|
|
821
947
|
}
|
|
822
948
|
}
|
|
823
949
|
async unwatchOrderBook(id) {
|
|
@@ -825,20 +951,25 @@ class Exchange {
|
|
|
825
951
|
try {
|
|
826
952
|
const args = [];
|
|
827
953
|
args.push(id);
|
|
828
|
-
const response = await
|
|
954
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/unwatchOrderBook`, {
|
|
829
955
|
method: 'POST',
|
|
830
956
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
831
957
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
832
958
|
});
|
|
833
959
|
if (!response.ok) {
|
|
834
|
-
const
|
|
835
|
-
|
|
960
|
+
const body = await response.json().catch(() => ({}));
|
|
961
|
+
if (body.error && typeof body.error === "object") {
|
|
962
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
963
|
+
}
|
|
964
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
836
965
|
}
|
|
837
966
|
const json = await response.json();
|
|
838
967
|
this.handleResponse(json);
|
|
839
968
|
}
|
|
840
969
|
catch (error) {
|
|
841
|
-
|
|
970
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
971
|
+
throw error;
|
|
972
|
+
throw new errors_js_1.PmxtError(`Failed to unwatchOrderBook: ${error}`);
|
|
842
973
|
}
|
|
843
974
|
}
|
|
844
975
|
async unwatchAddress(address) {
|
|
@@ -846,40 +977,207 @@ class Exchange {
|
|
|
846
977
|
try {
|
|
847
978
|
const args = [];
|
|
848
979
|
args.push(address);
|
|
849
|
-
const response = await
|
|
980
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/unwatchAddress`, {
|
|
850
981
|
method: 'POST',
|
|
851
982
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
852
983
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
853
984
|
});
|
|
854
985
|
if (!response.ok) {
|
|
855
|
-
const
|
|
856
|
-
|
|
986
|
+
const body = await response.json().catch(() => ({}));
|
|
987
|
+
if (body.error && typeof body.error === "object") {
|
|
988
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
989
|
+
}
|
|
990
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
857
991
|
}
|
|
858
992
|
const json = await response.json();
|
|
859
993
|
this.handleResponse(json);
|
|
860
994
|
}
|
|
861
995
|
catch (error) {
|
|
862
|
-
|
|
996
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
997
|
+
throw error;
|
|
998
|
+
throw new errors_js_1.PmxtError(`Failed to unwatchAddress: ${error}`);
|
|
863
999
|
}
|
|
864
1000
|
}
|
|
865
1001
|
async close() {
|
|
866
1002
|
await this.initPromise;
|
|
867
1003
|
try {
|
|
868
1004
|
const args = [];
|
|
869
|
-
const response = await
|
|
1005
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/close`, {
|
|
870
1006
|
method: 'POST',
|
|
871
1007
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
872
1008
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
873
1009
|
});
|
|
874
1010
|
if (!response.ok) {
|
|
875
|
-
const
|
|
876
|
-
|
|
1011
|
+
const body = await response.json().catch(() => ({}));
|
|
1012
|
+
if (body.error && typeof body.error === "object") {
|
|
1013
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
1014
|
+
}
|
|
1015
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
877
1016
|
}
|
|
878
1017
|
const json = await response.json();
|
|
879
1018
|
this.handleResponse(json);
|
|
880
1019
|
}
|
|
881
1020
|
catch (error) {
|
|
882
|
-
|
|
1021
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
1022
|
+
throw error;
|
|
1023
|
+
throw new errors_js_1.PmxtError(`Failed to close: ${error}`);
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
async fetchMarketMatches(params) {
|
|
1027
|
+
await this.initPromise;
|
|
1028
|
+
try {
|
|
1029
|
+
const args = [];
|
|
1030
|
+
args.push(params);
|
|
1031
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchMarketMatches`, {
|
|
1032
|
+
method: 'POST',
|
|
1033
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1034
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
1035
|
+
});
|
|
1036
|
+
if (!response.ok) {
|
|
1037
|
+
const body = await response.json().catch(() => ({}));
|
|
1038
|
+
if (body.error && typeof body.error === "object") {
|
|
1039
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
1040
|
+
}
|
|
1041
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
1042
|
+
}
|
|
1043
|
+
const json = await response.json();
|
|
1044
|
+
return this.handleResponse(json);
|
|
1045
|
+
}
|
|
1046
|
+
catch (error) {
|
|
1047
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
1048
|
+
throw error;
|
|
1049
|
+
throw new errors_js_1.PmxtError(`Failed to fetchMarketMatches: ${error}`);
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1052
|
+
async fetchMatches(params) {
|
|
1053
|
+
await this.initPromise;
|
|
1054
|
+
try {
|
|
1055
|
+
const args = [];
|
|
1056
|
+
args.push(params);
|
|
1057
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchMatches`, {
|
|
1058
|
+
method: 'POST',
|
|
1059
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1060
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
1061
|
+
});
|
|
1062
|
+
if (!response.ok) {
|
|
1063
|
+
const body = await response.json().catch(() => ({}));
|
|
1064
|
+
if (body.error && typeof body.error === "object") {
|
|
1065
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
1066
|
+
}
|
|
1067
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
1068
|
+
}
|
|
1069
|
+
const json = await response.json();
|
|
1070
|
+
return this.handleResponse(json);
|
|
1071
|
+
}
|
|
1072
|
+
catch (error) {
|
|
1073
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
1074
|
+
throw error;
|
|
1075
|
+
throw new errors_js_1.PmxtError(`Failed to fetchMatches: ${error}`);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
async fetchEventMatches(params) {
|
|
1079
|
+
await this.initPromise;
|
|
1080
|
+
try {
|
|
1081
|
+
const args = [];
|
|
1082
|
+
args.push(params);
|
|
1083
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchEventMatches`, {
|
|
1084
|
+
method: 'POST',
|
|
1085
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1086
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
1087
|
+
});
|
|
1088
|
+
if (!response.ok) {
|
|
1089
|
+
const body = await response.json().catch(() => ({}));
|
|
1090
|
+
if (body.error && typeof body.error === "object") {
|
|
1091
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
1092
|
+
}
|
|
1093
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
1094
|
+
}
|
|
1095
|
+
const json = await response.json();
|
|
1096
|
+
return this.handleResponse(json);
|
|
1097
|
+
}
|
|
1098
|
+
catch (error) {
|
|
1099
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
1100
|
+
throw error;
|
|
1101
|
+
throw new errors_js_1.PmxtError(`Failed to fetchEventMatches: ${error}`);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
async compareMarketPrices(params) {
|
|
1105
|
+
await this.initPromise;
|
|
1106
|
+
try {
|
|
1107
|
+
const args = [];
|
|
1108
|
+
args.push(params);
|
|
1109
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/compareMarketPrices`, {
|
|
1110
|
+
method: 'POST',
|
|
1111
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1112
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
1113
|
+
});
|
|
1114
|
+
if (!response.ok) {
|
|
1115
|
+
const body = await response.json().catch(() => ({}));
|
|
1116
|
+
if (body.error && typeof body.error === "object") {
|
|
1117
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
1118
|
+
}
|
|
1119
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
1120
|
+
}
|
|
1121
|
+
const json = await response.json();
|
|
1122
|
+
return this.handleResponse(json);
|
|
1123
|
+
}
|
|
1124
|
+
catch (error) {
|
|
1125
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
1126
|
+
throw error;
|
|
1127
|
+
throw new errors_js_1.PmxtError(`Failed to compareMarketPrices: ${error}`);
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
async fetchHedges(params) {
|
|
1131
|
+
await this.initPromise;
|
|
1132
|
+
try {
|
|
1133
|
+
const args = [];
|
|
1134
|
+
args.push(params);
|
|
1135
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchHedges`, {
|
|
1136
|
+
method: 'POST',
|
|
1137
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1138
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
1139
|
+
});
|
|
1140
|
+
if (!response.ok) {
|
|
1141
|
+
const body = await response.json().catch(() => ({}));
|
|
1142
|
+
if (body.error && typeof body.error === "object") {
|
|
1143
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
1144
|
+
}
|
|
1145
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
1146
|
+
}
|
|
1147
|
+
const json = await response.json();
|
|
1148
|
+
return this.handleResponse(json);
|
|
1149
|
+
}
|
|
1150
|
+
catch (error) {
|
|
1151
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
1152
|
+
throw error;
|
|
1153
|
+
throw new errors_js_1.PmxtError(`Failed to fetchHedges: ${error}`);
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
async fetchArbitrage(params) {
|
|
1157
|
+
await this.initPromise;
|
|
1158
|
+
try {
|
|
1159
|
+
const args = [];
|
|
1160
|
+
if (params !== undefined)
|
|
1161
|
+
args.push(params);
|
|
1162
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/fetchArbitrage`, {
|
|
1163
|
+
method: 'POST',
|
|
1164
|
+
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1165
|
+
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
1166
|
+
});
|
|
1167
|
+
if (!response.ok) {
|
|
1168
|
+
const body = await response.json().catch(() => ({}));
|
|
1169
|
+
if (body.error && typeof body.error === "object") {
|
|
1170
|
+
throw (0, errors_js_1.fromServerError)(body.error);
|
|
1171
|
+
}
|
|
1172
|
+
throw new errors_js_1.PmxtError(body.error?.message || response.statusText);
|
|
1173
|
+
}
|
|
1174
|
+
const json = await response.json();
|
|
1175
|
+
return this.handleResponse(json);
|
|
1176
|
+
}
|
|
1177
|
+
catch (error) {
|
|
1178
|
+
if (error instanceof errors_js_1.PmxtError)
|
|
1179
|
+
throw error;
|
|
1180
|
+
throw new errors_js_1.PmxtError(`Failed to fetchArbitrage: ${error}`);
|
|
883
1181
|
}
|
|
884
1182
|
}
|
|
885
1183
|
// END GENERATED METHODS
|
|
@@ -984,7 +1282,7 @@ class Exchange {
|
|
|
984
1282
|
if (limit !== undefined) {
|
|
985
1283
|
args.push(limit);
|
|
986
1284
|
}
|
|
987
|
-
const response = await
|
|
1285
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/watchOrderBook`, {
|
|
988
1286
|
method: 'POST',
|
|
989
1287
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
990
1288
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
@@ -1043,7 +1341,7 @@ class Exchange {
|
|
|
1043
1341
|
if (limit !== undefined) {
|
|
1044
1342
|
args.push(limit);
|
|
1045
1343
|
}
|
|
1046
|
-
const response = await
|
|
1344
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/watchTrades`, {
|
|
1047
1345
|
method: 'POST',
|
|
1048
1346
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1049
1347
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
@@ -1093,7 +1391,7 @@ class Exchange {
|
|
|
1093
1391
|
if (types !== undefined) {
|
|
1094
1392
|
args.push(types);
|
|
1095
1393
|
}
|
|
1096
|
-
const response = await
|
|
1394
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/watchAddress`, {
|
|
1097
1395
|
method: 'POST',
|
|
1098
1396
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1099
1397
|
body: JSON.stringify({ args, credentials: this.getCredentials() }),
|
|
@@ -1181,7 +1479,7 @@ class Exchange {
|
|
|
1181
1479
|
if (params.fee !== undefined) {
|
|
1182
1480
|
paramsDict.fee = params.fee;
|
|
1183
1481
|
}
|
|
1184
|
-
const response = await
|
|
1482
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/buildOrder`, {
|
|
1185
1483
|
method: 'POST',
|
|
1186
1484
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1187
1485
|
body: JSON.stringify({ args: [paramsDict], credentials: this.getCredentials() }),
|
|
@@ -1251,7 +1549,7 @@ class Exchange {
|
|
|
1251
1549
|
if (params.fee !== undefined) {
|
|
1252
1550
|
paramsDict.fee = params.fee;
|
|
1253
1551
|
}
|
|
1254
|
-
const response = await
|
|
1552
|
+
const response = await this.fetchWithRetry(`${this.resolveBaseUrl()}/api/${this.exchangeName}/createOrder`, {
|
|
1255
1553
|
method: 'POST',
|
|
1256
1554
|
headers: { 'Content-Type': 'application/json', ...this.getAuthHeaders() },
|
|
1257
1555
|
body: JSON.stringify({ args: [paramsDict], credentials: this.getCredentials() }),
|
|
@@ -1305,8 +1603,8 @@ class Exchange {
|
|
|
1305
1603
|
if (credentials) {
|
|
1306
1604
|
body.credentials = credentials;
|
|
1307
1605
|
}
|
|
1308
|
-
const url = `${this.
|
|
1309
|
-
const response = await
|
|
1606
|
+
const url = `${this.resolveBaseUrl()}/api/${this.exchangeName}/getExecutionPriceDetailed`;
|
|
1607
|
+
const response = await this.fetchWithRetry(url, {
|
|
1310
1608
|
method: 'POST',
|
|
1311
1609
|
headers: {
|
|
1312
1610
|
'Content-Type': 'application/json',
|