🏦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 nonReentrant
Parameter
Type
Description

borrower

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

circle-exclamation

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%):

Amount

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:

Condition
Error Message

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

Event
Parameters

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)

Contract
Address

WETH

0x4200000000000000000000000000000000000006

OP Mainnet - ChainlinkOEVWrapper

WETH Core Market Addresses (OP Mainnet)

Contract
Address

WETH

0x4200000000000000000000000000000000000006

Last updated