Skip to content

Commit 27bfd5f

Browse files
committed
feat: increase reward percentage accuracy
1 parent b521c15 commit 27bfd5f

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

contracts/CollateralManagement.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ contract CollateralManagementContract is
2828
/// @notice The role that can slash collateral from the contract by using
2929
/// the slashPegInCollateral or slashPegOutCollateral functions
3030
bytes32 public constant COLLATERAL_SLASHER = keccak256("COLLATERAL_SLASHER");
31+
uint256 public constant TOTAL_REWARD_PERCENTAGE = 10_000;
3132

3233
uint256 private _minCollateral;
3334
uint256 private _resignDelayInBlocks;
@@ -107,7 +108,6 @@ contract CollateralManagementContract is
107108
_minCollateral = minCollateral;
108109
_resignDelayInBlocks = resignDelayInBlocks;
109110
_rewardPercentage = rewardPercentage;
110-
_penalties = 0;
111111
}
112112

113113
/// @notice Sets the minimum collateral required for a liquidity provider **per operation**
@@ -145,7 +145,7 @@ contract CollateralManagementContract is
145145
_pegInCollateral[quote.liquidityProviderRskAddress]
146146
);
147147
_pegInCollateral[quote.liquidityProviderRskAddress] -= penalty;
148-
uint256 punisherReward = (penalty * _rewardPercentage) / 100;
148+
uint256 punisherReward = (penalty * _rewardPercentage) / TOTAL_REWARD_PERCENTAGE;
149149
_penalties += penalty - punisherReward;
150150
_rewards[punisher] += punisherReward;
151151
emit Penalized(
@@ -169,7 +169,7 @@ contract CollateralManagementContract is
169169
_pegOutCollateral[quote.lpRskAddress]
170170
);
171171
_pegOutCollateral[quote.lpRskAddress] -= penalty;
172-
uint256 punisherReward = (penalty * _rewardPercentage) / 100;
172+
uint256 punisherReward = (penalty * _rewardPercentage) / TOTAL_REWARD_PERCENTAGE;
173173
_penalties += penalty - punisherReward;
174174
_rewards[punisher] += punisherReward;
175175
emit Penalized(

test/utils/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const COLLATERAL_CONSTANTS = {
5959
TEST_DEFAULT_ADMIN_DELAY: 30n,
6060
TEST_MIN_COLLATERAL: ethers.parseEther("0.6"),
6161
TEST_RESIGN_DELAY_BLOCKS: 500n,
62-
TEST_REWARD_PERCENTAGE: 10n,
62+
TEST_REWARD_PERCENTAGE: 1000n,
6363
} as const;
6464

6565
export enum ProviderType {

test/utils/quotes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ export function getRewardForQuote(
144144
quote: { penaltyFee: BigNumberish },
145145
rewardPercentage: BigNumberish
146146
) {
147-
return (BigInt(quote.penaltyFee) * BigInt(rewardPercentage)) / 100n;
147+
return (BigInt(quote.penaltyFee) * BigInt(rewardPercentage)) / 10000n;
148148
}
149149

150150
export function getEmptyPegInQuote(): Quotes.PegInQuoteStruct {

0 commit comments

Comments
 (0)