Pool (PoolV3)
PoolV3 is the central vault for a specific underlying asset (e.g., USDC, WETH). It implements the ERC-4626 tokenized vault standard, allowing users to deposit assets and receive Diesel Tokens (LP shares). Only whitelisted Credit Managers can borrow from the pool.
Write Methods
ERC-4626 Standard
deposit
Deposits underlying assets and receives diesel tokens (shares).
function deposit(uint256 assets, address receiver) external returns (uint256 shares);
| Parameter | Type | Description |
|---|---|---|
assets | uint256 | Amount of underlying tokens to deposit |
receiver | address | Address to receive the minted shares |
Returns: Number of shares minted.
mint
Mints an exact number of shares, depositing the required underlying assets.
function mint(uint256 shares, address receiver) external returns (uint256 assets);
| Parameter | Type | Description |
|---|---|---|
shares | uint256 | Exact number of shares to mint |
receiver | address | Address to receive the minted shares |
Returns: Amount of underlying assets deposited.
withdraw
Withdraws an exact amount of underlying assets, burning the required shares.
function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);
| Parameter | Type | Description |
|---|---|---|
assets | uint256 | Exact amount of underlying to withdraw |
receiver | address | Address to receive the assets |
owner | address | Address whose shares are burned |
Returns: Number of shares burned. Reverts if pool is paused or insufficient liquidity.
redeem
Burns an exact number of shares and receives underlying assets.
function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);
| Parameter | Type | Description |
|---|---|---|
shares | uint256 | Exact number of shares to burn |
receiver | address | Address to receive the assets |
owner | address | Address whose shares are burned |
Returns: Amount of underlying assets received.
Gearbox Extensions
depositWithReferral
Deposits underlying assets with on-chain referral tracking.
function depositWithReferral(uint256 assets, address receiver, uint256 referralCode) external returns (uint256 shares);
| Parameter | Type | Description |
|---|---|---|
assets | uint256 | Amount of underlying tokens to deposit |
receiver | address | Address to receive the minted shares |
referralCode | uint256 | Referral code for tracking |
Returns: Number of shares minted.
lendCreditAccount
Lends underlying assets to a Credit Account. Called by the Credit Manager during debt increase.
function lendCreditAccount(uint256 borrowedAmount, address creditAccount) external;
| Parameter | Type | Description |
|---|---|---|
borrowedAmount | uint256 | Amount to lend |
creditAccount | address | Receiving Credit Account |
Access: Whitelisted Credit Manager only.
repayCreditAccount
Repays borrowed assets from a Credit Account. Called by the Credit Manager during debt decrease, closure, or liquidation.
function repayCreditAccount(uint256 repaidAmount, uint256 profit, uint256 loss) external;
| Parameter | Type | Description |
|---|---|---|
repaidAmount | uint256 | Amount being repaid |
profit | uint256 | Profit amount (added to treasury) |
loss | uint256 | Loss amount (may burn treasury shares or socialize) |
Access: Whitelisted Credit Manager only.
View Methods
ERC-4626 Standard
totalAssets
Returns the total value of underlying assets held by the pool.
function totalAssets() external view returns (uint256);
convertToShares / convertToAssets
Preview conversion between assets and shares.
function convertToShares(uint256 assets) external view returns (uint256 shares); function convertToAssets(uint256 shares) external view returns (uint256 assets);
previewDeposit / previewMint / previewWithdraw / previewRedeem
Preview the result of deposit, mint, withdraw, or redeem operations.
function previewDeposit(uint256 assets) external view returns (uint256 shares); function previewMint(uint256 shares) external view returns (uint256 assets); function previewWithdraw(uint256 assets) external view returns (uint256 shares); function previewRedeem(uint256 shares) external view returns (uint256 assets);
maxDeposit / maxMint / maxWithdraw / maxRedeem
Returns the maximum amount that can be deposited, minted, withdrawn, or redeemed.
function maxDeposit(address receiver) external view returns (uint256); function maxMint(address receiver) external view returns (uint256); function maxWithdraw(address owner) external view returns (uint256); function maxRedeem(address owner) external view returns (uint256);
asset
Returns the underlying token address.
function asset() external view returns (address);
Gearbox-Specific Views
availableLiquidity
Returns the amount of underlying tokens available for borrowing.
function availableLiquidity() external view returns (uint256);
dieselRate
Returns the current share price in RAY (27 decimals). Starts at 10^27 and increases as interest accrues.
function dieselRate() external view returns (uint256);
supplyRate
Returns the annualized supply rate for lenders in RAY.
function supplyRate() external view returns (uint256);
baseInterestRate
Returns the annualized borrow rate for Credit Accounts in RAY.
function baseInterestRate() external view returns (uint256);
baseInterestIndex
Returns the cumulative interest index used for debt tracking.
function baseInterestIndex() external view returns (uint256);
poolQuotaKeeper
Returns the address of the associated PoolQuotaKeeper.
function poolQuotaKeeper() external view returns (address);
interestRateModel
Returns the address of the Interest Rate Model contract.
function interestRateModel() external view returns (address);
Events
Deposit
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
Emitted on deposit or mint (ERC-4626 standard).
Withdraw
event Withdraw( address indexed sender, address indexed receiver, address indexed owner, uint256 assets, uint256 shares );
Emitted on withdraw or redeem (ERC-4626 standard).
Borrow
event Borrow(address indexed creditManager, address indexed creditAccount, uint256 amount);
Emitted when a Credit Manager borrows from the pool.
Repay
event Repay(address indexed creditManager, uint256 borrowedAmount, uint256 profit, uint256 loss);
Emitted when a Credit Manager repays to the pool.
Related Pages
- Quota Keeper -- Manages per-token quota limits and rates
- Credit Manager -- Borrows from the pool on behalf of Credit Accounts
- Compressors -- Aggregated pool data reading
- Smart Contracts Overview -- Full contract architecture