# SwapIntent

#### Overview

The `SwapIntent` allows users to express the desire to swap one input asset to exactly one of the specified output assets.

For each asset prices are determined via a dutch auction. The start and end amounts are supplied by the user and the price decreases linearly based on the fill or initiation time of the order.

At this time the settling mechanism takes no explicit fee but there is an implicit fee taken by the solver equal to the price difference between the input and output asset.

A valid `SwapIntent` must be signed by the swapper address. To allow gasless execution, the signed struct should be a `Permit2` permit where the `SwapIntent` is included as a witness.

#### Message Format

Messages largely match what is in the intentpool specification. The `SwapIntent` has the following fields:

* `swapper` , the address of the original issuer
* `nonce` , a nonce provided for preventing replay
* `initiateAfter` is the block number of the origin chain for when the intent is valid to be initiated. This can only be 0 if an auction is not being run.
* `initiateDeadline` is the block number of the origin chain for when the intent ceases to be valid. This can only be 0 if an auction is not being run.
* `finalizeDeadline` is the block number of the origin chain after initialization that the swap must finalize by.

```solidity
struct SwapIntent {
    address swapper;
    uint256 nonce;
    uint256 initiateAfter;
    uint256 initiateDeadline;
    uint256 finalizeDeadline;
    Item input;
    Item[] outputs;
}
```

The `Item` data structure is used for specifying other parameters of the auction:

```solidity
struct Item {
    IERC20 token;
    uint256 amountStart;
    uint256 amountEnd;
    uint32 chainId;
}
```

It specifies the chain and token by the `chainId` and `token` contract address, as well as the `amountStart` and `amountEnd` of the action. Note: a `SwapIntent` cannot have two `Item` with different `amountStart` and `amountEnd` , one item must have these values be the same (i.e., either the auction is over what the swapper provides, or what the swapper receives, but not both).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fabriq.network/the-protocol/intents-types/swapintent.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
