Deposit & Return
Managing deposits and withdrawals from vaults in the Intuition protocol involves interacting with the EthMultiVault contract to stake and unstake tokens. This process includes proper fee handling and share price calculations.
Prerequisites
This implementation guide assumes that you've completed the setup steps in the Overview guide. Steps for creating the createMultivaultContract and the publicClient referenced in this implementation example can be found in the overview.
Implementation
We recommend creating a multivault.ts that includes the following deposit and withdrawal functionality:
Core Deposit Pattern
// Deposit into vault
const depositConfig = {
...multiVaultContract,
functionName: 'deposit',
args: [vaultId, amount],
}
// Execute transaction
const hash = await walletClient.writeContract(depositConfig)Key Functions
We use these patterns to manage vault deposits and withdrawals:
deposit
Deposit tokens into a vault and receive shares based on current share price.
withdraw
Withdraw tokens from a vault by burning shares at current share price.
estimateDeposit
Estimate the number of shares received for a given deposit amount.
Usage Examples
Basic Deposit
// Deposit into vault
const vaultId = 123n
const amount = parseEther("0.1")
const result = await deposit(
MULTIVAULT_CONTRACT_ADDRESS,
vaultId,
amount,
walletClient,
publicClient
)Basic Withdrawal
// Withdraw from vault
const vaultId = 123n
const shares = parseEther("10")
const result = await withdraw(
MULTIVAULT_CONTRACT_ADDRESS,
vaultId,
shares,
walletClient,
publicClient
)Fee Structure
Understanding Fees
Entry Fee
Fee charged when depositing into a vault, calculated as a percentage of deposit.
Exit Fee
Fee charged when withdrawing from a vault, calculated as a percentage of withdrawal.
Protocol Fee
Fee collected by the protocol for maintaining the system and infrastructure.
Share Price Dynamics
Bonding Curve Mechanics
Price Discovery
Share price increases as more tokens are deposited into the vault.
Early Adopter Advantage
Early depositors receive more shares for the same token amount.
Liquidity Provision
Vaults provide continuous liquidity for depositors and withdrawers.
Best Practices
- Always estimate fees before executing transactions
- Consider share price impact when depositing large amounts
- Implement proper error handling for failed transactions
- Monitor vault state and share prices before transactions
- Use multicall patterns for batch operations
- Provide clear feedback to users about fee structures
Next Steps
After managing deposits and withdrawals, explore:
- Retrieve Vault Details - Get comprehensive vault information
- Create Atom - Create atoms to deposit into
- Create Triple - Create triples with associated vaults
For a full reference implementation, see the Intuition TypeScript SDK.