feat: add DeFi data via DefiLlama API (TDD)

7 new endpoints under /api/v1/defi/ (all free, no API key):
- GET /defi/tvl/protocols - top DeFi protocols by TVL
- GET /defi/tvl/chains - chain TVL rankings
- GET /defi/tvl/{protocol} - single protocol TVL
- GET /defi/yields - top yield pools (filter by chain/project)
- GET /defi/stablecoins - stablecoin market data
- GET /defi/volumes/dexs - DEX volume overview
- GET /defi/fees - protocol fees/revenue overview

Data source: DefiLlama API (free, no key needed)
58 new tests (33 service + 25 route). All 561 tests passing.
This commit is contained in:
Yaojia Wang
2026-03-19 23:03:01 +01:00
parent 4915f1bae4
commit 37c46e76ae
5 changed files with 1291 additions and 0 deletions

View File

@@ -40,6 +40,7 @@ from routes_technical import router as technical_router # noqa: E402
from routes_portfolio import router as portfolio_router # noqa: E402
from routes_backtest import router as backtest_router # noqa: E402
from routes_cn import router as cn_router # noqa: E402
from routes_defi import router as defi_router # noqa: E402
logging.basicConfig(
level=settings.log_level.upper(),
@@ -87,6 +88,7 @@ app.include_router(regulators_router)
app.include_router(portfolio_router)
app.include_router(backtest_router)
app.include_router(cn_router)
app.include_router(defi_router)
@app.get("/health", response_model=dict[str, str])