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
TRAILS_ROUTER_PLACEHOLDER_AMOUNT stands in for the arrived amount in your calldata. Trails substitutes the real figure at execution time, so slippage and bridge variance are absorbed automatically.
Encoding a composable action
PassdestinationCalldata with the encoded function call for whatever action you want executed on arrival. The example below deposits into an ERC-4626 yield vault, but the same pattern works for any protocol:
What you can compose
Any protocol interaction that takes a token amount as input works with this pattern:| Action | ABI function | Notes |
|---|---|---|
| Yield vault deposit | deposit(uint256 assets, address receiver) | ERC-4626 standard |
| Liquidity provision | addLiquidity(...) | AMM-specific ABI |
| Staking | stake(uint256 amount) | Protocol-specific |
| Lending supply | supply(address asset, uint256 amount, ...) | Aave-style |
| Custom contract call | Any payable function | Encode via encodeFunctionData |
Widget integration
For drop-in UI, passtoCalldata to the Trails Widget. The widget handles the full funding and action flow:
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, permit signing, 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.