For the complete documentation index, see llms.txt. This page is also available as Markdown.

BaseVault

Inherits: ERC4626Upgradeable, ReentrancyGuardUpgradeable

Title: BaseVault

Abstract base ERC-4626 vault providing shared mechanics for all Venus fixed-term vault types: fundraising (time-bounded deposit window), interest computation, settlement (protocol fee waterfall), and core state machine transitions.

Subcontracts (InstitutionalLoanVault) inherit this and add type-specific logic. Deployed as EIP-1167 minimal proxy clones by the respective VaultController.

Solidity API

State Variables

BPS

uint256 public constant BPS = 10_000

MANTISSA_ONE

uint256 public constant MANTISSA_ONE = 1e18

YEAR

uint256 public constant YEAR = 365 days

_config

Immutable vault configuration set at initialization.

_runtime

Runtime state that changes during the vault lifecycle.

vaultController

VaultController address — set to msg.sender during initialize.

pauseLevel

Current pause level (Unpaused, Partial, Complete).

Functions

onlyController

Reverts if caller is not the VaultController.

whenNotPaused

Reverts on any pause level (Partial or Complete). Used for general operations.

whenNotCompletelyPaused

Reverts only on Complete pause. Repay and liquidation remain available during Partial pause.

closeVault

Transitions vault to Closed state. All operations are blocked after this point. Governance should only call this once all suppliers have withdrawn their funds.

Notes:

  • error: InvalidState If vault is not in a terminal state (Matured/Failed/Liquidated).

  • event: StateTransition Emitted for the terminal state -> Closed transition.

  • event: VaultClosed Emitted with the previous terminal state.

partialPause

Partial pause — blocks general operations (deposits, collateral, borrowing). Repay and liquidation remain available so positions can still be defended/resolved.

Note: event: PauseLevelSet

completePause

Complete pause — blocks all operations including repay and liquidation.

Note: event: PauseLevelSet

unpause

Removes all pause restrictions.

Note: event: PauseLevelSet

sweep

Recovers any tokens stuck in the vault. Full balance is transferred.

Notes:

  • error: NothingToSweep If the token balance is zero.

  • event: TokensSwept

Parameters

Name
Type
Description

token

address

Token address to sweep.

updateVaultState

Permissionless vault finalizer. Triggers state transitions and settlement.

outstandingDebt

Total remaining debt. Decremented by repayments; zero when fully repaid.

Returns

Name
Type
Description

<none>

uint256

Outstanding debt in supply asset units.

config

Returns the vault configuration.

Returns

Name
Type
Description

<none>

VaultConfig

Immutable VaultConfig struct set at initialization.

runtime

Returns the runtime state.

Returns

Name
Type
Description

<none>

VaultRuntime

Mutable VaultRuntime struct tracking lifecycle progress.

state

Current vault lifecycle state.

Returns

Name
Type
Description

<none>

VaultState

Current VaultState enum value.

deposit

Deposits supply assets during the Fundraising window. Clamps to remaining capacity instead of reverting on excess.

Notes:

  • error: InvalidState If vault is not in Fundraising state.

  • error: ExceedsMaxCap If clamped deposit amount is zero (vault at capacity).

Parameters

Name
Type
Description

assets

uint256

Requested deposit amount in supply asset units.

receiver

address

Address to receive minted shares.

Returns

Name
Type
Description

shares

uint256

Actual shares minted (may be less than requested if cap approached).

mint

Mints shares during the Fundraising window. Clamps to remaining capacity instead of reverting on excess.

Notes:

  • error: InvalidState If vault is not in Fundraising state.

  • error: ExceedsMaxCap If clamped share amount is zero (vault at capacity).

Parameters

Name
Type
Description

shares

uint256

Requested shares to mint.

receiver

address

Address to receive minted shares.

Returns

Name
Type
Description

assets

uint256

Actual supply assets pulled (may be less than requested if cap approached).

withdraw

Withdraws supply assets in terminal states. Advances state before checking max, enabling single-tx withdrawals when the vault is ready to transition (e.g. PendingSettlement -> Matured).

Notes:

  • error: InvalidState If vault is not in a terminal state (Matured/Failed/Liquidated).

  • error: ExceedsMaxCap If requested assets exceed the caller's withdrawable balance.

Parameters

Name
Type
Description

assets

uint256

Amount of supply assets to withdraw.

receiver

address

Address to receive the assets.

owner

address

Share holder address.

Returns

Name
Type
Description

shares

uint256

Shares burned.

redeem

Redeems shares for supply assets in terminal states. Advances state before checking max, enabling single-tx redemptions when the vault is ready to transition (e.g. PendingSettlement -> Matured).

Notes:

  • error: InvalidState If vault is not in a terminal state (Matured/Failed/Liquidated).

  • error: ExceedsMaxCap If requested shares exceed the caller's redeemable balance.

Parameters

Name
Type
Description

shares

uint256

Shares to redeem.

receiver

address

Address to receive the assets.

owner

address

Share holder address.

Returns

Name
Type
Description

assets

uint256

Supply assets returned.

totalAssets

State-dependent total assets backing outstanding shares.

Matured/Failed/Liquidated: settlementAmount (decremented on each withdrawal). All other states: totalRaised.

Returns

Name
Type
Description

<none>

uint256

Total assets in supply asset units.

maxDeposit

Remaining deposit capacity in supply asset units. Zero outside Fundraising state.

Returns

Name
Type
Description

<none>

uint256

Maximum depositable amount.

maxMint

Share equivalent of maxDeposit.

Parameters

Name
Type
Description

receiver

address

Receiver address (passed through to maxDeposit).

Returns

Name
Type
Description

<none>

uint256

Maximum mintable shares.

maxWithdraw

Withdrawable supply asset amount for a supplier. Zero outside terminal states.

Parameters

Name
Type
Description

owner

address

Share holder address.

Returns

Name
Type
Description

<none>

uint256

Maximum withdrawable supply asset amount.

maxRedeem

Redeemable share amount for a supplier. Zero outside terminal states.

Parameters

Name
Type
Description

owner

address

Share holder address.

Returns

Name
Type
Description

<none>

uint256

Maximum redeemable share amount.

Events

StateTransition

VaultClosed

SettlementConfirmed

ShortfallDetected

PSRNotificationFailed

RaisedFundsClaimed

Repaid

PauseLevelSet

TokensSwept

Errors

InvalidState

SameStateTransition

BelowMinimumDepositAmount

ExceedsMaxCap

Unauthorized

AlreadyWithdrawn

NoOutstandingDebt

ZeroRepayAmount

NothingToSweep

PartiallyPaused

CompletelyPaused

Last updated