-
Notifications
You must be signed in to change notification settings - Fork 546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding arbitrum X docs #716
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
id: arbitrumfiller | ||
title: Arbitrum Pilot | ||
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 | ||
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. | ||
|
||
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: | ||
|
||
[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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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). | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you mention that we also support the webhook for Arbitrum orders and link to the
Signed Order Webhook Notifications
section in the other doc?