diff --git a/src/mocks/Reserve.sol b/src/mocks/Reserve.sol index d491add..2ad8a1d 100644 --- a/src/mocks/Reserve.sol +++ b/src/mocks/Reserve.sol @@ -55,12 +55,15 @@ contract Reserve is ERC20Permit { } function burn(uint256 amount) external payable { - (bool sent,) = msg.sender.call{ value: estimateAmount(amount) }(""); - require(sent, "Failed to send Ether"); _innerBurn(msg.sender, amount); + uint256 valueDiff = address(this).balance - accumulatedDonation; + uint256 valueBack = amount * valueDiff / (amount + totalSupply()); + + (bool sent,) = msg.sender.call{ value: valueBack }(""); + require(sent, "Failed to send Ether"); } - function estimateAmount(uint256 amount) public view returns (uint256) { + function estimateAmount(uint256 amount) external view returns (uint256) { uint256 valueDiff = address(this).balance - accumulatedDonation; return amount * valueDiff / totalSupply(); }