@cowprotocol/cow-sdk 5.10.2 → 5.11.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 +2 -0
- package/dist/README.md +2 -0
- package/dist/bridging/BridgingSdk/BridgingSdk.d.ts +90 -0
- package/dist/bridging/BridgingSdk/getCrossChainOrder.d.ts +14 -0
- package/dist/bridging/BridgingSdk/getErc20Decimals.d.ts +4 -0
- package/dist/bridging/BridgingSdk/getQuoteWithBridging.d.ts +32 -0
- package/dist/bridging/BridgingSdk/getQuoteWithoutBridge.d.ts +7 -0
- package/dist/bridging/const.d.ts +2 -0
- package/dist/bridging/errors.d.ts +4 -0
- package/dist/bridging/index.d.ts +6 -0
- package/dist/bridging/providers/across/AcrossApi.d.ts +27 -0
- package/dist/bridging/providers/across/AcrossBridgeProvider.d.ts +43 -0
- package/dist/bridging/providers/across/abi.d.ts +154 -0
- package/dist/bridging/providers/across/const/contracts.d.ts +3 -0
- package/dist/bridging/providers/across/const/misc.d.ts +1 -0
- package/dist/bridging/providers/across/const/tokens.d.ts +11 -0
- package/dist/bridging/providers/across/createAcrossDepositCall.d.ts +9 -0
- package/dist/bridging/providers/across/types.d.ts +169 -0
- package/dist/bridging/providers/across/util.d.ts +39 -0
- package/dist/bridging/providers/mock/MockBridgeProvider.d.ts +21 -0
- package/dist/bridging/types.d.ts +287 -0
- package/dist/bridging/utils.d.ts +9 -0
- package/dist/chains/const/index.d.ts +25 -0
- package/dist/chains/const/path.d.ts +1 -0
- package/dist/chains/details/arbitrum.d.ts +7 -0
- package/dist/chains/details/avalanche.d.ts +2 -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 +3 -0
- package/dist/chains/types.d.ts +123 -0
- package/dist/chains/utils.d.ts +18 -0
- package/dist/common/consts/config.d.ts +9 -0
- package/dist/common/{consts.d.ts → consts/contracts.d.ts} +1 -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 +12 -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/log.d.ts +2 -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} +44 -0
- package/dist/cow-shed/contracts/utils.d.ts +4 -0
- package/dist/cow-shed/index.d.ts +2 -3
- package/dist/cow-shed/types.d.ts +0 -16
- package/dist/hooks/utils.d.ts +3 -0
- package/dist/index-ef9ef589.js +29 -0
- package/dist/index-ef9ef589.js.map +1 -0
- package/dist/index.d.ts +4 -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/api.d.ts +1 -1
- package/dist/order-book/quoteAmountsAndCostsUtils.d.ts +13 -2
- package/dist/order-book/types.d.ts +54 -18
- 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 +13 -11
- package/dist/schemas/trading/LimitOrderAdvancedSettings.ts +26 -0
- package/dist/schemas/trading/LimitTradeParameters.ts +3 -0
- package/dist/schemas/trading/QuoteResultsSerialized.ts +21 -12
- package/dist/schemas/trading/QuoterParameters.ts +11 -1
- package/dist/schemas/trading/SwapAdvancedSettings.ts +206 -0
- package/dist/schemas/trading/TradeParameters.ts +3 -0
- package/dist/src/bridging/README.md +54 -0
- package/dist/src/cow-shed/README.md +60 -0
- package/dist/src/trading/README.md +55 -7
- package/dist/src/weiroll/README.md +58 -0
- package/dist/subgraph/api.d.ts +2 -2
- package/dist/test/utils.d.ts +1 -0
- package/dist/trading/appDataUtils.d.ts +2 -1
- package/dist/trading/calculateUniqueOrderId.d.ts +3 -4
- package/dist/trading/consts.d.ts +2 -4
- package/dist/trading/getEthFlowTransaction.d.ts +6 -5
- package/dist/trading/getOrderTypedData.d.ts +1 -1
- package/dist/trading/getPreSignTransaction.d.ts +2 -2
- package/dist/trading/getQuote.d.ts +1 -1
- package/dist/trading/postCoWProtocolTrade.d.ts +4 -4
- package/dist/trading/postLimitOrder.d.ts +2 -2
- package/dist/trading/postSellNativeCurrencyOrder.d.ts +2 -6
- package/dist/trading/postSwapOrder.d.ts +3 -3
- package/dist/trading/tradingSdk.d.ts +14 -11
- package/dist/trading/types.d.ts +73 -11
- package/dist/trading/utils.d.ts +8 -4
- package/dist/utils-757fe114.js +2 -0
- package/dist/utils-757fe114.js.map +1 -0
- package/dist/utils-9a7618d8.js +2 -0
- package/dist/utils-9a7618d8.js.map +1 -0
- package/dist/utils-f4151c05.js +2 -0
- package/dist/utils-f4151c05.js.map +1 -0
- package/dist/utils.d.ts +1 -1
- package/dist/weiroll/index.d.ts +23 -0
- package/package.json +13 -11
- 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-2ed223c8.js +0 -29
- package/dist/index-2ed223c8.js.map +0 -1
- package/dist/utils-4bdd94dd.js +0 -2
- package/dist/utils-4bdd94dd.js.map +0 -1
- package/dist/utils-63156cab.js +0 -2
- package/dist/utils-63156cab.js.map +0 -1
- package/dist/utils-faedc0ab.js +0 -2
- package/dist/utils-faedc0ab.js.map +0 -1
- /package/dist/common/{ipfs.d.ts → consts/ipfs.d.ts} +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { latest as latestAppData } from '@cowprotocol/app-data';
|
|
2
|
+
import { BridgeDeposit, BridgeHook, BridgeProvider, BridgeProviderInfo, BridgeQuoteResult, BridgeStatusResult, QuoteBridgeRequest } from '../../types';
|
|
3
|
+
import { EvmCall, TokenInfo } from '../../../common';
|
|
4
|
+
import { ChainInfo, SupportedChainId, TargetChainId } from '../../../chains';
|
|
5
|
+
import { Signer } from '@ethersproject/abstract-signer';
|
|
6
|
+
export declare class MockBridgeProvider implements BridgeProvider<BridgeQuoteResult> {
|
|
7
|
+
info: BridgeProviderInfo;
|
|
8
|
+
getNetworks(): Promise<ChainInfo[]>;
|
|
9
|
+
getBuyTokens(targetChainId: TargetChainId): Promise<TokenInfo[]>;
|
|
10
|
+
getIntermediateTokens({ sellTokenChainId }: QuoteBridgeRequest): Promise<string[]>;
|
|
11
|
+
getQuote(_request: QuoteBridgeRequest): Promise<BridgeQuoteResult>;
|
|
12
|
+
getGasLimitEstimationForHook(_request: QuoteBridgeRequest): number;
|
|
13
|
+
getUnsignedBridgeCall(_request: QuoteBridgeRequest, _quote: BridgeQuoteResult): Promise<EvmCall>;
|
|
14
|
+
getSignedHook(_chainId: SupportedChainId, _unsignedCall: EvmCall, _signer: Signer): Promise<BridgeHook>;
|
|
15
|
+
decodeBridgeHook(_hook: latestAppData.CoWHook): Promise<BridgeDeposit>;
|
|
16
|
+
getBridgingId(_orderUid: string, _settlementTx: string, _logIndex: number): Promise<string>;
|
|
17
|
+
getExplorerUrl(bridgingId: string): string;
|
|
18
|
+
getStatus(_bridgingId: string): Promise<BridgeStatusResult>;
|
|
19
|
+
getCancelBridgingTx(_bridgingId: string): Promise<EvmCall>;
|
|
20
|
+
getRefundBridgingTx(_bridgingId: string): Promise<EvmCall>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { latest as latestAppData } from '@cowprotocol/app-data';
|
|
2
|
+
import { ChainInfo, SupportedChainId, TargetChainId } from '../chains';
|
|
3
|
+
import { TokenInfo } from '../common/types/tokens';
|
|
4
|
+
import { Address, Amounts, EnrichedOrder, OrderKind } from '../order-book';
|
|
5
|
+
import { EvmCall } from '../common/types/ethereum';
|
|
6
|
+
import type { AccountAddress } from '../common/types/wallets';
|
|
7
|
+
import { OrderPostingResult, QuoteAndPost, QuoteResults, QuoterParameters, TradeOptionalParameters, TraderParameters } from '../trading';
|
|
8
|
+
import { Signer } from '@ethersproject/abstract-signer';
|
|
9
|
+
export interface BridgeProviderInfo {
|
|
10
|
+
name: string;
|
|
11
|
+
logoUrl: string;
|
|
12
|
+
}
|
|
13
|
+
interface WithSellToken {
|
|
14
|
+
sellTokenChainId: SupportedChainId;
|
|
15
|
+
sellTokenAddress: Address;
|
|
16
|
+
sellTokenDecimals: number;
|
|
17
|
+
}
|
|
18
|
+
interface WithBuyToken {
|
|
19
|
+
buyTokenChainId: TargetChainId;
|
|
20
|
+
buyTokenAddress: Address;
|
|
21
|
+
buyTokenDecimals: number;
|
|
22
|
+
}
|
|
23
|
+
type WithQuoter = Omit<QuoterParameters, 'chainId'>;
|
|
24
|
+
type WithTrader = Pick<TraderParameters, 'signer'>;
|
|
25
|
+
/**
|
|
26
|
+
* Parameters for getting a bridge quote
|
|
27
|
+
*/
|
|
28
|
+
export type QuoteBridgeRequest = {
|
|
29
|
+
kind: OrderKind;
|
|
30
|
+
amount: bigint;
|
|
31
|
+
owner?: AccountAddress;
|
|
32
|
+
} & WithSellToken & WithBuyToken & WithQuoter & WithTrader & TradeOptionalParameters;
|
|
33
|
+
export type QuoteBridgeRequestWithoutAmount = Omit<QuoteBridgeRequest, 'amount'>;
|
|
34
|
+
export interface BridgeQuoteResult {
|
|
35
|
+
/**
|
|
36
|
+
* Whether the quote is a sell or buy order.
|
|
37
|
+
*/
|
|
38
|
+
isSell: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Costs and amounts of the bridging.
|
|
41
|
+
*/
|
|
42
|
+
amountsAndCosts: BridgeQuoteAmountsAndCosts;
|
|
43
|
+
/**
|
|
44
|
+
* The estimated time in seconds it takes to fill the order.
|
|
45
|
+
*/
|
|
46
|
+
expectedFillTimeSeconds?: number;
|
|
47
|
+
/**
|
|
48
|
+
* The timestamp of the quote.
|
|
49
|
+
*/
|
|
50
|
+
quoteTimestamp: number;
|
|
51
|
+
fees: {
|
|
52
|
+
/**
|
|
53
|
+
* The amount that should go to the relayer as a fee to cover relayer capital costs.
|
|
54
|
+
* In token atoms.
|
|
55
|
+
*/
|
|
56
|
+
bridgeFee: bigint;
|
|
57
|
+
/**
|
|
58
|
+
* The amount that should go to the relayer as a fee to cover relayer gas costs.
|
|
59
|
+
* In token atoms.
|
|
60
|
+
*/
|
|
61
|
+
destinationGasFee: bigint;
|
|
62
|
+
};
|
|
63
|
+
limits: {
|
|
64
|
+
/**
|
|
65
|
+
* The minimum amount that should be deposited in the source chain.
|
|
66
|
+
* In token atoms.
|
|
67
|
+
*/
|
|
68
|
+
minDeposit: bigint;
|
|
69
|
+
/**
|
|
70
|
+
* The maximum amount that can be deposited in the source chain.
|
|
71
|
+
* In token atoms.
|
|
72
|
+
*/
|
|
73
|
+
maxDeposit: bigint;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export interface BridgeHook {
|
|
77
|
+
postHook: latestAppData.CoWHook;
|
|
78
|
+
recipient: string;
|
|
79
|
+
}
|
|
80
|
+
export declare enum BridgeStatus {
|
|
81
|
+
NOT_INITIATED = "not_initiated",
|
|
82
|
+
IN_PROGRESS = "in_progress",
|
|
83
|
+
EXECUTED = "executed",
|
|
84
|
+
FAILED = "failed",
|
|
85
|
+
EXPIRED = "expired"
|
|
86
|
+
}
|
|
87
|
+
export interface BridgeStatusResult {
|
|
88
|
+
status: BridgeStatus;
|
|
89
|
+
fillTimeInSeconds?: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A bridge deposit. It includes the provideer information, sell amount and the minimum buy amount.
|
|
93
|
+
*
|
|
94
|
+
* It models the minimal information for a bridging order.
|
|
95
|
+
*
|
|
96
|
+
*/
|
|
97
|
+
export interface BridgeDeposit extends Omit<QuoteBridgeRequest, 'amount'> {
|
|
98
|
+
readonly provider: BridgeProviderInfo;
|
|
99
|
+
sellTokenAmount: string;
|
|
100
|
+
minBuyAmount: string;
|
|
101
|
+
}
|
|
102
|
+
export interface BridgeProvider<Q extends BridgeQuoteResult> {
|
|
103
|
+
info: BridgeProviderInfo;
|
|
104
|
+
/**
|
|
105
|
+
* Get basic supported chains
|
|
106
|
+
*/
|
|
107
|
+
getNetworks(): Promise<ChainInfo[]>;
|
|
108
|
+
/**
|
|
109
|
+
* Get supported tokens for a chain
|
|
110
|
+
*/
|
|
111
|
+
getBuyTokens(targetChainId: TargetChainId): Promise<TokenInfo[]>;
|
|
112
|
+
/**
|
|
113
|
+
* Get intermediate tokens given a quote request.
|
|
114
|
+
*
|
|
115
|
+
* An intermediate token, is a token in the source chain, that could be used to bridge the tokens to the destination chain.
|
|
116
|
+
* This method returns a sorted list of tokens, they are sorted by priority, so first tokens are more likely to be more liquid.
|
|
117
|
+
*
|
|
118
|
+
* @param request - The quote request
|
|
119
|
+
*/
|
|
120
|
+
getIntermediateTokens(request: QuoteBridgeRequest): Promise<string[]>;
|
|
121
|
+
/**
|
|
122
|
+
* Get a quote for a bridge request.
|
|
123
|
+
*
|
|
124
|
+
* @param request - The quote request
|
|
125
|
+
*/
|
|
126
|
+
getQuote(request: QuoteBridgeRequest): Promise<Q>;
|
|
127
|
+
/**
|
|
128
|
+
* Get an unsigned bridge call for a quote.
|
|
129
|
+
*
|
|
130
|
+
* The transaction details should be executed in the context of cow-shed account.
|
|
131
|
+
*
|
|
132
|
+
* @param request - The quote request
|
|
133
|
+
* @param quote - The quote
|
|
134
|
+
* @returns The unsigned transaction details that cow-shed needs to sign
|
|
135
|
+
*/
|
|
136
|
+
getUnsignedBridgeCall(request: QuoteBridgeRequest, quote: Q): Promise<EvmCall>;
|
|
137
|
+
/**
|
|
138
|
+
* Returns the estimated gas cost for executing the bridge hook.
|
|
139
|
+
*
|
|
140
|
+
* This method helps calculate the final amount of tokens the user will receive more accurately.
|
|
141
|
+
* The estimation is done without the amount parameter to break a circular dependency:
|
|
142
|
+
* 1. Hook gas costs affect the final amount
|
|
143
|
+
* 2. The final amount could affect hook gas costs
|
|
144
|
+
*
|
|
145
|
+
* By estimating gas costs independently, we can resolve this dependency cycle.
|
|
146
|
+
*/
|
|
147
|
+
getGasLimitEstimationForHook(request: Omit<QuoteBridgeRequest, 'amount'>): number;
|
|
148
|
+
/**
|
|
149
|
+
* Get a pre-authorized hook for initiating a bridge.
|
|
150
|
+
*
|
|
151
|
+
* The hook contains the ethereum call that the trampoline contract will need to execute during the settlement to initate the bridge.
|
|
152
|
+
*
|
|
153
|
+
* Typically, this hook will:
|
|
154
|
+
* - Get the balance of cow-shed account
|
|
155
|
+
* - Ensure the approval for the bridge lock contract is set
|
|
156
|
+
* - Deposit into the bridge contract
|
|
157
|
+
*
|
|
158
|
+
* This hook will include the pre-authorization (signature) of the owner of the cow-shed account (the trader).
|
|
159
|
+
*
|
|
160
|
+
* @param unsignedCall
|
|
161
|
+
* @param signer
|
|
162
|
+
*/
|
|
163
|
+
getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, signer: Signer): Promise<BridgeHook>;
|
|
164
|
+
/**
|
|
165
|
+
* Decode a bridge hook into a bridge deposit information.
|
|
166
|
+
*
|
|
167
|
+
* This method is used to recover the information about the limit order placed into the bridge locking contract.
|
|
168
|
+
* 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.
|
|
169
|
+
*
|
|
170
|
+
* @param hook - The bridge hook
|
|
171
|
+
*/
|
|
172
|
+
decodeBridgeHook(hook: latestAppData.CoWHook): Promise<BridgeDeposit>;
|
|
173
|
+
/**
|
|
174
|
+
* Get the identifier of the bridging transaction from the settlement transaction.
|
|
175
|
+
* @param orderUid - The unique identifier of the order
|
|
176
|
+
* @param settlementTx - The settlement transaction in which the bridging post-hook was executed
|
|
177
|
+
* @param logIndex - The log index of the trade within the settlement transaction
|
|
178
|
+
*/
|
|
179
|
+
getBridgingId(orderUid: string, settlementTx: string, logIndex: number): Promise<string>;
|
|
180
|
+
/**
|
|
181
|
+
* Get the explorer url for a bridging id.
|
|
182
|
+
*
|
|
183
|
+
* @param bridgingId - The bridging id
|
|
184
|
+
*/
|
|
185
|
+
getExplorerUrl(bridgingId: string): string;
|
|
186
|
+
/**
|
|
187
|
+
* Get the status of a bridging transaction.
|
|
188
|
+
*
|
|
189
|
+
* @param bridgingId - The bridging id
|
|
190
|
+
*/
|
|
191
|
+
getStatus(bridgingId: string): Promise<BridgeStatusResult>;
|
|
192
|
+
getCancelBridgingTx(bridgingId: string): Promise<EvmCall>;
|
|
193
|
+
getRefundBridgingTx(bridgingId: string): Promise<EvmCall>;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* A quote and post for a cross-chain swap.
|
|
197
|
+
*
|
|
198
|
+
* If the order happens in a single chain, it returns the quote and post details for CoW Protocol.
|
|
199
|
+
* If the order happens in multiple chains, it returns the quote and post details for CoW Protocol, the bridging
|
|
200
|
+
* details, and a summary of the overall multi-step order.
|
|
201
|
+
*/
|
|
202
|
+
export type CrossChainQuoteAndPost = QuoteAndPost | BridgeQuoteAndPost;
|
|
203
|
+
export interface BridgeQuoteAndPost {
|
|
204
|
+
/**
|
|
205
|
+
* The quote results for the CoW Protocol order.
|
|
206
|
+
*/
|
|
207
|
+
swap: QuoteResults;
|
|
208
|
+
/**
|
|
209
|
+
* The quote results for the bridging.
|
|
210
|
+
*
|
|
211
|
+
* Includes the bridging details.
|
|
212
|
+
*/
|
|
213
|
+
bridge: BridgeQuoteResults;
|
|
214
|
+
/**
|
|
215
|
+
* Callback to post the swap order.
|
|
216
|
+
*/
|
|
217
|
+
postSwapOrderFromQuote(): Promise<OrderPostingResult>;
|
|
218
|
+
}
|
|
219
|
+
export interface BridgeCosts<T = bigint> {
|
|
220
|
+
bridgingFee: {
|
|
221
|
+
feeBps: number;
|
|
222
|
+
amountInSellCurrency: T;
|
|
223
|
+
amountInBuyCurrency: T;
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
export interface BridgeQuoteAmountsAndCosts<T = bigint> {
|
|
227
|
+
/**
|
|
228
|
+
* Costs of the bridging.
|
|
229
|
+
*/
|
|
230
|
+
costs: BridgeCosts<T>;
|
|
231
|
+
/**
|
|
232
|
+
* Amounts before fees
|
|
233
|
+
*/
|
|
234
|
+
beforeFee: Amounts<T>;
|
|
235
|
+
/**
|
|
236
|
+
* Amounts after fees.
|
|
237
|
+
*/
|
|
238
|
+
afterFee: Amounts<T>;
|
|
239
|
+
/**
|
|
240
|
+
* Amounts after slippage tolerance.
|
|
241
|
+
*
|
|
242
|
+
* It includes the fees and the slippage tolerance, so its the minimum amount that the user will receive.
|
|
243
|
+
*/
|
|
244
|
+
afterSlippage: Amounts<T>;
|
|
245
|
+
/**
|
|
246
|
+
* The slippage tolerance in basis points.
|
|
247
|
+
*/
|
|
248
|
+
slippageBps: number;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Details about the bridge call.
|
|
252
|
+
*/
|
|
253
|
+
export interface BridgeCallDetails {
|
|
254
|
+
/**
|
|
255
|
+
* Unsigned call to initiate the bridge. This call should be executed in the context of user's cow-shed account.
|
|
256
|
+
*/
|
|
257
|
+
unsignedBridgeCall: EvmCall;
|
|
258
|
+
/**
|
|
259
|
+
* Pre-authorized hook to initiate the bridge. This hook has been signed, and is ready to be executed by the
|
|
260
|
+
* CoW Protocol Trampoline contract after settling the swap order that buys the intermediate token.
|
|
261
|
+
*/
|
|
262
|
+
preAuthorizedBridgingHook: BridgeHook;
|
|
263
|
+
}
|
|
264
|
+
export interface BridgeQuoteResults extends BridgeQuoteResult {
|
|
265
|
+
/**
|
|
266
|
+
* Bridge provider information
|
|
267
|
+
*/
|
|
268
|
+
providerInfo: BridgeProviderInfo;
|
|
269
|
+
/**
|
|
270
|
+
* Trade parameters
|
|
271
|
+
*/
|
|
272
|
+
tradeParameters: QuoteBridgeRequest;
|
|
273
|
+
/**
|
|
274
|
+
* Bridge call details
|
|
275
|
+
*/
|
|
276
|
+
bridgeCallDetails: BridgeCallDetails;
|
|
277
|
+
}
|
|
278
|
+
export type GetErc20Decimals = (chainId: TargetChainId, tokenAddress: string) => Promise<number>;
|
|
279
|
+
export interface CrossChainOrder {
|
|
280
|
+
chainId: SupportedChainId;
|
|
281
|
+
order: EnrichedOrder;
|
|
282
|
+
status: BridgeStatus;
|
|
283
|
+
bridgingId?: string;
|
|
284
|
+
explorerUrl?: string;
|
|
285
|
+
fillTimeInSeconds?: number;
|
|
286
|
+
}
|
|
287
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { QuoteAndPost } from '../trading';
|
|
2
|
+
import { latest as latestAppData } from '@cowprotocol/app-data';
|
|
3
|
+
import { BridgeQuoteAndPost, CrossChainQuoteAndPost } from './types';
|
|
4
|
+
export declare function isBridgeQuoteAndPost(quote: CrossChainQuoteAndPost): quote is BridgeQuoteAndPost;
|
|
5
|
+
export declare function isQuoteAndPost(quote: CrossChainQuoteAndPost): quote is QuoteAndPost;
|
|
6
|
+
export declare function assertIsBridgeQuoteAndPost(quote: CrossChainQuoteAndPost): asserts quote is BridgeQuoteAndPost;
|
|
7
|
+
export declare function assertIsQuoteAndPost(quote: CrossChainQuoteAndPost): asserts quote is QuoteAndPost;
|
|
8
|
+
export declare function getPostHooks(fullAppData?: string): latestAppData.CoWHook[];
|
|
9
|
+
export declare function isAppDoc(appData: unknown): appData is latestAppData.AppDataRootSchema;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AdditionalTargetChainId, ChainInfo, SupportedChainId } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Details of all supported chains.
|
|
4
|
+
*/
|
|
5
|
+
export declare const ALL_SUPPORTED_CHAINS_MAP: Record<SupportedChainId, ChainInfo>;
|
|
6
|
+
/**
|
|
7
|
+
* All supported chains.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ALL_SUPPORTED_CHAINS: ChainInfo[];
|
|
10
|
+
/**
|
|
11
|
+
* The list of supported chains.
|
|
12
|
+
*/
|
|
13
|
+
export declare const ALL_SUPPORTED_CHAIN_IDS: SupportedChainId[];
|
|
14
|
+
/**
|
|
15
|
+
* Maps a chain where you can bridge to, but not sell tokens from (not supported by CoW Protocol)
|
|
16
|
+
*/
|
|
17
|
+
export declare const ADDITIONAL_TARGET_CHAINS_MAP: Record<AdditionalTargetChainId, ChainInfo>;
|
|
18
|
+
/**
|
|
19
|
+
* All chains (both supported by CoW Protocol, or chains where you can bridge to)
|
|
20
|
+
*/
|
|
21
|
+
export declare const ALL_CHAINS: ChainInfo[];
|
|
22
|
+
/**
|
|
23
|
+
* All chain ids (both supported by CoW Protocol, or chains where you can bridge to)
|
|
24
|
+
*/
|
|
25
|
+
export declare const ALL_CHAINS_IDS: number[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RAW_CHAINS_FILES_PATH: string;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { TokenInfo } from '../common/types/tokens';
|
|
2
|
+
/**
|
|
3
|
+
* Supported chains and their `chainId` for the SDK.
|
|
4
|
+
*
|
|
5
|
+
* A supported chain, is a chain where CoW Protocol is deployed, so you can sell tokens from there.
|
|
6
|
+
*
|
|
7
|
+
* @enum
|
|
8
|
+
*/
|
|
9
|
+
export declare enum SupportedChainId {
|
|
10
|
+
MAINNET = 1,
|
|
11
|
+
GNOSIS_CHAIN = 100,
|
|
12
|
+
ARBITRUM_ONE = 42161,
|
|
13
|
+
BASE = 8453,
|
|
14
|
+
POLYGON = 137,
|
|
15
|
+
AVALANCHE = 43114,
|
|
16
|
+
SEPOLIA = 11155111
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Chains where you can buy tokens using the bridge functionality. This enum contains chains that are not already included in the SupportedChainId enum.
|
|
20
|
+
*/
|
|
21
|
+
export declare enum AdditionalTargetChainId {
|
|
22
|
+
OPTIMISM = 10
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Chains where you can buy tokens using the bridge functionality.
|
|
26
|
+
*
|
|
27
|
+
* This enum contains all the supported chains and some additional ones supported by the different bridges.
|
|
28
|
+
*/
|
|
29
|
+
export type TargetChainId = SupportedChainId | AdditionalTargetChainId;
|
|
30
|
+
/**
|
|
31
|
+
* The chain id of the chain.
|
|
32
|
+
*
|
|
33
|
+
* TODO: Should we generalize it even more to allow non-EVM chains? We should probably revisit also the chain interface, and some other types.
|
|
34
|
+
*/
|
|
35
|
+
export type ChainId = number;
|
|
36
|
+
export interface ThemedImage {
|
|
37
|
+
light: string;
|
|
38
|
+
dark: string;
|
|
39
|
+
}
|
|
40
|
+
export interface WebUrl {
|
|
41
|
+
url: string;
|
|
42
|
+
name: string;
|
|
43
|
+
}
|
|
44
|
+
export type ChainRpcUrls = {
|
|
45
|
+
http: readonly string[];
|
|
46
|
+
webSocket?: readonly string[];
|
|
47
|
+
};
|
|
48
|
+
export type ChainContract = {
|
|
49
|
+
address: string;
|
|
50
|
+
blockCreated?: number | undefined;
|
|
51
|
+
};
|
|
52
|
+
export type ChainContracts = {
|
|
53
|
+
multicall3?: ChainContract;
|
|
54
|
+
ensRegistry?: ChainContract;
|
|
55
|
+
ensUniversalResolver?: ChainContract;
|
|
56
|
+
universalSignatureVerifier?: ChainContract;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* A chain on the network.
|
|
60
|
+
*
|
|
61
|
+
* 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.
|
|
62
|
+
*
|
|
63
|
+
* For a list of chains, see: https://github.com/wevm/viem/tree/main/src/chains/definitions
|
|
64
|
+
*/
|
|
65
|
+
export interface ChainInfo {
|
|
66
|
+
/**
|
|
67
|
+
* The chain id.
|
|
68
|
+
*/
|
|
69
|
+
readonly id: ChainId;
|
|
70
|
+
/**
|
|
71
|
+
* Label of the chain. Field used for display purposes.
|
|
72
|
+
*/
|
|
73
|
+
readonly label: string;
|
|
74
|
+
/**
|
|
75
|
+
* Native currency of the chain.
|
|
76
|
+
*/
|
|
77
|
+
readonly nativeCurrency: TokenInfo;
|
|
78
|
+
/**
|
|
79
|
+
* ERC-3770 address prefix
|
|
80
|
+
*
|
|
81
|
+
* See https://eips.ethereum.org/EIPS/eip-3770
|
|
82
|
+
*/
|
|
83
|
+
readonly addressPrefix: string;
|
|
84
|
+
/**
|
|
85
|
+
* Whether the chain is a testnet.
|
|
86
|
+
*/
|
|
87
|
+
readonly isTestnet: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* Contracts of the chain.
|
|
90
|
+
*/
|
|
91
|
+
readonly contracts: ChainContracts;
|
|
92
|
+
/**
|
|
93
|
+
* Main color of the chain, used for presentation purposes.
|
|
94
|
+
*/
|
|
95
|
+
readonly color: string;
|
|
96
|
+
/**
|
|
97
|
+
* Logo of the chain.
|
|
98
|
+
*/
|
|
99
|
+
readonly logo: ThemedImage;
|
|
100
|
+
/**
|
|
101
|
+
* Documentation of the chain.
|
|
102
|
+
*/
|
|
103
|
+
readonly docs: WebUrl;
|
|
104
|
+
/**
|
|
105
|
+
* Website of the chain.
|
|
106
|
+
*/
|
|
107
|
+
readonly website: WebUrl;
|
|
108
|
+
/**
|
|
109
|
+
* Block explorer of the chain.
|
|
110
|
+
*/
|
|
111
|
+
readonly blockExplorer: WebUrl;
|
|
112
|
+
/**
|
|
113
|
+
* Bridges of the chain.
|
|
114
|
+
*/
|
|
115
|
+
readonly bridges?: WebUrl[];
|
|
116
|
+
/**
|
|
117
|
+
* RPC URLs of the chain.
|
|
118
|
+
*/
|
|
119
|
+
readonly rpcUrls: {
|
|
120
|
+
[key: string]: ChainRpcUrls;
|
|
121
|
+
default: ChainRpcUrls;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AdditionalTargetChainId, ChainId, ChainInfo, SupportedChainId, TargetChainId } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Return the chain info for a given chain id or undefined if the chain is not known (not supported by CoW Protocol or the bridge providers).
|
|
4
|
+
* @param chainId
|
|
5
|
+
*/
|
|
6
|
+
export declare function getChainInfo(chainId: ChainId): ChainInfo | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Check if the chain is supported by CoW Protocol.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isSupportedChain(chainId: ChainId): chainId is SupportedChainId;
|
|
11
|
+
/**
|
|
12
|
+
* Check if the chain is supported by the bridge providers.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isAdditionalTargetChain(chainId: ChainId): chainId is AdditionalTargetChainId;
|
|
15
|
+
/**
|
|
16
|
+
* Check if the chain is supported by CoW Swap or the bridge providers.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isTargetChainId(chainId: ChainId): chainId is TargetChainId;
|
|
@@ -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,10 +20,6 @@ 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
|
-
* An object containing the addresses of wrapped native currencies for each supported chain.
|
|
32
|
-
*/
|
|
33
|
-
export declare const WRAPPED_NATIVE_CURRENCIES: Record<SupportedChainId, string>;
|
|
34
23
|
export declare const ETH_FLOW_ADDRESS = "0xba3cb449bd2b4adddbc894d8697f5170800eadec";
|
|
35
24
|
export declare const BARN_ETH_FLOW_ADDRESS = "0x04501b9b1d52e67f6862d157e00d13419d2d6e95";
|
|
36
25
|
/**
|
|
@@ -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,12 @@
|
|
|
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 { enableLogging } from './utils/log';
|
|
7
|
+
export * from '../chains/const';
|
|
8
|
+
export * from './consts/config';
|
|
9
|
+
export * from './consts/contracts';
|
|
10
|
+
export * from './consts/ipfs';
|
|
11
|
+
export * from './consts/tokens';
|
|
12
|
+
export * from './utils/config';
|
|
@@ -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;
|