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.

SwapParams public firstSwapParams;

struct SwapParams {
  address tokenIn;
  address tokenOut;
  uint24 fee;
  uint160 sqrtPriceLimitX96;
}
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.

SwapParams public secondSwapParams;

Write functions for the contract owner

L2TokenReceiver__init

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

function L2TokenReceiver__init(
    address router_,
    address nonfungiblePositionManager_,
    SwapParams memory secondSwapParams_
) external initializer
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.

function editParams(
  SwapParams memory newParams_,
  bool isEditFirstParams_
) external onlyOwner
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.

function swap(
  uint256 amountIn_,
  uint256 amountOutMinimum_,
  uint256 deadline_,
  bool isUseFirstSwapParams_
) external onlyOwner returns (uint256)
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.

function increaseLiquidityCurrentRange(
  uint256 tokenId_,
  uint256 amountAdd0_,
  uint256 amountAdd1_,
  uint256 amountMin0_,
  uint256 amountMin1_
) external onlyOwner returns (
  uint128 liquidity_,
  uint256 amount0_,
  uint256 amount1_
 )
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.

function collectFees(
  uint256 tokenId_
) external returns (uint256 amount0_, uint256 amount1_)
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.

function supportsInterface(bytes4 interfaceId_) external pure returns (bool)

Last updated

Was this helpful?