@cowprotocol/cow-sdk 3.0.0-rc.5 → 3.0.0-rc.8
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/composable/ConditionalOrder.d.ts +26 -14
- package/dist/composable/Multiplexer.d.ts +2 -2
- package/dist/composable/orderTypes/Twap.d.ts +30 -10
- package/dist/composable/orderTypes/index.d.ts +1 -1
- package/dist/composable/orderTypes/test/TestConditionalOrder.d.ts +25 -0
- package/dist/composable/types.d.ts +9 -5
- package/dist/composable/utils.d.ts +6 -2
- package/dist/index-983a9908.js +29 -0
- package/dist/index-983a9908.js.map +1 -0
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +1 -1
- package/dist/index.module.js +4 -4
- package/dist/index.module.js.map +1 -1
- package/dist/package.json +9 -3
- package/dist/{utils-eaf9b842.js → utils-438cb2f6.js} +2 -2
- package/dist/{utils-eaf9b842.js.map → utils-438cb2f6.js.map} +1 -1
- package/dist/{utils-1eebb758.js → utils-b25bc6f3.js} +1 -1
- package/dist/{utils-1eebb758.js.map → utils-b25bc6f3.js.map} +1 -1
- package/dist/{utils-0e112c15.js → utils-e1c3bbf3.js} +1 -1
- package/dist/{utils-0e112c15.js.map → utils-e1c3bbf3.js.map} +1 -1
- package/dist/utils.d.ts +3 -0
- package/package.json +9 -3
- package/dist/index-c5b085fe.js +0 -29
- package/dist/index-c5b085fe.js.map +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { BigNumber
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { BigNumber } from 'ethers';
|
|
2
|
+
import { GPv2Order } from './generated/ComposableCoW';
|
|
3
|
+
import { ConditionalOrderArguments, ConditionalOrderParams, ContextFactory, IsValidResult, OwnerContext, PollParams, PollResult, PollResultErrors } from './types';
|
|
4
|
+
import { UID } from 'src/order-book';
|
|
4
5
|
/**
|
|
5
6
|
* An abstract base class from which all conditional orders should inherit.
|
|
6
7
|
*
|
|
@@ -35,6 +36,7 @@ export declare abstract class ConditionalOrder<D, S> {
|
|
|
35
36
|
* @throws If the salt is not a valid 32-byte string.
|
|
36
37
|
*/
|
|
37
38
|
constructor(params: ConditionalOrderArguments<D>);
|
|
39
|
+
abstract get isSingleOrder(): boolean;
|
|
38
40
|
/**
|
|
39
41
|
* Get a descriptive name for the type of the conditional order (i.e twap, dca, etc).
|
|
40
42
|
*
|
|
@@ -72,6 +74,12 @@ export declare abstract class ConditionalOrder<D, S> {
|
|
|
72
74
|
* @returns The id of the conditional order.
|
|
73
75
|
*/
|
|
74
76
|
get id(): string;
|
|
77
|
+
/**
|
|
78
|
+
* The context key of the order (bytes32(0) if a merkle tree is used, otherwise H(params)) with which to lookup the cabinet
|
|
79
|
+
*
|
|
80
|
+
* The context, relates to the 'ctx' in the contract: https://github.com/cowprotocol/composable-cow/blob/c7fb85ab10c05e28a1632ba97a1749fb261fcdfb/src/interfaces/IConditionalOrder.sol#L38
|
|
81
|
+
*/
|
|
82
|
+
protected get ctx(): string;
|
|
75
83
|
/**
|
|
76
84
|
* Get the `leaf` of the conditional order. This is the data that is used to create the merkle tree.
|
|
77
85
|
*
|
|
@@ -136,21 +144,16 @@ export declare abstract class ConditionalOrder<D, S> {
|
|
|
136
144
|
/**
|
|
137
145
|
* Checks if the owner authorized the conditional order.
|
|
138
146
|
*
|
|
139
|
-
* @param owner
|
|
140
|
-
* @param chain Which chain to use for the ComposableCoW contract.
|
|
141
|
-
* @param provider An RPC provider for the chain.
|
|
147
|
+
* @param params owner context, to be able to check if the order is authorized
|
|
142
148
|
* @returns true if the owner authorized the order, false otherwise.
|
|
143
149
|
*/
|
|
144
|
-
isAuthorized(
|
|
150
|
+
isAuthorized(params: OwnerContext): Promise<boolean>;
|
|
145
151
|
/**
|
|
146
152
|
* Checks the value in the cabinet for a given owner and chain
|
|
147
153
|
*
|
|
148
|
-
* @param owner
|
|
149
|
-
* @param chain Which chain to use for the ComposableCoW contract.
|
|
150
|
-
* @param provider An RPC provider for the chain.
|
|
151
|
-
* @returns true if the owner authorized the order, false otherwise.
|
|
154
|
+
* @param params owner context, to be able to check the cabinet
|
|
152
155
|
*/
|
|
153
|
-
cabinet(
|
|
156
|
+
cabinet(params: OwnerContext): Promise<string>;
|
|
154
157
|
/**
|
|
155
158
|
* Allow concrete conditional orders to perform additional validation for the poll method.
|
|
156
159
|
*
|
|
@@ -163,7 +166,16 @@ export declare abstract class ConditionalOrder<D, S> {
|
|
|
163
166
|
*/
|
|
164
167
|
protected abstract pollValidate(params: PollParams): Promise<PollResultErrors | undefined>;
|
|
165
168
|
/**
|
|
166
|
-
*
|
|
169
|
+
* This method lets the concrete conditional order decide what to do if the order yielded in the polling is already present in the Orderbook API.
|
|
170
|
+
*
|
|
171
|
+
* The concrete conditional order will have a chance to schedule the next poll.
|
|
172
|
+
* For example, a TWAP order that has the current part already in the orderbook, can signal that the next poll should be done at the start time of the next part.
|
|
173
|
+
*
|
|
174
|
+
* @param params
|
|
175
|
+
*/
|
|
176
|
+
protected abstract handlePollFailedAlreadyPresent(orderUid: UID, order: GPv2Order.DataStruct, params: PollParams): Promise<PollResultErrors | undefined>;
|
|
177
|
+
/**
|
|
178
|
+
* Convert the struct that the contract expect as an encoded `staticInput` into a friendly data object modelling the smart order.
|
|
167
179
|
*
|
|
168
180
|
* **NOTE**: This should be overridden by any conditional order that requires transformations.
|
|
169
181
|
* This implementation is a no-op if you use the same type for both.
|
|
@@ -173,7 +185,7 @@ export declare abstract class ConditionalOrder<D, S> {
|
|
|
173
185
|
*/
|
|
174
186
|
abstract transformStructToData(params: S): D;
|
|
175
187
|
/**
|
|
176
|
-
* Converts a friendly data object
|
|
188
|
+
* Converts a friendly data object modelling the smart order into the struct that the contract expect as an encoded `staticInput`.
|
|
177
189
|
*
|
|
178
190
|
* **NOTE**: This should be overridden by any conditional order that requires transformations.
|
|
179
191
|
* This implementation is a no-op if you use the same type for both.
|
|
@@ -122,7 +122,7 @@ export declare class Multiplexer {
|
|
|
122
122
|
* @throws If the conditional order is not tradeable.
|
|
123
123
|
* @returns The tradeable `GPv2Order.Data` struct and the `signature` for the conditional order.
|
|
124
124
|
*/
|
|
125
|
-
static poll(owner: string, p: ProofWithParams, chain: SupportedChainId, provider: providers.Provider, offChainInputFn?: (owner: string, params: ConditionalOrderParams) => Promise<string>): Promise<[GPv2Order.
|
|
125
|
+
static poll(owner: string, p: ProofWithParams, chain: SupportedChainId, provider: providers.Provider, offChainInputFn?: (owner: string, params: ConditionalOrderParams) => Promise<string>): Promise<[GPv2Order.DataStruct, string]>;
|
|
126
126
|
/**
|
|
127
127
|
* The primary entry point for dumping the proofs and parameters for the conditional orders.
|
|
128
128
|
*
|
|
@@ -166,7 +166,7 @@ export declare class Multiplexer {
|
|
|
166
166
|
* @param orderType The order type to register.
|
|
167
167
|
* @param conditionalOrderClass The class to use for the given order type.
|
|
168
168
|
*/
|
|
169
|
-
static registerOrderType(orderType: string, conditionalOrderClass: new (...args:
|
|
169
|
+
static registerOrderType(orderType: string, conditionalOrderClass: new (...args: any[]) => ConditionalOrder<unknown, unknown>): void;
|
|
170
170
|
/**
|
|
171
171
|
* Reset the order type registry.
|
|
172
172
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BigNumber } from 'ethers';
|
|
2
2
|
import { ConditionalOrder } from '../ConditionalOrder';
|
|
3
|
-
import { ConditionalOrderArguments, ConditionalOrderParams, ContextFactory,
|
|
3
|
+
import { ConditionalOrderArguments, ConditionalOrderParams, ContextFactory, OwnerContext, IsValidResult, PollParams, PollResultErrors } from '../types';
|
|
4
|
+
import { GPv2Order } from '../generated/ComposableCoW';
|
|
4
5
|
export declare const TWAP_ADDRESS = "0x6cF1e9cA41f7611dEf408122793c358a3d11E5a5";
|
|
5
6
|
/**
|
|
6
7
|
* The address of the `CurrentBlockTimestampFactory` contract
|
|
@@ -12,8 +13,8 @@ export declare const MAX_UINT32: BigNumber;
|
|
|
12
13
|
export declare const MAX_FREQUENCY: BigNumber;
|
|
13
14
|
/**
|
|
14
15
|
* Base parameters for a TWAP order. Shared by:
|
|
15
|
-
* - TwapStruct (
|
|
16
|
-
* - TwapData (
|
|
16
|
+
* - TwapStruct (modelling the contract's struct used for `staticInput`).
|
|
17
|
+
* - TwapData (modelling the friendly SDK interface).
|
|
17
18
|
*/
|
|
18
19
|
export type TwapDataBase = {
|
|
19
20
|
/**
|
|
@@ -109,18 +110,19 @@ export declare enum DurationType {
|
|
|
109
110
|
export type StartTime = {
|
|
110
111
|
startType: StartTimeValue.AT_MINING_TIME;
|
|
111
112
|
} | {
|
|
112
|
-
startType: StartTimeValue.
|
|
113
|
+
startType: StartTimeValue.AT_EPOCH;
|
|
113
114
|
epoch: BigNumber;
|
|
114
115
|
};
|
|
115
116
|
export declare enum StartTimeValue {
|
|
116
117
|
AT_MINING_TIME = "AT_MINING_TIME",
|
|
117
|
-
|
|
118
|
+
AT_EPOCH = "AT_EPOCH"
|
|
118
119
|
}
|
|
119
120
|
/**
|
|
120
121
|
* `ComposableCoW` implementation of a TWAP order.
|
|
121
122
|
* @author mfw78 <mfw78@rndlabs.xyz>
|
|
122
123
|
*/
|
|
123
124
|
export declare class Twap extends ConditionalOrder<TwapData, TwapStruct> {
|
|
125
|
+
isSingleOrder: boolean;
|
|
124
126
|
/**
|
|
125
127
|
* @see {@link ConditionalOrder.constructor}
|
|
126
128
|
* @throws If the TWAP order is invalid.
|
|
@@ -157,8 +159,18 @@ export declare class Twap extends ConditionalOrder<TwapData, TwapStruct> {
|
|
|
157
159
|
* @throws If the TWAP order is invalid.
|
|
158
160
|
* @see {@link TwapStruct} for the native struct.
|
|
159
161
|
*/
|
|
160
|
-
isValid():
|
|
161
|
-
|
|
162
|
+
isValid(): IsValidResult;
|
|
163
|
+
protected startTimestamp(params: OwnerContext): Promise<number>;
|
|
164
|
+
/**
|
|
165
|
+
* Given the start timestamp of the TWAP, calculate the end timestamp.
|
|
166
|
+
* @dev As usually the `endTimestamp` is used when determining a TWAP's validity, we don't
|
|
167
|
+
* do any lookup to the blockchain to determine the start timestamp, as this has likely
|
|
168
|
+
* already been done during the verification flow.
|
|
169
|
+
* @dev Beware to handle the case of `span != 0` ie. `durationOfPart.durationType !== DurationType.AUTO`.
|
|
170
|
+
* @param startTimestamp The start timestamp of the TWAP.
|
|
171
|
+
* @returns The timestamp at which the TWAP will end.
|
|
172
|
+
*/
|
|
173
|
+
protected endTimestamp(startTimestamp: number): number;
|
|
162
174
|
/**
|
|
163
175
|
* Checks if the owner authorized the conditional order.
|
|
164
176
|
*
|
|
@@ -168,6 +180,16 @@ export declare class Twap extends ConditionalOrder<TwapData, TwapStruct> {
|
|
|
168
180
|
* @returns true if the owner authorized the order, false otherwise.
|
|
169
181
|
*/
|
|
170
182
|
protected pollValidate(params: PollParams): Promise<PollResultErrors | undefined>;
|
|
183
|
+
/**
|
|
184
|
+
* Handles the error when the order is already present in the orderbook.
|
|
185
|
+
*
|
|
186
|
+
* Given the current part is in the book, it will signal to Watch Tower what to do:
|
|
187
|
+
* - Wait until the next part starts
|
|
188
|
+
* - Don't try again if current part is the last one
|
|
189
|
+
*
|
|
190
|
+
* NOTE: The error messages will refer to the parts 1-indexed, so first part is 1, second part is 2, etc.
|
|
191
|
+
*/
|
|
192
|
+
protected handlePollFailedAlreadyPresent(_orderUid: string, _order: GPv2Order.DataStruct, params: PollParams): Promise<PollResultErrors | undefined>;
|
|
171
193
|
/**
|
|
172
194
|
* Serialize the TWAP order into it's ABI-encoded form.
|
|
173
195
|
* @returns {string} The ABI-encoded TWAP order.
|
|
@@ -186,11 +208,9 @@ export declare class Twap extends ConditionalOrder<TwapData, TwapStruct> {
|
|
|
186
208
|
static deserialize(twapSerialized: string): Twap;
|
|
187
209
|
/**
|
|
188
210
|
* Create a human-readable string representation of the TWAP order.
|
|
189
|
-
* @param {((address: string, amount: BigNumber) => string) | undefined} tokenFormatter An optional
|
|
190
|
-
* function that takes an address and an amount and returns a human-readable string.
|
|
191
211
|
* @returns {string} A human-readable string representation of the TWAP order.
|
|
192
212
|
*/
|
|
193
|
-
toString(
|
|
213
|
+
toString(): string;
|
|
194
214
|
/**
|
|
195
215
|
* Transform parameters into a native struct.
|
|
196
216
|
*
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { GPv2Order } from '../../generated/ComposableCoW';
|
|
2
|
+
import { ConditionalOrder } from '../../ConditionalOrder';
|
|
3
|
+
import { IsValidResult, PollParams, PollResultErrors } from '../../types';
|
|
4
|
+
export declare const DEFAULT_ORDER_PARAMS: TestConditionalOrderParams;
|
|
5
|
+
export type TestConditionalOrderParams = {
|
|
6
|
+
handler: string;
|
|
7
|
+
salt?: string;
|
|
8
|
+
data: string;
|
|
9
|
+
isSingleOrder: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare class TestConditionalOrder extends ConditionalOrder<string, string> {
|
|
12
|
+
isSingleOrder: boolean;
|
|
13
|
+
constructor(params: TestConditionalOrderParams);
|
|
14
|
+
get orderType(): string;
|
|
15
|
+
encodeStaticInput(): string;
|
|
16
|
+
testEncodeStaticInput(): string;
|
|
17
|
+
transformStructToData(params: string): string;
|
|
18
|
+
transformDataToStruct(params: string): string;
|
|
19
|
+
protected pollValidate(_params: PollParams): Promise<PollResultErrors | undefined>;
|
|
20
|
+
protected handlePollFailedAlreadyPresent(_orderUid: string, _order: GPv2Order.DataStruct, _params: PollParams): Promise<PollResultErrors | undefined>;
|
|
21
|
+
isValid(): IsValidResult;
|
|
22
|
+
serialize(): string;
|
|
23
|
+
toString(): string;
|
|
24
|
+
}
|
|
25
|
+
export declare const createTestConditionalOrder: (params?: Partial<TestConditionalOrderParams>) => TestConditionalOrder;
|
|
@@ -60,10 +60,14 @@ export type ProofWithParams = {
|
|
|
60
60
|
proof: string[];
|
|
61
61
|
params: ConditionalOrderParams;
|
|
62
62
|
};
|
|
63
|
-
export type
|
|
63
|
+
export type OwnerContext = {
|
|
64
64
|
owner: string;
|
|
65
65
|
chainId: SupportedChainId;
|
|
66
66
|
provider: providers.Provider;
|
|
67
|
+
};
|
|
68
|
+
export type PollParams = OwnerContext & {
|
|
69
|
+
offchainInput?: string;
|
|
70
|
+
proof?: string[];
|
|
67
71
|
/**
|
|
68
72
|
* If present, it can be used for custom conditional order validations. If not present, the orders will need to get the block info themselves
|
|
69
73
|
*/
|
|
@@ -80,12 +84,12 @@ export declare enum PollResultCode {
|
|
|
80
84
|
UNEXPECTED_ERROR = "UNEXPECTED_ERROR",
|
|
81
85
|
TRY_NEXT_BLOCK = "TRY_NEXT_BLOCK",
|
|
82
86
|
TRY_ON_BLOCK = "TRY_ON_BLOCK",
|
|
83
|
-
TRY_AT_EPOCH = "
|
|
87
|
+
TRY_AT_EPOCH = "TRY_AT_EPOCH",
|
|
84
88
|
DONT_TRY_AGAIN = "DONT_TRY_AGAIN"
|
|
85
89
|
}
|
|
86
90
|
export interface PollResultSuccess {
|
|
87
91
|
readonly result: PollResultCode.SUCCESS;
|
|
88
|
-
readonly order: GPv2Order.
|
|
92
|
+
readonly order: GPv2Order.DataStruct;
|
|
89
93
|
readonly signature: string;
|
|
90
94
|
}
|
|
91
95
|
export interface PollResultUnexpectedError {
|
|
@@ -105,10 +109,10 @@ export interface PollResultTryOnBlock {
|
|
|
105
109
|
export interface PollResultTryAtEpoch {
|
|
106
110
|
readonly result: PollResultCode.TRY_AT_EPOCH;
|
|
107
111
|
/**
|
|
108
|
-
* The epoch after which it is ok to
|
|
112
|
+
* The epoch after which it is ok to retry to to poll this order.
|
|
109
113
|
* The value is expressed as a Unix timestamp (in seconds).
|
|
110
114
|
*
|
|
111
|
-
* This epoch will be inclusive, meaning that it is ok to
|
|
115
|
+
* This epoch will be inclusive, meaning that it is ok to retry at the block mined precisely at this epoch or later.
|
|
112
116
|
*/
|
|
113
117
|
readonly epoch: number;
|
|
114
118
|
reason?: string;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import { utils, providers } from 'ethers';
|
|
1
|
+
import { utils, providers, BigNumber } from 'ethers';
|
|
2
2
|
import { SupportedChainId } from '../common';
|
|
3
3
|
import { BlockInfo, ConditionalOrderParams } from './types';
|
|
4
|
+
import { Order } from '@cowprotocol/contracts';
|
|
5
|
+
import { GPv2Order } from './generated/ComposableCoW';
|
|
4
6
|
export declare const CONDITIONAL_ORDER_PARAMS_ABI: string[];
|
|
7
|
+
export declare const DEFAULT_TOKEN_FORMATTER: (address: string, amount: BigNumber) => string;
|
|
5
8
|
export declare function isExtensibleFallbackHandler(handler: string, chainId: SupportedChainId): boolean;
|
|
6
9
|
export declare function isComposableCow(handler: string, chainId: SupportedChainId): boolean;
|
|
7
10
|
export declare function getDomainVerifier(safe: string, domain: string, chainId: SupportedChainId, provider: providers.Provider): Promise<string>;
|
|
@@ -29,4 +32,5 @@ export declare function decodeParams(encoded: string): ConditionalOrderParams;
|
|
|
29
32
|
*/
|
|
30
33
|
export declare function isValidAbi(types: readonly (string | utils.ParamType)[], values: any[]): boolean;
|
|
31
34
|
export declare function getBlockInfo(provider: providers.Provider): Promise<BlockInfo>;
|
|
32
|
-
export declare function
|
|
35
|
+
export declare function formatEpoch(epoch: number): string;
|
|
36
|
+
export declare function fromStructToOrder(order: GPv2Order.DataStruct): Order;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import"cross-fetch/polyfill";import{RateLimiter as e}from"limiter";import{backOff as t}from"exponential-backoff";import{gql as n,request as a}from"graphql-request";import{utils as r,Contract as s,ethers as i,constants as o,BigNumber as d}from"ethers";import{OrderBalance as p,OrderKind as c}from"@cowprotocol/contracts";import{StandardMerkleTree as u}from"@openzeppelin/merkle-tree";var y;!function(e){e[e.MAINNET=1]="MAINNET",e[e.GOERLI=5]="GOERLI",e[e.GNOSIS_CHAIN=100]="GNOSIS_CHAIN"}(y||(y={}));const l=["prod","staging"],f={env:"prod",chainId:y.MAINNET};class m extends Error{constructor(e,t){super(e),this.error_code=void 0,this.error_code=t}}const T="cow-sdk:",b="https://gnosis.mypinata.cloud/ipfs",h="https://api.pinata.cloud";function E(){return E=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},E.apply(this,arguments)}function I(e,t){if(null==e)return{};var n,a,r={},s=Object.keys(e);for(a=0;a<s.length;a++)t.indexOf(n=s[a])>=0||(r[n]=e[n]);return r}const{GPv2Settlement:A}=JSON.parse('{\n "GPv2AllowListAuthentication_Implementation": {\n "1": {\n "address": "0x9E7Ae8Bdba9AA346739792d219a808884996Db67",\n "transactionHash": "0x58340aa44119c74e48635fab0ac344170c6d6e8b42e5714baa4ba4e1651f63ad"\n },\n "4": {\n "address": "0x9E7Ae8Bdba9AA346739792d219a808884996Db67"\n },\n "5": {\n "address": "0x9E7Ae8Bdba9AA346739792d219a808884996Db67",\n "transactionHash": "0x24f4f80b46a17345011065f9ea2af823f582db56be81098b3b66cc2db9659ea7"\n },\n "100": {\n "address": "0x9E7Ae8Bdba9AA346739792d219a808884996Db67",\n "transactionHash": "0xe52d425fe34d6d5215ccfc9ddfa485d490b3018f0ee5bbed708f2d172044d60d"\n }\n },\n "GPv2AllowListAuthentication_Proxy": {\n "1": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0xb84bf720364f94c749f1ec1cdf0d4c44c70411b716459aaccfd24fc677013375"\n },\n "4": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x57b2278fd3a13ab1b132031024475ba1a4e28d7d4d37f556134c84512b742c1f"\n },\n "5": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x39dcf30baf887a5db54551a84de8bfdb6cf418bb284b09680d13aed17d5fa0c1"\n },\n "100": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x1a2d87a05a94bc6680a4faee31bbafbd74e9ddb63dd3941c717b5c609c08b957"\n }\n },\n "GPv2AllowListAuthentication": {\n "1": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0xb84bf720364f94c749f1ec1cdf0d4c44c70411b716459aaccfd24fc677013375"\n },\n "4": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x57b2278fd3a13ab1b132031024475ba1a4e28d7d4d37f556134c84512b742c1f"\n },\n "5": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x39dcf30baf887a5db54551a84de8bfdb6cf418bb284b09680d13aed17d5fa0c1"\n },\n "100": {\n "address": "0x2c4c28DDBdAc9C5E7055b4C863b72eA0149D8aFE",\n "transactionHash": "0x1a2d87a05a94bc6680a4faee31bbafbd74e9ddb63dd3941c717b5c609c08b957"\n }\n },\n "GPv2Settlement": {\n "1": {\n "address": "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",\n "transactionHash": "0xf49f90aa5a268c40001d1227b76bb4dd8247f18361fcad9fffd4a7a44f1320d3"\n },\n "4": {\n "address": "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",\n "transactionHash": "0x609fa2e8f32c73c1f5dc21ff60a26238dacb50d4674d336c90d6950bdda17a21"\n },\n "5": {\n "address": "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",\n "transactionHash": "0x982f089060ff66e19d0683ef1cc6a637297331a9ba95b65d8eb84b9f8dc64b04"\n },\n "100": {\n "address": "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",\n "transactionHash": "0x9ddc538f89cd8433f4a19bc4de0de27e7c68a1d04a14b327185e4bba9af87133"\n }\n },\n "GPv2VaultRelayer": {\n "1": {\n "address": "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",\n "transactionHash": "0xf49f90aa5a268c40001d1227b76bb4dd8247f18361fcad9fffd4a7a44f1320d3"\n },\n "4": {\n "address": "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",\n "transactionHash": "0x609fa2e8f32c73c1f5dc21ff60a26238dacb50d4674d336c90d6950bdda17a21"\n },\n "5": {\n "address": "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",\n "transactionHash": "0x982f089060ff66e19d0683ef1cc6a637297331a9ba95b65d8eb84b9f8dc64b04"\n },\n "100": {\n "address": "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",\n "transactionHash": "0x9ddc538f89cd8433f4a19bc4de0de27e7c68a1d04a14b327185e4bba9af87133"\n }\n }\n}'),O="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",S="0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5",N="0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74",_=[y.MAINNET,y.GOERLI,y.GNOSIS_CHAIN],g=_.reduce((e,t)=>E({},e,{[t]:A[t].address}),{}),v=_.reduce((e,t)=>E({},e,{[t]:S}),{}),D=_.reduce((e,t)=>E({},e,{[t]:N}),{});function w(e){return function(e){const{ethflowData:t}=e;if(!t)return e;const{userValidTo:n}=t;return E({},e,{validTo:n,owner:e.onchainUser||e.owner,sellToken:O})}(function(e){const{executedFeeAmount:t,executedSurplusFee:n}=e;return E({},e,{totalFee:null!=n?n:t})}(e))}class C extends Error{constructor(e,t){super("string"==typeof t?t:e.statusText),this.response=void 0,this.body=void 0,this.response=e,this.body=t}}const R=[408,425,429,500,502,503,504],P={numOfAttempts:10,maxDelay:Infinity,jitter:"none",retry:e=>!(e instanceof C)||R.includes(e.response.status)},x={tokensPerInterval:5,interval:"second"},U=async e=>{if(204!==e.status)try{const t=e.headers.get("Content-Type");if(t)return t.toLowerCase().startsWith("application/json")?await e.json():await e.text()}catch(e){console.error(e)}};async function L(e,{path:n,query:a,method:r,body:s},i,o){const d=`${e}${n}${a?"?"+a:""}`,p={method:r,body:(()=>{if(s)return"string"==typeof s?s:JSON.stringify(s)})(),headers:{Accept:"application/json","Content-Type":"application/json"}};return t(async()=>{await i.removeTokens(1);const e=await fetch(d,p),t=await U(e);return e.status>=200&&e.status<300?t:Promise.reject(new C(e,t))},o)}const M={[y.MAINNET]:"https://api.cow.fi/mainnet",[y.GNOSIS_CHAIN]:"https://api.cow.fi/xdai",[y.GOERLI]:"https://api.cow.fi/goerli"},F={[y.MAINNET]:"https://barn.api.cow.fi/mainnet",[y.GNOSIS_CHAIN]:"https://barn.api.cow.fi/xdai",[y.GOERLI]:"https://barn.api.cow.fi/goerli"};function k(e){return Object.keys(e).reduce((t,n)=>{const a=e[n];return void 0!==a&&(t[n]=a),t},{})}class G{constructor(t={}){this.context=void 0,this.rateLimiter=void 0,this.context=E({},f,t),this.rateLimiter=new e(t.limiterOpts||x)}getVersion(e={}){return this.fetch({path:"/api/v1/version",method:"GET"},e)}getTrades(e,t={}){if(e.owner&&e.orderUid)return Promise.reject(new m("Cannot specify both owner and orderId"));if(!e.owner&&!e.orderUid)return Promise.reject(new m("Must specify either owner or orderId"));const n=new URLSearchParams(k(e));return this.fetch({path:"/api/v1/trades",method:"GET",query:n},t)}getOrders({owner:e,offset:t=0,limit:n=1e3},a={}){const r=new URLSearchParams(k({offset:t.toString(),limit:n.toString()}));return this.fetch({path:`/api/v1/account/${e}/orders`,method:"GET",query:r},a).then(e=>e.map(w))}getTxOrders(e,t={}){return this.fetch({path:`/api/v1/transactions/${e}/orders`,method:"GET"},t).then(e=>e.map(w))}getOrder(e,t={}){return this.fetch({path:`/api/v1/orders/${e}`,method:"GET"},t).then(e=>w(e))}getOrderMultiEnv(e,t={}){const{env:n}=this.getContextWithOverride(t),a=l.filter(e=>e!==n);let r=0;const s=n=>{const i=a[r];return n instanceof C&&404===n.response.status&&i?(r++,this.getOrder(e,E({},t,{env:i})).catch(s)):Promise.reject(n)};return this.getOrder(e,E({},t,{env:n})).catch(s)}getQuote(e,t={}){return this.fetch({path:"/api/v1/quote",method:"POST",body:e},t)}sendSignedOrderCancellations(e,t={}){return this.fetch({path:"/api/v1/orders",method:"DELETE",body:e},t)}sendOrder(e,t={}){return this.fetch({path:"/api/v1/orders",method:"POST",body:e},t)}getNativePrice(e,t={}){return this.fetch({path:`/api/v1/token/${e}/native_price`,method:"GET"},t)}getTotalSurplus(e,t={}){return this.fetch({path:`/api/v1/users/${e}/total_surplus`,method:"GET"},t)}getAppData(e,t={}){return this.fetch({path:`/api/v1/app_data/${e}`,method:"GET"},t)}uploadAppData(e,t,n={}){return this.fetch({path:`/api/v1/app_data/${e}`,method:"PUT",body:{fullAppData:t}},n)}getSolverCompetition(e,t={}){return this.fetch({path:`/api/v1/solver_competition${"string"==typeof e?"/by_tx_hash":""}/${e}`,method:"GET"},t)}getOrderLink(e,t){const{chainId:n,env:a}=this.getContextWithOverride(t);return this.getApiBaseUrls(a)[n]+`/api/v1/orders/${e}`}getContextWithOverride(e={}){return E({},this.context,e)}getApiBaseUrls(e){return this.context.baseUrls?this.context.baseUrls:"prod"===e?M:F}fetch(e,t={}){const{chainId:n,env:a}=this.getContextWithOverride(t);return L(this.getApiBaseUrls(a)[n],e,this.rateLimiter,this.context.backoffOpts||P)}}var B,V,H,$,W,Y,j,Z,K,X,q,z,J,Q,ee;!function(e){e.ERC20="erc20",e.INTERNAL="internal"}(B||(B={})),function(e){e.EIP712="eip712",e.ETHSIGN="ethsign"}(V||(V={})),function(e){var t;(t=e.errorType||(e.errorType={})).NO_LIQUIDITY="NoLiquidity",t.UNSUPPORTED_TOKEN="UnsupportedToken",t.AMOUNT_IS_ZERO="AmountIsZero",t.SELL_AMOUNT_DOES_NOT_COVER_FEE="SellAmountDoesNotCoverFee"}(H||(H={})),function(e){var t;(t=e.placementError||(e.placementError={})).QUOTE_NOT_FOUND="QuoteNotFound",t.VALID_TO_TOO_FAR_IN_FUTURE="ValidToTooFarInFuture",t.PRE_VALIDATION_ERROR="PreValidationError"}($||($={})),function(e){var t;(t=e.errorType||(e.errorType={})).INVALID_SIGNATURE="InvalidSignature",t.WRONG_OWNER="WrongOwner",t.ORDER_NOT_FOUND="OrderNotFound",t.ALREADY_CANCELLED="AlreadyCancelled",t.ORDER_FULLY_EXECUTED="OrderFullyExecuted",t.ORDER_EXPIRED="OrderExpired",t.ON_CHAIN_ORDER="OnChainOrder"}(W||(W={})),function(e){e.MARKET="market",e.LIMIT="limit",e.LIQUIDITY="liquidity"}(Y||(Y={})),function(e){e.BUY="buy",e.SELL="sell"}(j||(j={})),function(e){var t;(t=e.errorType||(e.errorType={})).DUPLICATE_ORDER="DuplicateOrder",t.INSUFFICIENT_FEE="InsufficientFee",t.INSUFFICIENT_ALLOWANCE="InsufficientAllowance",t.INSUFFICIENT_BALANCE="InsufficientBalance",t.INSUFFICIENT_VALID_TO="InsufficientValidTo",t.EXCESSIVE_VALID_TO="ExcessiveValidTo",t.INVALID_SIGNATURE="InvalidSignature",t.TRANSFER_ETH_TO_CONTRACT="TransferEthToContract",t.TRANSFER_SIMULATION_FAILED="TransferSimulationFailed",t.UNSUPPORTED_TOKEN="UnsupportedToken",t.WRONG_OWNER="WrongOwner",t.INVALID_EIP1271SIGNATURE="InvalidEip1271Signature",t.MISSING_FROM="MissingFrom",t.SAME_BUY_AND_SELL_TOKEN="SameBuyAndSellToken",t.ZERO_AMOUNT="ZeroAmount",t.UNSUPPORTED_BUY_TOKEN_DESTINATION="UnsupportedBuyTokenDestination",t.UNSUPPORTED_SELL_TOKEN_SOURCE="UnsupportedSellTokenSource",t.UNSUPPORTED_ORDER_TYPE="UnsupportedOrderType",t.UNSUPPORTED_SIGNATURE="UnsupportedSignature",t.TOO_MANY_LIMIT_ORDERS="TooManyLimitOrders",t.INVALID_APP_DATA="InvalidAppData",t.APP_DATA_HASH_MISMATCH="AppDataHashMismatch"}(Z||(Z={})),function(e){e.BUY="buy"}(K||(K={})),function(e){e.SELL="sell"}(X||(X={})),function(e){e.PRESIGNATURE_PENDING="presignaturePending",e.OPEN="open",e.FULFILLED="fulfilled",e.CANCELLED="cancelled",e.EXPIRED="expired"}(q||(q={})),function(e){e.FAST="fast",e.OPTIMAL="optimal",e.VERIFIED="verified"}(z||(z={})),function(e){var t;(t=e.errorType||(e.errorType={})).ALREADY_CANCELLED="AlreadyCancelled",t.ORDER_FULLY_EXECUTED="OrderFullyExecuted",t.ORDER_EXPIRED="OrderExpired",t.ON_CHAIN_ORDER="OnChainOrder",t.DUPLICATE_ORDER="DuplicateOrder",t.INSUFFICIENT_FEE="InsufficientFee",t.INSUFFICIENT_ALLOWANCE="InsufficientAllowance",t.INSUFFICIENT_BALANCE="InsufficientBalance",t.INSUFFICIENT_VALID_TO="InsufficientValidTo",t.EXCESSIVE_VALID_TO="ExcessiveValidTo",t.INVALID_SIGNATURE="InvalidSignature",t.TRANSFER_ETH_TO_CONTRACT="TransferEthToContract",t.TRANSFER_SIMULATION_FAILED="TransferSimulationFailed",t.UNSUPPORTED_TOKEN="UnsupportedToken",t.WRONG_OWNER="WrongOwner",t.SAME_BUY_AND_SELL_TOKEN="SameBuyAndSellToken",t.ZERO_AMOUNT="ZeroAmount",t.UNSUPPORTED_BUY_TOKEN_DESTINATION="UnsupportedBuyTokenDestination",t.UNSUPPORTED_SELL_TOKEN_SOURCE="UnsupportedSellTokenSource",t.UNSUPPORTED_ORDER_TYPE="UnsupportedOrderType",t.UNSUPPORTED_SIGNATURE="UnsupportedSignature"}(J||(J={})),function(e){e.ERC20="erc20",e.INTERNAL="internal",e.EXTERNAL="external"}(Q||(Q={})),function(e){e.EIP712="eip712",e.ETHSIGN="ethsign",e.PRESIGN="presign",e.EIP1271="eip1271"}(ee||(ee={}));let te,ne,ae,re=e=>e;const se=n(te||(te=re`
|
|
2
|
+
query Totals {
|
|
3
|
+
totals {
|
|
4
|
+
tokens
|
|
5
|
+
orders
|
|
6
|
+
traders
|
|
7
|
+
settlements
|
|
8
|
+
volumeUsd
|
|
9
|
+
volumeEth
|
|
10
|
+
feesUsd
|
|
11
|
+
feesEth
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
`)),ie=n(ne||(ne=re`
|
|
15
|
+
query LastDaysVolume($days: Int!) {
|
|
16
|
+
dailyTotals(orderBy: timestamp, orderDirection: desc, first: $days) {
|
|
17
|
+
timestamp
|
|
18
|
+
volumeUsd
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`)),oe=n(ae||(ae=re`
|
|
22
|
+
query LastHoursVolume($hours: Int!) {
|
|
23
|
+
hourlyTotals(orderBy: timestamp, orderDirection: desc, first: $hours) {
|
|
24
|
+
timestamp
|
|
25
|
+
volumeUsd
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`)),de="https://api.thegraph.com/subgraphs/name/cowprotocol",pe={[y.MAINNET]:de+"/cow",[y.GNOSIS_CHAIN]:de+"/cow-gc",[y.GOERLI]:de+"/cow-goerli"},ce={[y.MAINNET]:de+"/cow-staging",[y.GNOSIS_CHAIN]:de+"/cow-gc-staging",[y.GOERLI]:""};class ue{constructor(e={}){this.API_NAME="CoW Protocol Subgraph",this.context=void 0,this.context=E({},f,e)}async getTotals(e={}){return(await this.runQuery(se,void 0,e)).totals[0]}async getLastDaysVolume(e,t={}){return this.runQuery(ie,{days:e},t)}async getLastHoursVolume(e,t={}){return this.runQuery(oe,{hours:e},t)}async runQuery(e,t=undefined,n={}){const{chainId:r,env:s}=this.getContextWithOverride(n),i=this.getEnvConfigs(s)[r];try{return await a(i,e,t)}catch(n){throw console.error(`[subgraph:${this.API_NAME}]`,n),new m(`Error running query: ${e}. Variables: ${JSON.stringify(t)}. API: ${i}. Inner Error: ${n}`)}}getContextWithOverride(e={}){return E({},this.context,e)}getEnvConfigs(e){return this.context.baseUrls?this.context.baseUrls:"prod"===e?pe:ce}}const ye=()=>import("./utils-438cb2f6.js");class le{static async signOrder(e,t,n){const{signOrder:a}=await ye();return a(e,t,n)}static async signOrderCancellation(e,t,n){const{signOrderCancellation:a}=await ye();return a(e,t,n)}static async signOrderCancellations(e,t,n){const{signOrderCancellations:a}=await ye();return a(e,t,n)}static async getDomain(e){const{getDomain:t}=await ye();return t(e)}static async getDomainSeparator(e){const{getDomain:t}=await ye(),{_TypedDataEncoder:n}=await import("ethers/lib/utils");return n.hashDomain(t(e))}static getEIP712Types(){return{Order:[{name:"sellToken",type:"address"},{name:"buyToken",type:"address"},{name:"receiver",type:"address"},{name:"sellAmount",type:"uint256"},{name:"buyAmount",type:"uint256"},{name:"validTo",type:"uint32"},{name:"appData",type:"bytes32"},{name:"feeAmount",type:"uint256"},{name:"kind",type:"string"},{name:"partiallyFillable",type:"bool"},{name:"sellTokenBalance",type:"string"},{name:"buyTokenBalance",type:"string"}]}}}var fe,me;!function(e){e[e.PRIVATE=0]="PRIVATE",e[e.EMITTED=1]="EMITTED",e[e.SWARM=2]="SWARM",e[e.WAKU=3]="WAKU",e[e.RESERVED=4]="RESERVED",e[e.IPFS=5]="IPFS"}(fe||(fe={})),function(e){e.SUCCESS="SUCCESS",e.UNEXPECTED_ERROR="UNEXPECTED_ERROR",e.TRY_NEXT_BLOCK="TRY_NEXT_BLOCK",e.TRY_ON_BLOCK="TRY_ON_BLOCK",e.TRY_AT_EPOCH="TRY_AT_EPOCH",e.DONT_TRY_AGAIN="DONT_TRY_AGAIN"}(me||(me={}));const Te=[{inputs:[{internalType:"address",name:"_settlement",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InterfaceNotSupported",type:"error"},{inputs:[],name:"InvalidHandler",type:"error"},{inputs:[],name:"ProofNotAuthed",type:"error"},{inputs:[],name:"SingleOrderNotAuthed",type:"error"},{inputs:[],name:"SwapGuardRestricted",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],indexed:!1,internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"}],name:"ConditionalOrderCreated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!1,internalType:"bytes32",name:"root",type:"bytes32"},{components:[{internalType:"uint256",name:"location",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],indexed:!1,internalType:"struct ComposableCoW.Proof",name:"proof",type:"tuple"}],name:"MerkleRootSet",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!1,internalType:"contract ISwapGuard",name:"swapGuard",type:"address"}],name:"SwapGuardSet",type:"event"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"bytes32",name:"",type:"bytes32"}],name:"cabinet",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"},{internalType:"bool",name:"dispatch",type:"bool"}],name:"create",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"},{internalType:"contract IValueFactory",name:"factory",type:"address"},{internalType:"bytes",name:"data",type:"bytes"},{internalType:"bool",name:"dispatch",type:"bool"}],name:"createWithContext",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"domainSeparator",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"},{internalType:"bytes",name:"offchainInput",type:"bytes"},{internalType:"bytes32[]",name:"proof",type:"bytes32[]"}],name:"getTradeableOrderWithSignature",outputs:[{components:[{internalType:"contract IERC20",name:"sellToken",type:"address"},{internalType:"contract IERC20",name:"buyToken",type:"address"},{internalType:"address",name:"receiver",type:"address"},{internalType:"uint256",name:"sellAmount",type:"uint256"},{internalType:"uint256",name:"buyAmount",type:"uint256"},{internalType:"uint32",name:"validTo",type:"uint32"},{internalType:"bytes32",name:"appData",type:"bytes32"},{internalType:"uint256",name:"feeAmount",type:"uint256"},{internalType:"bytes32",name:"kind",type:"bytes32"},{internalType:"bool",name:"partiallyFillable",type:"bool"},{internalType:"bytes32",name:"sellTokenBalance",type:"bytes32"},{internalType:"bytes32",name:"buyTokenBalance",type:"bytes32"}],internalType:"struct GPv2Order.Data",name:"order",type:"tuple"},{internalType:"bytes",name:"signature",type:"bytes"}],stateMutability:"view",type:"function"},{inputs:[{components:[{internalType:"contract IConditionalOrder",name:"handler",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"bytes",name:"staticInput",type:"bytes"}],internalType:"struct IConditionalOrder.ConditionalOrderParams",name:"params",type:"tuple"}],name:"hash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"contract Safe",name:"safe",type:"address"},{internalType:"address",name:"sender",type:"address"},{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes32",name:"_domainSeparator",type:"bytes32"},{internalType:"bytes32",name:"",type:"bytes32"},{internalType:"bytes",name:"encodeData",type:"bytes"},{internalType:"bytes",name:"payload",type:"bytes"}],name:"isValidSafeSignature",outputs:[{internalType:"bytes4",name:"magic",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"singleOrderHash",type:"bytes32"}],name:"remove",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"roots",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"root",type:"bytes32"},{components:[{internalType:"uint256",name:"location",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],internalType:"struct ComposableCoW.Proof",name:"proof",type:"tuple"}],name:"setRoot",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"root",type:"bytes32"},{components:[{internalType:"uint256",name:"location",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],internalType:"struct ComposableCoW.Proof",name:"proof",type:"tuple"},{internalType:"contract IValueFactory",name:"factory",type:"address"},{internalType:"bytes",name:"data",type:"bytes"}],name:"setRootWithContext",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"contract ISwapGuard",name:"swapGuard",type:"address"}],name:"setSwapGuard",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"bytes32",name:"",type:"bytes32"}],name:"singleOrders",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"swapGuards",outputs:[{internalType:"contract ISwapGuard",name:"",type:"address"}],stateMutability:"view",type:"function"}];class be{static createInterface(){return new r.Interface(Te)}static connect(e,t){return new s(e,Te,t)}}be.abi=Te;const he=[{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes32",name:"domainSeparator",type:"bytes32"},{indexed:!1,internalType:"contract ISafeSignatureVerifier",name:"verifier",type:"address"}],name:"AddedDomainVerifier",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"AddedInterface",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"selector",type:"bytes4"},{indexed:!1,internalType:"bytes32",name:"method",type:"bytes32"}],name:"AddedSafeMethod",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes32",name:"domainSeparator",type:"bytes32"},{indexed:!1,internalType:"contract ISafeSignatureVerifier",name:"oldVerifier",type:"address"},{indexed:!1,internalType:"contract ISafeSignatureVerifier",name:"newVerifier",type:"address"}],name:"ChangedDomainVerifier",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"selector",type:"bytes4"},{indexed:!1,internalType:"bytes32",name:"oldMethod",type:"bytes32"},{indexed:!1,internalType:"bytes32",name:"newMethod",type:"bytes32"}],name:"ChangedSafeMethod",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes32",name:"domainSeparator",type:"bytes32"}],name:"RemovedDomainVerifier",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"RemovedInterface",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"contract Safe",name:"safe",type:"address"},{indexed:!1,internalType:"bytes4",name:"selector",type:"bytes4"}],name:"RemovedSafeMethod",type:"event"},{stateMutability:"nonpayable",type:"fallback"},{inputs:[{internalType:"contract Safe",name:"",type:"address"},{internalType:"bytes32",name:"",type:"bytes32"}],name:"domainVerifiers",outputs:[{internalType:"contract ISafeSignatureVerifier",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"_hash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"isValidSignature",outputs:[{internalType:"bytes4",name:"magic",type:"bytes4"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"uint256[]",name:"",type:"uint256[]"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155BatchReceived",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC1155Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"},{internalType:"uint256",name:"",type:"uint256"},{internalType:"bytes",name:"",type:"bytes"}],name:"onERC721Received",outputs:[{internalType:"bytes4",name:"",type:"bytes4"}],stateMutability:"pure",type:"function"},{inputs:[{internalType:"contract Safe",name:"",type:"address"},{internalType:"bytes4",name:"",type:"bytes4"}],name:"safeInterfaces",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"contract Safe",name:"",type:"address"},{internalType:"bytes4",name:"",type:"bytes4"}],name:"safeMethods",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"domainSeparator",type:"bytes32"},{internalType:"contract ISafeSignatureVerifier",name:"newVerifier",type:"address"}],name:"setDomainVerifier",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"selector",type:"bytes4"},{internalType:"bytes32",name:"newMethod",type:"bytes32"}],name:"setSafeMethod",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"},{internalType:"bool",name:"supported",type:"bool"}],name:"setSupportedInterface",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"_interfaceId",type:"bytes4"},{internalType:"bytes32[]",name:"handlerWithSelectors",type:"bytes32[]"}],name:"setSupportedInterfaceBatch",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"}];class Ee{static createInterface(){return new r.Interface(he)}static connect(e,t){return new s(e,he,t)}}Ee.abi=he;const Ie=["erc20","0x5a28e9363bb942b639270062aa6bb295f434bcdfc42c97267bf003f272060dc9"],Ae=["external","0xabee3b73373acd583a130924aad6dc38cfdc44ba0555ba94ce2ff63980ea0632"],Oe=["internal","0x4ac99ace14ee0a5ef932dc609df0943ab7ac16b7583634612f8dc35a4289a6ce"],Se=["sell","0xf3b277728b3fee749481eb3e0b3b48980dbbab78658fc419025cb16eee346775"],Ne=["buy","0x6ed88e868af0a1983e3886d5f3e95a2fafbd6c3450bc229e27342283dc429ccc"],_e=["tuple(address handler, bytes32 salt, bytes staticInput)"],ge=(e,t)=>`${t}@${e}`;function ve(e,t){return e===v[t]}function De(e,t){return e===D[t]}async function we(e,t,n,a){const r=Ee.connect(v[n],a);return await r.callStatic.domainVerifiers(e,t)}function Ce(e,t){return Ee.createInterface().encodeFunctionData("setDomainVerifier",[e,t])}function Re(e){return r.defaultAbiCoder.encode(_e,[e])}function Pe(e){const{handler:t,salt:n,staticInput:a}=r.defaultAbiCoder.decode(_e,e)[0];return{handler:t,salt:n,staticInput:a}}function xe(e,t){try{r.defaultAbiCoder.encode(e,t)}catch(e){return!1}return!0}async function Ue(e){const t=await e.getBlock("latest");return{blockNumber:t.number,blockTimestamp:t.timestamp}}function Le(e){return new Date(1e3*e).toISOString()}function Me(e){if(Ie.includes(e))return p.ERC20;if(Ae.includes(e))return p.EXTERNAL;if(Oe.includes(e))return p.INTERNAL;throw new Error(`Unknown balance type: ${e}`)}function Fe(e){if(Se.includes(e))return c.SELL;if(Ne.includes(e))return c.BUY;throw new Error(`Unknown kind: ${e}`)}function ke(e){const{sellToken:t,sellAmount:n,buyToken:a,buyAmount:r,buyTokenBalance:s,sellTokenBalance:i,feeAmount:o,kind:d,receiver:p,validTo:c,partiallyFillable:u,appData:y}=e;return{sellToken:t,sellAmount:n,buyToken:a,buyAmount:r,feeAmount:o,receiver:p,partiallyFillable:u,appData:y,validTo:Number(c),kind:Fe(d.toString()),sellTokenBalance:Me(i.toString()),buyTokenBalance:Me(s.toString())}}let Ge,Be;function Ve(){return Ge||(Ge=be.createInterface()),Ge}function He(e,t){return Be||(Be=be.connect(D[e],t)),Be}const $e={};class We{constructor(e){this.handler=void 0,this.salt=void 0,this.data=void 0,this.staticInput=void 0,this.hasOffChainInput=void 0;const{handler:t,salt:n=r.keccak256(r.randomBytes(32)),data:a,hasOffChainInput:s=!1}=e;if(!i.utils.isAddress(t))throw new Error(`Invalid handler: ${t}`);if(!i.utils.isHexString(n)||32!==i.utils.hexDataLength(n))throw new Error(`Invalid salt: ${n}`);this.handler=t,this.salt=n,this.data=a,this.staticInput=this.transformDataToStruct(a),this.hasOffChainInput=s}get context(){}assertIsValid(){const e=this.isValid();if(!e.isValid)throw new Error(`Invalid order: ${e.reason}`)}get createCalldata(){this.assertIsValid();const e=this.context,t=Ve(),n={handler:this.handler,salt:this.salt,staticInput:this.encodeStaticInput()};if(e){const a=e.factoryArgs?r.defaultAbiCoder.encode(e.factoryArgs.argsType,e.factoryArgs.args):"0x";return t.encodeFunctionData("createWithContext",[n,e.address,a,!0])}return t.encodeFunctionData("create",[n,!0])}get removeCalldata(){return this.assertIsValid(),Ve().encodeFunctionData("remove",[this.id])}get id(){return r.keccak256(this.serialize())}get ctx(){return this.isSingleOrder?this.id:o.HashZero}get leaf(){return{handler:this.handler,salt:this.salt,staticInput:this.encodeStaticInput()}}static leafToId(e){return r.keccak256(Re(e))}get offChainInput(){return"0x"}encodeStaticInputHelper(e,t){return r.defaultAbiCoder.encode(e,[t])}async poll(e){const{chainId:t,owner:n,provider:a}=e,r=He(t,a);try{const a=this.isValid();if(!a.isValid)return{result:me.DONT_TRY_AGAIN,reason:`InvalidConditionalOrder. Reason: ${a.reason}`};const s=await this.pollValidate(e);if(s)return s;if(!await this.isAuthorized(e))return{result:me.DONT_TRY_AGAIN,reason:`NotAuthorized: Order ${this.id} is not authorized for ${n} on chain ${t}`};const[i,o]=await r.getTradeableOrderWithSignature(n,this.leaf,this.offChainInput,[]);let d=$e[t];d||(d=new G({chainId:t}),$e[t]=d);const p=await async function(e,t,n){const{computeOrderUid:a}=await import("@cowprotocol/contracts");return a(await le.getDomain(e),n,t)}(t,n,ke(i));return await d.getOrder(p).then(()=>!0).catch(()=>!1)?await this.handlePollFailedAlreadyPresent(p,i,e)||{result:me.TRY_NEXT_BLOCK,reason:"Order already in orderbook"}:{result:me.SUCCESS,order:i,signature:o}}catch(e){return{result:me.UNEXPECTED_ERROR,error:e}}}isAuthorized(e){const{chainId:t,owner:n,provider:a}=e;return He(t,a).callStatic.singleOrders(n,this.id)}cabinet(e){const{chainId:t,owner:n,provider:a}=e;return He(t,a).callStatic.cabinet(n,this.ctx)}static deserializeHelper(e,t,n,a){try{const{handler:s,salt:i,staticInput:o}=Pe(e);if(s!=t)throw new Error("HandlerMismatch");const[d]=r.defaultAbiCoder.decode(n,o);return a(d,i)}catch(e){throw"HandlerMismatch"===e.message?e:new Error("InvalidSerializedConditionalOrder")}}}const Ye=["orderType"],je=["address","bytes32","bytes"],Ze=["tuple(bytes32[] proof, tuple(address handler, bytes32 salt, bytes staticInput) params)[]"];class Ke{constructor(e,t,n,a=fe.PRIVATE){if(this.chain=void 0,this.location=void 0,this.orders={},this.tree=void 0,this.ctx=void 0,this.chain=e,this.location=a,t&&0===Object.keys(t).length)throw new Error("orders must have non-zero length");if(t&&!n||!t&&n)throw new Error("orders cannot have undefined root");for(const e in t)if(t.hasOwnProperty(e)){const n=t[e];if(!Ke.orderTypeRegistry.hasOwnProperty(n.orderType))throw new Error(`Unknown order type: ${n.orderType}`)}if(t&&(this.orders=t,this.getOrGenerateTree().root!==n))throw new Error("root mismatch")}static fromJSON(e){const{chain:t,orders:n,root:a,location:r}=JSON.parse(e,(e,t)=>{if("orders"===e&&"object"==typeof t&&null!==t){const e={};for(const n in t)if(t.hasOwnProperty(n)){const a=t[n],{orderType:r}=a,s=I(a,Ye);if(!Ke.orderTypeRegistry.hasOwnProperty(r))throw new Error(`Unknown order type: ${r}`);e[n]=new(0,Ke.orderTypeRegistry[r])(s)}return e}return"object"==typeof t&&null!==t&&t.hasOwnProperty("type")&&t.hasOwnProperty("hex")&&"BigNumber"===t.type?d.from(t):t}),s=new Ke(t,n,a);return s.location=r,s}toJSON(){const e=this.getOrGenerateTree().root;return JSON.stringify(E({},this,{root:e}),(e,t)=>{if("tree"!==e)return"object"==typeof t&&null!==t&&"orderType"in t?E({},t,{orderType:t.orderType}):t})}add(e){e.assertIsValid(),this.orders[e.id]=e,this.reset()}remove(e){delete this.orders[e],this.reset()}update(e,t){const n=t(this.orders[e],this.ctx);delete this.orders[e],this.orders[n.id]=n,this.reset()}getById(e){return this.orders[e]}getByIndex(e){return this.orders[this.orderIds[e]]}get orderIds(){return Object.keys(this.orders)}get root(){return this.getOrGenerateTree().root}getOrGenerateTree(){return this.tree||(this.tree=u.of(Object.values(this.orders).map(e=>[...Object.values(e.leaf)]),je)),this.tree}static decodeFromJSON(e){return JSON.parse(e)}async prepareProofStruct(e=this.location,t,n){var a=this;return await async function(){switch(e){case fe.PRIVATE:return"0x";case fe.EMITTED:return a.encodeToABI(t);case fe.SWARM:case fe.WAKU:case fe.IPFS:if(!n)throw new Error("Must provide an uploader function");try{return await n(a.encodeToJSON(t))}catch(t){throw new Error(`Error uploading to decentralized storage ${e}: ${t}`)}default:throw new Error("Unsupported location")}}().then(t=>{try{return r.hexlify(r.arrayify(t)),this.location=e,{location:e,data:t}}catch(e){throw new Error("data returned by uploader is invalid")}}).catch(e=>{throw new Error(`Error preparing proof struct: ${e}`)})}static async poll(e,t,n,a,r){const s=He(n,a),i=r?await r(e,t.params):"0x";return await s.getTradeableOrderWithSignature(e,t.params,i,t.proof)}dumpProofs(e){return this.encodeToJSON(e)}dumpProofsAndParams(e){return this.getProofs(e)}getProofs(e){return[...this.getOrGenerateTree().entries()].map(([t,n])=>e&&e(n)||void 0===e?{idx:t,value:n}:void 0).reduce((e,t)=>{if(t){const n={handler:t.value[0],salt:t.value[1],staticInput:t.value[2]};e.push({proof:this.getOrGenerateTree().getProof(t.idx),params:n})}return e},[])}encodeToABI(e){return r.defaultAbiCoder.encode(Ze,[this.getProofs(e)])}encodeToJSON(e){return JSON.stringify(this.getProofs(e))}reset(){this.tree=void 0}static registerOrderType(e,t){Ke.orderTypeRegistry[e]=t}static resetOrderTypeRegistry(){Ke.orderTypeRegistry={}}}Ke.orderTypeRegistry={};class Xe{constructor(e){this.knownOrderTypes=void 0,this.knownOrderTypes=e}fromParams(e){const{handler:t}=e,n=this.knownOrderTypes[t];if(n)return n(e)}}const qe=["sellAmount","buyAmount","numberOfParts","startTime","timeBetweenParts","durationOfPart"],ze=["n","partSellAmount","minPartLimit","t","t0","span"],Je="0x6cF1e9cA41f7611dEf408122793c358a3d11E5a5",Qe="0x52eD56Da04309Aca4c3FECC595298d80C2f16BAc",et=d.from(2).pow(32).sub(1),tt=d.from(31536e3),nt=["tuple(address sellToken, address buyToken, address receiver, uint256 partSellAmount, uint256 minPartLimit, uint256 t0, uint256 n, uint256 t, uint256 span, bytes32 appData)"];var at,rt;!function(e){e.AUTO="AUTO",e.LIMIT_DURATION="LIMIT_DURATION"}(at||(at={})),function(e){e.AT_MINING_TIME="AT_MINING_TIME",e.AT_EPOCH="AT_EPOCH"}(rt||(rt={}));const st={startType:rt.AT_MINING_TIME},it={durationType:at.AUTO};class ot extends We{constructor(e){const{handler:t,salt:n,data:a,hasOffChainInput:r}=e;if(t!==Je)throw new Error(`InvalidHandler: Expected: ${Je}, provided: ${t}`);super({handler:Je,salt:n,data:a,hasOffChainInput:r}),this.isSingleOrder=!0}static fromData(e){return new ot({handler:Je,data:e})}static fromParams(e){return ot.deserialize(Re(e))}get context(){return this.staticInput.t0.gt(0)?super.context:{address:Qe,factoryArgs:void 0}}get orderType(){return"twap"}isValid(){const e=(()=>{const{sellToken:e,sellAmount:t,buyToken:n,buyAmount:a,startTime:r=st,numberOfParts:s,timeBetweenParts:i,durationOfPart:d=it}=this.data;if(e==n)return"InvalidSameToken";if(e==o.AddressZero||n==o.AddressZero)return"InvalidToken";if(!t.gt(o.Zero))return"InvalidSellAmount";if(!a.gt(o.Zero))return"InvalidMinBuyAmount";if(r.startType===rt.AT_EPOCH){const e=r.epoch;if(!e.gte(o.Zero)||!e.lt(et))return"InvalidStartTime"}return s.gt(o.One)&&s.lte(et)?i.gt(o.Zero)&&i.lte(tt)?d.durationType!==at.LIMIT_DURATION||d.duration.lte(i)?xe(nt,[this.staticInput])?void 0:"InvalidData":"InvalidSpan":"InvalidFrequency":"InvalidNumParts"})();return e?{isValid:!1,reason:e}:{isValid:!0}}async startTimestamp(e){const{startTime:t}=this.data;if((null==t?void 0:t.startType)===rt.AT_EPOCH)return t.epoch.toNumber();const n=await this.cabinet(e);if(0===r.defaultAbiCoder.decode(["uint256"],n)[0])throw new Error("Cabinet is not set. Required for TWAP orders that start at mining time.");return parseInt(n,16)}endTimestamp(e){const{numberOfParts:t,timeBetweenParts:n,durationOfPart:a}=this.data;return a&&a.durationType===at.LIMIT_DURATION?e+t.sub(1).mul(n).add(a.duration).toNumber():e+t.mul(n).toNumber()}async pollValidate(e){const{blockInfo:t=await Ue(e.provider)}=e,{blockTimestamp:n}=t,a=await this.startTimestamp(e);if(a>n)return{result:me.TRY_AT_EPOCH,epoch:a,reason:`TWAP hasn't started yet. Starts at ${a} (${Le(a)})`};const r=this.endTimestamp(a);return n>=r?{result:me.DONT_TRY_AGAIN,reason:`TWAP has expired. Expired at ${r} (${Le(r)})`}:void 0}async handlePollFailedAlreadyPresent(e,t,n){const{blockInfo:a=await Ue(n.provider)}=n,{blockTimestamp:r}=a,s=this.data.timeBetweenParts.toNumber(),{numberOfParts:i}=this.data,o=await this.startTimestamp(n);if(r<o)return{result:me.UNEXPECTED_ERROR,reason:`TWAP part hash't started. First TWAP part start at ${o} (${Le(o)})`,error:void 0};const d=i.mul(s).add(o).toNumber();if(r>=d)return{result:me.UNEXPECTED_ERROR,reason:`TWAP is expired. Expired at ${d} (${Le(d)})`,error:void 0};const p=Math.floor((r-o)/s);if(p===i.toNumber()-1)return{result:me.DONT_TRY_AGAIN,reason:`Current active TWAP part (${p+1}/${i}) is already in the Order Book. This was the last TWAP part, no more orders need to be placed`};const c=o+(p+1)*s;return{result:me.TRY_AT_EPOCH,epoch:c,reason:`Current active TWAP part (${p+1}/${i}) is already in the Order Book. TWAP part ${p+2} doesn't start until ${c} (${Le(c)})`}}serialize(){return Re(this.leaf)}encodeStaticInput(){return super.encodeStaticInputHelper(nt,this.staticInput)}static deserialize(e){return super.deserializeHelper(e,Je,nt,(e,t)=>new ot({handler:Je,salt:t,data:pt(e)}))}toString(){const{sellAmount:e,sellToken:t,buyAmount:n,buyToken:a,numberOfParts:r,startTime:s=st,timeBetweenParts:i,durationOfPart:o=it,receiver:d,appData:p}=this.data,c=s.startType===rt.AT_MINING_TIME?"AT_MINING_TIME":s.epoch.toNumber(),u=o.durationType===at.AUTO?"AUTO":o.duration.toNumber(),y={sellAmount:e.toString(),sellToken:t,buyAmount:n.toString(),buyToken:a,numberOfParts:r.toString(),startTime:c,timeBetweenParts:i.toNumber(),durationOfPart:u,receiver:d,appData:p};return`${this.orderType}: ${JSON.stringify(y)}`}transformDataToStruct(e){return dt(e)}transformStructToData(e){return pt(e)}}function dt(e){const{sellAmount:t,buyAmount:n,numberOfParts:a,startTime:r=st,timeBetweenParts:s,durationOfPart:i=it}=e,d=I(e,qe),{partSellAmount:p,minPartLimit:c}=a&&!a.isZero()?{partSellAmount:t.div(a),minPartLimit:n.div(a)}:{partSellAmount:o.Zero,minPartLimit:o.Zero};return E({partSellAmount:p,minPartLimit:c,t0:r.startType===rt.AT_MINING_TIME?o.Zero:r.epoch,n:a,t:s,span:i.durationType===at.AUTO?o.Zero:i.duration},d)}function pt(e){const{n:t,partSellAmount:n,minPartLimit:a,t:r,t0:s,span:i}=e,o=I(e,ze),d=i.isZero()?{durationType:at.AUTO}:{durationType:at.LIMIT_DURATION,duration:i},p=i.isZero()?{startType:rt.AT_MINING_TIME}:{startType:rt.AT_EPOCH,epoch:s};return E({sellAmount:n.mul(t),buyAmount:a.mul(t),startTime:p,numberOfParts:t,timeBetweenParts:r,durationOfPart:d},o)}const ct={[Je]:e=>ot.fromParams(e)};export{Le as $,_ as A,O as B,m as C,f as D,V as E,H as F,pe as G,ce as H,ue as I,le as J,fe as K,me as L,_e as M,ge as N,M as O,z as P,ve as Q,J as R,y as S,De as T,we as U,Ce as V,Re as W,Pe as X,xe as Y,Ue as Z,E as _,g as a,ke as a0,We as a1,Ke as a2,Xe as a3,ct as a4,Je as a5,Qe as a6,et as a7,tt as a8,at as a9,rt as aa,ot as ab,dt as ac,pt as ad,l as b,b as c,h as d,S as e,N as f,v as g,D as h,F as i,G as j,B as k,T as l,$ as m,W as n,Y as o,j as p,Z as q,K as r,X as s,q as t,Q as u,ee as v,C as w,P as x,x as y,L as z};
|
|
29
|
+
//# sourceMappingURL=index-983a9908.js.map
|