🏦Core Markets
The ChainlinkOEVWrapper is used for liquidations in Moonwell's Core lending markets (mToken markets). The liquidator transfers loan tokens to the wrapper, which unlocks the fresh price, executes the liquidation, and splits the seized collateral (mTokens) between the liquidator and the protocol.
Function Signature
function updatePriceEarlyAndLiquidate(
address borrower,
uint256 repayAmount,
address mTokenCollateral,
address mTokenLoan
) external nonReentrantborrower
address
The underwater borrower to liquidate
repayAmount
uint256
Amount of loan tokens to repay
mTokenCollateral
address
The mToken market for collateral being seized
mTokenLoan
address
The mToken market for the loan being repaid
The OEV wrapper must be registered as the Chainlink feed for the underlying collateral token in Moonwell's ChainlinkOracle. The contract derives the underlying token via MErc20Storage(mTokenCollateral).underlying() and verifies chainlinkOracle.getFeed(underlyingCollateral.symbol()) == address(this). Use the correct wrapper for each collateral asset.
Liquidation Flow
┌─────────────────┐ ┌──────────────────────┐ ┌─────────────────┐
│ Liquidator │────▶│ ChainlinkOEVWrapper │────▶│ Moonwell Pool │
│ │ │ │ │ (Comptroller) │
└─────────────────┘ └──────────────────────┘ └─────────────────┘
│ │ │
│ 1. Transfer loan │ │
│ tokens │ │
│───────────────────────▶│ │
│ │ 2. Update cachedRoundId │
│ │ (unlock fresh price) │
│ │ │
│ │ 3. Execute liquidation │
│ │─────────────────────────▶│
│ │ │
│ │ 4. Receive mToken │
│ │ collateral │
│ │◀─────────────────────────│
│ │ │
│ 5. Receive mToken │ 6. Send protocol fee │
│ (repay + bonus) │ to feeRecipient │
│◀───────────────────────│ │Collateral Distribution
After liquidation, the seized mTokens are split:
Liquidator receives: Repayment value + (Profit ×
liquidatorFeeBps/ 10000)Protocol receives: Remaining profit (Profit × (10000 −
liquidatorFeeBps) / 10000)
Example with liquidatorFeeBps = 4000 (40%):
Repayment
1,000 USDC
Collateral seized (10% incentive)
1,100 USDC
Gross profit
100 USDC
Liquidator bonus (40%)
40 USDC
Liquidator total
1,040 USDC worth of mTokens
Protocol total
60 USDC worth of mTokens
Solidity Example
Revert Conditions
The following conditions will cause updatePriceEarlyAndLiquidate to revert:
repayAmount == 0
"ChainlinkOEVWrapper: repay amount cannot be zero"
borrower == address(0)
"ChainlinkOEVWrapper: borrower cannot be zero address"
mTokenCollateral == address(0)
"ChainlinkOEVWrapper: mToken collateral cannot be zero address"
mTokenLoan == address(0)
"ChainlinkOEVWrapper: mToken loan cannot be zero address"
Wrong wrapper for collateral
"ChainlinkOEVWrapper: chainlink oracle feed does not match"
Chainlink price ≤ 0
"Chainlink price cannot be lower or equal to 0"
Incomplete round
"Round is in incompleted state"
Stale Chainlink data
"Stale price"
No collateral seized
"ChainlinkOEVWrapper: collateral seized cannot be zero"
Liquidation failed
"ChainlinkOEVWrapper: liquidation failed"
Events
PriceUpdatedEarlyAndLiquidated
address indexed borrower, uint256 repayAmount, address mTokenCollateral, address mTokenLoan, uint256 protocolFee, uint256 liquidatorFee
FeeRecipientChanged
address oldFeeRecipient, address newFeeRecipient
LiquidatorFeeBpsChanged
uint16 oldLiquidatorFeeBps, uint16 newLiquidatorFeeBps
MaxRoundDelayChanged
uint256 oldMaxRoundDelay, uint256 newMaxRoundDelay
MaxDecrementsChanged
uint256 oldMaxDecrements, uint256 newMaxDecrements
Deployed Contracts
Base - ChainlinkOEVWrapper
WETH Core Market Addresses (Base)
WETH
0x4200000000000000000000000000000000000006
Moonwell WETH (mToken)
OP Mainnet - ChainlinkOEVWrapper
WETH Core Market Addresses (OP Mainnet)
WETH
0x4200000000000000000000000000000000000006
Moonwell WETH (mToken)
Last updated

