Decode a USD value
decode_usd_valueDecode the eth_call result YOUR node returned for a USD value (usd.in of prepare_quote with usd:true, or usdOut of decode_quote): the amount in USD (via USDC; USDG on Robinhood Chain; the dollar token counts as 1 USD), measured as Quoter netOut after the 0.28% fee, including price impact. Each via (direct, via WETH, via the tokens the direct route crosses; at most 8) is listed; the value is the minimum over measured vias, with the spread when two or more are measured. A via that reverts, finds no route or nets 0 is "not measured"; with none measured the value is "not measured", never 0. When the route crosses other tokens, the answer is next: a second eth_call pinned at the block hash of the first (EIP-1898, requireCanonical); run it and decode that one. That needs blockHash, the hash of the block the first call ran at (read the header with eth_getBlockByNumber and pin the call there, or pass blockHash to prepare_quote, which pins usd.in only). usdOut of decode_quote is prepared at latest: replace latest with {blockHash, requireCanonical: true} of a header you read, run it, and pass that hash here as blockHash. Without a hash the value is "not measured", never a call pinned by number. If your node answers an error for the hash, start again. Pure computation.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"request": "<request>",
"result": "<result>"
},
"name": "decode_usd_value"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes | the 0x hex result of that eth_call on your node | |
| request | Yes | the `request` object of the USD call (usd.in, usdOut or next), verbatim | |
| blockHash | No | the hash of the block the first USD call ran at (optional; needed when the route crosses other tokens) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | false: see code, error | |
| rpc | No | ||
| usd | No | ||
| code | No | ||
| mode | No | ||
| next | No | ||
| vias | No | ||
| basis | No | ||
| error | No | ||
| label | No | ||
| token | No | ||
| reason | No | ||
| spread | No | ||
| chainId | No | ||
| version | No | ||
| amountIn | No | ||
| complete | No | ||
| usdValue | No | ||
| unitPrice | No | ||
| blockNumber | No | ||
| dollarToken | No | ||
| tokenDecimals | No | ||
| dollarDecimals | No |