Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- MigrationCE
- Optimization enabled
- true
- Compiler version
- v0.8.19+commit.7dd6d404
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2024-09-26T15:33:00.483546Z
Contract source code
// SPDX-License-Identifier: No License (None)
pragma solidity 0.8.19;
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*
* Source https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-solidity/v2.1.3/contracts/ownership/Ownable.sol
* This contract is copied here and renamed from the original to avoid clashes in the compiled artifacts
* when the user imports a zos-lib contract (that transitively causes this contract to be compiled and added to the
* build/artifacts folder) as well as the vanilla Ownable implementation from an openzeppelin version.
*/
contract Ownable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor () {
_owner = msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
/**
* @return the address of the owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(isOwner(),"Not Owner");
_;
}
/**
* @return true if `msg.sender` is the owner of the contract.
*/
function isOwner() public view returns (bool) {
return msg.sender == _owner;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0),"Zero address not allowed");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
interface IERC223 {
function mint(address _to, uint256 _amount) external;
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function burnFrom(address sender, uint256 amount) external returns (bool);
function transfer(address recipient, uint256 amount) external;
function balanceOf(address account) external view returns (uint256);
}
contract MigrationCE is Ownable {
address constant public CLOE = address(0x1eAa43544dAa399b87EEcFcC6Fa579D5ea4A6187);
address constant public CE = address(0x3986E815F87feA74910F7aDeAcD1cE7f172E1df0);
uint256 public cloeRate = 30000; // rate in percentage with 2 decimals. CE amount = CLOE amount * cloeRate / 10000
bool public isPause;
uint256 public totalCEMinted;
uint256 public totalCLOEMigrated;
event Migrate(address user, uint256 CLOEAmount, uint256 CEAmount);
modifier migrationAllowed() {
require(!isPause, "Migration is paused");
_;
}
function tokenReceived(address, uint, bytes memory) external pure returns(bytes4) {
revert("not allowed");
}
function migrate(address user, uint256 amount) internal migrationAllowed {
IERC223(CLOE).transferFrom(msg.sender, address(this), amount);
uint256 ceAmount = amount * cloeRate / 10000;
totalCLOEMigrated += amount;
totalCEMinted += ceAmount;
emit Migrate(user, amount, ceAmount);
}
function setPause(bool pause) external onlyOwner {
isPause = pause;
}
// rate in percentage with 2 decimals. CE amount = CLOE amount * cloeRate / 10000
function setCloeRate(uint256 _cloeRate) external onlyOwner {
cloeRate = _cloeRate;
}
// Rescue tokens
event Rescue(address _token, uint256 _amount);
function rescueTokens(address _token) external onlyOwner {
uint256 _amount;
if (_token == address(0)) {
_amount = address(this).balance;
safeTransferETH(msg.sender, _amount);
} else {
_amount = IERC223(_token).balanceOf(address(this));
safeTransfer(_token, msg.sender, _amount);
}
emit Rescue(_token, _amount);
}
function safeTransfer(address token, address to, uint value) internal {
// bytes4(keccak256(bytes('transfer(address,uint256)')));
(bool success, bytes memory data) = token.call(
abi.encodeWithSelector(0xa9059cbb, to, value)
);
require(
success && (data.length == 0 || abi.decode(data, (bool))),
"TransferHelper: TRANSFER_FAILED"
);
}
function safeTransferETH(address to, uint value) internal {
(bool success,) = to.call{value:value}(new bytes(0));
require(success, 'TransferHelper: ETH_TRANSFER_FAILED');
}
}
Contract ABI
[{"type":"event","name":"Migrate","inputs":[{"type":"address","name":"user","internalType":"address","indexed":false},{"type":"uint256","name":"CLOEAmount","internalType":"uint256","indexed":false},{"type":"uint256","name":"CEAmount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Rescue","inputs":[{"type":"address","name":"_token","internalType":"address","indexed":false},{"type":"uint256","name":"_amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"CE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"CLOE","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"cloeRate","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isOwner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isPause","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"rescueTokens","inputs":[{"type":"address","name":"_token","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setCloeRate","inputs":[{"type":"uint256","name":"_cloeRate","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPause","inputs":[{"type":"bool","name":"pause","internalType":"bool"}]},{"type":"function","stateMutability":"pure","outputs":[{"type":"bytes4","name":"","internalType":"bytes4"}],"name":"tokenReceived","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"},{"type":"bytes","name":"","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalCEMinted","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"totalCLOEMigrated","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]}]
Contract Creation Code
0x608060405261753060015534801561001657600080fd5b50600080546001600160a01b0319163390811782556040519091907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908290a3610942806100656000396000f3fe608060405234801561001057600080fd5b50600436106100e95760003560e01c80638943ec021161008c5780638f32d59b116100665780638f32d59b146101d7578063bedb86fb146101f6578063f2fde38b14610209578063ff0938a71461021c57600080fd5b80638943ec02146101915780638b50e446146101bd5780638da5cb5b146101c657600080fd5b8063314de7c3116100c8578063314de7c31461015257806351d912431461015b5780635eb325eb1461016e578063715018a61461018957600080fd5b8062ae3bf8146100ee5780631a5057d5146101035780632da49d161461013b575b600080fd5b6101016100fc36600461073d565b610229565b005b61011e733986e815f87fea74910f7adeacd1ce7f172e1df081565b6040516001600160a01b0390911681526020015b60405180910390f35b61014460045481565b604051908152602001610132565b61014460015481565b61010161016936600461075f565b610338565b61011e731eaa43544daa399b87eecfcc6fa579d5ea4a618781565b610101610367565b6101a461019f36600461078e565b6103db565b6040516001600160e01b03199091168152602001610132565b61014460035481565b6000546001600160a01b031661011e565b6000546001600160a01b031633145b6040519015158152602001610132565b610101610204366004610867565b610414565b61010161021736600461073d565b610451565b6002546101e69060ff1681565b6000546001600160a01b0316331461025c5760405162461bcd60e51b815260040161025390610884565b60405180910390fd5b60006001600160a01b03821661027d5750476102783382610487565b6102f2565b6040516370a0823160e01b81523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa1580156102c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e591906108a7565b90506102f2823383610555565b604080516001600160a01b0384168152602081018390527f542fa6bfee3b4746210fbdd1d83f9e49b65adde3639f8d8f165dd18347938af2910160405180910390a15050565b6000546001600160a01b031633146103625760405162461bcd60e51b815260040161025390610884565b600155565b6000546001600160a01b031633146103915760405162461bcd60e51b815260040161025390610884565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60405162461bcd60e51b815260206004820152600b60248201526a1b9bdd08185b1b1bddd95960aa1b6044820152600090606401610253565b6000546001600160a01b0316331461043e5760405162461bcd60e51b815260040161025390610884565b6002805460ff1916911515919091179055565b6000546001600160a01b0316331461047b5760405162461bcd60e51b815260040161025390610884565b61048481610670565b50565b604080516000808252602082019092526001600160a01b0384169083906040516104b191906108c0565b60006040518083038185875af1925050503d80600081146104ee576040519150601f19603f3d011682016040523d82523d6000602084013e6104f3565b606091505b50509050806105505760405162461bcd60e51b815260206004820152602360248201527f5472616e7366657248656c7065723a204554485f5452414e534645525f46414960448201526213115160ea1b6064820152608401610253565b505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916105b191906108c0565b6000604051808303816000865af19150503d80600081146105ee576040519150601f19603f3d011682016040523d82523d6000602084013e6105f3565b606091505b509150915081801561061d57508051158061061d57508080602001905181019061061d91906108ef565b6106695760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c4544006044820152606401610253565b5050505050565b6001600160a01b0381166106c65760405162461bcd60e51b815260206004820152601860248201527f5a65726f2061646472657373206e6f7420616c6c6f77656400000000000000006044820152606401610253565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b80356001600160a01b038116811461073857600080fd5b919050565b60006020828403121561074f57600080fd5b61075882610721565b9392505050565b60006020828403121561077157600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6000806000606084860312156107a357600080fd5b6107ac84610721565b925060208401359150604084013567ffffffffffffffff808211156107d057600080fd5b818601915086601f8301126107e457600080fd5b8135818111156107f6576107f6610778565b604051601f8201601f19908116603f0116810190838211818310171561081e5761081e610778565b8160405282815289602084870101111561083757600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b801515811461048457600080fd5b60006020828403121561087957600080fd5b813561075881610859565b6020808252600990820152682737ba1027bbb732b960b91b604082015260600190565b6000602082840312156108b957600080fd5b5051919050565b6000825160005b818110156108e157602081860181015185830152016108c7565b506000920191825250919050565b60006020828403121561090157600080fd5b81516107588161085956fea264697066735822122024bef5ec1d6a9b6dca5afbf687e2a1bd8ca207ce1652412b67b9ad45f6534b5a64736f6c63430008130033
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100e95760003560e01c80638943ec021161008c5780638f32d59b116100665780638f32d59b146101d7578063bedb86fb146101f6578063f2fde38b14610209578063ff0938a71461021c57600080fd5b80638943ec02146101915780638b50e446146101bd5780638da5cb5b146101c657600080fd5b8063314de7c3116100c8578063314de7c31461015257806351d912431461015b5780635eb325eb1461016e578063715018a61461018957600080fd5b8062ae3bf8146100ee5780631a5057d5146101035780632da49d161461013b575b600080fd5b6101016100fc36600461073d565b610229565b005b61011e733986e815f87fea74910f7adeacd1ce7f172e1df081565b6040516001600160a01b0390911681526020015b60405180910390f35b61014460045481565b604051908152602001610132565b61014460015481565b61010161016936600461075f565b610338565b61011e731eaa43544daa399b87eecfcc6fa579d5ea4a618781565b610101610367565b6101a461019f36600461078e565b6103db565b6040516001600160e01b03199091168152602001610132565b61014460035481565b6000546001600160a01b031661011e565b6000546001600160a01b031633145b6040519015158152602001610132565b610101610204366004610867565b610414565b61010161021736600461073d565b610451565b6002546101e69060ff1681565b6000546001600160a01b0316331461025c5760405162461bcd60e51b815260040161025390610884565b60405180910390fd5b60006001600160a01b03821661027d5750476102783382610487565b6102f2565b6040516370a0823160e01b81523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa1580156102c1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102e591906108a7565b90506102f2823383610555565b604080516001600160a01b0384168152602081018390527f542fa6bfee3b4746210fbdd1d83f9e49b65adde3639f8d8f165dd18347938af2910160405180910390a15050565b6000546001600160a01b031633146103625760405162461bcd60e51b815260040161025390610884565b600155565b6000546001600160a01b031633146103915760405162461bcd60e51b815260040161025390610884565b600080546040516001600160a01b03909116907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600080546001600160a01b0319169055565b60405162461bcd60e51b815260206004820152600b60248201526a1b9bdd08185b1b1bddd95960aa1b6044820152600090606401610253565b6000546001600160a01b0316331461043e5760405162461bcd60e51b815260040161025390610884565b6002805460ff1916911515919091179055565b6000546001600160a01b0316331461047b5760405162461bcd60e51b815260040161025390610884565b61048481610670565b50565b604080516000808252602082019092526001600160a01b0384169083906040516104b191906108c0565b60006040518083038185875af1925050503d80600081146104ee576040519150601f19603f3d011682016040523d82523d6000602084013e6104f3565b606091505b50509050806105505760405162461bcd60e51b815260206004820152602360248201527f5472616e7366657248656c7065723a204554485f5452414e534645525f46414960448201526213115160ea1b6064820152608401610253565b505050565b604080516001600160a01b038481166024830152604480830185905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17905291516000928392908716916105b191906108c0565b6000604051808303816000865af19150503d80600081146105ee576040519150601f19603f3d011682016040523d82523d6000602084013e6105f3565b606091505b509150915081801561061d57508051158061061d57508080602001905181019061061d91906108ef565b6106695760405162461bcd60e51b815260206004820152601f60248201527f5472616e7366657248656c7065723a205452414e534645525f4641494c4544006044820152606401610253565b5050505050565b6001600160a01b0381166106c65760405162461bcd60e51b815260206004820152601860248201527f5a65726f2061646472657373206e6f7420616c6c6f77656400000000000000006044820152606401610253565b600080546040516001600160a01b03808516939216917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600080546001600160a01b0319166001600160a01b0392909216919091179055565b80356001600160a01b038116811461073857600080fd5b919050565b60006020828403121561074f57600080fd5b61075882610721565b9392505050565b60006020828403121561077157600080fd5b5035919050565b634e487b7160e01b600052604160045260246000fd5b6000806000606084860312156107a357600080fd5b6107ac84610721565b925060208401359150604084013567ffffffffffffffff808211156107d057600080fd5b818601915086601f8301126107e457600080fd5b8135818111156107f6576107f6610778565b604051601f8201601f19908116603f0116810190838211818310171561081e5761081e610778565b8160405282815289602084870101111561083757600080fd5b8260208601602083013760006020848301015280955050505050509250925092565b801515811461048457600080fd5b60006020828403121561087957600080fd5b813561075881610859565b6020808252600990820152682737ba1027bbb732b960b91b604082015260600190565b6000602082840312156108b957600080fd5b5051919050565b6000825160005b818110156108e157602081860181015185830152016108c7565b506000920191825250919050565b60006020828403121561090157600080fd5b81516107588161085956fea264697066735822122024bef5ec1d6a9b6dca5afbf687e2a1bd8ca207ce1652412b67b9ad45f6534b5a64736f6c63430008130033