Skip to content
Draft
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
4 changes: 2 additions & 2 deletions protocols/unibtc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ def check_por_coverage(state: UnibtcState, api_total_supply: Decimal | None) ->
f"PoR / API supply = {ratio:.4%} "
f"(CRITICAL < {POR_CRITICAL_RATIO:.0%}, HIGH < {POR_HIGH_RATIO:.0%})\n"
f"Chainlink PoR: {format_decimal_amount(reserves)} BTC\n"
f"API total_supply: {format_decimal_amount(api_total_supply)} uniBTC\n"
f"API total supply: {format_decimal_amount(api_total_supply)} uniBTC\n"
f"🔗 PoR {_etherscan(POR_FEED)}"
)
_alert_on_band_escalation(
Expand Down Expand Up @@ -1000,7 +1000,7 @@ def check_feeder_gap(state: UnibtcState, api: ApiStats) -> None:
f"total supply (threshold {FEEDER_GAP_THRESHOLD:.0%}).\n"
f"{hint}"
f"Feeder totalTokenSupply: {_fmt_btc(state.feeder_supply)} uniBTC\n"
f"API total_supply: {format_decimal_amount(api.total_supply)} uniBTC\n"
f"API total supply: {format_decimal_amount(api.total_supply)} uniBTC\n"
f"🔗 Feeder {_etherscan(SUPPLY_FEEDER)}"
)
_alert_while_true(CACHE_KEY_FEEDER_GAP, wrong, Alert(AlertSeverity.HIGH, message, PROTOCOL))
Expand Down
15 changes: 15 additions & 0 deletions tests/test_unibtc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,3 +1152,18 @@ def test_main_withholds_rejected_api_from_checks(monkeypatch: pytest.MonkeyPatch

assert received["por_supply"] is None
assert received["feeder_api"] is None


def test_feeder_gap_alert_is_valid_markdown(monkeypatch: pytest.MonkeyPatch) -> None:
"""A bare ``_`` (e.g. ``total_supply``) breaks Telegram Markdown V1 and forces a plain-text resend."""
alerts: list[Alert] = []
stub_cache(monkeypatch)
monkeypatch.setattr(unibtc, "send_alert", alerts.append)

unibtc.check_supply_feeder(make_state(feeder_supply=384_533_051_367), make_api())
unibtc.check_por_coverage(make_state(por_answer=4_000 * 10**18), make_api().total_supply)

assert len(alerts) == 2
for alert in alerts:
text = alert.message.replace("etherscan.io/address/", "")
assert "_" not in text.split("🔗")[0]
Loading