MonoCooler.sol

MonoCooler is the core lending contract in Cooler V2 that enables perpetual loans against gOHM collateral. Unlike V1's fixed-term loans that required rollovers, MonoCooler tracks continuous positions with a single unified state per user.

Each user can:

  • Deposit gOHM as collateral

  • Borrow USDS up to the current max origination LTV

  • Delegate their collateral's voting power

  • Repay at any time

The contract links three key parts of the system:

  • CoolerTreasuryBorrower for sourcing USDS

  • LTV Oracle for position limits and liquidation thresholds

  • DLGTE module for governance power delegation

MonoCooler Functions

Authorization Functions

setAuthorization(address authorized, uint96 authorizationDeadline)

  • Gives another address permission to manage caller's position until deadline

setAuthorizationWithSig(Authorization memory authorization, Signature calldata signature)

  • Same as setAuthorization but can be done with signature

  • Uses EIP-712 signature verification

Collateral Functions

addCollateral(uint128 collateralAmount, address onBehalfOf, DelegationRequest[] calldata delegationRequests)

  • Adds gOHM collateral to a position

  • Can be done for another account without authorization

  • Optional delegation requests for voting power

withdrawCollateral(uint128 collateralAmount, address onBehalfOf, address recipient, DelegationRequest[] calldata delegationRequests)

  • Removes collateral if position stays healthy

  • Requires authorization if withdrawing for another account

  • Can specify recipient address for withdrawn collateral

  • Can withdraw max possible amount using type(uint128).max

Borrowing Functions

borrow(uint128 borrowAmount, address onBehalfOf, address recipient)

  • Borrows USDS against position's collateral

  • Must maintain minimum debt and maximum LTV

  • Can borrow max possible using type(uint128).max

  • Requires authorization if borrowing for another account

repay(uint128 repayAmount, address onBehalfOf)

  • Repays debt for a position

  • Can repay for any account without authorization

  • Debt must stay above minimum unless fully repaying

Delegation Functions

applyDelegations(DelegationRequest[] calldata delegationRequests, address onBehalfOf)

  • Updates voting power delegation for collateral

  • Requires authorization if delegating for another account

applyUnhealthyDelegations(address account, DelegationRequest[] calldata delegationRequests)

  • Forces undelegation of collateral for liquidatable positions

  • Used before liquidating a position

Liquidation Functions

batchLiquidate(address[] calldata accounts, DelegationRequest[][] calldata delegationRequests)

  • Liquidates multiple unhealthy positions

  • Undelegates collateral using provided delegation requests

  • Distributes liquidation incentives to caller

  • Burns remaining collateral

Admin Functions

setLtvOracle(address newOracle) [admin]

  • Updates LTV oracle contract

  • New oracle can only increase LTV limits

setTreasuryBorrower(address newTreasuryBorrower) [admin]

  • Updates treasury borrower contract

  • Anyone can set if uninitialized

setLiquidationsPaused(bool isPaused) [admin/emergency]

  • Pauses/unpauses liquidations

setBorrowPaused(bool isPaused) [admin/emergency]

  • Pauses/unpauses borrowing

setInterestRateWad(uint96 newInterestRate) [admin]

  • Updates interest rate

setMaxDelegateAddresses(address account, uint32 maxDelegateAddresses) [admin]

  • Sets maximum number of delegates for an account

View Functions

accountPosition(address account)

  • Returns position's current state including:

    • Collateral and debt amounts

    • Current LTV and health factor

    • Max borrowable amount

    • Liquidation threshold

computeLiquidity(address[] calldata accounts)

  • Batch check if positions are liquidatable

accountDebt(address account)

  • Returns current debt including accrued interest

accountCollateral(address account)

  • Returns current collateral amount

Last updated