diff --git a/configs/example.toml b/configs/example.toml deleted file mode 100644 index bf2cd89..0000000 --- a/configs/example.toml +++ /dev/null @@ -1,2 +0,0 @@ -[[my_agent]] -Deployer = {} diff --git a/configs/stable_pool.toml b/configs/stable_pool.toml new file mode 100644 index 0000000..5c2b8c2 --- /dev/null +++ b/configs/stable_pool.toml @@ -0,0 +1,11 @@ +[[admin]] +Deployer = {} + +[[admin]] +PoolAdmin = {} + +[[admin]] +TokenAdmin = { token_data.TKN0 = { name = "TKN0", symbol = "Token 0", decimals = 18 } } + +[[changer]] +PriceChanger = { mu = 1, theta = 1, sigma = 1, cursor = 0, value = 1 } \ No newline at end of file diff --git a/src/behaviors/price_changer.rs b/src/behaviors/price_changer.rs index 862b13b..cfed42f 100644 --- a/src/behaviors/price_changer.rs +++ b/src/behaviors/price_changer.rs @@ -14,8 +14,9 @@ use crate::bindings::liquid_exchange::LiquidExchange; #[derive(Serialize, Deserialize)] pub struct PriceChanger { - #[serde(skip)] - pub params: OrnsteinUhlenbeckParams, + mu: f64, + sigma: f64, + theta: f64, #[serde(skip)] #[serde(default = "trajectory_default")] @@ -35,13 +36,6 @@ fn trajectory_default() -> Trajectories { } } -#[derive(Debug, Serialize, Deserialize, Default)] -pub struct OrnsteinUhlenbeckParams { - mu: f64, - sigma: f64, - theta: f64, -} - impl fmt::Debug for PriceChanger { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", serde_json::to_string(self).unwrap()) @@ -55,14 +49,16 @@ pub struct PriceUpdate { impl PriceChanger { /// Public constructor function to create a [`PriceChanger`] behaviour. - pub fn new(initial_value: f64, params: OrnsteinUhlenbeckParams) -> Self { - let ou = OrnsteinUhlenbeck::new(params.mu, params.sigma, params.theta); + pub fn new(initial_value: f64, mu: f64, sigma: f64, theta: f64) -> Self { + let ou = OrnsteinUhlenbeck::new(mu, sigma, theta); // Chunk our price trajectory over 100 price points. let current_chunk = ou.euler_maruyama(initial_value, 0.0, 100.0, 100_usize, 1_usize, false); Self { - params, + mu, + sigma, + theta, current_chunk, cursor: 0, client: None, @@ -75,14 +71,16 @@ impl PriceChanger { impl Behavior for PriceChanger { async fn startup( &mut self, - _client: Arc, + client: Arc, _messager: Messager, ) -> Result>> { + self.client = Some(client); + Ok(None) } async fn process(&mut self, event: Message) -> Result { - let ou = OrnsteinUhlenbeck::new(self.params.mu, self.params.sigma, self.params.theta); + let ou = OrnsteinUhlenbeck::new(self.mu, self.sigma, self.theta); let query: PriceUpdate = match serde_json::from_str(&event.data) { Ok(query) => query,