Zenji Vault

Zenji is the core ERC4626 vault contract. It handles share accounting, collateralized leverage, strategy deployment, and unwind logic for withdrawals.

Core Components

Zenji (ERC4626)

Deposits, share mint/burn, fee accounting, rebalancing triggers, emergency controls.

Loan Manager

Maintains collateral/debt position and exposes collateral/debt conversion and health checks.

Yield Strategy

Deploys borrowed debt asset, reports strategy value, and harvests rewards.

Two Forms of Collateral Value

The vault exposes value in collateral units (via getTotalCollateral()). Internally, this comes from two sources:

  1. Direct collateral inventory: collateral token balances in the vault and loan manager path.
  2. Debt-side value converted back to collateral: strategy and idle debt asset balances translated into collateral-equivalent value through loan manager pricing.

This design lets shares represent one unified collateral-denominated claim while the strategy side can stay in debt asset form.

User-Facing Functions

  • deposit(assets, receiver): deposit collateral and mint shares.
  • mint(shares, receiver): mint exact shares (vault calculates required assets).
  • withdraw(assets, receiver, owner): withdraw exact collateral amount.
  • redeem(shares, receiver, owner): burn exact shares for collateral.

Withdraw paths can partially or fully unwind debt/strategy positions depending on liquidity and requested size.

Permissionless Maintenance

  • rebalance(): adjusts LTV back toward target when outside deadband.
  • harvestYield(): claims/compounds strategy rewards.
  • accrueYieldFees(): realizes protocol fees from strategy profit deltas.

Bounded Parameters

Owner can change selected settings, but values are bounded in contract constants:

  • Target LTV: 15% to 65%
  • Fee rate: capped at 20%
  • Rebalance bounty rate: capped at 50%
  • Vault max slippage: capped at 10%

Risk Controls

  • Deadband rebalancing around target LTV
  • Oracle freshness checks on loan-manager pricing paths
  • Reentrancy protection on state-changing entry points
  • One-block action delay to reduce same-block transfer/redeem bypasses
  • Emergency mode one-way latch with staged unwind flow

Emergency mode is for controlled unwind and pro-rata exits. It is not a reversible pause switch.