Skip to main content

roboticus_core/config/
treasury_wallet.rs

1#[derive(Debug, Clone, Serialize, Deserialize)]
2pub struct TreasuryConfig {
3    #[serde(default = "default_per_payment_cap")]
4    pub per_payment_cap: f64,
5    #[serde(default = "default_hourly_limit")]
6    pub hourly_transfer_limit: f64,
7    #[serde(default = "default_daily_limit")]
8    pub daily_transfer_limit: f64,
9    #[serde(default = "default_min_reserve")]
10    pub minimum_reserve: f64,
11    #[serde(default = "default_inference_budget")]
12    pub daily_inference_budget: f64,
13    #[serde(default)]
14    pub revenue_swap: RevenueSwapConfig,
15}
16
17impl Default for TreasuryConfig {
18    fn default() -> Self {
19        Self {
20            per_payment_cap: default_per_payment_cap(),
21            hourly_transfer_limit: default_hourly_limit(),
22            daily_transfer_limit: default_daily_limit(),
23            minimum_reserve: default_min_reserve(),
24            daily_inference_budget: default_inference_budget(),
25            revenue_swap: RevenueSwapConfig::default(),
26        }
27    }
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct ProfitTaxConfig {
32    #[serde(default)]
33    pub enabled: bool,
34    #[serde(default = "default_profit_tax_rate")]
35    pub rate: f64,
36    #[serde(default)]
37    pub destination_wallet: Option<String>,
38}
39
40impl Default for ProfitTaxConfig {
41    fn default() -> Self {
42        Self {
43            enabled: false,
44            rate: default_profit_tax_rate(),
45            destination_wallet: None,
46        }
47    }
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize, Default)]
51pub struct SelfFundingConfig {
52    #[serde(default)]
53    pub tax: ProfitTaxConfig,
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize)]
57pub struct RevenueSwapChainConfig {
58    pub chain: String,
59    pub target_contract_address: String,
60    #[serde(default)]
61    pub swap_contract_address: Option<String>,
62}
63
64#[derive(Debug, Clone, Serialize, Deserialize)]
65pub struct RevenueSwapConfig {
66    #[serde(default = "default_true")]
67    pub enabled: bool,
68    #[serde(default = "default_revenue_swap_target_symbol")]
69    pub target_symbol: String,
70    #[serde(default = "default_revenue_swap_default_chain")]
71    pub default_chain: String,
72    #[serde(default = "default_revenue_swap_chains")]
73    pub chains: Vec<RevenueSwapChainConfig>,
74}
75
76impl Default for RevenueSwapConfig {
77    fn default() -> Self {
78        Self {
79            enabled: true,
80            target_symbol: default_revenue_swap_target_symbol(),
81            default_chain: default_revenue_swap_default_chain(),
82            chains: default_revenue_swap_chains(),
83        }
84    }
85}
86
87fn default_revenue_swap_target_symbol() -> String {
88    "PALM_USD".into()
89}
90
91fn default_revenue_swap_default_chain() -> String {
92    "ETH".into()
93}
94
95fn default_revenue_swap_chains() -> Vec<RevenueSwapChainConfig> {
96    vec![
97        RevenueSwapChainConfig {
98            chain: "ETH".into(),
99            target_contract_address: "0xfaf0cee6b20e2aaa4b80748a6af4cd89609a3d78".into(),
100            swap_contract_address: None,
101        },
102        RevenueSwapChainConfig {
103            chain: "BSC".into(),
104            target_contract_address: "0xFAF0cEe6B20e2Aaa4B80748a6AF4CD89609a3d78".into(),
105            swap_contract_address: None,
106        },
107    ]
108}
109
110fn default_profit_tax_rate() -> f64 {
111    0.0
112}
113
114fn default_per_payment_cap() -> f64 {
115    100.0
116}
117fn default_hourly_limit() -> f64 {
118    500.0
119}
120fn default_daily_limit() -> f64 {
121    2000.0
122}
123fn default_min_reserve() -> f64 {
124    5.0
125}
126fn default_inference_budget() -> f64 {
127    50.0
128}
129
130#[derive(Debug, Clone, Serialize, Deserialize)]
131pub struct YieldConfig {
132    #[serde(default)]
133    pub enabled: bool,
134    #[serde(default = "default_yield_protocol")]
135    pub protocol: String,
136    #[serde(default = "default_yield_chain")]
137    pub chain: String,
138    #[serde(default = "default_min_deposit")]
139    pub min_deposit: f64,
140    #[serde(default = "default_withdrawal_threshold")]
141    pub withdrawal_threshold: f64,
142    /// RPC URL for yield chain (e.g. Base Sepolia). If unset, deposit/withdraw use mock behavior.
143    #[serde(default)]
144    pub chain_rpc_url: Option<String>,
145    /// Aave V3 Pool address. Default: Base Sepolia.
146    #[serde(default = "default_yield_pool_address")]
147    pub pool_address: String,
148    /// Underlying asset (e.g. USDC) address for supply/withdraw. Default: Base Sepolia USDC.
149    #[serde(default = "default_yield_usdc_address")]
150    pub usdc_address: String,
151    /// aToken address for balance checks (e.g. aBase Sepolia USDC).
152    /// When `None`, falls back to the Base Sepolia aUSDC default.
153    #[serde(default)]
154    pub atoken_address: Option<String>,
155}
156
157impl Default for YieldConfig {
158    fn default() -> Self {
159        Self {
160            enabled: false,
161            protocol: default_yield_protocol(),
162            chain: default_yield_chain(),
163            min_deposit: default_min_deposit(),
164            withdrawal_threshold: default_withdrawal_threshold(),
165            chain_rpc_url: None,
166            pool_address: default_yield_pool_address(),
167            usdc_address: default_yield_usdc_address(),
168            atoken_address: None,
169        }
170    }
171}
172
173fn default_yield_protocol() -> String {
174    "aave".into()
175}
176fn default_yield_chain() -> String {
177    "base".into()
178}
179fn default_min_deposit() -> f64 {
180    50.0
181}
182fn default_withdrawal_threshold() -> f64 {
183    30.0
184}
185
186/// Aave V3 Pool on Base Sepolia
187fn default_yield_pool_address() -> String {
188    "0x07eA79F68B2B3df564D0A34F8e19D9B1e339814b".into()
189}
190/// USDC on Base Sepolia
191fn default_yield_usdc_address() -> String {
192    "0x036CbD53842c5426634e7929541eC2318f3dCF7e".into()
193}
194#[derive(Debug, Clone, Serialize, Deserialize)]
195pub struct WalletConfig {
196    #[serde(default = "default_wallet_path")]
197    pub path: PathBuf,
198    #[serde(default = "default_chain_id")]
199    pub chain_id: u64,
200    #[serde(default = "default_rpc_url")]
201    pub rpc_url: String,
202}
203
204impl Default for WalletConfig {
205    fn default() -> Self {
206        Self {
207            path: default_wallet_path(),
208            chain_id: default_chain_id(),
209            rpc_url: default_rpc_url(),
210        }
211    }
212}
213
214fn default_wallet_path() -> PathBuf {
215    dirs_next().join("wallet.json")
216}
217
218fn default_chain_id() -> u64 {
219    8453
220}
221
222fn default_rpc_url() -> String {
223    "https://mainnet.base.org".into()
224}