Calculate priced gross open interest from outstanding outcome positions

This commit is contained in:
2026-12-03 05:46:00 +08:00
parent 38742fbdec
commit f72d0fe602
10 changed files with 222 additions and 32 deletions
+26
View File
@@ -20,3 +20,29 @@ pub(crate) fn phase(tx: &Transaction, market: &str, allowed: &[&str]) -> Result<
ensure!(allowed.contains(&p.as_str()), "wrong market phase");
Ok(p)
}
#[derive(serde::Serialize, serde::Deserialize, PartialEq)]
#[serde(untagged)]
pub(crate) enum IdSelector {
One(String),
Many(Vec<String>),
}
impl IdSelector {
pub(crate) fn ids(&self) -> Result<Vec<String>> {
let mut ids = match self {
Self::One(id) => vec![id.clone()],
Self::Many(ids) => ids.clone(),
};
ids.sort();
ids.dedup();
ensure!(
(1..=20).contains(&ids.len()),
"expected 1 to 20 distinct IDs"
);
for id in &ids {
identifier(id)?;
}
Ok(ids)
}
}