Skip to content
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 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions docs/contracts/uniswapx/guides/arbitrumfiller.md
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.
Copy link
Contributor

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?


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)
1 change: 1 addition & 0 deletions docs/contracts/uniswapx/guides/becomeQuoter.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ 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.

41 changes: 3 additions & 38 deletions docs/contracts/uniswapx/guides/createFiller.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -53,46 +49,15 @@ 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`).
2. Decode returned orders using the [UniswapX SDK](https://github.com/Uniswap/UniswapX-sdk/#parsing-orders).
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:

Expand Down
38 changes: 38 additions & 0 deletions docs/contracts/uniswapx/guides/webhooks.md
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).

Loading