Skip to content

Commit ad84b67

Browse files
committed
feat: Adjustment formula for weight Balance of share;
1 parent e7bca17 commit ad84b67

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

contracts/gauges/Gauge.sol

+7-7
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ contract Gauge is IGauge, ERC2771Context, ReentrancyGuard {
9090
function updateGainBalance(address _user) internal {
9191
uint256 _originBalance = balanceOf[_user];
9292
if ( _originBalance > 0 ){
93-
//
94-
uint256 _gainBalance = _originBalance * gain / Factor + _originBalance;
93+
uint256 _share = shares[_user];
94+
uint256 _gainBalance = _originBalance * gain / Factor * _share / gainTotalSupply + _originBalance;
9595
uint256 _oldGainBalance = gainBalanceOf[_user];
9696
gainBalanceOf[_user] = _gainBalance;
9797
gainTotalSupply = gainTotalSupply - _oldGainBalance + _gainBalance;
@@ -168,16 +168,16 @@ contract Gauge is IGauge, ERC2771Context, ReentrancyGuard {
168168
totalSupply -= _amount;
169169
balanceOf[receipt] -= _amount;
170170
IERC20(stakingToken).safeTransfer(receipt, _amount);
171-
updateGainBalance(_recipient);
171+
updateGainBalance(receipt);
172172

173-
emit Withdraw(receipt, _amount);
173+
emit Withdraw(receipt, _amount);
174174
}
175175

176-
function _updateRewards(address _account) internal {
176+
function _updateRewards(address _user) internal {
177177
rewardPerTokenStored = rewardPerToken();
178178
lastUpdateTime = lastTimeRewardApplicable();
179-
rewards[_account] = earned(_account);
180-
userRewardPerTokenPaid[_account] = rewardPerTokenStored;
179+
rewards[_user] = earned(_user);
180+
userRewardPerTokenPaid[_user] = rewardPerTokenStored;
181181
}
182182

183183
/// @inheritdoc IGauge

0 commit comments

Comments
 (0)