Skip to main content

Documentation Index

Fetch the complete documentation index at: https://yieldxyz.mintlify.app/llms.txt

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

Overview

Patterns for getting better results from AI assistants when building with Yield.xyz. These prompts are designed to work with the Yield.xyz OpenAPI spec and our documentation.

Discovery Prompts

List Yields with Filtering

Using the Yield.xyz API, create a function that:
1. Lists all yield opportunities on Ethereum
2. Filters by type (staking, lending, vault)
3. Sorts by APY descending
4. Returns the top 10 results

Use the GET /v1/yields endpoint with appropriate query parameters.

Get Yield Details

Using the Yield.xyz API GET /v1/yields/{yieldId} endpoint, 
create a function that fetches yield metadata and extracts:
- Name and description
- Current APY/APR with breakdown by source
- Required arguments for entering
- Cooldown and warmup periods
- Supported input tokens

Fetch Validators

Using the Yield.xyz API, write a function to:
1. Get validators for cosmos-atom-native-staking
2. Filter by preferred validators
3. Sort by APR
4. Return validator address, name, and commission

Use GET /v1/yields/{yieldId}/validators endpoint.

Action Prompts

Enter a Yield Position

Create a complete TypeScript function to enter a yield position 
using the Yield.xyz API:

1. Call POST /v1/actions/enter with:
   - yieldId: "ethereum-eth-lido-staking"
   - address: user's wallet address
   - arguments: { amount: "1000000000000000000" }

2. For each transaction in the response:
   - Sign the unsignedTransaction with the wallet
   - Broadcast to the network
   - Call PUT /v1/transactions/{transactionId}/submit-hash with the hash

3. Handle errors and return the action status

Include proper TypeScript types based on the API response schema.

Exit a Position

Using the Yield.xyz API, create a function to exit a yield position:

1. POST /v1/actions/exit with yieldId, address, and amount
2. Process each transaction in order (synchronous execution)
3. Submit transaction hashes after each broadcast
4. Poll the action status until completed

Handle partial exits with specific amounts and full exits.

Manage Actions (Claim Rewards)

Using the Yield.xyz API, implement reward claiming:

1. First, get balances using POST /v1/yields/{yieldId}/balances
2. Find balances with type "claimable" that have pendingActions
3. Extract the passthrough from the pendingAction
4. Call POST /v1/actions/manage with:
   - yieldId
   - address
   - action: "CLAIM_REWARDS" 
   - passthrough: from step 3
5. Execute the returned transactions

The passthrough is required and comes from the balance endpoint.

Portfolio Prompts

Get All User Balances

Using the Yield.xyz API POST /v1/yields/balances endpoint, 
create a function that:

1. Takes an array of { address, network } objects
2. Fetches balances for all addresses
3. Groups results by balance type:
   - active: earning positions
   - claimable: rewards ready to claim
   - withdrawable: exited positions ready to withdraw
   - entering: pending entry
   - exiting: pending exit
   - locked: locked positions

4. Calculates total USD value per type
5. Returns a structured portfolio summary

Track Position Lifecycle

Create a React hook that tracks yield position lifecycle:

1. Polls GET /v1/yields/{yieldId}/balances every 30 seconds
2. Tracks state transitions (entering → active → exiting → withdrawable)
3. Shows countdown for cooldown periods
4. Highlights claimable rewards
5. Triggers notifications on state changes

Use the balance type field to determine current state.

Complete Integration Prompts

Full Staking Flow

Build a complete staking integration with Yield.xyz API:

1. Discovery:
   - GET /v1/yields?network=ethereum&type=staking
   - Display yield cards with APY, token, and protocol

2. Yield Details:
   - GET /v1/yields/{yieldId}
   - Show mechanics.arguments.enter schema for required fields
   - If requiresValidatorSelection, fetch validators

3. Enter Position:
   - POST /v1/actions/enter with user inputs
   - Sign and broadcast transactions
   - Submit hashes

4. Track Position:
   - POST /v1/yields/{yieldId}/balances
   - Show active balance and any pending actions

5. Exit Position:
   - POST /v1/actions/exit
   - Handle cooldown period display
   - Show withdrawable balance when ready

Include error handling for each step.

Multi-Network Portfolio

Create a portfolio dashboard that:

1. Fetches all positions across Ethereum, Polygon, Cosmos, Solana
2. Uses POST /v1/yields/balances with multiple addresses
3. Groups by:
   - Network
   - Protocol/Provider
   - Balance type
4. Shows:
   - Total AUM in USD
   - Projected daily/monthly yield
   - Pending actions (claims, withdrawals)
5. Enables one-click claim all rewards

Error Handling Prompts

Handle API Errors

Using the Yield.xyz API error response format, create an 
error handler that:

1. Handles 400 - Validation errors (show field-level messages)
2. Handles 401 - Auth errors (prompt for API key)
3. Handles 404 - Not found (invalid yieldId)
4. Handles 429 - Rate limits (implement exponential backoff)
5. Handles 500 - Server errors (retry with backoff)

Use the error response structure:
{
  "message": "string",
  "error": "string",
  "statusCode": number
}

Anti-Patterns to Avoid

Avoid these prompts:
  • “Make a staking app” (too vague, no API context)
  • “How do I stake?” (doesn’t reference Yield.xyz specifically)
  • Asking about features not in the API spec
  • Not specifying which endpoint to use

Tips for Better Results

Reference the Spec

Attach the OpenAPI spec or reference specific endpoints

Specify Your Stack

Mention React, Vue, TypeScript, etc.

Include Examples

Paste example API responses for context

Be Specific

Name exact endpoints and fields you need

Next Steps

Guardrails

AI safety best practices

API Reference

Complete API documentation