Contract
0x69a9b35498aB20083A39A79902b06085713c77e9
8
Contract Overview
Balance:
0 ETH
ETH Value:
$0.00
My Name Tag:
Not Available
[ Download CSV Export ]
Latest 25 internal transaction
[ Download CSV Export ]
Similar Match Source Code This contract matches the deployed ByteCode of the Source Code for Contract 0x558Df6Bb25F754Aea5fa2F3eD8e78E7AFE23a1A6 The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
BasicStakingStrategy
Compiler Version
v0.8.16+commit.07a7930e
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.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 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 { _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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.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 * ==== * * [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://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); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason 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 { // 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); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; // Interfaces import {IERC721Enumerable} from "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol"; import {IERC20} from "../external/interfaces/IERC20.sol"; // Structs import {Addresses, EpochData, EpochStrikeData, VaultCheckpoint} from "./SsovV3Structs.sol"; /// @title SSOV V3 interface interface ISsovV3 is IERC721Enumerable { function isPut() external view returns (bool); function currentEpoch() external view returns (uint256); function collateralPrecision() external view returns (uint256); function addresses() external view returns (Addresses memory); function collateralToken() external view returns (IERC20); function deposit( uint256 strikeIndex, uint256 amount, address to ) external returns (uint256 tokenId); function purchase( uint256 strikeIndex, uint256 amount, address to ) external returns (uint256 premium, uint256 totalFee); function settle( uint256 strikeIndex, uint256 amount, uint256 epoch, address to ) external returns (uint256 pnl); function withdraw(uint256 tokenId, address to) external returns ( uint256 collateralTokenWithdrawAmount, uint256[] memory rewardTokenWithdrawAmounts ); function getUnderlyingPrice() external view returns (uint256); function getCollateralPrice() external view returns (uint256); function getVolatility(uint256 _strike) external view returns (uint256); function calculatePremium( uint256 _strike, uint256 _amount, uint256 _expiry ) external view returns (uint256 premium); function calculatePnl( uint256 price, uint256 strike, uint256 amount, uint256 collateralExchangeRate ) external view returns (uint256); function calculatePurchaseFees(uint256 strike, uint256 amount) external view returns (uint256); function calculateSettlementFees(uint256 pnl) external view returns (uint256); function getEpochTimes(uint256 epoch) external view returns (uint256 start, uint256 end); function writePosition(uint256 tokenId) external view returns ( uint256 epoch, uint256 strike, uint256 collateralAmount, uint256 checkpointIndex, uint256[] memory rewardDistributionRatios ); function getEpochData(uint256 epoch) external view returns (EpochData memory); function getEpochStrikeData(uint256 epoch, uint256 strike) external view returns (EpochStrikeData memory); function getEpochStrikeCheckpointsLength(uint256 epoch, uint256 strike) external view returns (uint256); function checkpoints( uint256 epoch, uint256 strike, uint256 index ) external view returns (VaultCheckpoint memory); }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; struct Addresses { address feeStrategy; address stakingStrategy; address optionPricing; address priceOracle; address volatilityOracle; address feeDistributor; address optionsTokenImplementation; } struct EpochData { bool expired; uint256 startTime; uint256 expiry; uint256 settlementPrice; uint256 totalCollateralBalance; // Premium + Deposits from all strikes uint256 collateralExchangeRate; // Exchange rate for collateral to underlying (Only applicable to CALL options) uint256 settlementCollateralExchangeRate; // Exchange rate for collateral to underlying on settlement (Only applicable to CALL options) uint256[] strikes; uint256[] totalRewardsCollected; uint256[] rewardDistributionRatios; address[] rewardTokensToDistribute; } struct EpochStrikeData { address strikeToken; uint256 totalCollateral; uint256 activeCollateral; uint256 totalPremiums; uint256 checkpointPointer; uint256[] rewardStoredForPremiums; uint256[] rewardDistributionRatiosForPremiums; } struct VaultCheckpoint { uint256 activeCollateral; uint256 totalCollateral; uint256 accruedPremium; } struct WritePosition { uint256 epoch; uint256 strike; uint256 collateralAmount; uint256 checkpointIndex; uint256[] rewardDistributionRatios; }
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. * NOTE: Modified to include symbols and decimals. */ interface IERC20 { function totalSupply() external view returns (uint256); function symbol() external view returns (string memory); function decimals() external view returns (uint8); function balanceOf(address account) external view returns (uint256); function transfer(address recipient, uint256 amount) external returns (bool); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 amount) external returns (bool); function transferFrom( address sender, address recipient, uint256 amount ) external returns (bool); event Transfer(address indexed from, address indexed to, uint256 value); event Approval(address indexed owner, address indexed spender, uint256 value); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import {IERC20} from "../interfaces/IERC20.sol"; import {SafeMath} from "@openzeppelin/contracts/utils/math/SafeMath.sol"; import {Address} from "@openzeppelin/contracts/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 SafeMath for uint256; 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' // solhint-disable-next-line max-line-length 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).add( value ); _callOptionalReturn( token, abi.encodeWithSelector( token.approve.selector, spender, newAllowance ) ); } function safeDecreaseAllowance( IERC20 token, address spender, uint256 value ) internal { uint256 newAllowance = token.allowance(address(this), spender).sub( value, "SafeERC20: decreased allowance below zero" ); _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 // solhint-disable-next-line max-line-length require( abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed" ); } } }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; // Contracts import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; // Libraries import {SafeERC20} from "../external/libraries/SafeERC20.sol"; // Interfaces import {ISsovV3} from "../core/ISsovV3.sol"; import {IStakingStrategy} from "./IStakingStrategy.sol"; import {IERC20} from "../external/interfaces/IERC20.sol"; contract BasicStakingStrategy is IStakingStrategy, Ownable { using SafeERC20 for IERC20; mapping(uint256 => uint256) public rewardsPerEpoch; mapping(uint256 => uint256) public lastTimestamp; uint256 public balance; address[] public rewardTokens = new address[](1); address public immutable ssov; event NewRewards(uint256 epoch, uint256 rewards); event EmergencyWithdraw(address sender); constructor(address _ssov, address _rewardToken) { ssov = _ssov; rewardTokens[0] = _rewardToken; } function updateRewardsPerEpoch(uint256 _rewards, uint256 _epoch) external onlyOwner { rewardsPerEpoch[_epoch] = _rewards; emit NewRewards(_epoch, _rewards); } function getRewardTokens() external view returns (address[] memory) { return rewardTokens; } function stake(uint256 amount) external onlySsov(msg.sender) returns (uint256[] memory rewardTokenAmounts) { ISsovV3 _ssov = ISsovV3(ssov); uint256 epoch = _ssov.currentEpoch(); (uint256 startTime, uint256 expiry) = _ssov.getEpochTimes(epoch); require(block.timestamp < expiry, "Cannot stake after expiry"); uint256 rewardRate = rewardsPerEpoch[epoch] / (expiry - startTime); balance += amount; uint256 rewardsEmitted = rewardRate * (block.timestamp - startTime); rewardTokenAmounts = new uint256[](1); rewardTokenAmounts[0] = rewardsEmitted; emit Stake(msg.sender, amount, balance, rewardTokenAmounts); } function unstake() external onlySsov(msg.sender) returns (uint256[] memory rewardTokenAmounts) { ISsovV3 _ssov = ISsovV3(ssov); uint256 epoch = _ssov.currentEpoch(); rewardTokenAmounts = new uint256[](1); rewardTokenAmounts[0] = rewardsPerEpoch[epoch]; IERC20(rewardTokens[0]).safeTransfer( msg.sender, rewardsPerEpoch[epoch] ); emit Unstake(msg.sender, balance, rewardTokenAmounts); } /// @notice Transfers all funds to msg.sender /// @dev Can only be called by the owner /// @param tokens The list of erc20 tokens to withdraw /// @param transferNative Whether should transfer the native currency function emergencyWithdraw(address[] calldata tokens, bool transferNative) external onlyOwner { if (transferNative) payable(msg.sender).transfer(address(this).balance); IERC20 token; for (uint256 i = 0; i < tokens.length; i++) { token = IERC20(tokens[i]); token.safeTransfer(msg.sender, token.balanceOf(address(this))); } emit EmergencyWithdraw(msg.sender); } modifier onlySsov(address _sender) { require(_sender == ssov, "Sender must be the ssov"); _; } }
//SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; interface IStakingStrategy { function stake(uint256) external returns (uint256[] memory); function unstake() external returns (uint256[] memory); function getRewardTokens() external view returns (address[] memory); event Stake( address sender, uint256 amountStaked, uint256 totalStakedBalance, uint256[] totalRewardsArray ); event Unstake( address sender, uint256 amountUnstaked, uint256[] rewardTokenAmounts ); }
{ "evmVersion": "london", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 200 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
[{"inputs":[{"internalType":"address","name":"_ssov","type":"address"},{"internalType":"address","name":"_rewardToken","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"}],"name":"EmergencyWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"epoch","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"rewards","type":"uint256"}],"name":"NewRewards","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountStaked","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalStakedBalance","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"totalRewardsArray","type":"uint256[]"}],"name":"Stake","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountUnstaked","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"rewardTokenAmounts","type":"uint256[]"}],"name":"Unstake","type":"event"},{"inputs":[],"name":"balance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"bool","name":"transferNative","type":"bool"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getRewardTokens","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"lastTimestamp","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardTokens","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardsPerEpoch","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ssov","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[{"internalType":"uint256[]","name":"rewardTokenAmounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unstake","outputs":[{"internalType":"uint256[]","name":"rewardTokenAmounts","type":"uint256[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewards","type":"uint256"},{"internalType":"uint256","name":"_epoch","type":"uint256"}],"name":"updateRewardsPerEpoch","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
600160a081815260e06040529060c0602080368337505081516200002b92600492506020019062000113565b503480156200003957600080fd5b5060405162001283380380620012838339810160408190526200005c91620001b1565b6200006733620000c3565b6001600160a01b038216608052600480548291906000906200008d576200008d620001e9565b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055505050620001ff565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b8280548282559060005260206000209081019282156200016b579160200282015b828111156200016b57825182546001600160a01b0319166001600160a01b0390911617825560209092019160019091019062000134565b50620001799291506200017d565b5090565b5b808211156200017957600081556001016200017e565b80516001600160a01b0381168114620001ac57600080fd5b919050565b60008060408385031215620001c557600080fd5b620001d08362000194565b9150620001e06020840162000194565b90509250929050565b634e487b7160e01b600052603260045260246000fd5b60805161104c62000237600039600081816101800152818161022401528181610295015281816105d3015261063f015261104c6000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c80638355fc541161008c578063a694fc3a11610066578063a694fc3a146101d3578063b69ef8a8146101e6578063c4f59f9b146101ef578063f2fde38b1461020457600080fd5b80638355fc541461017b5780638da5cb5b146101a257806394cee7b3146101b357600080fd5b80632def6620146100d45780632e5eb29d146100f25780633368741814610107578063715018a6146101355780637bb7bed11461013d5780637c4b52cb14610168575b600080fd5b6100dc610217565b6040516100e99190610cd8565b60405180910390f35b610105610100366004610ceb565b6103f4565b005b610127610115366004610d0d565b60026020526000908152604090205481565b6040519081526020016100e9565b61010561044b565b61015061014b366004610d0d565b61045f565b6040516001600160a01b0390911681526020016100e9565b610105610176366004610d34565b610489565b6101507f000000000000000000000000000000000000000000000000000000000000000081565b6000546001600160a01b0316610150565b6101276101c1366004610d0d565b60016020526000908152604090205481565b6100dc6101e1366004610d0d565b6105c6565b61012760035481565b6101f761086c565b6040516100e99190610dba565b610105610212366004610e07565b6108ce565b6060336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001681146102915760405162461bcd60e51b815260206004820152601760248201527629b2b73232b91036bab9ba103132903a34329039b9b7bb60491b60448201526064015b60405180910390fd5b60007f000000000000000000000000000000000000000000000000000000000000000090506000816001600160a01b031663766718086040518163ffffffff1660e01b8152600401602060405180830381865afa1580156102f6573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061031a9190610e30565b6040805160018082528183019092529192506020808301908036833750505060008281526001602052604081205482519296509186919061035d5761035d610e49565b6020026020010181815250506103b1336001600084815260200190815260200160002054600460008154811061039557610395610e49565b6000918252602090912001546001600160a01b03169190610947565b7fe69f2c813fbacdba640c6e65761e2d4b772375f2fbe475137078d3ed850aff5733600354866040516103e693929190610e5f565b60405180910390a150505090565b6103fc61099e565b60008181526001602090815260409182902084905581518381529081018490527fb86e3e3978dde9fa5d4008534601be74ce40793f554fbc842b08631e20c61c95910160405180910390a15050565b61045361099e565b61045d60006109f8565b565b6004818154811061046f57600080fd5b6000918252602090912001546001600160a01b0316905081565b61049161099e565b80156104c55760405133904780156108fc02916000818181858888f193505050501580156104c3573d6000803e3d6000fd5b505b6000805b8381101561058c578484828181106104e3576104e3610e49565b90506020020160208101906104f89190610e07565b6040516370a0823160e01b815230600482015290925061057a9033906001600160a01b038516906370a0823190602401602060405180830381865afa158015610545573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105699190610e30565b6001600160a01b0385169190610947565b8061058481610ea5565b9150506104c9565b506040513381527f5e7b34819cd91b239220bec92fcfd3c10da2214ba13e4e2b1f6c9cfdbd68a9a29060200160405180910390a150505050565b6060336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016811461063b5760405162461bcd60e51b815260206004820152601760248201527629b2b73232b91036bab9ba103132903a34329039b9b7bb60491b6044820152606401610288565b60007f000000000000000000000000000000000000000000000000000000000000000090506000816001600160a01b031663766718086040518163ffffffff1660e01b8152600401602060405180830381865afa1580156106a0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106c49190610e30565b9050600080836001600160a01b0316636f56f56f846040518263ffffffff1660e01b81526004016106f791815260200190565b6040805180830381865afa158015610713573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107379190610ebe565b9150915080421061078a5760405162461bcd60e51b815260206004820152601960248201527f43616e6e6f74207374616b6520616674657220657870697279000000000000006044820152606401610288565b60006107968383610ee2565b6000858152600160205260409020546107af9190610efb565b905087600360008282546107c39190610f1d565b90915550600090506107d58442610ee2565b6107df9083610f30565b60408051600180825281830190925291925060208083019080368337019050509750808860008151811061081557610815610e49565b6020026020010181815250507ff129b07eb5effb6c354173bcbbef6ef8cbe16ba22a3207394dcd8e39314c3d39338a6003548b6040516108589493929190610f4f565b60405180910390a150505050505050919050565b606060048054806020026020016040519081016040528092919081815260200182805480156108c457602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116108a6575b5050505050905090565b6108d661099e565b6001600160a01b03811661093b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610288565b610944816109f8565b50565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b179052610999908490610a48565b505050565b6000546001600160a01b0316331461045d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610288565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000610a9d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316610b1a9092919063ffffffff16565b8051909150156109995780806020019051810190610abb9190610f86565b6109995760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610288565b6060610b298484600085610b33565b90505b9392505050565b606082471015610b945760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610288565b6001600160a01b0385163b610beb5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610288565b600080866001600160a01b03168587604051610c079190610fc7565b60006040518083038185875af1925050503d8060008114610c44576040519150601f19603f3d011682016040523d82523d6000602084013e610c49565b606091505b5091509150610c59828286610c64565b979650505050505050565b60608315610c73575081610b2c565b825115610c835782518084602001fd5b8160405162461bcd60e51b81526004016102889190610fe3565b600081518084526020808501945080840160005b83811015610ccd57815187529582019590820190600101610cb1565b509495945050505050565b602081526000610b2c6020830184610c9d565b60008060408385031215610cfe57600080fd5b50508035926020909101359150565b600060208284031215610d1f57600080fd5b5035919050565b801515811461094457600080fd5b600080600060408486031215610d4957600080fd5b833567ffffffffffffffff80821115610d6157600080fd5b818601915086601f830112610d7557600080fd5b813581811115610d8457600080fd5b8760208260051b8501011115610d9957600080fd5b60209283019550935050840135610daf81610d26565b809150509250925092565b6020808252825182820181905260009190848201906040850190845b81811015610dfb5783516001600160a01b031683529284019291840191600101610dd6565b50909695505050505050565b600060208284031215610e1957600080fd5b81356001600160a01b0381168114610b2c57600080fd5b600060208284031215610e4257600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b60018060a01b0384168152826020820152606060408201526000610e866060830184610c9d565b95945050505050565b634e487b7160e01b600052601160045260246000fd5b600060018201610eb757610eb7610e8f565b5060010190565b60008060408385031215610ed157600080fd5b505080516020909101519092909150565b81810381811115610ef557610ef5610e8f565b92915050565b600082610f1857634e487b7160e01b600052601260045260246000fd5b500490565b80820180821115610ef557610ef5610e8f565b6000816000190483118215151615610f4a57610f4a610e8f565b500290565b60018060a01b0385168152836020820152826040820152608060608201526000610f7c6080830184610c9d565b9695505050505050565b600060208284031215610f9857600080fd5b8151610b2c81610d26565b60005b83811015610fbe578181015183820152602001610fa6565b50506000910152565b60008251610fd9818460208701610fa3565b9190910192915050565b6020815260008251806020840152611002816040850160208701610fa3565b601f01601f1916919091016040019291505056fea26469706673582212208325a142604e93b43db880992628085fb08e0922ea710e22f29c0db71374e17364736f6c63430008100033000000000000000000000000fca61e79f38a7a82c62f469f55a9df54cb8df67800000000000000000000000013ad51ed4f1b7e9dc168d8a00cb3f4ddd85efa60
Age | Block | Fee Address | BC Fee Address | Voting Power | Jailed | Incoming |
---|
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.