diff --git a/box-contracts/src/G3M.sol b/box-contracts/src/G3M.sol index eb146bbf5..ad10aa738 100644 --- a/box-contracts/src/G3M.sol +++ b/box-contracts/src/G3M.sol @@ -331,8 +331,8 @@ contract G3M is IG3M { } /// @inheritdoc IG3M - function getInvariant() external view returns (UD60x18) { - return computeInvariant(reserveX, weightX(), reserveY, weightY()); + function getInvariant() external view returns (uint) { + return convert(computeInvariant(reserveX, weightX(), reserveY, weightY())); } function reserveXWithoutPrecision() external view returns (uint256) { diff --git a/box-contracts/src/IG3M.sol b/box-contracts/src/IG3M.sol index 4c5f6a462..a7f5bb752 100644 --- a/box-contracts/src/IG3M.sol +++ b/box-contracts/src/IG3M.sol @@ -118,7 +118,7 @@ interface IG3M { function getSpotPrice() external view returns (uint256); /// @notice Computes the invariant of the pool. - function getInvariant() external view returns (UD60x18); + function getInvariant() external view returns (uint); /// @notice Address of token X. function tokenX() external view returns (address); diff --git a/simulation/src/agents/arbitrageur/g3m.rs b/simulation/src/agents/arbitrageur/g3m.rs index 8c3edd6bd..778675260 100644 --- a/simulation/src/agents/arbitrageur/g3m.rs +++ b/simulation/src/agents/arbitrageur/g3m.rs @@ -14,9 +14,9 @@ impl Strategy for G3M { info!("weight_x: {}", weight_x); let weight_y = I256::from_raw(self.weight_y().call().await?); info!("weight_y: {}", weight_y); - let reserve_x = I256::from_raw(self.reserve_x().call().await?); + let reserve_x = I256::from_raw(self.reserve_x_without_precision().call().await?); info!("reserve_x: {}", reserve_x); - let reserve_y = I256::from_raw(self.reserve_y().call().await?); + let reserve_y = I256::from_raw(self.reserve_y_without_precision().call().await?); info!("reserve_y: {}", reserve_y); let invariant = I256::from_raw(self.get_invariant().call().await?); info!("invariant: {}", invariant); @@ -31,9 +31,6 @@ impl Strategy for G3M { let delta_x = invariant * math.pow(inside, weight_y).call().await? / iwad - reserve_x; info!("delta_x: {}", delta_x); - let gamma = iwad - (I256::from_raw(self.swap_fee().await?)) * I256::from(10u128.pow(14)); - info!("gamma: {}", gamma); - let delta_x = delta_x * gamma / iwad; Ok(delta_x.into_raw()) } @@ -46,9 +43,9 @@ impl Strategy for G3M { info!("weight_x: {}", weight_x); let weight_y = I256::from_raw(self.weight_y().call().await?); info!("weight_y: {}", weight_y); - let reserve_x = I256::from_raw(self.reserve_x().call().await?); + let reserve_x = I256::from_raw(self.reserve_x_without_precision().call().await?); info!("reserve_x: {}", reserve_x); - let reserve_y = I256::from_raw(self.reserve_y().call().await?); + let reserve_y = I256::from_raw(self.reserve_y_without_precision().call().await?); info!("reserve_y: {}", reserve_y); let invariant = I256::from_raw(self.get_invariant().call().await?); info!("invariant: {}", invariant); @@ -62,9 +59,6 @@ impl Strategy for G3M { info!("inside: {}", inside); let delta_y = invariant * math.pow(inside, weight_x).call().await? / iwad - reserve_y; info!("delta_y: {}", delta_y); - let gamma = iwad - (I256::from_raw(self.swap_fee().await?)) * I256::from(10u128.pow(14)); - info!("gamma: {}", gamma); - let delta_y = delta_y * gamma / iwad; Ok(delta_y.into_raw()) }