Skip to content

Commit 000283f

Browse files
authored
- update emergency fee handler to handle rebate leftover.
- update test case when total rebateBpsPerWallet < BPS. we have rebate leftover which is allocated for rewards
1 parent d7a026d commit 000283f

File tree

3 files changed

+309
-238
lines changed

3 files changed

+309
-238
lines changed

contracts/sol6/Dao/emergency/EmergencyFeeHandler.sol

+20-7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ contract EmergencyKyberFeeHandler is IKyberFeeHandler, PermissionGroupsNoModifie
2525
mapping(address => uint256) public rebatePerWallet;
2626
uint256 public totalRewardWei;
2727

28+
struct BRRWei {
29+
uint256 rewardWei;
30+
uint256 fullRebateWei;
31+
uint256 paidRebateWei;
32+
uint256 burnWei;
33+
}
34+
2835
event HandleFeeFailed(address[] rebateWallets, uint256[] rebateBpsPerWallet, uint256 feeBRRWei);
2936

3037
event HandleFee(
@@ -131,21 +138,27 @@ contract EmergencyKyberFeeHandler is IKyberFeeHandler, PermissionGroupsNoModifie
131138
uint256 feeBRRWei
132139
) external virtual {
133140
require(msg.sender == address(this), "only Feehandler contract can call this function");
134-
uint256 rebateWei = feeBRRWei.mul(rebateBps).div(BPS);
135-
uint256 rewardWei = feeBRRWei.mul(rewardBps).div(BPS);
141+
BRRWei memory brrAmounts;
142+
143+
brrAmounts.fullRebateWei = feeBRRWei.mul(rebateBps).div(BPS);
144+
brrAmounts.rewardWei = feeBRRWei.mul(rewardBps).div(BPS);
136145

137-
rebateWei = updateRebateValues(rebateWei, rebateWallets, rebateBpsPerWallet);
146+
brrAmounts.paidRebateWei = updateRebateValues(brrAmounts.fullRebateWei, rebateWallets, rebateBpsPerWallet);
147+
148+
brrAmounts.rewardWei = brrAmounts.rewardWei.add(
149+
brrAmounts.fullRebateWei.sub(brrAmounts.paidRebateWei)
150+
);
138151

139-
totalRewardWei = totalRewardWei.add(rewardWei);
152+
totalRewardWei = totalRewardWei.add(brrAmounts.rewardWei);
140153

141-
uint burnAmountWei = feeBRRWei.sub(rewardWei).sub(rebateWei);
154+
uint burnAmountWei = feeBRRWei.sub(brrAmounts.rewardWei).sub(brrAmounts.paidRebateWei);
142155

143156
emit FeeDistribution(
144157
ETH_TOKEN_ADDRESS,
145158
platformWallet,
146159
platformFee,
147-
rewardWei,
148-
rebateWei,
160+
brrAmounts.rewardWei,
161+
brrAmounts.paidRebateWei,
149162
rebateWallets,
150163
rebateBpsPerWallet,
151164
burnAmountWei

0 commit comments

Comments
 (0)