Overview
Earn mode enables users to deposit into DeFi protocols for yield generation and staking. It supports both pre-integrated protocols (Aave, Morpho) and custom contract integrations with arbitrary calldata.Earn mode includes both deposit and withdrawal tabs. To deep-link users directly into withdrawals, use Withdraw mode.
Quick start
Props
Required
Destination (optional)
Source (optional)
Thefrom shape is a discriminated union on paymentMethod.
Crypto source (paymentMethod is "CONNECTED_WALLET", "EXCHANGE", "CRYPTO_TRANSFER", or omitted):
Fiat source (
paymentMethod is "CREDIT_DEBIT_CARD"):
Payment method (optional)
paymentMethod controls how the user sources funds:
Lifecycle callbacks
intentId identifies the intent behind this flow and is what you pass to the Trails API or Trailscan to look it up. It is null for passthrough
quotes. See Callback payloads.
Examples
Protocol selection — user picks everything
Fixed amount protocol deposit
Deposit 1 USDC into Aave V3 on Arbitrum:ERC-4626 vault with dynamic amount
UseTRAILS_HYDRATE_PLACEHOLDER_AMOUNT when the deposit amount is a parameter and the user selects it:
Use
TRAILS_HYDRATE_PLACEHOLDER_AMOUNT when:- Deposit amount is a function parameter
- User selects the deposit amount
- Amount needs to reflect post-swap/bridge output
depositAll()).Composable actions (pre-integrated protocols)
For Aave, Compound, Morpho, Yearn, and other natively supported protocols, use composable actions instead of manual calldata encoding:useEarnMarkets to discover available market IDs. See Markets and Providers.
Calldata reference
When to use TRAILS_HYDRATE_PLACEHOLDER_AMOUNT
TRAILS_HYDRATE_PLACEHOLDER_AMOUNT is uint256.max internally. Trails replaces it with the actual output amount at execution time.
See also
- Earn use cases — DeFi integration patterns
- Composable actions — programmatic protocol deposits
- Fund mode — similar input-driven flow
- Configuration reference — full prop list