A variety of DeFi applications enable users to earn yield by depositing liquidity into their protocol. This is a complex task as users must evaluate which protocols have the best yield for each chain and asset that also meets their risk profile. Then find a bridge, manually move their liquidity to the desired chain, potentially swap to the vault or pool asset, and finally interact with the protocol.Trails simplifies this by natively integrating with DeFi protocols for easy integration. Additionally, developers can specify any arbitrary logic and pass it to trails for more complex or custom flows.For users, all the complexity is handled for them including swapping and bridging to the corresponding vault or pool token in a single transaction to immediately begin earning yield.
This example shows how to use the Trails widget to deposit USDC into Aave’s lending pool on Base where the user can utilize any token from any chain which automatically swaps to the corresponding pool token.
Copy
Ask AI
import { TrailsWidget } from '0xtrails/widget'import { encodeFunctionData } from 'viem'import { aaveABI } from './abi.ts'export const AaveDepositExample = () => { // Aave V3 Pool contract on Base const AAVE_POOL_CONTRACT = "0xa0d9C1E9E48Ca30c8d8C3B5D69FF5dc1f6DFfC24" // Encode the deposit function call on Aave const depositCalldata = encodeFunctionData({ abi: aaveABI, functionName: 'depositETH', args: [ "0xA238Dd80C259a72e81d7e4664a9801593F98d1c5", // pool address "0x97c4a952b46becad0663f76357d3776ba11566e1", // onBehalfOf 0, // referralCode ], }) return ( <TrailsWidget toAddress={AAVE_POOL_CONTRACT} toAmount="100" // 100 USDC toChainId={8453} // Base toToken="USDC" toCalldata={depositCalldata} theme="auto" /> )}