Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ensure exitContribution is less than 100% #549

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading