Skip to content

Commit

Permalink
update buffer feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Frihat-dev committed Oct 27, 2023
1 parent f6b69ce commit 669b286
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions contracts/TapETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ error InsufficientBalance(uint256 currentBalance, uint256 amount);
contract TapETH is Initializable, ITapETH {
using Math for uint256;
uint256 internal constant INFINITE_ALLOWANCE = ~uint256(0);
uint256 public constant BUFFER_DENOMINATOR = 10 ** 10;

uint256 private totalShares;
uint256 private _totalSupply;
Expand Down Expand Up @@ -256,12 +257,13 @@ contract TapETH is Initializable, ITapETH {
}

/**
* @notice This function is called by the governance to set the buffer.
* @notice This function is called by the governance to set the buffer rate.
*/
function setBuffer(uint256 _amount) external {
function setBuffer(uint256 _buffer) external {
require(msg.sender == governance, "TapETH: no governance");
buffer = _amount;
emit SetBuffer(_amount);
require(_buffer <= BUFFER_DENOMINATOR, "TapETH: out of range");
buffer = _buffer;
emit SetBuffer(_buffer);
}

/**
Expand All @@ -271,10 +273,8 @@ contract TapETH is Initializable, ITapETH {
function setTotalSupply(uint256 _amount) external {
require(pools[msg.sender], "TapETH: no pool");
require(_amount != 0, "TapETH: no pool");
uint256 _deltaBuffer = Math.min(buffer, _amount);
uint256 _deltaBuffer = (buffer * _amount) / BUFFER_DENOMINATOR;
_totalSupply += _amount - _deltaBuffer;
totalRewards += _amount;
buffer -= _deltaBuffer;
}

/**
Expand Down

0 comments on commit 669b286

Please sign in to comment.