L2 Token Receiver V2
L2TokenReceiverV2.sol
is a component of the Techno Capital Machine. It is responsible for receiving wstETH yield from L1Sender
via the native Arbitrum bridge and managing Protocol-Owned Liquidity.
The contract supports swapping tokens with the swap
method through Uniswap V3 for either of two token pairs specified in firstSwapParams
and secondSwapParams
. The former is used to swap bridged wstETH yield for WETH. The latter is used to swap half of the resulting WETH for MOR. In turn, additional liquidity for the MOR/WETH pair is provisioned using the increaseLiquidityCurrentRange
method.
All functions on L2TokenReceiverV2
can only be called by the contract owner – the Morpheus multisig.
Variables
router
address
Address of the Uniswap V3 router.
nonfungiblePositionManager
address
Address of the Uniswap V3 Nonfungible Position Manager.
secondSwapParams
SwapParams
Uniswap V3 parameters for the MOR/WETH pair, including token addresses, pair fee, and slippage tolerance.
firstSwapParams
SwapParams
Uniswap V3 parameters for the wstETH/WETH pair, including token addresses, pair fee, and slippage tolerance.
Functions
swap
Executes a token swap on Uniswap V3 using specified parameters. Used to swap wstETH for WETH or WETH for MOR.
Parameters:
amountIn_
uint256
The amount of input token to swap.
amountOutMinimum_
uint256
The minimum amount of output token to accept.
deadline_
uint256
Timestamp after which the transaction reverts.
isEditFirstParams_
bool
Determines if the swap uses firstSwapParams
(i.e. swaps wstETH for WETH) or secondSwapParams
(i.e. swaps WETH for MOR).
Return Values:
uint256
The amount of output tokens received from the swap.
increaseLiquidityCurrentRange
Increases liquidity in the current range for a Uniswap V3 liquidity position. Used to add liquidity on the MOR/WETH pair.
Parameters:
tokenId_
uint256
The ID of the NFT position to increase liquidity for.
depositTokenAmountAdd_
uint256
Amount of WETH to add to the position.
rewardTokenAmountAdd_
uint256
Amount of MOR to add to the position.
depositTokenAmountMin_
uint256
Minimum amount of WETH that must be added.
rewardTokenAmountMin_
uint256
Minimum amount of MOR that must be added.
Return Values:
uint128
The liquidity added to the position.
uint256
The amount of the first token added to the position.
uint256
The amount of the second token added to the position.
collectFees
Collects fees for a Uniswap V3 liquidity position. Used to collect fees from the MOR/WETH pair.
Parameters:
tokenId_
uint256
The ID of the NFT position from which to collect fees.
Return Values:
uint256
The amount of the first token collected as fees.
uint256
The amount of the second token collected as fees.
L2TokenReceiver__init
Initializes the contract.
Parameters:
router_
address
Address of the Uniswap V3 router.
nonfungiblePositionManager_
address
Address of the Uniswap V3 Nonfungible Position Manager.
params_
SwapParams
Initial parameters for swaps.
editParams
Updates the swap parameters for firstSwapParams
or secondSwapParams
.
Parameters:
newParams_
SwapParams
The new swap parameters to be applied.
isEditFirstParams_
bool
Determines if firstSwapParams
or secondSwapParams
is updated.
Events
TokensSwapped
Emitted when a swap operation is successfully executed.
Parameters:
tokenIn
address
The address of the input token.
tokenOut
address
The address of the output token.
amountIn
uint256
The amount of the input token swapped.
amountOut
uint256
The amount of the output token received.
amountOutMinimum
uint256
The minimum amount of output token specified for the swap.
LiquidityIncreased
Emitted when liquidity is successfully added to a Uniswap V3 position.
Parameters:
tokenId
uint256
The ID of the NFT position to which liquidity was added.
amount0
uint256
The amount of the first token added.
amount1
uint256
The amount of the second token added.
liquidity
uint128
The amount of liquidity added to the position.
amount0Min
uint256
The minimum amount of the first token that was required.
amount1Min
uint256
The minimum amount of the second token that was required.
FeesCollected
Emitted when fees are collected from a Uniswap V3 position.
Parameters:
tokenId
uint256
The ID of the NFT position from which fees are collected
Structs
SwapParams
Stores parameters used for swapping between tokens on Uniswap V3.
Fields
tokenIn
address
The address of the token to swap from.
tokenOut
address
The address of the token to swap to.
fee
uint24
The fee percentage for the swap in hundredths of a basis point.
sqrtPriceLimitX96
uint160
The square root of the price limit. Used to specify slippage tolerance.
Last updated
Was this helpful?