> For the complete documentation index, see [llms.txt](https://docs.turbine.exchange/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.turbine.exchange/reference/contracts/solidity-documentation/settler/interfaces/interface.iturbinesettler.md).

# ITurbineSettler

[Git Source](https://github.com/propeller-heads/turbine/blob/90514973167f1eb25cb9eb7756354fb3de34824d/src/settler/interfaces/ITurbineSettler.sol)

## Functions

### executedSellAmounts

\------------------------- EXTERNAL METHODS ------------------------- ///

Returns the cumulative executed sell amount for an order over all settlements

```solidity
function executedSellAmounts(bytes32 orderHash) external view returns (uint256);
```

**Parameters**

| Name        | Type      | Description           |
| ----------- | --------- | --------------------- |
| `orderHash` | `bytes32` | The hash of the order |

**Returns**

| Name     | Type      | Description              |
| -------- | --------- | ------------------------ |
| `<none>` | `uint256` | The executed sell amount |

### batchExecutedSellAmounts

Returns the cumulative executed sell amount for a batch of orders over all settlements

```solidity
function batchExecutedSellAmounts(bytes32[] calldata orderHashes) external view returns (uint256[] memory);
```

**Parameters**

| Name          | Type        | Description              |
| ------------- | ----------- | ------------------------ |
| `orderHashes` | `bytes32[]` | The hashes of the orders |

**Returns**

| Name     | Type        | Description               |
| -------- | ----------- | ------------------------- |
| `<none>` | `uint256[]` | The executed sell amounts |

### renounceAdmin

Renounces the caller's admin role

Can only be called by an admin. If multiple admins exist, other admins retain their roles.

```solidity
function renounceAdmin() external;
```

### getTurbineLiquidityRouter

Returns the address of the TurbineLiquidityRouter

Return type is address to avoid unnecessary imports

```solidity
function getTurbineLiquidityRouter() external view returns (address);
```

**Returns**

| Name     | Type      | Description                               |
| -------- | --------- | ----------------------------------------- |
| `<none>` | `address` | The address of the TurbineLiquidityRouter |

### getTurbineHook

Returns the address of the TurbineHook (via the TurbineLiquidityRouter)

Return type is address to avoid unnecessary imports

```solidity
function getTurbineHook() external view returns (address);
```

**Returns**

| Name     | Type      | Description                    |
| -------- | --------- | ------------------------------ |
| `<none>` | `address` | The address of the TurbineHook |

### turbineSigner

Returns the address of the Turbine signer

```solidity
function turbineSigner() external view returns (address);
```

**Returns**

| Name     | Type      | Description                                  |
| -------- | --------- | -------------------------------------------- |
| `<none>` | `address` | The address authorized to submit settlements |

### executeLiquidityActionsAndSettlement

Executes liquidity actions and a batch settlement

```solidity
function executeLiquidityActionsAndSettlement(
    AddLiquidityAppliedAction[] calldata addLiquidityActions,
    RemoveLiquidityAppliedAction[] calldata removeLiquidityOffchainActions,
    RemoveLiquidityIntentHash[] calldata removeLiquidityOnchainActions,
    BatchSettlement calldata settlement,
    uint256 targetBlockNumber,
    uint256 batchId
) external;
```

**Parameters**

| Name                             | Type                             | Description                                                |
| -------------------------------- | -------------------------------- | ---------------------------------------------------------- |
| `addLiquidityActions`            | `AddLiquidityAppliedAction[]`    | The liquidity actions to add liquidity                     |
| `removeLiquidityOffchainActions` | `RemoveLiquidityAppliedAction[]` | The offchain-applied liquidity actions to remove liquidity |
| `removeLiquidityOnchainActions`  | `RemoveLiquidityIntentHash[]`    | Intent hashes for onchain liquidity removals               |
| `settlement`                     | `BatchSettlement`                | The settlement to execute                                  |
| `targetBlockNumber`              | `uint256`                        | The block number at which the settlement is valid          |
| `batchId`                        | `uint256`                        | The unique identifier for this settlement batch            |

### feeWithdrawer

Returns the address of the fee withdrawer

```solidity
function feeWithdrawer() external view returns (address);
```

**Returns**

| Name     | Type      | Description                             |
| -------- | --------- | --------------------------------------- |
| `<none>` | `address` | The address authorized to withdraw fees |

### updateFeeWithdrawer

Updates the fee withdrawer address

Only callable by the admin

```solidity
function updateFeeWithdrawer(address newFeeWithdrawer) external;
```

**Parameters**

| Name               | Type      | Description                    |
| ------------------ | --------- | ------------------------------ |
| `newFeeWithdrawer` | `address` | The new fee withdrawer address |

### sweepFees

Sweeps all available balance of specified tokens to a specified recipient

Only callable by the fee withdrawer

```solidity
function sweepFees(address[] calldata tokens, address to) external;
```

**Parameters**

| Name     | Type        | Description                           |
| -------- | ----------- | ------------------------------------- |
| `tokens` | `address[]` | The addresses of the tokens to sweep  |
| `to`     | `address`   | The address to send the swept fees to |

## Events

### TurbineSignerSet

\------------------------- EVENTS ------------------------- ///

Emitted when the Turbine signer is set during construction

```solidity
event TurbineSignerSet(address indexed signer);
```

**Parameters**

| Name     | Type      | Description                                                    |
| -------- | --------- | -------------------------------------------------------------- |
| `signer` | `address` | The address of the Turbine signer (immutable after deployment) |

### TurbineSettlement

Emitted when a Turbine settlement is executed

```solidity
event TurbineSettlement(uint256 indexed batchId);
```

**Parameters**

| Name      | Type      | Description                                     |
| --------- | --------- | ----------------------------------------------- |
| `batchId` | `uint256` | The unique identifier for this settlement batch |

### OrderSettled

Emitted when an order is settled

```solidity
event OrderSettled(
    address indexed owner,
    bytes32 indexed orderHash,
    address sellToken,
    address buyToken,
    uint256 sellAmount,
    uint256 buyAmount
);
```

**Parameters**

| Name         | Type      | Description                    |
| ------------ | --------- | ------------------------------ |
| `owner`      | `address` | The owner of the settled order |
| `orderHash`  | `bytes32` | The hash of the settled order  |
| `sellToken`  | `address` |                                |
| `buyToken`   | `address` |                                |
| `sellAmount` | `uint256` | The amount of sell token       |
| `buyAmount`  | `uint256` | The amount of buy token        |

### SmartOrderSettled

Emitted when a smart order is executed

```solidity
event SmartOrderSettled(
    address indexed smartOrderTarget,
    bytes32 indexed orderHash,
    address sellToken,
    address buyToken,
    uint256 expectedSellAmount,
    uint256 receivedSellAmount,
    uint256 buyAmount
);
```

**Parameters**

| Name                 | Type      | Description                                                             |
| -------------------- | --------- | ----------------------------------------------------------------------- |
| `smartOrderTarget`   | `address` | The contract that executed the calldata                                 |
| `orderHash`          | `bytes32` | The hash of this smart order. In case of pool swaps, this hash is zero. |
| `sellToken`          | `address` | The sell token                                                          |
| `buyToken`           | `address` | The buy token                                                           |
| `expectedSellAmount` | `uint256` | The amount of sell token we expect from this order                      |
| `receivedSellAmount` | `uint256` | The amount of sell token we received from this order                    |
| `buyAmount`          | `uint256` | The amount of buy token                                                 |

### DEXSwapExecuted

Emitted when a DEX swap has been executed (typically via a Smart Order Router / aggregator).

```solidity
event DEXSwapExecuted(
    address indexed target,
    address sellToken,
    address buyToken,
    uint256 expectedSellAmount,
    uint256 receivedSellAmount,
    uint256 buyAmount
);
```

**Parameters**

| Name                 | Type      | Description                                                                |
| -------------------- | --------- | -------------------------------------------------------------------------- |
| `target`             | `address` | The target contract used to execute the swap (router/aggregator/exchange). |
| `sellToken`          | `address` | The token address being sold.                                              |
| `buyToken`           | `address` | The token address being purchased.                                         |
| `expectedSellAmount` | `uint256` | The expected amount of `sellToken` to be sold.                             |
| `receivedSellAmount` | `uint256` | The actual amount of `sellToken` sold by the pool/received by the settler. |
| `buyAmount`          | `uint256` | The amount of `buyToken` received from the swap.                           |

### TurbinePoolSwapExecuted

Emitted when a Turbine pool execution occurs

```solidity
event TurbinePoolSwapExecuted(
    address poolToken0, address poolToken1, uint24 poolFee, bool zeroForOne, uint256 amountIn, uint256 amountOut
);
```

**Parameters**

| Name         | Type      | Description                                               |
| ------------ | --------- | --------------------------------------------------------- |
| `poolToken0` | `address` | The address of token0 in the executed pool                |
| `poolToken1` | `address` | The address of token1 in the executed pool                |
| `poolFee`    | `uint24`  | The fee tier of the executed pool                         |
| `zeroForOne` | `bool`    | Direction of the swap, true if swapping token0 for token1 |
| `amountIn`   | `uint256` | Input token amount                                        |
| `amountOut`  | `uint256` | Output token amount                                       |

### FeeWithdrawerUpdated

Emitted when the fee withdrawer is updated

```solidity
event FeeWithdrawerUpdated(address indexed previous, address indexed newFeeWithdrawer);
```

**Parameters**

| Name               | Type      | Description                         |
| ------------------ | --------- | ----------------------------------- |
| `previous`         | `address` | The previous fee withdrawer address |
| `newFeeWithdrawer` | `address` | The new fee withdrawer address      |

### FeesSwept

Emitted when protocol fees are swept

```solidity
event FeesSwept(address[] tokens, address indexed recipient);
```

**Parameters**

| Name        | Type        | Description                       |
| ----------- | ----------- | --------------------------------- |
| `tokens`    | `address[]` | The addresses of the tokens swept |
| `recipient` | `address`   | The address receiving the fees    |

## Errors

### OnlyTurbineSigner

\------------------------- ERRORS ------------------------- ///

Only the turbine signer can call this function

```solidity
error OnlyTurbineSigner();
```

### OnlyFeeWithdrawer

Only the fee withdrawer can call this function

```solidity
error OnlyFeeWithdrawer();
```

### InsufficientTokensReceived

Insufficient amount of tokens received by the ITurbineSettler

```solidity
error InsufficientTokensReceived(uint256 expected, uint256 actual);
```

**Parameters**

| Name       | Type      | Description                                    |
| ---------- | --------- | ---------------------------------------------- |
| `expected` | `uint256` | The expected amount                            |
| `actual`   | `uint256` | The actual amount, smaller value than expected |

### InvalidCalldataTarget

Invalid calldata target. The calldata target cannot be the ITurbineSettler or the ITurbineLiquidityRouter.

```solidity
error InvalidCalldataTarget(address calldataTarget);
```

**Parameters**

| Name             | Type      | Description         |
| ---------------- | --------- | ------------------- |
| `calldataTarget` | `address` | The calldata target |

### ExcessiveTokensDistributed

More than expected amount of tokens sent out from the ITurbineSettler

```solidity
error ExcessiveTokensDistributed(uint256 expected, uint256 actual);
```

**Parameters**

| Name       | Type      | Description                                   |
| ---------- | --------- | --------------------------------------------- |
| `expected` | `uint256` | The expected amount                           |
| `actual`   | `uint256` | The actual amount, larger value than expected |

### InvalidBlockNumber

Current block number is not the target block number

```solidity
error InvalidBlockNumber();
```

### InsufficientBuyTokenBalance

There is not enough buy token balance to pay out users

```solidity
error InsufficientBuyTokenBalance(address token, uint256 available, uint256 required);
```

### ZeroAddress

Zero address provided where not allowed

```solidity
error ZeroAddress();
```

### RouterNotSet

TurbineLiquidityRouter must be set before renouncing admin

```solidity
error RouterNotSet();
```

### MissingAllowance

The allowance for a limit order is missing, and the onchain allowance is not enough to fulfill the order.

```solidity
error MissingAllowance(bytes32 orderHash);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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.turbine.exchange/reference/contracts/solidity-documentation/settler/interfaces/interface.iturbinesettler.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.
