Address Contract Verified
Address
0x7b35Ce522CB72e4077BaeB96Cb923A5529764a00
Balance
0 ETH
Nonce
1
Code Size
7945 bytes
Creator
0x9fC5341d...Ad35 at tx 0xb21e640e...3dd51f
Indexed Transactions
0
Contract Bytecode
7945 bytes
0x608060405234801561001057600080fd5b50600436106101515760003560e01c806370a08231116100cd578063b4b5ea5711610081578063dd62ed3e11610066578063dd62ed3e146102b5578063e7a324dc146102c8578063f1127ed8146102d057610151565b8063b4b5ea571461028f578063c3cda520146102a257610151565b80637ecebe00116100b25780637ecebe001461026157806395d89b4114610274578063a9059cbb1461027c57610151565b806370a082311461022e578063782d6fe11461024157610151565b806323b872dd11610124578063587cde1e11610109578063587cde1e146101d95780635c19a95c146101f95780636fcfff451461020e57610151565b806323b872dd146101b1578063313ce567146101c457610151565b806306fdde0314610156578063095ea7b31461017457806318160ddd1461019457806320606b70146101a9575b600080fd5b61015e6102f1565b60405161016b9190611a2e565b60405180910390f35b6101876101823660046117b7565b61032a565b60405161016b919061199a565b61019c61044d565b60405161016b91906119a5565b61019c61045c565b6101876101bf366004611777565b610473565b6101cc610611565b60405161016b9190611d02565b6101ec6101e7366004611728565b610616565b60405161016b9190611979565b61020c610207366004611728565b61063e565b005b61022161021c366004611728565b61064b565b60405161016b9190611ccd565b61019c61023c366004611728565b610663565b61025461024f3660046117b7565b610699565b60405161016b9190611d10565b61019c61026f366004611728565b610984565b61015e610996565b61018761028a3660046117b7565b6109cf565b61025461029d366004611728565b610a0b565b61020c6102b03660046117e1565b610aba565b61019c6102c3366004611743565b610d3f565b61019c610d83565b6102e36102de366004611840565b610d8f565b60405161016b929190611cde565b6040518060400160405280600881526020017f496d7065726d617800000000000000000000000000000000000000000000000081525081565b6000807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83141561037c57507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6103a1565b61039e83604051806060016040528060248152602001611dd660249139610dca565b90505b3360008181526020818152604080832073ffffffffffffffffffffffffffffffffffffffff891680855292529182902080547fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166bffffffffffffffffffffffff861617905590519091907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92590610439908590611d10565b60405180910390a360019150505b92915050565b6a52b7d2dcc80cd2e400000081565b604051610468906118b5565b604051809103902081565b73ffffffffffffffffffffffffffffffffffffffff83166000908152602081815260408083203380855290835281842054825160608101909352602480845291936bffffffffffffffffffffffff9091169285926104db9288929190611dd690830139610dca565b90508673ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561052757506bffffffffffffffffffffffff82811614155b156105f957600061055183836040518060600160405280603c8152602001611d9a603c9139610e1c565b73ffffffffffffffffffffffffffffffffffffffff898116600081815260208181526040808320948a16808452949091529081902080547fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166bffffffffffffffffffffffff86161790555192935090917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925906105ef908590611d10565b60405180910390a3505b610604878783610e7f565b5060019695505050505050565b601281565b60026020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b61064833826110eb565b50565b60046020526000908152604090205463ffffffff1681565b73ffffffffffffffffffffffffffffffffffffffff166000908152600160205260409020546bffffffffffffffffffffffff1690565b60004382106106dd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d490611a9f565b60405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff831660009081526004602052604090205463ffffffff1680610718576000915050610447565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260036020908152604080832063ffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8601811685529252909120541683106107f05773ffffffffffffffffffffffffffffffffffffffff841660009081526003602090815260408083207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9490940163ffffffff168352929052205464010000000090046bffffffffffffffffffffffff169050610447565b73ffffffffffffffffffffffffffffffffffffffff8416600090815260036020908152604080832083805290915290205463ffffffff16831015610838576000915050610447565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82015b8163ffffffff168163ffffffff16111561092c57600282820363ffffffff160481036108886116ed565b5073ffffffffffffffffffffffffffffffffffffffff8716600090815260036020908152604080832063ffffffff8581168552908352928190208151808301909252549283168082526401000000009093046bffffffffffffffffffffffff169181019190915290871415610907576020015194506104479350505050565b805163ffffffff1687111561091e57819350610925565b6001820392505b505061085e565b5073ffffffffffffffffffffffffffffffffffffffff8516600090815260036020908152604080832063ffffffff909416835292905220546bffffffffffffffffffffffff6401000000009091041691505092915050565b60056020526000908152604090205481565b6040518060400160405280600381526020017f494d58000000000000000000000000000000000000000000000000000000000081525081565b6000806109f483604051806060016040528060258152602001611eaf60259139610dca565b9050610a01338583610e7f565b5060019392505050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526004602052604081205463ffffffff1680610a43576000610ab3565b73ffffffffffffffffffffffffffffffffffffffff831660009081526003602090815260408083207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff850163ffffffff16845290915290205464010000000090046bffffffffffffffffffffffff165b9392505050565b6000604051610ac8906118b5565b60408051918290038220828201909152600882527f496d7065726d61780000000000000000000000000000000000000000000000006020909201919091527fd53cf706f42de6bfee93f7ee2995e952e6ca19494f5a5260fbff94baff4f92ca610b2f61119f565b30604051602001610b4394939291906119df565b6040516020818303038152906040528051906020012090506000604051610b699061192a565b604051908190038120610b84918a908a908a906020016119ae565b60405160208183030381529060405280519060200120905060008282604051602001610bb192919061187f565b604051602081830303815290604052805190602001209050600060018288888860405160008152602001604052604051610bee9493929190611a10565b6020604051602081039080840390855afa158015610c10573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff8116610c88576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d490611b59565b73ffffffffffffffffffffffffffffffffffffffff811660009081526005602052604090208054600181019091558914610cee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d490611c70565b87421115610d28576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d490611afc565b610d32818b6110eb565b505050505b505050505050565b73ffffffffffffffffffffffffffffffffffffffff9182166000908152602081815260408083209390941682529190915220546bffffffffffffffffffffffff1690565b6040516104689061192a565b600360209081526000928352604080842090915290825290205463ffffffff81169064010000000090046bffffffffffffffffffffffff1682565b6000816c010000000000000000000000008410610e14576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d49190611a2e565b509192915050565b6000836bffffffffffffffffffffffff16836bffffffffffffffffffffffff1611158290610e77576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d49190611a2e565b505050900390565b73ffffffffffffffffffffffffffffffffffffffff8316610ecc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d490611bb6565b73ffffffffffffffffffffffffffffffffffffffff8216610f19576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d490611c13565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260016020908152604091829020548251606081019093526035808452610f76936bffffffffffffffffffffffff9092169285929190611e5490830139610e1c565b73ffffffffffffffffffffffffffffffffffffffff848116600090815260016020908152604080832080547fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166bffffffffffffffffffffffff96871617905592861682529082902054825160608101909352602f8084526110089491909116928592909190611d6b908301396111a3565b73ffffffffffffffffffffffffffffffffffffffff8381166000818152600160205260409081902080547fffffffffffffffffffffffffffffffffffffffff000000000000000000000000166bffffffffffffffffffffffff95909516949094179093559151908516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9061109f908590611d10565b60405180910390a373ffffffffffffffffffffffffffffffffffffffff8084166000908152600260205260408082205485841683529120546110e6929182169116836111fe565b505050565b73ffffffffffffffffffffffffffffffffffffffff808316600081815260026020818152604080842080546001845282862054949093528787167fffffffffffffffffffffffff000000000000000000000000000000000000000084168117909155905191909516946bffffffffffffffffffffffff9092169391928592917f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9190a46111998284836111fe565b50505050565b4690565b6000838301826bffffffffffffffffffffffff80871690831610156111f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d49190611a2e565b50949350505050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415801561124857506000816bffffffffffffffffffffffff16115b156110e65773ffffffffffffffffffffffffffffffffffffffff83161561134b5773ffffffffffffffffffffffffffffffffffffffff831660009081526004602052604081205463ffffffff1690816112a2576000611312565b73ffffffffffffffffffffffffffffffffffffffff851660009081526003602090815260408083207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff860163ffffffff16845290915290205464010000000090046bffffffffffffffffffffffff165b905060006113398285604051806060016040528060278152602001611dfa60279139610e1c565b905061134786848484611441565b5050505b73ffffffffffffffffffffffffffffffffffffffff8216156110e65773ffffffffffffffffffffffffffffffffffffffff821660009081526004602052604081205463ffffffff1690816113a0576000611410565b73ffffffffffffffffffffffffffffffffffffffff841660009081526003602090815260408083207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff860163ffffffff16845290915290205464010000000090046bffffffffffffffffffffffff165b905060006114378285604051806060016040528060268152602001611e89602691396111a3565b9050610d37858484845b600061146543604051806060016040528060338152602001611e21603391396116ab565b905060008463ffffffff161180156114d9575073ffffffffffffffffffffffffffffffffffffffff8516600090815260036020908152604080832063ffffffff7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8901811685529252909120548282169116145b156115785773ffffffffffffffffffffffffffffffffffffffff851660009081526003602090815260408083207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff880163ffffffff168452909152902080547fffffffffffffffffffffffffffffffff000000000000000000000000ffffffff166401000000006bffffffffffffffffffffffff851602179055611654565b60408051808201825263ffffffff80841682526bffffffffffffffffffffffff808616602080850191825273ffffffffffffffffffffffffffffffffffffffff8b166000818152600383528781208c871682528352878120965187549451909516640100000000027fffffffffffffffffffffffffffffffff000000000000000000000000ffffffff9587167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000958616179590951694909417909555938252600490935292909220805460018801909316929091169190911790555b8473ffffffffffffffffffffffffffffffffffffffff167fdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724848460405161169c929190611d29565b60405180910390a25050505050565b6000816401000000008410610e14576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106d49190611a2e565b604080518082019091526000808252602082015290565b803573ffffffffffffffffffffffffffffffffffffffff8116811461044757600080fd5b600060208284031215611739578081fd5b610ab38383611704565b60008060408385031215611755578081fd5b61175f8484611704565b915061176e8460208501611704565b90509250929050565b60008060006060848603121561178b578081fd5b833561179681611d48565b925060208401356117a681611d48565b929592945050506040919091013590565b600080604083850312156117c9578182fd5b6117d38484611704565b946020939093013593505050565b60008060008060008060c087890312156117f9578182fd5b6118038888611704565b95506020870135945060408701359350606087013560ff81168114611826578283fd5b9598949750929560808101359460a0909101359350915050565b60008060408385031215611852578182fd5b61185c8484611704565b9150602083013563ffffffff81168114611874578182fd5b809150509250929050565b7f190100000000000000000000000000000000000000000000000000000000000081526002810192909252602282015260420190565b7f454950373132446f6d61696e28737472696e67206e616d652c75696e7432353681527f20636861696e49642c6164647265737320766572696679696e67436f6e74726160208201527f6374290000000000000000000000000000000000000000000000000000000000604082015260430190565b7f44656c65676174696f6e28616464726573732064656c6567617465652c75696e81527f74323536206e6f6e63652c75696e7432353620657870697279290000000000006020820152603a0190565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b901515815260200190565b90815260200190565b93845273ffffffffffffffffffffffffffffffffffffffff9290921660208401526040830152606082015260800190565b9384526020840192909252604083015273ffffffffffffffffffffffffffffffffffffffff16606082015260800190565b93845260ff9290921660208401526040830152606082015260800190565b6000602080835283518082850152825b81811015611a5a57858101830151858201604001528201611a3e565b81811115611a6b5783604083870101525b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016929092016040019392505050565b60208082526026908201527f496d783a3a6765745072696f72566f7465733a206e6f7420796574206465746560408201527f726d696e65640000000000000000000000000000000000000000000000000000606082015260800190565b60208082526025908201527f496d783a3a64656c656761746542795369673a207369676e617475726520657860408201527f7069726564000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526025908201527f496d783a3a64656c656761746542795369673a20696e76616c6964207369676e60408201527f6174757265000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252603b908201527f496d783a3a5f7472616e73666572546f6b656e733a2063616e6e6f742074726160408201527f6e736665722066726f6d20746865207a65726f20616464726573730000000000606082015260800190565b60208082526039908201527f496d783a3a5f7472616e73666572546f6b656e733a2063616e6e6f742074726160408201527f6e7366657220746f20746865207a65726f206164647265737300000000000000606082015260800190565b60208082526021908201527f496d783a3a64656c656761746542795369673a20696e76616c6964206e6f6e6360408201527f6500000000000000000000000000000000000000000000000000000000000000606082015260800190565b63ffffffff91909116815260200190565b63ffffffff9290921682526bffffffffffffffffffffffff16602082015260400190565b60ff91909116815260200190565b6bffffffffffffffffffffffff91909116815260200190565b6bffffffffffffffffffffffff92831681529116602082015260400190565b73ffffffffffffffffffffffffffffffffffffffff8116811461064857600080fdfe496d783a3a5f7472616e73666572546f6b656e733a207472616e7366657220616d6f756e74206f766572666c6f7773496d783a3a7472616e7366657246726f6d3a207472616e7366657220616d6f756e742065786365656473207370656e64657220616c6c6f77616e6365496d783a3a617070726f76653a20616d6f756e7420657863656564732039362062697473496d783a3a5f6d6f7665566f7465733a20766f746520616d6f756e7420756e646572666c6f7773496d783a3a5f7772697465436865636b706f696e743a20626c6f636b206e756d62657220657863656564732033322062697473496d783a3a5f7472616e73666572546f6b656e733a207472616e7366657220616d6f756e7420657863656564732062616c616e6365496d783a3a5f6d6f7665566f7465733a20766f746520616d6f756e74206f766572666c6f7773496d783a3a7472616e736665723a20616d6f756e7420657863656564732039362062697473a264697066735822122074213769c7038bc3be8fe9c297e3a86e71e9067222591c3786d14374fb7a2a1364736f6c63430006060033
Verified Source Code Full Match
Compiler: v0.6.6+commit.6c089d02
EVM: istanbul
Optimization: Yes (999999 runs)
Imx.sol 309 lines
// COPIED FROM https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
// Copyright 2020 Compound Labs, Inc.
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
pragma solidity =0.6.6;
pragma experimental ABIEncoderV2;
contract Imx {
/// @notice EIP-20 token name for this token
string public constant name = "Impermax";
/// @notice EIP-20 token symbol for this token
string public constant symbol = "IMX";
/// @notice EIP-20 token decimals for this token
uint8 public constant decimals = 18;
/// @notice Total number of tokens in circulation
uint public constant totalSupply = 100_000_000e18; // 100 million Imx
/// @notice Allowance amounts on behalf of others
mapping (address => mapping (address => uint96)) internal allowances;
/// @notice Official record of token balances for each account
mapping (address => uint96) internal balances;
/// @notice A record of each accounts delegate
mapping (address => address) public delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint96 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/// @notice The standard EIP-20 transfer event
event Transfer(address indexed from, address indexed to, uint256 amount);
/// @notice The standard EIP-20 approval event
event Approval(address indexed owner, address indexed spender, uint256 amount);
/**
* @notice Construct a new Imx token
* @param account The initial account to grant all the tokens
*/
constructor(address account) public {
balances[account] = uint96(totalSupply);
emit Transfer(address(0), account, totalSupply);
}
/**
* @notice Get the number of tokens `spender` is approved to spend on behalf of `account`
* @param account The address of the account holding the funds
* @param spender The address of the account spending the funds
* @return The number of tokens approved
*/
function allowance(address account, address spender) external view returns (uint) {
return allowances[account][spender];
}
/**
* @notice Approve `spender` to transfer up to `amount` from `src`
* @dev This will overwrite the approval amount for `spender`
* and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)
* @param spender The address of the account which may transfer tokens
* @param rawAmount The number of tokens that are approved (2^256-1 means infinite)
* @return Whether or not the approval succeeded
*/
function approve(address spender, uint rawAmount) external returns (bool) {
uint96 amount;
if (rawAmount == uint(-1)) {
amount = uint96(-1);
} else {
amount = safe96(rawAmount, "Imx::approve: amount exceeds 96 bits");
}
allowances[msg.sender][spender] = amount;
emit Approval(msg.sender, spender, amount);
return true;
}
/**
* @notice Get the number of tokens held by the `account`
* @param account The address of the account to get the balance of
* @return The number of tokens held
*/
function balanceOf(address account) external view returns (uint) {
return balances[account];
}
/**
* @notice Transfer `amount` tokens from `msg.sender` to `dst`
* @param dst The address of the destination account
* @param rawAmount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transfer(address dst, uint rawAmount) external returns (bool) {
uint96 amount = safe96(rawAmount, "Imx::transfer: amount exceeds 96 bits");
_transferTokens(msg.sender, dst, amount);
return true;
}
/**
* @notice Transfer `amount` tokens from `src` to `dst`
* @param src The address of the source account
* @param dst The address of the destination account
* @param rawAmount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transferFrom(address src, address dst, uint rawAmount) external returns (bool) {
address spender = msg.sender;
uint96 spenderAllowance = allowances[src][spender];
uint96 amount = safe96(rawAmount, "Imx::approve: amount exceeds 96 bits");
if (spender != src && spenderAllowance != uint96(-1)) {
uint96 newAllowance = sub96(spenderAllowance, amount, "Imx::transferFrom: transfer amount exceeds spender allowance");
allowances[src][spender] = newAllowance;
emit Approval(src, spender, newAllowance);
}
_transferTokens(src, dst, amount);
return true;
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) public {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) public {
bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this)));
bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, delegatee, nonce, expiry));
bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "Imx::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "Imx::delegateBySig: invalid nonce");
require(now <= expiry, "Imx::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account) external view returns (uint96) {
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber) public view returns (uint96) {
require(blockNumber < block.number, "Imx::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
// First check most recent balance
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
// Next check implicit zero balance
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2; // ceil, avoiding overflow
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee) internal {
address currentDelegate = delegates[delegator];
uint96 delegatorBalance = balances[delegator];
delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _transferTokens(address src, address dst, uint96 amount) internal {
require(src != address(0), "Imx::_transferTokens: cannot transfer from the zero address");
require(dst != address(0), "Imx::_transferTokens: cannot transfer to the zero address");
balances[src] = sub96(balances[src], amount, "Imx::_transferTokens: transfer amount exceeds balance");
balances[dst] = add96(balances[dst], amount, "Imx::_transferTokens: transfer amount overflows");
emit Transfer(src, dst, amount);
_moveDelegates(delegates[src], delegates[dst], amount);
}
function _moveDelegates(address srcRep, address dstRep, uint96 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
uint32 srcRepNum = numCheckpoints[srcRep];
uint96 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint96 srcRepNew = sub96(srcRepOld, amount, "Imx::_moveVotes: vote amount underflows");
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
uint32 dstRepNum = numCheckpoints[dstRep];
uint96 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint96 dstRepNew = add96(dstRepOld, amount, "Imx::_moveVotes: vote amount overflows");
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(address delegatee, uint32 nCheckpoints, uint96 oldVotes, uint96 newVotes) internal {
uint32 blockNumber = safe32(block.number, "Imx::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function safe96(uint n, string memory errorMessage) internal pure returns (uint96) {
require(n < 2**96, errorMessage);
return uint96(n);
}
function add96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {
uint96 c = a + b;
require(c >= a, errorMessage);
return c;
}
function sub96(uint96 a, uint96 b, string memory errorMessage) internal pure returns (uint96) {
require(b <= a, errorMessage);
return a - b;
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
}
Read Contract
DELEGATION_TYPEHASH 0xe7a324dc → bytes32
DOMAIN_TYPEHASH 0x20606b70 → bytes32
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
checkpoints 0xf1127ed8 → uint32, uint96
decimals 0x313ce567 → uint8
delegates 0x587cde1e → address
getCurrentVotes 0xb4b5ea57 → uint96
getPriorVotes 0x782d6fe1 → uint96
name 0x06fdde03 → string
nonces 0x7ecebe00 → uint256
numCheckpoints 0x6fcfff45 → uint32
symbol 0x95d89b41 → string
totalSupply 0x18160ddd → uint256
Write Contract 5 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address spender
uint256 rawAmount
returns: bool
delegate 0x5c19a95c
address delegatee
delegateBySig 0xc3cda520
address delegatee
uint256 nonce
uint256 expiry
uint8 v
bytes32 r
bytes32 s
transfer 0xa9059cbb
address dst
uint256 rawAmount
returns: bool
transferFrom 0x23b872dd
address src
address dst
uint256 rawAmount
returns: bool
Recent Transactions
No transactions found for this address