Trails lets you compose multiple onchain operations: bridge, swap, deposit, stake, or any contract call, into a single user-facing transaction. The user approves once. Trails handles routing, execution, and gas across every step. This is the foundation for any flow where funds need to move and land in a specific protocol state: a yield vault, a liquidity position, a staking contract, a cross-chain swap. The source chain, token, and amount are flexible. The destination action is whatever your protocol requires.Documentation Index
Fetch the complete documentation index at: https://docs.polygon.technology/llms.txt
Use this file to discover all available pages before exploring further.
How it works
deposit, lend, swap, and assertCondition. Amounts are human-readable decimal strings, so "100" means 100 USDC when the selected token is USDC.
Composing actions
The example below routes funds to Polygon USDC, lends 10 USDC into an Aave USDC market, swaps the remaining USDC to USDT, then deposits the USDT into a Morpho vault. UseuseEarnMarkets to discover live marketId values for Morpho, Aave, and other supported earn providers.
What you can compose
Use typed builders for common money actions:| Action | Builder | Notes |
|---|---|---|
| Yield vault deposit | deposit({ marketId, amount }) | ERC-4626-style vaults such as Morpho |
| Lending supply | lend({ marketId, amount }) | Lending markets such as Aave |
| Destination swap | swap({ tokenIn, tokenOut, amountIn }) | On-chain swap after funds arrive |
| Safety check | assertCondition({ erc20Balance }) | Reverts the whole destination batch if the condition fails |
| Custom contract call | custom(...) or to.calls | Escape hatch for unsupported protocols |
dynamic() when a later action should consume whatever amount is available at execution time:
Widget integration
For built-in earn flows, use theEarn mode widget. It gives users a ready-made UI for depositing into supported earn markets:
useQuote({ actions }) as shown above so your app controls the exact destination actions.
Example: yield accounts
One common use of composable actions is offering savings accounts in a fintech or neobank app. Users deposit USDC into a yield vault. The entire flow (bridge, swap, deposit) happens in a single tap, with no gas, no wallet management, and no protocol knowledge required from the user.Offer yield accounts to your users
Step-by-step guide: wallet setup, Morpho vault deposit with composable actions, and withdraw flow.
Next steps
Fund from Anywhere
Let users fund your protocol from any token, chain, credit card, or bank account.
Smart Sessions
Automate recurring actions without per-transaction prompts.
Trails API reference
Full endpoint reference for QuoteIntent, CommitIntent, and ExecuteIntent.