From 0074d123b444b4b5d7f557118922cc77bea1262d Mon Sep 17 00:00:00 2001 From: "Alex.Karys" Date: Wed, 12 Jun 2024 20:10:48 -0400 Subject: [PATCH 1/2] Adding arbitrum X docs --- .../uniswapx/guides/arbitrumfiller.md | 60 +++++++++++++++++++ .../contracts/uniswapx/guides/becomeQuoter.md | 33 ++++++++++ .../contracts/uniswapx/guides/createFiller.md | 39 +----------- 3 files changed, 94 insertions(+), 38 deletions(-) create mode 100644 docs/contracts/uniswapx/guides/arbitrumfiller.md diff --git a/docs/contracts/uniswapx/guides/arbitrumfiller.md b/docs/contracts/uniswapx/guides/arbitrumfiller.md new file mode 100644 index 000000000..c2da30200 --- /dev/null +++ b/docs/contracts/uniswapx/guides/arbitrumfiller.md @@ -0,0 +1,60 @@ +--- +id: arbitrumfiller +title: Arbitrum Pilot +sidebar_position: 1 +--- + +# Arbitrum Pilot Overview +Starting June 19 2024, the Uniswap team will be piloting running a portion of trades on Arbitrum through UniswapX. Unlike UniswapX on mainnet, these orders will have **no RFQ portion and thus no exclusivity** during the pilot. + +Filling on Arbitrum, however, follows the same two steps as filling on Mainnet: 1) Retrieving signed orders and 2) Filling orders. + +## Retrieving Signed Orders +All signed Dutch Orders on Arbitrum, created through the Uniswap UI will be available via the UniswapX Orders Endpoint. We have [swagger documentation](https://api.uniswap.org/v2/uniswapx/docs) but see below for a quick example curl. + +``` +GET https://api.uniswap.org/v2/orders?orderStatus=open&chainId=42161&limit=1000 +``` + +Use the [UniswapX SDK](https://github.com/Uniswap/sdks/tree/main/sdks/uniswapx-sdk) to parse the `encodedOrder` field returned from endpoint. Each one of these `Orders` represents a fillable user trader. + +## Filling Orders +To execute a discovered order, a filler needs to call the [execute](https://github.com/Uniswap/UniswapX/blob/main/src/reactors/BaseReactor.sol#L31) method of the Reactor specified in the retrieved `encodedOrder` body. Currently the Reactor used by the Uniswap interface is located at: + +[0x1bd1aAdc9E230626C44a139d7E70d842749351eb](https://arbiscan.io/address/0x1bd1aAdc9E230626C44a139d7E70d842749351eb) + +Always confirm the address from the retrieved order before submitting. + +The simplest fill strategy is called `Direct Filler`, where the trade is executed directly against tokens held in the fillers address. To use this strategy, a filler can simply approve the order's output tokens to the reactor and call `execute` or `executeBatch` from their address. (see [source](https://github.com/Uniswap/UniswapX/blob/v2.0.0-deploy/src/reactors/BaseReactor.sol)): + +```solidity +// Execute direct filler order +outputToken.approve(reactor, type(uint256).max); +reactor.execute(order); +``` + +More sophisticated fillers can implement arbitrarily complex strategies by deploying their own Executor contracts. This contract should implement the [IReactorCallback](https://github.com/Uniswap/UniswapX/blob/v2.0.0-deploy/src/interfaces/IReactorCallback.sol) interface, which takes in an order with input tokens and acquires the allotted number of output tokens for the caller. It must approve the output tokens to the reactor, which then transfers them to the order output recipients to settle the order. Executor contracts must call `reactor.executeWithCallback` or `reactor.executeBatchWithCallback`. They can also specify arbitrary callback data that will be passed into the `reactorCallback` call. + +```solidity +contract Executor { + function execute(Order calldata order, bytes calldata callbackData) { + reactor.executeWithCallback(order, callbackData) + } + + function reactorCallback(ResolvedOrder[] calldata orders, bytes calldata callbackData) { + // implement strategy here + } +} + +// Execute custom fill strategy +address executor = /* Address of deployed executor contract */ ; +bytes fillData = /* Call data to be sent to your executor contract */; +executor.execute(order, fillData); +``` + +For convenience, we’ve provided an [example Executor Contract](https://github.com/Uniswap/UniswapX/blob/v2.0.0-deploy/src/sample-executors/SwapRouter02Executor.sol) which demonstrates how a filler could implement a strategy that executes a UniswapX order against a Uniswap V3 pool. These contracts should be deployed to each chain that the filler would like to support. + + +# Get in touch +- To keep up to date, join our [Announcements Channel](https://t.me/uniswapx_fillers) +- To ask questions and discuss, join our [Fillers Group](https://t.me/uniswapx_fillers_discussion) \ No newline at end of file diff --git a/docs/contracts/uniswapx/guides/becomeQuoter.md b/docs/contracts/uniswapx/guides/becomeQuoter.md index f4a86988a..9c9583d8d 100644 --- a/docs/contracts/uniswapx/guides/becomeQuoter.md +++ b/docs/contracts/uniswapx/guides/becomeQuoter.md @@ -72,3 +72,36 @@ To begin testing in beta quoters will need to: 4. **Send hashes of 5 filled transactions** that demonstrate that the integration was able to fill during the exclusive period; specifically before [decayStartTime](https://github.com/Uniswap/UniswapX/blob/abd7a0b080148fc42ef7c86536d14de714eec4c7/src/lib/ExclusiveDutchOrderLib.sol#L12) The Uniswap Labs team will review the 5 transactions to confirm they were successful exclusive fills. Once they are confirmed, the quoters setup will be promoted to production and will start receiving traffic. + +# (Optional) Signed Order Webhook Notifications + +Signed open orders can always be fetched via the UniswapX API, but to provide improved latency there is the option to register for webhook notifications. Quoters can register an endpoint with their filler address, and receive notifications for every newly posted order that matches the filter. + +**Filter** + +Orders can be filtered by various fields, but most relevant here is `filler`. When registering your webhook notification endpoint, we recommend you provide the `filler` address that you plan to use to execute orders and to receive the last-look exclusivity period. Alternatively the webhook can be configured to send all open orders to your endpoint. + +**Filter** + +To register your webhook endpoint, please reach out in [UniswapX Fillers - Discussion](https://t.me/uniswapx_fillers_discussion). + +**Notification** + +Order notifications will be sent to the registered endpoint as http requests as follows: + +```jsx +method: POST +content-type: application/json +data: { + orderHash: "the hash identifier for the order", + createdAt: "timestamp at which the order was posted", + signature: "the swapper signature to include with order execution", + orderStatus: "current order status (always should be `open` upon receiving notification)", + encodedOrder: "The abi-encoded order to include with order execution. This can be decoded using the Uniswapx-SDK (https://github.com/uniswap/uniswapx-sdk) to verify order fields and signature", + chainId: "The chain ID that the order originates from and must be settled on", + filler?: "If this order was quoted by an RFQ participant then this will be their filler address", + quoteId?: "If this order was quoted by an RFQ participant then this will be the requestId from the quote request", + swapper?: "The swapper address", + type?: "The order type (e.g. 'Dutch_V2', 'Limit', etc)" +} +``` \ No newline at end of file diff --git a/docs/contracts/uniswapx/guides/createFiller.md b/docs/contracts/uniswapx/guides/createFiller.md index cc871494a..f41b47310 100644 --- a/docs/contracts/uniswapx/guides/createFiller.md +++ b/docs/contracts/uniswapx/guides/createFiller.md @@ -1,13 +1,9 @@ --- id: createfiller -title: Creating A Filler +title: Filling on Mainnet sidebar_position: 1 --- -### Get in touch - -For notifications from the Uniswap team on changes to filler set ups, join the [UniswapX Fillers - Announcements channel](https://t.me/uniswapx_fillers). For questions and discussion around integrations, join [UniswapX Fillers - Discussion](https://t.me/uniswapx_fillers_discussion). - # Integrating as a Filler There are two components to integrating as a filler: defining a filler execution strategy and retrieving & executing discovered orders. @@ -60,39 +56,6 @@ It’s up to the individual filler to architect their own systems for finding an 3. Determine which orders you would like to execute. 4. Send a new transaction to the [execute](https://github.com/Uniswap/UniswapX/blob/a2025e3306312fc284a29daebdcabb88b50037c2/src/reactors/BaseReactor.sol#L29) or [executeBatch](https://github.com/Uniswap/UniswapX/blob/a2025e3306312fc284a29daebdcabb88b50037c2/src/reactors/BaseReactor.sol#L37) methods of the [Dutch Order Reactor](https://github.com/Uniswap/UniswapX/blob/main/src/reactors/DutchOrderReactor.sol) specifying the signed orders you’d like to fill and the address of your executor contract. -### (Optional) Signed Order Webhook Notifications - -Signed open orders can always be fetched via the UniswapX API, but to provide improved latency there is the option to register for webhook notifications. Quoters can register an endpoint with their filler address, and receive notifications for every newly posted order that matches the filter. - -**Filter** - -Orders can be filtered by various fields, but most relevant here is `filler`. When registering your webhook notification endpoint, we recommend you provide the `filler` address that you plan to use to execute orders and to receive the last-look exclusivity period. Alternatively the webhook can be configured to send all open orders to your endpoint. - -**Filter** - -To register your webhook endpoint, please reach out in [UniswapX Fillers - Discussion](https://t.me/uniswapx_fillers_discussion). - -**Notification** - -Order notifications will be sent to the registered endpoint as http requests as follows: - -```jsx -method: POST -content-type: application/json -data: { - orderHash: "the hash identifier for the order", - createdAt: "timestamp at which the order was posted", - signature: "the swapper signature to include with order execution", - orderStatus: "current order status (always should be `open` upon receiving notification)", - encodedOrder: "The abi-encoded order to include with order execution. This can be decoded using the Uniswapx-SDK (https://github.com/uniswap/uniswapx-sdk) to verify order fields and signature", - chainId: "The chain ID that the order originates from and must be settled on", - filler?: "If this order was quoted by an RFQ participant then this will be their filler address", - quoteId?: "If this order was quoted by an RFQ participant then this will be the requestId from the quote request", - swapper?: "The swapper address", - type?: "The order type (e.g. 'Dutch_V2', 'Limit', etc)" -} -``` - ## 2B. Retrieve & Execute Signed Limit Orders The process for retrieving and executing limit orders is the same as Dutch Orders above except that Limit Orders will be retrieved from the [Limit Orders Endpoint](https://api.uniswap.org/v2/limit-orders) (full API docs [here](https://api.uniswap.org/v2/uniswapx/docs)) and executed against the [Limit Order Reactor](https://github.com/Uniswap/UniswapX/blob/main/src/reactors/LimitOrderReactor.sol). The process is: From ebaeb8b787d25445031852fa8287310c1d6b44cf Mon Sep 17 00:00:00 2001 From: "Alex.Karys" Date: Thu, 13 Jun 2024 12:21:18 -0400 Subject: [PATCH 2/2] Adding webhooks section --- .../uniswapx/guides/arbitrumfiller.md | 8 +++- .../contracts/uniswapx/guides/becomeQuoter.md | 32 ---------------- .../contracts/uniswapx/guides/createFiller.md | 2 + docs/contracts/uniswapx/guides/webhooks.md | 38 +++++++++++++++++++ 4 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 docs/contracts/uniswapx/guides/webhooks.md diff --git a/docs/contracts/uniswapx/guides/arbitrumfiller.md b/docs/contracts/uniswapx/guides/arbitrumfiller.md index c2da30200..45bf1ddf4 100644 --- a/docs/contracts/uniswapx/guides/arbitrumfiller.md +++ b/docs/contracts/uniswapx/guides/arbitrumfiller.md @@ -1,13 +1,15 @@ --- id: arbitrumfiller title: Arbitrum Pilot -sidebar_position: 1 +sidebar_position: 4 --- # Arbitrum Pilot Overview Starting June 19 2024, the Uniswap team will be piloting running a portion of trades on Arbitrum through UniswapX. Unlike UniswapX on mainnet, these orders will have **no RFQ portion and thus no exclusivity** during the pilot. -Filling on Arbitrum, however, follows the same two steps as filling on Mainnet: 1) Retrieving signed orders and 2) Filling orders. +Filling on Arbitrum, however, follows the same two steps as filling on Mainnet: +1. Retrieving signed orders +2. Filling orders ## Retrieving Signed Orders All signed Dutch Orders on Arbitrum, created through the Uniswap UI will be available via the UniswapX Orders Endpoint. We have [swagger documentation](https://api.uniswap.org/v2/uniswapx/docs) but see below for a quick example curl. @@ -18,6 +20,8 @@ GET https://api.uniswap.org/v2/orders?orderStatus=open&chainId=42161&limit=1000 Use the [UniswapX SDK](https://github.com/Uniswap/sdks/tree/main/sdks/uniswapx-sdk) to parse the `encodedOrder` field returned from endpoint. Each one of these `Orders` represents a fillable user trader. +As a lower latency alternative to polling the API, fillers can also apply to register a webhook and receive a feed of all open orders. See details for registering [here](./webhooks) + ## Filling Orders To execute a discovered order, a filler needs to call the [execute](https://github.com/Uniswap/UniswapX/blob/main/src/reactors/BaseReactor.sol#L31) method of the Reactor specified in the retrieved `encodedOrder` body. Currently the Reactor used by the Uniswap interface is located at: diff --git a/docs/contracts/uniswapx/guides/becomeQuoter.md b/docs/contracts/uniswapx/guides/becomeQuoter.md index 9c9583d8d..20d27f492 100644 --- a/docs/contracts/uniswapx/guides/becomeQuoter.md +++ b/docs/contracts/uniswapx/guides/becomeQuoter.md @@ -73,35 +73,3 @@ To begin testing in beta quoters will need to: The Uniswap Labs team will review the 5 transactions to confirm they were successful exclusive fills. Once they are confirmed, the quoters setup will be promoted to production and will start receiving traffic. -# (Optional) Signed Order Webhook Notifications - -Signed open orders can always be fetched via the UniswapX API, but to provide improved latency there is the option to register for webhook notifications. Quoters can register an endpoint with their filler address, and receive notifications for every newly posted order that matches the filter. - -**Filter** - -Orders can be filtered by various fields, but most relevant here is `filler`. When registering your webhook notification endpoint, we recommend you provide the `filler` address that you plan to use to execute orders and to receive the last-look exclusivity period. Alternatively the webhook can be configured to send all open orders to your endpoint. - -**Filter** - -To register your webhook endpoint, please reach out in [UniswapX Fillers - Discussion](https://t.me/uniswapx_fillers_discussion). - -**Notification** - -Order notifications will be sent to the registered endpoint as http requests as follows: - -```jsx -method: POST -content-type: application/json -data: { - orderHash: "the hash identifier for the order", - createdAt: "timestamp at which the order was posted", - signature: "the swapper signature to include with order execution", - orderStatus: "current order status (always should be `open` upon receiving notification)", - encodedOrder: "The abi-encoded order to include with order execution. This can be decoded using the Uniswapx-SDK (https://github.com/uniswap/uniswapx-sdk) to verify order fields and signature", - chainId: "The chain ID that the order originates from and must be settled on", - filler?: "If this order was quoted by an RFQ participant then this will be their filler address", - quoteId?: "If this order was quoted by an RFQ participant then this will be the requestId from the quote request", - swapper?: "The swapper address", - type?: "The order type (e.g. 'Dutch_V2', 'Limit', etc)" -} -``` \ No newline at end of file diff --git a/docs/contracts/uniswapx/guides/createFiller.md b/docs/contracts/uniswapx/guides/createFiller.md index f41b47310..b444629b6 100644 --- a/docs/contracts/uniswapx/guides/createFiller.md +++ b/docs/contracts/uniswapx/guides/createFiller.md @@ -49,6 +49,8 @@ All signed Dutch Orders created through the Uniswap UI will be available via the GET https://api.uniswap.org/v2/orders?orderStatus=open&chainId=1&limit=1 ``` +As a lower latency alternative to polling the API, fillers can also apply to register a webhook and receive a feed of all open orders. See details for registering [here](./webhooks). + It’s up to the individual filler to architect their own systems for finding and executing profitable orders, but the basic flow is as follows: 1. Call `GET` on the `/orders` of the UniswapX Orders Endpoint as written above, to retrieve open signed orders. Dutch Orders are available on Mainnet (`chainId=1`) and Arbitrum (`chainId=42161`). diff --git a/docs/contracts/uniswapx/guides/webhooks.md b/docs/contracts/uniswapx/guides/webhooks.md new file mode 100644 index 000000000..b61d8d75d --- /dev/null +++ b/docs/contracts/uniswapx/guides/webhooks.md @@ -0,0 +1,38 @@ +--- +id: webhooks +title: Webhook Support +sidebar_position: 3 +--- + +# Signed Order Webhook Notifications + +Signed open orders can always be fetched via the UniswapX API, but to provide improved latency there is the option to register for webhook notifications. Fillers can register an endpoint and receive notifications for every newly posted order that matches their desired filter. + +## Notifications + +Order notifications will be sent to the registered endpoint as http requests as follows: + +```jsx +method: POST +content-type: application/json +data: { + orderHash: "the hash identifier for the order", + createdAt: "timestamp at which the order was posted", + signature: "the swapper signature to include with order execution", + orderStatus: "current order status (always should be `open` upon receiving notification)", + encodedOrder: "The abi-encoded order to include with order execution. This can be decoded using the Uniswapx-SDK (https://github.com/uniswap/uniswapx-sdk) to verify order fields and signature", + chainId: "The chain ID that the order originates from and must be settled on", + filler?: "If this order was quoted by an RFQ participant then this will be their filler address", + quoteId?: "If this order was quoted by an RFQ participant then this will be the requestId from the quote request", + swapper?: "The swapper address", + type?: "The order type (e.g. 'Dutch_V2', 'Limit', etc)" +} +``` + +## Filtering +Orders can be filtered by various fields. For quoters, the most common use case is to filter to their address so they are notified immediately of won bids. Alternatively the webhook can be configured to send all open orders to your endpoint. + + +## Request a Webhook +To register your webhook endpoint, please reach out in [UniswapX Fillers - Discussion](https://t.me/uniswapx_fillers_discussion). +