@cowprotocol/cow-sdk 5.10.1-RC.0 → 5.10.2-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/dist/bridging/BridgingSdk.d.ts +42 -0
- package/dist/bridging/const.d.ts +1 -0
- package/dist/bridging/index.d.ts +3 -0
- package/dist/bridging/providers/MockBridgeProvider.d.ts +20 -0
- package/dist/bridging/types.d.ts +147 -0
- package/dist/chains/const.d.ts +14 -0
- package/dist/chains/details/arbitrum.d.ts +7 -0
- package/dist/chains/details/base.d.ts +7 -0
- package/dist/chains/details/gnosis.d.ts +7 -0
- package/dist/chains/details/mainnet.d.ts +7 -0
- package/dist/chains/details/optimism.d.ts +2 -0
- package/dist/chains/details/polygon.d.ts +2 -0
- package/dist/chains/details/sepolia.d.ts +7 -0
- package/dist/chains/index.d.ts +2 -0
- package/dist/chains/types.d.ts +106 -0
- package/dist/common/consts/config.d.ts +9 -0
- package/dist/common/{consts.d.ts → consts/contracts.d.ts} +7 -12
- package/dist/common/consts/path.d.ts +1 -0
- package/dist/common/consts/tokens.d.ts +9 -0
- package/dist/common/index.d.ts +10 -5
- package/dist/common/{configs.d.ts → types/config.d.ts} +1 -9
- package/dist/common/{cow-error.d.ts → types/cow-error.d.ts} +0 -1
- package/dist/common/types/ethereum.d.ts +5 -0
- package/dist/common/types/tokens.d.ts +12 -0
- package/dist/common/types/wallets.d.ts +5 -0
- package/dist/common/utils/config.d.ts +4 -0
- package/dist/common/utils/serialize.d.ts +1 -0
- package/dist/common/utils/wallet.d.ts +3 -0
- package/dist/composable/Multiplexer.d.ts +1 -1
- package/dist/composable/contracts.d.ts +1 -1
- package/dist/composable/types.d.ts +1 -1
- package/dist/composable/utils.d.ts +1 -1
- package/dist/cow-shed/CowShedSdk.d.ts +69 -0
- package/dist/cow-shed/{proxyInitCode.d.ts → contracts/CoWShedHooks.d.ts} +45 -0
- package/dist/cow-shed/contracts/utils.d.ts +4 -0
- package/dist/cow-shed/index.d.ts +1 -3
- package/dist/cow-shed/types.d.ts +0 -16
- package/dist/index-0ebfdcaf.js +29 -0
- package/dist/index-0ebfdcaf.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -19983
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +1 -13
- package/dist/index.modern.mjs.map +1 -1
- package/dist/index.module.js +4 -19880
- package/dist/index.module.js.map +1 -1
- package/dist/order-book/api.d.ts +1 -1
- package/dist/order-signing/orderSigningUtils.d.ts +1 -1
- package/dist/order-signing/types.d.ts +1 -1
- package/dist/order-signing/utils.d.ts +1 -1
- package/dist/package.json +4 -3
- package/dist/schemas/trading/LimitOrderAdvancedSettings.ts +26 -0
- package/dist/schemas/trading/LimitTradeParameters.ts +3 -0
- package/dist/schemas/trading/QuoteResultsSerialized.ts +3 -0
- package/dist/schemas/trading/SwapAdvancedSettings.ts +26 -0
- package/dist/schemas/trading/TradeParameters.ts +3 -0
- package/dist/src/bridging/README.md +44 -0
- package/dist/src/cow-shed/README.md +60 -0
- package/dist/src/trading/README.md +1 -0
- package/dist/src/weiroll/README.md +55 -0
- package/dist/subgraph/api.d.ts +2 -2
- package/dist/trading/calculateUniqueOrderId.d.ts +3 -4
- package/dist/trading/consts.d.ts +2 -0
- package/dist/trading/getEthFlowTransaction.d.ts +3 -4
- package/dist/trading/getOrderTypedData.d.ts +1 -1
- package/dist/trading/getPreSignTransaction.d.ts +1 -1
- package/dist/trading/postCoWProtocolTrade.d.ts +3 -3
- package/dist/trading/postSellNativeCurrencyOrder.d.ts +2 -3
- package/dist/trading/tradingSdk.d.ts +9 -7
- package/dist/trading/types.d.ts +36 -8
- package/dist/trading/utils.d.ts +8 -4
- package/dist/utils-69f2c801.js +2 -0
- package/dist/utils-69f2c801.js.map +1 -0
- package/dist/utils-8d77110e.js +2 -0
- package/dist/utils-8d77110e.js.map +1 -0
- package/dist/utils-c854e052.js +2 -0
- package/dist/utils-c854e052.js.map +1 -0
- package/dist/utils.d.ts +1 -1
- package/dist/weiroll/index.d.ts +20 -0
- package/package.json +4 -3
- package/dist/common/chains.d.ts +0 -11
- package/dist/cow-shed/CoWShedHooks.d.ts +0 -35
- package/dist/cow-shed/contracts.d.ts +0 -4
- package/dist/index-dc9d02b1.js +0 -19899
- package/dist/index-dc9d02b1.js.map +0 -1
- package/dist/utils-1a1e53c4.js +0 -224
- package/dist/utils-1a1e53c4.js.map +0 -1
- package/dist/utils-a7f9e3d4.js +0 -223
- package/dist/utils-a7f9e3d4.js.map +0 -1
- package/dist/utils-c5ceb9d8.js +0 -228
- package/dist/utils-c5ceb9d8.js.map +0 -1
- /package/dist/common/{ipfs.d.ts → consts/ipfs.d.ts} +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { QuoteAndPost, TraderParameters } from '../trading';
|
|
2
|
+
import { BridgeProvider, BridgeQuoteResult, GetBuyTokensParams, QuoteBridgeRequest } from './types';
|
|
3
|
+
import { TokenInfo } from '../common';
|
|
4
|
+
import { ChainInfo } from '../chains';
|
|
5
|
+
export interface BridgingSdkOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Providers for the bridging.
|
|
8
|
+
*/
|
|
9
|
+
providers: BridgeProvider<BridgeQuoteResult>[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* SDK for bridging for swapping tokens between different chains.
|
|
13
|
+
*/
|
|
14
|
+
export declare class BridgingSdk {
|
|
15
|
+
readonly traderParams: TraderParameters;
|
|
16
|
+
readonly options: BridgingSdkOptions;
|
|
17
|
+
constructor(traderParams: TraderParameters, options: BridgingSdkOptions);
|
|
18
|
+
private get provider();
|
|
19
|
+
/**
|
|
20
|
+
* Get the providers for the bridging.
|
|
21
|
+
*/
|
|
22
|
+
getProviders(): BridgeProvider<BridgeQuoteResult>[];
|
|
23
|
+
/**
|
|
24
|
+
* Get the available sources networks for the bridging.
|
|
25
|
+
*/
|
|
26
|
+
getSourceNetworks(): Promise<ChainInfo[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Get the available target networks for the bridging.
|
|
29
|
+
*/
|
|
30
|
+
getTargetNetworks(): Promise<ChainInfo[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Get the available buy tokens for buying in a specific target chain
|
|
33
|
+
*
|
|
34
|
+
* @param param
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
getBuyTokens(param: GetBuyTokensParams): Promise<TokenInfo[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Get quote for bridging tokens between chains.
|
|
40
|
+
*/
|
|
41
|
+
getQuote(_params: QuoteBridgeRequest): Promise<QuoteAndPost>;
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RAW_PROVIDERS_FILES_PATH: string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Signer } from 'ethers';
|
|
2
|
+
import { BridgeDeposit, BridgeHook, BridgeProvider, BridgeProviderInfo, BridgeQuoteResult, BridgeStatusResult, GetBuyTokensParams, QuoteBridgeRequest } from '../types';
|
|
3
|
+
import { ChainInfo } from '../../chains';
|
|
4
|
+
import { EvmCall } from '../../common/types/ethereum';
|
|
5
|
+
import { TokenInfo } from '../../common/types/tokens';
|
|
6
|
+
export declare class MockBridgeProvider implements BridgeProvider<BridgeQuoteResult> {
|
|
7
|
+
info: BridgeProviderInfo;
|
|
8
|
+
getNetworks(): Promise<ChainInfo[]>;
|
|
9
|
+
getBuyTokens(param: GetBuyTokensParams): Promise<TokenInfo[]>;
|
|
10
|
+
getIntermediateTokens(_request: QuoteBridgeRequest): Promise<string[]>;
|
|
11
|
+
getQuote(_request: QuoteBridgeRequest): Promise<BridgeQuoteResult>;
|
|
12
|
+
getUnsignedBridgeTx(_request: QuoteBridgeRequest, _quote: BridgeQuoteResult): Promise<EvmCall>;
|
|
13
|
+
getSignedHook(_unsignedTx: EvmCall, _signer: Signer): Promise<BridgeHook>;
|
|
14
|
+
decodeBridgeHook(_hook: BridgeHook): Promise<BridgeDeposit>;
|
|
15
|
+
getBridgingId(_orderUid: string, _settlementTx: string): Promise<string>;
|
|
16
|
+
getExplorerUrl(bridgingId: string): string;
|
|
17
|
+
getStatus(_bridgingId: string): Promise<BridgeStatusResult>;
|
|
18
|
+
getCancelBridgingTx(_bridgingId: string): Promise<EvmCall>;
|
|
19
|
+
getRefundBridgingTx(_bridgingId: string): Promise<EvmCall>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { latest as latestAppData } from '@cowprotocol/app-data';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
import { ChainInfo, ChainId } from '../chains';
|
|
4
|
+
import { TokenInfo } from '../common/types/tokens';
|
|
5
|
+
import { Address, OrderKind } from '../order-book';
|
|
6
|
+
import { EvmCall } from '../common/types/ethereum';
|
|
7
|
+
export interface BridgeProviderInfo {
|
|
8
|
+
name: string;
|
|
9
|
+
logoUrl: string;
|
|
10
|
+
}
|
|
11
|
+
export interface WithSellToken {
|
|
12
|
+
sellTokenChainId: ChainId;
|
|
13
|
+
sellTokenAddress: Address;
|
|
14
|
+
sellTokenDecimals: number;
|
|
15
|
+
}
|
|
16
|
+
export interface WithBuyToken {
|
|
17
|
+
buyTokenChainId: ChainId;
|
|
18
|
+
buyTokenAddress: Address;
|
|
19
|
+
buyTokenDecimals: number;
|
|
20
|
+
}
|
|
21
|
+
export interface GetBuyTokensParams extends Partial<WithSellToken> {
|
|
22
|
+
targetChainId: ChainId;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Parameters for getting a bridge quote
|
|
26
|
+
*/
|
|
27
|
+
export interface QuoteBridgeRequest extends WithSellToken, WithBuyToken {
|
|
28
|
+
type: OrderKind.SELL;
|
|
29
|
+
amount: string;
|
|
30
|
+
owner: string;
|
|
31
|
+
recipient?: string;
|
|
32
|
+
feeBps?: number;
|
|
33
|
+
feeRecipient?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface BridgeQuoteResult {
|
|
36
|
+
feeBps: number;
|
|
37
|
+
slippageBps: number;
|
|
38
|
+
buyAmount: string;
|
|
39
|
+
fillTimeInSeconds?: number;
|
|
40
|
+
}
|
|
41
|
+
export interface BridgeHook {
|
|
42
|
+
postHook: latestAppData.CoWHook;
|
|
43
|
+
recipient: string;
|
|
44
|
+
}
|
|
45
|
+
export declare enum BridgeStatus {
|
|
46
|
+
NOT_INITIATED = "not_initiated",
|
|
47
|
+
IN_PROGRESS = "in_progress",
|
|
48
|
+
EXECUTED = "executed",
|
|
49
|
+
FAILED = "failed",
|
|
50
|
+
EXPIRED = "expired"
|
|
51
|
+
}
|
|
52
|
+
export interface BridgeStatusResult {
|
|
53
|
+
status: BridgeStatus;
|
|
54
|
+
fillTimeInSeconds?: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A bridge deposit. It includes the sell amount and the minimum buy amount.
|
|
58
|
+
*
|
|
59
|
+
* It models the minimum information needed to initiate a bridge and that it can also be extracted from the cow hook.
|
|
60
|
+
*
|
|
61
|
+
*/
|
|
62
|
+
export interface BridgeDeposit extends Omit<QuoteBridgeRequest, 'amount'> {
|
|
63
|
+
provider: BridgeProviderInfo;
|
|
64
|
+
sellTokenAmount: string;
|
|
65
|
+
minBuyAmount: string;
|
|
66
|
+
}
|
|
67
|
+
export interface BridgeProvider<Q extends BridgeQuoteResult> {
|
|
68
|
+
info: BridgeProviderInfo;
|
|
69
|
+
/**
|
|
70
|
+
* Get basic supported chains
|
|
71
|
+
*/
|
|
72
|
+
getNetworks(): Promise<ChainInfo[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Get supported tokens for a chain
|
|
75
|
+
*/
|
|
76
|
+
getBuyTokens(chainId: GetBuyTokensParams): Promise<TokenInfo[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Get intermediate tokens given a quote request.
|
|
79
|
+
*
|
|
80
|
+
* An intermediate token, is a token in the source chain, that could be used to bridge the tokens to the destination chain.
|
|
81
|
+
* This method returns a sorted list of tokens, they are sorted by priority, so first tokens are more likely to be more liquid.
|
|
82
|
+
*
|
|
83
|
+
* @param request - The quote request
|
|
84
|
+
*/
|
|
85
|
+
getIntermediateTokens(request: QuoteBridgeRequest): Promise<string[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Get a quote for a bridge request.
|
|
88
|
+
*
|
|
89
|
+
* @param request - The quote request
|
|
90
|
+
*/
|
|
91
|
+
getQuote(request: QuoteBridgeRequest): Promise<Q>;
|
|
92
|
+
/**
|
|
93
|
+
* Get an unsigned bridge transaction for a quote.
|
|
94
|
+
*
|
|
95
|
+
* The transaction details should be executed in the context of cow-shed account.
|
|
96
|
+
*
|
|
97
|
+
* @param request - The quote request
|
|
98
|
+
* @param quote - The quote
|
|
99
|
+
* @returns The unsigned transaction details that cow-shed needs to sign
|
|
100
|
+
*/
|
|
101
|
+
getUnsignedBridgeTx(request: QuoteBridgeRequest, quote: Q): Promise<EvmCall>;
|
|
102
|
+
/**
|
|
103
|
+
* Get a pre-authorized hook for initiating a bridge.
|
|
104
|
+
*
|
|
105
|
+
* The hook contains the ethereum call that the trampoline contract will need to execute during the settlement to initate the bridge.
|
|
106
|
+
*
|
|
107
|
+
* Typically, this hook will:
|
|
108
|
+
* - Get the balance of cow-shed account
|
|
109
|
+
* - Ensure the approval for the bridge lock contract is set
|
|
110
|
+
* - Deposit into the bridge contract
|
|
111
|
+
*
|
|
112
|
+
* This hook will include the pre-authorization (signature) of the owner of the cow-shed account (the trader).
|
|
113
|
+
*
|
|
114
|
+
* @param unsignedTx
|
|
115
|
+
* @param signer
|
|
116
|
+
*/
|
|
117
|
+
getSignedHook(unsignedTx: EvmCall, signer: ethers.Signer): Promise<BridgeHook>;
|
|
118
|
+
/**
|
|
119
|
+
* Decode a bridge hook into a bridge deposit information.
|
|
120
|
+
*
|
|
121
|
+
* This method is used to recover the information about the limit order placed into the bridge locking contract.
|
|
122
|
+
* This allows to load an order from the orderbook and decode the bridging hook and understand what was the minimum buy amount the user signed to receive in the destination chain.
|
|
123
|
+
*
|
|
124
|
+
* @param hook - The bridge hook
|
|
125
|
+
*/
|
|
126
|
+
decodeBridgeHook(hook: BridgeHook): Promise<BridgeDeposit>;
|
|
127
|
+
/**
|
|
128
|
+
* Get the identifier of the bridging transaction from the settlement transaction.
|
|
129
|
+
* @param orderUid - The unique identifier of the order
|
|
130
|
+
* @param settlementTx - The settlement transaction in which the bridging post-hook was executed
|
|
131
|
+
*/
|
|
132
|
+
getBridgingId(orderUid: string, settlementTx: string): Promise<string>;
|
|
133
|
+
/**
|
|
134
|
+
* Get the explorer url for a bridging id.
|
|
135
|
+
*
|
|
136
|
+
* @param bridgingId - The bridging id
|
|
137
|
+
*/
|
|
138
|
+
getExplorerUrl(bridgingId: string): string;
|
|
139
|
+
/**
|
|
140
|
+
* Get the status of a bridging transaction.
|
|
141
|
+
*
|
|
142
|
+
* @param bridgingId - The bridging id
|
|
143
|
+
*/
|
|
144
|
+
getStatus(bridgingId: string): Promise<BridgeStatusResult>;
|
|
145
|
+
getCancelBridgingTx(bridgingId: string): Promise<EvmCall>;
|
|
146
|
+
getRefundBridgingTx(bridgingId: string): Promise<EvmCall>;
|
|
147
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChainInfo, SupportedChainId } from './types';
|
|
2
|
+
export declare const RAW_CHAINS_FILES_PATH: string;
|
|
3
|
+
/**
|
|
4
|
+
* Details of all supported chains.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ALL_SUPPORTED_CHAINS_MAP: Record<SupportedChainId, ChainInfo>;
|
|
7
|
+
/**
|
|
8
|
+
* All supported chains.
|
|
9
|
+
*/
|
|
10
|
+
export declare const ALL_SUPPORTED_CHAINS: ChainInfo[];
|
|
11
|
+
/**
|
|
12
|
+
* The list of supported chains.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ALL_SUPPORTED_CHAIN_IDS: SupportedChainId[];
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { TokenInfo } from '../common/types/tokens';
|
|
2
|
+
/**
|
|
3
|
+
* Supported chains and their `chainId` for the SDK.
|
|
4
|
+
* @enum
|
|
5
|
+
*/
|
|
6
|
+
export declare enum SupportedChainId {
|
|
7
|
+
MAINNET = 1,
|
|
8
|
+
GNOSIS_CHAIN = 100,
|
|
9
|
+
ARBITRUM_ONE = 42161,
|
|
10
|
+
BASE = 8453,
|
|
11
|
+
SEPOLIA = 11155111
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The chain id of the chain.
|
|
15
|
+
*
|
|
16
|
+
* TODO: Should we generalize it even more to allow non-EVM chains? We should probably revisit also the chain interface, and some other types.
|
|
17
|
+
*/
|
|
18
|
+
export type ChainId = number;
|
|
19
|
+
export interface ThemedImage {
|
|
20
|
+
light: string;
|
|
21
|
+
dark: string;
|
|
22
|
+
}
|
|
23
|
+
export interface WebUrl {
|
|
24
|
+
url: string;
|
|
25
|
+
name: string;
|
|
26
|
+
}
|
|
27
|
+
export type ChainRpcUrls = {
|
|
28
|
+
http: readonly string[];
|
|
29
|
+
webSocket?: readonly string[];
|
|
30
|
+
};
|
|
31
|
+
export type ChainContract = {
|
|
32
|
+
address: string;
|
|
33
|
+
blockCreated?: number | undefined;
|
|
34
|
+
};
|
|
35
|
+
export type ChainContracts = {
|
|
36
|
+
multicall3?: ChainContract;
|
|
37
|
+
ensRegistry?: ChainContract;
|
|
38
|
+
ensUniversalResolver?: ChainContract;
|
|
39
|
+
universalSignatureVerifier?: ChainContract;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A chain on the network.
|
|
43
|
+
*
|
|
44
|
+
* Probably we could use the viem chain definition, I think multicall3, and ensRegistry and the types defined there can be handy. But for now we are using a simplified version.
|
|
45
|
+
*
|
|
46
|
+
* For a list of chains, see: https://github.com/wevm/viem/tree/main/src/chains/definitions
|
|
47
|
+
*/
|
|
48
|
+
export interface ChainInfo {
|
|
49
|
+
/**
|
|
50
|
+
* The chain id.
|
|
51
|
+
*/
|
|
52
|
+
readonly id: ChainId;
|
|
53
|
+
/**
|
|
54
|
+
* Label of the chain. Field used for display purposes.
|
|
55
|
+
*/
|
|
56
|
+
readonly label: string;
|
|
57
|
+
/**
|
|
58
|
+
* Native currency of the chain.
|
|
59
|
+
*/
|
|
60
|
+
readonly nativeCurrency: TokenInfo;
|
|
61
|
+
/**
|
|
62
|
+
* ERC-3770 address prefix
|
|
63
|
+
*
|
|
64
|
+
* See https://eips.ethereum.org/EIPS/eip-3770
|
|
65
|
+
*/
|
|
66
|
+
readonly addressPrefix: string;
|
|
67
|
+
/**
|
|
68
|
+
* Whether the chain is a testnet.
|
|
69
|
+
*/
|
|
70
|
+
readonly isTestnet: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Contracts of the chain.
|
|
73
|
+
*/
|
|
74
|
+
readonly contracts: ChainContracts;
|
|
75
|
+
/**
|
|
76
|
+
* Main color of the chain, used for presentation purposes.
|
|
77
|
+
*/
|
|
78
|
+
readonly color: string;
|
|
79
|
+
/**
|
|
80
|
+
* Logo of the chain.
|
|
81
|
+
*/
|
|
82
|
+
readonly logo: ThemedImage;
|
|
83
|
+
/**
|
|
84
|
+
* Documentation of the chain.
|
|
85
|
+
*/
|
|
86
|
+
readonly docs: WebUrl;
|
|
87
|
+
/**
|
|
88
|
+
* Website of the chain.
|
|
89
|
+
*/
|
|
90
|
+
readonly website: WebUrl;
|
|
91
|
+
/**
|
|
92
|
+
* Block explorer of the chain.
|
|
93
|
+
*/
|
|
94
|
+
readonly blockExplorer: WebUrl;
|
|
95
|
+
/**
|
|
96
|
+
* Bridges of the chain.
|
|
97
|
+
*/
|
|
98
|
+
readonly bridges?: WebUrl[];
|
|
99
|
+
/**
|
|
100
|
+
* RPC URLs of the chain.
|
|
101
|
+
*/
|
|
102
|
+
readonly rpcUrls: {
|
|
103
|
+
[key: string]: ChainRpcUrls;
|
|
104
|
+
default: ChainRpcUrls;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import { SupportedChainId } from '
|
|
1
|
+
import { SupportedChainId } from '../../chains/types';
|
|
2
2
|
export declare const ETH_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
3
3
|
export declare const EXTENSIBLE_FALLBACK_HANDLER = "0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5";
|
|
4
4
|
export declare const COMPOSABLE_COW = "0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74";
|
|
5
5
|
export declare const COW_SHED_FACTORY = "0x00E989b87700514118Fa55326CD1cCE82faebEF6";
|
|
6
6
|
export declare const COW_SHED_IMPLEMENTATION = "0x2CFFA8cf11B90C9F437567b86352169dF4009F73";
|
|
7
|
-
/**
|
|
8
|
-
* The list of supported chains.
|
|
9
|
-
*/
|
|
10
|
-
export declare const ALL_SUPPORTED_CHAIN_IDS: SupportedChainId[];
|
|
11
|
-
export declare function mapSupportedNetworks<T>(value: (chainId: SupportedChainId) => T): Record<SupportedChainId, T>;
|
|
12
|
-
export declare function mapSupportedNetworks<T>(value: T): Record<SupportedChainId, T>;
|
|
13
|
-
export declare function mapAddressToSupportedNetworks(address: string): Record<SupportedChainId, string>;
|
|
14
7
|
/**
|
|
15
8
|
* An object containing the addresses of the CoW Protocol settlement contracts for each supported chain.
|
|
16
9
|
*/
|
|
@@ -27,13 +20,15 @@ export declare const EXTENSIBLE_FALLBACK_HANDLER_CONTRACT_ADDRESS: Record<Suppor
|
|
|
27
20
|
* An object containing the addresses of the `ComposableCow` contracts for each supported chain.
|
|
28
21
|
*/
|
|
29
22
|
export declare const COMPOSABLE_COW_CONTRACT_ADDRESS: Record<SupportedChainId, string>;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
*/
|
|
33
|
-
export declare const WRAPPED_NATIVE_CURRENCIES: Record<SupportedChainId, string>;
|
|
23
|
+
export declare const ETH_FLOW_ADDRESS = "0xba3cb449bd2b4adddbc894d8697f5170800eadec";
|
|
24
|
+
export declare const BARN_ETH_FLOW_ADDRESS = "0x04501b9b1d52e67f6862d157e00d13419d2d6e95";
|
|
34
25
|
/**
|
|
35
26
|
* An object containing the addresses of ETH flow contracts for each supported chain.
|
|
27
|
+
* @deprecated use ETH_FLOW_ADDRESS instead
|
|
36
28
|
*/
|
|
37
29
|
export declare const ETH_FLOW_ADDRESSES: Record<SupportedChainId, string>;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated use BARN_ETH_FLOW_ADDRESS instead
|
|
32
|
+
*/
|
|
38
33
|
export declare const BARN_ETH_FLOW_ADDRESSES: Record<SupportedChainId, string>;
|
|
39
34
|
export declare const MAX_VALID_TO_EPOCH = 4294967295;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RAW_FILES_PATH = "https://raw.githubusercontent.com/cowprotocol/cow-sdk/refs/heads/main";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SupportedChainId } from '../../chains/types';
|
|
2
|
+
import { TokenInfo } from '../types/tokens';
|
|
3
|
+
export declare const NATIVE_CURRENCY_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
|
|
4
|
+
export declare const TOKEN_LIST_IMAGES_PATH = "https://raw.githubusercontent.com/cowprotocol/token-lists/main/src/public/images";
|
|
5
|
+
export declare const WRAPPED_NATIVE_CURRENCIES: Record<SupportedChainId, TokenInfo>;
|
|
6
|
+
/**
|
|
7
|
+
* Just a base template for the native currency, handy to define new networks.
|
|
8
|
+
*/
|
|
9
|
+
export declare const nativeCurrencyTemplate: Omit<TokenInfo, 'chainId'>;
|
package/dist/common/index.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
1
|
+
export * from './types/config';
|
|
2
|
+
export * from './types/cow-error';
|
|
3
|
+
export * from './types/ethereum';
|
|
4
|
+
export * from './types/tokens';
|
|
5
|
+
export * from './types/wallets';
|
|
6
|
+
export * from '../chains/const';
|
|
7
|
+
export * from './consts/config';
|
|
8
|
+
export * from './consts/contracts';
|
|
9
|
+
export * from './consts/ipfs';
|
|
10
|
+
export * from './consts/tokens';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BackoffOptions } from 'exponential-backoff';
|
|
2
2
|
import { RateLimiterOpts } from 'limiter/dist/esm';
|
|
3
|
-
import { SupportedChainId } from '
|
|
3
|
+
import { SupportedChainId } from '../../chains/types';
|
|
4
4
|
/**
|
|
5
5
|
* IPFS configuration.
|
|
6
6
|
*
|
|
@@ -68,11 +68,3 @@ export interface ApiContext {
|
|
|
68
68
|
limiterOpts?: RateLimiterOpts;
|
|
69
69
|
backoffOpts?: BackoffOptions;
|
|
70
70
|
}
|
|
71
|
-
/**
|
|
72
|
-
* The list of available environments.
|
|
73
|
-
*/
|
|
74
|
-
export declare const ENVS_LIST: CowEnv[];
|
|
75
|
-
/**
|
|
76
|
-
* The default CoW Protocol API context.
|
|
77
|
-
*/
|
|
78
|
-
export declare const DEFAULT_COW_API_CONTEXT: ApiContext;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { SupportedChainId } from '../../chains/types';
|
|
2
|
+
export declare function mapSupportedNetworks<T>(value: (chainId: SupportedChainId) => T): Record<SupportedChainId, T>;
|
|
3
|
+
export declare function mapSupportedNetworks<T>(value: T): Record<SupportedChainId, T>;
|
|
4
|
+
export declare function mapAddressToSupportedNetworks(address: string): Record<SupportedChainId, string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const jsonReplacer: (_key: string, value: unknown) => unknown;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { providers } from 'ethers';
|
|
2
|
-
import { SupportedChainId } from '../
|
|
2
|
+
import { SupportedChainId } from '../chains';
|
|
3
3
|
import { ComposableCoW, GPv2Order } from '../common/generated/ComposableCoW';
|
|
4
4
|
import { ProofLocation, ProofWithParams, ConditionalOrderParams } from './types';
|
|
5
5
|
import { ConditionalOrder } from './ConditionalOrder';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { providers } from 'ethers';
|
|
2
|
-
import { SupportedChainId } from '../
|
|
2
|
+
import { SupportedChainId } from '../chains';
|
|
3
3
|
import { ComposableCoW } from '../common/generated';
|
|
4
4
|
import { ComposableCoWInterface } from '../common/generated/ComposableCoW';
|
|
5
5
|
export declare function getComposableCowInterface(): ComposableCoWInterface;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OrderBookApi } from '../order-book';
|
|
2
|
-
import { SupportedChainId } from '../
|
|
2
|
+
import { SupportedChainId } from '../chains';
|
|
3
3
|
import { GPv2Order } from '../common/generated/ComposableCoW';
|
|
4
4
|
import { providers } from 'ethers';
|
|
5
5
|
export interface ConditionalOrderArguments<T> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { utils, providers, BigNumber } from 'ethers';
|
|
2
|
-
import { SupportedChainId } from '../
|
|
2
|
+
import { SupportedChainId } from '../chains';
|
|
3
3
|
import { BlockInfo, ConditionalOrderParams, IsValid, IsValidResult } from './types';
|
|
4
4
|
import { Order } from '@cowprotocol/contracts';
|
|
5
5
|
import { GPv2Order } from '../common/generated/ComposableCoW';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { EvmCall, SignerLike } from '../common';
|
|
2
|
+
import { SupportedChainId } from '../chains';
|
|
3
|
+
import { CowShedHooks } from './contracts/CoWShedHooks';
|
|
4
|
+
import { EcdsaSigningScheme } from '@cowprotocol/contracts';
|
|
5
|
+
import { ICoWShedCall, ICoWShedOptions } from './types';
|
|
6
|
+
export interface SignAndEncodeTxArgs {
|
|
7
|
+
/**
|
|
8
|
+
* Calls to pre-authorize on the cow-shed account
|
|
9
|
+
*/
|
|
10
|
+
calls: ICoWShedCall[];
|
|
11
|
+
/**
|
|
12
|
+
* Signer for the cow-shed's owner account.
|
|
13
|
+
*
|
|
14
|
+
* The signer will be used to pre-authorise the calls.
|
|
15
|
+
* The cow-shed account will be derived from this signer.
|
|
16
|
+
*/
|
|
17
|
+
signer?: SignerLike;
|
|
18
|
+
/**
|
|
19
|
+
* Chain ID to use for the transaction.
|
|
20
|
+
*/
|
|
21
|
+
chainId: SupportedChainId;
|
|
22
|
+
/**
|
|
23
|
+
* Nonce to use for the transaction. If not provided, the current timestamp will be used.
|
|
24
|
+
*/
|
|
25
|
+
nonce?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Deadline to use for the transaction. If not provided, the maximum uint256 will be used.
|
|
28
|
+
*/
|
|
29
|
+
deadline?: bigint;
|
|
30
|
+
/**
|
|
31
|
+
* Default gas limit to use for the transaction. If not provided, it will throw an error if the gas limit cannot be estimated.
|
|
32
|
+
*/
|
|
33
|
+
defaultGasLimit?: bigint;
|
|
34
|
+
/**
|
|
35
|
+
* Signing scheme to use for the transaction.
|
|
36
|
+
*/
|
|
37
|
+
signingScheme?: EcdsaSigningScheme;
|
|
38
|
+
}
|
|
39
|
+
export interface CowShedCall {
|
|
40
|
+
cowShedAccount: string;
|
|
41
|
+
signedMulticall: EvmCall;
|
|
42
|
+
gasLimit: bigint;
|
|
43
|
+
}
|
|
44
|
+
export interface CowShedSdkOptions {
|
|
45
|
+
/**
|
|
46
|
+
* Signer for the cow-shed's owner account.
|
|
47
|
+
*/
|
|
48
|
+
signer?: SignerLike;
|
|
49
|
+
/**
|
|
50
|
+
* Custom options for the cow-shed hooks.
|
|
51
|
+
*/
|
|
52
|
+
factoryOptions?: ICoWShedOptions;
|
|
53
|
+
}
|
|
54
|
+
export declare class CowShedSdk {
|
|
55
|
+
private options;
|
|
56
|
+
protected hooksCache: Map<SupportedChainId, CowShedHooks>;
|
|
57
|
+
constructor(options?: CowShedSdkOptions);
|
|
58
|
+
getCowShedAccount(chainId: SupportedChainId, ownerAddress: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* Encodes multiple calls into a single pre-authorized call to the cow-shed factory.
|
|
61
|
+
*
|
|
62
|
+
* This single call will create the cow-shed account if it doesn't exist yet, then will execute the calls.
|
|
63
|
+
*
|
|
64
|
+
* @returns pre-authorized multicall details
|
|
65
|
+
*/
|
|
66
|
+
signCalls({ calls, signer: signerParam, chainId, nonce, deadline, defaultGasLimit, signingScheme, }: SignAndEncodeTxArgs): Promise<CowShedCall>;
|
|
67
|
+
protected getCowShedHooks(chainId: SupportedChainId, customOptions?: ICoWShedOptions): CowShedHooks;
|
|
68
|
+
protected static getNonce(): string;
|
|
69
|
+
}
|