From b28699cc5dc88438296104bf131405a852800bdb Mon Sep 17 00:00:00 2001 From: philbow61 Date: Thu, 21 Nov 2024 23:54:28 +0100 Subject: [PATCH] feat: ensure exitContribution is less than 100% --- contracts/goodDollar/BancorExchangeProvider.sol | 2 +- test/unit/goodDollar/BancorExchangeProvider.t.sol | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contracts/goodDollar/BancorExchangeProvider.sol b/contracts/goodDollar/BancorExchangeProvider.sol index 95391152..930e2ab5 100644 --- a/contracts/goodDollar/BancorExchangeProvider.sol +++ b/contracts/goodDollar/BancorExchangeProvider.sol @@ -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; diff --git a/test/unit/goodDollar/BancorExchangeProvider.t.sol b/test/unit/goodDollar/BancorExchangeProvider.t.sol index e3d19b53..3781e191 100644 --- a/test/unit/goodDollar/BancorExchangeProvider.t.sol +++ b/test/unit/goodDollar/BancorExchangeProvider.t.sol @@ -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 {