# Pool (PoolV3)

> Markdown export of the Gearbox Protocol documentation page for agents and retrieval systems.

Canonical page: https://docs.gearbox.finance/developers/gm-ref-pool
Source file: content/developers/gm-ref-pool.mdx
Section router: https://docs.gearbox.finance/developers/llms.txt
Section full export: https://docs.gearbox.finance/developers/llms-full.txt

**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).

```solidity
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.

```solidity
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.

```solidity
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.

```solidity
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.

```solidity
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.

```solidity
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.

```solidity
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.

```solidity
function totalAssets() external view returns (uint256);
```

---

#### convertToShares / convertToAssets

Preview conversion between assets and shares.

```solidity
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.

```solidity
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.

```solidity
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.

```solidity
function asset() external view returns (address);
```

---

### Gearbox-Specific Views

#### availableLiquidity

Returns the amount of underlying tokens available for borrowing.

```solidity
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.

```solidity
function dieselRate() external view returns (uint256);
```

---

#### supplyRate

Returns the annualized supply rate for lenders in RAY.

```solidity
function supplyRate() external view returns (uint256);
```

---

#### baseInterestRate

Returns the annualized borrow rate for Credit Accounts in RAY.

```solidity
function baseInterestRate() external view returns (uint256);
```

---

#### baseInterestIndex

Returns the cumulative interest index used for debt tracking.

```solidity
function baseInterestIndex() external view returns (uint256);
```

---

#### poolQuotaKeeper

Returns the address of the associated PoolQuotaKeeper.

```solidity
function poolQuotaKeeper() external view returns (address);
```

---

#### interestRateModel

Returns the address of the Interest Rate Model contract.

```solidity
function interestRateModel() external view returns (address);
```

---

## Events

### Deposit

```solidity
event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);
```

Emitted on deposit or mint (ERC-4626 standard).

### Withdraw

```solidity
event Withdraw(
    address indexed sender,
    address indexed receiver,
    address indexed owner,
    uint256 assets,
    uint256 shares
);
```

Emitted on withdraw or redeem (ERC-4626 standard).

### Borrow

```solidity
event Borrow(address indexed creditManager, address indexed creditAccount, uint256 amount);
```

Emitted when a Credit Manager borrows from the pool.

### Repay

```solidity
event Repay(address indexed creditManager, uint256 borrowedAmount, uint256 profit, uint256 loss);
```

Emitted when a Credit Manager repays to the pool.

---

## Related Pages

- [Quota Keeper](https://docs.gearbox.finance/developers/gm-ref-qk) -- Manages per-token quota limits and rates
- [Credit Manager](https://docs.gearbox.finance/developers/gm-ref-cm) -- Borrows from the pool on behalf of Credit Accounts
- [Compressors](https://docs.gearbox.finance/developers/gm-ref-compressors) -- Aggregated pool data reading
- [Smart Contracts Overview](https://docs.gearbox.finance/developers/gm-contracts) -- Full contract architecture
