feat(V2): cabla audit logging nei write endpoint dei 4 router exchange

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
AdrianoDev
2026-05-01 08:44:28 +02:00
parent 43bf8fc461
commit bd6b03ce43
9 changed files with 442 additions and 37 deletions
+45 -5
View File
@@ -11,6 +11,7 @@ from typing import Literal, cast
from fastapi import APIRouter, Depends, Request
from cerbero_mcp.client_registry import ClientRegistry
from cerbero_mcp.common.audit_helpers import audit_call
from cerbero_mcp.exchanges.hyperliquid import tools as t
from cerbero_mcp.exchanges.hyperliquid.client import HyperliquidClient
@@ -136,34 +137,73 @@ def make_router() -> APIRouter:
client: HyperliquidClient = Depends(get_hyperliquid_client),
):
creds = _build_creds(request)
return await t.place_order(client, params, creds=creds)
return await audit_call(
request=request,
exchange="hyperliquid",
action="place_order",
target_field="instrument",
params=params,
tool_fn=lambda: t.place_order(client, params, creds=creds),
)
@r.post("/tools/cancel_order")
async def _cancel_order(
params: t.CancelOrderReq,
request: Request,
client: HyperliquidClient = Depends(get_hyperliquid_client),
):
return await t.cancel_order(client, params)
return await audit_call(
request=request,
exchange="hyperliquid",
action="cancel_order",
target_field="order_id",
params=params,
tool_fn=lambda: t.cancel_order(client, params),
)
@r.post("/tools/set_stop_loss")
async def _set_stop_loss(
params: t.SetStopLossReq,
request: Request,
client: HyperliquidClient = Depends(get_hyperliquid_client),
):
return await t.set_stop_loss(client, params)
return await audit_call(
request=request,
exchange="hyperliquid",
action="set_stop_loss",
target_field="instrument",
params=params,
tool_fn=lambda: t.set_stop_loss(client, params),
)
@r.post("/tools/set_take_profit")
async def _set_take_profit(
params: t.SetTakeProfitReq,
request: Request,
client: HyperliquidClient = Depends(get_hyperliquid_client),
):
return await t.set_take_profit(client, params)
return await audit_call(
request=request,
exchange="hyperliquid",
action="set_take_profit",
target_field="instrument",
params=params,
tool_fn=lambda: t.set_take_profit(client, params),
)
@r.post("/tools/close_position")
async def _close_position(
params: t.ClosePositionReq,
request: Request,
client: HyperliquidClient = Depends(get_hyperliquid_client),
):
return await t.close_position(client, params)
return await audit_call(
request=request,
exchange="hyperliquid",
action="close_position",
target_field="instrument",
params=params,
tool_fn=lambda: t.close_position(client, params),
)
return r