Skip to content
Docs

DeFi

Action form

Typed form schema so each product’s enter / exit / claim / borrow / repay UI can differ correctly.

Endpoint

GET/v1/defi/products/:investmentId/action-form

Query kind: enter (default), exit, claim, borrow, or repay. Returns which tokens and fields that action needs (amount vs multi-LP amounts, tickLower/tickUpper, tokenId, redeemPercent, slippage). Meter defi_action_form (2).

Request
curl -sS "https://blockchain.gray3.io/v1/defi/products/9502/action-form?kind=enter" \
  -H "X-Gray-Project-Id: proj_your_project_id" \
  -H "Authorization: Bearer gray_sk_your_secret"

Response

HTTP 200 — success envelope wraps the payload in data.

json
{
  "data": {
    "kind": "enter",
    "investmentId": "9502",
    "chainId": "ethereum",
    "category": "earn",
    "supported": true,
    "inputs": [
      {
        "role": "deposit",
        "symbol": "USDC",
        "tokenAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
        "decimals": 6
      }
    ],
    "fields": [
      { "key": "amount", "required": true, "description": "Deposit amount for the primary input token" },
      { "key": "slippage", "required": false }
    ],
    "source": "live"
  }
}

Errors

Errors use HTTP { "error": { "code", "message", "retryable" } }. Branch on code, not the message text.

Every authenticated route may also return unauthorized (401), revoked_secret (401), forbidden (403), credits_exhausted (402), plan_feature_denied (403), rate_limit_exceeded (429, retryable), and invalid_argument (413) for request bodies over 256 KiB.

CodeHTTPWhen
unsupported_capability400Testnet chain id or feature disabled on testnets (prices, NFTs, DeFi, swap)
invalid_argument400Missing or malformed chainId, address, or body fields
plan_chain_denied403chainId is not on the project plan
chain_disabled403Chain turned off in Console › Networks
unsupported_capability400Capability not offered for this chain (e.g. testnet prices)
plan_feature_denied403The project plan does not include DeFi
credits_exhausted402Not enough Gray Credits for this meter
not_found404Unknown protocolId on GET /v1/defi/protocols/:protocolId
invalid_argument400Missing q / investmentId, bad category, or kind not one of enter / exit / claim / borrow / repay
defi_unavailable503The DeFi data service is temporarily unavailable (retryable)
json
{
  "error": {
    "code": "unsupported_capability",
    "message": "Human-readable detail (may be sanitized).",
    "retryable": false
  }
}