Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0xcf0C122c6b73ff809C693DB761e7BaeBe62b6a2E
Balance 0 ETH
Nonce 1
Code Size 8007 bytes
Indexed Transactions 2 (24,433,30524,433,308)
Gas Used (indexed) 159,853
External Etherscan · Sourcify

Contract Bytecode

8007 bytes
0x608060405234801561001057600080fd5b50600436106101b95760003560e01c80636fcfff45116100f9578063a9059cbb11610097578063dd62ed3e11610071578063dd62ed3e14610420578063e7a324dc14610459578063f1127ed814610480578063f2fde38b146104e857600080fd5b8063a9059cbb146103e7578063a9373b7b146103fa578063c3cda5201461040d57600080fd5b80637ecebe00116100d35780637ecebe001461039b5780638da5cb5b146103bb57806395d89b41146103cc578063a457c2d7146103d457600080fd5b80636fcfff451461032f57806370a082311461036a578063715018a61461039357600080fd5b806323b872dd11610166578063395093511161014057806339509351146102cb578063488d4a51146102de578063587cde1e146102f35780635c19a95c1461031c57600080fd5b806323b872dd1461027e578063271a452914610291578063313ce567146102bc57600080fd5b80631788963311610197578063178896331461022a57806318160ddd1461023d57806320606b701461025757600080fd5b806306fdde03146101be578063095ea7b3146101dc57806312280ba8146101ff575b600080fd5b6101c66104fb565b6040516101d39190611bfa565b60405180910390f35b6101ef6101ea366004611c6b565b61058d565b60405190151581526020016101d3565b600754610212906001600160a01b031681565b6040516001600160a01b0390911681526020016101d3565b600854610212906001600160a01b031681565b69021e19e0c9bab24000005b6040519081526020016101d3565b6102497f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a86681565b6101ef61028c366004611c95565b6105a4565b6102a461029f366004611cd1565b61068e565b6040516001600160e01b0390911681526020016101d3565b604051600981526020016101d3565b6101ef6102d9366004611c6b565b610968565b6102f16102ec366004611d11565b6109a4565b005b610212610301366004611d11565b6003602052600090815260409020546001600160a01b031681565b6102f161032a366004611d11565b610a6c565b61035561033d366004611d11565b60056020526000908152604090205463ffffffff1681565b60405163ffffffff90911681526020016101d3565b610249610378366004611d11565b6001600160a01b031660009081526001602052604090205490565b6102f1610a79565b6102496103a9366004611d11565b60046020526000908152604090205481565b6000546001600160a01b0316610212565b6101c6610adf565b6101ef6103e2366004611c6b565b610aee565b6101ef6103f5366004611c6b565b610bc5565b6102f1610408366004611d11565b610bd2565b6102f161041b366004611d33565b610c93565b61024961042e366004611d93565b6001600160a01b03918216600090815260026020908152604080832093909416825291909152205490565b6102497fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf81565b6104c461048e366004611cd1565b600660209081526000928352604080842090915290825290205463ffffffff81169064010000000090046001600160e01b031682565b6040805163ffffffff90931683526001600160e01b039091166020830152016101d3565b6102f16104f6366004611d11565b610fed565b60606009805461050a90611dc6565b80601f016020809104026020016040519081016040528092919081815260200182805461053690611dc6565b80156105835780601f1061055857610100808354040283529160200191610583565b820191906000526020600020905b81548152906001019060200180831161056657829003601f168201915b5050505050905090565b600061059a3384846110cc565b5060015b92915050565b60006105b1848484611227565b6001600160a01b0384166000908152600260209081526040808320338452909152902054828110156106765760405162461bcd60e51b815260206004820152604960248201527f464c4f4b493a7472616e7366657246726f6d3a414c4c4f57414e43455f45584360448201527f45454445443a205472616e7366657220616d6f756e742065786365656473206160648201527f6c6c6f77616e63652e0000000000000000000000000000000000000000000000608482015260a4015b60405180910390fd5b61068385338584036110cc565b506001949350505050565b6000438263ffffffff16106107315760405162461bcd60e51b815260206004820152604e60248201527f464c4f4b493a676574566f7465734174426c6f636b3a4655545552455f424c4f60448201527f434b3a2043616e6e6f742067657420766f746573206174206120626c6f636b2060648201527f696e20746865206675747572652e000000000000000000000000000000000000608482015260a40161066d565b6001600160a01b03831660009081526005602052604090205463ffffffff168061075f57600091505061059e565b6001600160a01b038416600090815260066020526040812063ffffffff85169161078a600185611e17565b63ffffffff908116825260208201929092526040016000205416116107fe576001600160a01b0384166000908152600660205260408120906107cd600184611e17565b63ffffffff16815260208101919091526040016000205464010000000090046001600160e01b0316915061059e9050565b6001600160a01b038416600090815260066020908152604080832083805290915290205463ffffffff8085169116111561083c57600091505061059e565b60008061084a600184611e17565b90505b8163ffffffff168163ffffffff161115610922576000600261086f8484611e17565b6108799190611e3c565b6108839083611e17565b6001600160a01b038816600090815260066020908152604080832063ffffffff8581168552908352928190208151808301909252548084168083526401000000009091046001600160e01b03169282019290925292935090881614156108f35760200151945061059e9350505050565b805163ffffffff8089169116101561090d5781935061091b565b610918600183611e17565b92505b505061084d565b506001600160a01b038516600090815260066020908152604080832063ffffffff909416835292905220546001600160e01b036401000000009091041691505092915050565b3360008181526002602090815260408083206001600160a01b0387168452909152812054909161059a91859061099f908690611e6d565b6110cc565b6000546001600160a01b031633146109fe5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161066d565b600780546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff1983168117909355604080519190921680825260208201939093527ed910c9481701ba32afe0c247572aaece27072f230c8ec769bf245fc0b38de691015b60405180910390a15050565b610a7633826117c2565b50565b6000546001600160a01b03163314610ad35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161066d565b610add6000611861565b565b6060600a805461050a90611dc6565b3360009081526002602090815260408083206001600160a01b038616845290915281205482811015610bae5760405162461bcd60e51b815260206004820152605760248201527f464c4f4b493a6465637265617365416c6c6f77616e63653a414c4c4f57414e4360448201527f455f554e444552464c4f573a205375627472616374696f6e20726573756c747360648201527f20696e207375622d7a65726f20616c6c6f77616e63652e000000000000000000608482015260a40161066d565b610bbb33858584036110cc565b5060019392505050565b600061059a338484611227565b6000546001600160a01b03163314610c2c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161066d565b600880546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff1983168117909355604080519190921680825260208201939093527f1bf87992a35ee29395ab494f9adb9a500a7fa60c3082cba0ef02701bb35900d99101610a60565b60007f8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866610cbe6104fb565b8051602091820120604080518084019490945283810191909152466060840152306080808501919091528151808503909101815260a0840182528051908301207fe48329057bfd03d55e49b547132e39cffd9c1820ad7b9d4c5307691425d15adf60c08501526001600160a01b038b1660e085015261010084018a90526101208085018a90528251808603909101815261014085019092528151919092012061190160f01b61016084015261016283018290526101828301819052909250906000906101a20160408051601f198184030181528282528051602091820120600080855291840180845281905260ff8a169284019290925260608301889052608083018790529092509060019060a0016020604051602081039080840390855afa158015610def573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116610e9e5760405162461bcd60e51b815260206004820152604660248201527f464c4f4b493a64656c656761746542795369673a494e56414c49445f5349474e60448201527f41545552453a205265636569766564207369676e61747572652077617320696e60648201527f76616c69642e0000000000000000000000000000000000000000000000000000608482015260a40161066d565b87421115610f3a5760405162461bcd60e51b815260206004820152604660248201527f464c4f4b493a64656c656761746542795369673a455850495245445f5349474e60448201527f41545552453a205265636569766564207369676e61747572652068617320657860648201527f70697265642e0000000000000000000000000000000000000000000000000000608482015260a40161066d565b6001600160a01b0381166000908152600460205260408120805491610f5e83611e85565b919050558914610fd65760405162461bcd60e51b815260206004820152603e60248201527f464c4f4b493a64656c656761746542795369673a494e56414c49445f4e4f4e4360448201527f453a205265636569766564206e6f6e63652077617320696e76616c69642e0000606482015260840161066d565b610fe0818b6117c2565b505050505b505050505050565b6000546001600160a01b031633146110475760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161066d565b6001600160a01b0381166110c35760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161066d565b610a7681611861565b6001600160a01b0383166111485760405162461bcd60e51b815260206004820152603f60248201527f464c4f4b493a5f617070726f76653a4f574e45525f5a45524f3a2043616e6e6f60448201527f7420617070726f766520666f7220746865207a65726f20616464726573732e00606482015260840161066d565b6001600160a01b0382166111c6576040805162461bcd60e51b81526020600482015260248101919091527f464c4f4b493a5f617070726f76653a5350454e4445525f5a45524f3a2043616e60448201527f6e6f7420617070726f766520746f20746865207a65726f20616464726573732e606482015260840161066d565b6001600160a01b0383811660008181526002602090815260408083209487168084529482529182902085905590518481527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925910160405180910390a3505050565b6001600160a01b0383166112ad5760405162461bcd60e51b815260206004820152604160248201527f464c4f4b493a5f7472616e736665723a46524f4d5f5a45524f3a2043616e6e6f60448201527f74207472616e736665722066726f6d20746865207a65726f20616464726573736064820152601760f91b608482015260a40161066d565b6001600160a01b0382166113295760405162461bcd60e51b815260206004820152603d60248201527f464c4f4b493a5f7472616e736665723a544f5f5a45524f3a2043616e6e6f742060448201527f7472616e7366657220746f20746865207a65726f20616464726573732e000000606482015260840161066d565b600081116113c55760405162461bcd60e51b815260206004820152604760248201527f464c4f4b493a5f7472616e736665723a5a45524f5f414d4f554e543a2054726160448201527f6e7366657220616d6f756e74206d75737420626520677265617465722074686160648201527f6e207a65726f2e00000000000000000000000000000000000000000000000000608482015260a40161066d565b6001600160a01b0383166000908152600160205260409020548111156114795760405162461bcd60e51b815260206004820152604660248201527f464c4f4b493a5f7472616e736665723a494e53554646494349454e545f42414c60448201527f414e43453a205472616e7366657220616d6f756e74206578636565647320626160648201527f6c616e63652e0000000000000000000000000000000000000000000000000000608482015260a40161066d565b6008546040517fc6512cc10000000000000000000000000000000000000000000000000000000081526001600160a01b0385811660048301528481166024830152604482018490529091169063c6512cc190606401600060405180830381600087803b1580156114e857600080fd5b505af11580156114fc573d6000803e3d6000fd5b50506007546040517fd7ad21ac0000000000000000000000000000000000000000000000000000000081526001600160a01b03878116600483015286811660248301526044820186905260009450909116915063d7ad21ac90606401602060405180830381865afa158015611575573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115999190611ea0565b905060006115a78284611eb9565b6001600160a01b0386166000908152600160205260408120805492935085929091906115d4908490611eb9565b90915550506001600160a01b03841660009081526001602052604081208054839290611601908490611e6d565b90915550506001600160a01b03808616600090815260036020526040808220548784168352912054611638929182169116836118be565b81156116e7576008546001600160a01b031660009081526001602052604081208054849290611668908490611e6d565b90915550506001600160a01b0380861660009081526003602052604080822054600854841683529120546116a1929182169116846118be565b6008546040518381526001600160a01b03918216918716907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9060200160405180910390a35b6008546040517fe613b1cd0000000000000000000000000000000000000000000000000000000081526001600160a01b0387811660048301528681166024830152604482018690529091169063e613b1cd90606401600060405180830381600087803b15801561175657600080fd5b505af115801561176a573d6000803e3d6000fd5b50505050836001600160a01b0316856001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef836040516117b391815260200190565b60405180910390a35050505050565b6001600160a01b038281166000818152600360208181526040808420805460018452948290205493835287871673ffffffffffffffffffffffffffffffffffffffff198616811790915581519586529390951690840181905293830191909152907f3134e8a2e6d97e929a7e54011ea5485d7d196dd5f0ba4d4ef95803e8e3fc257f9060600160405180910390a161185b8284836118be565b50505050565b600080546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b816001600160a01b0316836001600160a01b031614156118dd57505050565b6001600160e01b0381166118f057505050565b6001600160a01b03831615611998576001600160a01b03831660009081526005602052604081205463ffffffff16908161192b576000611978565b6001600160a01b03851660009081526006602052604081209061194f600185611e17565b63ffffffff16815260208101919091526040016000205464010000000090046001600160e01b03165b905060006119868483611ed0565b905061199486848484611a41565b5050505b6001600160a01b03821615611a3c576001600160a01b03821660009081526005602052604081205463ffffffff1690816119d3576000611a20565b6001600160a01b0384166000908152600660205260408120906119f7600185611e17565b63ffffffff16815260208101919091526040016000205464010000000090046001600160e01b03165b90506000611a2e8483611ef0565b9050610fe585848484611a41565b505050565b4363ffffffff841615801590611a9957506001600160a01b038516600090815260066020526040812063ffffffff831691611a7d600188611e17565b63ffffffff908116825260208201929092526040016000205416145b15611b09576001600160a01b03851660009081526006602052604081208391611ac3600188611e17565b63ffffffff1663ffffffff16815260200190815260200160002060000160046101000a8154816001600160e01b0302191690836001600160e01b03160217905550611ba1565b60408051808201825263ffffffff80841682526001600160e01b0380861660208085019182526001600160a01b038b166000908152600682528681208b86168252909152949094209251935116640100000000029216919091179055611b70846001611f1b565b6001600160a01b0386166000908152600560205260409020805463ffffffff191663ffffffff929092169190911790555b604080516001600160a01b03871681526001600160e01b03858116602083015284168183015290517fda5a64c2947c0b7bf4d6e7bf736c6f84d9d1c5f991770f88bbeb3fe19c85a1349181900360600190a15050505050565b600060208083528351808285015260005b81811015611c2757858101830151858201604001528201611c0b565b81811115611c39576000604083870101525b50601f01601f1916929092016040019392505050565b80356001600160a01b0381168114611c6657600080fd5b919050565b60008060408385031215611c7e57600080fd5b611c8783611c4f565b946020939093013593505050565b600080600060608486031215611caa57600080fd5b611cb384611c4f565b9250611cc160208501611c4f565b9150604084013590509250925092565b60008060408385031215611ce457600080fd5b611ced83611c4f565b9150602083013563ffffffff81168114611d0657600080fd5b809150509250929050565b600060208284031215611d2357600080fd5b611d2c82611c4f565b9392505050565b60008060008060008060c08789031215611d4c57600080fd5b611d5587611c4f565b95506020870135945060408701359350606087013560ff81168114611d7957600080fd5b9598949750929560808101359460a0909101359350915050565b60008060408385031215611da657600080fd5b611daf83611c4f565b9150611dbd60208401611c4f565b90509250929050565b600181811c90821680611dda57607f821691505b60208210811415611dfb57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600063ffffffff83811690831681811015611e3457611e34611e01565b039392505050565b600063ffffffff80841680611e6157634e487b7160e01b600052601260045260246000fd5b92169190910492915050565b60008219821115611e8057611e80611e01565b500190565b6000600019821415611e9957611e99611e01565b5060010190565b600060208284031215611eb257600080fd5b5051919050565b600082821015611ecb57611ecb611e01565b500390565b60006001600160e01b0383811690831681811015611e3457611e34611e01565b60006001600160e01b03808316818516808303821115611f1257611f12611e01565b01949350505050565b600063ffffffff808316818516808303821115611f1257611f12611e0156fea164736f6c634300080b000a

Verified Source Code Partial Match

Compiler: v0.8.11+commit.d7f03943 EVM: london Optimization: Yes (888 runs)
Floki.sol 466 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.11;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

import "./governance/IGovernanceToken.sol";
import "./tax/ITaxHandler.sol";
import "./treasury/ITreasuryHandler.sol";

/**
 * @title Floki token contract
 * @dev The Floki token has modular systems for tax and treasury handler as well as governance capabilities.
 */
contract FLOKI is IERC20, IGovernanceToken, Ownable {
    /// @dev Registry of user token balances.
    mapping(address => uint256) private _balances;

    /// @dev Registry of addresses users have given allowances to.
    mapping(address => mapping(address => uint256)) private _allowances;

    /// @notice Registry of user delegates for governance.
    mapping(address => address) public delegates;

    /// @notice Registry of nonces for vote delegation.
    mapping(address => uint256) public nonces;

    /// @notice Registry of the number of balance checkpoints an account has.
    mapping(address => uint32) public numCheckpoints;

    /// @notice Registry of balance checkpoints per account.
    mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;

    /// @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 The contract implementing tax calculations.
    ITaxHandler public taxHandler;

    /// @notice The contract that performs treasury-related operations.
    ITreasuryHandler public treasuryHandler;

    /// @notice Emitted when the tax handler contract is changed.
    event TaxHandlerChanged(address oldAddress, address newAddress);

    /// @notice Emitted when the treasury handler contract is changed.
    event TreasuryHandlerChanged(address oldAddress, address newAddress);

    /// @dev Name of the token.
    string private _name;

    /// @dev Symbol of the token.
    string private _symbol;

    /**
     * @param name_ Name of the token.
     * @param symbol_ Symbol of the token.
     * @param taxHandlerAddress Initial tax handler contract.
     * @param treasuryHandlerAddress Initial treasury handler contract.
     */
    constructor(
        string memory name_,
        string memory symbol_,
        address taxHandlerAddress,
        address treasuryHandlerAddress
    ) {
        _name = name_;
        _symbol = symbol_;

        taxHandler = ITaxHandler(taxHandlerAddress);
        treasuryHandler = ITreasuryHandler(treasuryHandlerAddress);

        _balances[_msgSender()] = totalSupply();

        emit Transfer(address(0), _msgSender(), totalSupply());
    }

    /**
     * @notice Get token name.
     * @return Name of the token.
     */
    function name() public view returns (string memory) {
        return _name;
    }

    /**
     * @notice Get token symbol.
     * @return Symbol of the token.
     */
    function symbol() external view returns (string memory) {
        return _symbol;
    }

    /**
     * @notice Get number of decimals used by the token.
     * @return Number of decimals used by the token.
     */
    function decimals() external pure returns (uint8) {
        return 9;
    }

    /**
     * @notice Get the maximum number of tokens.
     * @return The maximum number of tokens that will ever be in existence.
     */
    function totalSupply() public pure override returns (uint256) {
        // Ten trillion, i.e., 10,000,000,000,000 tokens.
        return 1e13 * 1e9;
    }

    /**
     * @notice Get token balance of given given account.
     * @param account Address to retrieve balance for.
     * @return The number of tokens owned by `account`.
     */
    function balanceOf(address account) external view override returns (uint256) {
        return _balances[account];
    }

    /**
     * @notice Transfer tokens from caller's address to another.
     * @param recipient Address to send the caller's tokens to.
     * @param amount The number of tokens to transfer to recipient.
     * @return True if transfer succeeds, else an error is raised.
     */
    function transfer(address recipient, uint256 amount) external override returns (bool) {
        _transfer(_msgSender(), recipient, amount);
        return true;
    }

    /**
     * @notice Get the allowance `owner` has given `spender`.
     * @param owner The address on behalf of whom tokens can be spent by `spender`.
     * @param spender The address authorized to spend tokens on behalf of `owner`.
     * @return The allowance `owner` has given `spender`.
     */
    function allowance(address owner, address spender) external view override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @notice Approve address to spend caller's tokens.
     * @dev This method can be exploited by malicious spenders if their allowance is already non-zero. See the following
     * document for details: https://docs.google.com/document/d/1YLPtQxZu1UAvO9cZ1O2RPXBbT0mooh4DYKjA_jp-RLM/edit.
     * Ensure the spender can be trusted before calling this method if they've already been approved before. Otherwise
     * use either the `increaseAllowance`/`decreaseAllowance` functions, or first set their allowance to zero, before
     * setting a new allowance.
     * @param spender Address to authorize for token expenditure.
     * @param amount The number of tokens `spender` is allowed to spend.
     * @return True if the approval succeeds, else an error is raised.
     */
    function approve(address spender, uint256 amount) external override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @notice Transfer tokens from one address to another.
     * @param sender Address to move tokens from.
     * @param recipient Address to send the caller's tokens to.
     * @param amount The number of tokens to transfer to recipient.
     * @return True if the transfer succeeds, else an error is raised.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) external override returns (bool) {
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(
            currentAllowance >= amount,
            "FLOKI:transferFrom:ALLOWANCE_EXCEEDED: Transfer amount exceeds allowance."
        );
        unchecked {
            _approve(sender, _msgSender(), currentAllowance - amount);
        }

        return true;
    }

    /**
     * @notice Increase spender's allowance.
     * @param spender Address of user authorized to spend caller's tokens.
     * @param addedValue The number of tokens to add to `spender`'s allowance.
     * @return True if the allowance is successfully increased, else an error is raised.
     */
    function increaseAllowance(address spender, uint256 addedValue) external returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);

        return true;
    }

    /**
     * @notice Decrease spender's allowance.
     * @param spender Address of user authorized to spend caller's tokens.
     * @param subtractedValue The number of tokens to remove from `spender`'s allowance.
     * @return True if the allowance is successfully decreased, else an error is raised.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(
            currentAllowance >= subtractedValue,
            "FLOKI:decreaseAllowance:ALLOWANCE_UNDERFLOW: Subtraction results in sub-zero allowance."
        );
        unchecked {
            _approve(_msgSender(), spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @notice Delegate votes to given address.
     * @dev It should be noted that users that want to vote themselves, also need to call this method, albeit with their
     * own address.
     * @param delegatee Address to delegate votes to.
     */
    function delegate(address delegatee) external {
        return _delegate(msg.sender, delegatee);
    }

    /**
     * @notice Delegate 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,
        uint256 nonce,
        uint256 expiry,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external {
        bytes32 domainSeparator = keccak256(
            abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name())), block.chainid, 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), "FLOKI:delegateBySig:INVALID_SIGNATURE: Received signature was invalid.");
        require(block.timestamp <= expiry, "FLOKI:delegateBySig:EXPIRED_SIGNATURE: Received signature has expired.");
        require(nonce == nonces[signatory]++, "FLOKI:delegateBySig:INVALID_NONCE: Received nonce was invalid.");

        return _delegate(signatory, delegatee);
    }

    /**
     * @notice Determine the 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 getVotesAtBlock(address account, uint32 blockNumber) public view returns (uint224) {
        require(
            blockNumber < block.number,
            "FLOKI:getVotesAtBlock:FUTURE_BLOCK: Cannot get votes at a block in the future."
        );

        uint32 nCheckpoints = numCheckpoints[account];
        if (nCheckpoints == 0) {
            return 0;
        }

        // First check most recent balance.
        if (checkpoints[account][nCheckpoints - 1].blockNumber <= blockNumber) {
            return checkpoints[account][nCheckpoints - 1].votes;
        }

        // Next check implicit zero balance.
        if (checkpoints[account][0].blockNumber > blockNumber) {
            return 0;
        }

        // Perform binary search.
        uint32 lowerBound = 0;
        uint32 upperBound = nCheckpoints - 1;
        while (upperBound > lowerBound) {
            uint32 center = upperBound - (upperBound - lowerBound) / 2;
            Checkpoint memory checkpoint = checkpoints[account][center];

            if (checkpoint.blockNumber == blockNumber) {
                return checkpoint.votes;
            } else if (checkpoint.blockNumber < blockNumber) {
                lowerBound = center;
            } else {
                upperBound = center - 1;
            }
        }

        // No exact block found. Use last known balance before that block number.
        return checkpoints[account][lowerBound].votes;
    }

    /**
     * @notice Set new tax handler contract.
     * @param taxHandlerAddress Address of new tax handler contract.
     */
    function setTaxHandler(address taxHandlerAddress) external onlyOwner {
        address oldTaxHandlerAddress = address(taxHandler);
        taxHandler = ITaxHandler(taxHandlerAddress);

        emit TaxHandlerChanged(oldTaxHandlerAddress, taxHandlerAddress);
    }

    /**
     * @notice Set new treasury handler contract.
     * @param treasuryHandlerAddress Address of new treasury handler contract.
     */
    function setTreasuryHandler(address treasuryHandlerAddress) external onlyOwner {
        address oldTreasuryHandlerAddress = address(treasuryHandler);
        treasuryHandler = ITreasuryHandler(treasuryHandlerAddress);

        emit TreasuryHandlerChanged(oldTreasuryHandlerAddress, treasuryHandlerAddress);
    }

    /**
     * @notice Delegate votes from one address to another.
     * @param delegator Address from which to delegate votes for.
     * @param delegatee Address to delegate votes to.
     */
    function _delegate(address delegator, address delegatee) private {
        address currentDelegate = delegates[delegator];
        uint256 delegatorBalance = _balances[delegator];
        delegates[delegator] = delegatee;

        emit DelegateChanged(delegator, currentDelegate, delegatee);

        _moveDelegates(currentDelegate, delegatee, uint224(delegatorBalance));
    }

    /**
     * @notice Move delegates from one address to another.
     * @param from Representative to move delegates from.
     * @param to Representative to move delegates to.
     * @param amount Number of delegates to move.
     */
    function _moveDelegates(
        address from,
        address to,
        uint224 amount
    ) private {
        // No need to update checkpoints if the votes don't actually move between different delegates. This can be the
        // case where tokens are transferred between two parties that have delegated their votes to the same address.
        if (from == to) {
            return;
        }

        // Some users preemptively delegate their votes (i.e. before they have any tokens). No need to perform an update
        // to the checkpoints in that case.
        if (amount == 0) {
            return;
        }

        if (from != address(0)) {
            uint32 fromRepNum = numCheckpoints[from];
            uint224 fromRepOld = fromRepNum > 0 ? checkpoints[from][fromRepNum - 1].votes : 0;
            uint224 fromRepNew = fromRepOld - amount;

            _writeCheckpoint(from, fromRepNum, fromRepOld, fromRepNew);
        }

        if (to != address(0)) {
            uint32 toRepNum = numCheckpoints[to];
            uint224 toRepOld = toRepNum > 0 ? checkpoints[to][toRepNum - 1].votes : 0;
            uint224 toRepNew = toRepOld + amount;

            _writeCheckpoint(to, toRepNum, toRepOld, toRepNew);
        }
    }

    /**
     * @notice Write balance checkpoint to chain.
     * @param delegatee The address to write the checkpoint for.
     * @param nCheckpoints The number of checkpoints `delegatee` already has.
     * @param oldVotes Number of votes prior to this checkpoint.
     * @param newVotes Number of votes `delegatee` now has.
     */
    function _writeCheckpoint(
        address delegatee,
        uint32 nCheckpoints,
        uint224 oldVotes,
        uint224 newVotes
    ) private {
        uint32 blockNumber = uint32(block.number);

        if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].blockNumber == blockNumber) {
            checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
        } else {
            checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
            numCheckpoints[delegatee] = nCheckpoints + 1;
        }

        emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
    }

    /**
     * @notice Approve spender on behalf of owner.
     * @param owner Address on behalf of whom tokens can be spent by `spender`.
     * @param spender Address to authorize for token expenditure.
     * @param amount The number of tokens `spender` is allowed to spend.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) private {
        require(owner != address(0), "FLOKI:_approve:OWNER_ZERO: Cannot approve for the zero address.");
        require(spender != address(0), "FLOKI:_approve:SPENDER_ZERO: Cannot approve to the zero address.");

        _allowances[owner][spender] = amount;

        emit Approval(owner, spender, amount);
    }

    /**
     * @notice Transfer `amount` tokens from account `from` to account `to`.
     * @param from Address the tokens are moved out of.
     * @param to Address the tokens are moved to.
     * @param amount The number of tokens to transfer.
     */
    function _transfer(
        address from,
        address to,
        uint256 amount
    ) private {
        require(from != address(0), "FLOKI:_transfer:FROM_ZERO: Cannot transfer from the zero address.");
        require(to != address(0), "FLOKI:_transfer:TO_ZERO: Cannot transfer to the zero address.");
        require(amount > 0, "FLOKI:_transfer:ZERO_AMOUNT: Transfer amount must be greater than zero.");
        require(amount <= _balances[from], "FLOKI:_transfer:INSUFFICIENT_BALANCE: Transfer amount exceeds balance.");

        treasuryHandler.beforeTransferHandler(from, to, amount);

        uint256 tax = taxHandler.getTax(from, to, amount);
        uint256 taxedAmount = amount - tax;

        _balances[from] -= amount;
        _balances[to] += taxedAmount;
        _moveDelegates(delegates[from], delegates[to], uint224(taxedAmount));

        if (tax > 0) {
            _balances[address(treasuryHandler)] += tax;

            _moveDelegates(delegates[from], delegates[address(treasuryHandler)], uint224(tax));

            emit Transfer(from, address(treasuryHandler), tax);
        }

        treasuryHandler.afterTransferHandler(from, to, amount);

        emit Transfer(from, to, taxedAmount);
    }
}
ITaxHandler.sol 21 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.11;

/**
 * @title Tax handler interface
 * @dev Any class that implements this interface can be used for protocol-specific tax calculations.
 */
interface ITaxHandler {
    /**
     * @notice Get number of tokens to pay as tax.
     * @param benefactor Address of the benefactor.
     * @param beneficiary Address of the beneficiary.
     * @param amount Number of tokens in the transfer.
     * @return Number of tokens to pay as tax.
     */
    function getTax(
        address benefactor,
        address beneficiary,
        uint256 amount
    ) external view returns (uint256);
}
ITreasuryHandler.sol 32 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.11;

/**
 * @title Treasury handler interface
 * @dev Any class that implements this interface can be used for protocol-specific operations pertaining to the treasury.
 */
interface ITreasuryHandler {
    /**
     * @notice Perform operations before a transfer is executed.
     * @param benefactor Address of the benefactor.
     * @param beneficiary Address of the beneficiary.
     * @param amount Number of tokens in the transfer.
     */
    function beforeTransferHandler(
        address benefactor,
        address beneficiary,
        uint256 amount
    ) external;

    /**
     * @notice Perform operations after a transfer is executed.
     * @param benefactor Address of the benefactor.
     * @param beneficiary Address of the beneficiary.
     * @param amount Number of tokens in the transfer.
     */
    function afterTransferHandler(
        address benefactor,
        address beneficiary,
        uint256 amount
    ) external;
}
Context.sol 23 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}
IGovernanceToken.sol 35 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.11;

/**
 * @title Governance token interface.
 */
interface IGovernanceToken {
    /// @notice A checkpoint for marking number of votes as of a given block.
    struct Checkpoint {
        // The 32-bit unsigned integer is valid until these estimated dates for these given chains:
        //  - BSC: Sat Dec 23 2428 18:23:11 UTC
        //  - ETH: Tue Apr 18 3826 09:27:12 UTC
        // This assumes that block mining rates don't speed up.
        uint32 blockNumber;
        // This type is set to `uint224` for optimizations purposes (i.e., specifically to fit in a 32-byte block). It
        // assumes that the number of votes for the implementing governance token never exceeds the maximum value for a
        // 224-bit number.
        uint224 votes;
    }

    /**
     * @notice Determine the 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 getVotesAtBlock(address account, uint32 blockNumber) external view returns (uint224);

    /// @notice Emitted whenever a new delegate is set for an account.
    event DelegateChanged(address delegator, address currentDelegate, address newDelegate);

    /// @notice Emitted when a delegate's vote count changes.
    event DelegateVotesChanged(address delegatee, uint224 oldVotes, uint224 newVotes);
}
Ownable.sol 71 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.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.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * 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.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _setOwner(_msgSender());
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _setOwner(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");
        _setOwner(newOwner);
    }

    function _setOwner(address newOwner) private {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}
IERC20.sol 81 lines
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @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 `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, 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 `sender` to `recipient` 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 sender,
        address recipient,
        uint256 amount
    ) external returns (bool);

    /**
     * @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);
}

Read Contract

DELEGATION_TYPEHASH 0xe7a324dc → bytes32
DOMAIN_TYPEHASH 0x20606b70 → bytes32
allowance 0xdd62ed3e → uint256
balanceOf 0x70a08231 → uint256
checkpoints 0xf1127ed8 → uint32, uint224
decimals 0x313ce567 → uint8
delegates 0x587cde1e → address
getVotesAtBlock 0x271a4529 → uint224
name 0x06fdde03 → string
nonces 0x7ecebe00 → uint256
numCheckpoints 0x6fcfff45 → uint32
owner 0x8da5cb5b → address
symbol 0x95d89b41 → string
taxHandler 0x12280ba8 → address
totalSupply 0x18160ddd → uint256
treasuryHandler 0x17889633 → address

Write Contract 11 functions

These functions modify contract state and require a wallet transaction to execute.

approve 0x095ea7b3
address spender
uint256 amount
returns: bool
decreaseAllowance 0xa457c2d7
address spender
uint256 subtractedValue
returns: bool
delegate 0x5c19a95c
address delegatee
delegateBySig 0xc3cda520
address delegatee
uint256 nonce
uint256 expiry
uint8 v
bytes32 r
bytes32 s
increaseAllowance 0x39509351
address spender
uint256 addedValue
returns: bool
renounceOwnership 0x715018a6
No parameters
setTaxHandler 0x488d4a51
address taxHandlerAddress
setTreasuryHandler 0xa9373b7b
address treasuryHandlerAddress
transfer 0xa9059cbb
address recipient
uint256 amount
returns: bool
transferFrom 0x23b872dd
address sender
address recipient
uint256 amount
returns: bool
transferOwnership 0xf2fde38b
address newOwner

Top Interactions

AddressTxnsSentReceived
0xF33368d1...3301 1 1
0x28C6c062...1d60 1 1

Recent Transactions

CSV
|
Hash Method Block Age From/To Value Txn Fee Type
0xbe6db903...0f5f80 transfer 24,433,308 IN 0x28C6c062...1d60 0 ETH EIP-1559
0x88ec94da...006f22 transferFrom 24,433,305 IN 0xF33368d1...3301 0 ETH EIP-1559