-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from 1inch/feature/curve-oracle/blacklist
[SC-1160] Blacklist in CurveOracle
- Loading branch information
Showing
5 changed files
with
68 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.23; | ||
|
||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
|
||
contract Blacklist is Ownable { | ||
event BlacklistUpdated(address pool, bool isBlacklisted); | ||
|
||
mapping(address => bool) public blacklisted; | ||
|
||
constructor(address[] memory initialBlacklist, address owner) Ownable(owner) { | ||
for (uint256 i = 0; i < initialBlacklist.length; i++) { | ||
blacklisted[initialBlacklist[i]] = true; | ||
} | ||
} | ||
|
||
function toggleBlacklistAddress(address pool) external onlyOwner { | ||
blacklisted[pool] = !blacklisted[pool]; | ||
emit BlacklistUpdated(pool, blacklisted[pool]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers'); | ||
const { ethers } = require('hardhat'); | ||
const { expect, deployContract } = require('@1inch/solidity-utils'); | ||
const { tokens } = require('./helpers.js'); | ||
|
||
describe('Blacklist', function () { | ||
async function initContracts () { | ||
const [owner, alice] = await ethers.getSigners(); | ||
const blacklist = await deployContract('Blacklist', [[], owner]); | ||
return { owner, alice, blacklist }; | ||
} | ||
|
||
it('should revert by non-owner', async function () { | ||
const { alice, blacklist } = await loadFixture(initContracts); | ||
await expect(blacklist.connect(alice).toggleBlacklistAddress(tokens.ETH)).to.be.revertedWithCustomError(blacklist, 'OwnableUnauthorizedAccount'); | ||
}); | ||
|
||
it('should toggle record state', async function () { | ||
const { owner, blacklist } = await loadFixture(initContracts); | ||
await blacklist.connect(owner).toggleBlacklistAddress(tokens.ETH); | ||
expect(await blacklist.blacklisted(tokens.ETH)).to.be.true; | ||
await blacklist.connect(owner).toggleBlacklistAddress(tokens.ETH); | ||
expect(await blacklist.blacklisted(tokens.ETH)).to.be.false; | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters