> For the complete documentation index, see [llms.txt](https://docs.nabla.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nabla.fi/developers/contract-interfaces/nablaportal.md).

# NablaPortal

### oracleAdapter

```solidity
address oracleAdapter
```

### assetsByRouter

```solidity
mapping(address => mapping(address => bool)) assetsByRouter
```

### routers

```solidity
address[] routers
```

### routerAssets

```solidity
mapping(address => address[]) routerAssets
```

## Events

### EthForExactTokensSwapped

```solidity
event EthForExactTokensSwapped(
    address sender, 
    address to, 
    address[] routerPath, 
    address[] tokenPath, 
    uint256[] swapAmounts
)
```

### ExactTokensForEthSwapped

```solidity
event ExactTokensForEthSwapped(
    address sender, 
    address to, 
    address[] routerPath, 
    address[] tokenPath, 
    uint256[] swapAmounts
)
```

### ExactTokensForTokensSwapped

{% code overflow="wrap" %}

```solidity
event ExactTokensForTokensSwapped(
    address sender, 
    address to, 
    address[] routerPath, 
    address[] tokenPath, 
    uint256[] swapAmounts
)
```

{% endcode %}

## Functions

### swapEthForExactTokens

{% code overflow="wrap" %}

```solidity
function swapEthForExactTokens(
    uint256 _amountIn, 
    uint256 _amountOutMin, 
    address[] _tokenPath, 
    address[] _routerPath, 
    address _to, 
    uint256 _deadline, 
    bytes[] _priceUpdateData
) external payable returns (uint256 amountOut_)
```

{% endcode %}

Swap ETH for tokens using the NablaRouter

*By calling this function the price feed gets be updated (IPriceOracleAdapter.updatePriceFeeds)*

#### **Parameters**

<table><thead><tr><th width="184">Name</th><th width="133">Type</th><th>Description</th></tr></thead><tbody><tr><td>_amountIn</td><td>uint256</td><td>The amount of input ETH to swap</td></tr><tr><td>_amountOutMin</td><td>uint256</td><td>The minimum amount of output token that the user will accept</td></tr><tr><td>_tokenPath</td><td>address[]</td><td>Array of tokens to swap along the route (first token must be WETH)</td></tr><tr><td>_routerPath</td><td>address[]</td><td>Array of routers to use</td></tr><tr><td>_to</td><td>address</td><td>The recipient of the output tokens</td></tr><tr><td>_deadline</td><td>uint256</td><td>Unix timestamp after which the transaction will revert</td></tr><tr><td>_priceUpdateData</td><td>bytes[]</td><td>Array of price update data</td></tr></tbody></table>

#### **Return Values**

<table><thead><tr><th width="188">Name</th><th width="133">Type</th><th>Description</th></tr></thead><tbody><tr><td>amountOut_</td><td>uint256</td><td>Output amount of tokens</td></tr></tbody></table>

### swapExactTokensForEth

{% code overflow="wrap" fullWidth="false" %}

```solidity
function swapExactTokensForEth(
    uint256 _amountIn, 
    uint256 _amountOutMin, 
    address[] _tokenPath, 
    address[] _routerPath, 
    address _to, 
    uint256 _deadline, 
    bytes[] _priceUpdateData
) external payable returns (uint256 amountOut_)
```

{% endcode %}

Swap tokens using the NablaRouter and receive ETH

*By calling this function the price feed gets be updated (IPriceOracleAdapter.updatePriceFeeds)*

#### **Parameters**

<table><thead><tr><th width="188">Name</th><th width="124">Type</th><th>Description</th></tr></thead><tbody><tr><td>_amountIn</td><td>uint256</td><td>The amount of input tokens to swap</td></tr><tr><td>_amountOutMin</td><td>uint256</td><td>The minimum amount of ETH that the user will accept</td></tr><tr><td>_tokenPath</td><td>address[]</td><td>Array of tokens to swap along the route (last token must be WETH)</td></tr><tr><td>_routerPath</td><td>address[]</td><td>Array of routers to use</td></tr><tr><td>_to</td><td>address</td><td>The recipient of ETH</td></tr><tr><td>_deadline</td><td>uint256</td><td>Unix timestamp after which the transaction will revert</td></tr><tr><td>_priceUpdateData</td><td>bytes[]</td><td>Array of price update data</td></tr></tbody></table>

#### **Return Values**

| Name        | Type    | Description          |
| ----------- | ------- | -------------------- |
| amountOut\_ | uint256 | Output amount of ETH |

### swapExactTokensForTokens

{% code overflow="wrap" %}

```solidity
function swapExactTokensForTokens(
    uint256 _amountIn, 
    uint256 _amountOutMin, 
    address[] _tokenPath, 
    address[] _routerPath, 
    address _to, 
    uint256 _deadline, 
    bytes[] _priceUpdateData
) external payable returns (uint256 amountOut_)
```

{% endcode %}

Swap tokens using the NablaRouter

*By calling this function the price feed gets be updated (IPriceOracleAdapter.updatePriceFeeds)*

#### **Parameters**

<table><thead><tr><th width="189">Name</th><th width="133">Type</th><th>Description</th></tr></thead><tbody><tr><td>_amountIn</td><td>uint256</td><td>The amount of input tokens to swap</td></tr><tr><td>_amountOutMin</td><td>uint256</td><td>The minimum amount of output token that the user will accept</td></tr><tr><td>_tokenPath</td><td>address[]</td><td>Array of tokens to swap along the route</td></tr><tr><td>_routerPath</td><td>address[]</td><td>Array of routers to use</td></tr><tr><td>_to</td><td>address</td><td>The recipient of the output tokens</td></tr><tr><td>_deadline</td><td>uint256</td><td>Unix timestamp after which the transaction will revert</td></tr><tr><td>_priceUpdateData</td><td>bytes[]</td><td>Array of price update data</td></tr></tbody></table>

#### **Return Values**

<table><thead><tr><th width="189">Name</th><th width="136">Type</th><th>Description</th></tr></thead><tbody><tr><td>amountOut_</td><td>uint256</td><td>Output amount of tokens</td></tr></tbody></table>

### quoteSwapExactTokensForTokens

{% code overflow="wrap" %}

```solidity
function quoteSwapExactTokensForTokens(
    uint256 _amountIn, 
    address[] _tokenPath, 
    address[] _routerPath, 
    uint256[] _tokenPrices
) external view returns (uint256 amountOut_)
```

{% endcode %}

Get a quote for how many `_toToken` tokens `_amountIn` many `tokenIn` tokens can currently be swapped for.

#### **Parameters**

<table><thead><tr><th width="189">Name</th><th width="141">Type</th><th>Description</th></tr></thead><tbody><tr><td>_amountIn</td><td>uint256</td><td>The amount of input tokens to swap</td></tr><tr><td>_tokenPath</td><td>address[]</td><td>Array of tokens to swap along the route</td></tr><tr><td>_routerPath</td><td>address[]</td><td>Array of routers to use</td></tr><tr><td>_tokenPrices</td><td>uint256[]</td><td>Array of token prices fetched off-chain</td></tr></tbody></table>

#### **Return Values**

<table><thead><tr><th width="191">Name</th><th width="142">Type</th><th>Description</th></tr></thead><tbody><tr><td>amountOut_</td><td>uint256</td><td>Number of <code>_toToken</code> tokens that such a swap would yield right now</td></tr></tbody></table>

### getRouters

```solidity
function getRouters() external view returns (address[] routers_)
```

Retrieves the list of routers.

#### **Return Values**

<table><thead><tr><th width="185">Name</th><th width="155">Type</th><th>Description</th></tr></thead><tbody><tr><td>routers_</td><td>address[]</td><td>An array of addresses representing the routers.</td></tr></tbody></table>

### getRouterAssets

{% code overflow="wrap" %}

```solidity
function getRouterAssets(address _router) external view returns (address[] routerAssets_)
```

{% endcode %}

Retrieves the list of assets associated with a specific router.

#### **Parameters**

<table><thead><tr><th width="158">Name</th><th width="140">Type</th><th>Description</th></tr></thead><tbody><tr><td>_router</td><td>address</td><td>The address of the router for which to retrieve the assets.</td></tr></tbody></table>

#### **Return Values**

<table><thead><tr><th width="156">Name</th><th width="140">Type</th><th>Description</th></tr></thead><tbody><tr><td>routerAssets_</td><td>address[]</td><td>An array of addresses representing the assets associated with the specified router.</td></tr></tbody></table>
