# LemmaRouter

## Public Functions

### mintUSDL

Function purpose: msg.sender deposits WETH and mints USDL.

```
function mintUSDL(
        uint256 amount,
        uint256 maxCollateralRequired,
        uint256 dexIndex,
        IERC20 collateral) public
```

| Parameters            | Description                                                                                                 | Attribute                                                                                                                                                         |
| --------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| amount                | Amount of USDL to be minted.                                                                                | USD, 18 decimals                                                                                                                                                  |
| maxCollateralRequired | Max amount of WETH to be deposited to mint the USDL amount above.                                           | WETH, 18 decimals                                                                                                                                                 |
| dexIndex              | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0). | Integer                                                                                                                                                           |
| collateral            | IERC20 for type of asset to be deposited as collateral on the derivative dex.                               | ERC20 address, initially will be just [WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1](https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1) |

### mintUSDLTo

Function purpose: msg.sender deposits WETH and mints USDL to a given address.

```
function mintUSDLTo(
        address to,
        uint256 amount,
        uint256 maxCollateralRequired,
        uint256 dexIndex,
        IERC20 collateral) public
```

| Parameters            | Description                                                                                                 | Attribute                                                                                                                                                         |
| --------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| to                    | Address where USDL will be minted.                                                                          | ERC20 address                                                                                                                                                     |
| amount                | Amount of USDL to be minted.                                                                                | USD, 18 decimals                                                                                                                                                  |
| maxCollateralRequired | Max amount of WETH to be deposited to mint the USDL amount above.                                           | WETH, 18 decimals                                                                                                                                                 |
| dexIndex              | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0). | Integer                                                                                                                                                           |
| collateral            | IERC20 for type of asset to be deposited as collateral on the derivative dex.                               | ERC20 address, initially will be just [WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1](https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1) |

### mintUSDLETH

Function purpose: msg.sender deposits ETH, converts the ETH to WETH and mints USDL.

```
function mintUSDLETH(uint256 amount, uint256 dexIndex) public payable
```

| Parameters | Description                                                                                                 | Attributes       |
| ---------- | ----------------------------------------------------------------------------------------------------------- | ---------------- |
| msg.value  | Max amount of ETH to be deposited to mint the USDL amount below.                                            | ETH, 18 decimals |
| amount     | Amount of USDL to be minted.                                                                                | USD, 18 decimals |
| dexIndex   | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0). | Integer          |

### mintUSDLToETH

Function purpose: msg.sender deposits ETH, converts the ETH to WETH and mints USDL to a given address.

```
function mintUSDLToETH(
        address to,
        uint256 amount,
        uint256 dexIndex) public payable
```

| Parameters | Description                                                                                                 | Attributes       |
| ---------- | ----------------------------------------------------------------------------------------------------------- | ---------------- |
| msg.value  | Max amount of ETH to be deposited to mint the USDL amount below.                                            | ETH, 18 decimals |
| to         | Address where USDL will be minted.                                                                          | ERC20 address    |
| amount     | Amount of USDL to be minted.                                                                                | USD, 18 decimals |
| dexIndex   | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0). | Integer          |

### mintUSDLUsingToken

Function purpose: msg.sender deposits a given token, converts the token to WETH and mints USDL.&#x20;

```
function mintUSDLUsingToken(
        IERC20 token,
        uint256 tokenAmount,
        address[] memory _swapActions,
        bytes[] memory _swapDatas,
        uint256 amount,
        uint256 maxCollateralRequired,
        uint256 dexIndex,
        IERC20 collateral) public 
```

| Parameter             | Description                                                                                                                                       | Attributes                                                                                                                                                        |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| token                 | IERC20 address for token type to be used to mint USDL.                                                                                            | ERC20 Address                                                                                                                                                     |
| tokenAmount           | Amount of token to be deposited to mint USDL amount below.                                                                                        | Token, number of decimals depends on token                                                                                                                        |
| \_swapActions         | Array of dex contract addresses you want 1inch to use for swapping (or to let 1inch decide, put in "0x111111125434b319222cdbf8c261674adb56f3ae"). | address\[]                                                                                                                                                        |
| \_swapDatas           | Array of the "data" variable outputted by a request you need to make to the [1inch API's Swap GET call](#public-functions).                       | bytes\[]                                                                                                                                                          |
| amount                | Amount of USDL to be minted.                                                                                                                      | USD, 18 decimals                                                                                                                                                  |
| maxCollateralRequired | Max amount of WETH to be deposited to mint the USDL amount above.                                                                                 | WETH, 18 decimals                                                                                                                                                 |
| dexIndex              | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0).                                       | Integer                                                                                                                                                           |
| collateral            | IERC20 for type of asset to be deposited as collateral on the derivative dex.                                                                     | ERC20 address, initially will be just [WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1](https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1) |

### mintUSDLToUsingToken

Function purpose: msg.sender deposits a given token, converts the token to WETH and mints USDL to a given address.&#x20;

```
function mintUSDLToUsingToken(
        IERC20 token,
        uint256 tokenAmount,
        address[] memory _swapActions,
        bytes[] memory _swapDatas,
        address to,
        uint256 amount,
        uint256 maxCollateralRequired,
        uint256 dexIndex,
        IERC20 collateral) public 
```

| Parameter             | Description                                                                                                                                       | Attributes                                                                                                                                                        |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| token                 | IERC20 address for token type to be used to mint USDL.                                                                                            | ERC20 Address                                                                                                                                                     |
| tokenAmount           | Amount of token to be deposited to mint USDL amount below.                                                                                        | Token, number of decimals depends on token                                                                                                                        |
| \_swapActions         | Array of dex contract addresses you want 1inch to use for swapping (or to let 1inch decide, put in "0x111111125434b319222cdbf8c261674adb56f3ae"). | address\[]                                                                                                                                                        |
| \_swapDatas           | Array of the "data" variable outputted by a request you need to make to the [1inch API's Swap GET call](#public-functions).                       | bytes\[]                                                                                                                                                          |
| to                    | Address where USDL will be minted.                                                                                                                | ERC20 address                                                                                                                                                     |
| amount                | Amount of USDL to be redeemed.                                                                                                                    | USD, 18 decimals                                                                                                                                                  |
| maxCollateralRequired | Max amount of WETH to be deposited to mint the USDL amount above.                                                                                 | WETH, 18 decimals                                                                                                                                                 |
| dexIndex              | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0).                                       | Integer                                                                                                                                                           |
| collateral            | IERC20 for type of asset to be deposited as collateral on the derivative dex.                                                                     | ERC20 address, initially will be just [WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1](https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1) |

### redeemUSDL

Function purpose: msg.sender redeems USDL for WETH.

```
function redeemUSDL(
        uint256 amount,
        uint256 minCollateralToGetBack,
        uint256 dexIndex,
        IERC20 collateral) public
```

<table><thead><tr><th width="249.33333333333331">Parameter</th><th>Description</th><th>Attributes</th></tr></thead><tbody><tr><td>amount</td><td>Amount of USDL to be redeemed.</td><td>USD, 18 decimals</td></tr><tr><td>minCollateralToGetBack</td><td>Min amount of WETH to be received after redeeming the USDL amount above.</td><td>WETH, 18 decimals</td></tr><tr><td>dexIndex</td><td>Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0).</td><td>Integer</td></tr><tr><td>collateral</td><td>IERC20 for type of asset to be claimed from collateral on the derivative dex.</td><td>ERC20 address, initially will be just <a href="https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1">WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1</a></td></tr></tbody></table>

### redeemUSDLTo

Function purpose: msg.sender redeems USDL for WETH and receives the WETH at a given address.

```
function redeemUSDLTo(
        address to,
        uint256 amount,
        uint256 minCollateralToGetBack,
        uint256 dexIndex,
        IERC20 collateral) public
```

| Parameters             | Description                                                                                                 | Attributes                                                                                                                                                        |
| ---------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| to                     | Address where WETH will be received.                                                                        | ERC20 address                                                                                                                                                     |
| amount                 | Amount of USDL to be redeemed.                                                                              | USD, 18 decimals                                                                                                                                                  |
| minCollateralToGetBack | Min amount of WETH to be received after redeeming the USDL amount above.                                    | WETH, 18 decimals                                                                                                                                                 |
| dexIndex               | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0). | Integer                                                                                                                                                           |
| collateral             | IERC20 for type of asset to be claimed from collateral on the derivative dex.                               | ERC20 address, initially will be just [WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1](https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1) |

### redeemUSDLETH

Function purpose: msg.sender redeems USDL for WETH and converts that WETH to ETH.

```
function redeemUSDLETH(
        uint256 amount,
        uint256 minCollateralToGetBack,
        uint256 dexIndex) external
```

| Parameter              | Description                                                                                                 | Attributes        |
| ---------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------- |
| amount                 | Amount of USDL to be redeemed.                                                                              | USD, 18 decimals  |
| minCollateralToGetBack | Min amount of WETH to be received after redeeming the USDL amount above.                                    | WETH, 18 decimals |
| dexIndex               | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0). | Integer           |

### redeemUSDLToETH

Function purpose: msg.sender redeems USDL for WETH, converts that WETH to ETH and receives the ETH at a given address.

```
function redeemUSDLToETH(
        address to,
        uint256 amount,
        uint256 minCollateralToGetBack,
        uint256 dexIndex) public
```

| Parameter              | Description                                                                                                 | Attributes        |
| ---------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------- |
| to                     | Address where ETH will be received.                                                                         | ERC20 address     |
| amount                 | Amount of USDL to be redeemed.                                                                              | USD, 18 decimals  |
| minCollateralToGetBack | Min amount of WETH to be received after redeeming the USDL amount above.                                    | WETH, 18 decimals |
| dexIndex               | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0). | Integer           |

### redeemUSDLUsingToken

Function purpose: msg.sender redeems USDL for WETH and swaps that WETH for a given token.

```
function redeemUSDLUsingToken(
        IERC20 token,
        address[] memory _swapActions,
        bytes[] memory _swapDatas,
        uint256 amount,
        uint256 minTokenAmount,
        uint256 dexIndex,
        IERC20 collateral) external
```

| Parameter      | Description                                                                                                                                                                    | Attributes                                                                                                                                                        |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| token          | IERC20 address for token type to be received after redeeming USDL.                                                                                                             | ERC20 Address                                                                                                                                                     |
| \_swapActions  | Array of contract addresses  Array of dex contract addresses you want 1inch to use for swapping (or to let 1inch decide, put in "0x111111125434b319222cdbf8c261674adb56f3ae"). | address\[]                                                                                                                                                        |
| \_swapDatas    | Array of the "data" variable outputted by a request you need to make to the [1inch API's Swap GET call](#public-functions).                                                    | bytes\[]                                                                                                                                                          |
| amount         | Amount of USDL to be redeemed.                                                                                                                                                 | USD, 18 decimals                                                                                                                                                  |
| minTokenAmount | Min amount of token to be received after redeeming the USDL amount above.                                                                                                      | Token, number of decimals depends on token                                                                                                                        |
| dexIndex       | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0).                                                                    | Integer                                                                                                                                                           |
| collateral     | IERC20 for type of asset to be claimed from collateral on the derivative dex.                                                                                                  | ERC20 address, initially will be just [WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1](https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1) |

### redeemUSDLToUsingToken

Function purpose: msg.sender redeems USDL for WETH, swaps that WETH for a given token and receives the token at a given address.

```
function redeemUSDLToUsingToken(
        IERC20 token,
        address[] memory _swapActions,
        bytes[] memory _swapDatas,
        address to,
        uint256 amount,
        uint256 minTokenAmount,
        uint256 dexIndex,
        IERC20 collateral) external 
```

| Parameter      | Description                                                                                                                                       | Attributes                                                                                                                                                        |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| token          | IERC20 address for token type to be received after redeeming USDL.                                                                                | ERC20 Address                                                                                                                                                     |
| \_swapActions  | Array of dex contract addresses you want 1inch to use for swapping (or to let 1inch decide, put in "0x111111125434b319222cdbf8c261674adb56f3ae"). | address\[]                                                                                                                                                        |
| \_swapDatas    | Array of the "data" variable outputted by a request you need to make to the [1inch API's Swap GET call](#public-functions).                       | bytes\[]                                                                                                                                                          |
| to             | Address where the given token will be received.                                                                                                   | ERC20 address                                                                                                                                                     |
| amount         | Amount of USDL to be redeemed.                                                                                                                    | USD, 18 decimals                                                                                                                                                  |
| minTokenAmount | Min amount of token to be received after redeeming the USDL amount above.                                                                         | Token, number of decimals depends on token                                                                                                                        |
| dexIndex       | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0).                                       | Integer                                                                                                                                                           |
| collateral     | IERC20 for type of asset to be claimed from collateral on the derivative dex.                                                                     | ERC20 address, initially will be just [WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1](https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1) |

### stakeUSDL

Function purpose: msg.sender stakes USDL and receives xUSDL in return. Keep in mind the xUSDL price fluctuates with the yields generated and takes 8 hours to unstake.

```
function stakeUSDL(uint256 amount) public
```

| Paramters | Description                  | Attributes       |
| --------- | ---------------------------- | ---------------- |
| amount    | Amount of USDL to be staked. | USD, 18 decimals |

### unstakeUSDL

Function purpose: msg.sender unstakes xUSDL and receives USDL in return. Keep in mind the xUSDL price fluctuates with the yields generated and takes 8 hours to unstake.

```
function unstakeUSDL(uint256 amount) public
```

| Paramters | Description                     | Attributes         |
| --------- | ------------------------------- | ------------------ |
| amount    | Amount of xUSDL to be unstaked. | xUSDL, 18 decimals |

### unstakeUSDLTo

Function purpose: msg.sender unstakes xUSDL and receives USDL at a given address in return. Keep in mind the xUSDL price fluctuates with the yields generated and takes 8 hours to unstake.

```
function unstakeUSDLTo(address to, uint256 amount) public
```

| Paramters | Description                          | Attributes         |
| --------- | ------------------------------------ | ------------------ |
| to        | Address where USDL will be received. | ERC20 address      |
| amount    | Amount of xUSDL to be unstaked.      | xUSDL, 18 decimals |

### mintAndStake

Function purpose: msg.sender deposits WETH, mints USDL, stakes it and receives xUSDL in return. Keep in mind the xUSDL price fluctuates with the yields generated and takes 8 hours to unstake.

```
function mintAndStake(
        uint256 amount,
        uint256 dexIndex,
        uint256 maxCollateralRequired,
        IERC20 collateral) public 
```

<table><thead><tr><th width="241.39014373716634">Paramters</th><th width="249.33333333333331">Description</th><th>Attributes</th></tr></thead><tbody><tr><td>amount</td><td>Amount of USDL to be minted &#x26; staked.</td><td>USD, 18 decimals</td></tr><tr><td>dexIndex</td><td>Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0).</td><td>Integer</td></tr><tr><td>maxCollateralRequired</td><td>Max amount of WETH to be deposited to mint the USDL amount above.</td><td>WETH, 18 decimals</td></tr><tr><td>collateral</td><td>IERC20 for type of asset to be deposited as collateral on the derivative dex.</td><td>ERC20 address, initially will be just <a href="https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1">WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1</a></td></tr></tbody></table>

### mintForEthAndStake

Function purpose: msg.sender deposits ETH, converts that ETH to WETH, mints USDL, stakes it and receives xUSDL in return. Keep in mind the xUSDL price fluctuates with the yields generated and takes 8 hours to unstake.

```
function mintForEthAndStake(
        uint256 amount, 
        uint256 dexIndex) public payable
```

| Paramters | Description                                                                                                 | Attributes       |
| --------- | ----------------------------------------------------------------------------------------------------------- | ---------------- |
| msg.value | Max amount of ETH to be deposited to mint the USDL amount below.                                            | ETH, 18 decimals |
| amount    | Amount of USDL to be minted & staked.                                                                       | USD, 18 decimals |
| dexIndex  | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0). | Integer          |

### mintUsingTokenAndStake

Function purpose: msg.sender deposits a given token, swaps it for WETH, mints USDL, stakes it and receives xUSDL in return. Keep in mind the xUSDL price fluctuates with the yields generated and takes 8 hours to unstake.

```
function mintUsingTokenAndStake(
        IERC20 token,
        uint256 tokenAmount,
        address[] memory _swapActions,
        bytes[] memory _swapDatas,
        uint256 amount,
        uint256 maxCollateralRequired,
        uint256 dexIndex,
        IERC20 collateral) public 
```

| Parameter             | Description                                                                                                                                       | Attributes                                                                                                                                                        |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| token                 | IERC20 address for token type to be used to mint USDL.                                                                                            | ERC20 Address                                                                                                                                                     |
| tokenAmount           | Amount of token to be deposited to mint USDL amount below.                                                                                        | Token, number of decimals depends on token                                                                                                                        |
| \_swapActions         | Array of dex contract addresses you want 1inch to use for swapping (or to let 1inch decide, put in "0x111111125434b319222cdbf8c261674adb56f3ae"). | address\[]                                                                                                                                                        |
| \_swapDatas           | Array of the "data" variable outputted by a request you need to make to the [1inch API's Swap GET call](#public-functions).                       | bytes\[]                                                                                                                                                          |
| amount                | Amount of USDL to be minted & staked.                                                                                                             | USD, 18 decimals                                                                                                                                                  |
| maxCollateralRequired | Max amount of WETH to be deposited to mint the USDL amount above.                                                                                 | WETH, 18 decimals                                                                                                                                                 |
| dexIndex              | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0).                                       | Integer                                                                                                                                                           |
| collateral            | IERC20 for type of asset to be deposited as collateral on the derivative dex.                                                                     | ERC20 address, initially will be just [WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1](https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1) |

### unstakeAndRedeemUSDL

Function purpose: msg.sender unstakes xUSDL, receives USDL in return, redeems the USDL and receives WETH in return. Keep in mind the xUSDL price fluctuates with the yields generated and takes 8 hours to unstake.

```
function unstakeAndRedeemUSDL(
        uint256 amount,
        uint256 minCollateralToGetBack,
        uint256 dexIndex,
        IERC20 collateral) public 
```

| Paramters              | Description                                                                                                 | Attributes                                                                                                                                                        |
| ---------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| amount                 | Amount of xUSDL to be unstaked.                                                                             | xUSDL, 18 decimals                                                                                                                                                |
| dexIndex               | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0). | Integer                                                                                                                                                           |
| minCollateralToGetBack | Min amount of WETH to be received after redeeming the USDL amount above.                                    | WETH, 18 decimals                                                                                                                                                 |
| collateral             | IERC20 for type of asset to be claimed from collateral on the derivative dex.                               | ERC20 address, initially will be just [WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1](https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1) |

### unstakeAndRedeemUSDLTo

Function purpose: msg.sender unstakes xUSDL, receives USDL in return, redeems the USDL and receives WETH in return at a given address. Keep in mind the xUSDL price fluctuates with the yields generated and takes 8 hours to unstake.

```
function unstakeAndRedeemUSDLTo(
        address to,
        uint256 amount,
        uint256 minCollateralToGetBack,
        uint256 dexIndex,
        IERC20 collateral) public
```

| Paramters              | Description                                                                                                 | Attributes                                                                                                                                                        |
| ---------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| to                     | Address where WETH will be received.                                                                        | ERC20 address                                                                                                                                                     |
| amount                 | Amount of xUSDL to be unstaked.                                                                             | xUSDL, 18 decimals                                                                                                                                                |
| dexIndex               | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0). | Integer                                                                                                                                                           |
| minCollateralToGetBack | Min amount of WETH to be received after redeeming the USDL amount above.                                    | WETH, 18 decimals                                                                                                                                                 |
| collateral             | IERC20 for type of asset to be claimed from collateral on the derivative dex.                               | ERC20 address, initially will be just [WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1](https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1) |

### unstakeAndRedeemUSDLForEth

Function purpose: msg.sender unstakes xUSDL, receives USDL in return, redeems the USDL, receives WETH in return and converts that WETH for ETH. Keep in mind the xUSDL price fluctuates with the yields generated and takes 8 hours to unstake.

```
function unstakeAndRedeemUSDLForEth(
    uint256 amount, 
    uint256 dexIndex) public
```

| Paramters | Description                                                                                                 | Attributes         |
| --------- | ----------------------------------------------------------------------------------------------------------- | ------------------ |
| amount    | Amount of xUSDL to be unstaked.                                                                             | xUSDL, 18 decimals |
| dexIndex  | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0). | Integer            |

### unstakeAndRedeemUSDLForEthTo

Function purpose: msg.sender unstakes xUSDL, receives USDL in return, redeems the USDL, receives WETH in return, converts that WETH for ETH and receives that ETH at a given address. Keep in mind the xUSDL price fluctuates with the yields generated and takes 8 hours to unstake.

```
function unstakeAndRedeemUSDLForEthTo(
        address to, 
        uint256 amount, 
        uint256 dexIndex) public
```

| Paramters | Description                                                                                                 | Attributes         |
| --------- | ----------------------------------------------------------------------------------------------------------- | ------------------ |
| to        | Address where ETH will be received.                                                                         | ERC20 address      |
| amount    | Amount of xUSDL to be unstaked.                                                                             | xUSDL, 18 decimals |
| dexIndex  | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0). | Integer            |

### unstakeAndRedeemToken

Function purpose: msg.sender unstakes xUSDL, receives USDL in return, redeems the USDL, receives WETH in return and swaps that WETH for a given token. Keep in mind the xUSDL price fluctuates with the yields generated and takes 8 hours to unstake.

```
function unstakeAndRedeemToken(
        IERC20 token,
        address[] memory _swapActions,
        bytes[] memory _swapDatas,
        uint256 amount,
        uint256 minTokenAmount,
        uint256 dexIndex,
        IERC20 collateral) public 
```

| Parameter      | Description                                                                                                                                       | Attributes                                                                                                                                                        |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| token          | IERC20 address for token type to be received after redeeming USDL.                                                                                | ERC20 Address                                                                                                                                                     |
| \_swapActions  | Array of dex contract addresses you want 1inch to use for swapping (or to let 1inch decide, put in "0x111111125434b319222cdbf8c261674adb56f3ae"). | address\[]                                                                                                                                                        |
| \_swapDatas    | Array of the "data" variable outputted by a request you need to make to the [1inch API's Swap GET call](#public-functions).                       | bytes\[]                                                                                                                                                          |
| amount         | Amount of USDL to be redeemed.                                                                                                                    | USD, 18 decimals                                                                                                                                                  |
| minTokenAmount | Min amount of token to be received after redeeming the USDL amount above.                                                                         | Token, number of decimals depends on token                                                                                                                        |
| dexIndex       | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0).                                       | Integer                                                                                                                                                           |
| collateral     | IERC20 for type of asset to be claimed from collateral on the derivative dex.                                                                     | ERC20 address, initially will be just [WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1](https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1) |

### unstakeAndRedeemToToken

Function purpose: msg.sender unstakes xUSDL, receives USDL in return, redeems the USDL, receives WETH in return, converts that WETH for a given token and receives that token at a given address. Keep in mind the xUSDL price fluctuates with the yields generated and takes 8 hours to unstake.

```
function unstakeAndRedeemToToken(
        IERC20 token,
        address[] memory _swapActions,
        bytes[] memory _swapDatas,
        address to,
        uint256 amount,
        uint256 minTokenAmount,
        uint256 dexIndex,
        IERC20 collateral) public
```

| Parameter      | Description                                                                                                                                       | Attributes                                                                                                                                                        |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| token          | IERC20 address for token type to be received after redeeming USDL.                                                                                | ERC20 Address                                                                                                                                                     |
| \_swapActions  | Array of dex contract addresses you want 1inch to use for swapping (or to let 1inch decide, put in "0x111111125434b319222cdbf8c261674adb56f3ae"). | address\[]                                                                                                                                                        |
| \_swapDatas    | Array of the "data" variable outputted by a request you need to make to the [1inch API's Swap GET call](#public-functions).                       | bytes\[]                                                                                                                                                          |
| to             | Address where token will be received.                                                                                                             | ERC20 address                                                                                                                                                     |
| amount         | Amount of USDL to be redeemed.                                                                                                                    | USD, 18 decimals                                                                                                                                                  |
| minTokenAmount | Min amount of token to be received after redeeming the USDL amount above.                                                                         | Token, number of decimals depends on token                                                                                                                        |
| dexIndex       | Index for derivative dex to be used (right now only MCDEX is integrated, and its corresponding index is 0).                                       | Integer                                                                                                                                                           |
| collateral     | IERC20 for type of asset to be claimed from collateral on the derivative dex.                                                                     | ERC20 address, initially will be just [WETH - 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1](https://arbiscan.io/address/0x82aF49447D8a07e3bd95BD0d56f35241523fBab1) |


---

# 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://lemma-support.gitbook.io/lemma/smart-contracts/periphery-contracts/lemmarouter.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.
