refactor(mcp-deribit): replace risk_guard with local leverage_cap
This commit is contained in:
@@ -34,7 +34,7 @@ def http(mock_client):
|
||||
"ct": Principal("core", {"core"}),
|
||||
"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)
|
||||
|
||||
|
||||
@@ -94,24 +94,8 @@ def test_place_order_observer_forbidden(http):
|
||||
assert r.status_code == 403
|
||||
|
||||
|
||||
def test_place_order_notional_cap_enforced(http):
|
||||
"""CER-016: reject se notional > CERBERO_MAX_NOTIONAL (default 200)."""
|
||||
r = http.post(
|
||||
"/tools/place_order",
|
||||
headers={"Authorization": "Bearer ct"},
|
||||
json={
|
||||
"instrument_name": "ETH-PERPETUAL",
|
||||
"side": "buy",
|
||||
"amount": 335, # USD — cap 200
|
||||
},
|
||||
)
|
||||
assert r.status_code == 403
|
||||
body = r.json()
|
||||
assert body["error"]["code"] == "HARD_PROHIBITION"
|
||||
|
||||
|
||||
def test_place_order_leverage_cap_enforced(http):
|
||||
"""CER-016: reject leverage > 3x."""
|
||||
"""Reject leverage > max_leverage (da secret, default 3)."""
|
||||
r = http.post(
|
||||
"/tools/place_order",
|
||||
headers={"Authorization": "Bearer ct"},
|
||||
@@ -124,22 +108,12 @@ def test_place_order_leverage_cap_enforced(http):
|
||||
)
|
||||
assert r.status_code == 403
|
||||
body = r.json()
|
||||
assert body["error"]["code"] == "HARD_PROHIBITION"
|
||||
|
||||
|
||||
def test_place_order_reduce_only_skips_cap(http):
|
||||
"""CER-016: reduce_only orders bypassano cap notional (è close)."""
|
||||
r = http.post(
|
||||
"/tools/place_order",
|
||||
headers={"Authorization": "Bearer ct"},
|
||||
json={
|
||||
"instrument_name": "ETH-PERPETUAL",
|
||||
"side": "sell",
|
||||
"amount": 10000,
|
||||
"reduce_only": True,
|
||||
},
|
||||
)
|
||||
assert r.status_code == 200
|
||||
err = body["error"]
|
||||
assert err["code"] == "LEVERAGE_CAP_EXCEEDED"
|
||||
details = err["details"]
|
||||
assert details["exchange"] == "deribit"
|
||||
assert details["requested"] == 50
|
||||
assert details["max"] == 3
|
||||
|
||||
|
||||
def test_close_position_core_ok(http):
|
||||
|
||||
Reference in New Issue
Block a user