Skip to main content

hypercall_db/traits/
mmp.rs

1//! MMP (Market Maker Protection) config persistence traits.
2
3use anyhow::Result;
4use hypercall_types::WalletAddress;
5
6use crate::MmpConfigRecord;
7
8/// Read-only MMP config queries.
9pub trait MmpConfigReader: Send + Sync {
10    /// Load MMP config for a specific wallet+currency pair.
11    fn get_mmp_config_sync(
12        &self,
13        wallet: &WalletAddress,
14        currency: &str,
15    ) -> Result<Option<MmpConfigRecord>>;
16    /// Load all MMP configs for a wallet (all currencies).
17    fn get_all_mmp_configs_for_wallet_sync(
18        &self,
19        wallet: &WalletAddress,
20    ) -> Result<Vec<MmpConfigRecord>>;
21    /// Load all MMP configs across all wallets.
22    fn get_all_mmp_configs_sync(&self) -> Result<Vec<MmpConfigRecord>>;
23}
24
25/// MMP config mutations.
26pub trait MmpConfigWriter: MmpConfigReader {
27    /// Upsert an MMP config (insert or update on wallet+currency conflict).
28    fn save_mmp_config_sync(&self, config: &MmpConfigRecord) -> Result<()>;
29    /// Delete an MMP config for a specific wallet+currency pair.
30    fn delete_mmp_config_sync(&self, wallet: &WalletAddress, currency: &str) -> Result<()>;
31}