use std::str::FromStr;
use num_bigint::BigUint;
use tycho_common::Bytes;
pub const PRICE_LEVEL_STREAM_FAMILY: &str = "pricelevelstream";
#[derive(Debug, Clone)]
pub struct PriceLevelStreamConfig {
pub protocol: String,
pub address: Bytes,
pub gas_cost: BigUint,
}
impl PriceLevelStreamConfig {
pub fn new(protocol: impl Into<String>, address: Bytes, gas_cost: BigUint) -> Self {
Self { protocol: protocol.into(), address, gas_cost }
}
pub(super) fn auto_detected(address: Bytes, gas_cost: BigUint) -> Self {
let protocol = address.to_string();
Self::new(protocol, address, gas_cost)
}
pub fn protocol_system(&self) -> String {
format!("{PRICE_LEVEL_STREAM_FAMILY}:{}", self.protocol)
}
}
pub const DEFAULT_AUTO_DETECTED_GAS_COST: u64 = 335_000;
pub fn default_served_pamms() -> Vec<PriceLevelStreamConfig> {
let pamms = [
("fermiswap", "0x5979458912f80b96d30d4220af8e2e4925a33320", 185_000u64),
("kipseli", "0x71e790dd841c8a9061487cb3e78c288e75ce0b3d", 335_000u64),
("metric", "0xe715dc29d2c273d0fc5a03e5cca9ccb0abb1dcdb", 230_000u64),
("bebop", "0xb09aaa5614916d7aeb59c295c52c92ca82addd76", 140_000u64),
("taurusfi", "0x217d58931a8549ca539426aa8152e33dafc3d95a", 110_000u64),
];
pamms
.into_iter()
.map(|(protocol, address, gas_cost)| {
PriceLevelStreamConfig::new(
protocol,
Bytes::from_str(address).expect("hardcoded pAMM address must parse"),
BigUint::from(gas_cost),
)
})
.collect()
}
pub fn default_denied_pamms() -> Vec<Bytes> {
["0x00000003f1ec2379e79f58e12ec6c4f51ee92149"]
.into_iter()
.map(|address| Bytes::from_str(address).expect("hardcoded pAMM address must parse"))
.collect()
}