Skip to content

Commit

Permalink
Change to use setFeeDiscountRatio
Browse files Browse the repository at this point in the history
  • Loading branch information
42bchen committed Aug 14, 2023
1 parent 931dbfe commit 06befd9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
8 changes: 6 additions & 2 deletions contracts/MarketRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ contract MarketRegistry is IMarketRegistry, IMarketRegistryHottub, ClearingHouse
external
checkPool(baseToken)
checkRatio(feeRatio)
onlyOwnerAndHottubFeeManager
onlyOwner
{
_exchangeFeeRatioMap[baseToken] = feeRatio;
emit FeeRatioChanged(baseToken, feeRatio);
Expand All @@ -137,7 +137,11 @@ contract MarketRegistry is IMarketRegistry, IMarketRegistryHottub, ClearingHouse
emit MarketMaxPriceSpreadRatioChanged(baseToken, ratio);
}

function setFeeDiscountRatio(address trader, uint24 discountRatio) external checkRatio(discountRatio) onlyOwner {
function setFeeDiscountRatio(address trader, uint24 discountRatio)
external
checkRatio(discountRatio)
onlyOwnerAndHottubFeeManager
{
_feeDiscountRatioMap[trader] = discountRatio;
emit FeeDiscountRatioChanged(trader, discountRatio);
}
Expand Down
28 changes: 15 additions & 13 deletions test/foundry/marketRegistry/MarketRegistry.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,6 @@ contract MarketRegistrySetterTest is IMarketRegistryEvent, Setup, Constant {
marketRegistry.setFeeRatio(address(baseToken), feeRatio);
}

function test_setFeeRatio_by_hottub_feeManager_should_emit_event(uint24 feeRatio) public {
vm.assume(feeRatio <= _ONE_HUNDRED_PERCENT_RATIO);

address hottubFeeManager = makeAddr("HottubFeeManager");
marketRegistry.setHottubFeeManager(hottubFeeManager);

vm.expectEmit(false, false, false, true, address(marketRegistry));
emit FeeRatioChanged(address(baseToken), feeRatio);
vm.prank(hottubFeeManager);
marketRegistry.setFeeRatio(address(baseToken), feeRatio);
}

function test_setHottubFeeManager_should_emit_event(uint24 feeRatio) public {
vm.assume(feeRatio <= _ONE_HUNDRED_PERCENT_RATIO);
vm.expectEmit(false, false, false, true, address(marketRegistry));
Expand All @@ -203,7 +191,7 @@ contract MarketRegistrySetterTest is IMarketRegistryEvent, Setup, Constant {
}

function test_revert_setFeeRatio_if_called_by_non_owner() public {
vm.expectRevert(bytes("MR_OWHFM"));
vm.expectRevert(bytes("SO_CNO"));
vm.prank(nonOwnerAddress);
marketRegistry.setFeeRatio(address(baseToken), _ONE_HUNDRED_PERCENT_RATIO);
}
Expand Down Expand Up @@ -285,6 +273,20 @@ contract MarketRegistrySetterTest is IMarketRegistryEvent, Setup, Constant {
assertEq(uint256(legacyMarketInfo.insuranceFundFeeRatio), 0);
}

function test_setFeeDiscountRatio_by_hottub_fee_manager() public {
address hottubFeeManager = makeAddr("HottubFeeManager");
marketRegistry.setHottubFeeManager(hottubFeeManager);

address trader = makeAddr("Trader");
uint24 discountRatio = 1e6;

vm.expectEmit(false, false, false, true, address(marketRegistry));
emit FeeDiscountRatioChanged(trader, discountRatio);

vm.prank(hottubFeeManager);
marketRegistry.setFeeDiscountRatio(trader, discountRatio);
}

function test_getMarketInfoByTrader_and_setFeeDiscountRatio() public {
address bob = makeAddr("Bob");
address alice = makeAddr("Alice");
Expand Down

0 comments on commit 06befd9

Please sign in to comment.