Skip to content

Commit

Permalink
feat: ensure exitContribution is less than 100% (#549)
Browse files Browse the repository at this point in the history
  • Loading branch information
philbow61 authored Nov 22, 2024
1 parent 84d9d42 commit 9f7ee3c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion contracts/goodDollar/BancorExchangeProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ contract BancorExchangeProvider is IExchangeProvider, IBancorExchangeProvider, B

function _setExitContribution(bytes32 exchangeId, uint32 exitContribution) internal {
require(exchanges[exchangeId].reserveAsset != address(0), "Exchange does not exist");
require(exitContribution <= MAX_WEIGHT, "Exit contribution is too high");
require(exitContribution < MAX_WEIGHT, "Exit contribution is too high");

PoolExchange storage exchange = exchanges[exchangeId];
exchange.exitContribution = exitContribution;
Expand Down
4 changes: 2 additions & 2 deletions test/unit/goodDollar/BancorExchangeProvider.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,12 @@ contract BancorExchangeProviderTest_initilizerSettersGetters is BancorExchangePr
bancorExchangeProvider.setExitContribution(exchangeId, 1e5);
}

function test_setExitContribution_whenExitContributionAbove100Percent_shouldRevert() public {
function test_setExitContribution_whenExitContributionIsNotLessThan100Percent_shouldRevert() public {
bytes32 exchangeId = bancorExchangeProvider.createExchange(poolExchange1);

uint32 maxWeight = bancorExchangeProvider.MAX_WEIGHT();
vm.expectRevert("Exit contribution is too high");
bancorExchangeProvider.setExitContribution(exchangeId, maxWeight + 1);
bancorExchangeProvider.setExitContribution(exchangeId, maxWeight);
}

function test_setExitContribution_whenSenderIsOwner_shouldUpdateAndEmit() public {
Expand Down

0 comments on commit 9f7ee3c

Please sign in to comment.