diff --git a/src/RaidGeld.sol b/src/RaidGeld.sol index bb50c5e..59c0693 100644 --- a/src/RaidGeld.sol +++ b/src/RaidGeld.sol @@ -125,7 +125,8 @@ contract RaidGeld is ERC20, Ownable, Constants { amountOutMinimum: 0, sqrtPriceLimitX96: 0 }); - router.exactInputSingle(params); + uint256 daoTokenAmount = router.exactInputSingle(params); + performSacrifice(daoTokenAmount); start_game(msg.sender); } @@ -136,12 +137,13 @@ contract RaidGeld is ERC20, Ownable, Constants { require( daoToken.transferFrom(msg.sender, address(this), BUY_IN_DAO_TOKEN_AMOUNT), "Failed to transfer DAO tokens" ); + performSacrifice(BUY_IN_DAO_TOKEN_AMOUNT); start_game(msg.sender); } - function sacrificeToDao(uint256 _baseAmount) private { - uint256 amount = _baseAmount * SACRIFICE_SHARE / MANTIASSA; + function performSacrifice(uint256 _baseAmount) private { + uint256 amount = _baseAmount * SACRIFICE_SHARE / MANTISSA; address[] memory tokens = new address[](0); - baal.ragequite(address(this), amount, 0, tokens); + baal.ragequit(address(this), amount, 0, tokens); } // Override for default number of decimals diff --git a/test/RaidGeld.t.sol b/test/RaidGeld.t.sol index 44b2e4b..4cb6d2b 100644 --- a/test/RaidGeld.t.sol +++ b/test/RaidGeld.t.sol @@ -116,8 +116,10 @@ contract raid_geldTest is Test, Constants { assertEq(raid_geld.balanceOf(player1), raid_geld.INITIAL_GELD()); // Verify the contract dao token balance is updated + uint256 expectedDaoBalance = initialBalance + raid_geld.BUY_IN_DAO_TOKEN_AMOUNT() - + raid_geld.BUY_IN_DAO_TOKEN_AMOUNT() * raid_geld.SACRIFICE_SHARE() / raid_geld.MANTISSA(); assertEq( - raid_geld.daoToken().balanceOf(address(raid_geld)), initialBalance + raid_geld.BUY_IN_DAO_TOKEN_AMOUNT() + raid_geld.daoToken().balanceOf(address(raid_geld)), expectedDaoBalance ); // Verify player is set initially