GET /yield/:asset

🔹 Get Yield Token Information

🌐 Endpoint

GET https://client.deframe.io/v1/yield/:token

📝 Overview

Retrieve yield token information and recommended strategy for a specific token. This endpoint analyzes all active strategies for the given token across different protocols and returns the strategy with the highest APY, along with spot position data and optional bytecode for execution. You can optionally specify an action query parameter set to lend or withdraw to indicate the intent of the request.

🔑 Authentication

This API requires authentication using an API key. Include your API key in the request headers:

x-api-key: YOUR_API_KEY

📋 Path Parameters

Parameter
Type
Required
Description

token

string

Token symbol/name (case-insensitive)

📋 Query Parameters

Parameter
Type
Required
Description

from

string

Source chain or protocol identifier

to

string

Destination chain or protocol identifier

amount

string

Amount of tokens for bytecode generation

wallet

string

User's wallet address for bytecode generation

action

string

Operation context for the request. Allowed values: lend or withdraw

📦 Response

Returns a JSON object containing:

  • recommendedStrategyId: Unique identifier for the recommended strategy

  • destinationChain: Network/chain where the strategy operates

  • bytecodeExecution: Transaction bytecode for strategy execution (if wallet and amount provided)

  • spotPosition: Current position data including APY and other metrics

  • strategy: Complete strategy object with protocol and asset details

Example Response:

{
  "recommendedStrategyId": "aave-USDC-ethereum",
  "destinationChain": "ethereum",
  "bytecodeExecution": "0x...",
  "spotPosition": {
    "apy": 4.25,
    "totalValueLocked": "1000000000000000000000",
    "availableLiquidity": "500000000000000000000"
  },
  "strategy": {
    "protocol": "aave",
    "assetName": "USDC",
    "network": "ethereum",
    "address": "0x...",
    "decimals": 6
  }
}

🔄 Strategy Selection Logic

The endpoint automatically:

  1. Fetches Active Strategies: Retrieves all active strategies for the customer and specified token

  2. APY Comparison: Calculates current APY for each strategy using spot position data

  3. Strategy Selection: Returns the strategy with the highest APY as the recommended option

  4. Bytecode Generation: Optionally generates transaction bytecode if wallet address and amount are provided

🛠️ Error Handling

The API returns appropriate error messages for:

  • Strategy not found for the specified token

  • Invalid wallet address format

  • Failed bytecode generation

  • Provider-specific errors during spot position calculation

Example Error Response:

{
  "error": "Strategy not found"
}

📝 Usage Examples

Basic Token Information:

GET /yield/USDC

With Optional Parameters for Bytecode Generation:

GET /yield/USDC?amount=1000000000&wallet=0x1234567890123456789012345678901234567890

Specifying the Action:

GET /yield/USDC?action=lend

With Additional Query Parameters:

GET /yield/USDC?from=ethereum&to=polygon&amount=1000000000&wallet=0x1234567890123456789012345678901234567890

🔍 Response Details

  • recommendedStrategyId: Format: {protocol}-{assetName}-{network}

  • bytecodeExecution: Contains transaction bytecode when wallet and amount are provided, otherwise shows placeholder message

  • spotPosition: Includes current APY, TVL, and liquidity information

  • strategy: Complete strategy configuration including protocol details and contract addresses

Last updated