Skip to main content

Documentation Index

Fetch the complete documentation index at: https://anypay-docs-sdk-0-15-0-updates.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Earn with Trails

Trails simplifies DeFi yield deposits by natively integrating with protocols across chains — surfacing APY, TVL, and other metrics, and handling all swapping and bridging to the vault or pool token in a single transaction.

Use cases

  • Deposit into lending protocols like Aave or Morpho
  • Fund yield aggregator vaults like Yearn Finance
  • Fund auto-compounding yield strategies

Examples

Deposit into a user-selected vault

Trails has integrated multiple DeFi pools and vaults across Aave, Morpho, and others. Users can pick from the integrated set out of the box:
import { Earn } from '0xtrails/widget'

export const App = () => {
  return (
    <Earn
      apiKey="YOUR_API_KEY"
      renderInline={true}
      theme="auto"
      onEarnSuccess={({ sessionId }) => {
        console.log('Deposit completed:', sessionId)
      }}
    />
  )
}

Deposit into a specific DeFi pool

For natively supported protocols like Aave and Morpho, use composable actions — no ABI encoding required. The lend and deposit builders handle the contract calls internally:
import { useTrailsSendTransaction, lend, erc20Utils } from '0xtrails'

export function AaveLendButton({ recipient }: { recipient: `0x${string}` }) {
  const { sendTransaction, isPending } = useTrailsSendTransaction({
    actions: [
      lend({
        marketId: 'base-usdc-aave-v3-lending',
        amount: '100',
      }),
    ],
  })

  return (
    <button
      disabled={isPending}
      onClick={() =>
        sendTransaction({
          to: recipient,
          tokenAddress: erc20Utils.USDC.addressOn('base'),
          tokenAmount: '100',
        })
      }
    >
      {isPending ? 'Sending...' : 'Supply 100 USDC to Aave'}
    </button>
  )
}
Use useEarnMarkets to discover available marketId values at runtime. For protocols not covered by the action builders, see Composable Actions — custom.

Next steps