Skip to content

Adding general getContractInfo EVM endpoint#1477

Merged
pragmaxim merged 8 commits intomasterfrom
chore/fetch-erc4626-data-for-token
Apr 28, 2026
Merged

Adding general getContractInfo EVM endpoint#1477
pragmaxim merged 8 commits intomasterfrom
chore/fetch-erc4626-data-for-token

Conversation

@pragmaxim
Copy link
Copy Markdown
Contributor

@pragmaxim pragmaxim commented Apr 22, 2026

Summary

The intention is to propagate erc4626 data with fiat rates to Suite :

  1. retrieve erc4626 on websocket session start through accountInfo request for an account
  2. retrieve particular contract erc4626 values AND fiat rates later to have fresh data

Also unifying existing getAccountInfo protocol with new getContractInfo method :

  • removing includeErc4626 flag and introducing protocols in request
  • changing response to protocols instead of erc4626 in root

Details

This PR adds a single-contract lookup endpoint so Suite can refresh current ERC-4626 vault numbers and fiat pricing for a token the user is actively interacting with, without reloading the full accountInfo response (whose erc4626 block is a snapshot taken at fetch time).

Also unifies the protocol-enrichment shape between getAccountInfo and the new getContractInfo so both responses carry the same protocols wrapper.

New endpoint

WebSocket

Method: getContractInfo

Request:

{
  "contract": "0x...",
  "currency": "usd",
  "protocols": ["erc4626"]
}
  • currency — optional. When present, response includes rates.secondaryRate in that currency.
  • protocols — optional. Currently supported: erc4626. Unknown values are rejected.

Response (ContractInfoResult):

{
  "contract": "0x...",
  "standard": "ERC20",
  "name": "Vault Share",
  "symbol": "vETH",
  "decimals": 18,
  "rates": {
    "baseRate": 0.000523,
    "currency": "usd",
    "secondaryRate": 1.24
  },
  "protocols": {
    "erc4626": { /* asset, share, totalAssets, convertTo*, preview*, error? */ }
  },
  "blockHeight": 12345678
}

REST

GET /api/v2/contract/<contract>?currency=usd&protocols=erc4626

Same response shape.

Errors

All errors are plain APIError messages:

  • "Missing contract" — empty contract param.
  • "Invalid contract, <parser error>" — contract string doesn't parse as an address on this chain.
  • "Contract not found" — address parses but is not a known contract (e.g. EOA).
  • "Unknown protocol: <value>" — a protocol string outside the allowlist.
  • "getContractInfo is not supported on this coin" — endpoint called on a non-EVM Blockbook.
  • "protocols parameter is not supported on this coin" — non-empty protocols sent to getAccountInfo on a non-EVM Blockbook.

Breaking changes to getAccountInfo (from PR #1431, not yet released)

  • includeErc4626: booleanprotocols: string[] (pass ["erc4626"]).
  • Per-token erc4626 field → protocols.erc4626 (same payload, nested under protocols).

REST equivalent: ?includeErc4626=true?protocols=erc4626.

Behavior notes

  • blockHeight is the indexer's best block at request time. ERC-4626 values (totalAssets, convertTo*, preview*) come from live eth_call against the backend, which may already be one or more blocks ahead of the indexer. Treat blockHeight as a floor.
  • rates is returned only when the contract's standard supports rates (fungible tokens) and at least a base rate or a requested currency is available. When currency is supplied, it is always echoed back, even if no secondary rate could be resolved.
  • protocols.erc4626 is returned only if the contract is detected as an ERC-4626 vault (via asset() + totalAssets() probe). Partial failures while fetching vault fields are reported in protocols.erc4626.error rather than failing the whole response.

Try it against dev Blockbooks

Shared variables:

# Hosts
ETH_HOST=???:9116
BASE_HOST=???:9311

# Ethereum — Gauntlet USDC Prime (gtUSDC), sDAI holder from fixtures
ETH_VAULT=0xdd0f28e19C1780eb6396170735D45153D261490d
ETH_SDAI=0x83F20F44975D03b1b09e64809B757c47f942BEeA
ETH_HOLDER=0x167478921b907422f8e88b43c4af2b8bea278d3a

# Base — Steakhouse USDC (steakUSDC)
BASE_VAULT=0xbeeF010f9cb27031ad51e3333f9aF9C6B1228183
BASE_HOLDER=0x9eA3721B5Bf3b64b4418c38B603154d2D597FAE3

Notes: -n on wscat and -k on curl bypass the dev self-signed cert; -w 3 gives the reply time to print before wscat exits.

Ethereum

WS getContractInfo:

wscat -n -c wss://${ETH_HOST}/websocket -w 3 \
  -x "{\"id\":\"1\",\"method\":\"getContractInfo\",\"params\":{\"contract\":\"${ETH_VAULT}\",\"currency\":\"usd\",\"protocols\":[\"erc4626\"]}}"

WS getAccountInfo:

wscat -n -c wss://${ETH_HOST}/websocket -w 3 \
  -x "{\"id\":\"1\",\"method\":\"getAccountInfo\",\"params\":{\"descriptor\":\"${ETH_HOLDER}\",\"details\":\"tokenBalances\",\"contractFilter\":\"${ETH_SDAI}\",\"protocols\":[\"erc4626\"]}}" | jq

REST getContractInfo:

curl -sk "https://${ETH_HOST}/api/v2/contract/${ETH_VAULT}?currency=usd&protocols=erc4626" | jq

REST getAccountInfo:

curl -sk "https://${ETH_HOST}/api/v2/address/${ETH_HOLDER}?details=tokenBalances&contract=${ETH_SDAI}&protocols=erc4626" | jq

Base

WS getContractInfo:

wscat -n -c wss://${BASE_HOST}/websocket -w 3 \
  -x "{\"id\":\"1\",\"method\":\"getContractInfo\",\"params\":{\"contract\":\"${BASE_VAULT}\",\"currency\":\"usd\",\"protocols\":[\"erc4626\"]}}" | jq

WS getAccountInfo:

wscat -n -c wss://${BASE_HOST}/websocket -w 3 \
  -x "{\"id\":\"1\",\"method\":\"getAccountInfo\",\"params\":{\"descriptor\":\"${BASE_HOLDER}\",\"details\":\"tokenBalances\",\"contractFilter\":\"${BASE_VAULT}\",\"protocols\":[\"erc4626\"]}}" | jq

REST getContractInfo:

curl -sk "https://${BASE_HOST}/api/v2/contract/${BASE_VAULT}?currency=usd&protocols=erc4626" | jq

REST getAccountInfo:

curl -sk "https://${BASE_HOST}/api/v2/address/${BASE_HOLDER}?details=tokenBalances&contract=${BASE_VAULT}&protocols=erc4626" | jq

@pragmaxim pragmaxim changed the title Adding ws endpoint to fetch 4626 data for token Adding general getContractInfo EVM endpoint Apr 23, 2026
Comment thread api/types.go Outdated
Comment thread api/types.go Outdated
@pragmaxim pragmaxim requested a review from cranycrane April 27, 2026 07:47
Copy link
Copy Markdown
Contributor

@cranycrane cranycrane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pragmaxim pragmaxim merged commit a12a630 into master Apr 28, 2026
3 checks passed
@pragmaxim pragmaxim deleted the chore/fetch-erc4626-data-for-token branch April 28, 2026 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants