Address Contract Verified
Address
0xCFC5bD99915aAa815401C5a41A927aB7a38d29cf
Balance
0 ETH
Nonce
1
Code Size
7754 bytes
Creator
0x49E3C589...4d2B at tx 0x07b0e318...6dc2c1
Indexed Transactions
0
Contract Bytecode
7754 bytes
0x608060405234801561001057600080fd5b506004361061028a5760003560e01c80638da5cb5b1161015c578063b1c6c182116100ce578063dd62ed3e11610087578063dd62ed3e146105d2578063e228406e1461060b578063e5f95ad014610613578063eecb7cc114610626578063f2fde38b14610639578063f698da251461064c57600080fd5b8063b1c6c1821461055a578063b427cd4e1461056d578063bef432c614610580578063cd33973a146105a3578063d505accf146105ac578063d5414ba2146105bf57600080fd5b8063a457c2d711610120578063a457c2d7146104ea578063a7936437146104fd578063a866eaf714610505578063a9059cbb1461050d578063af30192314610520578063afe5bf931461053357600080fd5b80638da5cb5b146104945780638f32d59b146104a557806395d89b41146104ad5780639ce922ff146104ce5780639dc29fac146104d757600080fd5b8063441633f211610200578063660edfd8116101b9578063660edfd81461040c5780636720c945146104145780636d3aa16a1461042757806370a082311461042f5780637ecebe00146104585780638961cb241461048157600080fd5b8063441633f21461038857806348581f391461039b57806354fd4d50146103a4578063560a0b8e146103c157806358f2f1cf146103e45780635fef0e581461040457600080fd5b80631d9d708b116102525780631d9d708b1461032f57806323b872dd14610338578063313ce5671461034b57806333ebbfef1461035a578063395093511461036257806340c10f191461037557600080fd5b8063011104791461028f57806306fdde0314610299578063095ea7b3146102d457806310ce43bd146102f757806318160ddd14610327575b600080fd5b610297610654565b005b60408051808201909152600d81526c151a1c995cda1bdb19081554d1609a1b60208201525b6040516102cb9190611acb565b60405180910390f35b6102e76102e2366004611b35565b610727565b60405190151581526020016102cb565b7f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c95b6040519081526020016102cb565b600154610319565b610319600e5481565b6102e7610346366004611b5f565b61073e565b604051601281526020016102cb565b6102976107f8565b6102e7610370366004611b35565b6108bf565b610297610383366004611b35565b6108f6565b610297610396366004611b9b565b610972565b610319600d5481565b6040805180820190915260018152603160f81b60208201526102be565b6102e76103cf366004611b9b565b60056020526000908152604090205460ff1681565b600a546103f7906001600160a01b031681565b6040516102cb9190611bbd565b610297610a20565b610297610abc565b6009546103f7906001600160a01b031681565b610297610b9a565b61031961043d366004611b9b565b6001600160a01b031660009081526003602052604090205490565b610319610466366004611b9b565b6001600160a01b031660009081526002602052604090205490565b61029761048f366004611b9b565b610c3b565b6000546001600160a01b03166103f7565b6102e7610cbd565b6040805180820190915260058152641d1a1554d160da1b60208201526102be565b610319600f5481565b6102976104e5366004611b35565b610cce565b6102e76104f8366004611b35565b610d46565b610297610de1565b610297610e7d565b6102e761051b366004611b35565b610f15565b6008546103f7906001600160a01b031681565b6103197f000000000000000000000000000000000000000000000000000000000076a70081565b610297610568366004611b9b565b610f2b565b6007546103f7906001600160a01b031681565b6102e761058e366004611b9b565b60066020526000908152604090205460ff1681565b61031960105481565b6102976105ba366004611bd1565b610fad565b600c546103f7906001600160a01b031681565b6103196105e0366004611c44565b6001600160a01b03918216600090815260046020908152604080832093909416825291909152205490565b6102976111b1565b600b546103f7906001600160a01b031681565b610297610634366004611c77565b611278565b610297610647366004611b9b565b6112fa565b61031961138f565b61065c610cbd565b6106815760405162461bcd60e51b815260040161067890611cba565b60405180910390fd5b601054600081116106a45760405162461bcd60e51b815260040161067890611cef565b6106ce7f000000000000000000000000000000000000000000000000000000000076a70082611d33565b4210156106ed5760405162461bcd60e51b815260040161067890611d46565b50600c80546001600160a01b03166000908152600660205260408120805460ff1916600117905560105580546001600160a01b0319169055565b6000610734338484611481565b5060015b92915050565b60006107498361150f565b6107548484846115c1565b6001600160a01b0384166000908152600460209081526040808320338452909152902054828110156107d95760405162461bcd60e51b815260206004820152602860248201527f45524332303a207472616e7366657220616d6f756e74206578636565647320616044820152676c6c6f77616e636560c01b6064820152608401610678565b6107ed85336107e88685611d7b565b611481565b506001949350505050565b610800610cbd565b61081c5760405162461bcd60e51b815260040161067890611cba565b600e546000811161083f5760405162461bcd60e51b815260040161067890611cef565b6108697f000000000000000000000000000000000000000000000000000000000076a70082611d33565b4210156108885760405162461bcd60e51b815260040161067890611d46565b50600b80546001600160a01b03166000908152600560205260408120805460ff19169055600e5580546001600160a01b0319169055565b3360008181526004602090815260408083206001600160a01b038716845290915281205490916107349185906107e8908690611d33565b3360009081526006602052604090205460ff166109645760405162461bcd60e51b815260206004820152602660248201527f5448555344546f6b656e3a2043616c6c6572206e6f7420616c6c6f77656420746044820152651bc81b5a5b9d60d21b6064820152608401610678565b61096e82826116f3565b5050565b61097a610cbd565b6109965760405162461bcd60e51b815260040161067890611cba565b6001600160a01b03811660009081526006602052604090205460ff16156109fa5760405162461bcd60e51b8152602060048201526018602482015277125b98dbdc9c9958dd081859191c995cdcc81d1bc818591960421b6044820152606401610678565b42601055600c80546001600160a01b0319166001600160a01b0392909216919091179055565b610a28610cbd565b610a445760405162461bcd60e51b815260040161067890611cba565b600e54600003610aa55760405162461bcd60e51b815260206004820152602660248201527f5265766f6b696e672066726f6d206275726e206c697374206973206e6f7420736044820152651d185c9d195960d21b6064820152608401610678565b6000600e55600b80546001600160a01b0319169055565b610ac4610cbd565b610ae05760405162461bcd60e51b815260040161067890611cba565b600f5460008111610b035760405162461bcd60e51b815260040161067890611cef565b610b2d7f000000000000000000000000000000000000000000000000000000000076a70082611d33565b421015610b4c5760405162461bcd60e51b815260040161067890611d46565b600754600854600954610b6e926001600160a01b039081169281169116611789565b506000600f55600780546001600160a01b03199081169091556008805482169055600980549091169055565b610ba2610cbd565b610bbe5760405162461bcd60e51b815260040161067890611cba565b600f54600003610c105760405162461bcd60e51b815260206004820152601f60248201527f416464696e6720636f6e747261637473206973206e6f742073746172746564006044820152606401610678565b6000600f55600780546001600160a01b03199081169091556008805482169055600980549091169055565b610c43610cbd565b610c5f5760405162461bcd60e51b815260040161067890611cba565b6001600160a01b03811660009081526006602052604090205460ff16610c975760405162461bcd60e51b815260040161067890611d8e565b42600d55600a80546001600160a01b0319166001600160a01b0392909216919091179055565b6000546001600160a01b0316331490565b3360009081526005602052604090205460ff16610d3c5760405162461bcd60e51b815260206004820152602660248201527f5448555344546f6b656e3a2043616c6c6572206e6f7420616c6c6f77656420746044820152653790313ab93760d11b6064820152608401610678565b61096e82826118db565b3360009081526004602090815260408083206001600160a01b038616845290915281205482811015610dc85760405162461bcd60e51b815260206004820152602560248201527f45524332303a2064656372656173656420616c6c6f77616e63652062656c6f77604482015264207a65726f60d81b6064820152608401610678565b610dd733856107e88685611d7b565b5060019392505050565b610de9610cbd565b610e055760405162461bcd60e51b815260040161067890611cba565b600d54600003610e665760405162461bcd60e51b815260206004820152602660248201527f5265766f6b696e672066726f6d206d696e74206c697374206973206e6f7420736044820152651d185c9d195960d21b6064820152608401610678565b6000600d55600a80546001600160a01b0319169055565b610e85610cbd565b610ea15760405162461bcd60e51b815260040161067890611cba565b601054600003610efe5760405162461bcd60e51b815260206004820152602260248201527f416464696e6720746f206d696e74206c697374206973206e6f74207374617274604482015261195960f21b6064820152608401610678565b6000601055600c80546001600160a01b0319169055565b6000610f208361150f565b6107343384846115c1565b610f33610cbd565b610f4f5760405162461bcd60e51b815260040161067890611cba565b6001600160a01b03811660009081526005602052604090205460ff16610f875760405162461bcd60e51b815260040161067890611d8e565b42600e55600b80546001600160a01b0319166001600160a01b0392909216919091179055565b42841015610ff75760405162461bcd60e51b815260206004820152601760248201527654485553443a206578706972656420646561646c696e6560481b6044820152606401610678565b600061100161138f565b6001600160a01b038916600090815260026020526040812080547f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9928c928c928c9290919061104f83611dc5565b909155506040805160208101969096526001600160a01b0394851690860152929091166060840152608083015260a082015260c0810187905260e001604051602081830303815290604052805190602001206040516020016110c892919061190160f01b81526002810192909252602282015260420190565b60408051601f198184030181528282528051602091820120600080855291840180845281905260ff88169284019290925260608301869052608083018590529092509060019060a0016020604051602081039080840390855afa158015611133573d6000803e3d6000fd5b505050602060405103519050886001600160a01b0316816001600160a01b03161461119b5760405162461bcd60e51b815260206004820152601860248201527754485553443a20696e76616c6964207369676e617475726560401b6044820152606401610678565b6111a6898989611481565b505050505050505050565b6111b9610cbd565b6111d55760405162461bcd60e51b815260040161067890611cba565b600d54600081116111f85760405162461bcd60e51b815260040161067890611cef565b6112227f000000000000000000000000000000000000000000000000000000000076a70082611d33565b4210156112415760405162461bcd60e51b815260040161067890611d46565b50600a80546001600160a01b03166000908152600660205260408120805460ff19169055600d5580546001600160a01b0319169055565b611280610cbd565b61129c5760405162461bcd60e51b815260040161067890611cba565b6112a5836119d6565b6112ae826119d6565b6112b7816119d6565b600780546001600160a01b039485166001600160a01b03199182161790915560088054938516938216939093179092556009805491909316911617905542600f55565b611302610cbd565b61131e5760405162461bcd60e51b815260040161067890611cba565b6001600160a01b0381166113835760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610678565b61138c81611a7b565b50565b60007f000000000000000000000000000000000000000000000000000000000000000146036113dd57507f92e0445b508818d319373a2cdef0f7d13fc7506ce8d3951718c029c907eb63d990565b50604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6020808301919091527f0132ab907e8d4684c184f18878af163da1d6014d0a0e446bff0fda502e3bac79828401527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b6001600160a01b03831661149757611497611dde565b6001600160a01b0382166114ad576114ad611dde565b6001600160a01b0383811660008181526004602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591015b60405180910390a3505050565b6001600160a01b0381161580159061153057506001600160a01b0381163014155b61138c5760405162461bcd60e51b815260206004820152605660248201527f54485553443a2043616e6e6f74207472616e7366657220746f6b656e7320646960448201527f726563746c7920746f2074686520544855534420746f6b656e20636f6e7472616064820152756374206f7220746865207a65726f206164647265737360501b608482015260a401610678565b6001600160a01b0383166115d7576115d7611dde565b6001600160a01b0382166115ed576115ed611dde565b6001600160a01b0383166000908152600360205260409020548111156116645760405162461bcd60e51b815260206004820152602660248201527f45524332303a207472616e7366657220616d6f756e7420657863656564732062604482015265616c616e636560d01b6064820152608401610678565b6001600160a01b0383166000908152600360205260408120805483929061168c908490611d7b565b90915550506001600160a01b038216600090815260036020526040812080548392906116b9908490611d33565b92505081905550816001600160a01b0316836001600160a01b0316600080516020611df58339815191528360405161150291815260200190565b6001600160a01b03821661170957611709611dde565b806001546117179190611d33565b6001556001600160a01b03821660009081526003602052604090205461173e908290611d33565b6001600160a01b038316600081815260036020526040808220939093559151909190600080516020611df58339815191529061177d9085815260200190565b60405180910390a35050565b611792836119d6565b61179b826119d6565b6117a4816119d6565b6001600160a01b03831660009081526005602052604090819020805460ff19166001179055517f552e6c3035c33f04f1890bc312cbff2a7785b2e14ba719e635c5a8a754705647906117f7908590611bbd565b60405180910390a16001600160a01b03821660009081526005602052604090819020805460ff19166001179055517fd5aac92b48f52fdc22e5b14b07e3cbbd61e939d86cec15efe7db4fd82a8d191190611852908490611bbd565b60405180910390a16001600160a01b03811660009081526005602052604090819020805460ff19166001179055517f5f1db3103369b41aebc8a140eb5553e5a21d3df288ff446278b59eb15d59e2a4906118ad908390611bbd565b60405180910390a16001600160a01b03166000908152600660205260409020805460ff191660011790555050565b6001600160a01b0382166118f1576118f1611dde565b6001600160a01b0382166000908152600360205260409020548111156119645760405162461bcd60e51b815260206004820152602260248201527f45524332303a206275726e20616d6f756e7420657863656564732062616c616e604482015261636560f01b6064820152608401610678565b6001600160a01b0382166000908152600360205260408120805483929061198c908490611d7b565b9250508190555080600160008282546119a59190611d7b565b90915550506040518181526000906001600160a01b03841690600080516020611df58339815191529060200161177d565b6001600160a01b038116611a2c5760405162461bcd60e51b815260206004820152601e60248201527f4163636f756e742063616e6e6f74206265207a65726f206164647265737300006044820152606401610678565b803b8061096e5760405162461bcd60e51b815260206004820181905260248201527f4163636f756e7420636f64652073697a652063616e6e6f74206265207a65726f6044820152606401610678565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060208083528351808285015260005b81811015611af857858101830151858201604001528201611adc565b506000604082860101526040601f19601f8301168501019250505092915050565b80356001600160a01b0381168114611b3057600080fd5b919050565b60008060408385031215611b4857600080fd5b611b5183611b19565b946020939093013593505050565b600080600060608486031215611b7457600080fd5b611b7d84611b19565b9250611b8b60208501611b19565b9150604084013590509250925092565b600060208284031215611bad57600080fd5b611bb682611b19565b9392505050565b6001600160a01b0391909116815260200190565b600080600080600080600060e0888a031215611bec57600080fd5b611bf588611b19565b9650611c0360208901611b19565b95506040880135945060608801359350608088013560ff81168114611c2757600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215611c5757600080fd5b611c6083611b19565b9150611c6e60208401611b19565b90509250929050565b600080600060608486031215611c8c57600080fd5b611c9584611b19565b9250611ca360208501611b19565b9150611cb160408501611b19565b90509250925092565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526014908201527310da185b99d9481b9bdd081a5b9a5d1a585d195960621b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b8082018082111561073857610738611d1d565b6020808252818101527f476f7665726e616e63652064656c617920686173206e6f7420656c6170736564604082015260600190565b8181038181111561073857610738611d1d565b6020808252601b908201527f496e636f7272656374206164647265737320746f207265766f6b650000000000604082015260600190565b600060018201611dd757611dd7611d1d565b5060010190565b634e487b7160e01b600052600160045260246000fdfeddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa264697066735822122071bb42158c5e941c67c989fec28ce135fdf3d72f3d1d0625b4f90ad4041d326a64736f6c63430008110033
Verified Source Code Full Match
Compiler: v0.8.17+commit.8df45f5f
EVM: london
Optimization: Yes (100 runs)
THUSDToken.sol 419 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "./Interfaces/ITHUSDToken.sol";
import "./Dependencies/CheckContract.sol";
import "./Dependencies/Ownable.sol";
/*
*
* Based upon OpenZeppelin's ERC20 contract:
* https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol
*
* and their EIP2612 (ERC20Permit / ERC712) functionality:
* https://github.com/OpenZeppelin/openzeppelin-contracts/blob/53516bc555a454862470e7860a9b5254db4d00f5/contracts/token/ERC20/ERC20Permit.sol
*
*
* --- Functionality added specific to the THUSDToken ---
*
* 1) Transfer protection: blacklist of addresses that are invalid recipients (i.e. core Liquity contracts) in external
* transfer() and transferFrom() calls. The purpose is to protect users from losing tokens by mistakenly sending THUSD directly to a Liquity
* core contract, when they should rather call the right function.
*
*/
contract THUSDToken is Ownable, CheckContract, ITHUSDToken {
uint256 private _totalSupply;
string constant internal _NAME = "Threshold USD";
string constant internal _SYMBOL = "thUSD";
string constant internal _VERSION = "1";
uint8 constant internal _DECIMALS = 18;
// --- Data for EIP2612 ---
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 private constant _PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
// keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
bytes32 private constant _TYPE_HASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f;
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
uint256 private immutable _CACHED_CHAIN_ID;
bytes32 private immutable _HASHED_NAME;
bytes32 private immutable _HASHED_VERSION;
mapping (address => uint256) private _nonces;
// User data for THUSD token
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
// --- Addresses ---
mapping(address => bool) public burnList;
mapping(address => bool) public mintList;
uint256 public immutable governanceTimeDelay;
address public pendingTroveManager;
address public pendingStabilityPool;
address public pendingBorrowerOperations;
address public pendingRevokedMintAddress;
address public pendingRevokedBurnAddress;
address public pendingAddedMintAddress;
uint256 public revokeMintListInitiated;
uint256 public revokeBurnListInitiated;
uint256 public addContractsInitiated;
uint256 public addMintListInitiated;
constructor
(
address _troveManagerAddress1,
address _stabilityPoolAddress1,
address _borrowerOperationsAddress1,
address _troveManagerAddress2,
address _stabilityPoolAddress2,
address _borrowerOperationsAddress2,
uint256 _governanceTimeDelay
)
{
// when created its linked to one set of contracts and collateral, other collateral types can be added via governance
_addSystemContracts(_troveManagerAddress1, _stabilityPoolAddress1, _borrowerOperationsAddress1);
if (_troveManagerAddress2 != address(0)) {
_addSystemContracts(_troveManagerAddress2, _stabilityPoolAddress2, _borrowerOperationsAddress2);
}
bytes32 hashedName = keccak256(bytes(_NAME));
bytes32 hashedVersion = keccak256(bytes(_VERSION));
_HASHED_NAME = hashedName;
_HASHED_VERSION = hashedVersion;
_CACHED_CHAIN_ID = block.chainid;
_CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(_TYPE_HASH, hashedName, hashedVersion);
governanceTimeDelay = _governanceTimeDelay;
require(governanceTimeDelay <= 30 weeks, "Governance delay is too big");
}
modifier onlyAfterGovernanceDelay(
uint256 _changeInitializedTimestamp
) {
require(_changeInitializedTimestamp > 0, "Change not initiated");
require(
block.timestamp >= _changeInitializedTimestamp + governanceTimeDelay,
"Governance delay has not elapsed"
);
_;
}
// --- Governance ---
function startRevokeMintList(address _account)
external
onlyOwner
{
require(mintList[_account], "Incorrect address to revoke");
revokeMintListInitiated = block.timestamp;
pendingRevokedMintAddress = _account;
}
function cancelRevokeMintList() external onlyOwner {
require(revokeMintListInitiated != 0, "Revoking from mint list is not started");
revokeMintListInitiated = 0;
pendingRevokedMintAddress = address(0);
}
function finalizeRevokeMintList()
external
onlyOwner
onlyAfterGovernanceDelay(revokeMintListInitiated)
{
mintList[pendingRevokedMintAddress] = false;
revokeMintListInitiated = 0;
pendingRevokedMintAddress = address(0);
}
function startAddMintList(address _account) external onlyOwner {
require(!mintList[_account], "Incorrect address to add");
addMintListInitiated = block.timestamp;
pendingAddedMintAddress = _account;
}
function cancelAddMintList() external onlyOwner {
require(addMintListInitiated != 0, "Adding to mint list is not started");
addMintListInitiated = 0;
pendingAddedMintAddress = address(0);
}
function finalizeAddMintList()
external
onlyOwner
onlyAfterGovernanceDelay(addMintListInitiated)
{
mintList[pendingAddedMintAddress] = true;
addMintListInitiated = 0;
pendingAddedMintAddress = address(0);
}
function startAddContracts(address _troveManagerAddress, address _stabilityPoolAddress, address _borrowerOperationsAddress)
external
onlyOwner
{
checkContract(_troveManagerAddress);
checkContract(_stabilityPoolAddress);
checkContract(_borrowerOperationsAddress);
// save as provisional contracts to add
pendingTroveManager = _troveManagerAddress;
pendingStabilityPool = _stabilityPoolAddress;
pendingBorrowerOperations = _borrowerOperationsAddress;
// save block number
addContractsInitiated = block.timestamp;
}
function cancelAddContracts() external onlyOwner {
require(addContractsInitiated != 0, "Adding contracts is not started");
addContractsInitiated = 0;
pendingTroveManager = address(0);
pendingStabilityPool = address(0);
pendingBorrowerOperations = address(0);
}
function finalizeAddContracts()
external
onlyOwner
onlyAfterGovernanceDelay(addContractsInitiated)
{
// make sure minimum blocks has passed
_addSystemContracts(pendingTroveManager, pendingStabilityPool, pendingBorrowerOperations);
addContractsInitiated = 0;
pendingTroveManager = address(0);
pendingStabilityPool = address(0);
pendingBorrowerOperations = address(0);
}
function startRevokeBurnList(address _account)
external
onlyOwner
{
require(burnList[_account], "Incorrect address to revoke");
revokeBurnListInitiated = block.timestamp;
pendingRevokedBurnAddress = _account;
}
function cancelRevokeBurnList() external onlyOwner {
require(revokeBurnListInitiated != 0, "Revoking from burn list is not started");
revokeBurnListInitiated = 0;
pendingRevokedBurnAddress = address(0);
}
function finalizeRevokeBurnList()
external
onlyOwner
onlyAfterGovernanceDelay(revokeBurnListInitiated)
{
burnList[pendingRevokedBurnAddress] = false;
revokeBurnListInitiated = 0;
pendingRevokedBurnAddress = address(0);
}
// --- Functions for intra-Liquity calls ---
function mint(address _account, uint256 _amount) external override {
require(mintList[msg.sender], "THUSDToken: Caller not allowed to mint");
_mint(_account, _amount);
}
function burn(address _account, uint256 _amount) external override {
require(burnList[msg.sender], "THUSDToken: Caller not allowed to burn");
_burn(_account, _amount);
}
// --- External functions ---
function totalSupply() external view override returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) external view override returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) external override returns (bool) {
_requireValidRecipient(recipient);
_transfer(msg.sender, recipient, amount);
return true;
}
function allowance(address owner, address spender) external view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) external override returns (bool) {
_approve(msg.sender, spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) external override returns (bool) {
_requireValidRecipient(recipient);
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][msg.sender];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
_approve(sender, msg.sender, currentAllowance - amount);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) external override returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender] + addedValue);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) external override returns (bool) {
uint256 currentAllowance = _allowances[msg.sender][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
_approve(msg.sender, spender, currentAllowance - subtractedValue);
return true;
}
// --- EIP 2612 Functionality ---
function domainSeparator() public view override returns (bytes32) {
if (block.chainid == _CACHED_CHAIN_ID) {
return _CACHED_DOMAIN_SEPARATOR;
} else {
return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
}
}
function permit
(
address owner,
address spender,
uint256 amount,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
)
external
override
{
require(deadline >= block.timestamp, 'THUSD: expired deadline');
bytes32 digest = keccak256(abi.encodePacked('\x19\x01',
domainSeparator(), keccak256(abi.encode(
_PERMIT_TYPEHASH, owner, spender, amount,
_nonces[owner]++, deadline))));
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress == owner, 'THUSD: invalid signature');
_approve(owner, spender, amount);
}
function nonces(address owner) external view override returns (uint256) { // FOR EIP 2612
return _nonces[owner];
}
// --- Internal operations ---
function _buildDomainSeparator(bytes32 typeHash, bytes32 hashedName, bytes32 hashedVersion) private view returns (bytes32) {
return keccak256(abi.encode(typeHash, hashedName, hashedVersion, block.chainid, address(this)));
}
// --- Internal operations ---
function _addSystemContracts(address _troveManagerAddress, address _stabilityPoolAddress, address _borrowerOperationsAddress) internal {
checkContract(_troveManagerAddress);
checkContract(_stabilityPoolAddress);
checkContract(_borrowerOperationsAddress);
burnList[_troveManagerAddress] = true;
emit TroveManagerAddressAdded(_troveManagerAddress);
burnList[_stabilityPoolAddress] = true;
emit StabilityPoolAddressAdded(_stabilityPoolAddress);
burnList[_borrowerOperationsAddress] = true;
emit BorrowerOperationsAddressAdded(_borrowerOperationsAddress);
mintList[_borrowerOperationsAddress] = true;
}
// Warning: sanity checks (for sender and recipient) should have been done before calling these internal functions
function _transfer(address sender, address recipient, uint256 amount) internal {
assert(sender != address(0));
assert(recipient != address(0));
require(_balances[sender] >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] -= amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
function _mint(address account, uint256 amount) internal {
assert(account != address(0));
_totalSupply = _totalSupply + amount;
_balances[account] = _balances[account] + amount;
emit Transfer(address(0), account, amount);
}
function _burn(address account, uint256 amount) internal {
assert(account != address(0));
require(_balances[account] >= amount, "ERC20: burn amount exceeds balance");
_balances[account] -= amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
function _approve(address owner, address spender, uint256 amount) internal {
assert(owner != address(0));
assert(spender != address(0));
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
// --- 'require' functions ---
function _requireValidRecipient(address _recipient) internal view {
require(
_recipient != address(0) &&
_recipient != address(this),
"THUSD: Cannot transfer tokens directly to the THUSD token contract or the zero address"
);
}
// --- Optional functions ---
function name() external pure override returns (string memory) {
return _NAME;
}
function symbol() external pure override returns (string memory) {
return _SYMBOL;
}
function decimals() external pure override returns (uint8) {
return _DECIMALS;
}
function version() external pure override returns (string memory) {
return _VERSION;
}
function permitTypeHash() external pure override returns (bytes32) {
return _PERMIT_TYPEHASH;
}
}
Ownable.sol 85 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
/**
* Based on OpenZeppelin's Ownable contract:
* https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/Ownable.sol
*
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
contract Ownable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
_owner = msg.sender;
emit OwnershipTransferred(address(0), msg.sender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(isOwner(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Returns true if the caller is the current owner.
*/
function isOwner() public view returns (bool) {
return msg.sender == _owner;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*
* NOTE: This function is not safe, as it doesn’t check owner is calling it.
* Make sure you check it before calling it.
*/
function _renounceOwnership() internal {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IERC2612.sol 58 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
/**
* @dev Interface of the ERC2612 standard as defined in the EIP.
*
* Adds the {permit} method, which can be used to change one's
* {IERC20-allowance} without having to send a transaction, by signing a
* message. This allows users to spend tokens without having to hold Ether.
*
* See https://eips.ethereum.org/EIPS/eip-2612.
*
* Code adapted from https://github.com/OpenZeppelin/openzeppelin-contracts/pull/2237/
*/
interface IERC2612 {
/**
* @dev Sets `amount` as the allowance of `spender` over `owner`'s tokens,
* given `owner`'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(address owner, address spender, uint256 amount,
uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;
/**
* @dev Returns the current ERC2612 nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases `owner`'s nonce by one. This
* prevents a signature from being used multiple times.
*
* `owner` can limit the time a Permit is valid for by setting `deadline` to
* a value in the near future. The deadline argument can be set to uint(-1) to
* create Permits that effectively never expire.
*/
function nonces(address owner) external view returns (uint256);
function version() external view returns (string memory);
function permitTypeHash() external view returns (bytes32);
function domainSeparator() external view returns (bytes32);
}
ITHUSDToken.sol 29 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import "../Dependencies/IERC2612.sol";
interface ITHUSDToken is IERC20Metadata, IERC2612 {
// --- Events ---
event TroveManagerAddressAdded(address _troveManagerAddress);
event StabilityPoolAddressAdded(address _newStabilityPoolAddress);
event BorrowerOperationsAddressAdded(address _newBorrowerOperationsAddress);
event THUSDTokenBalanceUpdated(address _user, uint256 _amount);
// --- Functions ---
function mintList(address contractAddress) external view returns (bool);
function burnList(address contractAddress) external view returns (bool);
function mint(address _account, uint256 _amount) external;
function burn(address _account, uint256 _amount) external;
function increaseAllowance(address spender, uint256 addedValue) external returns (bool);
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);
}
CheckContract.sol 19 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;
contract CheckContract {
/**
* Check that the account is an already deployed non-destroyed contract.
* See: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol#L12
*/
function checkContract(address _account) internal view {
require(_account != address(0), "Account cannot be zero address");
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(_account) }
require(size > 0, "Account code size cannot be zero");
}
}
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
IERC20Metadata.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
Read Contract
addContractsInitiated 0x9ce922ff → uint256
addMintListInitiated 0xcd33973a → uint256
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
burnList 0x560a0b8e → bool
decimals 0x313ce567 → uint8
domainSeparator 0xf698da25 → bytes32
governanceTimeDelay 0xafe5bf93 → uint256
isOwner 0x8f32d59b → bool
mintList 0xbef432c6 → bool
name 0x06fdde03 → string
nonces 0x7ecebe00 → uint256
owner 0x8da5cb5b → address
pendingAddedMintAddress 0xd5414ba2 → address
pendingBorrowerOperations 0x6720c945 → address
pendingRevokedBurnAddress 0xe5f95ad0 → address
pendingRevokedMintAddress 0x58f2f1cf → address
pendingStabilityPool 0xaf301923 → address
pendingTroveManager 0xb427cd4e → address
permitTypeHash 0x10ce43bd → bytes32
revokeBurnListInitiated 0x1d9d708b → uint256
revokeMintListInitiated 0x48581f39 → uint256
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
version 0x54fd4d50 → string
Write Contract 21 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address spender
uint256 amount
returns: bool
burn 0x9dc29fac
address _account
uint256 _amount
cancelAddContracts 0x6d3aa16a
No parameters
cancelAddMintList 0xa866eaf7
No parameters
cancelRevokeBurnList 0x5fef0e58
No parameters
cancelRevokeMintList 0xa7936437
No parameters
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
finalizeAddContracts 0x660edfd8
No parameters
finalizeAddMintList 0x01110479
No parameters
finalizeRevokeBurnList 0x33ebbfef
No parameters
finalizeRevokeMintList 0xe228406e
No parameters
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
mint 0x40c10f19
address _account
uint256 _amount
permit 0xd505accf
address owner
address spender
uint256 amount
uint256 deadline
uint8 v
bytes32 r
bytes32 s
startAddContracts 0xeecb7cc1
address _troveManagerAddress
address _stabilityPoolAddress
address _borrowerOperationsAddress
startAddMintList 0x441633f2
address _account
startRevokeBurnList 0xb1c6c182
address _account
startRevokeMintList 0x8961cb24
address _account
transfer 0xa9059cbb
address recipient
uint256 amount
returns: bool
transferFrom 0x23b872dd
address sender
address recipient
uint256 amount
returns: bool
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address