Skip to content

Commit

Permalink
whitelist - minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanzhelyazkov committed Oct 17, 2024
1 parent 4b92c2a commit 02f3f55
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions contracts/network/BancorNetwork.sol
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,18 @@ contract BancorNetwork is IBancorNetwork, Upgradeable, ReentrancyGuardUpgradeabl
}
}

modifier onlyWhitelisted(address addr) {
_onlyWhitelisted(addr);

_;
}

function _onlyWhitelisted(address addr) internal view {
if (!_feeExemptionWhitelist.contains(addr)) {
revert AccessDenied();
}
}

receive() external payable {}

/**
Expand Down Expand Up @@ -702,10 +714,7 @@ contract BancorNetwork is IBancorNetwork, Upgradeable, ReentrancyGuardUpgradeabl
uint256 minReturnAmount,
uint256 deadline,
address beneficiary
) external payable whenNotPaused returns (uint256) {
if (!_feeExemptionWhitelist.contains(msg.sender)) {
revert AccessDenied();
}
) external payable whenNotPaused onlyWhitelisted(msg.sender) returns (uint256) {
return
_tradeBySourceAmount(
sourceToken,
Expand All @@ -729,10 +738,7 @@ contract BancorNetwork is IBancorNetwork, Upgradeable, ReentrancyGuardUpgradeabl
uint256 maxSourceAmount,
uint256 deadline,
address beneficiary
) external payable whenNotPaused returns (uint256) {
if (!_feeExemptionWhitelist.contains(msg.sender)) {
revert AccessDenied();
}
) external payable whenNotPaused onlyWhitelisted(msg.sender) returns (uint256) {
return
_tradeByTargetAmount(
sourceToken,
Expand Down Expand Up @@ -902,7 +908,7 @@ contract BancorNetwork is IBancorNetwork, Upgradeable, ReentrancyGuardUpgradeabl
function feeExemptionWhitelist() external view returns (address[] memory) {
uint256 length = _feeExemptionWhitelist.length();
address[] memory list = new address[](length);
for (uint256 i = 0; i < length; i++) {
for (uint256 i = 0; i < length; ++i) {
list[i] = _feeExemptionWhitelist.at(i);
}
return list;
Expand All @@ -929,22 +935,11 @@ contract BancorNetwork is IBancorNetwork, Upgradeable, ReentrancyGuardUpgradeabl
function addAddressesToWhitelist(address[] calldata addrs) external onlyAdmin {
uint256 length = addrs.length;

for (uint256 i = 0; i < length; i++) {
for (uint256 i = 0; i < length; ++i) {
_addToWhitelist(addrs[i]);
}
}

/**
* @dev adds an address to the fee exemption whitelist
*/
function _addToWhitelist(address addr) private validExternalAddress(addr) {
if (!_feeExemptionWhitelist.add(addr)) {
revert AlreadyExists();
}

emit AddressAddedToWhitelist(addr);
}

/**
* @dev removes an address from the fee exemption whitelist
*
Expand Down Expand Up @@ -1023,6 +1018,17 @@ contract BancorNetwork is IBancorNetwork, Upgradeable, ReentrancyGuardUpgradeabl
emit MinNetworkFeeBurnUpdated(oldMinNetworkFeeBurn, newMinNetworkFeeBurn);
}

/**
* @dev adds an address to the fee exemption whitelist
*/
function _addToWhitelist(address addr) private validExternalAddress(addr) {
if (!_feeExemptionWhitelist.add(addr)) {
revert AlreadyExists();
}

emit AddressAddedToWhitelist(addr);
}

/**
* @dev generates context ID for a deposit request
*/
Expand Down

0 comments on commit 02f3f55

Please sign in to comment.