Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Autoparallel committed Oct 11, 2023
1 parent 0daaf92 commit 2f19bc2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
22 changes: 12 additions & 10 deletions box-simulation/src/agents/arbitrageur/g3m.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ impl Strategy for G3M<RevmMiddleware> {
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<U256> {
Expand All @@ -24,11 +25,12 @@ impl Strategy for G3M<RevmMiddleware> {
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<U256> {
Expand Down
12 changes: 12 additions & 0 deletions box-simulation/src/agents/arbitrageur/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{ops::Div, sync::Arc};

use arbiter_core::bindings::arbiter_token::ArbiterToken;
use tracing::info;

use super::*;
Expand Down Expand Up @@ -52,6 +53,17 @@ impl<S: Strategy> Arbitrageur<S> {
.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,
Expand Down

0 comments on commit 2f19bc2

Please sign in to comment.