@cowprotocol/cow-sdk 5.8.0 → 5.10.0-RC.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.
- package/README.md +44 -3
- package/dist/README.md +44 -3
- package/dist/common/consts.d.ts +11 -1
- package/dist/common/generated/EthFlow.d.ts +117 -0
- package/dist/common/generated/GPv2Settlement.d.ts +107 -0
- package/dist/common/generated/factories/EthFlow__factory.d.ts +124 -0
- package/dist/common/generated/factories/GPv2Settlement__factory.d.ts +81 -0
- package/dist/common/generated/factories/index.d.ts +2 -0
- package/dist/common/generated/index.d.ts +4 -0
- package/dist/index-f4e68213.js +29 -0
- package/dist/index-f4e68213.js.map +1 -0
- package/dist/index.d.ts +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/order-book/generated/index.d.ts +0 -1
- package/dist/order-book/generated/models/Auction.d.ts +1 -10
- package/dist/order-book/generated/models/AuctionPrices.d.ts +1 -4
- package/dist/order-book/generated/models/CompetitionOrderStatus.d.ts +4 -2
- package/dist/order-book/generated/models/ExecutedProtocolFee.d.ts +0 -6
- package/dist/order-book/generated/models/OnchainOrderData.d.ts +3 -9
- package/dist/order-book/generated/models/OrderCreation.d.ts +4 -12
- package/dist/order-book/generated/models/OrderMetaData.d.ts +20 -17
- package/dist/order-book/generated/models/OrderParameters.d.ts +1 -2
- package/dist/order-book/generated/models/OrderQuoteRequest.d.ts +11 -7
- package/dist/order-book/generated/models/OrderQuoteResponse.d.ts +1 -2
- package/dist/order-book/generated/models/OrderQuoteSide.d.ts +1 -2
- package/dist/order-book/generated/models/PriceQuality.d.ts +4 -3
- package/dist/order-book/generated/models/SolverSettlement.d.ts +6 -1
- package/dist/order-book/generated/models/UID.d.ts +4 -3
- package/dist/order-signing/orderSigningUtils.d.ts +18 -8
- package/dist/order-signing/utils.d.ts +11 -1
- package/dist/package.json +8 -5
- package/dist/schemas/trading/LimitOrderAdvancedSettings.ts +228 -0
- package/dist/schemas/trading/LimitTradeParameters.ts +105 -0
- package/dist/schemas/trading/QuoteResultsSerialized.ts +848 -0
- package/dist/schemas/trading/QuoterParameters.ts +31 -0
- package/dist/schemas/trading/SwapAdvancedSettings.ts +334 -0
- package/dist/schemas/trading/TradeParameters.ts +93 -0
- package/dist/trading/appDataUtils.d.ts +4 -0
- package/dist/trading/calculateUniqueOrderId.d.ts +6 -0
- package/dist/trading/consts.d.ts +8 -0
- package/dist/trading/getEthFlowTransaction.d.ts +7 -0
- package/dist/trading/getOrderToSign.d.ts +8 -0
- package/dist/trading/getOrderTypedData.d.ts +4 -0
- package/dist/trading/getPreSignTransaction.d.ts +4 -0
- package/dist/trading/getQuote.d.ts +14 -0
- package/dist/trading/index.d.ts +19 -0
- package/dist/trading/postCoWProtocolTrade.d.ts +4 -0
- package/dist/trading/postLimitOrder.d.ts +3 -0
- package/dist/trading/postSellNativeCurrencyOrder.d.ts +8 -0
- package/dist/trading/postSwapOrder.d.ts +4 -0
- package/dist/trading/tradingSdk.d.ts +16 -0
- package/dist/trading/types.d.ts +138 -0
- package/dist/trading/utils.d.ts +15 -0
- package/dist/utils-43555783.js +2 -0
- package/dist/utils-43555783.js.map +1 -0
- package/dist/utils-9d1e9d0e.js +2 -0
- package/dist/utils-9d1e9d0e.js.map +1 -0
- package/dist/utils-dc9c9d10.js +2 -0
- package/dist/utils-dc9c9d10.js.map +1 -0
- package/package.json +8 -5
- package/dist/index-c004f2c4.js +0 -29
- package/dist/index-c004f2c4.js.map +0 -1
- package/dist/order-book/generated/models/ProtocolAppData.d.ts +0 -1
- package/dist/utils-2718e59e.js +0 -2
- package/dist/utils-2718e59e.js.map +0 -1
- package/dist/utils-353bb58e.js +0 -2
- package/dist/utils-353bb58e.js.map +0 -1
- package/dist/utils-61509987.js +0 -2
- package/dist/utils-61509987.js.map +0 -1
|
@@ -40,7 +40,6 @@ export type { PreSignature } from './models/PreSignature';
|
|
|
40
40
|
export { PriceEstimationError } from './models/PriceEstimationError';
|
|
41
41
|
export type { PriceImprovement } from './models/PriceImprovement';
|
|
42
42
|
export { PriceQuality } from './models/PriceQuality';
|
|
43
|
-
export type { ProtocolAppData } from './models/ProtocolAppData';
|
|
44
43
|
export type { Quote } from './models/Quote';
|
|
45
44
|
export { SellTokenSource } from './models/SellTokenSource';
|
|
46
45
|
export type { Signature } from './models/Signature';
|
|
@@ -12,19 +12,10 @@ export type Auction = {
|
|
|
12
12
|
*/
|
|
13
13
|
id?: number;
|
|
14
14
|
/**
|
|
15
|
-
* The block number for the auction. Orders and prices are guaranteed to be valid on this
|
|
16
|
-
* block. Proposed settlements should be valid for this block as well.
|
|
15
|
+
* The block number for the auction. Orders and prices are guaranteed to be valid on this block. Proposed settlements should be valid for this block as well.
|
|
17
16
|
*
|
|
18
17
|
*/
|
|
19
18
|
block?: number;
|
|
20
|
-
/**
|
|
21
|
-
* The latest block on which a settlement has been processed.
|
|
22
|
-
*
|
|
23
|
-
* **NOTE**: Under certain conditions it is possible for a settlement to have been mined as
|
|
24
|
-
* part of `block` but not have yet been processed.
|
|
25
|
-
*
|
|
26
|
-
*/
|
|
27
|
-
latestSettlementBlock?: number;
|
|
28
19
|
/**
|
|
29
20
|
* The solvable orders included in the auction.
|
|
30
21
|
*
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { BigUint } from './BigUint';
|
|
2
2
|
/**
|
|
3
|
-
* The reference prices for all traded tokens in the auction as a mapping from token
|
|
4
|
-
* addresses to a price denominated in native token (i.e. 1e18 represents a token that
|
|
5
|
-
* trades one to one with the native token). These prices are used for solution competition
|
|
6
|
-
* for computing surplus and converting fees to native token.
|
|
3
|
+
* The reference prices for all traded tokens in the auction as a mapping from token addresses to a price denominated in native token (i.e. 1e18 represents a token that trades one to one with the native token). These prices are used for solution competition for computing surplus and converting fees to native token.
|
|
7
4
|
*
|
|
8
5
|
*/
|
|
9
6
|
export type AuctionPrices = Record<string, BigUint>;
|
|
@@ -2,9 +2,11 @@ import type { ExecutedAmounts } from './ExecutedAmounts';
|
|
|
2
2
|
export type CompetitionOrderStatus = {
|
|
3
3
|
type: CompetitionOrderStatus.type;
|
|
4
4
|
/**
|
|
5
|
-
* A list of solvers who participated in the latest competition, sorted
|
|
6
|
-
*
|
|
5
|
+
* A list of solvers who participated in the latest competition, sorted
|
|
6
|
+
* by score in ascending order, where the last element is the winner.
|
|
7
7
|
*
|
|
8
|
+
* The presence of executed amounts defines whether the solver provided
|
|
9
|
+
* a solution for the desired order.
|
|
8
10
|
*/
|
|
9
11
|
value?: Array<{
|
|
10
12
|
/**
|
|
@@ -3,12 +3,6 @@ import type { FeePolicy } from './FeePolicy';
|
|
|
3
3
|
import type { TokenAmount } from './TokenAmount';
|
|
4
4
|
export type ExecutedProtocolFee = {
|
|
5
5
|
policy?: FeePolicy;
|
|
6
|
-
/**
|
|
7
|
-
* Fee amount taken
|
|
8
|
-
*/
|
|
9
6
|
amount?: TokenAmount;
|
|
10
|
-
/**
|
|
11
|
-
* The token in which the fee is taken
|
|
12
|
-
*/
|
|
13
7
|
token?: Address;
|
|
14
8
|
};
|
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
import type { Address } from './Address';
|
|
2
2
|
export type OnchainOrderData = {
|
|
3
3
|
/**
|
|
4
|
-
* If orders are placed as on-chain orders, the owner of the order might
|
|
5
|
-
* be a smart contract, but not the user placing the order. The
|
|
6
|
-
* actual user will be provided in this field.
|
|
4
|
+
* If orders are placed as on-chain orders, the owner of the order might be a smart contract, but not the user placing the order. The actual user will be provided in this field.
|
|
7
5
|
*
|
|
8
6
|
*/
|
|
9
7
|
sender: Address;
|
|
10
8
|
/**
|
|
11
|
-
* Describes the error, if the order placement was not successful. This could
|
|
12
|
-
* happen, for example, if the `validTo` is too high, or no valid quote was
|
|
13
|
-
* found or generated.
|
|
9
|
+
* Describes the error, if the order placement was not successful. This could happen, for example, if the `validTo` is too high, or no valid quote was found or generated.
|
|
14
10
|
*
|
|
15
11
|
*/
|
|
16
12
|
placementError?: OnchainOrderData.placementError;
|
|
17
13
|
};
|
|
18
14
|
export declare namespace OnchainOrderData {
|
|
19
15
|
/**
|
|
20
|
-
* Describes the error, if the order placement was not successful. This could
|
|
21
|
-
* happen, for example, if the `validTo` is too high, or no valid quote was
|
|
22
|
-
* found or generated.
|
|
16
|
+
* Describes the error, if the order placement was not successful. This could happen, for example, if the `validTo` is too high, or no valid quote was found or generated.
|
|
23
17
|
*
|
|
24
18
|
*/
|
|
25
19
|
enum placementError {
|
|
@@ -58,30 +58,22 @@ export type OrderCreation = {
|
|
|
58
58
|
signingScheme: SigningScheme;
|
|
59
59
|
signature: Signature;
|
|
60
60
|
/**
|
|
61
|
-
* If set, the backend enforces that this address matches what is decoded as the *signer* of
|
|
62
|
-
* the signature. This helps catch errors with invalid signature encodings as the backend
|
|
63
|
-
* might otherwise silently work with an unexpected address that for example does not have
|
|
64
|
-
* any balance.
|
|
61
|
+
* If set, the backend enforces that this address matches what is decoded as the *signer* of the signature. This helps catch errors with invalid signature encodings as the backend might otherwise silently work with an unexpected address that for example does not have any balance.
|
|
65
62
|
*
|
|
66
63
|
*/
|
|
67
64
|
from?: Address | null;
|
|
68
65
|
/**
|
|
69
|
-
* Orders can optionally include a quote ID. This way the order can be linked to a quote
|
|
70
|
-
* and enable providing more metadata when analysing order slippage.
|
|
66
|
+
* Orders can optionally include a quote ID. This way the order can be linked to a quote and enable providing more metadata when analysing order slippage.
|
|
71
67
|
*
|
|
72
68
|
*/
|
|
73
69
|
quoteId?: number | null;
|
|
74
70
|
/**
|
|
75
|
-
* This field comes in two forms for backward compatibility. The hash form will eventually
|
|
76
|
-
* stop being accepted.
|
|
71
|
+
* This field comes in two forms for backward compatibility. The hash form will eventually stop being accepted.
|
|
77
72
|
*
|
|
78
73
|
*/
|
|
79
74
|
appData: (AppData | AppDataHash);
|
|
80
75
|
/**
|
|
81
|
-
* May be set for debugging purposes. If set, this field is compared to what the backend
|
|
82
|
-
* internally calculates as the app data hash based on the contents of `appData`. If the
|
|
83
|
-
* hash does not match, an error is returned. If this field is set, then `appData` **MUST** be
|
|
84
|
-
* a string encoding of a JSON object.
|
|
76
|
+
* May be set for debugging purposes. If set, this field is compared to what the backend internally calculates as the app data hash based on the contents of `appData`. If the hash does not match, an error is returned. If this field is set, then `appData` **MUST** be a string encoding of a JSON object.
|
|
85
77
|
*
|
|
86
78
|
*/
|
|
87
79
|
appDataHash?: AppDataHash | null;
|
|
@@ -7,8 +7,7 @@ import type { OrderStatus } from './OrderStatus';
|
|
|
7
7
|
import type { TokenAmount } from './TokenAmount';
|
|
8
8
|
import type { UID } from './UID';
|
|
9
9
|
/**
|
|
10
|
-
* Extra order data that is returned to users when querying orders but not provided by users
|
|
11
|
-
* when creating orders.
|
|
10
|
+
* Extra order data that is returned to users when querying orders but not provided by users when creating orders.
|
|
12
11
|
*
|
|
13
12
|
*/
|
|
14
13
|
export type OrderMetaData = {
|
|
@@ -57,40 +56,44 @@ export type OrderMetaData = {
|
|
|
57
56
|
*/
|
|
58
57
|
fullFeeAmount?: TokenAmount;
|
|
59
58
|
/**
|
|
60
|
-
* Liquidity orders are functionally the same as normal smart contract
|
|
61
|
-
* placed with the intent of actively getting
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* As such liquidity orders will only be used in order to improve settlement of normal
|
|
66
|
-
* orders. They should not be expected to be traded otherwise and should not expect to get
|
|
67
|
-
* surplus.
|
|
59
|
+
* Liquidity orders are functionally the same as normal smart contract
|
|
60
|
+
* orders but are not placed with the intent of actively getting
|
|
61
|
+
* traded. Instead they facilitate the trade of normal orders by
|
|
62
|
+
* allowing them to be matched against liquidity orders which uses less
|
|
63
|
+
* gas and can have better prices than external liquidity.
|
|
68
64
|
*
|
|
65
|
+
* As such liquidity orders will only be used in order to improve
|
|
66
|
+
* settlement of normal orders. They should not be expected to be
|
|
67
|
+
* traded otherwise and should not expect to get surplus.
|
|
69
68
|
*/
|
|
70
69
|
isLiquidityOrder?: boolean;
|
|
71
70
|
ethflowData?: EthflowData;
|
|
72
71
|
/**
|
|
73
72
|
* This represents the actual trader of an on-chain order.
|
|
74
|
-
*
|
|
75
73
|
* ### ethflow orders
|
|
76
|
-
*
|
|
77
74
|
* In this case, the `owner` would be the `EthFlow` contract and *not* the actual trader.
|
|
78
75
|
*
|
|
79
76
|
*/
|
|
80
77
|
onchainUser?: Address;
|
|
81
78
|
/**
|
|
82
|
-
* There is some data only available for orders that are placed on-chain. This data
|
|
83
|
-
* can be found in this object.
|
|
79
|
+
* There is some data only available for orders that are placed on-chain. This data can be found in this object.
|
|
84
80
|
*
|
|
85
81
|
*/
|
|
86
82
|
onchainOrderData?: OnchainOrderData;
|
|
87
83
|
/**
|
|
88
84
|
* Surplus fee that the limit order was executed with.
|
|
89
85
|
*/
|
|
90
|
-
executedSurplusFee?: BigUint
|
|
86
|
+
executedSurplusFee?: BigUint;
|
|
87
|
+
/**
|
|
88
|
+
* Total fee charged for execution of the order. Contains network fee and protocol fees.
|
|
89
|
+
*/
|
|
90
|
+
executedFee?: BigUint;
|
|
91
|
+
/**
|
|
92
|
+
* Token the executed fee was captured in.
|
|
93
|
+
*/
|
|
94
|
+
executedFeeToken?: Address;
|
|
91
95
|
/**
|
|
92
|
-
* Full `appData`, which the contract-level `appData` is a hash of. See `OrderCreation`
|
|
93
|
-
* for more information.
|
|
96
|
+
* Full `appData`, which the contract-level `appData` is a hash of. See `OrderCreation` for more information.
|
|
94
97
|
*
|
|
95
98
|
*/
|
|
96
99
|
fullAppData?: string | null;
|
|
@@ -18,8 +18,7 @@ export type OrderParameters = {
|
|
|
18
18
|
*/
|
|
19
19
|
buyToken: Address;
|
|
20
20
|
/**
|
|
21
|
-
* An optional Ethereum address to receive the proceeds of the trade instead
|
|
22
|
-
* of the owner (i.e. the order signer).
|
|
21
|
+
* An optional Ethereum address to receive the proceeds of the trade instead of the owner (i.e. the order signer).
|
|
23
22
|
*
|
|
24
23
|
*/
|
|
25
24
|
receiver?: Address | null;
|
|
@@ -27,17 +27,22 @@ export type OrderQuoteRequest = (OrderQuoteSide & OrderQuoteValidity & {
|
|
|
27
27
|
receiver?: Address | null;
|
|
28
28
|
/**
|
|
29
29
|
* AppData which will be assigned to the order.
|
|
30
|
-
* Expects either a string JSON doc as defined on [AppData](https://github.com/cowprotocol/app-data) or a
|
|
31
|
-
* hex encoded string for backwards compatibility.
|
|
32
|
-
* When the first format is used, it's possible to provide the derived appDataHash field.
|
|
33
30
|
*
|
|
31
|
+
* Expects either a string JSON doc as defined on
|
|
32
|
+
* [AppData](https://github.com/cowprotocol/app-data) or a hex
|
|
33
|
+
* encoded string for backwards compatibility.
|
|
34
|
+
*
|
|
35
|
+
* When the first format is used, it's possible to provide the
|
|
36
|
+
* derived appDataHash field.
|
|
34
37
|
*/
|
|
35
38
|
appData?: (AppData | AppDataHash);
|
|
36
39
|
/**
|
|
37
40
|
* The hash of the stringified JSON appData doc.
|
|
38
|
-
* If present, `appData` field must be set with the aforementioned data where this hash is derived from.
|
|
39
|
-
* In case they differ, the call will fail.
|
|
40
41
|
*
|
|
42
|
+
* If present, `appData` field must be set with the aforementioned
|
|
43
|
+
* data where this hash is derived from.
|
|
44
|
+
*
|
|
45
|
+
* In case they differ, the call will fail.
|
|
41
46
|
*/
|
|
42
47
|
appDataHash?: AppDataHash;
|
|
43
48
|
sellTokenBalance?: SellTokenSource;
|
|
@@ -46,8 +51,7 @@ export type OrderQuoteRequest = (OrderQuoteSide & OrderQuoteValidity & {
|
|
|
46
51
|
priceQuality?: PriceQuality;
|
|
47
52
|
signingScheme?: SigningScheme;
|
|
48
53
|
/**
|
|
49
|
-
* Flag to signal whether the order is intended for on-chain order placement. Only valid
|
|
50
|
-
* for non ECDSA-signed orders."
|
|
54
|
+
* Flag to signal whether the order is intended for on-chain order placement. Only valid for non ECDSA-signed orders."
|
|
51
55
|
*
|
|
52
56
|
*/
|
|
53
57
|
onchainOrder?: any;
|
|
@@ -15,8 +15,7 @@ export type OrderQuoteResponse = {
|
|
|
15
15
|
*/
|
|
16
16
|
expiration: string;
|
|
17
17
|
/**
|
|
18
|
-
* Quote ID linked to a quote to enable providing more metadata when analysing
|
|
19
|
-
* order slippage.
|
|
18
|
+
* Quote ID linked to a quote to enable providing more metadata when analysing order slippage.
|
|
20
19
|
*
|
|
21
20
|
*/
|
|
22
21
|
id?: number;
|
|
@@ -7,8 +7,7 @@ import type { TokenAmount } from './TokenAmount';
|
|
|
7
7
|
export type OrderQuoteSide = ({
|
|
8
8
|
kind: OrderQuoteSideKindSell;
|
|
9
9
|
/**
|
|
10
|
-
* The total amount that is available for the order. From this value, the fee
|
|
11
|
-
* is deducted and the buy amount is calculated.
|
|
10
|
+
* The total amount that is available for the order. From this value, the fee is deducted and the buy amount is calculated.
|
|
12
11
|
*
|
|
13
12
|
*/
|
|
14
13
|
sellAmountBeforeFee: TokenAmount;
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Fast: The price estimate is chosen among the fastest N price estimates.
|
|
5
5
|
* Optimal: The price estimate is chosen among all price estimates.
|
|
6
|
-
* Verified: The price estimate is chosen among all verified/simulated
|
|
7
|
-
*
|
|
8
|
-
* **NOTE**: Orders are supposed to be created from `verified` or `optimal` price estimates.
|
|
6
|
+
* Verified: The price estimate is chosen among all verified/simulated
|
|
7
|
+
* price estimates.
|
|
9
8
|
*
|
|
9
|
+
* **NOTE**: Orders are supposed to be created from `verified` or `optimal`
|
|
10
|
+
* price estimates.
|
|
10
11
|
*/
|
|
11
12
|
export declare enum PriceQuality {
|
|
12
13
|
FAST = "fast",
|
|
@@ -7,8 +7,9 @@ export type SolverSettlement = {
|
|
|
7
7
|
solver?: string;
|
|
8
8
|
/**
|
|
9
9
|
* The address used by the solver to execute the settlement on-chain.
|
|
10
|
-
* This field is missing for old settlements, the zero address has been used instead.
|
|
11
10
|
*
|
|
11
|
+
* This field is missing for old settlements, the zero address has been
|
|
12
|
+
* used instead.
|
|
12
13
|
*/
|
|
13
14
|
solverAddress?: string;
|
|
14
15
|
objective?: {
|
|
@@ -39,4 +40,8 @@ export type SolverSettlement = {
|
|
|
39
40
|
id?: UID;
|
|
40
41
|
executedAmount?: BigUint;
|
|
41
42
|
}>;
|
|
43
|
+
/**
|
|
44
|
+
* whether the solution is a winner (received the right to get executed) or not
|
|
45
|
+
*/
|
|
46
|
+
isWinner?: boolean;
|
|
42
47
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Unique identifier for the order: 56 bytes encoded as hex with `0x`
|
|
3
|
-
*
|
|
4
|
-
* 52..56 the expiry (`validTo`) as a `uint32` unix epoch timestamp.
|
|
2
|
+
* Unique identifier for the order: 56 bytes encoded as hex with `0x`
|
|
3
|
+
* prefix.
|
|
5
4
|
*
|
|
5
|
+
* Bytes 0..32 are the order digest, bytes 30..52 the owner address and
|
|
6
|
+
* bytes 52..56 the expiry (`validTo`) as a `uint32` unix epoch timestamp.
|
|
6
7
|
*/
|
|
7
8
|
export type UID = string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SupportedChainId } from '../common';
|
|
2
2
|
import type { Signer } from '@ethersproject/abstract-signer';
|
|
3
|
-
import type { TypedDataDomain } from '@cowprotocol/contracts';
|
|
3
|
+
import type { Order, TypedDataDomain, OrderUidParams } from '@cowprotocol/contracts';
|
|
4
4
|
import type { SigningResult, UnsignedOrder } from './types';
|
|
5
5
|
/**
|
|
6
6
|
* Utility class for signing order intents and cancellations.
|
|
@@ -10,7 +10,7 @@ import type { SigningResult, UnsignedOrder } from './types';
|
|
|
10
10
|
* @example
|
|
11
11
|
*
|
|
12
12
|
* ```typescript
|
|
13
|
-
* import { OrderSigningUtils, SupportedChainId } from '@cowprotocol/cow-sdk'
|
|
13
|
+
* import { OrderSigningUtils, SupportedChainId, UnsignedOrder } from '@cowprotocol/cow-sdk'
|
|
14
14
|
* import { Web3Provider } from '@ethersproject/providers'
|
|
15
15
|
*
|
|
16
16
|
* const account = 'YOUR_WALLET_ADDRESS'
|
|
@@ -19,10 +19,10 @@ import type { SigningResult, UnsignedOrder } from './types';
|
|
|
19
19
|
* const signer = provider.getSigner()
|
|
20
20
|
*
|
|
21
21
|
* async function main() {
|
|
22
|
-
* const
|
|
23
|
-
* const orderSigningResult = await OrderSigningUtils.signOrder(
|
|
22
|
+
* const orderToSign: UnsignedOrder = { ... }
|
|
23
|
+
* const orderSigningResult = await OrderSigningUtils.signOrder(orderToSign, chainId, signer)
|
|
24
24
|
*
|
|
25
|
-
* const orderId = await orderBookApi.sendOrder({ ...
|
|
25
|
+
* const orderId = await orderBookApi.sendOrder({ ...orderToSign, ...orderSigningResult })
|
|
26
26
|
*
|
|
27
27
|
* const order = await orderBookApi.getOrder(orderId)
|
|
28
28
|
*
|
|
@@ -60,18 +60,28 @@ export declare class OrderSigningUtils {
|
|
|
60
60
|
/**
|
|
61
61
|
* Sign a cancellation message of multiple order intents with the specified signer.
|
|
62
62
|
* @param {string[]} orderUids An array of `orderUid` to cancel.
|
|
63
|
-
* @param {SupportedChainId} chainId The CoW Protocol
|
|
63
|
+
* @param {SupportedChainId} chainId The CoW Protocol `chainId` context that's being used.
|
|
64
64
|
* @param {Signer} signer The signer who initially placed the order intents.
|
|
65
65
|
* @returns {Promise<SigningResult>} Encoded signature including signing scheme for the cancellation.
|
|
66
66
|
*/
|
|
67
67
|
static signOrderCancellations(orderUids: string[], chainId: SupportedChainId, signer: Signer): Promise<SigningResult>;
|
|
68
68
|
/**
|
|
69
69
|
* Get the EIP-712 typed domain data being used for signing.
|
|
70
|
-
* @param {SupportedChainId} chainId The CoW Protocol
|
|
70
|
+
* @param {SupportedChainId} chainId The CoW Protocol `chainId` context that's being used.
|
|
71
71
|
* @return The EIP-712 typed domain data.
|
|
72
72
|
* @see https://eips.ethereum.org/EIPS/eip-712
|
|
73
73
|
*/
|
|
74
74
|
static getDomain(chainId: SupportedChainId): Promise<TypedDataDomain>;
|
|
75
|
+
/**
|
|
76
|
+
* Hashes the order intent and generate deterministic order ID.
|
|
77
|
+
* @param {SupportedChainId} chainId The CoW Protocol `chainId` context that's being used.
|
|
78
|
+
* @param {Order} order order to sign
|
|
79
|
+
* @param {Pick<OrderUidParams, 'owner'>} params order unique identifier parameters.
|
|
80
|
+
*/
|
|
81
|
+
static generateOrderId(chainId: SupportedChainId, order: Order, params: Pick<OrderUidParams, 'owner'>): Promise<{
|
|
82
|
+
orderId: string;
|
|
83
|
+
orderDigest: string;
|
|
84
|
+
}>;
|
|
75
85
|
/**
|
|
76
86
|
* Get the domain separator hash for the EIP-712 typed domain data being used for signing.
|
|
77
87
|
* @param chainId {SupportedChainId} chainId The CoW Protocol protocol `chainId` context that's being used.
|
|
@@ -83,5 +93,5 @@ export declare class OrderSigningUtils {
|
|
|
83
93
|
* signing orders using smart contracts, whereby this SDK cannot do the EIP-1271 signing for you.
|
|
84
94
|
* @returns The EIP-712 types used for signing.
|
|
85
95
|
*/
|
|
86
|
-
static getEIP712Types(): Record<string,
|
|
96
|
+
static getEIP712Types(): Record<string, unknown>;
|
|
87
97
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TypedDataDomain } from '@cowprotocol/contracts';
|
|
1
|
+
import type { TypedDataDomain, Order, OrderUidParams } from '@cowprotocol/contracts';
|
|
2
2
|
import type { Signer } from '@ethersproject/abstract-signer';
|
|
3
3
|
import type { SigningResult, UnsignedOrder } from './types';
|
|
4
4
|
import { SupportedChainId } from '../common';
|
|
@@ -37,3 +37,13 @@ export declare function signOrderCancellations(orderUids: string[], chainId: Sup
|
|
|
37
37
|
* @throws {CowError} If the chainId is not supported.
|
|
38
38
|
*/
|
|
39
39
|
export declare function getDomain(chainId: SupportedChainId): TypedDataDomain;
|
|
40
|
+
/**
|
|
41
|
+
* Generate a deterministic order ID for the specified order.
|
|
42
|
+
* @param {SupportedChainId} chainId The chain Id
|
|
43
|
+
* @param {Order} order order to sign
|
|
44
|
+
* @param {Pick<OrderUidParams, 'owner'>} params order unique identifier parameters.
|
|
45
|
+
*/
|
|
46
|
+
export declare function generateOrderId(chainId: SupportedChainId, order: Order, params: Pick<OrderUidParams, 'owner'>): Promise<{
|
|
47
|
+
orderId: string;
|
|
48
|
+
orderDigest: string;
|
|
49
|
+
}>;
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cowprotocol/cow-sdk",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.10.0-RC.0",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"files": [
|
|
6
6
|
"/dist"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"prebuild": "rm -rf dist && yarn run codegen",
|
|
18
18
|
"build": "microbundle -f modern,esm,cjs",
|
|
19
19
|
"start": "microbundle -f modern,esm,cjs watch",
|
|
20
|
-
"postbuild": "cp package.json dist && cp README.md dist",
|
|
20
|
+
"postbuild": "cp package.json dist && cp README.md dist && yarn run trading:generateSchemas",
|
|
21
21
|
"lint": "eslint src",
|
|
22
22
|
"format": "prettier --write \"src/**/*.+(ts|json)\"",
|
|
23
23
|
"test": "jest",
|
|
@@ -27,10 +27,12 @@
|
|
|
27
27
|
"prepare": "npm run build",
|
|
28
28
|
"prepublishOnly": "npm test && npm run lint",
|
|
29
29
|
"graphql:codegen": "graphql-codegen --config graphql-codegen.yml",
|
|
30
|
-
"swagger:codegen": " openapi --input https://raw.githubusercontent.com/cowprotocol/services/v2.
|
|
31
|
-
"typechain:codegen": "typechain --target ethers-v5 --out-dir ./src/common/generated './abi/*.json'"
|
|
30
|
+
"swagger:codegen": " openapi --input https://raw.githubusercontent.com/cowprotocol/services/v2.291.0/crates/orderbook/openapi.yml --output src/order-book/generated --exportServices false --exportCore false",
|
|
31
|
+
"typechain:codegen": "typechain --target ethers-v5 --out-dir ./src/common/generated './abi/*.json'",
|
|
32
|
+
"trading:generateSchemas": "ts-node scripts/generateTradingSchemas.ts"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
35
|
+
"@cowprotocol/app-data": "^2.4.0",
|
|
34
36
|
"@cowprotocol/contracts": "^1.6.0",
|
|
35
37
|
"@ethersproject/abstract-signer": "^5.7.0",
|
|
36
38
|
"@openzeppelin/merkle-tree": "^1.0.5",
|
|
@@ -53,7 +55,7 @@
|
|
|
53
55
|
"@graphql-codegen/typescript-operations": "^3.0.0",
|
|
54
56
|
"@typechain/ethers-v5": "^11.0.0",
|
|
55
57
|
"@types/jest": "^29.4.0",
|
|
56
|
-
"@types/node": "^
|
|
58
|
+
"@types/node": "^22.9.0",
|
|
57
59
|
"@typescript-eslint/eslint-plugin": "^5.51.0",
|
|
58
60
|
"@typescript-eslint/parser": "^5.51.0",
|
|
59
61
|
"babel-plugin-inline-import": "^3.0.0",
|
|
@@ -68,6 +70,7 @@
|
|
|
68
70
|
"microbundle": "^0.15.1",
|
|
69
71
|
"openapi-typescript-codegen": "^0.23.0",
|
|
70
72
|
"prettier": "^2.5.1",
|
|
73
|
+
"ts-json-schema-generator": "^2.3.0",
|
|
71
74
|
"ts-mockito": "^2.6.1",
|
|
72
75
|
"tsc-watch": "^6.0.0",
|
|
73
76
|
"typechain": "^8.2.0",
|