Skip to main content
This guide shows you how to let a customer open a yield position in one step: they fund from whatever they hold, and the deposit into the lending market or vault happens as part of the same intent. You need an OMS publishable key (pk_...) and the SDK installed.

Let the customer pick a market

Render Earn with no destination to show the market selector. The customer chooses a market, a funding source, and an amount.
Markets include Aave lending pools and Morpho vaults across supported chains. The widget includes a withdrawal tab for existing positions.

Deposit into a market you choose

Most products offer a fixed set of markets. Encode the market’s deposit call and pass it as to.calldata, with TRAILS_HYDRATE_PLACEHOLDER_AMOUNT where the amount goes. At execution, the placeholder is replaced with the amount that actually arrived, so the deposit uses every token that landed after fees.
Set the vault’s share recipient to the customer’s address, as above, so the position belongs to them. To fund a vault from a card, pass paymentMethod="CREDIT_DEBIT_CARD". For more on encoding destination calls, see contract calls on arrival.

Find markets

useEarnMarkets lists markets you can offer, filtered by chain, provider, and type, and sorted by rate. It requires TrailsProvider; see React hooks.

Show a customer’s positions

useEarnBalances returns a wallet’s positions on one or more chains. It reads public state and does not need a connected wallet.

From your server

To deposit without the widget, quote an intent with destinationCallData set to the encoded deposit. See quotes and execution.