What is a Vault?
A vault in Mewler is an isolated lending market for a single ERC-20 token. Each vault operates independently with its own:- Interest rate model
- Collateral and borrowing parameters
- Oracle configuration
- Risk parameters
Vault Types
Borrowable Vaults
Borrowable vaults allow users to:- Deposit assets to earn interest (supply)
- Use deposited assets as collateral to borrow other assets
- Borrow the vault’s underlying asset
Collateral-Only Vaults
Some vaults are configured as collateral-only, meaning:- Users can deposit assets to earn interest
- Deposited assets can be used as collateral in other vaults
- The vault’s underlying asset cannot be borrowed
Vault Accounting
Share-Based Model
Mewler uses a share-based accounting model similar to ERC-4626:- When you deposit assets, you receive vault shares (eTokens)
- Shares represent your proportional claim on the vault’s assets
- As interest accrues, the share price increases
- When you withdraw, shares are redeemed at the current share price
Share Price Calculation
Example
- Alice deposits 100 USDC when share price = 1.0
- Receives: 100 eUSDC shares
- Interest accrues, vault now has 110 USDC
- Share price = 110 / 100 = 1.1
- Bob deposits 110 USDC
- Receives: 100 eUSDC shares (110 / 1.1)
- Total: 220 USDC, 200 shares, share price = 1.1
- Alice can redeem 100 shares for 110 USDC
- Bob can redeem 100 shares for 110 USDC
Vault Parameters
Collateral Factor
The collateral factor determines how much you can borrow against your collateral:- 750
Liquidation Threshold
The liquidation threshold is the health score at which a position becomes liquidatable. Typically set lower than the collateral factor to provide a buffer.Interest Rate Model
Each vault has an Interest Rate Model (IRM) that determines:- Supply APY: Interest earned by lenders
- Borrow APY: Interest paid by borrowers
Creating a Vault
Vaults are created using the Mewler Vault Kit. The process involves:- Deployment: Deploy a new vault contract via the factory
- Configuration: Set parameters like:
- Underlying asset
- Interest rate model
- Collateral factors
- Oracle adapter
- Optional hook targets
- Initialization: Initialize the vault with starting parameters
Vault Lifecycle
Deployment
A vault is deployed as an immutable contract (or upgradeable, depending on configuration).Active Operation
- Users deposit and withdraw
- Borrowers take and repay loans
- Interest accrues continuously
- Liquidations occur when positions become unhealthy
Risk Management
Vault parameters can be adjusted by governance or risk stewards:- Collateral factors
- Interest rate model parameters
- Oracle configurations
- Emergency pauses (if configured)
Cross-Vault Interactions
Using Vault Shares as Collateral
You can use eToken shares from one vault as collateral in another vault. This enables:- Leveraged positions
- Complex DeFi strategies
- Capital efficiency