Summary
GET /v2/crypto/coins/{id}/tvl downloads a protocol's entire TVL history — 10.4 MB for aave — to report four current numbers. It times out in CI against the adapter's own 45s limit.
Current state
The route calls client.protocol(id), which fetches https://api.llama.fi/protocol/{id}. That response carries the full historical TVL series. Measured directly:
- 10,428,459 bytes for
aave
- 11.3s total, 7.2s to first byte on a home connection
src/adapters/defillama/mod.rs:33 sets DEFAULT_TIMEOUT = Duration::from_secs(45). In nightly probe run 34475491821 the protocol-tvl probe started at 12:30:03.714Z and failed at 12:30:49.028Z — 45.3 seconds. It timed out on the limit, it did not error.
This is variable rather than consistently broken. The protocol-tvl-history probe immediately afterwards pulled the same payload in 18s and passed, and the route returns 200 in about 11s from a home connection right now. So it fails intermittently, depending on how fast the path happens to be.
The size is load-bearing, not incidental: ProtocolTvl needs chains, marketCap, tvl and change1DPercent / change7DPercent, and the two change percentages are computed from the history by change_percent in src/adapters/defillama/crypto/mod.rs. So the history is not simply being over-fetched and discarded — the current shape of the response depends on it.
Note what is not the problem. The 45s timeout previously surfaced as an opaque 500; #483 fixes the classification so it reports 408, which makes the failure legible but does not make it any faster. And this is not the provider-routing collapse fixed in #481 — that path returns NotSupported, which would surface as 501.
Proposed change
Get current TVL without the history.
- Find a lighter upstream for
tvl / marketCap / chains. DefiLlama exposes endpoints that return current protocol state without the full series.
- Source
change1DPercent / change7DPercent separately, or compute them from a bounded window rather than the entire series.
Raising DEFAULT_TIMEOUT is deliberately not the proposal. It would make the probe pass while leaving a 10.4 MB fetch on a request path that needs four numbers.
Acceptance
GET /v2/crypto/coins/{id}/tvl returns the same fields it does today.
- The route no longer downloads the full TVL history to serve them.
- The
protocol-tvl probe stops failing intermittently on timeout.
DEFAULT_TIMEOUT is unchanged, or lowered.
Summary
GET /v2/crypto/coins/{id}/tvldownloads a protocol's entire TVL history — 10.4 MB foraave— to report four current numbers. It times out in CI against the adapter's own 45s limit.Current state
The route calls
client.protocol(id), which fetcheshttps://api.llama.fi/protocol/{id}. That response carries the full historical TVL series. Measured directly:aavesrc/adapters/defillama/mod.rs:33setsDEFAULT_TIMEOUT = Duration::from_secs(45). In nightly probe run 34475491821 theprotocol-tvlprobe started at12:30:03.714Zand failed at12:30:49.028Z— 45.3 seconds. It timed out on the limit, it did not error.This is variable rather than consistently broken. The
protocol-tvl-historyprobe immediately afterwards pulled the same payload in 18s and passed, and the route returns 200 in about 11s from a home connection right now. So it fails intermittently, depending on how fast the path happens to be.The size is load-bearing, not incidental:
ProtocolTvlneedschains,marketCap,tvlandchange1DPercent/change7DPercent, and the two change percentages are computed from the history bychange_percentinsrc/adapters/defillama/crypto/mod.rs. So the history is not simply being over-fetched and discarded — the current shape of the response depends on it.Note what is not the problem. The 45s timeout previously surfaced as an opaque
500; #483 fixes the classification so it reports408, which makes the failure legible but does not make it any faster. And this is not the provider-routing collapse fixed in #481 — that path returnsNotSupported, which would surface as501.Proposed change
Get current TVL without the history.
tvl/marketCap/chains. DefiLlama exposes endpoints that return current protocol state without the full series.change1DPercent/change7DPercentseparately, or compute them from a bounded window rather than the entire series.Raising
DEFAULT_TIMEOUTis deliberately not the proposal. It would make the probe pass while leaving a 10.4 MB fetch on a request path that needs four numbers.Acceptance
GET /v2/crypto/coins/{id}/tvlreturns the same fields it does today.protocol-tvlprobe stops failing intermittently on timeout.DEFAULT_TIMEOUTis unchanged, or lowered.