L2TokenReceiverV2

Introduction

The L2TokenReceiverV2 contract is a component of the protocol deployed on Arbitrum (L2). It is responsible for receiving stETH yield sent from Ethereum (L1) via the Arbitrum Bridge. Upon receipt, the yield is stored within the contract and can later be converted into MOR tokens to support liquidity or distribution.

Key Responsibilities

  • Bridged token receiver: handles incoming stETH/wstETH tokens from the L1Sender contract via Arbitrum Bridge.

  • Uniswap v3 Integration: enables the protocol to swap tokens or increase liquidity in Uniswap v3 pools.


Storage

router

The address of Uniswap v3 SwapRouter used for swaps.

address public router;

nonfungiblePositionManager

The address of Uniswap v3 NonfungiblePositionManager used for adding liquidity and collect fees.

address public nonfungiblePositionManager;

firstSwapParams

Holds the current token swap configuration for Uniswap v3 operations. Uses for wstETH/wETH pair.

Field
Description

tokenIn

Address of the token to be swapped from (input token).

tokenOut

Address of the token to be swapped to (output token).

fee

Uniswap v3 pool fee tier in hundredths of a bip (e.g., 3000 = 0.3%).

sqrtPriceLimitX96

Optional price limit for swap.

secondSwapParams

Holds the current token swap configuration for Uniswap v3 operations. Uses for wETH/MOR pair.

Write functions for the contract owner

L2TokenReceiver__init

Initializes the contract during deployment (used with proxies). Can only be called once.

Name
Description

router_

Address of Uniswap v3 SwapRouter contract.

nonfungiblePositionManager_

Address of Uniswap v3 NonfungiblePositionManager contract.

secondSwapParams_

Swap parameters for the Uniswap wETH/MOR pool.

editParams

Allows the contract owner to update swap parameters and reapprove token allowances.

Parameter
Description

newParams_

New SwapParams struct for the Uniswap pool.

isEditFirstParams_

True - when edit the wstETH/wETH pair. False for the wETH/MOR pair.


swap

Performs a token swap using Uniswap v3 router.

Parameter
Description

amountIn_

Amount of input token to swap.

amountOutMinimum_

Minimum expected output amount.

deadline_

Expiry timestamp for the transaction.

isEditFirstParams_

True - when use the wstETH/wETH pair. False for the wETH/MOR pair.

Returns: output token amount.

increaseLiquidityCurrentRange

Adds liquidity to an existing Uniswap NFT position.

Parameter
Description

tokenId_

NFT ID of the position.

amountAdd0_

Desired amount for token 0.

amountAdd1_

Desired amount for token 1.

amountMin0_

Minimum amount of token 0.

amountMin1_

Minimum amount of token 1.

collectFees

Collects all available fees from a Uniswap NFT liquidity position. Returns the collected amounts of token0 and token1.

Parameter
Description

tokenId_

NFT ID of the position

Read functions

supportsInterface

Used for interface detection (ERC165). Returns true if the contract supports a specific interfaceId_. Supports IL2TokenReceiverV2, IERC165.

Last updated

Was this helpful?