> ## Documentation Index
> Fetch the complete documentation index at: https://anypay-docs-update-resources-2026-06-29.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# YieldGetMarkets

> List and filter DeFi markets available through the Trails earn system

## Overview

`YieldGetMarkets` returns DeFi markets available for deposit through Trails, including lending markets (Aave, Morpho) and yield vaults (Yearn, ERC-4626). Use this to power market selection UIs or discover `marketId` values for composable actions.

The SDK's `useEarnMarkets` hook wraps this endpoint with typed filters and caching — prefer it in React apps.

## Request Parameters

All fields are optional.

| Field      | Type   | Description                                               |
| ---------- | ------ | --------------------------------------------------------- |
| `provider` | string | Filter by protocol (e.g. `"aave"`, `"morpho"`, `"yearn"`) |
| `chainId`  | string | Filter by chain ID (e.g. `"8453"` for Base)               |
| `type`     | string | Market category: `"lending"` or `"vault"`                 |
| `search`   | string | Free-text search over market names and tokens             |
| `sort`     | string | Sort order (e.g. `"rewardRateDesc"`)                      |
| `limit`    | number | Number of results to return                               |
| `offset`   | number | Pagination offset                                         |

## Response

Returns `payload` containing an array of market objects. Each market includes:

| Field               | Description                                                                |
| ------------------- | -------------------------------------------------------------------------- |
| `id`                | Unique market ID — pass this to `lend()` or `deposit()` composable actions |
| `providerId`        | Protocol identifier (e.g. `"aave"`, `"morpho"`)                            |
| `rewardRate`        | Current APY as a decimal (e.g. `0.045` = 4.5%)                             |
| `statistics.tvlUsd` | Total value locked in USD                                                  |
| `metadata.name`     | Human-readable market name                                                 |
| `metadata.token`    | Underlying token info (symbol, address, decimals)                          |

## Examples

### List all markets on Base

```typescript theme={null}
const response = await fetch('https://trails-api.sequence.app/rpc/Trails/YieldGetMarkets', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Access-Key': 'YOUR_ACCESS_KEY',
  },
  body: JSON.stringify({
    chainId: '8453',
    limit: 20,
    offset: 0,
  }),
})

const { payload } = await response.json()
const markets = JSON.parse(payload)

markets.forEach(market => {
  console.log(`${market.id}: ${(market.rewardRate * 100).toFixed(2)}% APY`)
})
```

### Filter lending markets by protocol

```typescript theme={null}
const response = await fetch('https://trails-api.sequence.app/rpc/Trails/YieldGetMarkets', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Access-Key': 'YOUR_ACCESS_KEY',
  },
  body: JSON.stringify({
    provider: 'aave',
    type: 'lending',
    sort: 'rewardRateDesc',
  }),
})

const { payload } = await response.json()
const markets = JSON.parse(payload)
```

### Search for USDC markets

```typescript theme={null}
const response = await fetch('https://trails-api.sequence.app/rpc/Trails/YieldGetMarkets', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Access-Key': 'YOUR_ACCESS_KEY',
  },
  body: JSON.stringify({
    search: 'usdc',
    sort: 'rewardRateDesc',
    limit: 10,
  }),
})
```

## SDK alternative

In React, use the typed `useEarnMarkets` hook instead of calling this endpoint directly:

```tsx theme={null}
import { useEarnMarkets } from '0xtrails'

const { data: markets, isLoading } = useEarnMarkets({
  chain: 'base',
  type: 'lending',
  provider: 'aave',
  search: 'usdc',
  sortBy: 'rewardRateDesc',
  limit: 20,
})

// markets[i].id → pass to lend() or deposit() actions
```

## See also

* [YieldGetProviders](/api-reference/endpoints/yield-get-providers) — List available protocols
* [Markets & Providers](/sdk/composable-actions/markets-and-providers) — SDK hooks reference


## OpenAPI

````yaml trails-api.gen.json post /rpc/Trails/YieldGetMarkets
openapi: 3.0.0
info:
  title: Trails API
  version: 0.0.1
servers:
  - url: https://trails-api.sequence.app
    description: Trails API
security: []
paths:
  /rpc/Trails/YieldGetMarkets:
    post:
      tags:
        - Trails
      summary: YieldGetMarkets returns DeFi markets with optional filters.
      description: >
        Returns yield-bearing markets (lending pools, ERC-4626 vaults) with APY,
        TVL, and market IDs

        for use with composable actions. Use marketId values with the lend() and
        deposit() SDK builders.
      operationId: Trails-YieldGetMarkets
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GetYieldMarketsRequest'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetYieldMarketsResponse'
        4XX:
          description: Client error
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/ErrorWebrpcEndpoint'
                  - $ref: '#/components/schemas/ErrorWebrpcRequestFailed'
                  - $ref: '#/components/schemas/ErrorWebrpcBadRoute'
                  - $ref: '#/components/schemas/ErrorWebrpcBadMethod'
                  - $ref: '#/components/schemas/ErrorWebrpcBadRequest'
                  - $ref: '#/components/schemas/ErrorInvalidArgument'
                  - $ref: '#/components/schemas/ErrorUnavailable'
                  - $ref: '#/components/schemas/ErrorNotFound'
        5XX:
          description: Server error
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/ErrorWebrpcBadResponse'
                  - $ref: '#/components/schemas/ErrorWebrpcServerPanic'
                  - $ref: '#/components/schemas/ErrorWebrpcInternalError'
                  - $ref: '#/components/schemas/ErrorUnexpected'
components:
  schemas:
    GetYieldMarketsRequest:
      type: object
      properties:
        provider:
          type: string
          description: Filter by protocol ID (e.g. "aave", "morpho", "yearn")
        chainId:
          type: string
          description: Filter by chain ID as a string (e.g. "8453" for Base)
        type:
          type: string
          description: 'Market category: "lending" or "vault"'
        search:
          type: string
          description: Free-text search over market names and tokens
        sort:
          type: string
          description: Sort order (e.g. "rewardRateDesc")
        limit:
          type: integer
          format: int32
          description: Number of results to return
        offset:
          type: integer
          format: int32
          description: Pagination offset
    GetYieldMarketsResponse:
      type: object
      required:
        - payload
      properties:
        payload:
          type: object
          description: JSON array of market objects from the yield provider
          additionalProperties: true
    ErrorWebrpcEndpoint:
      type: object
      required:
        - error
        - code
        - msg
        - status
      properties:
        error:
          type: string
          example: WebrpcEndpoint
        code:
          type: number
          example: 0
        msg:
          type: string
          example: endpoint error
        cause:
          type: string
        status:
          type: number
          example: 400
    ErrorWebrpcRequestFailed:
      type: object
      required:
        - error
        - code
        - msg
        - status
      properties:
        error:
          type: string
          example: WebrpcRequestFailed
        code:
          type: number
          example: -1
        msg:
          type: string
          example: request failed
        cause:
          type: string
        status:
          type: number
          example: 400
    ErrorWebrpcBadRoute:
      type: object
      required:
        - error
        - code
        - msg
        - status
      properties:
        error:
          type: string
          example: WebrpcBadRoute
        code:
          type: number
          example: -2
        msg:
          type: string
          example: bad route
        cause:
          type: string
        status:
          type: number
          example: 404
    ErrorWebrpcBadMethod:
      type: object
      required:
        - error
        - code
        - msg
        - status
      properties:
        error:
          type: string
          example: WebrpcBadMethod
        code:
          type: number
          example: -3
        msg:
          type: string
          example: bad method
        cause:
          type: string
        status:
          type: number
          example: 405
    ErrorWebrpcBadRequest:
      type: object
      required:
        - error
        - code
        - msg
        - status
      properties:
        error:
          type: string
          example: WebrpcBadRequest
        code:
          type: number
          example: -4
        msg:
          type: string
          example: bad request
        cause:
          type: string
        status:
          type: number
          example: 400
    ErrorInvalidArgument:
      type: object
      required:
        - error
        - code
        - msg
        - status
      properties:
        error:
          type: string
          example: InvalidArgument
        code:
          type: number
          example: 2000
        msg:
          type: string
          example: Invalid argument
        cause:
          type: string
        status:
          type: number
          example: 400
    ErrorUnavailable:
      type: object
      required:
        - error
        - code
        - msg
        - status
      properties:
        error:
          type: string
          example: Unavailable
        code:
          type: number
          example: 2002
        msg:
          type: string
          example: Unavailable resource
        cause:
          type: string
        status:
          type: number
          example: 400
    ErrorNotFound:
      type: object
      required:
        - error
        - code
        - msg
        - status
      properties:
        error:
          type: string
          example: NotFound
        code:
          type: number
          example: 8000
        msg:
          type: string
          example: Resource not found
        cause:
          type: string
        status:
          type: number
          example: 400
    ErrorWebrpcBadResponse:
      type: object
      required:
        - error
        - code
        - msg
        - status
      properties:
        error:
          type: string
          example: WebrpcBadResponse
        code:
          type: number
          example: -5
        msg:
          type: string
          example: bad response
        cause:
          type: string
        status:
          type: number
          example: 500
    ErrorWebrpcServerPanic:
      type: object
      required:
        - error
        - code
        - msg
        - status
      properties:
        error:
          type: string
          example: WebrpcServerPanic
        code:
          type: number
          example: -6
        msg:
          type: string
          example: server panic
        cause:
          type: string
        status:
          type: number
          example: 500
    ErrorWebrpcInternalError:
      type: object
      required:
        - error
        - code
        - msg
        - status
      properties:
        error:
          type: string
          example: WebrpcInternalError
        code:
          type: number
          example: -7
        msg:
          type: string
          example: internal error
        cause:
          type: string
        status:
          type: number
          example: 500
    ErrorUnexpected:
      type: object
      required:
        - error
        - code
        - msg
        - status
      properties:
        error:
          type: string
          example: Unexpected
        code:
          type: number
          example: 2001
        msg:
          type: string
          example: Unexpected server error
        cause:
          type: string
        status:
          type: number
          example: 500

````