idea149-deltax-forge-cross/deltax_forge_cross/ir.py

112 lines
2.5 KiB
Python

from __future__ import annotations
from dataclasses import dataclass, field
from typing import Dict, List
@dataclass
class LocalArbProblem:
venue_id: str
assets: List[str]
target_delta_budget: float
liquidity_budget: float
latency_budget: float
def to_dict(self) -> Dict:
return {
"venue_id": self.venue_id,
"assets": list(self.assets),
"target_delta_budget": self.target_delta_budget,
"liquidity_budget": self.liquidity_budget,
"latency_budget": self.latency_budget,
}
@dataclass
class SharedSignals:
version: int
price_deltas: Dict[str, float] # asset_symbol -> delta
correlations: Dict[str, float] = field(default_factory=dict)
def to_dict(self) -> Dict:
return {
"version": self.version,
"price_deltas": dict(self.price_deltas),
"correlations": dict(self.correlations),
}
@dataclass
class PlanDeltaIR:
delta_actions: Dict[str, float]
timestamp: float
contract_id: str
author_signature: str
def to_dict(self) -> Dict:
return {
"delta_actions": dict(self.delta_actions),
"timestamp": self.timestamp,
"contract_id": self.contract_id,
"author_signature": self.author_signature,
}
@dataclass
class DualVariables:
shadow_prices: Dict[str, float] = field(default_factory=dict)
def to_dict(self) -> Dict:
return {"shadow_prices": dict(self.shadow_prices)}
@dataclass
class PrivacyBudget:
per_message_budget: float
total_budget: float
def to_dict(self) -> Dict:
return {
"per_message_budget": self.per_message_budget,
"total_budget": self.total_budget,
}
@dataclass
class AuditLog:
entries: List[str] = field(default_factory=list)
def to_dict(self) -> Dict:
return {"entries": list(self.entries)}
@dataclass
class TimeRounds:
rounds: int
round_length_seconds: float
def to_dict(self) -> Dict:
return {"rounds": self.rounds, "round_length_seconds": self.round_length_seconds}
@dataclass
class GoCRegistryEntry:
contract: str
version: str
metadata: Dict[str, str] = field(default_factory=dict)
def to_dict(self) -> Dict:
return {"contract": self.contract, "version": self.version, "metadata": dict(self.metadata)}
__all__ = [
"LocalArbProblem",
"SharedSignals",
"PlanDeltaIR",
"DualVariables",
"PrivacyBudget",
"AuditLog",
"TimeRounds",
"GoCRegistryEntry",
]