@cowprotocol/cow-sdk 6.3.2-RC.2 → 7.0.0-beta.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 (246) hide show
  1. package/README.md +276 -192
  2. package/dist/CHANGELOG.md +24 -0
  3. package/dist/README.md +276 -192
  4. package/dist/index.d.mts +73 -0
  5. package/dist/index.d.ts +73 -11
  6. package/dist/index.js +86 -27
  7. package/dist/index.mjs +49 -0
  8. package/dist/package.json +71 -91
  9. package/package.json +71 -91
  10. package/LICENSE-APACHE +0 -201
  11. package/LICENSE-MIT +0 -21
  12. package/dist/COPYRIGHT.md +0 -13
  13. package/dist/bridging/BridgingSdk/BridgingSdk.d.ts +0 -87
  14. package/dist/bridging/BridgingSdk/findBridgeProviderFromHook.d.ts +0 -2
  15. package/dist/bridging/BridgingSdk/getBridgeSignedHook.d.ts +0 -8
  16. package/dist/bridging/BridgingSdk/getCrossChainOrder.d.ts +0 -16
  17. package/dist/bridging/BridgingSdk/getQuoteWithBridge.d.ts +0 -3
  18. package/dist/bridging/BridgingSdk/getQuoteWithoutBridge.d.ts +0 -7
  19. package/dist/bridging/BridgingSdk/mock/bridgeRequestMocks.d.ts +0 -21
  20. package/dist/bridging/BridgingSdk/types.d.ts +0 -43
  21. package/dist/bridging/const.d.ts +0 -6
  22. package/dist/bridging/errors.d.ts +0 -22
  23. package/dist/bridging/index.d.ts +0 -8
  24. package/dist/bridging/providers/across/AcrossApi.d.ts +0 -30
  25. package/dist/bridging/providers/across/AcrossBridgeProvider.d.ts +0 -44
  26. package/dist/bridging/providers/across/abi.d.ts +0 -154
  27. package/dist/bridging/providers/across/const/contracts.d.ts +0 -3
  28. package/dist/bridging/providers/across/const/interfaces.d.ts +0 -3
  29. package/dist/bridging/providers/across/const/misc.d.ts +0 -2
  30. package/dist/bridging/providers/across/const/tokens.d.ts +0 -11
  31. package/dist/bridging/providers/across/createAcrossDepositCall.d.ts +0 -9
  32. package/dist/bridging/providers/across/getDepositParams.d.ts +0 -4
  33. package/dist/bridging/providers/across/types.d.ts +0 -242
  34. package/dist/bridging/providers/across/util.d.ts +0 -43
  35. package/dist/bridging/providers/bungee/BungeeApi.d.ts +0 -67
  36. package/dist/bridging/providers/bungee/BungeeBridgeProvider.d.ts +0 -45
  37. package/dist/bridging/providers/bungee/abi.d.ts +0 -203
  38. package/dist/bridging/providers/bungee/const/contracts.d.ts +0 -4
  39. package/dist/bridging/providers/bungee/const/misc.d.ts +0 -8
  40. package/dist/bridging/providers/bungee/createBungeeDepositCall.d.ts +0 -7
  41. package/dist/bridging/providers/bungee/getBridgingStatusFromEvents.d.ts +0 -3
  42. package/dist/bridging/providers/bungee/types.d.ts +0 -268
  43. package/dist/bridging/providers/bungee/util.d.ts +0 -62
  44. package/dist/bridging/providers/mock/MockBridgeProvider.d.ts +0 -26
  45. package/dist/bridging/providers/utils/getGasLimitEstimationForHook.d.ts +0 -10
  46. package/dist/bridging/types.d.ts +0 -333
  47. package/dist/bridging/utils.d.ts +0 -9
  48. package/dist/chains/const/index.d.ts +0 -25
  49. package/dist/chains/const/path.d.ts +0 -1
  50. package/dist/chains/details/arbitrum.d.ts +0 -7
  51. package/dist/chains/details/avalanche.d.ts +0 -2
  52. package/dist/chains/details/base.d.ts +0 -7
  53. package/dist/chains/details/bnb.d.ts +0 -2
  54. package/dist/chains/details/gnosis.d.ts +0 -7
  55. package/dist/chains/details/index.d.ts +0 -10
  56. package/dist/chains/details/lens.d.ts +0 -2
  57. package/dist/chains/details/mainnet.d.ts +0 -7
  58. package/dist/chains/details/optimism.d.ts +0 -2
  59. package/dist/chains/details/polygon.d.ts +0 -2
  60. package/dist/chains/details/sepolia.d.ts +0 -7
  61. package/dist/chains/index.d.ts +0 -4
  62. package/dist/chains/types.d.ts +0 -133
  63. package/dist/chains/utils.d.ts +0 -19
  64. package/dist/common/consts/config.d.ts +0 -9
  65. package/dist/common/consts/contracts.d.ts +0 -45
  66. package/dist/common/consts/ipfs.d.ts +0 -2
  67. package/dist/common/consts/order.d.ts +0 -1
  68. package/dist/common/consts/path.d.ts +0 -1
  69. package/dist/common/consts/tokens.d.ts +0 -9
  70. package/dist/common/generated/CoWShed.d.ts +0 -219
  71. package/dist/common/generated/CoWShedFactory.d.ts +0 -191
  72. package/dist/common/generated/ComposableCoW.d.ts +0 -340
  73. package/dist/common/generated/EthFlow.d.ts +0 -117
  74. package/dist/common/generated/ExtensibleFallbackHandler.d.ts +0 -282
  75. package/dist/common/generated/GPv2Settlement.d.ts +0 -107
  76. package/dist/common/generated/TWAP.d.ts +0 -141
  77. package/dist/common/generated/common.d.ts +0 -21
  78. package/dist/common/generated/factories/CoWShedFactory__factory.d.ts +0 -250
  79. package/dist/common/generated/factories/CoWShed__factory.d.ts +0 -254
  80. package/dist/common/generated/factories/ComposableCoW__factory.d.ts +0 -475
  81. package/dist/common/generated/factories/EthFlow__factory.d.ts +0 -124
  82. package/dist/common/generated/factories/ExtensibleFallbackHandler__factory.d.ts +0 -389
  83. package/dist/common/generated/factories/GPv2Settlement__factory.d.ts +0 -81
  84. package/dist/common/generated/factories/TWAP__factory.d.ts +0 -260
  85. package/dist/common/generated/factories/index.d.ts +0 -7
  86. package/dist/common/generated/index.d.ts +0 -15
  87. package/dist/common/index.d.ts +0 -12
  88. package/dist/common/types/config.d.ts +0 -70
  89. package/dist/common/types/cow-error.d.ts +0 -4
  90. package/dist/common/types/ethereum.d.ts +0 -5
  91. package/dist/common/types/tokens.d.ts +0 -12
  92. package/dist/common/types/wallets.d.ts +0 -5
  93. package/dist/common/utils/common.d.ts +0 -1
  94. package/dist/common/utils/config.d.ts +0 -4
  95. package/dist/common/utils/log.d.ts +0 -2
  96. package/dist/common/utils/math.d.ts +0 -19
  97. package/dist/common/utils/order.d.ts +0 -4
  98. package/dist/common/utils/serialize.d.ts +0 -1
  99. package/dist/common/utils/wallet.d.ts +0 -3
  100. package/dist/composable/ConditionalOrder.d.ts +0 -206
  101. package/dist/composable/ConditionalOrderFactory.d.ts +0 -19
  102. package/dist/composable/Multiplexer.d.ts +0 -174
  103. package/dist/composable/contracts.d.ts +0 -6
  104. package/dist/composable/generated/ComposableCoW.d.ts +0 -340
  105. package/dist/composable/generated/ExtensibleFallbackHandler.d.ts +0 -282
  106. package/dist/composable/generated/TWAP.d.ts +0 -141
  107. package/dist/composable/generated/common.d.ts +0 -21
  108. package/dist/composable/generated/factories/ComposableCoW__factory.d.ts +0 -475
  109. package/dist/composable/generated/factories/ExtensibleFallbackHandler__factory.d.ts +0 -389
  110. package/dist/composable/generated/factories/TWAP__factory.d.ts +0 -260
  111. package/dist/composable/generated/factories/index.d.ts +0 -3
  112. package/dist/composable/generated/index.d.ts +0 -7
  113. package/dist/composable/index.d.ts +0 -6
  114. package/dist/composable/orderTypes/Twap.d.ts +0 -242
  115. package/dist/composable/orderTypes/index.d.ts +0 -3
  116. package/dist/composable/orderTypes/test/TestConditionalOrder.d.ts +0 -25
  117. package/dist/composable/types.d.ts +0 -133
  118. package/dist/composable/utils.d.ts +0 -37
  119. package/dist/cow-shed/CowShedSdk.d.ts +0 -74
  120. package/dist/cow-shed/contracts/CoWShedHooks.d.ts +0 -46
  121. package/dist/cow-shed/contracts/utils.d.ts +0 -4
  122. package/dist/cow-shed/index.d.ts +0 -3
  123. package/dist/cow-shed/types.d.ts +0 -17
  124. package/dist/docs/architecture.md +0 -353
  125. package/dist/examples/cra/README.md +0 -21
  126. package/dist/hooks/utils.d.ts +0 -3
  127. package/dist/index-30eefcb8.js +0 -29
  128. package/dist/index-30eefcb8.js.map +0 -1
  129. package/dist/index.js.map +0 -1
  130. package/dist/index.modern.mjs +0 -2
  131. package/dist/index.modern.mjs.map +0 -1
  132. package/dist/index.module.js +0 -29
  133. package/dist/index.module.js.map +0 -1
  134. package/dist/order-book/api.d.ts +0 -235
  135. package/dist/order-book/generated/index.d.ts +0 -55
  136. package/dist/order-book/generated/models/Address.d.ts +0 -4
  137. package/dist/order-book/generated/models/AppData.d.ts +0 -7
  138. package/dist/order-book/generated/models/AppDataHash.d.ts +0 -6
  139. package/dist/order-book/generated/models/AppDataObject.d.ts +0 -7
  140. package/dist/order-book/generated/models/Auction.d.ts +0 -30
  141. package/dist/order-book/generated/models/AuctionOrder.d.ts +0 -92
  142. package/dist/order-book/generated/models/AuctionPrices.d.ts +0 -6
  143. package/dist/order-book/generated/models/BigUint.d.ts +0 -4
  144. package/dist/order-book/generated/models/BuyTokenDestination.d.ts +0 -7
  145. package/dist/order-book/generated/models/CallData.d.ts +0 -4
  146. package/dist/order-book/generated/models/CompetitionAuction.d.ts +0 -14
  147. package/dist/order-book/generated/models/CompetitionOrderStatus.d.ts +0 -29
  148. package/dist/order-book/generated/models/EcdsaSignature.d.ts +0 -4
  149. package/dist/order-book/generated/models/EcdsaSigningScheme.d.ts +0 -7
  150. package/dist/order-book/generated/models/EthflowData.d.ts +0 -20
  151. package/dist/order-book/generated/models/ExecutedAmounts.d.ts +0 -5
  152. package/dist/order-book/generated/models/ExecutedProtocolFee.d.ts +0 -8
  153. package/dist/order-book/generated/models/FeePolicy.d.ts +0 -7
  154. package/dist/order-book/generated/models/InteractionData.d.ts +0 -11
  155. package/dist/order-book/generated/models/NativePriceResponse.d.ts +0 -10
  156. package/dist/order-book/generated/models/OnchainOrderData.d.ts +0 -24
  157. package/dist/order-book/generated/models/Order.d.ts +0 -3
  158. package/dist/order-book/generated/models/OrderCancellation.d.ts +0 -14
  159. package/dist/order-book/generated/models/OrderCancellationError.d.ts +0 -15
  160. package/dist/order-book/generated/models/OrderCancellations.d.ts +0 -18
  161. package/dist/order-book/generated/models/OrderClass.d.ts +0 -8
  162. package/dist/order-book/generated/models/OrderCreation.d.ts +0 -80
  163. package/dist/order-book/generated/models/OrderKind.d.ts +0 -7
  164. package/dist/order-book/generated/models/OrderMetaData.d.ts +0 -100
  165. package/dist/order-book/generated/models/OrderParameters.d.ts +0 -53
  166. package/dist/order-book/generated/models/OrderPostError.d.ts +0 -35
  167. package/dist/order-book/generated/models/OrderQuoteRequest.d.ts +0 -58
  168. package/dist/order-book/generated/models/OrderQuoteResponse.d.ts +0 -27
  169. package/dist/order-book/generated/models/OrderQuoteSide.d.ts +0 -26
  170. package/dist/order-book/generated/models/OrderQuoteSideKindBuy.d.ts +0 -3
  171. package/dist/order-book/generated/models/OrderQuoteSideKindSell.d.ts +0 -3
  172. package/dist/order-book/generated/models/OrderQuoteValidity.d.ts +0 -14
  173. package/dist/order-book/generated/models/OrderStatus.d.ts +0 -10
  174. package/dist/order-book/generated/models/PreSignature.d.ts +0 -4
  175. package/dist/order-book/generated/models/PriceEstimationError.d.ts +0 -12
  176. package/dist/order-book/generated/models/PriceImprovement.d.ts +0 -12
  177. package/dist/order-book/generated/models/PriceQuality.d.ts +0 -16
  178. package/dist/order-book/generated/models/Quote.d.ts +0 -19
  179. package/dist/order-book/generated/models/SellTokenSource.d.ts +0 -8
  180. package/dist/order-book/generated/models/Signature.d.ts +0 -6
  181. package/dist/order-book/generated/models/SigningScheme.d.ts +0 -9
  182. package/dist/order-book/generated/models/SolverCompetitionResponse.d.ts +0 -30
  183. package/dist/order-book/generated/models/SolverSettlement.d.ts +0 -47
  184. package/dist/order-book/generated/models/Surplus.d.ts +0 -7
  185. package/dist/order-book/generated/models/TokenAmount.d.ts +0 -4
  186. package/dist/order-book/generated/models/TotalSurplus.d.ts +0 -10
  187. package/dist/order-book/generated/models/Trade.d.ts +0 -57
  188. package/dist/order-book/generated/models/TransactionHash.d.ts +0 -4
  189. package/dist/order-book/generated/models/UID.d.ts +0 -8
  190. package/dist/order-book/generated/models/Volume.d.ts +0 -6
  191. package/dist/order-book/index.d.ts +0 -5
  192. package/dist/order-book/mock.d.ts +0 -63
  193. package/dist/order-book/quoteAmountsAndCostsUtils.d.ts +0 -35
  194. package/dist/order-book/request.d.ts +0 -49
  195. package/dist/order-book/transformOrder.d.ts +0 -10
  196. package/dist/order-book/types.d.ts +0 -74
  197. package/dist/order-signing/index.d.ts +0 -2
  198. package/dist/order-signing/orderSigningUtils.d.ts +0 -97
  199. package/dist/order-signing/types.d.ts +0 -55
  200. package/dist/order-signing/utils.d.ts +0 -49
  201. package/dist/schemas/trading/LimitOrderAdvancedSettings.ts +0 -422
  202. package/dist/schemas/trading/LimitTradeParameters.ts +0 -229
  203. package/dist/schemas/trading/QuoteResultsSerialized.ts +0 -1151
  204. package/dist/schemas/trading/QuoterParameters.ts +0 -43
  205. package/dist/schemas/trading/SwapAdvancedSettings.ts +0 -708
  206. package/dist/schemas/trading/TradeParameters.ts +0 -217
  207. package/dist/src/bridging/PROVIDER_README.md +0 -796
  208. package/dist/src/bridging/README.md +0 -718
  209. package/dist/src/cow-shed/README.md +0 -60
  210. package/dist/src/trading/README.md +0 -544
  211. package/dist/src/weiroll/README.md +0 -58
  212. package/dist/subgraph/api.d.ts +0 -77
  213. package/dist/subgraph/graphql.d.ts +0 -3203
  214. package/dist/subgraph/index.d.ts +0 -1
  215. package/dist/subgraph/queries.d.ts +0 -14
  216. package/dist/test/getWallet.d.ts +0 -5
  217. package/dist/test/utils.d.ts +0 -1
  218. package/dist/trading/appDataUtils.d.ts +0 -5
  219. package/dist/trading/calculateUniqueOrderId.d.ts +0 -5
  220. package/dist/trading/consts.d.ts +0 -6
  221. package/dist/trading/getEthFlowTransaction.d.ts +0 -12
  222. package/dist/trading/getOrderToSign.d.ts +0 -11
  223. package/dist/trading/getOrderTypedData.d.ts +0 -4
  224. package/dist/trading/getPreSignTransaction.d.ts +0 -4
  225. package/dist/trading/getQuote.d.ts +0 -26
  226. package/dist/trading/index.d.ts +0 -21
  227. package/dist/trading/postCoWProtocolTrade.d.ts +0 -4
  228. package/dist/trading/postLimitOrder.d.ts +0 -3
  229. package/dist/trading/postSellNativeCurrencyOrder.d.ts +0 -4
  230. package/dist/trading/postSwapOrder.d.ts +0 -5
  231. package/dist/trading/suggestSlippageBps.d.ts +0 -13
  232. package/dist/trading/suggestSlippageFromFee.d.ts +0 -19
  233. package/dist/trading/suggestSlippageFromVolume.d.ts +0 -10
  234. package/dist/trading/tradingSdk.d.ts +0 -26
  235. package/dist/trading/types.d.ts +0 -221
  236. package/dist/trading/utils/getPartnerFeeBps.d.ts +0 -2
  237. package/dist/trading/utils/misc.d.ts +0 -27
  238. package/dist/trading/utils/slippage.d.ts +0 -16
  239. package/dist/utils-9f8a0370.js +0 -2
  240. package/dist/utils-9f8a0370.js.map +0 -1
  241. package/dist/utils-a846dcac.js +0 -2
  242. package/dist/utils-a846dcac.js.map +0 -1
  243. package/dist/utils-ea990520.js +0 -2
  244. package/dist/utils-ea990520.js.map +0 -1
  245. package/dist/utils.d.ts +0 -3
  246. package/dist/weiroll/index.d.ts +0 -23
@@ -1,235 +0,0 @@
1
- import 'cross-fetch/polyfill';
2
- import { ApiBaseUrls, ApiContext, PartialApiContext } from '../common/types/config';
3
- import { Address, AppDataHash, AppDataObject, CompetitionOrderStatus, NativePriceResponse, OrderCancellations, OrderCreation, OrderQuoteRequest, OrderQuoteResponse, SolverCompetitionResponse, TotalSurplus, Trade, TransactionHash, UID } from './generated';
4
- import { EnrichedOrder } from './types';
5
- /**
6
- * An object containing *production* environment base URLs for each supported `chainId`.
7
- * @see {@link https://api.cow.fi/docs/#/}
8
- */
9
- export declare const ORDER_BOOK_PROD_CONFIG: ApiBaseUrls;
10
- /**
11
- * An object containing *staging* environment base URLs for each supported `chainId`.
12
- */
13
- export declare const ORDER_BOOK_STAGING_CONFIG: ApiBaseUrls;
14
- /**
15
- * The parameters for the `getOrders` request.
16
- */
17
- export type GetOrdersRequest = {
18
- owner: Address;
19
- offset?: number;
20
- limit?: number;
21
- };
22
- /**
23
- * The CoW Protocol OrderBook API client.
24
- *
25
- * This is the main entry point for interacting with the CoW Protocol OrderBook API. The main advantage of using
26
- * this client is the batteries-included approach to interacting with the API. It handles:
27
- *
28
- * - Environment configuration (mainnet, staging, etc.)
29
- * - Rate limiting
30
- * - Retries
31
- * - Backoff
32
- * - Error handling
33
- * - Request signing
34
- * - Request validation
35
- *
36
- * @example
37
- *
38
- * ```typescript
39
- * import { OrderBookApi, OrderSigningUtils, SupportedChainId } from '@cowprotocol/cow-sdk'
40
- * import { Web3Provider } from '@ethersproject/providers'
41
- *
42
- * const account = 'YOUR_WALLET_ADDRESS'
43
- * const chainId = 100 // Gnosis chain
44
- * const provider = new Web3Provider(window.ethereum)
45
- * const signer = provider.getSigner()
46
- *
47
- * const quoteRequest = {
48
- * sellToken: '0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1', // WETH gnosis chain
49
- * buyToken: '0x9c58bacc331c9aa871afd802db6379a98e80cedb', // GNO gnosis chain
50
- * from: account,
51
- * receiver: account,
52
- * sellAmountBeforeFee: (0.4 * 10 ** 18).toString(), // 0.4 WETH
53
- * kind: OrderQuoteSide.kind.SELL,
54
- * }
55
- *
56
- * const orderBookApi = new OrderBookApi({ chainId: SupportedChainId.GNOSIS_CHAIN })
57
- *
58
- * async function main() {
59
- * const { quote } = await orderBookApi.getQuote(quoteRequest)
60
- *
61
- * const orderSigningResult = await OrderSigningUtils.signOrder(quote, chainId, signer)
62
- *
63
- * const orderId = await orderBookApi.sendOrder({ ...quote, ...orderSigningResult })
64
- *
65
- * const order = await orderBookApi.getOrder(orderId)
66
- *
67
- * const trades = await orderBookApi.getTrades({ orderId })
68
- *
69
- * const orderCancellationSigningResult = await OrderSigningUtils.signOrderCancellations([orderId], chainId, signer)
70
- *
71
- * const cancellationResult = await orderBookApi.sendSignedOrderCancellations({...orderCancellationSigningResult, orderUids: [orderId] })
72
- *
73
- * console.log('Results: ', { orderId, order, trades, orderCancellationSigningResult, cancellationResult })
74
- * }
75
- * ```
76
- *
77
- * @see {@link Swagger documentation https://api.cow.fi/docs/#/}
78
- * @see {@link OrderBook API https://github.com/cowprotocol/services}
79
- */
80
- export declare class OrderBookApi {
81
- context: ApiContext;
82
- private rateLimiter;
83
- /**
84
- * Creates a new instance of the CoW Protocol OrderBook API client.
85
- * @param context - The API context to use. If not provided, the default context will be used.
86
- */
87
- constructor(context?: PartialApiContext);
88
- /**
89
- * Get the version of the API.
90
- * @param contextOverride Optional context override for this request.
91
- * @returns The version of the API.
92
- * @see {@link https://api.cow.fi/docs/#/default/get_api_v1_version}
93
- */
94
- getVersion(contextOverride?: PartialApiContext): Promise<string>;
95
- /**
96
- * Get all the trades for either an `owner` **OR** `orderUid`.
97
- *
98
- * Given that an order *may* be partially fillable, it is possible that a discrete order (`orderUid`)
99
- * may have *multiple* trades. Therefore, this method returns a list of trades, either for *all* the orders
100
- * of a given `owner`, or for a discrete order (`orderUid`).
101
- * @param request Either an `owner` or an `orderUid` **MUST** be specified.
102
- * @param contextOverride Optional context override for this request.
103
- * @returns A list of trades matching the request.
104
- */
105
- getTrades(request: {
106
- owner?: Address;
107
- orderUid?: UID;
108
- }, contextOverride?: PartialApiContext): Promise<Array<Trade>>;
109
- /**
110
- * Get a list of orders for a given `owner`.
111
- * @param request The request parameters with `request.offset = 0` and `request.limit = 1000` by default.
112
- * @param contextOverride Optional context override for this request.
113
- * @returns A list of orders matching the request.
114
- * @see {@link GetOrdersRequest}
115
- * @see {@link EnrichedOrder}
116
- */
117
- getOrders({ owner, offset, limit }: GetOrdersRequest, contextOverride?: PartialApiContext): Promise<Array<EnrichedOrder>>;
118
- /**
119
- * Get a list of orders from a given settlement transaction hash.
120
- * @param txHash The transaction hash.
121
- * @param contextOverride Optional context override for this request.
122
- * @returns A list of orders matching the request.
123
- * @see {@link EnrichedOrder}
124
- */
125
- getTxOrders(txHash: TransactionHash, contextOverride?: PartialApiContext): Promise<Array<EnrichedOrder>>;
126
- /**
127
- * Get an order by its unique identifier, `orderUid`.
128
- * @param orderUid The unique identifier of the order.
129
- * @param contextOverride Optional context override for this request.
130
- * @returns The order matching the request.
131
- */
132
- getOrder(orderUid: UID, contextOverride?: PartialApiContext): Promise<EnrichedOrder>;
133
- /**
134
- * Get the order status while open
135
- */
136
- getOrderCompetitionStatus(orderUid: UID, contextOverride?: PartialApiContext): Promise<CompetitionOrderStatus>;
137
- /**
138
- * Attempt to get an order by its unique identifier, `orderUid`, from multiple environments.
139
- *
140
- * **NOTE**: The environment refers to either `prod` or `staging`. This allows a conveience method to
141
- * attempt to get an order from both environments, in the event that the order is not found in the
142
- * environment specified in the context.
143
- * @param orderUid The unique identifier of the order.
144
- * @param contextOverride Optional context override for this request.
145
- * @returns The order matching the request.
146
- * @throws {OrderBookApiError} If the order is not found in any of the environments.
147
- */
148
- getOrderMultiEnv(orderUid: UID, contextOverride?: PartialApiContext): Promise<EnrichedOrder>;
149
- /**
150
- * Get a quote for an order.
151
- * This allows for the calculation of the total cost of an order, including fees, before signing and submitting.
152
- * @param requestBody The parameters for the order quote request.
153
- * @param contextOverride Optional context override for this request.
154
- * @returns A hydrated order matching the request ready to be signed.
155
- */
156
- getQuote(requestBody: OrderQuoteRequest, contextOverride?: PartialApiContext): Promise<OrderQuoteResponse>;
157
- /**
158
- * Cancel one or more orders.
159
- *
160
- * **NOTE**: Cancellation is on a best-effort basis. Orders that are already in the process of being settled
161
- * (ie. transaction has been submitted to chain by the solver) cannot not be cancelled.
162
- * **CAUTION**: This method can only be used to cancel orders that were signed using `EIP-712` or `eth_sign (EIP-191)`.
163
- * @param requestBody Orders to be cancelled and signed instructions to cancel them.
164
- * @param contextOverride Optional context override for this request.
165
- * @returns A list of order unique identifiers that were successfully cancelled.
166
- */
167
- sendSignedOrderCancellations(requestBody: OrderCancellations, contextOverride?: PartialApiContext): Promise<void>;
168
- /**
169
- * Submit an order to the order book.
170
- * @param requestBody The signed order to be submitted.
171
- * @param contextOverride Optional context override for this request.
172
- * @returns The unique identifier of the order.
173
- */
174
- sendOrder(requestBody: OrderCreation, contextOverride?: PartialApiContext): Promise<UID>;
175
- /**
176
- * Get the native price of a token.
177
- *
178
- * **NOTE**: The native price is the price of the token in the native currency of the chain. For example, on Ethereum
179
- * this would be the price of the token in ETH.
180
- * @param tokenAddress The address of the ERC-20 token.
181
- * @param contextOverride Optional context override for this request.
182
- * @returns The native price of the token.
183
- */
184
- getNativePrice(tokenAddress: Address, contextOverride?: PartialApiContext): Promise<NativePriceResponse>;
185
- /**
186
- * Given a user's address, get the total surplus that they have earned.
187
- * @param address The user's address
188
- * @param contextOverride Optional context override for this request.
189
- * @returns Calculated user's surplus
190
- */
191
- getTotalSurplus(address: Address, contextOverride?: PartialApiContext): Promise<TotalSurplus>;
192
- /**
193
- * Retrieve the full app data for a given app data hash.
194
- * @param appDataHash `bytes32` hash of the app data
195
- * @param contextOverride Optional context override for this request.
196
- * @returns Full app data that was uploaded
197
- */
198
- getAppData(appDataHash: AppDataHash, contextOverride?: PartialApiContext): Promise<AppDataObject>;
199
- /**
200
- * Upload the full app data that corresponds to a given app data hash.
201
- * @param appDataHash `bytes32` hash of the app data
202
- * @param fullAppData Full app data to be uploaded
203
- * @param contextOverride Optional context override for this request.
204
- * @returns The string encoding of the full app data that was uploaded.
205
- */
206
- uploadAppData(appDataHash: AppDataHash, fullAppData: string, contextOverride?: PartialApiContext): Promise<AppDataObject>;
207
- getSolverCompetition(auctionId: number, contextOverride?: PartialApiContext): Promise<SolverCompetitionResponse>;
208
- getSolverCompetition(txHash: string, contextOverride?: PartialApiContext): Promise<SolverCompetitionResponse>;
209
- /**
210
- * Generate an API endpoint for an order by its unique identifier, `orderUid`.
211
- * @param orderUid The unique identifier of the order.
212
- * @param contextOverride Optional context override for this request.
213
- * @returns The API endpoint to get the order.
214
- */
215
- getOrderLink(orderUid: UID, contextOverride?: PartialApiContext): string;
216
- /**
217
- * Apply an override to the context for a request.
218
- * @param contextOverride Optional context override for this request.
219
- * @returns New context with the override applied.
220
- */
221
- private getContextWithOverride;
222
- /**
223
- * Get the base URLs for the API endpoints given the environment.
224
- * @param env The environment to get the base URLs for.
225
- * @returns The base URLs for the API endpoints.
226
- */
227
- private getApiBaseUrls;
228
- /**
229
- * Make a request to the API.
230
- * @param params The parameters for the request.
231
- * @param contextOverride Optional context override for this request.
232
- * @returns The response from the API.
233
- */
234
- private fetch;
235
- }
@@ -1,55 +0,0 @@
1
- export type { Address } from './models/Address';
2
- export type { AppData } from './models/AppData';
3
- export type { AppDataHash } from './models/AppDataHash';
4
- export type { AppDataObject } from './models/AppDataObject';
5
- export type { Auction } from './models/Auction';
6
- export type { AuctionOrder } from './models/AuctionOrder';
7
- export type { AuctionPrices } from './models/AuctionPrices';
8
- export type { BigUint } from './models/BigUint';
9
- export { BuyTokenDestination } from './models/BuyTokenDestination';
10
- export type { CallData } from './models/CallData';
11
- export type { CompetitionAuction } from './models/CompetitionAuction';
12
- export { CompetitionOrderStatus } from './models/CompetitionOrderStatus';
13
- export type { EcdsaSignature } from './models/EcdsaSignature';
14
- export { EcdsaSigningScheme } from './models/EcdsaSigningScheme';
15
- export type { EthflowData } from './models/EthflowData';
16
- export type { ExecutedAmounts } from './models/ExecutedAmounts';
17
- export type { ExecutedProtocolFee } from './models/ExecutedProtocolFee';
18
- export type { FeePolicy } from './models/FeePolicy';
19
- export type { InteractionData } from './models/InteractionData';
20
- export type { NativePriceResponse } from './models/NativePriceResponse';
21
- export { OnchainOrderData } from './models/OnchainOrderData';
22
- export type { Order } from './models/Order';
23
- export type { OrderCancellation } from './models/OrderCancellation';
24
- export { OrderCancellationError } from './models/OrderCancellationError';
25
- export type { OrderCancellations } from './models/OrderCancellations';
26
- export { OrderClass } from './models/OrderClass';
27
- export type { OrderCreation } from './models/OrderCreation';
28
- export { OrderKind } from './models/OrderKind';
29
- export type { OrderMetaData } from './models/OrderMetaData';
30
- export type { OrderParameters } from './models/OrderParameters';
31
- export { OrderPostError } from './models/OrderPostError';
32
- export type { OrderQuoteRequest } from './models/OrderQuoteRequest';
33
- export type { OrderQuoteResponse } from './models/OrderQuoteResponse';
34
- export type { OrderQuoteSide } from './models/OrderQuoteSide';
35
- export { OrderQuoteSideKindBuy } from './models/OrderQuoteSideKindBuy';
36
- export { OrderQuoteSideKindSell } from './models/OrderQuoteSideKindSell';
37
- export type { OrderQuoteValidity } from './models/OrderQuoteValidity';
38
- export { OrderStatus } from './models/OrderStatus';
39
- export type { PreSignature } from './models/PreSignature';
40
- export { PriceEstimationError } from './models/PriceEstimationError';
41
- export type { PriceImprovement } from './models/PriceImprovement';
42
- export { PriceQuality } from './models/PriceQuality';
43
- export type { Quote } from './models/Quote';
44
- export { SellTokenSource } from './models/SellTokenSource';
45
- export type { Signature } from './models/Signature';
46
- export { SigningScheme } from './models/SigningScheme';
47
- export type { SolverCompetitionResponse } from './models/SolverCompetitionResponse';
48
- export type { SolverSettlement } from './models/SolverSettlement';
49
- export type { Surplus } from './models/Surplus';
50
- export type { TokenAmount } from './models/TokenAmount';
51
- export type { TotalSurplus } from './models/TotalSurplus';
52
- export type { Trade } from './models/Trade';
53
- export type { TransactionHash } from './models/TransactionHash';
54
- export type { UID } from './models/UID';
55
- export type { Volume } from './models/Volume';
@@ -1,4 +0,0 @@
1
- /**
2
- * 20 byte Ethereum address encoded as a hex with `0x` prefix.
3
- */
4
- export type Address = string;
@@ -1,7 +0,0 @@
1
- /**
2
- * The string encoding of a JSON object representing some `appData`. The
3
- * format of the JSON expected in the `appData` field is defined
4
- * [here](https://github.com/cowprotocol/app-data).
5
- *
6
- */
7
- export type AppData = string;
@@ -1,6 +0,0 @@
1
- /**
2
- * 32 bytes encoded as hex with `0x` prefix.
3
- * It's expected to be the hash of the stringified JSON object representing the `appData`.
4
- *
5
- */
6
- export type AppDataHash = string;
@@ -1,7 +0,0 @@
1
- import type { AppData } from './AppData';
2
- /**
3
- * An `appData` document that is registered with the API.
4
- */
5
- export type AppDataObject = {
6
- fullAppData?: AppData;
7
- };
@@ -1,30 +0,0 @@
1
- import type { Address } from './Address';
2
- import type { AuctionOrder } from './AuctionOrder';
3
- import type { AuctionPrices } from './AuctionPrices';
4
- /**
5
- * A batch auction for solving.
6
- *
7
- */
8
- export type Auction = {
9
- /**
10
- * The unique identifier of the auction. Increment whenever the backend creates a new auction.
11
- *
12
- */
13
- id?: number;
14
- /**
15
- * The block number for the auction. Orders and prices are guaranteed to be valid on this block. Proposed settlements should be valid for this block as well.
16
- *
17
- */
18
- block?: number;
19
- /**
20
- * The solvable orders included in the auction.
21
- *
22
- */
23
- orders?: Array<AuctionOrder>;
24
- prices?: AuctionPrices;
25
- /**
26
- * List of addresses on whose surplus will count towards the objective value of their solution (unlike other orders that were created by the solver).
27
- *
28
- */
29
- surplusCapturingJitOrderOwners?: Array<Address>;
30
- };
@@ -1,92 +0,0 @@
1
- import type { Address } from './Address';
2
- import type { AppDataHash } from './AppDataHash';
3
- import type { BuyTokenDestination } from './BuyTokenDestination';
4
- import type { FeePolicy } from './FeePolicy';
5
- import type { InteractionData } from './InteractionData';
6
- import type { OrderClass } from './OrderClass';
7
- import type { OrderKind } from './OrderKind';
8
- import type { Quote } from './Quote';
9
- import type { SellTokenSource } from './SellTokenSource';
10
- import type { Signature } from './Signature';
11
- import type { TokenAmount } from './TokenAmount';
12
- import type { UID } from './UID';
13
- /**
14
- * A solvable order included in the current batch auction. Contains the data forwarded to solvers for solving.
15
- *
16
- */
17
- export type AuctionOrder = {
18
- uid: UID;
19
- /**
20
- * see `OrderParameters::sellToken`
21
- */
22
- sellToken: Address;
23
- /**
24
- * see `OrderParameters::buyToken`
25
- */
26
- buyToken: Address;
27
- /**
28
- * see `OrderParameters::sellAmount`
29
- */
30
- sellAmount: TokenAmount;
31
- /**
32
- * see `OrderParameters::buyAmount`
33
- */
34
- buyAmount: TokenAmount;
35
- /**
36
- * Creation time of the order. Denominated in epoch seconds.
37
- */
38
- created: string;
39
- /**
40
- * see `OrderParameters::validTo`
41
- */
42
- validTo: number;
43
- /**
44
- * see `OrderParameters::kind`
45
- */
46
- kind: OrderKind;
47
- /**
48
- * see `OrderParameters::receiver`
49
- */
50
- receiver: Address | null;
51
- owner: Address;
52
- /**
53
- * see `OrderParameters::partiallyFillable`
54
- */
55
- partiallyFillable: boolean;
56
- /**
57
- * Currently executed amount of sell/buy token, depending on the order kind.
58
- *
59
- */
60
- executed: TokenAmount;
61
- /**
62
- * The pre-interactions that need to be executed before the first execution of the order.
63
- *
64
- */
65
- preInteractions: Array<InteractionData>;
66
- /**
67
- * The post-interactions that need to be executed after the execution of the order.
68
- *
69
- */
70
- postInteractions: Array<InteractionData>;
71
- /**
72
- * see `OrderParameters::sellTokenBalance`
73
- */
74
- sellTokenBalance: SellTokenSource;
75
- /**
76
- * see `OrderParameters::buyTokenBalance`
77
- */
78
- buyTokenBalance: BuyTokenDestination;
79
- class: OrderClass;
80
- appData: AppDataHash;
81
- signature: Signature;
82
- /**
83
- * The fee policies that are used to compute the protocol fees for this order.
84
- *
85
- */
86
- protocolFees: Array<FeePolicy>;
87
- /**
88
- * A winning quote.
89
- *
90
- */
91
- quote?: Quote;
92
- };
@@ -1,6 +0,0 @@
1
- import type { BigUint } from './BigUint';
2
- /**
3
- * The reference prices for all traded tokens in the auction as a mapping from token addresses to a price denominated in native token (i.e. 1e18 represents a token that trades one to one with the native token). These prices are used for solution competition for computing surplus and converting fees to native token.
4
- *
5
- */
6
- export type AuctionPrices = Record<string, BigUint>;
@@ -1,4 +0,0 @@
1
- /**
2
- * A big unsigned integer encoded in decimal.
3
- */
4
- export type BigUint = string;
@@ -1,7 +0,0 @@
1
- /**
2
- * Where should the `buyToken` be transferred to?
3
- */
4
- export declare enum BuyTokenDestination {
5
- ERC20 = "erc20",
6
- INTERNAL = "internal"
7
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * Some `calldata` sent to a contract in a transaction encoded as a hex with `0x` prefix.
3
- */
4
- export type CallData = string;
@@ -1,14 +0,0 @@
1
- import type { AuctionPrices } from './AuctionPrices';
2
- import type { UID } from './UID';
3
- /**
4
- * The components that describe a batch auction for the solver competition.
5
- *
6
- */
7
- export type CompetitionAuction = {
8
- /**
9
- * The UIDs of the orders included in the auction.
10
- *
11
- */
12
- orders?: Array<UID>;
13
- prices?: AuctionPrices;
14
- };
@@ -1,29 +0,0 @@
1
- import type { ExecutedAmounts } from './ExecutedAmounts';
2
- export type CompetitionOrderStatus = {
3
- type: CompetitionOrderStatus.type;
4
- /**
5
- * A list of solvers who participated in the latest competition, sorted
6
- * by score in ascending order, where the last element is the winner.
7
- *
8
- * The presence of executed amounts defines whether the solver provided
9
- * a solution for the desired order.
10
- */
11
- value?: Array<{
12
- /**
13
- * Name of the solver.
14
- */
15
- solver: string;
16
- executedAmounts?: ExecutedAmounts;
17
- }>;
18
- };
19
- export declare namespace CompetitionOrderStatus {
20
- enum type {
21
- OPEN = "open",
22
- SCHEDULED = "scheduled",
23
- ACTIVE = "active",
24
- SOLVED = "solved",
25
- EXECUTING = "executing",
26
- TRADED = "traded",
27
- CANCELLED = "cancelled"
28
- }
29
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * 65 bytes encoded as hex with `0x` prefix. `r || s || v` from the spec.
3
- */
4
- export type EcdsaSignature = string;
@@ -1,7 +0,0 @@
1
- /**
2
- * How was the order signed?
3
- */
4
- export declare enum EcdsaSigningScheme {
5
- EIP712 = "eip712",
6
- ETHSIGN = "ethsign"
7
- }
@@ -1,20 +0,0 @@
1
- import type { TransactionHash } from './TransactionHash';
2
- /**
3
- * Provides the additional data for ethflow orders.
4
- */
5
- export type EthflowData = {
6
- /**
7
- * Specifies in which transaction the order was refunded. If
8
- * this field is null the order was not yet refunded.
9
- *
10
- */
11
- refundTxHash: TransactionHash | null;
12
- /**
13
- * Describes the `validTo` of an order ethflow order.
14
- *
15
- * **NOTE**: For ethflow orders, the `validTo` encoded in the smart
16
- * contract is `type(uint256).max`.
17
- *
18
- */
19
- userValidTo: number;
20
- };
@@ -1,5 +0,0 @@
1
- import type { BigUint } from './BigUint';
2
- export type ExecutedAmounts = {
3
- sell: BigUint;
4
- buy: BigUint;
5
- };
@@ -1,8 +0,0 @@
1
- import type { Address } from './Address';
2
- import type { FeePolicy } from './FeePolicy';
3
- import type { TokenAmount } from './TokenAmount';
4
- export type ExecutedProtocolFee = {
5
- policy?: FeePolicy;
6
- amount?: TokenAmount;
7
- token?: Address;
8
- };
@@ -1,7 +0,0 @@
1
- import type { PriceImprovement } from './PriceImprovement';
2
- import type { Surplus } from './Surplus';
3
- import type { Volume } from './Volume';
4
- /**
5
- * Defines the ways to calculate the protocol fee.
6
- */
7
- export type FeePolicy = (Surplus | Volume | PriceImprovement);
@@ -1,11 +0,0 @@
1
- import type { Address } from './Address';
2
- import type { CallData } from './CallData';
3
- import type { TokenAmount } from './TokenAmount';
4
- export type InteractionData = {
5
- target?: Address;
6
- value?: TokenAmount;
7
- /**
8
- * The call data to be used for the interaction.
9
- */
10
- call_data?: Array<CallData>;
11
- };
@@ -1,10 +0,0 @@
1
- /**
2
- * The estimated native price for the token
3
- *
4
- */
5
- export type NativePriceResponse = {
6
- /**
7
- * Estimated price of the token.
8
- */
9
- price?: number;
10
- };
@@ -1,24 +0,0 @@
1
- import type { Address } from './Address';
2
- export type OnchainOrderData = {
3
- /**
4
- * If orders are placed as on-chain orders, the owner of the order might be a smart contract, but not the user placing the order. The actual user will be provided in this field.
5
- *
6
- */
7
- sender: Address;
8
- /**
9
- * Describes the error, if the order placement was not successful. This could happen, for example, if the `validTo` is too high, or no valid quote was found or generated.
10
- *
11
- */
12
- placementError?: OnchainOrderData.placementError;
13
- };
14
- export declare namespace OnchainOrderData {
15
- /**
16
- * Describes the error, if the order placement was not successful. This could happen, for example, if the `validTo` is too high, or no valid quote was found or generated.
17
- *
18
- */
19
- enum placementError {
20
- QUOTE_NOT_FOUND = "QuoteNotFound",
21
- VALID_TO_TOO_FAR_IN_FUTURE = "ValidToTooFarInFuture",
22
- PRE_VALIDATION_ERROR = "PreValidationError"
23
- }
24
- }
@@ -1,3 +0,0 @@
1
- import type { OrderCreation } from './OrderCreation';
2
- import type { OrderMetaData } from './OrderMetaData';
3
- export type Order = (OrderCreation & OrderMetaData);
@@ -1,14 +0,0 @@
1
- import type { EcdsaSignature } from './EcdsaSignature';
2
- import type { EcdsaSigningScheme } from './EcdsaSigningScheme';
3
- /**
4
- * [EIP-712](https://eips.ethereum.org/EIPS/eip-712) signature of struct
5
- * `OrderCancellation(bytes orderUid)` from the order's owner.
6
- *
7
- */
8
- export type OrderCancellation = {
9
- /**
10
- * OrderCancellation signed by owner
11
- */
12
- signature: EcdsaSignature;
13
- signingScheme: EcdsaSigningScheme;
14
- };