@cowprotocol/cow-sdk 1.0.2-RC.6 → 2.0.0-alpha.0

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.
Files changed (86) hide show
  1. package/LICENSE-APACHE +201 -0
  2. package/LICENSE-MIT +21 -0
  3. package/README.md +11 -13
  4. package/package.json +28 -31
  5. package/dist/CowSdk.d.ts +0 -21
  6. package/dist/api/0x/error/index.d.ts +0 -21
  7. package/dist/api/0x/index.d.ts +0 -11
  8. package/dist/api/0x/types.d.ts +0 -87
  9. package/dist/api/0x/utils.d.ts +0 -17
  10. package/dist/api/base/index.d.ts +0 -27
  11. package/dist/api/cow/errors/OperatorError.d.ts +0 -63
  12. package/dist/api/cow/errors/QuoteError.d.ts +0 -32
  13. package/dist/api/cow/index.d.ts +0 -26
  14. package/dist/api/cow/transformOrder.d.ts +0 -2
  15. package/dist/api/cow/types.d.ts +0 -133
  16. package/dist/api/cow-subgraph/graphql.d.ts +0 -2957
  17. package/dist/api/cow-subgraph/index.d.ts +0 -23
  18. package/dist/api/cow-subgraph/queries.d.ts +0 -3
  19. package/dist/api/index.d.ts +0 -3
  20. package/dist/api/metadata/index.d.ts +0 -58
  21. package/dist/api/metadata/types.d.ts +0 -22
  22. package/dist/api/paraswap/constants.d.ts +0 -10
  23. package/dist/api/paraswap/error/index.d.ts +0 -10
  24. package/dist/api/paraswap/index.d.ts +0 -32
  25. package/dist/api/paraswap/types.d.ts +0 -19
  26. package/dist/api/paraswap/utils.d.ts +0 -19
  27. package/dist/appData.schema-0c8db23b.js +0 -2
  28. package/dist/appData.schema-0c8db23b.js.map +0 -1
  29. package/dist/appData.schema-412cbfbf.js +0 -2
  30. package/dist/appData.schema-412cbfbf.js.map +0 -1
  31. package/dist/appData.schema-42d10730.js +0 -2
  32. package/dist/appData.schema-42d10730.js.map +0 -1
  33. package/dist/appData.schema-4c010c50.js +0 -2
  34. package/dist/appData.schema-4c010c50.js.map +0 -1
  35. package/dist/appData.schema-adfc1c6f.js +0 -2
  36. package/dist/appData.schema-adfc1c6f.js.map +0 -1
  37. package/dist/appData.schema-b8f018d7.js +0 -2
  38. package/dist/appData.schema-b8f018d7.js.map +0 -1
  39. package/dist/constants/chains.d.ts +0 -6
  40. package/dist/constants/index.d.ts +0 -5
  41. package/dist/constants/tokens.d.ts +0 -5
  42. package/dist/index.d.ts +0 -6
  43. package/dist/index.js +0 -29
  44. package/dist/index.js.map +0 -1
  45. package/dist/index.modern.js +0 -29
  46. package/dist/index.modern.js.map +0 -1
  47. package/dist/index.modern.mjs +0 -29
  48. package/dist/index.modern.mjs.map +0 -1
  49. package/dist/index.module.js +0 -29
  50. package/dist/index.module.js.map +0 -1
  51. package/dist/src/appData.schema-d44994e0.js +0 -2
  52. package/dist/src/appData.schema-d44994e0.js.map +0 -1
  53. package/dist/src/appData.schema-fb2df827.js +0 -2
  54. package/dist/src/appData.schema-fb2df827.js.map +0 -1
  55. package/dist/src/cow-sdk.esm.js +0 -2
  56. package/dist/src/cow-sdk.esm.js.map +0 -1
  57. package/dist/src/cow-sdk.js +0 -2
  58. package/dist/src/cow-sdk.js.map +0 -1
  59. package/dist/src/cow-sdk.modern.js +0 -2
  60. package/dist/src/cow-sdk.modern.js.map +0 -1
  61. package/dist/src/src/CowSdk.d.ts +0 -16
  62. package/dist/src/src/api/cow/errors/OperatorError.d.ts +0 -63
  63. package/dist/src/src/api/cow/errors/QuoteError.d.ts +0 -32
  64. package/dist/src/src/api/cow/index.d.ts +0 -38
  65. package/dist/src/src/api/cow/types.d.ts +0 -73
  66. package/dist/src/src/api/index.d.ts +0 -1
  67. package/dist/src/src/constants/chains.d.ts +0 -6
  68. package/dist/src/src/constants/index.d.ts +0 -3
  69. package/dist/src/src/constants/tokens.d.ts +0 -5
  70. package/dist/src/src/index.d.ts +0 -4
  71. package/dist/src/src/types/index.d.ts +0 -7
  72. package/dist/src/src/utils/appData.d.ts +0 -7
  73. package/dist/src/src/utils/common.d.ts +0 -5
  74. package/dist/src/src/utils/context.d.ts +0 -24
  75. package/dist/src/src/utils/sign.d.ts +0 -54
  76. package/dist/src/src/utils/tokens.d.ts +0 -2
  77. package/dist/types/index.d.ts +0 -15
  78. package/dist/types/sdk.d.ts +0 -39
  79. package/dist/types/utilities.d.ts +0 -5
  80. package/dist/utils/appData.d.ts +0 -3
  81. package/dist/utils/common.d.ts +0 -9
  82. package/dist/utils/context.d.ts +0 -42
  83. package/dist/utils/ipfs.d.ts +0 -10
  84. package/dist/utils/market.d.ts +0 -16
  85. package/dist/utils/sign.d.ts +0 -55
  86. package/dist/utils/tokens.d.ts +0 -2
@@ -1,32 +0,0 @@
1
- import { CowError } from '../../../utils/common';
2
- import { ApiErrorObject } from './OperatorError';
3
- export interface GpQuoteErrorObject {
4
- errorType: GpQuoteErrorCodes;
5
- description: string;
6
- data?: unknown;
7
- }
8
- export declare enum GpQuoteErrorCodes {
9
- UnsupportedToken = "UnsupportedToken",
10
- InsufficientLiquidity = "InsufficientLiquidity",
11
- FeeExceedsFrom = "FeeExceedsFrom",
12
- ZeroPrice = "ZeroPrice",
13
- UNHANDLED_ERROR = "UNHANDLED_ERROR"
14
- }
15
- export declare enum GpQuoteErrorDetails {
16
- UnsupportedToken = "One of the tokens you are trading is unsupported. Please read the FAQ for more info.",
17
- InsufficientLiquidity = "Token pair selected has insufficient liquidity",
18
- FeeExceedsFrom = "Current fee exceeds entered \"from\" amount",
19
- ZeroPrice = "Quoted price is zero. This is likely due to a significant price difference between the two tokens. Please try increasing amounts.",
20
- UNHANDLED_ERROR = "Quote fetch failed. This may be due to a server or network connectivity issue. Please try again later."
21
- }
22
- export declare function mapOperatorErrorToQuoteError(error?: ApiErrorObject): GpQuoteErrorObject;
23
- export default class GpQuoteError extends CowError {
24
- name: string;
25
- description: string;
26
- data?: unknown;
27
- static quoteErrorDetails: typeof GpQuoteErrorDetails;
28
- static getErrorMessage(response: Response): Promise<string>;
29
- static getErrorFromStatusCode(response: Response): Promise<string>;
30
- constructor(quoteError: GpQuoteErrorObject);
31
- }
32
- export declare function isValidQuoteError(error: unknown): error is GpQuoteError;
@@ -1,26 +0,0 @@
1
- import { QuoteQuery } from '@cowprotocol/contracts';
2
- import { OrderCreation } from '../../utils/sign';
3
- import { FeeQuoteParams, GetOrdersParams, GetTradesParams, Options, OrderCancellationParams, OrderID, OrderMetaData, PriceInformation, PriceQuoteLegacyParams, ProfileData, SimpleGetQuoteResponse, TradeMetaData } from './types';
4
- import { Context } from '../../utils/context';
5
- import BaseApi from '../base';
6
- export declare class CowApi extends BaseApi {
7
- constructor(context: Context);
8
- getProfileData(address: string, options?: Options): Promise<ProfileData | null>;
9
- getTrades(params: GetTradesParams, options?: Options): Promise<TradeMetaData[]>;
10
- getOrders(params: GetOrdersParams, options?: Options): Promise<OrderMetaData[]>;
11
- getTxOrders(txHash: string, options?: Options): Promise<OrderMetaData[]>;
12
- getOrder(orderId: string, options?: Options): Promise<OrderMetaData | null>;
13
- getPriceQuoteLegacy(params: PriceQuoteLegacyParams, options?: Options): Promise<PriceInformation | null>;
14
- getQuoteLegacyParams(params: FeeQuoteParams, options?: Options): Promise<SimpleGetQuoteResponse>;
15
- getQuote(params: QuoteQuery, options?: Options): Promise<SimpleGetQuoteResponse>;
16
- sendSignedOrderCancellation(params: OrderCancellationParams, options?: Options): Promise<void>;
17
- sendOrder(params: {
18
- order: Omit<OrderCreation, 'appData'>;
19
- owner: string;
20
- }, options?: Options): Promise<OrderID>;
21
- getOrderLink(orderId: OrderID): Promise<string>;
22
- protected getApiBaseUrl(): Promise<string>;
23
- private getProfile;
24
- private mapNewToLegacyParams;
25
- private fetchProfile;
26
- }
@@ -1,2 +0,0 @@
1
- import { OrderDto, OrderMetaData } from './types';
2
- export declare function transformOrder(order: OrderDto): OrderMetaData;
@@ -1,133 +0,0 @@
1
- import { GetQuoteResponse, OrderKind } from '@cowprotocol/contracts';
2
- import { SupportedChainId as ChainId } from '../../constants/chains';
3
- import { Env } from '../../utils/context';
4
- import { OrderCancellation, SigningSchemeValue } from '../../utils/sign';
5
- import type { StrictUnion } from '../../types/utilities';
6
- /**
7
- * Unique identifier for the order, calculated by keccak256(orderDigest, ownerAddress, validTo),
8
- * where orderDigest = keccak256(orderStruct). bytes32.
9
- */
10
- export declare type OrderID = string;
11
- export declare type ApiOrderStatus = 'fulfilled' | 'expired' | 'cancelled' | 'presignaturePending' | 'open';
12
- export declare type OrderClass = 'market' | 'limit' | 'liquidity';
13
- export interface OrderDto {
14
- creationDate: string;
15
- owner: string;
16
- uid: OrderID;
17
- availableBalance: string;
18
- executedBuyAmount: string;
19
- executedSellAmount: string;
20
- executedSellAmountBeforeFees: string;
21
- executedFeeAmount: string;
22
- executedSurplusFee: string | null;
23
- invalidated: false;
24
- sellToken: string;
25
- buyToken: string;
26
- sellAmount: string;
27
- buyAmount: string;
28
- validTo: number;
29
- appData: number;
30
- feeAmount: string;
31
- kind: OrderKind;
32
- class: OrderClass;
33
- partiallyFillable: false;
34
- signature: string;
35
- signingScheme: SigningSchemeValue;
36
- status: ApiOrderStatus;
37
- receiver: string;
38
- ethflowData?: EthFlowData;
39
- onchainUser?: string;
40
- }
41
- export interface OrderMetaData extends OrderDto {
42
- totalFee: string;
43
- }
44
- declare type EthFlowData = {
45
- userValidTo: number;
46
- isRefunded: boolean;
47
- };
48
- export interface TradeMetaData {
49
- blockNumber: number;
50
- logIndex: number;
51
- orderUid: OrderID;
52
- owner: string;
53
- sellToken: string;
54
- buyToken: string;
55
- sellAmount: string;
56
- buyAmount: string;
57
- sellAmountBeforeFees: string;
58
- txHash: string;
59
- }
60
- export interface UnsupportedToken {
61
- [token: string]: {
62
- address: string;
63
- dateAdded: number;
64
- };
65
- }
66
- export declare type PaginationParams = {
67
- limit?: number;
68
- offset?: number;
69
- };
70
- export declare type OrderCancellationParams = {
71
- chainId: ChainId;
72
- cancellation: OrderCancellation;
73
- owner: string;
74
- };
75
- export declare type GetOrdersParams = {
76
- owner: string;
77
- } & PaginationParams;
78
- declare type WithOwner = {
79
- owner: string;
80
- };
81
- declare type WithOrderId = {
82
- orderId: string;
83
- };
84
- export declare type GetTradesParams = StrictUnion<WithOwner | WithOrderId>;
85
- export declare type ProfileData = {
86
- totalTrades: number;
87
- totalReferrals: number;
88
- tradeVolumeUsd: number;
89
- referralVolumeUsd: number;
90
- lastUpdated: string;
91
- };
92
- export interface QuoteParams {
93
- quoteParams: FeeQuoteParams;
94
- fetchFee: boolean;
95
- previousFee?: FeeInformation;
96
- isPriceRefresh: boolean;
97
- }
98
- export interface FeeInformation {
99
- expirationDate: string;
100
- amount: string;
101
- }
102
- export interface PriceInformation {
103
- token: string;
104
- amount: string | null;
105
- quoteId?: number;
106
- }
107
- export declare type SimpleGetQuoteResponse = Pick<GetQuoteResponse, 'from'> & {
108
- quote: Omit<GetQuoteResponse['quote'], 'sellAmount' | 'buyAmount' | 'feeAmount' | 'validTo'> & {
109
- sellAmount: string;
110
- buyAmount: string;
111
- validTo: string;
112
- feeAmount: string;
113
- };
114
- expiration: string;
115
- id: number | null;
116
- };
117
- export declare type FeeQuoteParams = Pick<OrderMetaData, 'sellToken' | 'buyToken' | 'kind'> & {
118
- amount: string;
119
- userAddress?: string | null;
120
- receiver?: string | null;
121
- validTo: number;
122
- };
123
- export declare type PriceQuoteLegacyParams = Omit<FeeQuoteParams, 'sellToken' | 'buyToken'> & {
124
- baseToken: string;
125
- quoteToken: string;
126
- };
127
- export declare type Options = {
128
- chainId?: ChainId;
129
- env?: Env;
130
- requestOptions?: RequestInit;
131
- apiUrlGetterParams?: unknown[];
132
- };
133
- export {};