Overview
Fund mode implements input-driven deposit flows where users select the amount they want to send. The widget automatically routes funds from any supported chain/token to the destination. Trade Type:EXACT_INPUT - User specifies input amount, variable output amount after fees.
Configuration
Required Props
| Prop | Type | Description |
|---|---|---|
mode | "fund" | Sets the widget to fund mode |
Optional Props
| Prop | Type | Description |
|---|---|---|
toAmount | string | Pre-set deposit amount (user can still modify) |
toAddress | string | Destination address or contract |
toChainId | number | Destination chain ID |
toToken | string | Destination token symbol or address |
toCalldata | string | Calldata to execute on destination |
slippageTolerance | string | number | Slippage tolerance (default: 0.5%) |
quoteProvider | QuoteProvider | Specific quote provider |
Implementation
Basic Chain Funding
Simple deposit to a chain:Fixed Amount Deposit
Pre-populate a specific amount:Protocol Deposit with Static Calldata
Deposit into a DeFi protocol with predefined parameters:Dynamic Amount Protocol Deposit
Use placeholder amount for user-selected deposit amounts in calldata:Dynamic Calldata Pattern
When the deposit amount is part of the calldata and user-selected, useTRAILS_CONTRACT_PLACEHOLDER_AMOUNT:
Why it’s needed: In fund mode, the final output amount after swaps/bridging isn’t known until execution. The placeholder gets replaced with the actual output amount.
When to use:
- ERC-4626 vault deposits with dynamic amounts
- Staking contracts that require amount parameter
- Any function where amount is a parameter and user-selectable
- Simple transfers to addresses
- Static calldata where amount isn’t a parameter
- Functions that read balance directly (e.g.,
depositAll())
Event Handlers
Use Cases
- Chain Onboarding: Help users get started on new chains
- Protocol Deposits: Deposit into lending protocols (Aave, Compound, Morpho)
- Vault Deposits: Fund yield aggregators and vaults
- Perp Exchange Funding: Deposit into perpetual exchanges
- Liquidity Provision: Add liquidity to AMMs and pools
- Staking: Fund staking contracts
See Also
- Use Case Examples - Detailed implementation patterns
- Configuration Reference - Full configuration options