What ERC4626 defines
An ERC4626 vault is an ERC20 contract that holds one underlying token. Depositors receive share tokens, and the ratio of total assets to total shares sets the price of a share. The standard fixes the interface, so aggregators and front ends integrate any vault the same way, whatever strategy runs behind it. The lifecycle has four entry points:deposit and mint move assets in, and
withdraw and redeem move them out. View functions such as convertToShares
and previewDeposit let clients compute amounts before they send a transaction.
The accounts behind a Solana vault
An ERC4626 contract is the vault, the custodian, and the share token at once. On Solana, these are separate accounts that one program controls through a PDA:One vault program can serve many vaults. Each vault is a set of accounts.
| Piece | Account | Purpose |
|---|---|---|
| Underlying asset | An existing mint | The token the vault accepts, such as USDC |
| Shares | A new mint with the PDA as mint authority | Tracks proportional ownership of the vault |
| Custody | A token account owned by the PDA | Holds the deposited assets |
| Vault state | A small data account | Stores the share mint, the total assets, the PDA bump, and settings |
| Authority | A PDA derived from the vault state address | Signs transfers out of the vault and share mints |
ERC4626 functions on Solana
State-changing functions become instructions of your program. View functions become account reads on the client.| ERC4626 | Solana | How it maps |
|---|---|---|
asset() | The underlying mint address | Read it from the vault token account or the vault state. |
totalAssets() | Vault state field | Read the total that the program tracks in vault state. The live token balance can be changed by anyone who sends tokens to the vault. |
totalSupply() | Share mint supply | Read supply from the share mint. |
deposit(), mint() | A deposit instruction | Transfer assets into the vault and mint shares to the depositor. An exact-shares mint variant rounds the assets up. |
withdraw(), redeem() | A redeem instruction | Burn the holder’s shares and transfer assets out, signed by the PDA. An exact-assets withdraw variant rounds the shares up. |
convertTo*, preview* | Client-side math or simulation | Compute from the two balances, or simulate the transaction to see exact balance changes before signing. |
| Share token transfers | Token Program transfers | Shares are a regular token. Wallets and other programs handle them like any mint. |
| Redeeming for another owner | A delegate on the share account | The share holder approves a delegate, which then signs the redeem. |
Deposit and redeem
A deposit is one instruction that makes two cross-program invocations (CPIs) to the Token Program. The first depositor receives shares one to one. Later depositors receiveassets × share supply ÷ total assets. The example computes
from the total that the vault tracks in its state, so tokens sent straight to
the vault cannot change the share price.
1
User calls deposit
The transaction lists the user’s token accounts, the vault token account, the
share mint, and the vault state.
3
Transfer assets in
A CPI moves the assets from the user to the vault. The user’s signature
authorizes it.
shares × total assets ÷ share supply.
1
User calls redeem
The transaction lists the same accounts as a deposit.
2
Compute assets
The program calculates the assets owed for the shares.
4
Transfer assets out
A CPI moves the assets to the user. The PDA signs for the vault token account.
Design differences
ERC4626 vault
- One contract is the vault and the share token.
- Many vaults add a
nonReentrantguard to deposit and redeem. - View functions on the contract return previews.
- Each vault is a new contract deployment.
Solana vault
- The share token is a separate mint that the vault’s PDA controls.
- The runtime blocks reentrancy from the Token Program back into your program.
- Every account is listed up front, so wallets simulate the transaction and show the balance changes.
- One program can create any number of vaults as new accounts.
Pitfalls to check
Vault bugs are usually math or account-validation bugs. Check each item before you deploy.- Compute shares before you transfer tokens. Account data you loaded earlier does not update after a CPI unless you reload it.
- Round in the vault’s favor: round shares down on deposit and assets down on redeem. Exact-output variants round the other way, with shares up on withdraw and assets up on mint.
- Track total assets in vault state, as the example does. A vault that reads its live token balance lets an attacker donate tokens to an empty vault and inflate the share price.
- Do the math in
u128with checked operations, return an error on overflow or division by zero, and reject deposits that would mint zero shares. - Validate that the vault token account, the share mint, and the PDA seeds match the vault state. Callers choose the accounts they pass in.
- Derive the vault’s authority PDA from the vault state address. A single PDA shared by every vault would hold authority over all of them.
- If the underlying mint uses Token Extensions with transfer fees, the vault receives less than the amount sent. Reload the vault token account after the transfer and credit the difference.