Address Contract Partially Verified
Address
0xdffB306174CB0d9d1aaF2D5512EE31229A3f6Ee7
Balance
0 ETH
Nonce
1
Code Size
6340 bytes
Creator
0xc79cC95f...571a at tx 0x780eeb31...2a84db
Indexed Transactions
0
Contract Bytecode
6340 bytes
0x608060405260043610610134575f3560e01c806380e17d87116100a8578063a59d616a1161006d578063a59d616a14610485578063b10c17e7146104a4578063dd059012146104b9578063e11400bb146104d8578063e6c681c3146104ec578063f2fde38b1461050b575f80fd5b806380e17d87146103d457806389e25d2b146103fb5780638da5cb5b14610442578063941d82d61461045e57806396db582a14610472575f80fd5b80634da6a556116100f95780634da6a5561461027a5780634e533572146102ae57806358a75b0d146103775780635b256ac21461038d57806361296c68146103a1578063715018a6146103c0575f80fd5b806303795679146101b7578063098d3228146101d65780630c51b88f146101fd5780631e1198381461021c57806344c7d6ef1461025b575f80fd5b366101b3573373d01607c3c5ecaba394d8be377a08590149325722146101b15760405162461bcd60e51b815260206004820152602760248201527f43616e6e6f742072656365697665204554482066726f6d206f7468657220636f6044820152666e74726163747360c81b60648201526084015b60405180910390fd5b005b5f80fd5b3480156101c2575f80fd5b506101b16101d136600461164d565b61052a565b3480156101e1575f80fd5b506101ea5f1981565b6040519081526020015b60405180910390f35b348015610208575f80fd5b506101b1610217366004611678565b610537565b348015610227575f80fd5b5061024373d01607c3c5ecaba394d8be377a0859014932572281565b6040516001600160a01b0390911681526020016101f4565b348015610266575f80fd5b506101b161027536600461164d565b6108d0565b348015610285575f80fd5b506101ea6102943660046116aa565b6001600160a01b03165f9081526004602052604090205490565b3480156102b9575f80fd5b506103366102c836600461164d565b60408051608080820183525f80835260208084018290528385018290526060938401829052948152600685528390208351918201845280546001600160a01b039081168352600182015416948201949094526002840154928101929092526003909201549181019190915290565b6040516101f4919081516001600160a01b03908116825260208084015190911690820152604080830151908201526060918201519181019190915260800190565b348015610382575f80fd5b506101ea62093a8081565b348015610398575f80fd5b506101ea600281565b3480156103ac575f80fd5b506101b16103bb3660046116aa565b610c1f565b3480156103cb575f80fd5b506101b1610f7a565b3480156103df575f80fd5b50610243732f39d218133afab8f2b819b1066c7e434ad94e9e81565b348015610406575f80fd5b506104326104153660046116aa565b6001600160a01b03165f9081526003602052604090205460ff1690565b60405190151581526020016101f4565b34801561044d575f80fd5b505f546001600160a01b0316610243565b348015610469575f80fd5b506002546101ea565b6101b161048036600461164d565b610f8d565b348015610490575f80fd5b506101b161049f3660046116cc565b611275565b3480156104af575f80fd5b506101ea60055481565b3480156104c4575f80fd5b506101b16104d33660046116aa565b6112df565b3480156104e3575f80fd5b506101ea603481565b3480156104f7575f80fd5b506101b16105063660046116aa565b611307565b348015610516575f80fd5b506101b16105253660046116aa565b61138e565b6105326113c8565b600555565b61053f6113f4565b5f82116105895760405162461bcd60e51b815260206004820152601860248201527743616e6e6f74207374616b65207a65726f20746f6b656e7360401b60448201526064016101a8565b60028110156105aa5760405162461bcd60e51b81526004016101a890611707565b60348111156105cb5760405162461bcd60e51b81526004016101a89061174b565b6001600160a01b0383165f9081526003602052604090205460ff1615156001146106375760405162461bcd60e51b815260206004820152601e60248201527f43616e6e6f74207374616b65206e6f6e2d616c6c6f77656420746f6b656e000060448201526064016101a8565b6001600160a01b03831661068d5760405162461bcd60e51b815260206004820152601760248201527f43616e6e6f74207374616b65206164647265737328302900000000000000000060448201526064016101a8565b60055442106106ae5760405162461bcd60e51b81526004016101a89061178e565b5f6106bc62093a80836117e4565b6106c690426117fb565b90506106d48433308661141e565b604080516080810182526001600160a01b03808716808352336020808501918252848601878152606086018a8152600280545f90815260068552898120985189549089166001600160a01b0319918216178a55955160018a01805491909916961695909517909655905194860194909455925160039094019390935582526004905290812080548592906107699084906117fb565b925050819055505f732f39d218133afab8f2b819b1066c7e434ad94e9e6001600160a01b031663026b1d5f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107c1573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107e5919061180e565b60405163617ba03760e01b81526001600160a01b038781166004830152602482018790523060448301525f60648301529192509082169063617ba037906084015f604051808303815f87803b15801561083c575f80fd5b505af115801561084e573d5f803e3d5ffd5b5050600254604080516001600160a01b038a168152602081018990523381830152606081019290925260808201879052517f0d1b57de846e37edc71baa7b5046bf618d408f15d06c7a0fc1e47df48337994693509081900360a0019150a160028054905f6108bb83611829565b919050555050506108cb60018055565b505050565b6108d86113f4565b5f81815260066020908152604091829020825160808101845281546001600160a01b039081168252600183015416928101839052600282015493810193909352600301546060830152331461096f5760405162461bcd60e51b815260206004820152601e60248201527f4f6e6c7920746865207374616b65206f776e65722063616e20636c61696d000060448201526064016101a8565b42816040015111156109d25760405162461bcd60e51b815260206004820152602660248201527f43616e206f6e6c7920636c61696d2061667465722074686520656e64206c6f636044820152656b2074696d6560d01b60648201526084016101a8565b80516001600160a01b0316610a565760608101516020820151604051630402806960e51b815273d01607c3c5ecaba394d8be377a08590149325722926380500d2092610a24925f929190600401611841565b5f604051808303815f87803b158015610a3b575f80fd5b505af1158015610a4d573d5f803e3d5ffd5b50505050610b4b565b5f732f39d218133afab8f2b819b1066c7e434ad94e9e6001600160a01b031663026b1d5f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610aa7573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610acb919061180e565b825160608401516020850151604051631a4ca37b60e21b81529394506001600160a01b038516936369328dec93610b089390929091600401611841565b6020604051808303815f875af1158015610b24573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b489190611864565b50505b5f82815260066020908152604080832080546001600160a01b03199081168255600182018054909116905560028101849055600301839055606084015184516001600160a01b0316845260049092528220805491929091610bad90849061187b565b90915550508051606080830151602080850151604080516001600160a01b03968716815292830193909352939093169083015281018390527f8dab6d35466ca3cba614bc5b262979b277949786977e81107f375f7e39f7734a9060800160405180910390a150610c1c60018055565b50565b610c276113f4565b610c2f6113c8565b6001600160a01b038116610d8057604051630402806960e51b815273d01607c3c5ecaba394d8be377a08590149325722906380500d2090610c79905f905f19903090600401611841565b5f604051808303815f87803b158015610c90575f80fd5b505af1158015610ca2573d5f803e3d5ffd5b50505f8052505060046020527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec548015610d465760405163474cf53d60e01b81525f60048201819052306024830152604482015273d01607c3c5ecaba394d8be377a085901493257229063474cf53d9083906064015f604051808303818588803b158015610d2e575f80fd5b505af1158015610d40573d5f803e3d5ffd5b50505050505b478015610d7957604051339082156108fc029083905f818181858888f19350505050158015610d77573d5f803e3d5ffd5b505b5050610f71565b5f732f39d218133afab8f2b819b1066c7e434ad94e9e6001600160a01b031663026b1d5f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610dd1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610df5919061180e565b604051631a4ca37b60e21b81529091506001600160a01b038216906369328dec90610e299085905f19903090600401611841565b6020604051808303815f875af1158015610e45573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610e699190611864565b506001600160a01b0382165f908152600460205260409020548015610ef25760405163617ba03760e01b81526001600160a01b038481166004830152602482018390523060448301525f606483015283169063617ba037906084015f604051808303815f87803b158015610edb575f80fd5b505af1158015610eed573d5f803e3d5ffd5b505050505b6040516370a0823160e01b81523060048201525f906001600160a01b038516906370a0823190602401602060405180830381865afa158015610f36573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610f5a9190611864565b90508015610f6d57610f6d84338361148b565b5050505b610c1c60018055565b610f826113c8565b610f8b5f6114bc565b565b610f956113f4565b5f3411610fdf5760405162461bcd60e51b815260206004820152601860248201527743616e6e6f74207374616b65207a65726f20746f6b656e7360401b60448201526064016101a8565b60028110156110005760405162461bcd60e51b81526004016101a890611707565b60348111156110215760405162461bcd60e51b81526004016101a89061174b565b5f805260036020527f3617319a054d772f909f7c479a2cebe5066e836a939412e32403c99029b92eff5460ff16151560011461109f5760405162461bcd60e51b815260206004820152601e60248201527f43616e6e6f74207374616b65206e6f6e2d616c6c6f77656420746f6b656e000060448201526064016101a8565b60055442106110c05760405162461bcd60e51b81526004016101a89061178e565b5f6110ce62093a80836117e4565b6110d890426117fb565b604080516080810182525f808252336020808401918252838501868152346060860181815260028054875260068552978620965187546001600160a01b03199081166001600160a01b039283161789559551600189018054909716911617909455905195850195909555905160039093019290925580805260049091527f17ef568e3e12ab5b9c7254a8d58478811de00f9e6eb34345acd53bf8fd09d3ec805493945091926111889084906117fb565b909155505060405163474cf53d60e01b81525f60048201819052306024830152604482015273d01607c3c5ecaba394d8be377a085901493257229063474cf53d9034906064015f604051808303818588803b1580156111e5575f80fd5b505af11580156111f7573d5f803e3d5ffd5b5050600254604080515f815234602082015233918101919091526060810191909152608081018690527f0d1b57de846e37edc71baa7b5046bf618d408f15d06c7a0fc1e47df483379946935060a001915061124f9050565b60405180910390a160028054905f61126683611829565b919050555050610c1c60018055565b61127d6113c8565b6001600160a01b0382165f81815260036020908152604091829020805460ff19168515159081179091558251938452908301527f616bc2acc1c0d253fb9cbb2474082fb6dbd7479f84ca9d7dbe8ffbd5e81823fc910160405180910390a15050565b6112e76113c8565b610c1c8173d01607c3c5ecaba394d8be377a085901493257225f1961150b565b61130f6113c8565b610c1c81732f39d218133afab8f2b819b1066c7e434ad94e9e6001600160a01b031663026b1d5f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611363573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611387919061180e565b5f1961150b565b6113966113c8565b6001600160a01b0381166113bf57604051631e4fbdf760e01b81525f60048201526024016101a8565b610c1c816114bc565b5f546001600160a01b03163314610f8b5760405163118cdaa760e01b81523360048201526024016101a8565b60026001540361141757604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b6040516001600160a01b0384811660248301528381166044830152606482018390526114859186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b038381831617835250505050611596565b50505050565b6040516001600160a01b038381166024830152604482018390526108cb91859182169063a9059cbb90606401611453565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b17905261155c8482611602565b611485576040516001600160a01b0384811660248301525f604483015261159091869182169063095ea7b390606401611453565b61148584825b5f8060205f8451602086015f885af1806115b5576040513d5f823e3d81fd5b50505f513d915081156115cc5780600114156115d9565b6001600160a01b0384163b155b1561148557604051635274afe760e01b81526001600160a01b03851660048201526024016101a8565b5f805f8060205f8651602088015f8a5af192503d91505f519050828015611641575081156116335780600114611641565b5f866001600160a01b03163b115b93505050505b92915050565b5f6020828403121561165d575f80fd5b5035919050565b6001600160a01b0381168114610c1c575f80fd5b5f805f6060848603121561168a575f80fd5b833561169581611664565b95602085013595506040909401359392505050565b5f602082840312156116ba575f80fd5b81356116c581611664565b9392505050565b5f80604083850312156116dd575f80fd5b82356116e881611664565b9150602083013580151581146116fc575f80fd5b809150509250929050565b60208082526024908201527f43616e6e6f74207374616b6520666f72206c657373207468616e2074776f207760408201526365656b7360e01b606082015260800190565b60208082526023908201527f43616e6e6f74207374616b6520666f72206d6f7265207468616e203532207765604082015262656b7360e81b606082015260800190565b60208082526022908201527f43616e6e6f74207374616b652061667465722066696e616c206c6f636b2074696040820152616d6560f01b606082015260800190565b634e487b7160e01b5f52601160045260245ffd5b8082028115828204841417611647576116476117d0565b80820180821115611647576116476117d0565b5f6020828403121561181e575f80fd5b81516116c581611664565b5f6001820161183a5761183a6117d0565b5060010190565b6001600160a01b0393841681526020810192909252909116604082015260600190565b5f60208284031215611874575f80fd5b5051919050565b81810381811115611647576116476117d056fea26469706673582212201c7e2fca7f6c840f273f185c16284541ac70d02533ce2ad7d595f792fb2d24f964736f6c634300081a0033
Verified Source Code Partial Match
Compiler: v0.8.26+commit.8a97fa7a
EVM: cancun
Optimization: Yes (200 runs)
StakingDD.sol 854 lines
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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);
}
// File: @openzeppelin/contracts/interfaces/IERC20.sol
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* 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[ERC 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);
}
// File: @openzeppelin/contracts/interfaces/IERC165.sol
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
// File: @openzeppelin/contracts/interfaces/IERC1363.sol
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
// File: @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
// OpenZeppelin Contracts (last updated v5.2.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 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 {
/**
* @dev An operation with an ERC-20 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.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
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.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
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.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
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 Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
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 {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
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 silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
// File: @openzeppelin/contracts/utils/Context.sol
// 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;
}
}
// File: @openzeppelin/contracts/access/Ownable.sol
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
/**
* @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.
*
* The initial owner is set to the address provided by the deployer. 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;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(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 {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// File: @openzeppelin/contracts/utils/ReentrancyGuard.sol
// OpenZeppelin Contracts (last updated v5.1.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 EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* 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;
}
}
// File: stakingdd.sol
pragma solidity ^0.8.0;
// Taken from https://raw.githubusercontent.com/aave/aave-v3-periphery/refs/heads/master/contracts/misc/interfaces/IWrappedTokenGatewayV3.sol
interface IWrappedTokenGatewayV3 {
function depositETH(address pool, address onBehalfOf, uint16 referralCode) external payable;
function withdrawETH(address pool, uint256 amount, address onBehalfOf) external;
}
// Taken from https://raw.githubusercontent.com/aave/aave-v3-core/refs/heads/master/contracts/interfaces/IPoolAddressesProvider.sol
// Stripped down to only the minimal functions we will be using
interface IPoolAddressesProvider {
/**
* @notice Returns the address of the Pool proxy.
* @return The Pool proxy address
*/
function getPool() external view returns (address);
}
// Taken from https://raw.githubusercontent.com/aave/aave-v3-core/refs/heads/master/contracts/interfaces/IPool.sol
/**
* @title IPool
* @author Aave
* @notice Defines the basic interface for an Aave Pool.
*/
interface IPool {
/**
* @notice Supplies an `amount` of underlying asset into the reserve, receiving in return overlying aTokens.
* - E.g. User supplies 100 USDC and gets in return 100 aUSDC
* @param asset The address of the underlying asset to supply
* @param amount The amount to be supplied
* @param onBehalfOf The address that will receive the aTokens, same as msg.sender if the user
* wants to receive them on his own wallet, or a different address if the beneficiary of aTokens
* is a different wallet
* @param referralCode Code used to register the integrator originating the operation, for potential rewards.
* 0 if the action is executed directly by the user, without any middle-man
*/
function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode) external;
/**
* @notice Withdraws an `amount` of underlying asset from the reserve, burning the equivalent aTokens owned
* E.g. User has 100 aUSDC, calls withdraw() and receives 100 USDC, burning the 100 aUSDC
* @param asset The address of the underlying asset to withdraw
* @param amount The underlying amount to be withdrawn
* - Send the value type(uint256).max in order to withdraw the whole aToken balance
* @param to The address that will receive the underlying, same as msg.sender if the user
* wants to receive it on his own wallet, or a different address if the beneficiary is a
* different wallet
* @return The final amount withdrawn
*/
function withdraw(address asset, uint256 amount, address to) external returns (uint256);
}
contract StakingDD is Ownable, ReentrancyGuard {
struct Stake {
IERC20 token; // token == address(0) means it's an ETH stake
address owner;
uint256 endLockTime;
uint256 amount;
}
uint256 private stakeIndex_ = 0;
uint256 public constant MAX_INT = 2**256 - 1;
mapping (IERC20 => bool) private allowedStake_;
mapping (IERC20 => uint256) private stakedAmount_;
uint256 public constant MIN_WEEKS = 2;
uint256 public constant MAX_WEEKS = 52;
uint256 public constant WEEK_IN_SECONDS = 604800;
uint256 public FINAL_LOCK_TIME = 1746057600;
mapping (uint256 => Stake) private stakeList_;
bool setStakingToken = false;
IPoolAddressesProvider public constant poolAddressesProvider = IPoolAddressesProvider(0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e);
IWrappedTokenGatewayV3 public constant wrappedTokenGateway = IWrappedTokenGatewayV3(0xd01607c3C5eCABa394D8be377a08590149325722);
constructor() Ownable(msg.sender) {}
event Staked(IERC20 token, uint256 amount, address owner, uint256 index, uint256 weeks_);
event Claimed(IERC20 token, uint256 amount, address owner, uint256 index);
event AllowedStakeChanged(IERC20 token, bool allowed);
function stakeEth(uint256 weeks_) nonReentrant external payable {
require(msg.value > 0, "Cannot stake zero tokens");
require(weeks_ >= MIN_WEEKS, "Cannot stake for less than two weeks");
require(weeks_ <= MAX_WEEKS, "Cannot stake for more than 52 weeks");
require(allowedStake_[IERC20(address(0))] == true, "Cannot stake non-allowed token");
require(block.timestamp < FINAL_LOCK_TIME, "Cannot stake after final lock time");
uint256 stakeFinalTime = block.timestamp + (weeks_ * WEEK_IN_SECONDS);
stakeList_[stakeIndex_] = Stake({
token: IERC20(address(0)),
owner: msg.sender,
endLockTime: stakeFinalTime,
amount: msg.value
});
stakedAmount_[IERC20(address(0))] += msg.value;
wrappedTokenGateway.depositETH{value: msg.value}(address(0), address(this), 0);
emit Staked(IERC20(address(0)), msg.value, msg.sender, stakeIndex_, weeks_);
stakeIndex_++;
}
function stake(IERC20 token, uint256 amount, uint256 weeks_) nonReentrant external {
require(amount > 0, "Cannot stake zero tokens");
require(weeks_ >= MIN_WEEKS, "Cannot stake for less than two weeks");
require(weeks_ <= MAX_WEEKS, "Cannot stake for more than 52 weeks");
require(allowedStake_[token] == true, "Cannot stake non-allowed token");
require(token != IERC20(address(0)), "Cannot stake address(0)");
require(block.timestamp < FINAL_LOCK_TIME, "Cannot stake after final lock time");
uint256 stakeFinalTime = block.timestamp + (weeks_ * WEEK_IN_SECONDS);
SafeERC20.safeTransferFrom(token, msg.sender, address(this), amount);
stakeList_[stakeIndex_] = Stake({
token: token,
owner: msg.sender,
endLockTime: stakeFinalTime,
amount: amount
});
stakedAmount_[token] += amount;
IPool pool = IPool(poolAddressesProvider.getPool());
pool.supply(address(token), amount, address(this), 0);
emit Staked(token, amount, msg.sender, stakeIndex_, weeks_);
stakeIndex_++;
}
function claimStake(uint256 index) nonReentrant external {
Stake memory currentStake = stakeList_[index];
require(currentStake.owner == msg.sender, "Only the stake owner can claim");
require(currentStake.endLockTime <= block.timestamp, "Can only claim after the end lock time");
if (currentStake.token == IERC20(address(0))) {
wrappedTokenGateway.withdrawETH(address(0), currentStake.amount, currentStake.owner);
} else {
IPool pool = IPool(poolAddressesProvider.getPool());
pool.withdraw(address(currentStake.token), currentStake.amount, currentStake.owner);
}
delete stakeList_[index];
stakedAmount_[currentStake.token] -= currentStake.amount;
emit Claimed(currentStake.token, currentStake.amount, currentStake.owner, index);
}
function claimAave(address tokenToClaim) nonReentrant onlyOwner external {
if (tokenToClaim == address(0)) {
wrappedTokenGateway.withdrawETH(address(0), MAX_INT, address(this));
// Redeposit the stakedAmount
uint256 stakedAmount = stakedAmount_[IERC20(address(0))];
if (stakedAmount > 0) {
wrappedTokenGateway.depositETH{value: stakedAmount}(address(0), address(this), 0);
}
// Send the extra tokens to the owner
uint256 balance = address(this).balance;
if (balance > 0) {
payable(msg.sender).transfer(balance);
}
} else {
IPool pool = IPool(poolAddressesProvider.getPool());
pool.withdraw(tokenToClaim, MAX_INT, address(this));
// We have succesfully withdraw all tokens, now we have to redeposit the already staked tokens
uint256 stakedAmount = stakedAmount_[IERC20(tokenToClaim)];
if (stakedAmount > 0) {
pool.supply(tokenToClaim, stakedAmount, address(this), 0);
}
// Then we can send the extra tokens to the user
uint256 balance = IERC20(tokenToClaim).balanceOf(address(this));
if (balance > 0) {
SafeERC20.safeTransfer(IERC20(tokenToClaim), msg.sender, balance);
}
}
}
function stakeInfo(uint256 index) view external returns (Stake memory) {
return stakeList_[index];
}
function stakeIndex() view external returns (uint256) {
return stakeIndex_;
}
function allowedStake(IERC20 tokenAddr) view external returns (bool) {
return allowedStake_[tokenAddr];
}
function setAllowedStake(IERC20 tokenAddr, bool boolean) onlyOwner external {
allowedStake_[tokenAddr] = boolean;
emit AllowedStakeChanged(tokenAddr, boolean);
}
function getStakedAmount(IERC20 token) view external returns (uint256) {
return stakedAmount_[token];
}
function setApproval(IERC20 token) onlyOwner external {
SafeERC20.forceApprove(token, address(poolAddressesProvider.getPool()), MAX_INT);
}
function setFinalLockTime(uint256 time) onlyOwner external {
FINAL_LOCK_TIME = time;
}
function setApprovalForGateway(IERC20 token) onlyOwner external {
SafeERC20.forceApprove(token, address(wrappedTokenGateway), MAX_INT);
}
receive() external payable {
// Can only receive from the wrappedTokenGateway
require (msg.sender == address(wrappedTokenGateway), "Cannot receive ETH from other contracts");
}
}
Read Contract
FINAL_LOCK_TIME 0xb10c17e7 → uint256
MAX_INT 0x098d3228 → uint256
MAX_WEEKS 0xe11400bb → uint256
MIN_WEEKS 0x5b256ac2 → uint256
WEEK_IN_SECONDS 0x58a75b0d → uint256
allowedStake 0x89e25d2b → bool
getStakedAmount 0x4da6a556 → uint256
owner 0x8da5cb5b → address
poolAddressesProvider 0x80e17d87 → address
stakeIndex 0x941d82d6 → uint256
stakeInfo 0x4e533572 → tuple
wrappedTokenGateway 0x1e119838 → address
Write Contract 10 functions
These functions modify contract state and require a wallet transaction to execute.
claimAave 0x61296c68
address tokenToClaim
claimStake 0x44c7d6ef
uint256 index
renounceOwnership 0x715018a6
No parameters
setAllowedStake 0xa59d616a
address tokenAddr
bool boolean
setApproval 0xe6c681c3
address token
setApprovalForGateway 0xdd059012
address token
setFinalLockTime 0x03795679
uint256 time
stake 0x0c51b88f
address token
uint256 amount
uint256 weeks_
stakeEth 0x96db582a
uint256 weeks_
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address