@cowprotocol/cow-sdk 0.0.13 → 0.0.14
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/api/cow/types.d.ts +9 -3
- package/dist/api/cow-subgraph/graphql.d.ts +132 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +2 -2
- package/dist/index.modern.js.map +1 -1
- package/dist/index.module.js +2 -2
- package/dist/index.module.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/sign.d.ts +1 -1
- package/package.json +2 -2
package/dist/api/cow/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { GetQuoteResponse, OrderKind } from '@
|
|
1
|
+
import { GetQuoteResponse, OrderKind } from '@cowprotocol/contracts';
|
|
2
|
+
import { StrictUnion } from 'utilities';
|
|
2
3
|
import { SupportedChainId as ChainId } from '../../constants/chains';
|
|
3
4
|
import { OrderCancellation, SigningSchemeValue } from '../../utils/sign';
|
|
4
5
|
/**
|
|
@@ -61,9 +62,13 @@ export declare type OrderCancellationParams = {
|
|
|
61
62
|
export declare type GetOrdersParams = {
|
|
62
63
|
owner: string;
|
|
63
64
|
} & PaginationParams;
|
|
64
|
-
|
|
65
|
+
declare type WithOwner = {
|
|
65
66
|
owner: string;
|
|
66
|
-
}
|
|
67
|
+
};
|
|
68
|
+
declare type WithOrderId = {
|
|
69
|
+
orderId: string;
|
|
70
|
+
};
|
|
71
|
+
export declare type GetTradesParams = StrictUnion<WithOwner | WithOrderId> & PaginationParams;
|
|
67
72
|
export declare type ProfileData = {
|
|
68
73
|
totalTrades: number;
|
|
69
74
|
totalReferrals: number;
|
|
@@ -104,3 +109,4 @@ export declare type PriceQuoteParams = Omit<FeeQuoteParams, 'sellToken' | 'buyTo
|
|
|
104
109
|
baseToken: string;
|
|
105
110
|
quoteToken: string;
|
|
106
111
|
};
|
|
112
|
+
export {};
|
|
@@ -442,8 +442,16 @@ export declare type Pair = {
|
|
|
442
442
|
id: Scalars['ID'];
|
|
443
443
|
/** The token 0 address lower than token1 */
|
|
444
444
|
token0: Token;
|
|
445
|
+
/** Token0 last trade price */
|
|
446
|
+
token0Price?: Maybe<Scalars['BigDecimal']>;
|
|
447
|
+
/** Token 0 price expressed in token1 in the last trade */
|
|
448
|
+
token0relativePrice?: Maybe<Scalars['BigDecimal']>;
|
|
445
449
|
/** The token 1 address greater than token0 */
|
|
446
450
|
token1: Token;
|
|
451
|
+
/** Token1 last trade price */
|
|
452
|
+
token1Price?: Maybe<Scalars['BigDecimal']>;
|
|
453
|
+
/** Token 1 price expressed in token1 in the last trade */
|
|
454
|
+
token1relativePrice?: Maybe<Scalars['BigDecimal']>;
|
|
447
455
|
/** Total volume of token 0 traded */
|
|
448
456
|
volumeToken0?: Maybe<Scalars['BigInt']>;
|
|
449
457
|
/** Total volume of token 1 traded */
|
|
@@ -461,8 +469,16 @@ export declare type PairDaily = {
|
|
|
461
469
|
timestamp: Scalars['Int'];
|
|
462
470
|
/** The token 0 address lower than token1 */
|
|
463
471
|
token0: Token;
|
|
472
|
+
/** Token0 last trade price */
|
|
473
|
+
token0Price?: Maybe<Scalars['BigDecimal']>;
|
|
474
|
+
/** Token 0 price expressed in token1 in the last trade */
|
|
475
|
+
token0relativePrice?: Maybe<Scalars['BigDecimal']>;
|
|
464
476
|
/** The token 1 address greater than token0 */
|
|
465
477
|
token1: Token;
|
|
478
|
+
/** Token1 last trade price */
|
|
479
|
+
token1Price?: Maybe<Scalars['BigDecimal']>;
|
|
480
|
+
/** Token 1 price expressed in token1 in the last trade */
|
|
481
|
+
token1relativePrice?: Maybe<Scalars['BigDecimal']>;
|
|
466
482
|
/** Total volume of token 0 traded */
|
|
467
483
|
volumeToken0?: Maybe<Scalars['BigInt']>;
|
|
468
484
|
/** Total volume of token 1 traded */
|
|
@@ -492,6 +508,14 @@ export declare type PairDaily_Filter = {
|
|
|
492
508
|
timestamp_not?: InputMaybe<Scalars['Int']>;
|
|
493
509
|
timestamp_not_in?: InputMaybe<Array<Scalars['Int']>>;
|
|
494
510
|
token0?: InputMaybe<Scalars['String']>;
|
|
511
|
+
token0Price?: InputMaybe<Scalars['BigDecimal']>;
|
|
512
|
+
token0Price_gt?: InputMaybe<Scalars['BigDecimal']>;
|
|
513
|
+
token0Price_gte?: InputMaybe<Scalars['BigDecimal']>;
|
|
514
|
+
token0Price_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
515
|
+
token0Price_lt?: InputMaybe<Scalars['BigDecimal']>;
|
|
516
|
+
token0Price_lte?: InputMaybe<Scalars['BigDecimal']>;
|
|
517
|
+
token0Price_not?: InputMaybe<Scalars['BigDecimal']>;
|
|
518
|
+
token0Price_not_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
495
519
|
token0_contains?: InputMaybe<Scalars['String']>;
|
|
496
520
|
token0_contains_nocase?: InputMaybe<Scalars['String']>;
|
|
497
521
|
token0_ends_with?: InputMaybe<Scalars['String']>;
|
|
@@ -511,7 +535,23 @@ export declare type PairDaily_Filter = {
|
|
|
511
535
|
token0_not_starts_with_nocase?: InputMaybe<Scalars['String']>;
|
|
512
536
|
token0_starts_with?: InputMaybe<Scalars['String']>;
|
|
513
537
|
token0_starts_with_nocase?: InputMaybe<Scalars['String']>;
|
|
538
|
+
token0relativePrice?: InputMaybe<Scalars['BigDecimal']>;
|
|
539
|
+
token0relativePrice_gt?: InputMaybe<Scalars['BigDecimal']>;
|
|
540
|
+
token0relativePrice_gte?: InputMaybe<Scalars['BigDecimal']>;
|
|
541
|
+
token0relativePrice_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
542
|
+
token0relativePrice_lt?: InputMaybe<Scalars['BigDecimal']>;
|
|
543
|
+
token0relativePrice_lte?: InputMaybe<Scalars['BigDecimal']>;
|
|
544
|
+
token0relativePrice_not?: InputMaybe<Scalars['BigDecimal']>;
|
|
545
|
+
token0relativePrice_not_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
514
546
|
token1?: InputMaybe<Scalars['String']>;
|
|
547
|
+
token1Price?: InputMaybe<Scalars['BigDecimal']>;
|
|
548
|
+
token1Price_gt?: InputMaybe<Scalars['BigDecimal']>;
|
|
549
|
+
token1Price_gte?: InputMaybe<Scalars['BigDecimal']>;
|
|
550
|
+
token1Price_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
551
|
+
token1Price_lt?: InputMaybe<Scalars['BigDecimal']>;
|
|
552
|
+
token1Price_lte?: InputMaybe<Scalars['BigDecimal']>;
|
|
553
|
+
token1Price_not?: InputMaybe<Scalars['BigDecimal']>;
|
|
554
|
+
token1Price_not_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
515
555
|
token1_contains?: InputMaybe<Scalars['String']>;
|
|
516
556
|
token1_contains_nocase?: InputMaybe<Scalars['String']>;
|
|
517
557
|
token1_ends_with?: InputMaybe<Scalars['String']>;
|
|
@@ -531,6 +571,14 @@ export declare type PairDaily_Filter = {
|
|
|
531
571
|
token1_not_starts_with_nocase?: InputMaybe<Scalars['String']>;
|
|
532
572
|
token1_starts_with?: InputMaybe<Scalars['String']>;
|
|
533
573
|
token1_starts_with_nocase?: InputMaybe<Scalars['String']>;
|
|
574
|
+
token1relativePrice?: InputMaybe<Scalars['BigDecimal']>;
|
|
575
|
+
token1relativePrice_gt?: InputMaybe<Scalars['BigDecimal']>;
|
|
576
|
+
token1relativePrice_gte?: InputMaybe<Scalars['BigDecimal']>;
|
|
577
|
+
token1relativePrice_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
578
|
+
token1relativePrice_lt?: InputMaybe<Scalars['BigDecimal']>;
|
|
579
|
+
token1relativePrice_lte?: InputMaybe<Scalars['BigDecimal']>;
|
|
580
|
+
token1relativePrice_not?: InputMaybe<Scalars['BigDecimal']>;
|
|
581
|
+
token1relativePrice_not_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
534
582
|
volumeToken0?: InputMaybe<Scalars['BigInt']>;
|
|
535
583
|
volumeToken0_gt?: InputMaybe<Scalars['BigInt']>;
|
|
536
584
|
volumeToken0_gte?: InputMaybe<Scalars['BigInt']>;
|
|
@@ -568,7 +616,11 @@ export declare enum PairDaily_OrderBy {
|
|
|
568
616
|
Id = "id",
|
|
569
617
|
Timestamp = "timestamp",
|
|
570
618
|
Token0 = "token0",
|
|
619
|
+
Token0Price = "token0Price",
|
|
620
|
+
Token0relativePrice = "token0relativePrice",
|
|
571
621
|
Token1 = "token1",
|
|
622
|
+
Token1Price = "token1Price",
|
|
623
|
+
Token1relativePrice = "token1relativePrice",
|
|
572
624
|
VolumeToken0 = "volumeToken0",
|
|
573
625
|
VolumeToken1 = "volumeToken1",
|
|
574
626
|
VolumeTradedEth = "volumeTradedEth",
|
|
@@ -582,8 +634,16 @@ export declare type PairHourly = {
|
|
|
582
634
|
timestamp: Scalars['Int'];
|
|
583
635
|
/** The token 0 address lower than token1 */
|
|
584
636
|
token0: Token;
|
|
637
|
+
/** Token0 last trade price */
|
|
638
|
+
token0Price?: Maybe<Scalars['BigDecimal']>;
|
|
639
|
+
/** Token 0 price expressed in token1 in the last trade */
|
|
640
|
+
token0relativePrice?: Maybe<Scalars['BigDecimal']>;
|
|
585
641
|
/** The token 1 address greater than token0 */
|
|
586
642
|
token1: Token;
|
|
643
|
+
/** Token1 last trade price */
|
|
644
|
+
token1Price?: Maybe<Scalars['BigDecimal']>;
|
|
645
|
+
/** Token 1 price expressed in token1 in the last trade */
|
|
646
|
+
token1relativePrice?: Maybe<Scalars['BigDecimal']>;
|
|
587
647
|
/** Total volume of token 0 traded */
|
|
588
648
|
volumeToken0?: Maybe<Scalars['BigInt']>;
|
|
589
649
|
/** Total volume of token 1 traded */
|
|
@@ -613,6 +673,14 @@ export declare type PairHourly_Filter = {
|
|
|
613
673
|
timestamp_not?: InputMaybe<Scalars['Int']>;
|
|
614
674
|
timestamp_not_in?: InputMaybe<Array<Scalars['Int']>>;
|
|
615
675
|
token0?: InputMaybe<Scalars['String']>;
|
|
676
|
+
token0Price?: InputMaybe<Scalars['BigDecimal']>;
|
|
677
|
+
token0Price_gt?: InputMaybe<Scalars['BigDecimal']>;
|
|
678
|
+
token0Price_gte?: InputMaybe<Scalars['BigDecimal']>;
|
|
679
|
+
token0Price_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
680
|
+
token0Price_lt?: InputMaybe<Scalars['BigDecimal']>;
|
|
681
|
+
token0Price_lte?: InputMaybe<Scalars['BigDecimal']>;
|
|
682
|
+
token0Price_not?: InputMaybe<Scalars['BigDecimal']>;
|
|
683
|
+
token0Price_not_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
616
684
|
token0_contains?: InputMaybe<Scalars['String']>;
|
|
617
685
|
token0_contains_nocase?: InputMaybe<Scalars['String']>;
|
|
618
686
|
token0_ends_with?: InputMaybe<Scalars['String']>;
|
|
@@ -632,7 +700,23 @@ export declare type PairHourly_Filter = {
|
|
|
632
700
|
token0_not_starts_with_nocase?: InputMaybe<Scalars['String']>;
|
|
633
701
|
token0_starts_with?: InputMaybe<Scalars['String']>;
|
|
634
702
|
token0_starts_with_nocase?: InputMaybe<Scalars['String']>;
|
|
703
|
+
token0relativePrice?: InputMaybe<Scalars['BigDecimal']>;
|
|
704
|
+
token0relativePrice_gt?: InputMaybe<Scalars['BigDecimal']>;
|
|
705
|
+
token0relativePrice_gte?: InputMaybe<Scalars['BigDecimal']>;
|
|
706
|
+
token0relativePrice_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
707
|
+
token0relativePrice_lt?: InputMaybe<Scalars['BigDecimal']>;
|
|
708
|
+
token0relativePrice_lte?: InputMaybe<Scalars['BigDecimal']>;
|
|
709
|
+
token0relativePrice_not?: InputMaybe<Scalars['BigDecimal']>;
|
|
710
|
+
token0relativePrice_not_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
635
711
|
token1?: InputMaybe<Scalars['String']>;
|
|
712
|
+
token1Price?: InputMaybe<Scalars['BigDecimal']>;
|
|
713
|
+
token1Price_gt?: InputMaybe<Scalars['BigDecimal']>;
|
|
714
|
+
token1Price_gte?: InputMaybe<Scalars['BigDecimal']>;
|
|
715
|
+
token1Price_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
716
|
+
token1Price_lt?: InputMaybe<Scalars['BigDecimal']>;
|
|
717
|
+
token1Price_lte?: InputMaybe<Scalars['BigDecimal']>;
|
|
718
|
+
token1Price_not?: InputMaybe<Scalars['BigDecimal']>;
|
|
719
|
+
token1Price_not_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
636
720
|
token1_contains?: InputMaybe<Scalars['String']>;
|
|
637
721
|
token1_contains_nocase?: InputMaybe<Scalars['String']>;
|
|
638
722
|
token1_ends_with?: InputMaybe<Scalars['String']>;
|
|
@@ -652,6 +736,14 @@ export declare type PairHourly_Filter = {
|
|
|
652
736
|
token1_not_starts_with_nocase?: InputMaybe<Scalars['String']>;
|
|
653
737
|
token1_starts_with?: InputMaybe<Scalars['String']>;
|
|
654
738
|
token1_starts_with_nocase?: InputMaybe<Scalars['String']>;
|
|
739
|
+
token1relativePrice?: InputMaybe<Scalars['BigDecimal']>;
|
|
740
|
+
token1relativePrice_gt?: InputMaybe<Scalars['BigDecimal']>;
|
|
741
|
+
token1relativePrice_gte?: InputMaybe<Scalars['BigDecimal']>;
|
|
742
|
+
token1relativePrice_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
743
|
+
token1relativePrice_lt?: InputMaybe<Scalars['BigDecimal']>;
|
|
744
|
+
token1relativePrice_lte?: InputMaybe<Scalars['BigDecimal']>;
|
|
745
|
+
token1relativePrice_not?: InputMaybe<Scalars['BigDecimal']>;
|
|
746
|
+
token1relativePrice_not_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
655
747
|
volumeToken0?: InputMaybe<Scalars['BigInt']>;
|
|
656
748
|
volumeToken0_gt?: InputMaybe<Scalars['BigInt']>;
|
|
657
749
|
volumeToken0_gte?: InputMaybe<Scalars['BigInt']>;
|
|
@@ -689,7 +781,11 @@ export declare enum PairHourly_OrderBy {
|
|
|
689
781
|
Id = "id",
|
|
690
782
|
Timestamp = "timestamp",
|
|
691
783
|
Token0 = "token0",
|
|
784
|
+
Token0Price = "token0Price",
|
|
785
|
+
Token0relativePrice = "token0relativePrice",
|
|
692
786
|
Token1 = "token1",
|
|
787
|
+
Token1Price = "token1Price",
|
|
788
|
+
Token1relativePrice = "token1relativePrice",
|
|
693
789
|
VolumeToken0 = "volumeToken0",
|
|
694
790
|
VolumeToken1 = "volumeToken1",
|
|
695
791
|
VolumeTradedEth = "volumeTradedEth",
|
|
@@ -707,6 +803,14 @@ export declare type Pair_Filter = {
|
|
|
707
803
|
id_not?: InputMaybe<Scalars['ID']>;
|
|
708
804
|
id_not_in?: InputMaybe<Array<Scalars['ID']>>;
|
|
709
805
|
token0?: InputMaybe<Scalars['String']>;
|
|
806
|
+
token0Price?: InputMaybe<Scalars['BigDecimal']>;
|
|
807
|
+
token0Price_gt?: InputMaybe<Scalars['BigDecimal']>;
|
|
808
|
+
token0Price_gte?: InputMaybe<Scalars['BigDecimal']>;
|
|
809
|
+
token0Price_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
810
|
+
token0Price_lt?: InputMaybe<Scalars['BigDecimal']>;
|
|
811
|
+
token0Price_lte?: InputMaybe<Scalars['BigDecimal']>;
|
|
812
|
+
token0Price_not?: InputMaybe<Scalars['BigDecimal']>;
|
|
813
|
+
token0Price_not_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
710
814
|
token0_contains?: InputMaybe<Scalars['String']>;
|
|
711
815
|
token0_contains_nocase?: InputMaybe<Scalars['String']>;
|
|
712
816
|
token0_ends_with?: InputMaybe<Scalars['String']>;
|
|
@@ -726,7 +830,23 @@ export declare type Pair_Filter = {
|
|
|
726
830
|
token0_not_starts_with_nocase?: InputMaybe<Scalars['String']>;
|
|
727
831
|
token0_starts_with?: InputMaybe<Scalars['String']>;
|
|
728
832
|
token0_starts_with_nocase?: InputMaybe<Scalars['String']>;
|
|
833
|
+
token0relativePrice?: InputMaybe<Scalars['BigDecimal']>;
|
|
834
|
+
token0relativePrice_gt?: InputMaybe<Scalars['BigDecimal']>;
|
|
835
|
+
token0relativePrice_gte?: InputMaybe<Scalars['BigDecimal']>;
|
|
836
|
+
token0relativePrice_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
837
|
+
token0relativePrice_lt?: InputMaybe<Scalars['BigDecimal']>;
|
|
838
|
+
token0relativePrice_lte?: InputMaybe<Scalars['BigDecimal']>;
|
|
839
|
+
token0relativePrice_not?: InputMaybe<Scalars['BigDecimal']>;
|
|
840
|
+
token0relativePrice_not_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
729
841
|
token1?: InputMaybe<Scalars['String']>;
|
|
842
|
+
token1Price?: InputMaybe<Scalars['BigDecimal']>;
|
|
843
|
+
token1Price_gt?: InputMaybe<Scalars['BigDecimal']>;
|
|
844
|
+
token1Price_gte?: InputMaybe<Scalars['BigDecimal']>;
|
|
845
|
+
token1Price_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
846
|
+
token1Price_lt?: InputMaybe<Scalars['BigDecimal']>;
|
|
847
|
+
token1Price_lte?: InputMaybe<Scalars['BigDecimal']>;
|
|
848
|
+
token1Price_not?: InputMaybe<Scalars['BigDecimal']>;
|
|
849
|
+
token1Price_not_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
730
850
|
token1_contains?: InputMaybe<Scalars['String']>;
|
|
731
851
|
token1_contains_nocase?: InputMaybe<Scalars['String']>;
|
|
732
852
|
token1_ends_with?: InputMaybe<Scalars['String']>;
|
|
@@ -746,6 +866,14 @@ export declare type Pair_Filter = {
|
|
|
746
866
|
token1_not_starts_with_nocase?: InputMaybe<Scalars['String']>;
|
|
747
867
|
token1_starts_with?: InputMaybe<Scalars['String']>;
|
|
748
868
|
token1_starts_with_nocase?: InputMaybe<Scalars['String']>;
|
|
869
|
+
token1relativePrice?: InputMaybe<Scalars['BigDecimal']>;
|
|
870
|
+
token1relativePrice_gt?: InputMaybe<Scalars['BigDecimal']>;
|
|
871
|
+
token1relativePrice_gte?: InputMaybe<Scalars['BigDecimal']>;
|
|
872
|
+
token1relativePrice_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
873
|
+
token1relativePrice_lt?: InputMaybe<Scalars['BigDecimal']>;
|
|
874
|
+
token1relativePrice_lte?: InputMaybe<Scalars['BigDecimal']>;
|
|
875
|
+
token1relativePrice_not?: InputMaybe<Scalars['BigDecimal']>;
|
|
876
|
+
token1relativePrice_not_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
|
|
749
877
|
volumeToken0?: InputMaybe<Scalars['BigInt']>;
|
|
750
878
|
volumeToken0_gt?: InputMaybe<Scalars['BigInt']>;
|
|
751
879
|
volumeToken0_gte?: InputMaybe<Scalars['BigInt']>;
|
|
@@ -782,7 +910,11 @@ export declare type Pair_Filter = {
|
|
|
782
910
|
export declare enum Pair_OrderBy {
|
|
783
911
|
Id = "id",
|
|
784
912
|
Token0 = "token0",
|
|
913
|
+
Token0Price = "token0Price",
|
|
914
|
+
Token0relativePrice = "token0relativePrice",
|
|
785
915
|
Token1 = "token1",
|
|
916
|
+
Token1Price = "token1Price",
|
|
917
|
+
Token1relativePrice = "token1relativePrice",
|
|
786
918
|
VolumeToken0 = "volumeToken0",
|
|
787
919
|
VolumeToken1 = "volumeToken1",
|
|
788
920
|
VolumeTradedEth = "volumeTradedEth",
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var e=require("loglevel"),r=require("cross-fetch"),t=require("@gnosis.pm/gp-v2-contracts"),n=require("@gnosis.pm/gp-v2-contracts/networks.json"),o=require("graphql-request"),i=require("ajv");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function a(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),r.default=e,r}var u=/*#__PURE__*/s(e),c=/*#__PURE__*/s(r),d=/*#__PURE__*/s(n),l=/*#__PURE__*/s(i);class h extends Error{constructor(e,r){super(e),this.error_code=void 0,this.error_code=r}}function p(e){if(!e)return"";const r=new URLSearchParams;for(const t of Object.keys(e)){const n=e[t];n&&r.append(t,n.toString())}const t=r.toString();return t?`?${t}`:""}const m="cow-sdk:";var f;exports.SupportedChainId=void 0,(f=exports.SupportedChainId||(exports.SupportedChainId={}))[f.MAINNET=1]="MAINNET",f[f.RINKEBY=4]="RINKEBY",f[f.GNOSIS_CHAIN=100]="GNOSIS_CHAIN";const g=[exports.SupportedChainId.MAINNET,exports.SupportedChainId.RINKEBY,exports.SupportedChainId.GNOSIS_CHAIN],{GPv2Settlement:T}=d.default,v={[exports.SupportedChainId.MAINNET]:T[exports.SupportedChainId.MAINNET].address,[exports.SupportedChainId.RINKEBY]:T[exports.SupportedChainId.RINKEBY].address,[exports.SupportedChainId.GNOSIS_CHAIN]:T[exports.SupportedChainId.GNOSIS_CHAIN].address},E=function(e,r,n,o="v4"){try{let s;function i(e){var r;return s?e:{signature:null==(r=d)?void 0:r.data.toString(),signingScheme:a}}const a="eth_sign"===o?t.SigningScheme.ETHSIGN:t.SigningScheme.EIP712;let c,d=null;try{switch(o){case"v3":c=new t.TypedDataV3Signer(n);break;case"int_v4":c=new t.IntChainIdTypedDataV4Signer(n);break;default:c=n}}catch(p){throw u.default.error(m,"Wallet not supported:",p),new h("Wallet not supported")}const l=function(t,n){try{var o=Promise.resolve(r({...e,signer:c,signingScheme:a})).then(function(e){d=e})}catch(e){return n(e)}return o&&o.then?o.then(void 0,n):o}(0,function(t){if(void 0===(i=t).code&&void 0===i.message)throw u.default.error(m,t),t;var i;if(t.code===A||S.test(t.message))switch(o){case"v4":const o=E(e,r,n,"v3");return s=1,o;case"v3":const i=E(e,r,n,"eth_sign");return s=1,i;default:throw t}else{if(k.test(t.message)){const t=E(e,r,n,"int_v4");return s=1,t}if(t.code===I){const t=E(e,r,n,"eth_sign");return s=1,t}if(w.test(t.message)){const t=E(e,r,n,"v3");return s=1,t}if(N.test(t.message)){const t=E(e,r,n,"eth_sign");return s=1,t}}});return Promise.resolve(l&&l.then?l.then(i):i(l))}catch(f){return Promise.reject(f)}},P=function(e){try{const{chainId:r,signer:n,signingScheme:o,orderId:i}=e,s=C(r);return Promise.resolve(t.signOrderCancellation(s,i,n,x(o)))}catch(e){return Promise.reject(e)}},y=function(e){try{const{chainId:r,signer:n,order:o,signingScheme:i}=e,s=C(r);return Promise.resolve(t.signOrder(s,o,n,x(i)))}catch(e){return Promise.reject(e)}},I=-32603,A=-32601,w=/eth_signTypedData_v4 does not exist/i,N=/eth_signTypedData_v3 does not exist/i,S=/RPC request failed/i,k=/provided chainid .* must match the active chainid/i,D=new Map([[t.SigningScheme.EIP712,{libraryValue:0,apiValue:"eip712"}],[t.SigningScheme.ETHSIGN,{libraryValue:1,apiValue:"ethsign"}],[t.SigningScheme.EIP1271,{libraryValue:2,apiValue:"eip1271"}],[t.SigningScheme.PRESIGN,{libraryValue:3,apiValue:"presign"}]]);function O(e){const r=D.get(e);if(void 0===r)throw new h("Unknown schema "+e);return r}function _(e){return O(e).apiValue}function x(e){return O(e).libraryValue}function C(e){const r=v[e];if(!r)throw new h("Unsupported network. Settlement contract is not deployed");return t.domain(e,r)}var U,b,R,j;!function(e){e.DuplicateOrder="DuplicateOrder",e.InvalidSignature="InvalidSignature",e.MissingOrderData="MissingOrderData",e.InsufficientValidTo="InsufficientValidTo",e.InsufficientAllowance="InsufficientAllowance",e.InsufficientBalance="InsufficientBalance",e.InsufficientFee="InsufficientFee",e.WrongOwner="WrongOwner",e.NotFound="NotFound",e.OrderNotFound="OrderNotFound",e.AlreadyCancelled="AlreadyCancelled",e.OrderFullyExecuted="OrderFullyExecuted",e.OrderExpired="OrderExpired",e.NoLiquidity="NoLiquidity",e.UnsupportedToken="UnsupportedToken",e.AmountIsZero="AmountIsZero",e.SellAmountDoesNotCoverFee="SellAmountDoesNotCoverFee",e.TransferEthToContract="TransferEthToContract",e.UNHANDLED_GET_ERROR="UNHANDLED_GET_ERROR",e.UNHANDLED_CREATE_ERROR="UNHANDLED_CREATE_ERROR",e.UNHANDLED_DELETE_ERROR="UNHANDLED_DELETE_ERROR"}(U||(U={})),function(e){e.DuplicateOrder="There was another identical order already submitted. Please try again.",e.InsufficientFee="The signed fee is insufficient. It's possible that is higher now due to a change in the gas price, ether price, or the sell token price. Please try again to get an updated fee quote.",e.InvalidSignature="The order signature is invalid. Check whether your Wallet app supports off-chain signing.",e.MissingOrderData="The order has missing information",e.InsufficientValidTo="The order you are signing is already expired. This can happen if you set a short expiration in the settings and waited too long before signing the transaction. Please try again.",e.InsufficientAllowance="The account doesn't have enough funds",e.InsufficientBalance="The account needs to approve the selling token in order to trade",e.WrongOwner="The signature is invalid.\n\nIt's likely that the signing method provided by your wallet doesn't comply with the standards required by CowSwap.\n\nCheck whether your Wallet app supports off-chain signing (EIP-712 or ETHSIGN).",e.NotFound="Token pair selected has insufficient liquidity",e.OrderNotFound="The order you are trying to cancel does not exist",e.AlreadyCancelled="Order is already cancelled",e.OrderFullyExecuted="Order is already filled",e.OrderExpired="Order is expired",e.NoLiquidity="Token pair selected has insufficient liquidity",e.UnsupportedToken="One of the tokens you are trading is unsupported. Please read the FAQ for more info.",e.AmountIsZero="Amount is zero",e.SellAmountDoesNotCoverFee="Sell amount does not sufficiently cover the current fee",e.TransferEthToContract="Sending the native currency to smart contract wallets is not currently supported",e.UNHANDLED_GET_ERROR="Order fetch failed. This may be due to a server or network connectivity issue. Please try again later.",e.UNHANDLED_CREATE_ERROR="The order was not accepted by the network",e.UNHANDLED_DELETE_ERROR="The order cancellation was not accepted by the network"}(b||(b={}));class H extends h{static getErrorMessage(e,r){try{return Promise.resolve(function(r,t){try{var n=Promise.resolve(e.json()).then(function(e){return e.errorType?H.apiErrorDetails[e.errorType]||e.errorType:(u.default.error(m,"Unknown reason for bad order submission",e),e.description)})}catch(e){return t()}return n&&n.then?n.then(void 0,t):n}(0,function(){return u.default.error(m,"Error handling a 400 error. Likely a problem deserialising the JSON response"),function(e){switch(e){case"get":return b.UNHANDLED_GET_ERROR;case"create":return b.UNHANDLED_CREATE_ERROR;case"delete":return b.UNHANDLED_DELETE_ERROR;default:return u.default.error(m,"[OperatorError::_mapActionToErrorDetails] Uncaught error mapping error action type to server error. Please try again later."),"Something failed. Please try again later."}}(r)}))}catch(e){return Promise.reject(e)}}static getErrorFromStatusCode(e,r){try{const t=this;switch(e.status){case 400:case 404:return Promise.resolve(t.getErrorMessage(e,r));case 403:return Promise.resolve(`The order cannot be ${"create"===r?"accepted":"cancelled"}. Your account is deny-listed.`);case 429:return Promise.resolve(`The order cannot be ${"create"===r?"accepted. Too many order placements":"cancelled. Too many order cancellations"}. Please, retry in a minute`);default:return u.default.error(m,`[OperatorError::getErrorFromStatusCode] Error ${"create"===r?"creating":"cancelling"} the order, status code:`,e.status||"unknown"),Promise.resolve(`Error ${"create"===r?"creating":"cancelling"} the order`)}return Promise.resolve()}catch(e){return Promise.reject(e)}}constructor(e){super(e.description,e.errorType),this.name="OperatorError",this.description=void 0,this.description=e.description,this.message=b[e.errorType]}}H.apiErrorDetails=b,function(e){e.UnsupportedToken="UnsupportedToken",e.InsufficientLiquidity="InsufficientLiquidity",e.FeeExceedsFrom="FeeExceedsFrom",e.ZeroPrice="ZeroPrice",e.UNHANDLED_ERROR="UNHANDLED_ERROR"}(R||(R={})),function(e){e.UnsupportedToken="One of the tokens you are trading is unsupported. Please read the FAQ for more info.",e.InsufficientLiquidity="Token pair selected has insufficient liquidity",e.FeeExceedsFrom='Current fee exceeds entered "from" amount',e.ZeroPrice="Quoted price is zero. This is likely due to a significant price difference between the two tokens. Please try increasing amounts.",e.UNHANDLED_ERROR="Quote fetch failed. This may be due to a server or network connectivity issue. Please try again later."}(j||(j={}));class L extends h{static getErrorMessage(e){try{return Promise.resolve(function(r,t){try{var n=Promise.resolve(e.json()).then(function(e){return e.errorType?L.quoteErrorDetails[e.errorType]||e.errorType:(u.default.error(m,"Unknown reason for bad quote fetch",e),e.description)})}catch(e){return t()}return n&&n.then?n.then(void 0,t):n}(0,function(){return u.default.error(m,"Error handling 400/404 error. Likely a problem deserialising the JSON response"),L.quoteErrorDetails.UNHANDLED_ERROR}))}catch(e){return Promise.reject(e)}}static getErrorFromStatusCode(e){try{const r=this;switch(e.status){case 400:case 404:return Promise.resolve(r.getErrorMessage(e));default:return u.default.error(m,"[QuoteError::getErrorFromStatusCode] Error fetching quote, status code:",e.status||"unknown"),Promise.resolve("Error fetching quote")}return Promise.resolve()}catch(e){return Promise.reject(e)}}constructor(e){super(e.description,e.errorType),this.name="QuoteErrorObject",this.description=void 0,this.data=void 0,this.description=e.description,this.message=L.quoteErrorDetails[e.errorType],this.data=null==e?void 0:e.data}}L.quoteErrorDetails=j;class V{constructor(e,r){this.symbol=void 0,this.address=void 0,this.symbol=e,this.address=r}}const F={[exports.SupportedChainId.MAINNET]:new V("WETH","0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),[exports.SupportedChainId.RINKEBY]:new V("WETH","0xc778417E063141139Fce010982780140Aa0cD5Ab"),[exports.SupportedChainId.GNOSIS_CHAIN]:new V("WXDAI","0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d")},B={[exports.SupportedChainId.MAINNET]:"ETH",[exports.SupportedChainId.RINKEBY]:"ETH",[exports.SupportedChainId.GNOSIS_CHAIN]:"XDAI"};function $(e,r){let t=e;return e===B[r]&&(t=F[r].address),t}function q(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}const M=function(e,r){try{return e.ok?Promise.resolve(e.json()):Promise.resolve(e.json()).then(function(e){const t=function(e){switch(null==e?void 0:e.errorType){case U.NotFound:case U.NoLiquidity:return{errorType:R.InsufficientLiquidity,description:j.InsufficientLiquidity};case U.SellAmountDoesNotCoverFee:return{errorType:R.FeeExceedsFrom,description:j.FeeExceedsFrom,data:null==e?void 0:e.data};case U.UnsupportedToken:return{errorType:R.UnsupportedToken,description:e.description};case U.SellAmountDoesNotCoverFee:return{errorType:R.FeeExceedsFrom,description:e.description};default:return{errorType:R.UNHANDLED_ERROR,description:j.UNHANDLED_ERROR}}}(e),n=new L(t);if(r){const{sellToken:e,buyToken:t}=r;u.default.error(m,`Error querying fee from API - sellToken: ${e}, buyToken: ${t}`)}throw n})}catch(e){return Promise.reject(e)}},G={errorType:R.UNHANDLED_ERROR,description:j.UNHANDLED_ERROR},K={errorType:U.UNHANDLED_CREATE_ERROR,description:b.UNHANDLED_CREATE_ERROR};class Q{constructor(e){this.context=void 0,this.API_NAME="CoW Protocol",this.context=e}get DEFAULT_HEADERS(){return{"Content-Type":"application/json","X-AppId":this.context.appDataHash}}get API_BASE_URL(){return this.context.isDevEnvironment?{[exports.SupportedChainId.MAINNET]:"https://barn.api.cow.fi/mainnet/api",[exports.SupportedChainId.RINKEBY]:"https://barn.api.cow.fi/rinkeby/api",[exports.SupportedChainId.GNOSIS_CHAIN]:"https://barn.api.cow.fi/xdai/api"}:{[exports.SupportedChainId.MAINNET]:"https://api.cow.fi/mainnet/api",[exports.SupportedChainId.RINKEBY]:"https://api.cow.fi/rinkeby/api",[exports.SupportedChainId.GNOSIS_CHAIN]:"https://api.cow.fi/xdai/api"}}get PROFILE_API_BASE_URL(){return this.context.isDevEnvironment?{[exports.SupportedChainId.MAINNET]:"https://barn.api.cow.fi/affiliate/api"}:{[exports.SupportedChainId.MAINNET]:"https://api.cow.fi/affiliate/api"}}getProfileData(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(m,`[api:${r.API_NAME}] Get profile data for`,t,e),t!==exports.SupportedChainId.MAINNET?(u.default.info(m,"Profile data is only available for mainnet"),null):Promise.resolve(r.getProfile(`/profile/${e}`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw u.default.error(m,e),new h(null==e?void 0:e.description)})})})}catch(e){return Promise.reject(e)}}getTrades(e){try{const r=this,{owner:t,limit:n,offset:o}=e,i=p({owner:t,limit:n,offset:o});return Promise.resolve(r.context.chainId).then(function(e){return u.default.debug(m,"[util:operator] Get trades for",e,t,{limit:n,offset:o}),q(function(){return Promise.resolve(r.get(`/trades${i}`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw new H(e)})})},function(e){if(u.default.error(m,"Error getting trades:",e),e instanceof H)throw e;throw new h("Error getting trades: "+e)})})}catch(e){return Promise.reject(e)}}getOrders(e){try{const r=this,{owner:t,limit:n=1e3,offset:o=0}=e,i=p({limit:n,offset:o});return Promise.resolve(r.context.chainId).then(function(e){return u.default.debug(m,`[api:${r.API_NAME}] Get orders for `,e,t,n,o),q(function(){return Promise.resolve(r.get(`/account/${t}/orders/${i}`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw new H(e)})})},function(e){if(u.default.error(m,"Error getting orders information:",e),e instanceof H)throw e;throw new H(K)})})}catch(e){return Promise.reject(e)}}getTxOrders(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(`[api:${r.API_NAME}] Get tx orders for `,t,e),q(function(){return Promise.resolve(r.get(`/transactions/${e}/orders`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw new H(e)})})},function(e){if(u.default.error("Error getting transaction orders information:",e),e instanceof H)throw e;throw new H(K)})})}catch(e){return Promise.reject(e)}}getOrder(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(m,`[api:${r.API_NAME}] Get order for `,t,e),q(function(){return Promise.resolve(r.get(`/orders/${e}`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw new H(e)})})},function(e){if(u.default.error(m,"Error getting order information:",e),e instanceof H)throw e;throw new H(K)})})}catch(e){return Promise.reject(e)}}getPriceQuoteLegacy(e){try{const r=this,{baseToken:t,quoteToken:n,amount:o,kind:i}=e;return Promise.resolve(r.context.chainId).then(function(s){return u.default.debug(m,`[api:${r.API_NAME}] Get price from API`,e,"for",s),Promise.resolve(r.get(`/markets/${$(t,s)}-${$(n,s)}/${i}/${o}`).catch(e=>{throw u.default.error(m,"Error getting price quote:",e),new L(G)})).then(M)})}catch(e){return Promise.reject(e)}}getQuote(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){const n=r.mapNewToLegacyParams(e,t);return Promise.resolve(r.post("/quote",n)).then(M)})}catch(e){return Promise.reject(e)}}sendSignedOrderCancellation(e){try{const r=this,{cancellation:t,owner:n}=e;return Promise.resolve(r.context.chainId).then(function(e){return u.default.debug(m,`[api:${r.API_NAME}] Delete signed order for network`,e,t),Promise.resolve(r.delete(`/orders/${t.orderUid}`,{signature:t.signature,signingScheme:_(t.signingScheme),from:n})).then(function(n){function o(n){u.default.debug(m,`[api:${r.API_NAME}] Cancelled order`,t.orderUid,e)}const i=function(){if(!n.ok)return Promise.resolve(H.getErrorFromStatusCode(n,"delete")).then(function(e){throw new h(e)})}();return i&&i.then?i.then(o):o()})})}catch(e){return Promise.reject(e)}}sendOrder(e){try{const r=this,t={...e.order,appData:r.context.appDataHash};return Promise.resolve(r.context.chainId).then(function(n){const{owner:o}=e;return u.default.debug(m,`[api:${r.API_NAME}] Post signed order for network`,n,t),Promise.resolve(r.post("/orders",{...t,signingScheme:_(t.signingScheme),from:o})).then(function(e){function t(t){return Promise.resolve(e.json()).then(function(e){return u.default.debug(m,`[api:${r.API_NAME}] Success posting the signed order`,e),e})}const n=function(){if(!e.ok)return Promise.resolve(H.getErrorFromStatusCode(e,"create")).then(function(e){throw new h(e)})}();return n&&n.then?n.then(t):t()})})}catch(e){return Promise.reject(e)}}getOrderLink(e){return this.getApiBaseUrl()+`/orders/${e}`}mapNewToLegacyParams(e,r){const{amount:n,kind:o,userAddress:i,receiver:s,validTo:a,sellToken:u,buyToken:c}=e,d=i||"0x0000000000000000000000000000000000000000",l={sellToken:$(u,r),buyToken:$(c,r),from:d,receiver:s||d,appData:this.context.appDataHash,validTo:a,partiallyFillable:!1};return o===t.OrderKind.SELL?{kind:t.OrderKind.SELL,sellAmountBeforeFee:n,...l}:{kind:t.OrderKind.BUY,buyAmountAfterFee:n,...l}}getApiBaseUrl(){try{const e=this;return Promise.resolve(e.context.chainId).then(function(r){const t=e.API_BASE_URL[r];if(t)return t+"/v1";throw new h(`Unsupported Network. The ${e.API_NAME} API is not deployed in the Network `+r)})}catch(e){return Promise.reject(e)}}getProfileApiBaseUrl(){try{const e=this;return Promise.resolve(e.context.chainId).then(function(r){const t=e.PROFILE_API_BASE_URL[r];if(t)return t+"/v1";throw new h(`Unsupported Network. The ${e.API_NAME} API is not deployed in the Network `+r)})}catch(e){return Promise.reject(e)}}fetch(e,r,t){try{const n=this;return Promise.resolve(n.getApiBaseUrl()).then(function(o){return c.default(o+e,{headers:n.DEFAULT_HEADERS,method:r,body:void 0!==t?JSON.stringify(t):t})})}catch(e){return Promise.reject(e)}}fetchProfile(e,r,t){try{const n=this;return Promise.resolve(n.getProfileApiBaseUrl()).then(function(o){return c.default(o+e,{headers:n.DEFAULT_HEADERS,method:r,body:void 0!==t?JSON.stringify(t):t})})}catch(e){return Promise.reject(e)}}post(e,r){return this.fetch(e,"POST",r)}get(e){return this.fetch(e,"GET")}getProfile(e){return this.fetchProfile(e,"GET")}delete(e,r){return this.fetch(e,"DELETE",r)}}const Y=o.gql`
|
|
1
|
+
var e=require("loglevel"),r=require("cross-fetch"),t=require("@cowprotocol/contracts"),n=require("@cowprotocol/contracts/networks.json"),o=require("graphql-request"),i=require("ajv");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function a(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach(function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),r.default=e,r}var u=/*#__PURE__*/s(e),c=/*#__PURE__*/s(r),d=/*#__PURE__*/s(n),l=/*#__PURE__*/s(i);class h extends Error{constructor(e,r){super(e),this.error_code=void 0,this.error_code=r}}function p(e){if(!e)return"";const r=new URLSearchParams;for(const t of Object.keys(e)){const n=e[t];n&&r.append(t,n.toString())}const t=r.toString();return t?`?${t}`:""}const m="cow-sdk:";var f;exports.SupportedChainId=void 0,(f=exports.SupportedChainId||(exports.SupportedChainId={}))[f.MAINNET=1]="MAINNET",f[f.RINKEBY=4]="RINKEBY",f[f.GNOSIS_CHAIN=100]="GNOSIS_CHAIN";const g=[exports.SupportedChainId.MAINNET,exports.SupportedChainId.RINKEBY,exports.SupportedChainId.GNOSIS_CHAIN],{GPv2Settlement:T}=d.default,v={[exports.SupportedChainId.MAINNET]:T[exports.SupportedChainId.MAINNET].address,[exports.SupportedChainId.RINKEBY]:T[exports.SupportedChainId.RINKEBY].address,[exports.SupportedChainId.GNOSIS_CHAIN]:T[exports.SupportedChainId.GNOSIS_CHAIN].address},P=function(e,r,n,o="v4"){try{let s;function i(e){var r;return s?e:{signature:null==(r=d)?void 0:r.data.toString(),signingScheme:a}}const a="eth_sign"===o?t.SigningScheme.ETHSIGN:t.SigningScheme.EIP712;let c,d=null;try{switch(o){case"v3":c=new t.TypedDataV3Signer(n);break;case"int_v4":c=new t.IntChainIdTypedDataV4Signer(n);break;default:c=n}}catch(p){throw u.default.error(m,"Wallet not supported:",p),new h("Wallet not supported")}const l=function(t,n){try{var o=Promise.resolve(r({...e,signer:c,signingScheme:a})).then(function(e){d=e})}catch(e){return n(e)}return o&&o.then?o.then(void 0,n):o}(0,function(t){if(void 0===(i=t).code&&void 0===i.message)throw u.default.error(m,t),t;var i;if(t.code===A||N.test(t.message))switch(o){case"v4":const o=P(e,r,n,"v3");return s=1,o;case"v3":const i=P(e,r,n,"eth_sign");return s=1,i;default:throw t}else{if(S.test(t.message)){const t=P(e,r,n,"int_v4");return s=1,t}if(t.code===I){const t=P(e,r,n,"eth_sign");return s=1,t}if(w.test(t.message)){const t=P(e,r,n,"v3");return s=1,t}if(k.test(t.message)){const t=P(e,r,n,"eth_sign");return s=1,t}}});return Promise.resolve(l&&l.then?l.then(i):i(l))}catch(f){return Promise.reject(f)}},E=function(e){try{const{chainId:r,signer:n,signingScheme:o,orderId:i}=e,s=C(r);return Promise.resolve(t.signOrderCancellation(s,i,n,x(o)))}catch(e){return Promise.reject(e)}},y=function(e){try{const{chainId:r,signer:n,order:o,signingScheme:i}=e,s=C(r);return Promise.resolve(t.signOrder(s,o,n,x(i)))}catch(e){return Promise.reject(e)}},I=-32603,A=-32601,w=/eth_signTypedData_v4 does not exist/i,k=/eth_signTypedData_v3 does not exist/i,N=/RPC request failed/i,S=/provided chainid .* must match the active chainid/i,D=new Map([[t.SigningScheme.EIP712,{libraryValue:0,apiValue:"eip712"}],[t.SigningScheme.ETHSIGN,{libraryValue:1,apiValue:"ethsign"}],[t.SigningScheme.EIP1271,{libraryValue:2,apiValue:"eip1271"}],[t.SigningScheme.PRESIGN,{libraryValue:3,apiValue:"presign"}]]);function O(e){const r=D.get(e);if(void 0===r)throw new h("Unknown schema "+e);return r}function _(e){return O(e).apiValue}function x(e){return O(e).libraryValue}function C(e){const r=v[e];if(!r)throw new h("Unsupported network. Settlement contract is not deployed");return t.domain(e,r)}var U,b,R,j;!function(e){e.DuplicateOrder="DuplicateOrder",e.InvalidSignature="InvalidSignature",e.MissingOrderData="MissingOrderData",e.InsufficientValidTo="InsufficientValidTo",e.InsufficientAllowance="InsufficientAllowance",e.InsufficientBalance="InsufficientBalance",e.InsufficientFee="InsufficientFee",e.WrongOwner="WrongOwner",e.NotFound="NotFound",e.OrderNotFound="OrderNotFound",e.AlreadyCancelled="AlreadyCancelled",e.OrderFullyExecuted="OrderFullyExecuted",e.OrderExpired="OrderExpired",e.NoLiquidity="NoLiquidity",e.UnsupportedToken="UnsupportedToken",e.AmountIsZero="AmountIsZero",e.SellAmountDoesNotCoverFee="SellAmountDoesNotCoverFee",e.TransferEthToContract="TransferEthToContract",e.UNHANDLED_GET_ERROR="UNHANDLED_GET_ERROR",e.UNHANDLED_CREATE_ERROR="UNHANDLED_CREATE_ERROR",e.UNHANDLED_DELETE_ERROR="UNHANDLED_DELETE_ERROR"}(U||(U={})),function(e){e.DuplicateOrder="There was another identical order already submitted. Please try again.",e.InsufficientFee="The signed fee is insufficient. It's possible that is higher now due to a change in the gas price, ether price, or the sell token price. Please try again to get an updated fee quote.",e.InvalidSignature="The order signature is invalid. Check whether your Wallet app supports off-chain signing.",e.MissingOrderData="The order has missing information",e.InsufficientValidTo="The order you are signing is already expired. This can happen if you set a short expiration in the settings and waited too long before signing the transaction. Please try again.",e.InsufficientAllowance="The account doesn't have enough funds",e.InsufficientBalance="The account needs to approve the selling token in order to trade",e.WrongOwner="The signature is invalid.\n\nIt's likely that the signing method provided by your wallet doesn't comply with the standards required by CowSwap.\n\nCheck whether your Wallet app supports off-chain signing (EIP-712 or ETHSIGN).",e.NotFound="Token pair selected has insufficient liquidity",e.OrderNotFound="The order you are trying to cancel does not exist",e.AlreadyCancelled="Order is already cancelled",e.OrderFullyExecuted="Order is already filled",e.OrderExpired="Order is expired",e.NoLiquidity="Token pair selected has insufficient liquidity",e.UnsupportedToken="One of the tokens you are trading is unsupported. Please read the FAQ for more info.",e.AmountIsZero="Amount is zero",e.SellAmountDoesNotCoverFee="Sell amount does not sufficiently cover the current fee",e.TransferEthToContract="Sending the native currency to smart contract wallets is not currently supported",e.UNHANDLED_GET_ERROR="Order fetch failed. This may be due to a server or network connectivity issue. Please try again later.",e.UNHANDLED_CREATE_ERROR="The order was not accepted by the network",e.UNHANDLED_DELETE_ERROR="The order cancellation was not accepted by the network"}(b||(b={}));class H extends h{static getErrorMessage(e,r){try{return Promise.resolve(function(r,t){try{var n=Promise.resolve(e.json()).then(function(e){return e.errorType?H.apiErrorDetails[e.errorType]||e.errorType:(u.default.error(m,"Unknown reason for bad order submission",e),e.description)})}catch(e){return t()}return n&&n.then?n.then(void 0,t):n}(0,function(){return u.default.error(m,"Error handling a 400 error. Likely a problem deserialising the JSON response"),function(e){switch(e){case"get":return b.UNHANDLED_GET_ERROR;case"create":return b.UNHANDLED_CREATE_ERROR;case"delete":return b.UNHANDLED_DELETE_ERROR;default:return u.default.error(m,"[OperatorError::_mapActionToErrorDetails] Uncaught error mapping error action type to server error. Please try again later."),"Something failed. Please try again later."}}(r)}))}catch(e){return Promise.reject(e)}}static getErrorFromStatusCode(e,r){try{const t=this;switch(e.status){case 400:case 404:return Promise.resolve(t.getErrorMessage(e,r));case 403:return Promise.resolve(`The order cannot be ${"create"===r?"accepted":"cancelled"}. Your account is deny-listed.`);case 429:return Promise.resolve(`The order cannot be ${"create"===r?"accepted. Too many order placements":"cancelled. Too many order cancellations"}. Please, retry in a minute`);default:return u.default.error(m,`[OperatorError::getErrorFromStatusCode] Error ${"create"===r?"creating":"cancelling"} the order, status code:`,e.status||"unknown"),Promise.resolve(`Error ${"create"===r?"creating":"cancelling"} the order`)}return Promise.resolve()}catch(e){return Promise.reject(e)}}constructor(e){super(e.description,e.errorType),this.name="OperatorError",this.description=void 0,this.description=e.description,this.message=b[e.errorType]}}H.apiErrorDetails=b,function(e){e.UnsupportedToken="UnsupportedToken",e.InsufficientLiquidity="InsufficientLiquidity",e.FeeExceedsFrom="FeeExceedsFrom",e.ZeroPrice="ZeroPrice",e.UNHANDLED_ERROR="UNHANDLED_ERROR"}(R||(R={})),function(e){e.UnsupportedToken="One of the tokens you are trading is unsupported. Please read the FAQ for more info.",e.InsufficientLiquidity="Token pair selected has insufficient liquidity",e.FeeExceedsFrom='Current fee exceeds entered "from" amount',e.ZeroPrice="Quoted price is zero. This is likely due to a significant price difference between the two tokens. Please try increasing amounts.",e.UNHANDLED_ERROR="Quote fetch failed. This may be due to a server or network connectivity issue. Please try again later."}(j||(j={}));class L extends h{static getErrorMessage(e){try{return Promise.resolve(function(r,t){try{var n=Promise.resolve(e.json()).then(function(e){return e.errorType?L.quoteErrorDetails[e.errorType]||e.errorType:(u.default.error(m,"Unknown reason for bad quote fetch",e),e.description)})}catch(e){return t()}return n&&n.then?n.then(void 0,t):n}(0,function(){return u.default.error(m,"Error handling 400/404 error. Likely a problem deserialising the JSON response"),L.quoteErrorDetails.UNHANDLED_ERROR}))}catch(e){return Promise.reject(e)}}static getErrorFromStatusCode(e){try{const r=this;switch(e.status){case 400:case 404:return Promise.resolve(r.getErrorMessage(e));default:return u.default.error(m,"[QuoteError::getErrorFromStatusCode] Error fetching quote, status code:",e.status||"unknown"),Promise.resolve("Error fetching quote")}return Promise.resolve()}catch(e){return Promise.reject(e)}}constructor(e){super(e.description,e.errorType),this.name="QuoteErrorObject",this.description=void 0,this.data=void 0,this.description=e.description,this.message=L.quoteErrorDetails[e.errorType],this.data=null==e?void 0:e.data}}L.quoteErrorDetails=j;class V{constructor(e,r){this.symbol=void 0,this.address=void 0,this.symbol=e,this.address=r}}const F={[exports.SupportedChainId.MAINNET]:new V("WETH","0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),[exports.SupportedChainId.RINKEBY]:new V("WETH","0xc778417E063141139Fce010982780140Aa0cD5Ab"),[exports.SupportedChainId.GNOSIS_CHAIN]:new V("WXDAI","0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d")},B={[exports.SupportedChainId.MAINNET]:"ETH",[exports.SupportedChainId.RINKEBY]:"ETH",[exports.SupportedChainId.GNOSIS_CHAIN]:"XDAI"};function $(e,r){let t=e;return e===B[r]&&(t=F[r].address),t}function q(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}const M=function(e,r){try{return e.ok?Promise.resolve(e.json()):Promise.resolve(e.json()).then(function(e){const t=function(e){switch(null==e?void 0:e.errorType){case U.NotFound:case U.NoLiquidity:return{errorType:R.InsufficientLiquidity,description:j.InsufficientLiquidity};case U.SellAmountDoesNotCoverFee:return{errorType:R.FeeExceedsFrom,description:j.FeeExceedsFrom,data:null==e?void 0:e.data};case U.UnsupportedToken:return{errorType:R.UnsupportedToken,description:e.description};case U.SellAmountDoesNotCoverFee:return{errorType:R.FeeExceedsFrom,description:e.description};default:return{errorType:R.UNHANDLED_ERROR,description:j.UNHANDLED_ERROR}}}(e),n=new L(t);if(r){const{sellToken:e,buyToken:t}=r;u.default.error(m,`Error querying fee from API - sellToken: ${e}, buyToken: ${t}`)}throw n})}catch(e){return Promise.reject(e)}},G={errorType:R.UNHANDLED_ERROR,description:j.UNHANDLED_ERROR},K={errorType:U.UNHANDLED_CREATE_ERROR,description:b.UNHANDLED_CREATE_ERROR};class Q{constructor(e){this.context=void 0,this.API_NAME="CoW Protocol",this.context=e}get DEFAULT_HEADERS(){return{"Content-Type":"application/json","X-AppId":this.context.appDataHash}}get API_BASE_URL(){return this.context.isDevEnvironment?{[exports.SupportedChainId.MAINNET]:"https://barn.api.cow.fi/mainnet/api",[exports.SupportedChainId.RINKEBY]:"https://barn.api.cow.fi/rinkeby/api",[exports.SupportedChainId.GNOSIS_CHAIN]:"https://barn.api.cow.fi/xdai/api"}:{[exports.SupportedChainId.MAINNET]:"https://api.cow.fi/mainnet/api",[exports.SupportedChainId.RINKEBY]:"https://api.cow.fi/rinkeby/api",[exports.SupportedChainId.GNOSIS_CHAIN]:"https://api.cow.fi/xdai/api"}}get PROFILE_API_BASE_URL(){return this.context.isDevEnvironment?{[exports.SupportedChainId.MAINNET]:"https://barn.api.cow.fi/affiliate/api"}:{[exports.SupportedChainId.MAINNET]:"https://api.cow.fi/affiliate/api"}}getProfileData(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(m,`[api:${r.API_NAME}] Get profile data for`,t,e),t!==exports.SupportedChainId.MAINNET?(u.default.info(m,"Profile data is only available for mainnet"),null):Promise.resolve(r.getProfile(`/profile/${e}`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw u.default.error(m,e),new h(null==e?void 0:e.description)})})})}catch(e){return Promise.reject(e)}}getTrades(e){try{const r=this,{owner:t,orderId:n,limit:o,offset:i}=e;if(t&&n)throw new h("Cannot specify both owner and orderId");const s=p({owner:t,orderUid:n,limit:o,offset:i});return Promise.resolve(r.context.chainId).then(function(e){return u.default.debug(m,"[util:operator] Get trades for",e,{owner:t,orderId:n,limit:o,offset:i}),q(function(){return Promise.resolve(r.get(`/trades${s}`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw new H(e)})})},function(e){if(u.default.error(m,"Error getting trades:",e),e instanceof H)throw e;throw new h("Error getting trades: "+e)})})}catch(e){return Promise.reject(e)}}getOrders(e){try{const r=this,{owner:t,limit:n=1e3,offset:o=0}=e,i=p({limit:n,offset:o});return Promise.resolve(r.context.chainId).then(function(e){return u.default.debug(m,`[api:${r.API_NAME}] Get orders for `,e,t,n,o),q(function(){return Promise.resolve(r.get(`/account/${t}/orders/${i}`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw new H(e)})})},function(e){if(u.default.error(m,"Error getting orders information:",e),e instanceof H)throw e;throw new H(K)})})}catch(e){return Promise.reject(e)}}getTxOrders(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(`[api:${r.API_NAME}] Get tx orders for `,t,e),q(function(){return Promise.resolve(r.get(`/transactions/${e}/orders`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw new H(e)})})},function(e){if(u.default.error("Error getting transaction orders information:",e),e instanceof H)throw e;throw new H(K)})})}catch(e){return Promise.reject(e)}}getOrder(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(m,`[api:${r.API_NAME}] Get order for `,t,e),q(function(){return Promise.resolve(r.get(`/orders/${e}`)).then(function(e){return e.ok?e.json():Promise.resolve(e.json()).then(function(e){throw new H(e)})})},function(e){if(u.default.error(m,"Error getting order information:",e),e instanceof H)throw e;throw new H(K)})})}catch(e){return Promise.reject(e)}}getPriceQuoteLegacy(e){try{const r=this,{baseToken:t,quoteToken:n,amount:o,kind:i}=e;return Promise.resolve(r.context.chainId).then(function(s){return u.default.debug(m,`[api:${r.API_NAME}] Get price from API`,e,"for",s),Promise.resolve(r.get(`/markets/${$(t,s)}-${$(n,s)}/${i}/${o}`).catch(e=>{throw u.default.error(m,"Error getting price quote:",e),new L(G)})).then(M)})}catch(e){return Promise.reject(e)}}getQuote(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){const n=r.mapNewToLegacyParams(e,t);return Promise.resolve(r.post("/quote",n)).then(M)})}catch(e){return Promise.reject(e)}}sendSignedOrderCancellation(e){try{const r=this,{cancellation:t,owner:n}=e;return Promise.resolve(r.context.chainId).then(function(e){return u.default.debug(m,`[api:${r.API_NAME}] Delete signed order for network`,e,t),Promise.resolve(r.delete(`/orders/${t.orderUid}`,{signature:t.signature,signingScheme:_(t.signingScheme),from:n})).then(function(n){function o(n){u.default.debug(m,`[api:${r.API_NAME}] Cancelled order`,t.orderUid,e)}const i=function(){if(!n.ok)return Promise.resolve(H.getErrorFromStatusCode(n,"delete")).then(function(e){throw new h(e)})}();return i&&i.then?i.then(o):o()})})}catch(e){return Promise.reject(e)}}sendOrder(e){try{const r=this,t={...e.order,appData:r.context.appDataHash};return Promise.resolve(r.context.chainId).then(function(n){const{owner:o}=e;return u.default.debug(m,`[api:${r.API_NAME}] Post signed order for network`,n,t),Promise.resolve(r.post("/orders",{...t,signingScheme:_(t.signingScheme),from:o})).then(function(e){function t(t){return Promise.resolve(e.json()).then(function(e){return u.default.debug(m,`[api:${r.API_NAME}] Success posting the signed order`,e),e})}const n=function(){if(!e.ok)return Promise.resolve(H.getErrorFromStatusCode(e,"create")).then(function(e){throw new h(e)})}();return n&&n.then?n.then(t):t()})})}catch(e){return Promise.reject(e)}}getOrderLink(e){return this.getApiBaseUrl()+`/orders/${e}`}mapNewToLegacyParams(e,r){const{amount:n,kind:o,userAddress:i,receiver:s,validTo:a,sellToken:u,buyToken:c}=e,d=i||"0x0000000000000000000000000000000000000000",l={sellToken:$(u,r),buyToken:$(c,r),from:d,receiver:s||d,appData:this.context.appDataHash,validTo:a,partiallyFillable:!1};return o===t.OrderKind.SELL?{kind:t.OrderKind.SELL,sellAmountBeforeFee:n,...l}:{kind:t.OrderKind.BUY,buyAmountAfterFee:n,...l}}getApiBaseUrl(){try{const e=this;return Promise.resolve(e.context.chainId).then(function(r){const t=e.API_BASE_URL[r];if(t)return t+"/v1";throw new h(`Unsupported Network. The ${e.API_NAME} API is not deployed in the Network `+r)})}catch(e){return Promise.reject(e)}}getProfileApiBaseUrl(){try{const e=this;return Promise.resolve(e.context.chainId).then(function(r){const t=e.PROFILE_API_BASE_URL[r];if(t)return t+"/v1";throw new h(`Unsupported Network. The ${e.API_NAME} API is not deployed in the Network `+r)})}catch(e){return Promise.reject(e)}}fetch(e,r,t){try{const n=this;return Promise.resolve(n.getApiBaseUrl()).then(function(o){return c.default(o+e,{headers:n.DEFAULT_HEADERS,method:r,body:void 0!==t?JSON.stringify(t):t})})}catch(e){return Promise.reject(e)}}fetchProfile(e,r,t){try{const n=this;return Promise.resolve(n.getProfileApiBaseUrl()).then(function(o){return c.default(o+e,{headers:n.DEFAULT_HEADERS,method:r,body:void 0!==t?JSON.stringify(t):t})})}catch(e){return Promise.reject(e)}}post(e,r){return this.fetch(e,"POST",r)}get(e){return this.fetch(e,"GET")}getProfile(e){return this.fetchProfile(e,"GET")}delete(e,r){return this.fetch(e,"DELETE",r)}}const Y=o.gql`
|
|
2
2
|
query Totals {
|
|
3
3
|
totals {
|
|
4
4
|
tokens
|
|
@@ -25,5 +25,5 @@ var e=require("loglevel"),r=require("cross-fetch"),t=require("@gnosis.pm/gp-v2-c
|
|
|
25
25
|
volumeUsd
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
`,Z={[exports.SupportedChainId.MAINNET]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow",[exports.SupportedChainId.RINKEBY]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow-rinkeby",[exports.SupportedChainId.GNOSIS_CHAIN]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow-gc"};class z{constructor(e){this.context=void 0,this.clients=void 0,this.API_NAME="CoW Protocol Subgraph",this.context=e,this.clients=this.createClients()}createClients(){return{[exports.SupportedChainId.MAINNET]:new o.GraphQLClient(Z[exports.SupportedChainId.MAINNET],{fetch:c.default}),[exports.SupportedChainId.RINKEBY]:new o.GraphQLClient(Z[exports.SupportedChainId.RINKEBY],{fetch:c.default}),[exports.SupportedChainId.GNOSIS_CHAIN]:new o.GraphQLClient(Z[exports.SupportedChainId.GNOSIS_CHAIN],{fetch:c.default})}}getBaseUrl(){try{return Promise.resolve(this.context.chainId).then(function(e){return Z[e]})}catch(e){return Promise.reject(e)}}getTotals(){try{const e=this;return Promise.resolve(e.context.chainId).then(function(r){return u.default.debug(`[subgraph:${e.API_NAME}] Get totals for:`,r),Promise.resolve(e.runQuery(Y)).then(function(e){return e.totals[0]})})}catch(e){return Promise.reject(e)}}getLastDaysVolume(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(`[subgraph:${r.API_NAME}] Get last ${e} days volume for:`,t),r.runQuery(W,{days:e})})}catch(e){return Promise.reject(e)}}getLastHoursVolume(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(`[subgraph:${r.API_NAME}] Get last ${e} hours volume for:`,t),r.runQuery(J,{hours:e})})}catch(e){return Promise.reject(e)}}runQuery(e,r){try{const t=this;return Promise.resolve(function(n,o){try{var i=Promise.resolve(t.context.chainId).then(function(n){return Promise.resolve(t.clients[n].request(e,r))})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(n){return u.default.error(n),Promise.resolve(t.getBaseUrl()).then(function(t){throw new h(`Error running query: ${e}. Variables: ${JSON.stringify(r)}. API: ${t}. Inner Error: ${n}`)})}))}catch(e){return Promise.reject(e)}}}const X=function(e){return Promise.resolve(re()).then(function({ajv:r,validate:t}){return{result:!!t(e),errors:r.errors?r.errorsText(r.errors):void 0}})},ee=function(e){try{const r=1,t=112,n=18,o=32,i=function(e){const r=e.match(/.{1,2}/g);if(r)return new Uint8Array(r.map(e=>parseInt(e,16)))}(e.replace(/(^0x)/,""));if(!i)return Promise.resolve();const s=Uint8Array.from([r,t,n,o,...i]);return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("multiformats/cid"))})).then(function({CID:e}){return e.decode(s).toV0().toString()})}catch(e){return Promise.reject(e)}},re=function(){try{function e(){return{ajv:ne,validate:te}}ne||(ne=new l.default);const r=function(){if(!te)return Promise.resolve(Promise.resolve().then(function(){return require("./appData.schema-4c010c50.js")})).then(function(e){te=ne.compile(e)})}();return Promise.resolve(r&&r.then?r.then(e):e())}catch(t){return Promise.reject(t)}};let te,ne;function oe(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}const ie="CowSwap";class se{constructor(e){this.context=void 0,this.context=e}generateAppDataDoc(e={},r){const{appCode:t=ie,environment:n}=r||{};return{version:"0.3.0",appCode:t,environment:n,metadata:{...e}}}decodeAppData(e){try{return Promise.resolve(oe(function(){return Promise.resolve(ee(e)).then(function(e){if(!e)throw new h("Error getting serialized CID");return function(e,r="https://gnosis.mypinata.cloud/ipfs"){try{return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("cross-fetch"))})).then(function({default:t}){return Promise.resolve(t(`${r}/${e}`)).then(function(e){return Promise.resolve(e.json())})})}catch(e){return Promise.reject(e)}}(e)})},function(e){const r=e;throw u.default.error("Error decoding AppData:",r),new h("Error decoding AppData: "+r.message)}))}catch(e){return Promise.reject(e)}}cidToAppDataHex(e){try{return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("multiformats/cid"))})).then(function({CID:r}){const{digest:t}=r.parse(e).multihash;return`0x${Buffer.from(t).toString("hex")}`})}catch(e){return Promise.reject(e)}}appDataHexToCid(e){try{return Promise.resolve(ee(e)).then(function(e){if(!e)throw new h("Error getting serialized CID");return e})}catch(e){return Promise.reject(e)}}calculateAppDataHash(e){try{const r=this;return Promise.resolve(X(e)).then(function(t){if(null==t||!t.result)throw new h("Invalid appData provided",null==t?void 0:t.errors);return oe(function(){return Promise.resolve(function(e){try{const r=JSON.stringify(e);return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("ipfs-only-hash"))})).then(function({of:e}){return e(r,{cidVersion:0})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return Promise.resolve(r.cidToAppDataHex(e)).then(function(r){if(!r)throw new h(`Could not extract appDataHash from calculated cidV0 ${e}`);return{cidV0:e,appDataHash:r}})})},function(e){throw new h("Failed to calculate appDataHash",e.message)})})}catch(e){return Promise.reject(e)}}uploadMetadataDocToIpfs(e){try{const r=this;return Promise.resolve(function(e,{writeUri:r="https://api.pinata.cloud",pinataApiKey:t="",pinataApiSecret:n=""}){try{return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("cross-fetch"))})).then(function({default:o}){if(!t||!n)throw new h("You need to pass IPFS api credentials.");const i=JSON.stringify({pinataContent:e,pinataMetadata:{name:"appData"}});return Promise.resolve(o(`${r}/pinning/pinJSONToIPFS`,{method:"POST",body:i,headers:{"Content-Type":"application/json",pinata_api_key:t,pinata_secret_api_key:n}})).then(function(e){return Promise.resolve(e.json()).then(function(r){if(200!==e.status)throw new Error(r.error.details||r.error);return r})})})}catch(e){return Promise.reject(e)}}(e,r.context.ipfs)).then(function({IpfsHash:e}){return r.cidToAppDataHex(e)})}catch(e){return Promise.reject(e)}}}var ae=0;function ue(e){return"__private_"+ae+++"_"+e}function ce(e,r){if(!Object.prototype.hasOwnProperty.call(e,r))throw new TypeError("attempted to use private field on non-instance");return e}const de={appDataHash:"0x0000000000000000000000000000000000000000000000000000000000000000",isDevEnvironment:!1,ipfs:{readUri:"https://gnosis.mypinata.cloud/ipfs",writeUri:"https://api.pinata.cloud",apiKey:void 0,apiSecret:void 0}};var le,he,pe,me,fe,ge,Te,ve,Ee,Pe,ye,Ie,Ae,we,Ne,Se,ke,De,Oe,_e=/*#__PURE__*/ue("context"),xe=/*#__PURE__*/ue("chainId");class Ce{constructor(e,r){Object.defineProperty(this,_e,{writable:!0,value:void 0}),Object.defineProperty(this,xe,{writable:!0,value:void 0}),ce(this,xe)[xe]=this.updateChainId(e),ce(this,_e)[_e]={...de,...r,ipfs:{...de.ipfs,...r.ipfs}}}updateChainId(e){if(!exports.SupportedChainId[e])throw new h(`Invalid chainId: ${e}`);return u.default.debug(m,`Updating chainId to: ${e}`),ce(this,xe)[xe]=e,e}get chainId(){const e=this;var r;const t=null==(r=ce(this,_e)[_e].signer)?void 0:r.provider;return t?(u.default.debug(m,"Getting chainId from provider"),function(){try{return Promise.resolve(t.getNetwork()).then(function(r){const t=r.chainId;return t!==ce(e,xe)[xe]&&(u.default.debug(m,`ChainId mismatch: Provider's chainId: ${t} vs Context's chainId: ${ce(e,xe)[xe]}. Updating Context's chainId`),e.updateChainId(t)),t})}catch(e){return Promise.reject(e)}}()):Promise.resolve(ce(this,xe)[xe])}get appDataHash(){var e;return null!==(e=ce(this,_e)[_e].appDataHash)&&void 0!==e?e:de.appDataHash}get isDevEnvironment(){var e;return null!==(e=ce(this,_e)[_e].isDevEnvironment)&&void 0!==e?e:de.isDevEnvironment}get signer(){return ce(this,_e)[_e].signer}get ipfs(){var e;return null!==(e=ce(this,_e)[_e].ipfs)&&void 0!==e?e:de.ipfs}}!function(e){e.EthPriceUsd="ethPriceUSD",e.Id="id"}(le||(le={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Timestamp="timestamp",e.Tokens="tokens",e.TotalTokens="totalTokens",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(he||(he={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Timestamp="timestamp",e.Tokens="tokens",e.TotalTokens="totalTokens",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(pe||(pe={})),function(e){e.Asc="asc",e.Desc="desc"}(me||(me={})),function(e){e.Id="id",e.InvalidateTimestamp="invalidateTimestamp",e.IsSigned="isSigned",e.IsValid="isValid",e.Owner="owner",e.PresignTimestamp="presignTimestamp",e.Trades="trades",e.TradesTimestamp="tradesTimestamp"}(fe||(fe={})),function(e){e.Id="id",e.Timestamp="timestamp",e.Token0="token0",e.Token1="token1",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(ge||(ge={})),function(e){e.Id="id",e.Timestamp="timestamp",e.Token0="token0",e.Token1="token1",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(Te||(Te={})),function(e){e.Id="id",e.Token0="token0",e.Token1="token1",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(ve||(ve={})),function(e){e.FirstTradeTimestamp="firstTradeTimestamp",e.Id="id",e.Solver="solver",e.Trades="trades",e.TxHash="txHash"}(Ee||(Ee={})),function(e){e.AveragePrice="averagePrice",e.ClosePrice="closePrice",e.HigherPrice="higherPrice",e.Id="id",e.LowerPrice="lowerPrice",e.OpenPrice="openPrice",e.Timestamp="timestamp",e.Token="token",e.TotalTrades="totalTrades",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(Pe||(Pe={})),function(e){e.AveragePrice="averagePrice",e.ClosePrice="closePrice",e.HigherPrice="higherPrice",e.Id="id",e.LowerPrice="lowerPrice",e.OpenPrice="openPrice",e.Timestamp="timestamp",e.Token="token",e.TotalTrades="totalTrades",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(ye||(ye={})),function(e){e.AmountEth="amountEth",e.AmountUsd="amountUsd",e.Id="id",e.Timestamp="timestamp",e.Token="token",e.Trade="trade"}(Ie||(Ie={})),function(e){e.Address="address",e.Decimals="decimals",e.FirstTradeTimestamp="firstTradeTimestamp",e.History="history",e.Id="id",e.Name="name",e.NumberOfTrades="numberOfTrades",e.PriceEth="priceEth",e.PriceUsd="priceUsd",e.Symbol="symbol",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(Ae||(Ae={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Tokens="tokens",e.Traders="traders",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(we||(we={})),function(e){e.BuyAmount="buyAmount",e.BuyAmountEth="buyAmountEth",e.BuyAmountUsd="buyAmountUsd",e.BuyToken="buyToken",e.FeeAmount="feeAmount",e.GasPrice="gasPrice",e.Id="id",e.Order="order",e.SellAmount="sellAmount",e.SellAmountEth="sellAmountEth",e.SellAmountUsd="sellAmountUsd",e.SellToken="sellToken",e.Settlement="settlement",e.Timestamp="timestamp",e.TxHash="txHash"}(Ne||(Ne={})),function(e){e.Id="id",e.Liquidity="liquidity",e.Tick="tick",e.Token0="token0",e.Token0Price="token0Price",e.Token1="token1",e.Token1Price="token1Price",e.TotalValueLockedToken0="totalValueLockedToken0",e.TotalValueLockedToken1="totalValueLockedToken1"}(Se||(Se={})),function(e){e.Address="address",e.AllowedPools="allowedPools",e.Decimals="decimals",e.Id="id",e.Name="name",e.PriceEth="priceEth",e.PriceUsd="priceUsd",e.Symbol="symbol"}(ke||(ke={})),function(e){e.Address="address",e.FirstTradeTimestamp="firstTradeTimestamp",e.Id="id",e.IsSolver="isSolver",e.NumberOfTrades="numberOfTrades",e.OrdersPlaced="ordersPlaced",e.SolvedAmountEth="solvedAmountEth",e.SolvedAmountUsd="solvedAmountUsd",e.TradedAmountEth="tradedAmountEth",e.TradedAmountUsd="tradedAmountUsd"}(De||(De={})),function(e){e.Allow="allow",e.Deny="deny"}(Oe||(Oe={}));var Ue={__proto__:null,get Bundle_OrderBy(){return le},get DailyTotal_OrderBy(){return he},get HourlyTotal_OrderBy(){return pe},get OrderDirection(){return me},get Order_OrderBy(){return fe},get PairDaily_OrderBy(){return ge},get PairHourly_OrderBy(){return Te},get Pair_OrderBy(){return ve},get Settlement_OrderBy(){return Ee},get TokenDailyTotal_OrderBy(){return Pe},get TokenHourlyTotal_OrderBy(){return ye},get TokenTradingEvent_OrderBy(){return Ie},get Token_OrderBy(){return Ae},get Total_OrderBy(){return we},get Trade_OrderBy(){return Ne},get UniswapPool_OrderBy(){return Se},get UniswapToken_OrderBy(){return ke},get User_OrderBy(){return De},get _SubgraphErrorPolicy_(){return Oe}};Object.defineProperty(exports,"OrderKind",{enumerable:!0,get:function(){return t.OrderKind}}),exports.ALL_SUPPORTED_CHAIN_IDS=g,exports.CowError=h,exports.CowSdk=class{constructor(e,r={},t={}){this.context=void 0,this.cowApi=void 0,this.metadataApi=void 0,this.cowSubgraphApi=void 0,this.updateChainId=e=>{this.context.updateChainId(e)},this.validateAppDataDocument=X,this.context=new Ce(e,{...r}),this.cowApi=new Q(this.context),this.cowSubgraphApi=new z(this.context),this.metadataApi=new se(this.context),u.default.setLevel(t.loglevel||"error")}signOrder(e){try{const r=this,t=r._checkSigner();return Promise.resolve(r.context.chainId).then(function(n){return function(e,r,t){return E({order:e,chainId:r},y,t)}({...e,appData:r.context.appDataHash},n,t)})}catch(e){return Promise.reject(e)}}signOrderCancellation(e){try{const r=this,t=r._checkSigner();return Promise.resolve(r.context.chainId).then(function(r){return function(e,r,t){return E({orderId:e,chainId:r},P,t)}(e,r,t)})}catch(e){return Promise.reject(e)}}_checkSigner(e=this.context.signer){if(!e)throw new h("No signer available");return e}},exports.GraphQL=Ue,exports.Token=V;
|
|
28
|
+
`,Z={[exports.SupportedChainId.MAINNET]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow",[exports.SupportedChainId.RINKEBY]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow-rinkeby",[exports.SupportedChainId.GNOSIS_CHAIN]:"https://api.thegraph.com/subgraphs/name/cowprotocol/cow-gc"};class z{constructor(e){this.context=void 0,this.clients=void 0,this.API_NAME="CoW Protocol Subgraph",this.context=e,this.clients=this.createClients()}createClients(){return{[exports.SupportedChainId.MAINNET]:new o.GraphQLClient(Z[exports.SupportedChainId.MAINNET],{fetch:c.default}),[exports.SupportedChainId.RINKEBY]:new o.GraphQLClient(Z[exports.SupportedChainId.RINKEBY],{fetch:c.default}),[exports.SupportedChainId.GNOSIS_CHAIN]:new o.GraphQLClient(Z[exports.SupportedChainId.GNOSIS_CHAIN],{fetch:c.default})}}getBaseUrl(){try{return Promise.resolve(this.context.chainId).then(function(e){return Z[e]})}catch(e){return Promise.reject(e)}}getTotals(){try{const e=this;return Promise.resolve(e.context.chainId).then(function(r){return u.default.debug(`[subgraph:${e.API_NAME}] Get totals for:`,r),Promise.resolve(e.runQuery(Y)).then(function(e){return e.totals[0]})})}catch(e){return Promise.reject(e)}}getLastDaysVolume(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(`[subgraph:${r.API_NAME}] Get last ${e} days volume for:`,t),r.runQuery(W,{days:e})})}catch(e){return Promise.reject(e)}}getLastHoursVolume(e){try{const r=this;return Promise.resolve(r.context.chainId).then(function(t){return u.default.debug(`[subgraph:${r.API_NAME}] Get last ${e} hours volume for:`,t),r.runQuery(J,{hours:e})})}catch(e){return Promise.reject(e)}}runQuery(e,r){try{const t=this;return Promise.resolve(function(n,o){try{var i=Promise.resolve(t.context.chainId).then(function(n){return Promise.resolve(t.clients[n].request(e,r))})}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(n){return u.default.error(n),Promise.resolve(t.getBaseUrl()).then(function(t){throw new h(`Error running query: ${e}. Variables: ${JSON.stringify(r)}. API: ${t}. Inner Error: ${n}`)})}))}catch(e){return Promise.reject(e)}}}const X=function(e){return Promise.resolve(re()).then(function({ajv:r,validate:t}){return{result:!!t(e),errors:r.errors?r.errorsText(r.errors):void 0}})},ee=function(e){try{const r=1,t=112,n=18,o=32,i=function(e){const r=e.match(/.{1,2}/g);if(r)return new Uint8Array(r.map(e=>parseInt(e,16)))}(e.replace(/(^0x)/,""));if(!i)return Promise.resolve();const s=Uint8Array.from([r,t,n,o,...i]);return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("multiformats/cid"))})).then(function({CID:e}){return e.decode(s).toV0().toString()})}catch(e){return Promise.reject(e)}},re=function(){try{function e(){return{ajv:ne,validate:te}}ne||(ne=new l.default);const r=function(){if(!te)return Promise.resolve(Promise.resolve().then(function(){return require("./appData.schema-4c010c50.js")})).then(function(e){te=ne.compile(e)})}();return Promise.resolve(r&&r.then?r.then(e):e())}catch(t){return Promise.reject(t)}};let te,ne;function oe(e,r){try{var t=e()}catch(e){return r(e)}return t&&t.then?t.then(void 0,r):t}const ie="CowSwap";class se{constructor(e){this.context=void 0,this.context=e}generateAppDataDoc(e={},r){const{appCode:t=ie,environment:n}=r||{};return{version:"0.3.0",appCode:t,environment:n,metadata:{...e}}}decodeAppData(e){try{return Promise.resolve(oe(function(){return Promise.resolve(ee(e)).then(function(e){if(!e)throw new h("Error getting serialized CID");return function(e,r="https://gnosis.mypinata.cloud/ipfs"){try{return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("cross-fetch"))})).then(function({default:t}){return Promise.resolve(t(`${r}/${e}`)).then(function(e){return Promise.resolve(e.json())})})}catch(e){return Promise.reject(e)}}(e)})},function(e){const r=e;throw u.default.error("Error decoding AppData:",r),new h("Error decoding AppData: "+r.message)}))}catch(e){return Promise.reject(e)}}cidToAppDataHex(e){try{return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("multiformats/cid"))})).then(function({CID:r}){const{digest:t}=r.parse(e).multihash;return`0x${Buffer.from(t).toString("hex")}`})}catch(e){return Promise.reject(e)}}appDataHexToCid(e){try{return Promise.resolve(ee(e)).then(function(e){if(!e)throw new h("Error getting serialized CID");return e})}catch(e){return Promise.reject(e)}}calculateAppDataHash(e){try{const r=this;return Promise.resolve(X(e)).then(function(t){if(null==t||!t.result)throw new h("Invalid appData provided",null==t?void 0:t.errors);return oe(function(){return Promise.resolve(function(e){try{const r=JSON.stringify(e);return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("ipfs-only-hash"))})).then(function({of:e}){return e(r,{cidVersion:0})})}catch(e){return Promise.reject(e)}}(e)).then(function(e){return Promise.resolve(r.cidToAppDataHex(e)).then(function(r){if(!r)throw new h(`Could not extract appDataHash from calculated cidV0 ${e}`);return{cidV0:e,appDataHash:r}})})},function(e){throw new h("Failed to calculate appDataHash",e.message)})})}catch(e){return Promise.reject(e)}}uploadMetadataDocToIpfs(e){try{const r=this;return Promise.resolve(function(e,{writeUri:r="https://api.pinata.cloud",pinataApiKey:t="",pinataApiSecret:n=""}){try{return Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return a(require("cross-fetch"))})).then(function({default:o}){if(!t||!n)throw new h("You need to pass IPFS api credentials.");const i=JSON.stringify({pinataContent:e,pinataMetadata:{name:"appData"}});return Promise.resolve(o(`${r}/pinning/pinJSONToIPFS`,{method:"POST",body:i,headers:{"Content-Type":"application/json",pinata_api_key:t,pinata_secret_api_key:n}})).then(function(e){return Promise.resolve(e.json()).then(function(r){if(200!==e.status)throw new Error(r.error.details||r.error);return r})})})}catch(e){return Promise.reject(e)}}(e,r.context.ipfs)).then(function({IpfsHash:e}){return r.cidToAppDataHex(e)})}catch(e){return Promise.reject(e)}}}var ae=0;function ue(e){return"__private_"+ae+++"_"+e}function ce(e,r){if(!Object.prototype.hasOwnProperty.call(e,r))throw new TypeError("attempted to use private field on non-instance");return e}const de={appDataHash:"0x0000000000000000000000000000000000000000000000000000000000000000",isDevEnvironment:!1,ipfs:{readUri:"https://gnosis.mypinata.cloud/ipfs",writeUri:"https://api.pinata.cloud",apiKey:void 0,apiSecret:void 0}};var le,he,pe,me,fe,ge,Te,ve,Pe,Ee,ye,Ie,Ae,we,ke,Ne,Se,De,Oe,_e=/*#__PURE__*/ue("context"),xe=/*#__PURE__*/ue("chainId");class Ce{constructor(e,r){Object.defineProperty(this,_e,{writable:!0,value:void 0}),Object.defineProperty(this,xe,{writable:!0,value:void 0}),ce(this,xe)[xe]=this.updateChainId(e),ce(this,_e)[_e]={...de,...r,ipfs:{...de.ipfs,...r.ipfs}}}updateChainId(e){if(!exports.SupportedChainId[e])throw new h(`Invalid chainId: ${e}`);return u.default.debug(m,`Updating chainId to: ${e}`),ce(this,xe)[xe]=e,e}get chainId(){const e=this;var r;const t=null==(r=ce(this,_e)[_e].signer)?void 0:r.provider;return t?(u.default.debug(m,"Getting chainId from provider"),function(){try{return Promise.resolve(t.getNetwork()).then(function(r){const t=r.chainId;return t!==ce(e,xe)[xe]&&(u.default.debug(m,`ChainId mismatch: Provider's chainId: ${t} vs Context's chainId: ${ce(e,xe)[xe]}. Updating Context's chainId`),e.updateChainId(t)),t})}catch(e){return Promise.reject(e)}}()):Promise.resolve(ce(this,xe)[xe])}get appDataHash(){var e;return null!==(e=ce(this,_e)[_e].appDataHash)&&void 0!==e?e:de.appDataHash}get isDevEnvironment(){var e;return null!==(e=ce(this,_e)[_e].isDevEnvironment)&&void 0!==e?e:de.isDevEnvironment}get signer(){return ce(this,_e)[_e].signer}get ipfs(){var e;return null!==(e=ce(this,_e)[_e].ipfs)&&void 0!==e?e:de.ipfs}}!function(e){e.EthPriceUsd="ethPriceUSD",e.Id="id"}(le||(le={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Timestamp="timestamp",e.Tokens="tokens",e.TotalTokens="totalTokens",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(he||(he={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Timestamp="timestamp",e.Tokens="tokens",e.TotalTokens="totalTokens",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(pe||(pe={})),function(e){e.Asc="asc",e.Desc="desc"}(me||(me={})),function(e){e.Id="id",e.InvalidateTimestamp="invalidateTimestamp",e.IsSigned="isSigned",e.IsValid="isValid",e.Owner="owner",e.PresignTimestamp="presignTimestamp",e.Trades="trades",e.TradesTimestamp="tradesTimestamp"}(fe||(fe={})),function(e){e.Id="id",e.Timestamp="timestamp",e.Token0="token0",e.Token0Price="token0Price",e.Token0relativePrice="token0relativePrice",e.Token1="token1",e.Token1Price="token1Price",e.Token1relativePrice="token1relativePrice",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(ge||(ge={})),function(e){e.Id="id",e.Timestamp="timestamp",e.Token0="token0",e.Token0Price="token0Price",e.Token0relativePrice="token0relativePrice",e.Token1="token1",e.Token1Price="token1Price",e.Token1relativePrice="token1relativePrice",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(Te||(Te={})),function(e){e.Id="id",e.Token0="token0",e.Token0Price="token0Price",e.Token0relativePrice="token0relativePrice",e.Token1="token1",e.Token1Price="token1Price",e.Token1relativePrice="token1relativePrice",e.VolumeToken0="volumeToken0",e.VolumeToken1="volumeToken1",e.VolumeTradedEth="volumeTradedEth",e.VolumeTradedUsd="volumeTradedUsd"}(ve||(ve={})),function(e){e.FirstTradeTimestamp="firstTradeTimestamp",e.Id="id",e.Solver="solver",e.Trades="trades",e.TxHash="txHash"}(Pe||(Pe={})),function(e){e.AveragePrice="averagePrice",e.ClosePrice="closePrice",e.HigherPrice="higherPrice",e.Id="id",e.LowerPrice="lowerPrice",e.OpenPrice="openPrice",e.Timestamp="timestamp",e.Token="token",e.TotalTrades="totalTrades",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(Ee||(Ee={})),function(e){e.AveragePrice="averagePrice",e.ClosePrice="closePrice",e.HigherPrice="higherPrice",e.Id="id",e.LowerPrice="lowerPrice",e.OpenPrice="openPrice",e.Timestamp="timestamp",e.Token="token",e.TotalTrades="totalTrades",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(ye||(ye={})),function(e){e.AmountEth="amountEth",e.AmountUsd="amountUsd",e.Id="id",e.Timestamp="timestamp",e.Token="token",e.Trade="trade"}(Ie||(Ie={})),function(e){e.Address="address",e.Decimals="decimals",e.FirstTradeTimestamp="firstTradeTimestamp",e.History="history",e.Id="id",e.Name="name",e.NumberOfTrades="numberOfTrades",e.PriceEth="priceEth",e.PriceUsd="priceUsd",e.Symbol="symbol",e.TotalVolume="totalVolume",e.TotalVolumeEth="totalVolumeEth",e.TotalVolumeUsd="totalVolumeUsd"}(Ae||(Ae={})),function(e){e.FeesEth="feesEth",e.FeesUsd="feesUsd",e.Id="id",e.NumberOfTrades="numberOfTrades",e.Orders="orders",e.Settlements="settlements",e.Tokens="tokens",e.Traders="traders",e.VolumeEth="volumeEth",e.VolumeUsd="volumeUsd"}(we||(we={})),function(e){e.BuyAmount="buyAmount",e.BuyAmountEth="buyAmountEth",e.BuyAmountUsd="buyAmountUsd",e.BuyToken="buyToken",e.FeeAmount="feeAmount",e.GasPrice="gasPrice",e.Id="id",e.Order="order",e.SellAmount="sellAmount",e.SellAmountEth="sellAmountEth",e.SellAmountUsd="sellAmountUsd",e.SellToken="sellToken",e.Settlement="settlement",e.Timestamp="timestamp",e.TxHash="txHash"}(ke||(ke={})),function(e){e.Id="id",e.Liquidity="liquidity",e.Tick="tick",e.Token0="token0",e.Token0Price="token0Price",e.Token1="token1",e.Token1Price="token1Price",e.TotalValueLockedToken0="totalValueLockedToken0",e.TotalValueLockedToken1="totalValueLockedToken1"}(Ne||(Ne={})),function(e){e.Address="address",e.AllowedPools="allowedPools",e.Decimals="decimals",e.Id="id",e.Name="name",e.PriceEth="priceEth",e.PriceUsd="priceUsd",e.Symbol="symbol"}(Se||(Se={})),function(e){e.Address="address",e.FirstTradeTimestamp="firstTradeTimestamp",e.Id="id",e.IsSolver="isSolver",e.NumberOfTrades="numberOfTrades",e.OrdersPlaced="ordersPlaced",e.SolvedAmountEth="solvedAmountEth",e.SolvedAmountUsd="solvedAmountUsd",e.TradedAmountEth="tradedAmountEth",e.TradedAmountUsd="tradedAmountUsd"}(De||(De={})),function(e){e.Allow="allow",e.Deny="deny"}(Oe||(Oe={}));var Ue={__proto__:null,get Bundle_OrderBy(){return le},get DailyTotal_OrderBy(){return he},get HourlyTotal_OrderBy(){return pe},get OrderDirection(){return me},get Order_OrderBy(){return fe},get PairDaily_OrderBy(){return ge},get PairHourly_OrderBy(){return Te},get Pair_OrderBy(){return ve},get Settlement_OrderBy(){return Pe},get TokenDailyTotal_OrderBy(){return Ee},get TokenHourlyTotal_OrderBy(){return ye},get TokenTradingEvent_OrderBy(){return Ie},get Token_OrderBy(){return Ae},get Total_OrderBy(){return we},get Trade_OrderBy(){return ke},get UniswapPool_OrderBy(){return Ne},get UniswapToken_OrderBy(){return Se},get User_OrderBy(){return De},get _SubgraphErrorPolicy_(){return Oe}};Object.defineProperty(exports,"OrderKind",{enumerable:!0,get:function(){return t.OrderKind}}),exports.ALL_SUPPORTED_CHAIN_IDS=g,exports.CowError=h,exports.CowSdk=class{constructor(e,r={},t={}){this.context=void 0,this.cowApi=void 0,this.metadataApi=void 0,this.cowSubgraphApi=void 0,this.updateChainId=e=>{this.context.updateChainId(e)},this.validateAppDataDocument=X,this.context=new Ce(e,{...r}),this.cowApi=new Q(this.context),this.cowSubgraphApi=new z(this.context),this.metadataApi=new se(this.context),u.default.setLevel(t.loglevel||"error")}signOrder(e){try{const r=this,t=r._checkSigner();return Promise.resolve(r.context.chainId).then(function(n){return function(e,r,t){return P({order:e,chainId:r},y,t)}({...e,appData:r.context.appDataHash},n,t)})}catch(e){return Promise.reject(e)}}signOrderCancellation(e){try{const r=this,t=r._checkSigner();return Promise.resolve(r.context.chainId).then(function(r){return function(e,r,t){return P({orderId:e,chainId:r},E,t)}(e,r,t)})}catch(e){return Promise.reject(e)}}_checkSigner(e=this.context.signer){if(!e)throw new h("No signer available");return e}},exports.GraphQL=Ue,exports.Token=V;
|
|
29
29
|
//# sourceMappingURL=index.js.map
|