# IMaverickV2RewardRouter

**Inherits:** [IMaverickV2LiquidityManager](/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/interfaces/imaverickv2liquiditymanager.md)

### Functions <a href="#functions" id="functions"></a>

#### stake <a href="#stake" id="stake"></a>

This function stakes any new staking token balance that are in the `reward.vault()` for a specified recipient tokenId. Passing input `tokenId=0` will cause the stake to mint to either the first tokenId for the caller, or a new NFT tokenId if the sender does not yet have one.

```solidity
function stake(IMaverickV2Reward reward, uint256 tokenId)
    external
    payable
    returns (uint256 amount, uint256 stakedTokenId);
```

**Parameters**

| Name      | Type                | Description                                        |
| --------- | ------------------- | -------------------------------------------------- |
| `reward`  | `IMaverickV2Reward` | The IMaverickV2Reward contract for which to stake. |
| `tokenId` | `uint256`           | Nft tokenId to stake for the staked tokens.        |

**Returns**

| Name            | Type      | Description                                                                                                               |
| --------------- | --------- | ------------------------------------------------------------------------------------------------------------------------- |
| `amount`        | `uint256` | The amount of staking tokens staked. May differ from input if there were unstaked tokens in the vault prior to this call. |
| `stakedTokenId` | `uint256` | TokenId where liquidity was staked to. This may differ from the input tokenId if the input `tokenId=0`.                   |

#### rewardFactory <a href="#rewardfactory" id="rewardfactory"></a>

This function retrieves the address of the MaverickV2RewardFactory contract associated with this contract.

```solidity
function rewardFactory() external view returns (IMaverickV2RewardFactory);
```

#### notifyRewardAmount <a href="#notifyrewardamount" id="notifyrewardamount"></a>

This function transfers a specified amount of reward tokens from the caller to a reward contract and notifies it to distribute them over a defined duration.

```solidity
function notifyRewardAmount(IMaverickV2Reward reward, IERC20 rewardToken, uint256 duration)
    external
    payable
    returns (uint256 _duration);
```

**Parameters**

| Name          | Type                | Description                                                     |
| ------------- | ------------------- | --------------------------------------------------------------- |
| `reward`      | `IMaverickV2Reward` | The IMaverickV2Reward contract to notify.                       |
| `rewardToken` | `IERC20`            | The address of the reward token to transfer.                    |
| `duration`    | `uint256`           | The duration (in seconds) over which to distribute the rewards. |

**Returns**

| Name        | Type      | Description                                                           |
| ----------- | --------- | --------------------------------------------------------------------- |
| `_duration` | `uint256` | The duration in seconds that the incentives will be distributed over. |

#### transferAndStake <a href="#transferandstake" id="transferandstake"></a>

This function transfers a specified amount of staking tokens from the caller, stakes them on the recipient's behalf, and associates them with a specified reward contract.

```solidity
function transferAndStake(IMaverickV2Reward reward, uint256 tokenId, uint256 _amount)
    external
    payable
    returns (uint256 amount, uint256 stakedTokenId);
```

**Parameters**

| Name      | Type                | Description                                         |
| --------- | ------------------- | --------------------------------------------------- |
| `reward`  | `IMaverickV2Reward` | The IMaverickV2Reward contract for which to stake.  |
| `tokenId` | `uint256`           | Nft tokenId to stake for the staked tokens.         |
| `_amount` | `uint256`           | The amount of staking tokens to transfer and stake. |

**Returns**

| Name            | Type      | Description                                                                                                               |
| --------------- | --------- | ------------------------------------------------------------------------------------------------------------------------- |
| `amount`        | `uint256` | The amount of staking tokens staked. May differ from input if there were unstaked tokens in the vault prior to this call. |
| `stakedTokenId` | `uint256` | TokenId where liquidity was staked to. This may differ from the input tokenIf if the input `tokenId=0`.                   |

#### transferAndNotifyRewardAmount <a href="#transferandnotifyrewardamount" id="transferandnotifyrewardamount"></a>

This function transfers a specified amount of reward tokens from the caller and adds them to the reward contract as incentives.

```solidity
function transferAndNotifyRewardAmount(IMaverickV2Reward reward, IERC20 rewardToken, uint256 duration, uint256 amount)
    external
    payable
    returns (uint256 _duration);
```

**Parameters**

| Name          | Type                | Description                                                     |
| ------------- | ------------------- | --------------------------------------------------------------- |
| `reward`      | `IMaverickV2Reward` | The IMaverickV2Reward contract to notify.                       |
| `rewardToken` | `IERC20`            | The address of the reward token to transfer.                    |
| `duration`    | `uint256`           | The duration (in seconds) over which to distribute the rewards. |
| `amount`      | `uint256`           | The amount of staking tokens to stake (uint256).                |

**Returns**

| Name        | Type      | Description                                                           |
| ----------- | --------- | --------------------------------------------------------------------- |
| `_duration` | `uint256` | The duration in seconds that the incentives will be distributed over. |

#### createBoostedPositionAndAddLiquidityAndStake <a href="#createboostedpositionandaddliquidityandstake" id="createboostedpositionandaddliquidityandstake"></a>

This function creates a new BoostedPosition contract, adds liquidity to a pool using the provided parameters, stakes the received LP tokens, and associates them with a specified reward contract.

```solidity
function createBoostedPositionAndAddLiquidityAndStake(
    address recipient,
    IMaverickV2PoolLens.CreateBoostedPositionInputs memory params,
    IERC20[] memory rewardTokens,
    IMaverickV2VotingEscrow[] memory veTokens
)
    external
    payable
    returns (
        IMaverickV2BoostedPosition boostedPosition,
        uint256 mintedLpAmount,
        uint256 tokenAAmount,
        uint256 tokenBAmount,
        uint256 stakeAmount,
        IMaverickV2Reward reward,
        uint256 tokenId
    );
```

**Parameters**

| Name           | Type                                              | Description                                                                                                            |
| -------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `recipient`    | `address`                                         | The address to which the minted LP tokens will be credited.                                                            |
| `params`       | `IMaverickV2PoolLens.CreateBoostedPositionInputs` | A struct containing parameters for creating the BoostedPosition (see IMaverickV2PoolLens.CreateBoostedPositionInputs). |
| `rewardTokens` | `IERC20[]`                                        | An array of IERC20 token addresses representing the available reward tokens for the staked LP position.                |
| `veTokens`     | `IMaverickV2VotingEscrow[]`                       | An array of IMaverickV2VotingEscrow contract addresses representing the veTokens used for boosting.                    |

**Returns**

| Name              | Type                         | Description                                               |
| ----------------- | ---------------------------- | --------------------------------------------------------- |
| `boostedPosition` | `IMaverickV2BoostedPosition` | The created IMaverickV2BoostedPosition contract.          |
| `mintedLpAmount`  | `uint256`                    | The amount of LP tokens minted from the added liquidity.  |
| `tokenAAmount`    | `uint256`                    | The amount of token A deposited for liquidity.            |
| `tokenBAmount`    | `uint256`                    | The amount of token B deposited for liquidity.            |
| `stakeAmount`     | `uint256`                    | The amount of LP tokens staked in the reward contract.    |
| `reward`          | `IMaverickV2Reward`          | The IMaverickV2Reward contract.                           |
| `tokenId`         | `uint256`                    | Token on reward contract where user liquidity was staked. |

#### createBoostedPositionAndAddLiquidityAndStakeToSender <a href="#createboostedpositionandaddliquidityandstaketosender" id="createboostedpositionandaddliquidityandstaketosender"></a>

This function is similar to `createBoostedPositionAndAddLiquidityAndStake` but stakes the minted LP tokens for the caller (msg.sender) instead of a specified recipient.

```solidity
function createBoostedPositionAndAddLiquidityAndStakeToSender(
    IMaverickV2PoolLens.CreateBoostedPositionInputs memory params,
    IERC20[] memory rewardTokens,
    IMaverickV2VotingEscrow[] memory veTokens
)
    external
    payable
    returns (
        IMaverickV2BoostedPosition boostedPosition,
        uint256 mintedLpAmount,
        uint256 tokenAAmount,
        uint256 tokenBAmount,
        uint256 stakeAmount,
        IMaverickV2Reward reward,
        uint256 tokenId
    );
```

**Parameters**

| Name           | Type                                              | Description                                                                                                            |
| -------------- | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `params`       | `IMaverickV2PoolLens.CreateBoostedPositionInputs` | A struct containing parameters for creating the BoostedPosition (see IMaverickV2PoolLens.CreateBoostedPositionInputs). |
| `rewardTokens` | `IERC20[]`                                        | An array of IERC20 token addresses representing the available reward tokens for the staked LP position.                |
| `veTokens`     | `IMaverickV2VotingEscrow[]`                       | An array of IMaverickV2VotingEscrow contract addresses representing the veTokens used for boosting.                    |

**Returns**

| Name              | Type                         | Description                                                            |
| ----------------- | ---------------------------- | ---------------------------------------------------------------------- |
| `boostedPosition` | `IMaverickV2BoostedPosition` | The created IMaverickV2BoostedPosition contract.                       |
| `mintedLpAmount`  | `uint256`                    | The amount of LP tokens minted from the added liquidity.               |
| `tokenAAmount`    | `uint256`                    | The amount of token A deposited for liquidity.                         |
| `tokenBAmount`    | `uint256`                    | The amount of token B deposited for liquidity.                         |
| `stakeAmount`     | `uint256`                    | The amount of LP tokens staked in the reward contract.                 |
| `reward`          | `IMaverickV2Reward`          | The IMaverickV2Reward contract associated with the staked LP position. |
| `tokenId`         | `uint256`                    | Token on reward contract where user liquidity was staked.              |

#### addLiquidityAndMintBoostedPositionAndStake <a href="#addliquidityandmintboostedpositionandstake" id="addliquidityandmintboostedpositionandstake"></a>

This function adds liquidity to a pool using a pre-created BoostedPosition contract, stakes the received LP tokens, and associates them with a specified reward contract.

```solidity
function addLiquidityAndMintBoostedPositionAndStake(
    uint256 tokenId,
    IMaverickV2BoostedPosition boostedPosition,
    bytes memory packedSqrtPriceBreaks,
    bytes[] memory packedArgs,
    IMaverickV2Reward reward
) external payable returns (uint256 mintedLpAmount, uint256 tokenAAmount, uint256 tokenBAmount, uint256 stakeAmount);
```

**Parameters**

| Name                    | Type                         | Description                                                                                                     |
| ----------------------- | ---------------------------- | --------------------------------------------------------------------------------------------------------------- |
| `tokenId`               | `uint256`                    | Token on reward contract where liquidity is to be staked.                                                       |
| `boostedPosition`       | `IMaverickV2BoostedPosition` | The IMaverickV2BoostedPosition contract representing the existing boosted position.                             |
| `packedSqrtPriceBreaks` | `bytes`                      | A packed representation of sqrt price breaks for the liquidity range (see IMaverickV2Pool.IAddLiquidityParams). |
| `packedArgs`            | `bytes[]`                    | Additional packed arguments for adding liquidity (see IMaverickV2Pool.IAddLiquidityParams).                     |
| `reward`                | `IMaverickV2Reward`          | The IMaverickV2Reward contract for which to stake the LP tokens.                                                |

**Returns**

| Name             | Type      | Description                                              |
| ---------------- | --------- | -------------------------------------------------------- |
| `mintedLpAmount` | `uint256` | The amount of LP tokens minted from the added liquidity. |
| `tokenAAmount`   | `uint256` | The amount of token A deposited for liquidity.           |
| `tokenBAmount`   | `uint256` | The amount of token B deposited for liquidity.           |
| `stakeAmount`    | `uint256` | The amount of LP tokens staked in the reward contract.   |

#### addLiquidityAndMintBoostedPositionAndStakeToSender <a href="#addliquidityandmintboostedpositionandstaketosender" id="addliquidityandmintboostedpositionandstaketosender"></a>

This function is similar to `addLiquidityAndMintBoostedPositionAndStake` but uses the caller (msg.sender) as the recipient for the minted reward stake.

```solidity
function addLiquidityAndMintBoostedPositionAndStakeToSender(
    uint256 sendersTokenIndex,
    IMaverickV2BoostedPosition boostedPosition,
    bytes memory packedSqrtPriceBreaks,
    bytes[] memory packedArgs,
    IMaverickV2Reward reward
)
    external
    payable
    returns (uint256 mintedLpAmount, uint256 tokenAAmount, uint256 tokenBAmount, uint256 stakeAmount, uint256 tokenId);
```

**Parameters**

| Name                    | Type                         | Description                                                                                                                                  |
| ----------------------- | ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `sendersTokenIndex`     | `uint256`                    | Token index of sender on the reward contract to mint to. If sender does not have a token already, then this call will mint one for the user. |
| `boostedPosition`       | `IMaverickV2BoostedPosition` | The IMaverickV2BoostedPosition contract representing the existing boosted position.                                                          |
| `packedSqrtPriceBreaks` | `bytes`                      | A packed representation of sqrt price breaks for the liquidity range (see IMaverickV2Pool.IAddLiquidityParams).                              |
| `packedArgs`            | `bytes[]`                    | Additional packed arguments for adding liquidity (see IMaverickV2Pool.IAddLiquidityParams).                                                  |
| `reward`                | `IMaverickV2Reward`          | The IMaverickV2Reward contract for which to stake the LP tokens.                                                                             |

**Returns**

| Name             | Type      | Description                                               |
| ---------------- | --------- | --------------------------------------------------------- |
| `mintedLpAmount` | `uint256` | The amount of LP tokens minted from the added liquidity.  |
| `tokenAAmount`   | `uint256` | The amount of token A deposited for liquidity.            |
| `tokenBAmount`   | `uint256` | The amount of token B deposited for liquidity.            |
| `stakeAmount`    | `uint256` | The amount of LP tokens staked in the reward contract.    |
| `tokenId`        | `uint256` | Token on reward contract where user liquidity was staked. |

#### sync <a href="#sync" id="sync"></a>

This function syncs the balance of a staker's votes on the legacy ve mav contract with the new V2 ve mav contract.

```solidity
function sync(IMaverickV2VotingEscrowWSync ve, address staker, uint256[] memory legacyLockupIndexes)
    external
    returns (uint256[] memory newBalance);
```

**Parameters**

| Name                  | Type                           | Description                                                                   |
| --------------------- | ------------------------------ | ----------------------------------------------------------------------------- |
| `ve`                  | `IMaverickV2VotingEscrowWSync` | The IMaverickV2VotingEscrowWSync contract to interact with.                   |
| `staker`              | `address`                      | The address of the user whose veToken lock may need syncing.                  |
| `legacyLockupIndexes` | `uint256[]`                    | A list of indexes to synchronize from the legacy veMav to the V2 ve contract. |

#### mintTokenInRewardToSender <a href="#minttokeninrewardtosender" id="minttokeninrewardtosender"></a>

```solidity
function mintTokenInRewardToSender(IMaverickV2Reward reward) external payable returns (uint256 tokenId);
```

#### mintTokenInReward <a href="#minttokeninreward" id="minttokeninreward"></a>

```solidity
function mintTokenInReward(IMaverickV2Reward reward, address recipient) external payable returns (uint256 tokenId);
```

<br>


---

# 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.mav.xyz/technical-reference/maverick-v2/v2-contracts/maverick-v2-reward-contracts/interfaces/imaverickv2rewardrouter.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.
