Address Contract Partially Verified
Address
0x77f400a7af20d22F387503dbA3979bA28d8aF48b
Balance
0 ETH
Nonce
1
Code Size
9043 bytes
Creator
0xCF23e502...6554 at tx 0xebbcd67d...36e8a1
Indexed Transactions
0
Contract Bytecode
9043 bytes
0x608060405234801561001057600080fd5b50600436106101a35760003560e01c806385049c39116100ee578063a1003b2911610097578063d18df53c11610071578063d18df53c146103e8578063d444d327146103fb578063f2fde38b1461040e578063f7c618c11461042157600080fd5b8063a1003b2914610382578063ac9650d814610395578063cbd258b5146103b557600080fd5b80638da5cb5b116100c85780638da5cb5b1461030a5780638dbdbe6d1461032857806393f1a40b1461033b57600080fd5b806385049c39146102a95780638ae39cac146102ee5780638aee8127146102f757600080fd5b80634809b4291161015057806364482f791161012a57806364482f791461027b578063715018a61461028e5780637abceffd1461029657600080fd5b80634809b4291461024d57806351eb05a614610260578063630b5ba11461027357600080fd5b806317caf6f11161018157806317caf6f11461021e57806318fccc76146102275780632f940c701461023a57600080fd5b8063081e3eda146101a85780630ad58d2f146101bf5780631526fe27146101d4575b600080fd5b6004545b6040519081526020015b60405180910390f35b6101d26101cd366004611e29565b610441565b005b6101e76101e2366004611e62565b6106d1565b6040805173ffffffffffffffffffffffffffffffffffffffff909516855260208501939093529183015260608201526080016101b6565b6101ac60065481565b6101d2610235366004611e7b565b610722565b6101d2610248366004611e7b565b610858565b6101d261025b366004611eab565b610963565b6101d261026e366004611e62565b610a2b565b6101d2610bd6565b6101d2610289366004611ed6565b610bff565b6101d2610d39565b6101d26102a4366004611f04565b610dc6565b6003546102c99073ffffffffffffffffffffffffffffffffffffffff1681565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101b6565b6101ac60075481565b6101d2610305366004611eab565b611086565b60005473ffffffffffffffffffffffffffffffffffffffff166102c9565b6101d2610336366004611e29565b61114e565b61036d610349366004611e7b565b60056020908152600092835260408084209091529082529020805460019091015482565b604080519283526020830191909152016101b6565b6101d2610390366004611e62565b61135c565b6103a86103a3366004611f87565b6113e2565b6040516101b6919061203f565b6103d86103c3366004611eab565b60086020526000908152604090205460ff1681565b60405190151581526020016101b6565b6101ac6103f6366004611e7b565b6114d7565b6101d2610409366004611f87565b6116b8565b6101d261041c366004611eab565b6116f9565b6002546102c99073ffffffffffffffffffffffffffffffffffffffff1681565b600260015414156104b3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064015b60405180910390fd5b60026001556104c183610a2b565b6000600484815481106104d6576104d66120bf565b60009182526020808320604080516080810182526004909402909101805473ffffffffffffffffffffffffffffffffffffffff168452600181015484840152600281015484830152600301546060840152878452600582528084203385529091529091208054919250908411156105a9576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601260248201527f77697468647261773a206e6f7420676f6f64000000000000000000000000000060448201526064016104aa565b600064e8d4a51000836020015183600001546105c5919061211d565b6105cf919061215a565b905060008260010154826105e39190612195565b90508015610616576003546002546106169173ffffffffffffffffffffffffffffffffffffffff91821691168784611826565b851561064e578254610629908790612195565b8355835161064e9073ffffffffffffffffffffffffffffffffffffffff168688611908565b6020840151835464e8d4a51000916106659161211d565b61066f919061215a565b600184015560405186815273ffffffffffffffffffffffffffffffffffffffff861690889033907f8166bf25f8a2b7ed3c85049207da4358d16edbed977d23fa2ee6f0dde3ec2132906020015b60405180910390a45050600180555050505050565b600481815481106106e157600080fd5b6000918252602090912060049091020180546001820154600283015460039093015473ffffffffffffffffffffffffffffffffffffffff9092169350919084565b61072b82610a2b565b600060048381548110610740576107406120bf565b60009182526020808320604080516080810182526004909402909101805473ffffffffffffffffffffffffffffffffffffffff168452600181015484840190815260028201548584015260039091015460608501528785526005835281852033865290925283209051815492945090929164e8d4a51000916107c19161211d565b6107cb919061215a565b905060008260010154826107df9190612195565b6001840183905590508015610819576003546002546108199173ffffffffffffffffffffffffffffffffffffffff91821691168784611826565b604051818152869033907f71bab65ced2e5750775a0613be067df48ef06cf92a496ebf7663ae06609249549060200160405180910390a3505050505050565b60006004838154811061086d5761086d6120bf565b60009182526020808320604080516080810182526004909402909101805473ffffffffffffffffffffffffffffffffffffffff9081168552600180830154868601526002830154868501526003909201546060860152888652600584528286203387529093529084208054858255918101949094558251929450916108f491168583611908565b8373ffffffffffffffffffffffffffffffffffffffff16853373ffffffffffffffffffffffffffffffffffffffff167f2cac5e20e1541d836381527a43f651851e302817b71dc8e810284e69210c1c6b8460405161095491815260200190565b60405180910390a45050505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633146109e4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104aa565b600380547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600060048281548110610a4057610a406120bf565b9060005260206000209060040201905080600201544311610a5f575050565b80546040517f70a0823100000000000000000000000000000000000000000000000000000000815230600482015260009173ffffffffffffffffffffffffffffffffffffffff16906370a0823190602401602060405180830381865afa158015610acd573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610af191906121ac565b9050801580610b0257506003820154155b15610b1257504360029091015550565b6000826002015443610b249190612195565b90506000600654846003015460075484610b3e919061211d565b610b48919061211d565b610b52919061215a565b905082610b6464e8d4a510008361211d565b610b6e919061215a565b8460010154610b7d91906121c5565b600185018190554360028601819055604080519182526020820186905281019190915285907fcb7325664a4a3b7c7223eefc492a97ca4fdf94d46884621e5a8fae5a04b2b9d29060600160405180910390a25050505050565b60005b600454811015610bfc57610bec81610a2b565b610bf5816121dd565b9050610bd9565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610c80576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104aa565b8015610c8e57610c8e610bd6565b8160048481548110610ca257610ca26120bf565b906000526020600020906004020160030154600654610cc19190612195565b610ccb91906121c5565b6006819055508160048481548110610ce557610ce56120bf565b906000526020600020906004020160030181905550827f942cc7e17a17c164bd977f32ab8c54265d5b9d481e4e352bf874f1e568874e7c83604051610d2c91815260200190565b60405180910390a2505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314610dba576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104aa565b610dc4600061195e565b565b60005473ffffffffffffffffffffffffffffffffffffffff163314610e47576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104aa565b73ffffffffffffffffffffffffffffffffffffffff821660009081526008602052604090205460ff1615610ed7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f5374616b696e673a206475706c69636174656420706f6f6c000000000000000060448201526064016104aa565b8015610ee557610ee5610bd6565b82600654610ef391906121c5565b60065573ffffffffffffffffffffffffffffffffffffffff8281166000818152600860209081526040808320805460017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff009091168117909155815160808101835285815292830184815243928401928352606084018a81526004805480850182559681905294517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b96860296870180547fffffffffffffffffffffffff0000000000000000000000000000000000000000169190991617909755517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19c85015590517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19d84015593517f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19e9092019190915554909161104e91612195565b6040518581527f4710feb78e3bce8d2e3ca2989a8eb2f8bcd32a6a55b4535942c180fc4d2e29529060200160405180910390a3505050565b60005473ffffffffffffffffffffffffffffffffffffffff163314611107576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104aa565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b600260015414156111bb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104aa565b60026001556111c983610a2b565b6000600484815481106111de576111de6120bf565b60009182526020808320604080516080810182526004909402909101805473ffffffffffffffffffffffffffffffffffffffff168452600181015484840190815260028201548584015260039091015460608501528885526005835281852033865290925283209051815492945090929164e8d4a510009161125f9161211d565b611269919061215a565b9050600082600101548261127d9190612195565b905080156112b0576003546002546112b09173ffffffffffffffffffffffffffffffffffffffff91821691168784611826565b85156112ea5783516112da9073ffffffffffffffffffffffffffffffffffffffff16333089611826565b82546112e79087906121c5565b83555b6020840151835464e8d4a51000916113019161211d565b61130b919061215a565b600184015560405186815273ffffffffffffffffffffffffffffffffffffffff861690889033907f02d7e648dd130fc184d383e55bb126ac4c9c60e8f94bf05acdf557ba2d540b47906020016106bc565b60005473ffffffffffffffffffffffffffffffffffffffff1633146113dd576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104aa565b600755565b60608167ffffffffffffffff8111156113fd576113fd612216565b60405190808252806020026020018201604052801561143057816020015b606081526020019060019003908161141b5790505b50905060005b828110156114d0576114a030858584818110611454576114546120bf565b90506020028101906114669190612245565b8080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506119d392505050565b8282815181106114b2576114b26120bf565b602002602001018190525080806114c8906121dd565b915050611436565b5092915050565b600080600484815481106114ed576114ed6120bf565b60009182526020808320604080516080810182526004948502909201805473ffffffffffffffffffffffffffffffffffffffff908116845260018083015485870190815260028401548686015260039093015460608601528b8852600586528388208b8316895286528388208451808601865281548152910154958101959095529051835192517f70a08231000000000000000000000000000000000000000000000000000000008152309681019690965292965092949193919216906370a0823190602401602060405180830381865afa1580156115d0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115f491906121ac565b905083604001514311801561160857508015155b1561167857600084604001514361161f9190612195565b90506000600654866060015160075484611639919061211d565b611643919061211d565b61164d919061215a565b90508261165f64e8d4a510008361211d565b611669919061215a565b61167390856121c5565b935050505b600064e8d4a51000838560000151611690919061211d565b61169a919061215a565b90508360200151816116ac9190612195565b98975050505050505050565b60005b818110156116f4576116e48383838181106116d8576116d86120bf565b90506020020135610a2b565b6116ed816121dd565b90506116bb565b505050565b60005473ffffffffffffffffffffffffffffffffffffffff16331461177a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104aa565b73ffffffffffffffffffffffffffffffffffffffff811661181d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f646472657373000000000000000000000000000000000000000000000000000060648201526084016104aa565b610bfc8161195e565b60405173ffffffffffffffffffffffffffffffffffffffff808516602483015283166044820152606481018290526119029085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff00000000000000000000000000000000000000000000000000000000909316929092179091526119ff565b50505050565b60405173ffffffffffffffffffffffffffffffffffffffff83166024820152604481018290526116f49084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401611880565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60606119f883836040518060600160405280602781526020016122f760279139611b0b565b9392505050565b6000611a61826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16611c1d9092919063ffffffff16565b8051909150156116f45780806020019051810190611a7f91906122aa565b6116f4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f7420737563636565640000000000000000000000000000000000000000000060648201526084016104aa565b6060833b611b9b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f60448201527f6e7472616374000000000000000000000000000000000000000000000000000060648201526084016104aa565b6000808573ffffffffffffffffffffffffffffffffffffffff1685604051611bc391906122c7565b600060405180830381855af49150503d8060008114611bfe576040519150601f19603f3d011682016040523d82523d6000602084013e611c03565b606091505b5091509150611c13828286611c34565b9695505050505050565b6060611c2c8484600085611c87565b949350505050565b60608315611c435750816119f8565b825115611c535782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104aa91906122e3565b606082471015611d19576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c000000000000000000000000000000000000000000000000000060648201526084016104aa565b843b611d81576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016104aa565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051611daa91906122c7565b60006040518083038185875af1925050503d8060008114611de7576040519150601f19603f3d011682016040523d82523d6000602084013e611dec565b606091505b5091509150611dfc828286611c34565b979650505050505050565b73ffffffffffffffffffffffffffffffffffffffff81168114610bfc57600080fd5b600080600060608486031215611e3e57600080fd5b83359250602084013591506040840135611e5781611e07565b809150509250925092565b600060208284031215611e7457600080fd5b5035919050565b60008060408385031215611e8e57600080fd5b823591506020830135611ea081611e07565b809150509250929050565b600060208284031215611ebd57600080fd5b81356119f881611e07565b8015158114610bfc57600080fd5b600080600060608486031215611eeb57600080fd5b83359250602084013591506040840135611e5781611ec8565b600080600060608486031215611f1957600080fd5b833592506020840135611f2b81611e07565b91506040840135611e5781611ec8565b60008083601f840112611f4d57600080fd5b50813567ffffffffffffffff811115611f6557600080fd5b6020830191508360208260051b8501011115611f8057600080fd5b9250929050565b60008060208385031215611f9a57600080fd5b823567ffffffffffffffff811115611fb157600080fd5b611fbd85828601611f3b565b90969095509350505050565b60005b83811015611fe4578181015183820152602001611fcc565b838111156119025750506000910152565b6000815180845261200d816020860160208601611fc9565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6000602080830181845280855180835260408601915060408160051b870101925083870160005b828110156120b2577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc08886030184526120a0858351611ff5565b94509285019290850190600101612066565b5092979650505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615612155576121556120ee565b500290565b600082612190577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500490565b6000828210156121a7576121a76120ee565b500390565b6000602082840312156121be57600080fd5b5051919050565b600082198211156121d8576121d86120ee565b500190565b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82141561220f5761220f6120ee565b5060010190565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261227a57600080fd5b83018035915067ffffffffffffffff82111561229557600080fd5b602001915036819003821315611f8057600080fd5b6000602082840312156122bc57600080fd5b81516119f881611ec8565b600082516122d9818460208701611fc9565b9190910192915050565b6020815260006119f86020830184611ff556fe416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a26469706673582212204f8418a82ac100b5fbe22c7dc5a6ca94a976ed60f74b426cd7f28c5eae97c07064736f6c634300080a0033
Verified Source Code Partial Match
Compiler: v0.8.10+commit.fc410830
EVM: london
Optimization: Yes (2000000 runs)
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);
}
Address.sol 210 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @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, it is bubbled up by this
* function (like regular Solidity function calls).
*
* 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.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @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`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) private pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// 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
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
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;
}
}
Ownable.sol 71 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./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);
}
}
staking.sol 272 lines
// SPDX-License-Identifier: MIT
// combined from
// https://github.com/Thorstarter/thorstarter-contracts/blob/main/contracts/Staking.sol
// and:
// https://github.com/goosedefi/goose-contracts/blob/master/contracts/MasterChefV2.sol
// which was audited
pragma solidity ^0.8.4;
import "./IERC20.sol";
import "./SafeERC20.sol";
import "./Ownable.sol";
import "./Multicall.sol";
import "./ReentrancyGuard.sol";
contract THORWallet_Staking_V2 is Ownable, Multicall, ReentrancyGuard {
using SafeERC20 for IERC20;
/// @notice Info of each Staking user.
/// `amount` LP token amount the user has provided.
/// `rewardOffset` The amount of token which needs to be subtracted at the next harvesting event.
struct UserInfo {
uint256 amount;
uint256 rewardOffset;
}
/// @notice Info of each Staking pool.
/// `lpToken` The address of LP token contract.
/// `allocPoint` The amount of allocation points assigned to the pool.
/// Also known as the amount of token to distribute per block.
struct PoolInfo {
IERC20 lpToken;
uint256 accRewardPerShare;
uint256 lastRewardBlock;
uint256 allocPoint;
}
// The amount of rewardTokens entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accRewardPerShare) - user.rewardOffset
//
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accRewardPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardOffset` gets updated.
/// @notice Address of token contract.
IERC20 public rewardToken;
address public rewardOwner;
/// @notice Info of each Staking pool.
PoolInfo[] public poolInfo;
/// @notice Info of each user that stakes LP tokens.
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
/// @dev Total allocation points. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
uint256 public rewardPerBlock = 0;
uint256 private constant ACC_PRECISION = 1e12;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount, address indexed to);
event Harvest(address indexed user, uint256 indexed pid, uint256 amount);
event LogPoolAddition(uint256 indexed pid, uint256 allocPoint, IERC20 indexed lpToken);
event LogSetPool(uint256 indexed pid, uint256 allocPoint);
event LogUpdatePool(uint256 indexed pid, uint256 lastRewardBlock, uint256 lpSupply, uint256 accRewardPerShare);
/// @param _rewardToken The reward token contract address.
constructor(IERC20 _rewardToken, address _rewardOwner, uint256 _rewardPerBlock) Ownable() {
rewardToken = _rewardToken;
rewardOwner = _rewardOwner;
rewardPerBlock = _rewardPerBlock;
}
/// @notice Sets the reward token.
function setRewardToken(IERC20 _rewardToken) public onlyOwner {
rewardToken = _rewardToken;
}
/// @notice Sets the reward owner.
function setRewardOwner(address _rewardOwner) public onlyOwner {
rewardOwner = _rewardOwner;
}
/// @notice Adjusts the reward per block.
function setRewardsPerBlock(uint256 _rewardPerBlock) public onlyOwner {
rewardPerBlock = _rewardPerBlock;
}
/// @notice Returns the number of Staking pools.
function poolLength() public view returns (uint256 pools) {
pools = poolInfo.length;
}
mapping(IERC20 => bool) public poolExistence;
/// @notice Add a new LP to the pool. Can only be called by the owner.
/// DO NOT add the same LP token more than once. Rewards will be messed up if you do.
/// @param _allocPoint AP of the new pool.
/// @param _lpToken Address of the LP ERC-20 token.
function addPool(uint256 _allocPoint, IERC20 _lpToken, bool _withUpdate) public onlyOwner {
require(!poolExistence[_lpToken], "Staking: duplicated pool");
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint + _allocPoint;
poolExistence[_lpToken] = true;
poolInfo.push(PoolInfo({
lpToken : _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: block.number,
accRewardPerShare: 0
}));
emit LogPoolAddition(poolInfo.length - 1, _allocPoint, _lpToken);
}
/// @notice Update the given pool's token allocation point. Can only be called by the owner.
/// @param _pid The index of the pool. See `poolInfo`.
/// @param _allocPoint New AP of the pool.
function set(uint256 _pid, uint256 _allocPoint, bool _withUpdate) public onlyOwner {
if (_withUpdate) {
massUpdatePools();
}
totalAllocPoint = totalAllocPoint - poolInfo[_pid].allocPoint + _allocPoint;
poolInfo[_pid].allocPoint = _allocPoint;
emit LogSetPool(_pid, _allocPoint);
}
/// @notice View function to see pending token reward on frontend.
/// @param _pid The index of the pool. See `poolInfo`.
/// @param _user Address of user.
/// @return pending token reward for a given user.
function pendingRewards(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo memory pool = poolInfo[_pid];
UserInfo memory user = userInfo[_pid][_user];
uint256 accRewardPerShare = pool.accRewardPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 blocks = block.number - pool.lastRewardBlock;
uint256 reward = (blocks * rewardPerBlock * pool.allocPoint) / totalAllocPoint;
accRewardPerShare = accRewardPerShare + ((reward * ACC_PRECISION) / lpSupply);
}
uint256 accumulatedReward = (user.amount * accRewardPerShare) / ACC_PRECISION;
return accumulatedReward - user.rewardOffset;
}
// Update reward variables for all pools. Be careful of gas spending!
function massUpdatePools() public {
for (uint256 i = 0; i < poolInfo.length; ++i) {
updatePool(i);
}
}
function massUpdatePoolsByIds(uint256[] calldata pids) external {
for (uint256 i = 0; i < pids.length; ++i) {
updatePool(pids[i]);
}
}
/// @notice Update reward variables of the given pool.
/// @param pid The index of the pool. See `poolInfo`.
function updatePool(uint256 pid) public {
PoolInfo storage pool = poolInfo[pid];
if (block.number <= pool.lastRewardBlock) {
return;
}
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (lpSupply == 0 || pool.allocPoint == 0) {
pool.lastRewardBlock = block.number;
return;
}
uint256 blocks = block.number - pool.lastRewardBlock;
uint256 reward = (blocks * rewardPerBlock * pool.allocPoint) / totalAllocPoint;
pool.accRewardPerShare = pool.accRewardPerShare + ((reward * ACC_PRECISION) / lpSupply);
pool.lastRewardBlock = block.number;
emit LogUpdatePool(pid, pool.lastRewardBlock, lpSupply, pool.accRewardPerShare);
}
/// @notice Deposit LP tokens to Staking for reward token allocation.
/// @param pid The index of the pool. See `poolInfo`.
/// @param amount LP token amount to deposit.
/// @param to The receiver of `amount` deposit benefit.
function deposit(uint256 pid, uint256 amount, address to) public nonReentrant {
updatePool(pid);
PoolInfo memory pool = poolInfo[pid];
UserInfo storage user = userInfo[pid][msg.sender];
// harvest
uint256 accumulatedReward = (user.amount * pool.accRewardPerShare) / ACC_PRECISION;
uint256 pendingReward = accumulatedReward - user.rewardOffset;
if (pendingReward > 0) {
rewardToken.safeTransferFrom(rewardOwner, to, pendingReward);
}
if (amount > 0) {
pool.lpToken.safeTransferFrom(address(msg.sender), address(this), amount);
user.amount = user.amount + amount;
}
user.rewardOffset = (user.amount * pool.accRewardPerShare) / ACC_PRECISION;
emit Deposit(msg.sender, pid, amount, to);
}
/// @notice Withdraw LP tokens from Staking.
/// @param pid The index of the pool. See `poolInfo`.
/// @param amount LP token amount to withdraw.
/// @param to Receiver of the LP tokens.
function withdraw(uint256 pid, uint256 amount, address to) public nonReentrant {
updatePool(pid);
PoolInfo memory pool = poolInfo[pid];
UserInfo storage user = userInfo[pid][msg.sender];
require(user.amount >= amount, "withdraw: not good");
// harvest
uint256 accumulatedReward = (user.amount * pool.accRewardPerShare) / ACC_PRECISION;
uint256 pendingReward = accumulatedReward - user.rewardOffset;
if (pendingReward > 0) {
rewardToken.safeTransferFrom(rewardOwner, to, pendingReward);
}
if (amount > 0) {
user.amount = user.amount - amount;
pool.lpToken.safeTransfer(to, amount);
}
user.rewardOffset = (user.amount * pool.accRewardPerShare) / ACC_PRECISION;
emit Withdraw(msg.sender, pid, amount, to);
}
/// @notice Harvest proceeds for transaction sender to `to`.
/// @param pid The index of the pool. See `poolInfo`.
/// @param to Receiver of token rewards.
function harvest(uint256 pid, address to) public {
updatePool(pid);
PoolInfo memory pool = poolInfo[pid];
UserInfo storage user = userInfo[pid][msg.sender];
uint256 accumulatedReward = (user.amount * pool.accRewardPerShare) / ACC_PRECISION;
uint256 pendingReward = accumulatedReward - user.rewardOffset;
user.rewardOffset = accumulatedReward;
if (pendingReward > 0) {
rewardToken.safeTransferFrom(rewardOwner, to, pendingReward);
}
emit Harvest(msg.sender, pid, pendingReward);
}
/// @notice Withdraw without caring about rewards. EMERGENCY ONLY.
/// @param pid The index of the pool. See `poolInfo`.
/// @param to Receiver of the LP tokens.
function emergencyWithdraw(uint256 pid, address to) public {
PoolInfo memory pool = poolInfo[pid];
UserInfo storage user = userInfo[pid][msg.sender];
uint256 amount = user.amount;
user.amount = 0;
user.rewardOffset = 0;
pool.lpToken.safeTransfer(to, amount);
emit EmergencyWithdraw(msg.sender, pid, amount, to);
}
}
Multicall.sol 23 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./Address.sol";
/**
* @dev Provides a function to batch together multiple calls in a single external call.
*
* _Available since v4.1._
*/
abstract contract Multicall {
/**
* @dev Receives and executes a batch of function calls on this contract.
*/
function multicall(bytes[] calldata data) external returns (bytes[] memory results) {
results = new bytes[](data.length);
for (uint256 i = 0; i < data.length; i++) {
results[i] = Address.functionDelegateCall(address(this), data[i]);
}
return results;
}
}
SafeERC20.sol 98 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./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;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @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, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
ReentrancyGuard.sol 62 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @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;
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 make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
Read Contract
owner 0x8da5cb5b → address
pendingRewards 0xd18df53c → uint256
poolExistence 0xcbd258b5 → bool
poolInfo 0x1526fe27 → address, uint256, uint256, uint256
poolLength 0x081e3eda → uint256
rewardOwner 0x85049c39 → address
rewardPerBlock 0x8ae39cac → uint256
rewardToken 0xf7c618c1 → address
totalAllocPoint 0x17caf6f1 → uint256
userInfo 0x93f1a40b → uint256, uint256
Write Contract 15 functions
These functions modify contract state and require a wallet transaction to execute.
addPool 0x7abceffd
uint256 _allocPoint
address _lpToken
bool _withUpdate
deposit 0x8dbdbe6d
uint256 pid
uint256 amount
address to
emergencyWithdraw 0x2f940c70
uint256 pid
address to
harvest 0x18fccc76
uint256 pid
address to
massUpdatePools 0x630b5ba1
No parameters
massUpdatePoolsByIds 0xd444d327
uint256[] pids
multicall 0xac9650d8
bytes[] data
returns: bytes[]
renounceOwnership 0x715018a6
No parameters
set 0x64482f79
uint256 _pid
uint256 _allocPoint
bool _withUpdate
setRewardOwner 0x4809b429
address _rewardOwner
setRewardToken 0x8aee8127
address _rewardToken
setRewardsPerBlock 0xa1003b29
uint256 _rewardPerBlock
transferOwnership 0xf2fde38b
address newOwner
updatePool 0x51eb05a6
uint256 pid
withdraw 0x0ad58d2f
uint256 pid
uint256 amount
address to
Recent Transactions
No transactions found for this address