pub mod abi;
pub mod error;
pub mod num;
pub mod state;
pub mod stream;
#[cfg(feature = "testing")]
pub mod testing;
#[cfg(test)]
mod tests;
pub mod types;
use alloy::primitives::{Address, address};
#[derive(Clone, Debug)]
pub struct Chain {
chain_id: u64,
collateral_token: Address,
deployed_at_block: u64,
exchange: Address,
perpetuals: Vec<types::PerpetualId>,
excluded_perpetuals: Vec<types::PerpetualId>,
}
impl Chain {
pub fn mainnet() -> Self {
Self {
chain_id: 143,
collateral_token: address!("0x00000000eFE302BEAA2b3e6e1b18d08D69a9012a"),
deployed_at_block: 54773010,
exchange: address!("0x34B6552d57a35a1D042CcAe1951BD1C370112a6F"),
perpetuals: vec![],
excluded_perpetuals: vec![30],
}
}
pub fn testnet() -> Self {
Self {
chain_id: 10143,
collateral_token: address!("0xa9012a055bd4e0eDfF8Ce09f960291C09D5322dC"),
deployed_at_block: 62953,
exchange: address!("0x1964C32f0bE608E7D29302AFF5E61268E72080cc"),
perpetuals: vec![],
excluded_perpetuals: vec![],
}
}
pub fn custom(
chain_id: u64,
collateral_token: Address,
deployed_at_block: u64,
exchange: Address,
perpetuals: Vec<types::PerpetualId>,
) -> Self {
Self {
chain_id,
collateral_token,
deployed_at_block,
exchange,
perpetuals,
excluded_perpetuals: vec![],
}
}
pub fn chain_id(&self) -> u64 { self.chain_id }
pub fn collateral_token(&self) -> Address { self.collateral_token }
pub fn deployed_at_block(&self) -> u64 { self.deployed_at_block }
pub fn exchange(&self) -> Address { self.exchange }
pub fn perpetuals(&self) -> &[types::PerpetualId] { &self.perpetuals }
pub fn with_perpetuals(mut self, perpetuals: Vec<types::PerpetualId>) -> Self {
self.perpetuals = perpetuals;
self
}
pub fn excluded_perpetuals(&self) -> &[types::PerpetualId] { &self.excluded_perpetuals }
pub fn with_excluded_perpetuals(mut self, perpetuals: Vec<types::PerpetualId>) -> Self {
self.excluded_perpetuals = perpetuals;
self
}
}