feat(mcp-hyperliquid): leverage_cap + testnet resolver + environment_info

This commit is contained in:
AdrianoDev
2026-04-27 17:55:26 +02:00
parent e958422fe5
commit fb8c43cc61
7 changed files with 217 additions and 58 deletions
@@ -37,7 +37,7 @@ def http(mock_client):
"ot": Principal("observer", {"observer"}),
}
)
app = create_app(client=mock_client, token_store=store)
app = create_app(client=mock_client, token_store=store, creds={"max_leverage": 3})
return TestClient(app)
@@ -128,18 +128,8 @@ def test_place_order_observer_forbidden(http):
assert r.status_code == 403
def test_place_order_notional_cap_enforced(http):
"""CER-016: HL reject amount*price > 200."""
r = http.post(
"/tools/place_order",
headers={"Authorization": "Bearer ct"},
json={"instrument": "ETH", "side": "buy", "amount": 0.1, "price": 3350},
)
assert r.status_code == 403
assert r.json()["error"]["code"] == "HARD_PROHIBITION"
def test_place_order_leverage_cap_enforced_hl(http):
"""Reject leverage > max_leverage (da secret, default 3)."""
r = http.post(
"/tools/place_order",
headers={"Authorization": "Bearer ct"},
@@ -152,6 +142,10 @@ def test_place_order_leverage_cap_enforced_hl(http):
},
)
assert r.status_code == 403
body = r.json()
err = body["error"]
assert err["code"] == "LEVERAGE_CAP_EXCEEDED"
assert err["details"]["exchange"] == "hyperliquid"
def test_cancel_order_core_ok(http):