Address Contract Verified
Address
0x39Ae84f831dAa1b5081371B6Dc81372f7Dee5fe8
Balance
0 ETH
Nonce
1
Code Size
4449 bytes
Creator
0x222d81F2...ebB5 at tx 0x8f8f3efe...8c3dd0
Indexed Transactions
0
Contract Bytecode
4449 bytes
0x608060405234801561001057600080fd5b506004361061012c5760003560e01c806398807d84116100ad578063ef40a67011610071578063ef40a6701461027b578063f2fde38b146102a4578063fb468ac3146102b7578063fc0c546a146102bf578063ff50abdc146102e657600080fd5b806398807d8414610205578063a5a302d314610225578063bd8d99f41461024c578063c771c3901461025f578063ee947a7c1461027257600080fd5b80636694fc25116100f45780636694fc251461019d578063715018a6146101bd5780637362377b146101c557806389476069146101cd5780638da5cb5b146101e057600080fd5b8063118ab4e1146101315780631d62ebd91461014d578063238a6d9e1461016057806329cc05cf14610180578063372500ab14610195575b600080fd5b61013a60015481565b6040519081526020015b60405180910390f35b61013a61015b366004610f44565b6102ee565b61013a61016e366004610f44565b60066020526000908152604090205481565b61019361018e366004610f74565b6102ff565b005b61019361038a565b61013a6101ab366004610f44565b60076020526000908152604090205481565b610193610395565b6101936103a7565b6101936101db366004610f44565b61043d565b6000546001600160a01b03165b6040516001600160a01b039091168152602001610144565b61013a610213366004610f44565b60046020526000908152604090205481565b6101ed7f000000000000000000000000a56ce568d5af16c379cfd41be98754f9b257ebc081565b61019361025a366004610fb4565b610524565b61019361026d366004610fd7565b610534565b61013a60035481565b61013a610289366004610f44565b6001600160a01b031660009081526004602052604090205490565b6101936102b2366004610f44565b610541565b6101936105b7565b6101ed7f00000000000000000000000089d584a1edb3a70b3b07963f9a3ea5399e38b13681565b60025461013a565b60006102f9826106de565b92915050565b337f000000000000000000000000a56ce568d5af16c379cfd41be98754f9b257ebc06001600160a01b03161461036b5760405162461bcd60e51b815260206004820152600c60248201526b155b985d5d1a1bdc9a5e995960a21b60448201526064015b60405180910390fd5b80156103805761037b8383610807565b505050565b61037b8383610972565b61039333610aa4565b565b61039d610b3f565b6103936000610b99565b6103af610b3f565b604051600090339047908381818185875af1925050503d80600081146103f1576040519150601f19603f3d011682016040523d82523d6000602084013e6103f6565b606091505b505090508061043a5760405162461bcd60e51b815260206004820152601060248201526f2a3930b739b332b9103330b4b632b21760811b6044820152606401610362565b50565b610445610b3f565b6040516370a0823160e01b81523060048201526000906001600160a01b038316906370a0823190602401602060405180830381865afa15801561048c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104b09190610ff0565b60405163a9059cbb60e01b8152336004820152602481018290529091506001600160a01b0383169063a9059cbb906044016020604051808303816000875af1158015610500573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061037b9190611009565b61052c610b3f565b60ff16600155565b61053c610b3f565b600355565b610549610b3f565b6001600160a01b0381166105ae5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610362565b61043a81610b99565b6105bf610b3f565b6002546040516370a0823160e01b8152306004820152600091906001600160a01b037f00000000000000000000000089d584a1edb3a70b3b07963f9a3ea5399e38b13616906370a0823190602401602060405180830381865afa15801561062a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061064e9190610ff0565b610658919061103c565b9050600081116106aa5760405162461bcd60e51b815260206004820152601f60248201527f4e6f20726573696475616c2042616c616e636520746f207769746864726177006044820152606401610362565b61043a7f00000000000000000000000089d584a1edb3a70b3b07963f9a3ea5399e38b1366001600160a01b03163383610be9565b6003546001600160a01b03821660009081526006602052604081205490918291610708904261103c565b116107135742610739565b6001600160a01b0383166000908152600660205260409020546003546107399190611053565b6001600160a01b038416600090815260076020526040812054919250908211610763576000610786565b6001600160a01b038416600090815260076020526040902054610786908361103c565b6001546001600160a01b038616600090815260046020526040812054929350916064916301e133809185916107ba9161106b565b6107c4919061106b565b6107ce919061108a565b6107d8919061108a565b6001600160a01b0386166000908152600560205260409020549091506107fe9082611053565b95945050505050565b600081116108575760405162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e20300000006044820152606401610362565b6001600160a01b0382166000908152600460205260409020548111156108bf5760405162461bcd60e51b815260206004820152601f60248201527f416d6f756e7420686967686572207468616e207374616b6564416d6f756e74006044820152606401610362565b6108c882610aa4565b80600260008282546108da919061103c565b90915550506001600160a01b0382166000908152600460205260408120805483929061090790849061103c565b90915550506001600160a01b0382166000818152600660209081526040808320429081905560079092529182902055517f884edad9ce6fa2440d8a54cc123490eb96d2768479d49ff9c7366125a9424364906109669084815260200190565b60405180910390a25050565b600081116109c25760405162461bcd60e51b815260206004820152601d60248201527f416d6f756e74206d7573742062652067726561746572207468616e20300000006044820152606401610362565b6001600160a01b0382166000908152600660205260409020546109fb576001600160a01b03821660009081526006602052604090204290555b610a0482610c3b565b6001600160a01b03821660009081526004602052604081208054839290610a2c908490611053565b925050819055508060026000828254610a459190611053565b90915550506001600160a01b0382166000818152600660209081526040808320429081905560079092529182902055517fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c906109669084815260200190565b610aad81610c3b565b6001600160a01b038116600090815260056020526040812080549190558015610b0457610b046001600160a01b037f00000000000000000000000089d584a1edb3a70b3b07963f9a3ea5399e38b136168383610be9565b816001600160a01b03167f47cee97cb7acd717b3c0aa1435d004cd5b3c8c57d70dbceb4e4458bbd60e39d48260405161096691815260200190565b6000546001600160a01b031633146103935760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610362565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b17905261037b908490610cc6565b610c44816106de565b6001600160a01b038216600090815260056020908152604080832093909355600354600690915291902054610c79904261103c565b11610c845742610caa565b6001600160a01b038116600090815260066020526040902054600354610caa9190611053565b6001600160a01b03909116600090815260076020526040902055565b6000610d1b826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610d9b9092919063ffffffff16565b9050805160001480610d3c575080806020019051810190610d3c9190611009565b61037b5760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610362565b6060610daa8484600085610db2565b949350505050565b606082471015610e135760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610362565b600080866001600160a01b03168587604051610e2f91906110dc565b60006040518083038185875af1925050503d8060008114610e6c576040519150601f19603f3d011682016040523d82523d6000602084013e610e71565b606091505b5091509150610e8287838387610e8d565b979650505050505050565b60608315610ef9578251610ef2576001600160a01b0385163b610ef25760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610362565b5081610daa565b610daa8383815115610f0e5781518083602001fd5b8060405162461bcd60e51b815260040161036291906110f8565b80356001600160a01b0381168114610f3f57600080fd5b919050565b600060208284031215610f5657600080fd5b610f5f82610f28565b9392505050565b801515811461043a57600080fd5b600080600060608486031215610f8957600080fd5b610f9284610f28565b9250602084013591506040840135610fa981610f66565b809150509250925092565b600060208284031215610fc657600080fd5b813560ff81168114610f5f57600080fd5b600060208284031215610fe957600080fd5b5035919050565b60006020828403121561100257600080fd5b5051919050565b60006020828403121561101b57600080fd5b8151610f5f81610f66565b634e487b7160e01b600052601160045260246000fd5b60008282101561104e5761104e611026565b500390565b6000821982111561106657611066611026565b500190565b600081600019048311821515161561108557611085611026565b500290565b6000826110a757634e487b7160e01b600052601260045260246000fd5b500490565b60005b838110156110c75781810151838201526020016110af565b838111156110d6576000848401525b50505050565b600082516110ee8184602087016110ac565b9190910192915050565b60208152600082518060208401526111178160408501602087016110ac565b601f01601f1916919091016040019291505056fea2646970667358221220aada5c620f0238a168f0b2dadf52e6274e17a722d9a0d726ed65bcdd7d1a6f8764736f6c634300080c0033
Verified Source Code Full Match
Compiler: v0.8.12+commit.f00d7308
EVM: london
Optimization: Yes (200 runs)
TokenStakingPool.sol 212 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import './interfaces/ITokenStakingPool.sol';
import './interfaces/IPoolExtension.sol';
/// @author www.github.com/jscrui
/// @title Staking Platform with fixed APY and lockup
contract TokenStakingPool is IPoolExtension, ITokenStakingPool, Ownable {
using SafeERC20 for IERC20;
address public immutable mainPool;
IERC20 public immutable token;
uint public fixedAPR;
uint private _totalStaked;
uint256 public lockupPeriod;
mapping(address => uint) public staked;
mapping(address => uint) private _rewardsToClaim;
mapping(address => uint) public _userStartTime;
mapping(address => uint) public _userStartClaim;
modifier onlyPool() {
require(_msgSender() == mainPool, 'Unauthorized');
_;
}
/**
* @notice constructor contains all the parameters of the staking platform
* @dev all parameters are immutable
* @param _token, address of the token to be staked
* @param _fixedAPR, the fixed APY (in %) 10 = 10%, 50 = 50%
*/
constructor(address _mainPool, IERC20 _token, uint _fixedAPR, uint256 _lockupPeriod) {
mainPool = _mainPool;
token = _token;
fixedAPR = _fixedAPR;
lockupPeriod = _lockupPeriod;
}
function setShare(
address wallet,
uint256 balanceChange,
bool isRemoving
) external override onlyPool {
if (isRemoving) {
_withdraw(wallet, balanceChange);
} else {
_deposit(wallet, balanceChange);
}
}
/**
* @notice function that allows a user to deposit tokens
* @dev user must first approve the amount to deposit before calling this function,
* cannot exceed the `maxAmountStaked`
* @param amount, the amount to be deposited
* @dev that the amount deposited should greater than 0
*/
function _deposit(address wallet, uint amount) internal {
require(amount > 0, 'Amount must be greater than 0');
if (_userStartTime[wallet] == 0) {
_userStartTime[wallet] = block.timestamp;
}
_updateRewards(wallet);
staked[wallet] += amount;
_totalStaked += amount;
_userStartTime[wallet] = block.timestamp;
_userStartClaim[wallet] = block.timestamp;
emit Deposit(wallet, amount);
}
/**
* @notice function that allows a user to withdraw its initial deposit
* @param amount, amount to withdraw
* @dev `amount` must be higher than `0`
* @dev `amount` must be lower or equal to the amount staked
* withdraw reset all states variable for the `msg.sender` to 0, and claim rewards
* if rewards to claim
*/
function _withdraw(address wallet, uint amount) internal {
require(amount > 0, 'Amount must be greater than 0');
require(amount <= staked[wallet], 'Amount higher than stakedAmount');
_claimRewards(wallet);
_totalStaked -= amount;
staked[wallet] -= amount;
_userStartTime[wallet] = block.timestamp;
_userStartClaim[wallet] = block.timestamp;
emit Withdraw(wallet, amount);
}
/**
* @notice claim all remaining balance on the contract
* Residual balance is all the remaining tokens that have not been distributed
* (e.g, in case the number of stakeholders is not sufficient)
* @dev Can only be called after the end of the staking period
* Cannot claim initial stakeholders deposit
*/
function withdrawResidualBalance() external onlyOwner {
uint residualBalance = token.balanceOf(address(this)) - _totalStaked;
require(residualBalance > 0, 'No residual Balance to withdraw');
token.safeTransfer(_msgSender(), residualBalance);
}
/**
* @notice function that allows the owner to set the APY
* @param _newAPR, the new APY to be set (in %) 10 = 10%, 50 = 50
*/
function setAPR(uint8 _newAPR) external onlyOwner {
fixedAPR = _newAPR;
}
function setLockupPeriod(uint256 _lockupPeriod) external onlyOwner {
lockupPeriod = _lockupPeriod;
}
function withdrawEther() external onlyOwner {
(bool success, ) = msg.sender.call{value: address(this).balance}("");
require(success, "Transfer failed.");
}
function withdrawToken(address _token) external onlyOwner {
uint256 amount = IERC20(_token).balanceOf(address(this));
IERC20(_token).transfer(msg.sender, amount);
}
/**
* @notice function that returns the amount of total Staked tokens
* for a specific user
* @param stakeHolder, address of the user to check
* @return uint amount of the total deposited Tokens by the caller
*/
function amountStaked(
address stakeHolder
) external view override returns (uint) {
return staked[stakeHolder];
}
/**
* @notice function that returns the amount of total Staked tokens
* on the smart contract
* @return uint amount of the total deposited Tokens
*/
function totalDeposited() external view override returns (uint) {
return _totalStaked;
}
/**
* @notice function that returns the amount of pending rewards
* that can be claimed by the user
* @param stakeHolder, address of the user to be checked
* @return uint amount of claimable rewards
*/
function rewardOf(address stakeHolder) external view override returns (uint) {
return _calculateRewards(stakeHolder);
}
/**
* @notice function that claims pending rewards
* @dev transfer the pending rewards to the `msg.sender`
*/
function claimRewards() external override {
_claimRewards(_msgSender());
}
/**
* @notice calculate rewards based on the `fixedAPR`
* @param stakeHolder, address of the user to be checked
* @return uint amount of claimable tokens of the specified address
*/
function _calculateRewards(address stakeHolder) internal view returns (uint) {
uint _timepoint = (block.timestamp - _userStartTime[stakeHolder]) > lockupPeriod ? lockupPeriod + _userStartTime[stakeHolder] : block.timestamp;
uint _timeStaked = _timepoint > _userStartClaim[stakeHolder] ? _timepoint - _userStartClaim[stakeHolder] : 0;
uint rewardOnRange = ((staked[stakeHolder] * fixedAPR * _timeStaked) / 365 days / 100);
return rewardOnRange + _rewardsToClaim[stakeHolder];
}
/**
* @notice internal function that claims pending rewards
* @dev transfer the pending rewards to the user address
*/
function _claimRewards(address stakeHolder) private {
_updateRewards(stakeHolder);
uint rewardsToClaim = _rewardsToClaim[stakeHolder];
// require(rewardsToClaim > 0, 'Nothing to claim');
_rewardsToClaim[stakeHolder] = 0;
if(rewardsToClaim > 0) token.safeTransfer(stakeHolder, rewardsToClaim);
emit Claim(stakeHolder, rewardsToClaim);
}
/**
* @notice function that update pending rewards
* and shift them to rewardsToClaim
* @dev update rewards claimable
* and check the time spent since deposit for the `msg.sender`
*/
function _updateRewards(address stakeHolder) private {
_rewardsToClaim[stakeHolder] = _calculateRewards(stakeHolder);
_userStartClaim[stakeHolder] = (block.timestamp - _userStartTime[stakeHolder]) > lockupPeriod ? lockupPeriod + _userStartTime[stakeHolder] : block.timestamp;
}
}
Address.sol 244 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @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
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 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://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/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 functionCallWithValue(target, data, 0, "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");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, 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) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @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 {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @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 {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_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);
}
}
IPoolExtension.sol 10 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IPoolExtension {
function setShare(
address wallet,
uint256 balanceChange,
bool isRemoving
) external;
}
IERC20.sol 78 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the 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 `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, 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 `from` to `to` 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 from, address to, uint256 amount) external returns (bool);
}
ITokenStakingPool.sol 56 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @author RetreebInc
/// @title Interface Staking Platform with fixed APY and lockup
interface ITokenStakingPool {
/**
* @notice function that returns the amount of total Staked tokens
* for a specific user
* @param stakeHolder, address of the user to check
* @return uint amount of the total deposited Tokens by the caller
*/
function amountStaked(address stakeHolder) external view returns (uint);
/**
* @notice function that returns the amount of total Staked tokens
* on the smart contract
* @return uint amount of the total deposited Tokens
*/
function totalDeposited() external view returns (uint);
/**
* @notice function that returns the amount of pending rewards
* that can be claimed by the user
* @param stakeHolder, address of the user to be checked
* @return uint amount of claimable rewards
*/
function rewardOf(address stakeHolder) external view returns (uint);
/**
* @notice function that claims pending rewards
* @dev transfer the pending rewards to the `msg.sender`
*/
function claimRewards() external;
/**
* @dev Emitted when `amount` tokens are deposited into
* staking platform
*/
event Deposit(address indexed owner, uint amount);
/**
* @dev Emitted when user withdraw deposited `amount`
*/
event Withdraw(address indexed owner, uint amount);
/**
* @dev Emitted when `stakeHolder` claim rewards
*/
event Claim(address indexed stakeHolder, uint amount);
/**
* @dev Emitted when staking has started
*/
event StartStaking(uint startPeriod, uint endingPeriod);
}
SafeERC20.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev 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.encodeWithSelector(token.transfer.selector, 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.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));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
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");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @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");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}
IERC20Permit.sol 90 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
Read Contract
_userStartClaim 0x6694fc25 → uint256
_userStartTime 0x238a6d9e → uint256
amountStaked 0xef40a670 → uint256
fixedAPR 0x118ab4e1 → uint256
lockupPeriod 0xee947a7c → uint256
mainPool 0xa5a302d3 → address
owner 0x8da5cb5b → address
rewardOf 0x1d62ebd9 → uint256
staked 0x98807d84 → uint256
token 0xfc0c546a → address
totalDeposited 0xff50abdc → uint256
Write Contract 9 functions
These functions modify contract state and require a wallet transaction to execute.
claimRewards 0x372500ab
No parameters
renounceOwnership 0x715018a6
No parameters
setAPR 0xbd8d99f4
uint8 _newAPR
setLockupPeriod 0xc771c390
uint256 _lockupPeriod
setShare 0x29cc05cf
address wallet
uint256 balanceChange
bool isRemoving
transferOwnership 0xf2fde38b
address newOwner
withdrawEther 0x7362377b
No parameters
withdrawResidualBalance 0xfb468ac3
No parameters
withdrawToken 0x89476069
address _token
Recent Transactions
No transactions found for this address