Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions monitoring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,12 @@ protocols:
tasks:
- protocols/ethena/ethena.py
monitors:
- name: "USDe Backing Ratio"
description: "Collateral / supply < 1.0 via Ethena transparency API (CRITICAL)"
- name: "USDe Backing Ratio (Ethena API)"
description: "(collateral + reserve fund) / supply < 1.0 (CRITICAL) or < 1.005 (HIGH) via Ethena transparency API"
- name: "USDe Backing Ratio (LlamaRisk)"
description: "Independent (collateral + reserve fund) / supply < 1.0 (CRITICAL) or < 1.005 (HIGH) via LlamaRisk"
- name: "On-Chain Supply Consistency"
description: "LlamaRisk USDe/sUSDe supply vs on-chain totalSupply() differs by > 0.5%"
- name: "Data Freshness"
description: "Collateral, chain, or reserve data older than 12 hours"

Expand Down
53 changes: 18 additions & 35 deletions protocols/ethena/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,33 @@ Ethena is a synthetic dollar protocol built on Ethereum that provides a crypto-n

The script [`ethena/ethena.py`](ethena.py) runs daily via our VPS automation to sanity-check that **USDe remains fully backed** and that the public data feeds are fresh and internally consistent. Telegram messages are sent if some values are out of the expected range.

### Data Source - Ethena Transparency API
Two **independent** backing checks run each cycle — one against Ethena's own transparency API, one against LlamaRisk. They run in isolation (a failure or false positive in one provider never suppresses the other), and **every alert is prefixed with the provider that triggered it** (`[Ethena API]` or `[LlamaRisk]`) so it is obvious which source fired.

The primary backing check uses Ethena's own transparency API (`app.ethena.fi`). This API was previously blocked for GitHub Actions IPs, so a Chaos Labs / Oracle Security Proof-of-Reserve endpoint was used instead. That endpoint has since been decommissioned (returns HTTP 503), and Chainlink's USDe Proof of Reserves (Ethena's [PoR launch](https://ethena.fi/blog/usde-proof-of-reserves-launch) with Chainlink, Chaos Labs, LlamaRisk and Harris & Trotter) is not published as a public on-chain feed we can query. Since monitoring now runs on our VPS, Ethena's transparency API is reachable and is used directly.
Both checks compute the same ratio: `(collateral + reserve fund) / supply`, alert **CRITICAL** if `< 1` and **HIGH** if `< 1.005` (`COLLATERAL_RATIO_TRIGGER`). USDe targets ~1:1 collateral backing with a separate reserve fund as the buffer, so the collateral-only figure hovers right around 1.0; including the reserve fund gives the true solvency ratio and avoids false positives on fractional collateral dips.

1. **Supply**: `GET /api/solvency/token-supply?symbol=USDe`
2. **Collateral**: `GET /api/positions/current/collateral?latest=true`
3. **Backing Ratio**: `totalBackingAssetsInUsd / supply` — alert CRITICAL if `< 1`. USDe targets ~1:1 collateral backing with a separate reserve fund as the buffer, so the collateral-only ratio sits just above 1.0 in normal operation.

### Data Sources - LlamaRisk

> NOTE: LlamaRisk data is not reliable, so it is currently disabled (`llama_risk_check`).
> **The two checks measure different collateral lenses — they are not a like-for-like cross-check.** The Ethena check queries `/positions/current/collateral?latest=true`, whose `totalBackingAssetsInUsd` is a *net backing* figure that tracks supply ~1:1 (ratio ≈ 1.00, ≈ 1.015 with reserve). LlamaRisk (and the same Ethena endpoint *without* `latest=true`) report *gross collateral*, ~2.7% higher (ratio ≈ 1.027, ≈ 1.042 with reserve). They agree asset-by-asset to ~0.04%, so the ~2.7% ratio difference between the two checks is expected and definitional, **not** a data-staleness or backing problem. Each is a valid independent lower-bound on backing; they are intentionally kept separate rather than reconciled into one ratio.

#### Off-Chain
### Check 1 — Ethena Transparency API (`ethena_backing_check`)

Data used is provided by Ethena on [transparency page](https://app.ethena.fi/dashboards/transparency) and LlamaRisk:
Uses Ethena's own transparency API (`app.ethena.fi`). This API was previously blocked for GitHub Actions IPs, so a Chaos Labs / Oracle Security Proof-of-Reserve endpoint was used instead. That endpoint has since been decommissioned (returns HTTP 503), and Chainlink's USDe Proof of Reserves (Ethena's [PoR launch](https://ethena.fi/blog/usde-proof-of-reserves-launch) with Chainlink, Chaos Labs, LlamaRisk and Harris & Trotter) is not published as a public on-chain feed we can query. Since monitoring now runs on our VPS, Ethena's transparency API is reachable.

1. **Ethena Transparency**
• Collateral: `GET /positions/current/collateral?latest=true`
• Supply : `GET /solvency/token-supply?symbol=USDe`
2. **LlamaRisk Dashboard**
`GET https://api.llamarisk.com/protocols/ethena/overview/all/?format=json`

> NOTE: This LlamaRisk cross-check section is currently disabled (`llama_risk_check`). The note that Ethena data was unavailable applied to the old GitHub Actions setup; on our VPS the Ethena transparency API is reachable and is the primary source (see above).
1. **Supply**: `GET /api/solvency/token-supply?symbol=USDe`
2. **Collateral**: `GET /api/positions/current/collateral?latest=true` (`totalBackingAssetsInUsd`)
3. **Reserve fund**: `GET /api/solvency/reserve-fund` — latest point of the `queryIndex[0].yields` time series.

#### On-Chain
### Check 2 — LlamaRisk (`llama_risk_check`)

1. **USDe Supply**
`totalSupply` for USDe token
2. **sUSDe Supply**
`totalSupply` for sUSDe token
Uses the LlamaRisk transparency dashboard as a fully independent second opinion:

#### What We Monitor
`GET https://api.llamarisk.com/protocols/ethena/overview/all/?format=json`

1. **Collateral Ratio**
`totalBackingAssetsInUsd + reserveFund / totalUsdeSupply`
• Warn if ratio < **1.01**
- **Backing ratio**: `(collateral_value + reserve_fund) / total_usde_supply`, same CRITICAL/HIGH thresholds as Check 1.
- **On-chain cross-validation**: LlamaRisk's USDe and sUSDe supply are compared against on-chain `totalSupply()`; a MEDIUM alert fires if they differ by more than 0.5%. Skipped when LlamaRisk chain data is older than 2h (it would be out of sync with chain state).
- **Data freshness**: LOW alerts if LlamaRisk collateral or reserve data is older than 12h.

2. **Dual-Source Consistency**
• Ethena vs LlamaRisk supply — alert if they differ by > 0.1%
• Ethena vs LlamaRisk collateral — alert if they differ by > 0.1%
> NOTE: LlamaRisk data has historically lagged/diverged from Ethena's; it is treated as a secondary cross-check, which is why the two checks are independent and separately labelled rather than merged into one ratio.

3. **Data Freshness**
• If collateral or chain data is older than 12h from either API triggers a stale-data warning. Also, if reserve data is older than 12 h, send a warning.
#### On-Chain feeds used by Check 2

4. **On-Chain Supply**
• Ethena vs LlamaRisk supply for USDe and sUSDe — alert if they differ by > 0.5%
• If chain data is old, use on-chain data for validating backings
1. **USDe Supply** — `totalSupply` for the [USDe token](https://etherscan.io/address/0x4c9EDD5852cd905f086C759E8383e09bff1E68B3)
2. **sUSDe Supply** — `totalSupply` for the [sUSDe token](https://etherscan.io/address/0x9D39A5DE30e57443BfF2A8307A4256c8797A3497)
Loading