-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new test case on testSlashOperator , still on it, almost
- Loading branch information
1 parent
787c7e5
commit 6686a05
Showing
2 changed files
with
137 additions
and
9 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
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,103 @@ | ||
// SPDX-License-Identifier: MIT | ||
// ___ __ ___ __ _ _ | ||
// / \/ / / __\ / /(_)_ __ | | __ | ||
// / /\ / / / / / / | | '_ \| |/ / | ||
// / /_// /__/ /____/ /__| | | | | < | ||
// /___,'\____|____(_)____/_|_| |_|_|\_\ | ||
|
||
pragma solidity 0.8.25; | ||
|
||
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PermitUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; | ||
|
||
/** | ||
* @author DLC.Link 2024 | ||
* @title iBTC | ||
* @notice The iBTC Token represents Bitcoin locked in self-custody by the DLC.Link protocol. | ||
* @dev Owner is the DLCManager contract | ||
* @dev Minter/Burner rights are given to CCIP token pools | ||
* @custom:contact eng@dlc.link | ||
* @custom:website https://www.dlc.link | ||
*/ | ||
contract IBTC is Initializable, ERC20Upgradeable, ERC20PermitUpgradeable, OwnableUpgradeable { | ||
mapping(address => bool) public blacklisted; // deprecated. there is no blacklisting anymore | ||
address private _minter; | ||
address private _burner; | ||
uint256[48] __gap; | ||
|
||
error NotAuthorized(); | ||
|
||
event MinterSet(address minter); | ||
event BurnerSet(address burner); | ||
|
||
/// @custom:oz-upgrades-unsafe-allow constructor | ||
constructor() { | ||
_disableInitializers(); | ||
} | ||
|
||
function initialize() public initializer { | ||
__ERC20_init("iBTC", "IBTC"); | ||
__Ownable_init(msg.sender); | ||
__ERC20Permit_init("iBTC"); | ||
} | ||
|
||
function reinitializeEIP712() public reinitializer(2) { | ||
// Reinitialize EIP712 with new name | ||
__EIP712_init_unchained("iBTC", "1"); | ||
} | ||
|
||
modifier onlyOwnerOrCCIPMinter() { | ||
if (msg.sender != _minter && msg.sender != owner()) { | ||
revert NotAuthorized(); | ||
} | ||
_; | ||
} | ||
|
||
modifier onlyCCIPBurner() { | ||
if (msg.sender != _burner) revert NotAuthorized(); | ||
_; | ||
} | ||
|
||
// Representing Satoshis | ||
function decimals() public view virtual override returns (uint8) { | ||
return 8; | ||
} | ||
|
||
function name() public view virtual override returns (string memory) { | ||
return "iBTC"; | ||
} | ||
|
||
function symbol() public view virtual override returns (string memory) { | ||
return "IBTC"; | ||
} | ||
|
||
function mint(address to, uint256 amount) external onlyOwnerOrCCIPMinter { | ||
_mint(to, amount); | ||
} | ||
|
||
function burn(address from, uint256 amount) external onlyOwner { | ||
_burn(from, amount); | ||
} | ||
|
||
function burn( | ||
uint256 amount | ||
) external onlyCCIPBurner { | ||
_burn(msg.sender, amount); | ||
} | ||
|
||
function setMinter( | ||
address minter | ||
) external onlyOwner { | ||
_minter = minter; | ||
emit MinterSet(minter); | ||
} | ||
|
||
function setBurner( | ||
address burner | ||
) external onlyOwner { | ||
_burner = burner; | ||
emit BurnerSet(burner); | ||
} | ||
} |