@cowprotocol/cow-sdk 6.0.0-RC.9 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/README.md +3 -1
  2. package/dist/README.md +3 -1
  3. package/dist/bridging/BridgingSdk/BridgingSdk.d.ts +87 -63
  4. package/dist/bridging/BridgingSdk/findBridgeProviderFromHook.d.ts +2 -0
  5. package/dist/bridging/BridgingSdk/getBridgeSignedHook.d.ts +8 -0
  6. package/dist/bridging/BridgingSdk/getCrossChainOrder.d.ts +16 -0
  7. package/dist/bridging/BridgingSdk/getQuoteWithBridge.d.ts +3 -0
  8. package/dist/bridging/BridgingSdk/getQuoteWithoutBridge.d.ts +7 -7
  9. package/dist/bridging/BridgingSdk/mock/bridgeRequestMocks.d.ts +20 -0
  10. package/dist/bridging/BridgingSdk/types.d.ts +43 -0
  11. package/dist/bridging/const.d.ts +4 -2
  12. package/dist/bridging/errors.d.ts +22 -0
  13. package/dist/bridging/index.d.ts +8 -5
  14. package/dist/bridging/providers/across/AcrossApi.d.ts +30 -195
  15. package/dist/bridging/providers/across/AcrossBridgeProvider.d.ts +44 -41
  16. package/dist/bridging/providers/across/abi.d.ts +154 -154
  17. package/dist/bridging/providers/across/const/contracts.d.ts +3 -3
  18. package/dist/bridging/providers/across/const/interfaces.d.ts +3 -0
  19. package/dist/bridging/providers/across/const/misc.d.ts +2 -0
  20. package/dist/bridging/providers/across/const/tokens.d.ts +11 -11
  21. package/dist/bridging/providers/across/createAcrossDepositCall.d.ts +9 -9
  22. package/dist/bridging/providers/across/getDepositParams.d.ts +4 -0
  23. package/dist/bridging/providers/across/types.d.ts +242 -0
  24. package/dist/bridging/providers/across/util.d.ts +43 -39
  25. package/dist/bridging/providers/bungee/BungeeApi.d.ts +67 -0
  26. package/dist/bridging/providers/bungee/BungeeBridgeProvider.d.ts +44 -0
  27. package/dist/bridging/providers/bungee/abi.d.ts +203 -0
  28. package/dist/bridging/providers/bungee/const/contracts.d.ts +4 -0
  29. package/dist/bridging/providers/bungee/const/misc.d.ts +8 -0
  30. package/dist/bridging/providers/bungee/createBungeeDepositCall.d.ts +7 -0
  31. package/dist/bridging/providers/bungee/getBridgingStatusFromEvents.d.ts +3 -0
  32. package/dist/bridging/providers/bungee/types.d.ts +267 -0
  33. package/dist/bridging/providers/bungee/util.d.ts +62 -0
  34. package/dist/bridging/providers/mock/MockBridgeProvider.d.ts +26 -20
  35. package/dist/bridging/providers/utils/getGasLimitEstimationForHook.d.ts +4 -0
  36. package/dist/bridging/types.d.ts +323 -251
  37. package/dist/bridging/utils.d.ts +9 -6
  38. package/dist/chains/const/index.d.ts +25 -25
  39. package/dist/chains/const/path.d.ts +1 -1
  40. package/dist/chains/details/arbitrum.d.ts +7 -7
  41. package/dist/chains/details/avalanche.d.ts +2 -0
  42. package/dist/chains/details/base.d.ts +7 -7
  43. package/dist/chains/details/gnosis.d.ts +7 -7
  44. package/dist/chains/details/index.d.ts +8 -0
  45. package/dist/chains/details/mainnet.d.ts +7 -7
  46. package/dist/chains/details/optimism.d.ts +2 -2
  47. package/dist/chains/details/polygon.d.ts +2 -2
  48. package/dist/chains/details/sepolia.d.ts +7 -7
  49. package/dist/chains/index.d.ts +4 -3
  50. package/dist/chains/types.d.ts +127 -122
  51. package/dist/chains/utils.d.ts +18 -18
  52. package/dist/common/consts/config.d.ts +9 -9
  53. package/dist/common/consts/contracts.d.ts +43 -34
  54. package/dist/common/consts/ipfs.d.ts +2 -2
  55. package/dist/common/consts/order.d.ts +1 -0
  56. package/dist/common/consts/path.d.ts +1 -1
  57. package/dist/common/consts/tokens.d.ts +9 -9
  58. package/dist/common/generated/CoWShed.d.ts +219 -219
  59. package/dist/common/generated/CoWShedFactory.d.ts +191 -191
  60. package/dist/common/generated/ComposableCoW.d.ts +340 -340
  61. package/dist/common/generated/EthFlow.d.ts +117 -117
  62. package/dist/common/generated/ExtensibleFallbackHandler.d.ts +282 -282
  63. package/dist/common/generated/GPv2Settlement.d.ts +107 -107
  64. package/dist/common/generated/TWAP.d.ts +141 -141
  65. package/dist/common/generated/common.d.ts +21 -21
  66. package/dist/common/generated/factories/CoWShedFactory__factory.d.ts +250 -250
  67. package/dist/common/generated/factories/CoWShed__factory.d.ts +254 -254
  68. package/dist/common/generated/factories/ComposableCoW__factory.d.ts +475 -475
  69. package/dist/common/generated/factories/EthFlow__factory.d.ts +124 -124
  70. package/dist/common/generated/factories/ExtensibleFallbackHandler__factory.d.ts +389 -389
  71. package/dist/common/generated/factories/GPv2Settlement__factory.d.ts +81 -81
  72. package/dist/common/generated/factories/TWAP__factory.d.ts +260 -260
  73. package/dist/common/generated/factories/index.d.ts +7 -7
  74. package/dist/common/generated/index.d.ts +15 -15
  75. package/dist/common/index.d.ts +12 -10
  76. package/dist/common/types/config.d.ts +70 -70
  77. package/dist/common/types/cow-error.d.ts +4 -4
  78. package/dist/common/types/ethereum.d.ts +5 -5
  79. package/dist/common/types/tokens.d.ts +12 -12
  80. package/dist/common/types/wallets.d.ts +5 -5
  81. package/dist/common/utils/common.d.ts +1 -0
  82. package/dist/common/utils/config.d.ts +4 -4
  83. package/dist/common/utils/log.d.ts +2 -0
  84. package/dist/common/utils/math.d.ts +19 -0
  85. package/dist/common/utils/order.d.ts +4 -0
  86. package/dist/common/utils/serialize.d.ts +1 -1
  87. package/dist/common/utils/wallet.d.ts +3 -3
  88. package/dist/composable/ConditionalOrder.d.ts +206 -206
  89. package/dist/composable/ConditionalOrderFactory.d.ts +19 -19
  90. package/dist/composable/Multiplexer.d.ts +174 -174
  91. package/dist/composable/contracts.d.ts +6 -6
  92. package/dist/composable/generated/ComposableCoW.d.ts +340 -340
  93. package/dist/composable/generated/ExtensibleFallbackHandler.d.ts +282 -282
  94. package/dist/composable/generated/TWAP.d.ts +141 -141
  95. package/dist/composable/generated/common.d.ts +21 -21
  96. package/dist/composable/generated/factories/ComposableCoW__factory.d.ts +475 -475
  97. package/dist/composable/generated/factories/ExtensibleFallbackHandler__factory.d.ts +389 -389
  98. package/dist/composable/generated/factories/TWAP__factory.d.ts +260 -260
  99. package/dist/composable/generated/factories/index.d.ts +3 -3
  100. package/dist/composable/generated/index.d.ts +7 -7
  101. package/dist/composable/index.d.ts +6 -6
  102. package/dist/composable/orderTypes/Twap.d.ts +242 -242
  103. package/dist/composable/orderTypes/index.d.ts +3 -3
  104. package/dist/composable/orderTypes/test/TestConditionalOrder.d.ts +25 -25
  105. package/dist/composable/types.d.ts +133 -133
  106. package/dist/composable/utils.d.ts +37 -37
  107. package/dist/cow-shed/CowShedSdk.d.ts +74 -69
  108. package/dist/cow-shed/contracts/CoWShedHooks.d.ts +47 -45
  109. package/dist/cow-shed/contracts/utils.d.ts +4 -4
  110. package/dist/cow-shed/index.d.ts +3 -2
  111. package/dist/cow-shed/types.d.ts +17 -17
  112. package/dist/hooks/utils.d.ts +3 -2
  113. package/dist/index-847d9333.js +29 -0
  114. package/dist/index-847d9333.js.map +1 -0
  115. package/dist/index.d.ts +11 -10
  116. package/dist/index.js +4 -4
  117. package/dist/index.js.map +1 -1
  118. package/dist/index.modern.mjs +1 -1
  119. package/dist/index.module.js +4 -4
  120. package/dist/index.module.js.map +1 -1
  121. package/dist/order-book/api.d.ts +235 -235
  122. package/dist/order-book/generated/index.d.ts +55 -55
  123. package/dist/order-book/generated/models/Address.d.ts +4 -4
  124. package/dist/order-book/generated/models/AppData.d.ts +7 -7
  125. package/dist/order-book/generated/models/AppDataHash.d.ts +6 -6
  126. package/dist/order-book/generated/models/AppDataObject.d.ts +7 -7
  127. package/dist/order-book/generated/models/Auction.d.ts +30 -30
  128. package/dist/order-book/generated/models/AuctionOrder.d.ts +92 -92
  129. package/dist/order-book/generated/models/AuctionPrices.d.ts +6 -6
  130. package/dist/order-book/generated/models/BigUint.d.ts +4 -4
  131. package/dist/order-book/generated/models/BuyTokenDestination.d.ts +7 -7
  132. package/dist/order-book/generated/models/CallData.d.ts +4 -4
  133. package/dist/order-book/generated/models/CompetitionAuction.d.ts +14 -14
  134. package/dist/order-book/generated/models/CompetitionOrderStatus.d.ts +29 -29
  135. package/dist/order-book/generated/models/EcdsaSignature.d.ts +4 -4
  136. package/dist/order-book/generated/models/EcdsaSigningScheme.d.ts +7 -7
  137. package/dist/order-book/generated/models/EthflowData.d.ts +20 -20
  138. package/dist/order-book/generated/models/ExecutedAmounts.d.ts +5 -5
  139. package/dist/order-book/generated/models/ExecutedProtocolFee.d.ts +8 -8
  140. package/dist/order-book/generated/models/FeePolicy.d.ts +7 -7
  141. package/dist/order-book/generated/models/InteractionData.d.ts +11 -11
  142. package/dist/order-book/generated/models/NativePriceResponse.d.ts +10 -10
  143. package/dist/order-book/generated/models/OnchainOrderData.d.ts +24 -24
  144. package/dist/order-book/generated/models/Order.d.ts +3 -3
  145. package/dist/order-book/generated/models/OrderCancellation.d.ts +14 -14
  146. package/dist/order-book/generated/models/OrderCancellationError.d.ts +15 -15
  147. package/dist/order-book/generated/models/OrderCancellations.d.ts +18 -18
  148. package/dist/order-book/generated/models/OrderClass.d.ts +8 -8
  149. package/dist/order-book/generated/models/OrderCreation.d.ts +80 -80
  150. package/dist/order-book/generated/models/OrderKind.d.ts +7 -7
  151. package/dist/order-book/generated/models/OrderMetaData.d.ts +100 -100
  152. package/dist/order-book/generated/models/OrderParameters.d.ts +53 -53
  153. package/dist/order-book/generated/models/OrderPostError.d.ts +35 -35
  154. package/dist/order-book/generated/models/OrderQuoteRequest.d.ts +58 -58
  155. package/dist/order-book/generated/models/OrderQuoteResponse.d.ts +27 -27
  156. package/dist/order-book/generated/models/OrderQuoteSide.d.ts +26 -26
  157. package/dist/order-book/generated/models/OrderQuoteSideKindBuy.d.ts +3 -3
  158. package/dist/order-book/generated/models/OrderQuoteSideKindSell.d.ts +3 -3
  159. package/dist/order-book/generated/models/OrderQuoteValidity.d.ts +14 -14
  160. package/dist/order-book/generated/models/OrderStatus.d.ts +10 -10
  161. package/dist/order-book/generated/models/PreSignature.d.ts +4 -4
  162. package/dist/order-book/generated/models/PriceEstimationError.d.ts +12 -12
  163. package/dist/order-book/generated/models/PriceImprovement.d.ts +12 -12
  164. package/dist/order-book/generated/models/PriceQuality.d.ts +16 -16
  165. package/dist/order-book/generated/models/Quote.d.ts +19 -19
  166. package/dist/order-book/generated/models/SellTokenSource.d.ts +8 -8
  167. package/dist/order-book/generated/models/Signature.d.ts +6 -6
  168. package/dist/order-book/generated/models/SigningScheme.d.ts +9 -9
  169. package/dist/order-book/generated/models/SolverCompetitionResponse.d.ts +30 -30
  170. package/dist/order-book/generated/models/SolverSettlement.d.ts +47 -47
  171. package/dist/order-book/generated/models/Surplus.d.ts +7 -7
  172. package/dist/order-book/generated/models/TokenAmount.d.ts +4 -4
  173. package/dist/order-book/generated/models/TotalSurplus.d.ts +10 -10
  174. package/dist/order-book/generated/models/Trade.d.ts +57 -57
  175. package/dist/order-book/generated/models/TransactionHash.d.ts +4 -4
  176. package/dist/order-book/generated/models/UID.d.ts +8 -8
  177. package/dist/order-book/generated/models/Volume.d.ts +6 -6
  178. package/dist/order-book/index.d.ts +5 -5
  179. package/dist/order-book/mock.d.ts +63 -63
  180. package/dist/order-book/quoteAmountsAndCostsUtils.d.ts +35 -22
  181. package/dist/order-book/request.d.ts +49 -49
  182. package/dist/order-book/transformOrder.d.ts +10 -10
  183. package/dist/order-book/types.d.ts +74 -74
  184. package/dist/order-signing/index.d.ts +2 -2
  185. package/dist/order-signing/orderSigningUtils.d.ts +97 -97
  186. package/dist/order-signing/types.d.ts +55 -55
  187. package/dist/order-signing/utils.d.ts +49 -49
  188. package/dist/package.json +31 -32
  189. package/dist/schemas/trading/LimitOrderAdvancedSettings.ts +151 -12
  190. package/dist/schemas/trading/LimitTradeParameters.ts +136 -15
  191. package/dist/schemas/trading/QuoteResultsSerialized.ts +292 -27
  192. package/dist/schemas/trading/QuoterParameters.ts +10 -0
  193. package/dist/schemas/trading/SwapAdvancedSettings.ts +331 -12
  194. package/dist/schemas/trading/TradeParameters.ts +136 -15
  195. package/dist/src/trading/README.md +99 -7
  196. package/dist/subgraph/api.d.ts +77 -77
  197. package/dist/subgraph/graphql.d.ts +3203 -3203
  198. package/dist/subgraph/index.d.ts +1 -1
  199. package/dist/subgraph/queries.d.ts +14 -14
  200. package/dist/test/utils.d.ts +1 -0
  201. package/dist/trading/appDataUtils.d.ts +5 -4
  202. package/dist/trading/calculateUniqueOrderId.d.ts +5 -5
  203. package/dist/trading/consts.d.ts +6 -14
  204. package/dist/trading/getEthFlowTransaction.d.ts +12 -7
  205. package/dist/trading/getOrderToSign.d.ts +11 -8
  206. package/dist/trading/getOrderTypedData.d.ts +4 -4
  207. package/dist/trading/getPreSignTransaction.d.ts +4 -4
  208. package/dist/trading/getQuote.d.ts +26 -14
  209. package/dist/trading/index.d.ts +21 -19
  210. package/dist/trading/postCoWProtocolTrade.d.ts +4 -4
  211. package/dist/trading/postLimitOrder.d.ts +3 -3
  212. package/dist/trading/postSellNativeCurrencyOrder.d.ts +4 -7
  213. package/dist/trading/postSwapOrder.d.ts +5 -5
  214. package/dist/trading/suggestSlippageBps.d.ts +13 -0
  215. package/dist/trading/suggestSlippageFromFee.d.ts +19 -0
  216. package/dist/trading/suggestSlippageFromVolume.d.ts +10 -0
  217. package/dist/trading/tradingSdk.d.ts +26 -26
  218. package/dist/trading/types.d.ts +221 -190
  219. package/dist/trading/utils/getPartnerFeeBps.d.ts +2 -0
  220. package/dist/trading/{utils.d.ts → utils/misc.d.ts} +27 -27
  221. package/dist/trading/utils/slippage.d.ts +16 -0
  222. package/dist/utils-09dadb80.js +2 -0
  223. package/dist/utils-09dadb80.js.map +1 -0
  224. package/dist/utils-0ff3f95e.js +2 -0
  225. package/dist/utils-0ff3f95e.js.map +1 -0
  226. package/dist/utils-ddcfac77.js +2 -0
  227. package/dist/utils-ddcfac77.js.map +1 -0
  228. package/dist/utils.d.ts +3 -3
  229. package/dist/weiroll/index.d.ts +23 -23
  230. package/package.json +31 -32
  231. package/dist/bridging/BridgingSdk/getErc20Decimals.d.ts +0 -4
  232. package/dist/bridging/BridgingSdk/getQuoteWithBridging.d.ts +0 -9
  233. package/dist/index-317c25f1.js +0 -29
  234. package/dist/index-317c25f1.js.map +0 -1
  235. package/dist/utils-204a9cbe.js +0 -2
  236. package/dist/utils-204a9cbe.js.map +0 -1
  237. package/dist/utils-762ee9c3.js +0 -2
  238. package/dist/utils-762ee9c3.js.map +0 -1
  239. package/dist/utils-de2eb543.js +0 -2
  240. package/dist/utils-de2eb543.js.map +0 -1
@@ -1,251 +1,323 @@
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, OrderKind } from '../order-book';
5
- import { EvmCall } from '../common/types/ethereum';
6
- import { QuoteAndPost, QuoteResults, QuoterParameters, TradeOptionalParameters, TraderParameters } from '../trading';
7
- import { Signer } from '@ethersproject/abstract-signer';
8
- export interface BridgeProviderInfo {
9
- name: string;
10
- logoUrl: string;
11
- }
12
- export interface GetBuyTokensParams extends Partial<WithSellToken> {
13
- targetChainId: TargetChainId;
14
- }
15
- interface WithSellToken {
16
- sellTokenChainId: SupportedChainId;
17
- sellTokenAddress: Address;
18
- sellTokenDecimals: number;
19
- }
20
- interface WithBuyToken {
21
- buyTokenChainId: TargetChainId;
22
- buyTokenAddress: Address;
23
- buyTokenDecimals: number;
24
- }
25
- type WithQuoter = Omit<QuoterParameters, 'chainId'>;
26
- type WithTrader = Pick<TraderParameters, 'signer'>;
27
- /**
28
- * Parameters for getting a bridge quote
29
- */
30
- export type QuoteBridgeRequest = {
31
- kind: OrderKind.SELL;
32
- amount: bigint;
33
- } & WithSellToken & WithBuyToken & WithQuoter & WithTrader & TradeOptionalParameters;
34
- export type QuoteBridgeRequestWithoutAmount = Omit<QuoteBridgeRequest, 'amount'>;
35
- export interface BridgeQuoteResult {
36
- /**
37
- * Whether the quote is a sell or buy order.
38
- */
39
- isSell: boolean;
40
- /**
41
- * Costs and amounts of the bridging.
42
- */
43
- amountsAndCosts: BridgeQuoteAmountsAndCosts;
44
- /**
45
- * The estimated time in seconds it takes to fill the order.
46
- */
47
- expectedFillTimeSeconds?: number;
48
- /**
49
- * The timestamp of the quote.
50
- */
51
- quoteTimestamp: number;
52
- }
53
- export interface BridgeHook {
54
- postHook: latestAppData.CoWHook;
55
- recipient: string;
56
- }
57
- export declare enum BridgeStatus {
58
- NOT_INITIATED = "not_initiated",
59
- IN_PROGRESS = "in_progress",
60
- EXECUTED = "executed",
61
- FAILED = "failed",
62
- EXPIRED = "expired"
63
- }
64
- export interface BridgeStatusResult {
65
- status: BridgeStatus;
66
- fillTimeInSeconds?: number;
67
- }
68
- /**
69
- * A bridge deposit. It includes the provideer information, sell amount and the minimum buy amount.
70
- *
71
- * It models the minimal information for a bridging order.
72
- *
73
- */
74
- export interface BridgeDeposit extends Omit<QuoteBridgeRequest, 'amount'> {
75
- readonly provider: BridgeProviderInfo;
76
- sellTokenAmount: string;
77
- minBuyAmount: string;
78
- }
79
- export interface BridgeProvider<Q extends BridgeQuoteResult> {
80
- info: BridgeProviderInfo;
81
- /**
82
- * Get basic supported chains
83
- */
84
- getNetworks(): Promise<ChainInfo[]>;
85
- /**
86
- * Get supported tokens for a chain
87
- */
88
- getBuyTokens(chainId: GetBuyTokensParams): Promise<TokenInfo[]>;
89
- /**
90
- * Get intermediate tokens given a quote request.
91
- *
92
- * An intermediate token, is a token in the source chain, that could be used to bridge the tokens to the destination chain.
93
- * This method returns a sorted list of tokens, they are sorted by priority, so first tokens are more likely to be more liquid.
94
- *
95
- * @param request - The quote request
96
- */
97
- getIntermediateTokens(request: QuoteBridgeRequest): Promise<string[]>;
98
- /**
99
- * Get a quote for a bridge request.
100
- *
101
- * @param request - The quote request
102
- */
103
- getQuote(request: QuoteBridgeRequest): Promise<Q>;
104
- /**
105
- * Get an unsigned bridge call for a quote.
106
- *
107
- * The transaction details should be executed in the context of cow-shed account.
108
- *
109
- * @param request - The quote request
110
- * @param quote - The quote
111
- * @returns The unsigned transaction details that cow-shed needs to sign
112
- */
113
- getUnsignedBridgeCall(request: QuoteBridgeRequest, quote: Q): Promise<EvmCall>;
114
- /**
115
- * Returns the estimated gas cost for executing the bridge hook.
116
- *
117
- * This method helps calculate the final amount of tokens the user will receive more accurately.
118
- * The estimation is done without the amount parameter to break a circular dependency:
119
- * 1. Hook gas costs affect the final amount
120
- * 2. The final amount could affect hook gas costs
121
- *
122
- * By estimating gas costs independently, we can resolve this dependency cycle.
123
- */
124
- getGasLimitEstimationForHook(request: Omit<QuoteBridgeRequest, 'amount'>): number;
125
- /**
126
- * Get a pre-authorized hook for initiating a bridge.
127
- *
128
- * The hook contains the ethereum call that the trampoline contract will need to execute during the settlement to initate the bridge.
129
- *
130
- * Typically, this hook will:
131
- * - Get the balance of cow-shed account
132
- * - Ensure the approval for the bridge lock contract is set
133
- * - Deposit into the bridge contract
134
- *
135
- * This hook will include the pre-authorization (signature) of the owner of the cow-shed account (the trader).
136
- *
137
- * @param unsignedCall
138
- * @param signer
139
- */
140
- getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, signer: Signer): Promise<BridgeHook>;
141
- /**
142
- * Decode a bridge hook into a bridge deposit information.
143
- *
144
- * This method is used to recover the information about the limit order placed into the bridge locking contract.
145
- * 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.
146
- *
147
- * @param hook - The bridge hook
148
- */
149
- decodeBridgeHook(hook: BridgeHook): Promise<BridgeDeposit>;
150
- /**
151
- * Get the identifier of the bridging transaction from the settlement transaction.
152
- * @param orderUid - The unique identifier of the order
153
- * @param settlementTx - The settlement transaction in which the bridging post-hook was executed
154
- */
155
- getBridgingId(orderUid: string, settlementTx: string): Promise<string>;
156
- /**
157
- * Get the explorer url for a bridging id.
158
- *
159
- * @param bridgingId - The bridging id
160
- */
161
- getExplorerUrl(bridgingId: string): string;
162
- /**
163
- * Get the status of a bridging transaction.
164
- *
165
- * @param bridgingId - The bridging id
166
- */
167
- getStatus(bridgingId: string): Promise<BridgeStatusResult>;
168
- getCancelBridgingTx(bridgingId: string): Promise<EvmCall>;
169
- getRefundBridgingTx(bridgingId: string): Promise<EvmCall>;
170
- }
171
- /**
172
- * A quote and post for a cross-chain swap.
173
- *
174
- * If the order happens in a single chain, it returns the quote and post details for CoW Protocol.
175
- * If the order happens in multiple chains, it returns the quote and post details for CoW Protocol, the bridging
176
- * details, and a summary of the overall multi-step order.
177
- */
178
- export type CrossChainQuoteAndPost = QuoteAndPost | BridgeQuoteAndPost;
179
- export interface BridgeQuoteAndPost {
180
- /**
181
- * The quote results for the CoW Protocol order.
182
- */
183
- swap: QuoteResults;
184
- /**
185
- * The quote results for the bridging.
186
- *
187
- * Includes the bridging details.
188
- */
189
- bridge: BridgeQuoteResults;
190
- /**
191
- * Callback to post the swap order.
192
- */
193
- postSwapOrderFromQuote(): Promise<string>;
194
- }
195
- export interface BridgeCosts<T = bigint> {
196
- bridgingFee: {
197
- feeBps: number;
198
- amountInSellCurrency: T;
199
- amountInBuyCurrency: T;
200
- };
201
- }
202
- export interface BridgeQuoteAmountsAndCosts<T = bigint> {
203
- /**
204
- * Costs of the bridging.
205
- */
206
- costs: BridgeCosts<T>;
207
- /**
208
- * Amounts before fees
209
- */
210
- beforeFee: Amounts<T>;
211
- /**
212
- * Amounts after fees.
213
- */
214
- afterFee: Amounts<T>;
215
- /**
216
- * Amounts after slippage tolerance.
217
- *
218
- * It includes the fees and the slippage tolerance, so its the minimum amount that the user will receive.
219
- */
220
- afterSlippage: Amounts<T>;
221
- /**
222
- * The slippage tolerance in basis points.
223
- */
224
- slippageBps: number;
225
- }
226
- export interface BridgeQuoteResults extends BridgeQuoteResult {
227
- /**
228
- * Bridge provider information
229
- */
230
- providerInfo: BridgeProviderInfo;
231
- /**
232
- * Trade parameters
233
- */
234
- tradeParameters: QuoteBridgeRequest;
235
- /**
236
- * Bridge call details
237
- */
238
- bridgeCallDetails: {
239
- /**
240
- * Unsigned call to initiate the bridge. This call should be executed in the context of user's cow-shed account.
241
- */
242
- unsignedBridgeCall: EvmCall;
243
- /**
244
- * Pre-authorized hook to initiate the bridge. This hook has been signed, and is ready to be executed by the
245
- * CoW Protocol Trampoline contract after settling the swap order that buys the intermediate token.
246
- */
247
- preAuthorizedBridgingHook: BridgeHook;
248
- };
249
- }
250
- export type GetErc20Decimals = (chainId: TargetChainId, tokenAddress: string) => Promise<number>;
251
- export {};
1
+ import { latest as latestAppData } from '@cowprotocol/app-data';
2
+ import { ChainId, 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, SigningStepManager, SwapAdvancedSettings, TradeOptionalParameters, TraderParameters } from '../trading';
8
+ import { Signer } from '@ethersproject/abstract-signer';
9
+ import { JsonRpcProvider } from '@ethersproject/providers';
10
+ export interface BridgeProviderInfo {
11
+ name: string;
12
+ logoUrl: string;
13
+ dappId: string;
14
+ website: string;
15
+ }
16
+ interface WithSellToken {
17
+ sellTokenChainId: SupportedChainId;
18
+ sellTokenAddress: Address;
19
+ sellTokenDecimals: number;
20
+ }
21
+ interface WithBuyToken {
22
+ buyTokenChainId: TargetChainId;
23
+ buyTokenAddress: Address;
24
+ buyTokenDecimals: number;
25
+ }
26
+ type WithQuoter = Omit<QuoterParameters, 'chainId'>;
27
+ type WithTrader = Pick<TraderParameters, 'signer'>;
28
+ /**
29
+ * Parameters for getting a bridge quote
30
+ */
31
+ export type QuoteBridgeRequest = {
32
+ kind: OrderKind;
33
+ amount: bigint;
34
+ owner?: AccountAddress;
35
+ } & WithSellToken & WithBuyToken & WithQuoter & WithTrader & TradeOptionalParameters;
36
+ export type QuoteBridgeRequestWithoutAmount = Omit<QuoteBridgeRequest, 'amount'>;
37
+ export interface BridgeQuoteResult {
38
+ /**
39
+ * Whether the quote is a sell or buy order.
40
+ */
41
+ isSell: boolean;
42
+ /**
43
+ * Costs and amounts of the bridging.
44
+ */
45
+ amountsAndCosts: BridgeQuoteAmountsAndCosts;
46
+ /**
47
+ * The estimated time in seconds it takes to fill the order.
48
+ */
49
+ expectedFillTimeSeconds?: number;
50
+ /**
51
+ * The timestamp of the quote.
52
+ */
53
+ quoteTimestamp: number;
54
+ fees: {
55
+ /**
56
+ * The amount that should go to the relayer as a fee to cover relayer capital costs.
57
+ * In token atoms.
58
+ */
59
+ bridgeFee: bigint;
60
+ /**
61
+ * The amount that should go to the relayer as a fee to cover relayer gas costs.
62
+ * In token atoms.
63
+ */
64
+ destinationGasFee: bigint;
65
+ };
66
+ limits: {
67
+ /**
68
+ * The minimum amount that should be deposited in the source chain.
69
+ * In token atoms.
70
+ */
71
+ minDeposit: bigint;
72
+ /**
73
+ * The maximum amount that can be deposited in the source chain.
74
+ * In token atoms.
75
+ */
76
+ maxDeposit: bigint;
77
+ };
78
+ }
79
+ export interface BridgeHook {
80
+ postHook: latestAppData.CoWHook;
81
+ recipient: string;
82
+ }
83
+ export declare enum BridgeStatus {
84
+ IN_PROGRESS = "in_progress",
85
+ EXECUTED = "executed",
86
+ EXPIRED = "expired",
87
+ REFUND = "refund",
88
+ UNKNOWN = "unknown"
89
+ }
90
+ export interface BridgeStatusResult {
91
+ status: BridgeStatus;
92
+ fillTimeInSeconds?: number;
93
+ /**
94
+ * Transaction hash of the deposit on the origin chain.
95
+ */
96
+ depositTxHash?: string;
97
+ /**
98
+ * Transaction hash of the fill on the destination chain.
99
+ * Only present when fillStatus is 'filled'.
100
+ */
101
+ fillTxHash?: string;
102
+ }
103
+ /**
104
+ * When sellChainId and/or sellTokenAddress are specified
105
+ * then the buy tokens list will be additionally filtered
106
+ */
107
+ export interface BuyTokensParams {
108
+ buyChainId: TargetChainId;
109
+ sellChainId?: SupportedChainId;
110
+ sellTokenAddress?: string;
111
+ }
112
+ /**
113
+ * A bridge deposit. It includes the provideer information, sell amount and the minimum buy amount.
114
+ *
115
+ * It models the minimal information for a bridging order.
116
+ *
117
+ */
118
+ export interface BridgeDeposit extends Omit<QuoteBridgeRequest, 'amount'> {
119
+ readonly provider: BridgeProviderInfo;
120
+ sellTokenAmount: string;
121
+ minBuyAmount: string;
122
+ }
123
+ export interface BridgeProvider<Q extends BridgeQuoteResult> {
124
+ info: BridgeProviderInfo;
125
+ getRpcProvider(chainId: SupportedChainId): JsonRpcProvider;
126
+ /**
127
+ * Get basic supported chains
128
+ */
129
+ getNetworks(): Promise<ChainInfo[]>;
130
+ /**
131
+ * Get supported tokens for a chain
132
+ */
133
+ getBuyTokens(params: BuyTokensParams): Promise<TokenInfo[]>;
134
+ /**
135
+ * Get intermediate tokens given a quote request.
136
+ *
137
+ * An intermediate token, is a token in the source chain, that could be used to bridge the tokens to the destination chain.
138
+ * This method returns a sorted list of tokens, they are sorted by priority, so first tokens are more likely to be more liquid.
139
+ *
140
+ * @param request - The quote request
141
+ */
142
+ getIntermediateTokens(request: QuoteBridgeRequest): Promise<TokenInfo[]>;
143
+ /**
144
+ * Get a quote for a bridge request.
145
+ *
146
+ * @param request - The quote request
147
+ */
148
+ getQuote(request: QuoteBridgeRequest): Promise<Q>;
149
+ /**
150
+ * Get an unsigned bridge call for a quote.
151
+ *
152
+ * The transaction details should be executed in the context of cow-shed account.
153
+ *
154
+ * @param request - The quote request
155
+ * @param quote - The quote
156
+ * @returns The unsigned transaction details that cow-shed needs to sign
157
+ */
158
+ getUnsignedBridgeCall(request: QuoteBridgeRequest, quote: Q): Promise<EvmCall>;
159
+ /**
160
+ * Returns the estimated gas cost for executing the bridge hook.
161
+ *
162
+ * This method helps calculate the final amount of tokens the user will receive more accurately.
163
+ * The estimation is done without the amount parameter to break a circular dependency:
164
+ * 1. Hook gas costs affect the final amount
165
+ * 2. The final amount could affect hook gas costs
166
+ *
167
+ * By estimating gas costs independently, we can resolve this dependency cycle.
168
+ */
169
+ getGasLimitEstimationForHook(request: Omit<QuoteBridgeRequest, 'amount'>): Promise<number>;
170
+ /**
171
+ * Get a pre-authorized hook for initiating a bridge.
172
+ *
173
+ * The hook contains the ethereum call that the trampoline contract will need to execute during the settlement to initate the bridge.
174
+ *
175
+ * Typically, this hook will:
176
+ * - Get the balance of cow-shed account
177
+ * - Ensure the approval for the bridge lock contract is set
178
+ * - Deposit into the bridge contract
179
+ *
180
+ * This hook will include the pre-authorization (signature) of the owner of the cow-shed account (the trader).
181
+ */
182
+ getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, signer: Signer, bridgeHookNonce: string, deadline: bigint, hookGasLimit: number): Promise<BridgeHook>;
183
+ /**
184
+ * Decode a bridge hook into a bridge deposit information.
185
+ *
186
+ * This method is used to recover the information about the limit order placed into the bridge locking contract.
187
+ * 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.
188
+ *
189
+ * @param hook - The bridge hook
190
+ */
191
+ decodeBridgeHook(hook: latestAppData.CoWHook): Promise<BridgeDeposit>;
192
+ /**
193
+ * Get the identifier of the bridging transaction from the settlement transaction.
194
+ * @param chainId
195
+ * @param orderUid - The unique identifier of the order
196
+ * @param txHash - The hash of the settlement transaction in which the bridging post-hook was executed
197
+ */
198
+ getBridgingParams(chainId: ChainId, orderUid: string, txHash: string): Promise<{
199
+ params: BridgingDepositParams;
200
+ status: BridgeStatusResult;
201
+ } | null>;
202
+ /**
203
+ * Get the explorer url for a bridging id.
204
+ *
205
+ * @param bridgingId - The bridging id
206
+ */
207
+ getExplorerUrl(bridgingId: string): string;
208
+ /**
209
+ * Get the status of a bridging transaction.
210
+ *
211
+ * @param bridgingId - The bridging id
212
+ * @param originChainId - id of network where funds were deposited
213
+ */
214
+ getStatus(bridgingId: string, originChainId: SupportedChainId): Promise<BridgeStatusResult>;
215
+ getCancelBridgingTx(bridgingId: string): Promise<EvmCall>;
216
+ getRefundBridgingTx(bridgingId: string): Promise<EvmCall>;
217
+ }
218
+ /**
219
+ * A quote and post for a cross-chain swap.
220
+ *
221
+ * If the order happens in a single chain, it returns the quote and post details for CoW Protocol.
222
+ * If the order happens in multiple chains, it returns the quote and post details for CoW Protocol, the bridging
223
+ * details, and a summary of the overall multi-step order.
224
+ */
225
+ export type CrossChainQuoteAndPost = QuoteAndPost | BridgeQuoteAndPost;
226
+ export interface BridgeQuoteAndPost {
227
+ /**
228
+ * The quote results for the CoW Protocol order.
229
+ */
230
+ swap: QuoteResults;
231
+ /**
232
+ * The quote results for the bridging.
233
+ *
234
+ * Includes the bridging details.
235
+ */
236
+ bridge: BridgeQuoteResults;
237
+ /**
238
+ * Callback to post the swap order.
239
+ */
240
+ postSwapOrderFromQuote(advancedSettings?: SwapAdvancedSettings, signingStepManager?: SigningStepManager): Promise<OrderPostingResult>;
241
+ }
242
+ export interface BridgeCosts<T = bigint> {
243
+ bridgingFee: {
244
+ feeBps: number;
245
+ amountInSellCurrency: T;
246
+ amountInBuyCurrency: T;
247
+ };
248
+ }
249
+ export interface BridgeQuoteAmountsAndCosts<T = bigint> {
250
+ /**
251
+ * Costs of the bridging.
252
+ */
253
+ costs: BridgeCosts<T>;
254
+ /**
255
+ * Amounts before fees
256
+ */
257
+ beforeFee: Amounts<T>;
258
+ /**
259
+ * Amounts after fees.
260
+ */
261
+ afterFee: Amounts<T>;
262
+ /**
263
+ * Amounts after slippage tolerance.
264
+ *
265
+ * It includes the fees and the slippage tolerance, so its the minimum amount that the user will receive.
266
+ */
267
+ afterSlippage: Amounts<T>;
268
+ /**
269
+ * The slippage tolerance in basis points.
270
+ */
271
+ slippageBps: number;
272
+ }
273
+ /**
274
+ * Details about the bridge call.
275
+ */
276
+ export interface BridgeCallDetails {
277
+ /**
278
+ * Unsigned call to initiate the bridge. This call should be executed in the context of user's cow-shed account.
279
+ */
280
+ unsignedBridgeCall: EvmCall;
281
+ /**
282
+ * Pre-authorized hook to initiate the bridge. This hook has been signed, and is ready to be executed by the
283
+ * CoW Protocol Trampoline contract after settling the swap order that buys the intermediate token.
284
+ */
285
+ preAuthorizedBridgingHook: BridgeHook;
286
+ }
287
+ export interface BridgeQuoteResults extends BridgeQuoteResult {
288
+ /**
289
+ * Bridge provider information
290
+ */
291
+ providerInfo: BridgeProviderInfo;
292
+ /**
293
+ * Trade parameters
294
+ */
295
+ tradeParameters: QuoteBridgeRequest;
296
+ /**
297
+ * Bridge call details
298
+ */
299
+ bridgeCallDetails: BridgeCallDetails;
300
+ }
301
+ export interface BridgingDepositParams {
302
+ inputTokenAddress: Address;
303
+ outputTokenAddress: Address;
304
+ inputAmount: bigint;
305
+ outputAmount: bigint | null;
306
+ owner: Address;
307
+ quoteTimestamp: number | null;
308
+ fillDeadline: number | null;
309
+ recipient: Address;
310
+ sourceChainId: number;
311
+ destinationChainId: number;
312
+ bridgingId: string;
313
+ }
314
+ export interface CrossChainOrder {
315
+ provider: BridgeProvider<BridgeQuoteResult>;
316
+ chainId: SupportedChainId;
317
+ order: EnrichedOrder;
318
+ statusResult: BridgeStatusResult;
319
+ bridgingParams: BridgingDepositParams;
320
+ tradeTxHash: string;
321
+ explorerUrl?: string;
322
+ }
323
+ export {};
@@ -1,6 +1,9 @@
1
- import { QuoteAndPost } from '../trading';
2
- import { BridgeQuoteAndPost, CrossChainQuoteAndPost } from './types';
3
- export declare function isBridgeQuoteAndPost(quote: CrossChainQuoteAndPost): quote is BridgeQuoteAndPost;
4
- export declare function isQuoteAndPost(quote: CrossChainQuoteAndPost): quote is QuoteAndPost;
5
- export declare function assertIsBridgeQuoteAndPost(quote: CrossChainQuoteAndPost): asserts quote is BridgeQuoteAndPost;
6
- export declare function assertIsQuoteAndPost(quote: CrossChainQuoteAndPost): asserts quote is QuoteAndPost;
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;
@@ -1,25 +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[];
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[];
@@ -1 +1 @@
1
- export declare const RAW_CHAINS_FILES_PATH: string;
1
+ export declare const RAW_CHAINS_FILES_PATH = "https://raw.githubusercontent.com/cowprotocol/cow-sdk/refs/heads/main/src/chains";