> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fibrous.finance/llms.txt
> Use this file to discover all available pages before exploring further.

# Citrea

> Citrea Smart Contracts

### Functions

```solidity theme={null}
    /**
     * @dev  Performs a swap using the provided route and swap parameters.
     * @param   route  The route parameters for the swap.
     * @param   swap_parameters  The parameters for the swaps to perform.
     * @return  The amount of the output token received.
     */
    function swap(RouteParam calldata route, SwapParams[] calldata swap_parameters)
        external
        payable
        returns (uint256)
```

## Paramaters

# RouteParam

> @notice RouteParam is a struct that contains the parameters needed to execute a swap

```solidity theme={null}
struct RouteParam {
    address token_in;
    address token_out;
    uint256 amount_in;
    uint256 min_received;
    address destination;
    SwapType swap_type;
}
```

| name | type | description |
| - | - | - |
| **token\_in** | address | contract address of token to sell |
| **token\_out** | address | contract address of token to buy |
| **amount\_in** | uint256 | amount of token to sell |
| **min\_received** | uint256 | minimum received amount of user get |
| **destination** | address | The receiver address for the output token |
| **swap\_type** | enum(SwapType) | Swap type |

\#SwapType(Enum)

> @notice SwapType is an enum that represents the type of swap

```solidity theme={null}
enum SwapType {
    ethToToken,
    tokenToEth,
    tokenToToken
}
```

| name | value | description |
| - | - | - |
| **ethToToken** | 0 | eth to token |
| **tokenToEth** | 1 | token to eth |
| **tokenToToken** | 2 | token to token |

# SwapParams

> @notice SwapParams is a struct that contains the parameters needed to execute a swap

```solidity theme={null}
struct SwapParams {
    address token_in;
    address token_out;
    uint32 rate;
    uint256 protocol_id;
    address pool_address;
    SwapType swap_type;
    uint256[] extra_data;
}
```

| name | type | description |
| - | - | - |
| **token\_in** | ContractAddress | contract address of token to sell |
| **token\_out** | ContractAddress | contract address of token to buy |
| **rate** | uint32 | rate \* 10\*\*4 gives 4 precision points |
| **protocol\_id** | uint256 | procotol id |
| **pool\_address** | address | pool contract address |
| **swap\_type** | enum(SwapType) | Swap type |
| **extra\_data** | Array(uint256) | extra data from route |

## Events

# Swap

```solidity theme={null}
event Swap(
    address sender,
    uint256 amount_in,
    uint256 amount_out,
    address token_in,
    address token_out,
    address destination
  )
```

| name | type | description |
| - | - | - |
| **sender** | address | address that execute the swap |
| **token\_in** | address | contract address of token to sold |
| **token\_out** | address | contract address of token to bought |
| **amount\_in** | uint256 | amount of token to sold |
| **amount\_out** | uint256 | amount of token to bought |
| **destination** | address | The receiver address for the output token |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.