From 2f19bc264604ee588d61527f46acb4940a6841fc Mon Sep 17 00:00:00 2001 From: Colin Roberts Date: Wed, 11 Oct 2023 13:10:10 -0600 Subject: [PATCH] changes --- box-simulation/src/agents/arbitrageur/g3m.rs | 22 +++++++++++--------- box-simulation/src/agents/arbitrageur/mod.rs | 12 +++++++++++ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/box-simulation/src/agents/arbitrageur/g3m.rs b/box-simulation/src/agents/arbitrageur/g3m.rs index f60eb3d29..60cb1328a 100644 --- a/box-simulation/src/agents/arbitrageur/g3m.rs +++ b/box-simulation/src/agents/arbitrageur/g3m.rs @@ -11,11 +11,12 @@ impl Strategy for G3M { let reserve_y = self.reserve_y().call().await?; let invariant = self.get_invariant().call().await?; - Ok(weight_y - * U256::from(1) - .div(target_price_wad * invariant.pow(U256::from(1).div(weight_x))) - .pow(U256::from(1) + weight_y.div(weight_x)) - - reserve_y) + // Ok(weight_y + // * U256::from(1) + // .div(target_price_wad * invariant.pow(U256::from(1).div(weight_x))) + // .pow(U256::from(1) + weight_y.div(weight_x)) + // - reserve_y) + Ok(U256::from(1_000_000_000)) } async fn get_y_input(&self, target_price_wad: U256) -> Result { @@ -24,11 +25,12 @@ impl Strategy for G3M { let reserve_x = self.reserve_x().call().await?; let invariant = self.get_invariant().call().await?; - Ok(weight_x - * target_price_wad - .div(invariant.pow(U256::from(1).div(weight_y))) - .pow(U256::from(1) + weight_x.div(weight_y)) - - reserve_x) + // Ok(weight_x + // * target_price_wad + // .div(invariant.pow(U256::from(1).div(weight_y))) + // .pow(U256::from(1) + weight_x.div(weight_y)) + // - reserve_x) + Ok(U256::from(1_000_000_000)) } async fn get_spot_price(&self) -> Result { diff --git a/box-simulation/src/agents/arbitrageur/mod.rs b/box-simulation/src/agents/arbitrageur/mod.rs index 69dd4d36d..8f98a7907 100644 --- a/box-simulation/src/agents/arbitrageur/mod.rs +++ b/box-simulation/src/agents/arbitrageur/mod.rs @@ -1,5 +1,6 @@ use std::{ops::Div, sync::Arc}; +use arbiter_core::bindings::arbiter_token::ArbiterToken; use tracing::info; use super::*; @@ -52,6 +53,17 @@ impl Arbitrageur { .send() .await?; + let arbx = ArbiterToken::new(arbx, client.clone()); + let arby = ArbiterToken::new(arby, client.clone()); + arbx.approve(atomic_arbitrage.address(), U256::MAX) + .send() + .await? + .await?; + arby.approve(atomic_arbitrage.address(), U256::MAX) + .send() + .await? + .await?; + Ok(Self { client, liquid_exchange,