Cryo Explorer Ethereum Mainnet

Address Contract Verified

Address 0x98D06b4CA0d60C0e155bdD8F88a9fdf0A50e1Aa6
Balance 0 ETH
Nonce 1
Code Size 8691 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

8691 bytes
0x608060405234801561001057600080fd5b506004361061018e5760003560e01c8063a217fddf116100de578063c5a9e27811610097578063dbf3fa8011610071578063dbf3fa8014610392578063e2c4f6e9146103b2578063f0198efb146103ba578063f1cb325d146103e057600080fd5b8063c5a9e2781461033c578063d547741f14610367578063d8f0733f1461037a57600080fd5b8063a217fddf146102d1578063a8d6e68e146102d9578063adc9772e146102e9578063af1c7f20146102fc578063bf4e07cb14610305578063c2fff4a51461033457600080fd5b806336568abe1161014b57806365c43cc71161012557806365c43cc7146102835780636cf50b1a1461029857806391d14854146102ab578063a17a2312146102be57600080fd5b806336568abe1461024a5780633c22d7a91461025d5780635a05be981461027057600080fd5b806301ffc9a7146101935780630a659ad9146101bb5780630c540e14146101e757806313f9f340146101fe578063248a9ca3146102135780632f2ff15d14610237575b600080fd5b6101a66101a13660046118e3565b6103f3565b60405190151581526020015b60405180910390f35b6004546101d290600160401b900463ffffffff1681565b60405163ffffffff90911681526020016101b2565b6101f060065481565b6040519081526020016101b2565b61021161020c36600461190d565b61042a565b005b6101f061022136600461190d565b6000908152600160208190526040909120015490565b610211610245366004611942565b610507565b610211610258366004611942565b610533565b6101f061026b3660046119ba565b61056b565b6101f061027e3660046119fc565b610747565b61028b610773565b6040516101b29190611a76565b6102116102a6366004611a9d565b610801565b6101a66102b9366004611942565b6109fa565b6102116102cc366004611b6a565b610a25565b6101f0600081565b6004546101d29063ffffffff1681565b6102116102f7366004611bde565b610b77565b6101f060055481565b6101d2610313366004611c08565b6001600160a01b031660009081526008602052604090205463ffffffff1690565b61028b610fcc565b6101f061034a3660046119fc565b600760209081526000928352604080842090915290825290205481565b610211610375366004611942565b610fd9565b6004546101d290640100000000900463ffffffff1681565b6103a56103a0366004611c23565b610fff565b6040516101b29190611c6e565b6005546101f0565b6101d26103c8366004611c08565b60086020526000908152604090205463ffffffff1681565b6102116103ee366004611cb2565b611126565b60006001600160e01b03198216637965db0b60e01b148061042457506301ffc9a760e01b6001600160e01b03198316145b92915050565b6000610435816111e6565b600454600160401b900463ffffffff161580610452575060055482105b6104cb576040805162461bcd60e51b81526020600482015260248101919091527f667265657a652073746174652c2074696d65206d757374206265206c6573732060448201527f7468616e207468652073657420756e7374616b696e6754696d652076616c756560648201526084015b60405180910390fd5b60058290556040518281527f1c10690b72a9b7421267eb4214fb56b028c136d5e9119de849a01b0af17170689060200160405180910390a15050565b60008281526001602081905260409091200154610523816111e6565b61052d83836111f3565b50505050565b6001600160a01b038116331461055c5760405163334bd91960e11b815260040160405180910390fd5b610566828261126c565b505050565b60006105756112d9565b6005544210156105bc5760405162461bcd60e51b815260206004820152601260248201527163616e6e6f7420756e7374616b65206e6f7760701b60448201526064016104c2565b816105fe5760405162461bcd60e51b81526020600482015260126024820152716e65656420746f6b656e206164647265737360701b60448201526064016104c2565b60005b828110156106f757600061063b85858481811061062057610620611cce565b90506020020160208101906106359190611c08565b33610747565b905080156106855761067385858481811061065857610658611cce565b905060200201602081019061066d9190611c08565b82611303565b8261067d81611cfa565b9350506106ee565b7fa6eefd04443f1a7822da0df565443ce430c422ca39772c1cfd290c5ec92fd6788585848181106106b8576106b8611cce565b90506020020160208101906106cd9190611c08565b604080516001600160a01b0390921682523360208301520160405180910390a15b50600101610601565b506000811161073d5760405162461bcd60e51b8152602060048201526012602482015271139bc81d1bdad95b9cc81d5b9cdd185ad95960721b60448201526064016104c2565b6104246001600055565b6001600160a01b0380821660009081526007602090815260408083209386168352929052205492915050565b6003805461078090611d13565b80601f01602080910402602001604051908101604052809291908181526020018280546107ac90611d13565b80156107f95780601f106107ce576101008083540402835291602001916107f9565b820191906000526020600020905b8154815290600101906020018083116107dc57829003601f168201915b505050505081565b600061080c816111e6565b600454600160401b900463ffffffff16158061084457506001600160a01b03831660009081526008602052604090205463ffffffff16155b6108a85760405162461bcd60e51b815260206004820152602f60248201527f667265657a652073746174652c206f6e6c7920636c6f73656420746f6b656e7360448201526e1031b0b71031329037b832b732b21760891b60648201526084016104c2565b63ffffffff821615806108c1575063ffffffff82166001145b61091e5760405162461bcd60e51b815260206004820152602860248201527f6465706f73697461626c652076616c7565206973203028636c6f736529206f726044820152672031286f70656e2960c01b60648201526084016104c2565b6001600160a01b03831660009081526008602052604090205463ffffffff80841691160361098e5760405162461bcd60e51b815260206004820152601c60248201527f53616d652066726f6d207468652063757272656e74207374617475730000000060448201526064016104c2565b6001600160a01b038316600081815260086020908152604091829020805463ffffffff191663ffffffff87169081179091558251938452908301527f40c9bc4c6393e87f33110d2652d044c5046b4b354b41b783c369bed7ff8db8e091015b60405180910390a1505050565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b600454600160401b900463ffffffff1615610a715760405162461bcd60e51b815260206004820152600c60248201526b333932b2bd329030b236b4b760a11b60448201526064016104c2565b6000610a7c816111e6565b63ffffffff82161580610a95575063ffffffff82166001145b610aed5760405162461bcd60e51b815260206004820152602360248201527f667265657a652076616c756520697320302866616c736529206f72203128747260448201526275652960e81b60648201526084016104c2565b6002610af98582611d9d565b506003610b068482611d9d565b50600480546bffffffff00000000000000001916600160401b63ffffffff858116820292909217928390556040517fca3344463ca26728ba9dc322ba28ea23018b744e6d98e93d4271c1984a64636e93610b699360029360039392041690611eda565b60405180910390a150505050565b610b7f6112d9565b60008111610bcf5760405162461bcd60e51b815260206004820152601d60248201527f616d6f756e74206d7573742062652067726561746572207468616e203000000060448201526064016104c2565b6001600160a01b03821660009081526008602052604090205463ffffffff16600114610c3d5760405162461bcd60e51b815260206004820181905260248201527f7468697320697320696d706f737369626c6520746f6b656e206164647265737360448201526064016104c2565b6040516370a0823160e01b815233600482015282906000906001600160a01b038316906370a0823190602401602060405180830381865afa158015610c86573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610caa9190611f16565b905082811015610cfc5760405162461bcd60e51b815260206004820152601960248201527f696e73756666696369656e7420746f6b656e20616d6f756e740000000000000060448201526064016104c2565b6000826001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d3c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d609190611f2f565b60045490915060009063ffffffff640100000000820481169116610d8584600a612036565b610d8f9190612045565b610d99919061205c565b905080851015610de25760405162461bcd60e51b81526020600482015260146024820152731b5a5b9a5b5d5b481d1bdad95b88185b5bdd5b9d60621b60448201526064016104c2565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa158015610e29573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e4d9190611f16565b9050610e646001600160a01b03861633308961153d565b6040516370a0823160e01b81523060048201526000906001600160a01b038716906370a0823190602401602060405180830381865afa158015610eab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ecf9190611f16565b90506000610edd838361207e565b3360009081526007602090815260408083206001600160a01b038e168452909152812080549293508392909190610f15908490612091565b909155505060068054906000610f2a83611cfa565b91905055506000610f3c6006546115a4565b905060006002600383604051602001610f5793929190612117565b6040516020818303038152906040529050336001600160a01b03168b6001600160a01b03167f03e554b7511fd51b981b8470efad2ea27ff25ea0388745046bb7f614d58b50c68584604051610fad92919061215e565b60405180910390a3505050505050505050610fc86001600055565b5050565b6002805461078090611d13565b60008281526001602081905260409091200154610ff5816111e6565b61052d838361126c565b6060826110435760405162461bcd60e51b81526020600482015260126024820152716e65656420746f6b656e206164647265737360701b60448201526064016104c2565b60008367ffffffffffffffff81111561105e5761105e611ac7565b604051908082528060200260200182016040528015611087578160200160208202803683370190505b50905060005b8481101561111b576001600160a01b0384166000908152600760205260408120908787848181106110c0576110c0611cce565b90506020020160208101906110d59190611c08565b6001600160a01b03166001600160a01b031681526020019081526020016000205482828151811061110857611108611cce565b602090810291909101015260010161108d565b5090505b9392505050565b600454600160401b900463ffffffff16156111725760405162461bcd60e51b815260206004820152600c60248201526b333932b2bd329030b236b4b760a11b60448201526064016104c2565b600061117d816111e6565b6004805463ffffffff84811664010000000090810267ffffffffffffffff19909316878316179290921792839055604080518483168152929093041660208201527ff76c9eb19db5aac43e442b5ab3e8fe32a423697be45a23afb76e284de8bccbb391016109ed565b6111f08133611637565b50565b60006111ff83836109fa565b6112645760008381526001602081815260408084206001600160a01b0387168086529252808420805460ff19169093179092559051339286917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a4506001610424565b506000610424565b600061127883836109fa565b156112645760008381526001602090815260408083206001600160a01b0386168085529252808320805460ff1916905551339286917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a4506001610424565b6002600054036112fc57604051633ee5aeb560e01b815260040160405180910390fd5b6002600055565b600081116113535760405162461bcd60e51b815260206004820152601a60248201527f596f7520646f206e6f7420686f6c6420616e7920746f6b656e7300000000000060448201526064016104c2565b600061135f8333610747565b9050818110156113b15760405162461bcd60e51b815260206004820152601c60248201527f696e73756666696369656e74207374616b696e672062616c616e63650000000060448201526064016104c2565b3360009081526007602090815260408083206001600160a01b0387168452909152812080548492906113e490849061207e565b90915550506040516370a0823160e01b815230600482015283906000906001600160a01b038316906370a0823190602401602060405180830381865afa158015611432573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114569190611f16565b905061146c6001600160a01b0386163386611670565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a0823190602401602060405180830381865afa1580156114b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114d79190611f16565b905060006114e5828461207e565b9050336001600160a01b0316876001600160a01b03167f48f78116cd3b34293966fc8f8a9fae9af25c9674f9960a6cf0e555ab2bc2f5a78360405161152c91815260200190565b60405180910390a350505050505050565b6040516001600160a01b03848116602483015283811660448301526064820183905261052d9186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b0383818316178352505050506116a1565b606060006115b183611704565b600101905060008167ffffffffffffffff8111156115d1576115d1611ac7565b6040519080825280601f01601f1916602001820160405280156115fb576020820181803683370190505b5090508181016020015b600019016f181899199a1a9b1b9c1cb0b131b232b360811b600a86061a8153600a850494508461160557509392505050565b61164182826109fa565b610fc85760405163e2517d3f60e01b81526001600160a01b0382166004820152602481018390526044016104c2565b6040516001600160a01b0383811660248301526044820183905261056691859182169063a9059cbb90606401611572565b60006116b66001600160a01b038416836117dc565b905080516000141580156116db5750808060200190518101906116d9919061217f565b155b1561056657604051635274afe760e01b81526001600160a01b03841660048201526024016104c2565b60008072184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b83106117435772184f03e93ff9f4daa797ed6e38ed64bf6a1f0160401b830492506040015b6d04ee2d6d415b85acef8100000000831061176f576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061178d57662386f26fc10000830492506010015b6305f5e10083106117a5576305f5e100830492506008015b61271083106117b957612710830492506004015b606483106117cb576064830492506002015b600a83106104245760010192915050565b606061111f8383600084600080856001600160a01b0316848660405161180291906121a1565b60006040518083038185875af1925050503d806000811461183f576040519150601f19603f3d011682016040523d82523d6000602084013e611844565b606091505b509150915061185486838361185e565b9695505050505050565b6060826118735761186e826118ba565b61111f565b815115801561188a57506001600160a01b0384163b155b156118b357604051639996b31560e01b81526001600160a01b03851660048201526024016104c2565b508061111f565b8051156118ca5780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6000602082840312156118f557600080fd5b81356001600160e01b03198116811461111f57600080fd5b60006020828403121561191f57600080fd5b5035919050565b80356001600160a01b038116811461193d57600080fd5b919050565b6000806040838503121561195557600080fd5b8235915061196560208401611926565b90509250929050565b60008083601f84011261198057600080fd5b50813567ffffffffffffffff81111561199857600080fd5b6020830191508360208260051b85010111156119b357600080fd5b9250929050565b600080602083850312156119cd57600080fd5b823567ffffffffffffffff8111156119e457600080fd5b6119f08582860161196e565b90969095509350505050565b60008060408385031215611a0f57600080fd5b611a1883611926565b915061196560208401611926565b60005b83811015611a41578181015183820152602001611a29565b50506000910152565b60008151808452611a62816020860160208601611a26565b601f01601f19169290920160200192915050565b60208152600061111f6020830184611a4a565b803563ffffffff8116811461193d57600080fd5b60008060408385031215611ab057600080fd5b611ab983611926565b915061196560208401611a89565b634e487b7160e01b600052604160045260246000fd5b600082601f830112611aee57600080fd5b813567ffffffffffffffff80821115611b0957611b09611ac7565b604051601f8301601f19908116603f01168101908282118183101715611b3157611b31611ac7565b81604052838152866020858801011115611b4a57600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600060608486031215611b7f57600080fd5b833567ffffffffffffffff80821115611b9757600080fd5b611ba387838801611add565b94506020860135915080821115611bb957600080fd5b50611bc686828701611add565b925050611bd560408501611a89565b90509250925092565b60008060408385031215611bf157600080fd5b611bfa83611926565b946020939093013593505050565b600060208284031215611c1a57600080fd5b61111f82611926565b600080600060408486031215611c3857600080fd5b833567ffffffffffffffff811115611c4f57600080fd5b611c5b8682870161196e565b9094509250611bd5905060208501611926565b6020808252825182820181905260009190848201906040850190845b81811015611ca657835183529284019291840191600101611c8a565b50909695505050505050565b60008060408385031215611cc557600080fd5b611ab983611a89565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b600060018201611d0c57611d0c611ce4565b5060010190565b600181811c90821680611d2757607f821691505b602082108103611d4757634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115610566576000816000526020600020601f850160051c81016020861015611d765750805b601f850160051c820191505b81811015611d9557828155600101611d82565b505050505050565b815167ffffffffffffffff811115611db757611db7611ac7565b611dcb81611dc58454611d13565b84611d4d565b602080601f831160018114611e005760008415611de85750858301515b600019600386901b1c1916600185901b178555611d95565b600085815260208120601f198616915b82811015611e2f57888601518255948401946001909101908401611e10565b5085821015611e4d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b60008154611e6a81611d13565b808552602060018381168015611e875760018114611ea157611ecf565b60ff1985168884015283151560051b880183019550611ecf565b866000528260002060005b85811015611ec75781548a8201860152908301908401611eac565b890184019650505b505050505092915050565b606081526000611eed6060830186611e5d565b8281036020840152611eff8186611e5d565b91505063ffffffff83166040830152949350505050565b600060208284031215611f2857600080fd5b5051919050565b600060208284031215611f4157600080fd5b815160ff8116811461111f57600080fd5b600181815b80851115611f8d578160001904821115611f7357611f73611ce4565b80851615611f8057918102915b93841c9390800290611f57565b509250929050565b600082611fa457506001610424565b81611fb157506000610424565b8160018114611fc75760028114611fd157611fed565b6001915050610424565b60ff841115611fe257611fe2611ce4565b50506001821b610424565b5060208310610133831016604e8410600b8410161715612010575081810a610424565b61201a8383611f52565b806000190482111561202e5761202e611ce4565b029392505050565b600061111f60ff841683611f95565b808202811582820484141761042457610424611ce4565b60008261207957634e487b7160e01b600052601260045260246000fd5b500490565b8181038181111561042457610424611ce4565b8082018082111561042457610424611ce4565b600081546120b181611d13565b600182811680156120c957600181146120de5761210d565b60ff198416875282151583028701945061210d565b8560005260208060002060005b858110156121045781548a8201529084019082016120eb565b50505082870194505b5050505092915050565b600061212382866120a4565b602d60f81b80825261213860018301876120a4565b9150808252508351612151816001840160208801611a26565b0160010195945050505050565b8281526040602082015260006121776040830184611a4a565b949350505050565b60006020828403121561219157600080fd5b8151801515811461111f57600080fd5b600082516121b3818460208701611a26565b919091019291505056fea26469706673582212202e31f7c54923752cc25d98f6f155ec15c185c7e40541c9dc68bcd7496a565da564736f6c63430008180033

Verified Source Code Full Match

Compiler: v0.8.24+commit.e11b9ed9 EVM: paris Optimization: Yes (200 runs)
LiftMemeStake.sol 218 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract LiftMemeStake is ReentrancyGuard, AccessControl {
    using Address for address;
    using SafeERC20 for IERC20Metadata;

    string public net;
    string public ver;

    uint32 public minStakeValue;
    uint32 public minStakePerValue;
    uint32 public adminFreeze;
    uint256 public unstakingTime;
    uint256 public stakingCount;

    uint32 private constant _NOT_FREEZE = 0;
    uint32 private constant _FREEZE = 1;
    uint32 private constant _CLOSE = 0;
    uint32 private constant _OPEN = 1;

    mapping(address => mapping(address => uint256)) public stakeData;
    mapping(address => uint32) public isDepositable;

    // account event
    event Staking(
        address indexed token,
        address indexed owner,
        uint256 amount,
        string uid
    );
    event Unstaking(
        address indexed token,
        address indexed owner,
        uint256 amount
    );

    // system event
    event SetStakeValue(uint32 minStakeValue_, uint32 minStakePerValue_);
    event SetUnstakeTime(uint256 time);
    event SetVersion(string network, string version, uint32 freeze);
    event SwitchToken(address token, uint32 available);
    event UnstakeAttemptZeroBalance(address token, address account);

    constructor(address[] memory tokens, address admin, string memory network) {
        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);

        setStakeValue(0, 100);
        setUnstakeTime(1743433200); // 2025-04-01 00:00:00
        setVersion(network, "1", _NOT_FREEZE);
        for (uint256 i = 0; i < tokens.length; i++) {
            switchToken(tokens[i], _OPEN);
        }

        if (admin != address(0)) {
            _grantRole(DEFAULT_ADMIN_ROLE, admin);
        }
    }

    modifier checkAdminFreeze() {
        require(adminFreeze == _NOT_FREEZE, "freeze admin");
        _;
    }

    function setStakeValue(
        uint32 minStakeValue_,
        uint32 minStakePerValue_
    ) public checkAdminFreeze onlyRole(DEFAULT_ADMIN_ROLE) {
        minStakeValue = minStakeValue_;
        minStakePerValue = minStakePerValue_;
        emit SetStakeValue(minStakeValue, minStakePerValue);
    }

    function setUnstakeTime(uint256 time) public onlyRole(DEFAULT_ADMIN_ROLE) {
        require(
            adminFreeze == _NOT_FREEZE || time < unstakingTime,
            "freeze state, time must be less than the set unstakingTime value"
        );
        unstakingTime = time;
        emit SetUnstakeTime(unstakingTime);
    }

    function setVersion(
        string memory network,
        string memory version,
        uint32 freeze
    ) public checkAdminFreeze onlyRole(DEFAULT_ADMIN_ROLE) {
        require(
            freeze == _NOT_FREEZE || freeze == _FREEZE,
            "freeze value is 0(false) or 1(true)"
        );

        net = network;
        ver = version;
        adminFreeze = freeze;
        emit SetVersion(net, ver, adminFreeze);
    }

    function switchToken(
        address token,
        uint32 depositable
    ) public onlyRole(DEFAULT_ADMIN_ROLE) {
        require(
            adminFreeze == _NOT_FREEZE || isDepositable[token] == _CLOSE,
            "freeze state, only closed tokens can be opened."
        );
        require(
            depositable == _CLOSE || depositable == _OPEN,
            "depositable value is 0(close) or 1(open)"
        );
        require(
            isDepositable[token] != depositable,
            "Same from the current status"
        );
        isDepositable[token] = depositable;
        emit SwitchToken(token, isDepositable[token]);
    }

    function isAvailableToken(address token) external view returns (uint32) {
        return isDepositable[token];
    }

    function getUnstakeTime() public view returns (uint256) {
        return unstakingTime;
    }

    function stakingOf(
        address token,
        address user
    ) public view returns (uint256) {
        return stakeData[user][token];
    }

    function stakingOf(
        address[] calldata tokens,
        address user
    ) public view returns (uint256[] memory) {
        require(tokens.length > 0, "need token address");
        uint256[] memory balances = new uint256[](tokens.length);
        for (uint256 i = 0; i < tokens.length; i++) {
            balances[i] = stakeData[user][tokens[i]];
        }

        return balances;
    }

    function stake(address token, uint256 amount) public nonReentrant {
        require(amount > 0, "amount must be greater than 0");
        require(
            isDepositable[token] == _OPEN,
            "this is impossible token address"
        );
        IERC20Metadata tokenContract = IERC20Metadata(token);
        uint256 balance = tokenContract.balanceOf(msg.sender);
        require(balance >= amount, "insufficient token amount");

        uint8 decimals = tokenContract.decimals();
        uint256 minStakeAmount = ((10 ** decimals) * minStakeValue) /
            minStakePerValue;
        require(amount >= minStakeAmount, "minimum token amount");

        uint256 beforeAmount = tokenContract.balanceOf(address(this));
        tokenContract.safeTransferFrom(msg.sender, address(this), amount);
        uint256 afterAmount = tokenContract.balanceOf(address(this));
        uint256 validAmount = afterAmount - beforeAmount;

        stakeData[msg.sender][token] += validAmount;
        stakingCount++;

        string memory strCount = Strings.toString(stakingCount);
        string memory usid = string(
            abi.encodePacked(net, "-", ver, "-", strCount)
        );

        emit Staking(token, msg.sender, validAmount, usid);
    }

    function unstake(
        address[] calldata tokens
    ) public nonReentrant returns (uint256 unstakedCount) {
        require(block.timestamp >= unstakingTime, "cannot unstake now");
        require(tokens.length > 0, "need token address");
        for (uint256 i = 0; i < tokens.length; i++) {
            uint256 balance = stakingOf(tokens[i], msg.sender);
            if (balance > 0) {
                _unstakeToken(tokens[i], balance);
                unstakedCount++;
            } else {
                emit UnstakeAttemptZeroBalance(tokens[i], msg.sender);
            }
        }
        require(unstakedCount > 0, "No tokens unstaked");
    }

    function _unstakeToken(address token, uint256 balance) internal {
        require(balance > 0, "You do not hold any tokens");
        uint256 stakingBalance = stakingOf(token, msg.sender);
        require(stakingBalance >= balance, "insufficient staking balance");

        stakeData[msg.sender][token] -= balance;

        IERC20Metadata tokenContract = IERC20Metadata(token);

        uint256 beforeAmount = tokenContract.balanceOf(address(this));
        IERC20Metadata(token).safeTransfer(msg.sender, balance);
        uint256 afterAmount = tokenContract.balanceOf(address(this));
        uint256 validAmount = beforeAmount - afterAmount;

        emit Unstaking(token, msg.sender, validAmount);
    }
}
Address.sol 159 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert FailedInnerCall();
        }
    }
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

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

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}
Strings.sol 94 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Strings.sol)

pragma solidity ^0.8.20;

import {Math} from "./math/Math.sol";
import {SignedMath} from "./math/SignedMath.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant HEX_DIGITS = "0123456789abcdef";
    uint8 private constant ADDRESS_LENGTH = 20;

    /**
     * @dev The `value` string doesn't fit in the specified `length`.
     */
    error StringsInsufficientHexLength(uint256 value, uint256 length);

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), HEX_DIGITS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toStringSigned(int256 value) internal pure returns (string memory) {
        return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value)));
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        uint256 localValue = value;
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = HEX_DIGITS[localValue & 0xf];
            localValue >>= 4;
        }
        if (localValue != 0) {
            revert StringsInsufficientHexLength(value, length);
        }
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal
     * representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), ADDRESS_LENGTH);
    }

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b));
    }
}
Math.sol 415 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @dev Muldiv operation overflow.
     */
    error MathOverflowedMulDiv();

    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            uint256 c = a + b;
            if (c < a) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with an overflow flag.
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b > a) return (false, 0);
            return (true, a - b);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a / b);
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            if (b == 0) return (false, 0);
            return (true, a % b);
        }
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            return a / b;
        }

        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
     * denominator == 0.
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
     * Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0 = x * y; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            if (denominator <= prod1) {
                revert MathOverflowedMulDiv();
            }

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator.
            // Always >= 1. See https://cs.stackexchange.com/q/138556/92363.

            uint256 twos = denominator & (0 - denominator);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
            // works in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
     * towards zero.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10 ** 64) {
                value /= 10 ** 64;
                result += 64;
            }
            if (value >= 10 ** 32) {
                value /= 10 ** 32;
                result += 32;
            }
            if (value >= 10 ** 16) {
                value /= 10 ** 16;
                result += 16;
            }
            if (value >= 10 ** 8) {
                value /= 10 ** 8;
                result += 8;
            }
            if (value >= 10 ** 4) {
                value /= 10 ** 4;
                result += 4;
            }
            if (value >= 10 ** 2) {
                value /= 10 ** 2;
                result += 2;
            }
            if (value >= 10 ** 1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0);
        }
    }

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` 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 value) external returns (bool);
}
AccessControl.sol 209 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    mapping(bytes32 role => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual returns (bool) {
        return _roles[role].hasRole[account];
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        if (callerConfirmation != _msgSender()) {
            revert AccessControlBadConfirmation();
        }

        _revokeRole(role, callerConfirmation);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        if (!hasRole(role, account)) {
            _roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        if (hasRole(role, account)) {
            _roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}
IAccessControl.sol 98 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/IAccessControl.sol)

pragma solidity ^0.8.20;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}
ReentrancyGuard.sol 84 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant NOT_ENTERED = 1;
    uint256 private constant ENTERED = 2;

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be NOT_ENTERED
        if (_status == ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        _status = ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == ENTERED;
    }
}
SignedMath.sol 43 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.20;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two signed numbers.
     */
    function min(int256 a, int256 b) internal pure returns (int256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}
ERC165.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

import {IERC165} from "./IERC165.sol";

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}
SafeERC20.sol 118 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC20Permit.sol 90 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` 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:
     *
     * - `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].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current 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.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}
IERC20Metadata.sol 26 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 */
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

DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
adminFreeze 0x0a659ad9 → uint32
getRoleAdmin 0x248a9ca3 → bytes32
getUnstakeTime 0xe2c4f6e9 → uint256
hasRole 0x91d14854 → bool
isAvailableToken 0xbf4e07cb → uint32
isDepositable 0xf0198efb → uint32
minStakePerValue 0xd8f0733f → uint32
minStakeValue 0xa8d6e68e → uint32
net 0xc2fff4a5 → string
stakeData 0xc5a9e278 → uint256
stakingCount 0x0c540e14 → uint256
stakingOf 0x5a05be98 → uint256
stakingOf 0xdbf3fa80 → uint256[]
supportsInterface 0x01ffc9a7 → bool
unstakingTime 0xaf1c7f20 → uint256
ver 0x65c43cc7 → string

Write Contract 9 functions

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

grantRole 0x2f2ff15d
bytes32 role
address account
renounceRole 0x36568abe
bytes32 role
address callerConfirmation
revokeRole 0xd547741f
bytes32 role
address account
setStakeValue 0xf1cb325d
uint32 minStakeValue_
uint32 minStakePerValue_
setUnstakeTime 0x13f9f340
uint256 time
setVersion 0xa17a2312
string network
string version
uint32 freeze
stake 0xadc9772e
address token
uint256 amount
switchToken 0x6cf50b1a
address token
uint32 depositable
unstake 0x3c22d7a9
address[] tokens
returns: uint256

Recent Transactions

No transactions found for this address