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.
Using the Yield.xyz API, create a function that:1. Lists all yield opportunities on Ethereum2. Filters by type (staking, lending, vault)3. Sorts by APY descending4. Returns the top 10 resultsUse the GET /v1/yields endpoint with appropriate query parameters.
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
Using the Yield.xyz API, write a function to:1. Get validators for cosmos-atom-native-staking2. Filter by preferred validators3. Sort by APR4. Return validator address, name, and commissionUse GET /v1/yields/{yieldId}/validators endpoint.
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 hash3. Handle errors and return the action statusInclude proper TypeScript types based on the API response schema.
Using the Yield.xyz API, create a function to exit a yield position:1. POST /v1/actions/exit with yieldId, address, and amount2. Process each transaction in order (synchronous execution)3. Submit transaction hashes after each broadcast4. Poll the action status until completedHandle partial exits with specific amounts and full exits.
Using the Yield.xyz API, implement reward claiming:1. First, get balances using POST /v1/yields/{yieldId}/balances2. Find balances with type "claimable" that have pendingActions3. Extract the passthrough from the pendingAction4. Call POST /v1/actions/manage with: - yieldId - address - action: "CLAIM_REWARDS" - passthrough: from step 35. Execute the returned transactionsThe passthrough is required and comes from the balance endpoint.
Using the Yield.xyz API POST /v1/yields/balances endpoint, create a function that:1. Takes an array of { address, network } objects2. Fetches balances for all addresses3. 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 positions4. Calculates total USD value per type5. Returns a structured portfolio summary
Create a React hook that tracks yield position lifecycle:1. Polls GET /v1/yields/{yieldId}/balances every 30 seconds2. Tracks state transitions (entering → active → exiting → withdrawable)3. Shows countdown for cooldown periods4. Highlights claimable rewards5. Triggers notifications on state changesUse the balance type field to determine current state.
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 protocol2. Yield Details: - GET /v1/yields/{yieldId} - Show mechanics.arguments.enter schema for required fields - If requiresValidatorSelection, fetch validators3. Enter Position: - POST /v1/actions/enter with user inputs - Sign and broadcast transactions - Submit hashes4. Track Position: - POST /v1/yields/{yieldId}/balances - Show active balance and any pending actions5. Exit Position: - POST /v1/actions/exit - Handle cooldown period display - Show withdrawable balance when readyInclude error handling for each step.