Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
Loading...
Loading
Contract Name:
OsTokenVaultController
Compiler Version
v0.8.22+commit.4fc1097e
Optimization Enabled:
Yes with 200 runs
Other Settings:
shanghai EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.22; import {Ownable2Step, Ownable} from '@openzeppelin/contracts/access/Ownable2Step.sol'; import {SafeCast} from '@openzeppelin/contracts/utils/math/SafeCast.sol'; import {Math} from '@openzeppelin/contracts/utils/math/Math.sol'; import {Errors} from '../libraries/Errors.sol'; import {IVaultsRegistry} from '../interfaces/IVaultsRegistry.sol'; import {IOsToken} from '../interfaces/IOsToken.sol'; import {IVaultVersion} from '../interfaces/IVaultVersion.sol'; import {IOsTokenVaultController} from '../interfaces/IOsTokenVaultController.sol'; /** * @title OsTokenVaultController * @author StakeWise * @notice Over-collateralized staked token controller */ contract OsTokenVaultController is Ownable2Step, IOsTokenVaultController { uint256 private constant _wad = 1e18; uint256 private constant _maxFeePercent = 10_000; // @dev 100.00 % address private immutable _registry; address private immutable _osToken; /// @inheritdoc IOsTokenVaultController address public override keeper; /// @inheritdoc IOsTokenVaultController uint256 public override capacity; /// @inheritdoc IOsTokenVaultController uint256 public override avgRewardPerSecond; /// @inheritdoc IOsTokenVaultController address public override treasury; /// @inheritdoc IOsTokenVaultController uint64 public override feePercent; uint192 private _cumulativeFeePerShare = uint192(_wad); uint64 private _lastUpdateTimestamp; uint128 private _totalShares; uint128 private _totalAssets; /** * @dev Constructor * @param _keeper The address of the Keeper contract * @param registry The address of the VaultsRegistry contract * @param osToken The address of the OsToken contract * @param _treasury The address of the DAO treasury * @param _owner The address of the owner of the contract * @param _feePercent The fee percent applied on the rewards * @param _capacity The amount after which the osToken stops accepting deposits */ constructor( address _keeper, address registry, address osToken, address _treasury, address _owner, uint16 _feePercent, uint256 _capacity ) Ownable(msg.sender) { if (_owner == address(0)) revert Errors.ZeroAddress(); keeper = _keeper; _registry = registry; _osToken = osToken; _lastUpdateTimestamp = uint64(block.timestamp); setCapacity(_capacity); setTreasury(_treasury); setFeePercent(_feePercent); _transferOwnership(_owner); } /// @inheritdoc IOsTokenVaultController function totalShares() external view override returns (uint256) { return _totalShares; } /// @inheritdoc IOsTokenVaultController function totalAssets() public view override returns (uint256) { uint256 profitAccrued = _unclaimedAssets(); if (profitAccrued == 0) return _totalAssets; uint256 treasuryAssets = Math.mulDiv(profitAccrued, feePercent, _maxFeePercent); return _totalAssets + profitAccrued - treasuryAssets; } /// @inheritdoc IOsTokenVaultController function convertToShares(uint256 assets) public view override returns (uint256 shares) { return _convertToShares(assets, _totalShares, totalAssets(), Math.Rounding.Floor); } /// @inheritdoc IOsTokenVaultController function convertToAssets(uint256 shares) public view override returns (uint256 assets) { return _convertToAssets(shares, _totalShares, totalAssets(), Math.Rounding.Floor); } /// @inheritdoc IOsTokenVaultController function mintShares(address receiver, uint256 shares) external override returns (uint256 assets) { if ( !IVaultsRegistry(_registry).vaults(msg.sender) || !IVaultsRegistry(_registry).vaultImpls(IVaultVersion(msg.sender).implementation()) ) { revert Errors.AccessDenied(); } if (receiver == address(0)) revert Errors.ZeroAddress(); if (shares == 0) revert Errors.InvalidShares(); // pull accumulated rewards updateState(); // calculate amount of assets to mint assets = convertToAssets(shares); uint256 totalAssetsAfter = _totalAssets + assets; if (totalAssetsAfter > capacity) revert Errors.CapacityExceeded(); // update counters _totalShares += SafeCast.toUint128(shares); _totalAssets = SafeCast.toUint128(totalAssetsAfter); // mint shares IOsToken(_osToken).mint(receiver, shares); emit Mint(msg.sender, receiver, assets, shares); } /// @inheritdoc IOsTokenVaultController function burnShares(address owner, uint256 shares) external override returns (uint256 assets) { if (!IVaultsRegistry(_registry).vaults(msg.sender)) revert Errors.AccessDenied(); if (shares == 0) revert Errors.InvalidShares(); // pull accumulated rewards updateState(); // calculate amount of assets to burn assets = convertToAssets(shares); // burn shares IOsToken(_osToken).burn(owner, shares); // update counters unchecked { // cannot underflow because the sum of all shares can't exceed the _totalShares _totalShares -= SafeCast.toUint128(shares); // cannot underflow because the sum of all assets can't exceed the _totalAssets _totalAssets -= SafeCast.toUint128(assets); } emit Burn(msg.sender, owner, assets, shares); } /// @inheritdoc IOsTokenVaultController function setCapacity(uint256 _capacity) public override onlyOwner { // update os token capacity capacity = _capacity; emit CapacityUpdated(_capacity); } /// @inheritdoc IOsTokenVaultController function setTreasury(address _treasury) public override onlyOwner { if (_treasury == address(0)) revert Errors.ZeroAddress(); // update DAO treasury address treasury = _treasury; emit TreasuryUpdated(_treasury); } /// @inheritdoc IOsTokenVaultController function setFeePercent(uint16 _feePercent) public override onlyOwner { if (_feePercent > _maxFeePercent) revert Errors.InvalidFeePercent(); // pull reward with the current fee percent updateState(); // update fee percent feePercent = _feePercent; emit FeePercentUpdated(_feePercent); } /// @inheritdoc IOsTokenVaultController function setAvgRewardPerSecond(uint256 _avgRewardPerSecond) external override { if (msg.sender != keeper) revert Errors.AccessDenied(); updateState(); avgRewardPerSecond = _avgRewardPerSecond; emit AvgRewardPerSecondUpdated(_avgRewardPerSecond); } /// @inheritdoc IOsTokenVaultController function setKeeper(address _keeper) external override onlyOwner { if (_keeper == address(0)) revert Errors.ZeroAddress(); keeper = _keeper; emit KeeperUpdated(_keeper); } /// @inheritdoc IOsTokenVaultController function cumulativeFeePerShare() external view override returns (uint256) { // SLOAD to memory uint256 currCumulativeFeePerShare = _cumulativeFeePerShare; // calculate rewards uint256 profitAccrued = _unclaimedAssets(); if (profitAccrued == 0) return currCumulativeFeePerShare; // calculate treasury assets uint256 treasuryAssets = Math.mulDiv(profitAccrued, feePercent, _maxFeePercent); if (treasuryAssets == 0) return currCumulativeFeePerShare; // SLOAD to memory uint256 totalShares_ = _totalShares; // calculate treasury shares uint256 treasuryShares; unchecked { treasuryShares = _convertToShares( treasuryAssets, totalShares_, // cannot underflow because profitAccrued >= treasuryAssets _totalAssets + profitAccrued - treasuryAssets, Math.Rounding.Floor ); } return currCumulativeFeePerShare + Math.mulDiv(treasuryShares, _wad, totalShares_); } /// @inheritdoc IOsTokenVaultController function updateState() public override { // calculate rewards uint256 profitAccrued = _unclaimedAssets(); // check whether any profit accrued if (profitAccrued == 0) { if (_lastUpdateTimestamp != block.timestamp) { _lastUpdateTimestamp = uint64(block.timestamp); } return; } // calculate treasury assets uint256 newTotalAssets = _totalAssets + profitAccrued; uint256 treasuryAssets = Math.mulDiv(profitAccrued, feePercent, _maxFeePercent); if (treasuryAssets == 0) { // no treasury assets _lastUpdateTimestamp = uint64(block.timestamp); _totalAssets = SafeCast.toUint128(newTotalAssets); return; } // SLOAD to memory uint256 totalShares_ = _totalShares; // calculate treasury shares uint256 treasuryShares; unchecked { treasuryShares = _convertToShares( treasuryAssets, totalShares_, // cannot underflow because newTotalAssets >= treasuryAssets newTotalAssets - treasuryAssets, Math.Rounding.Floor ); } // SLOAD to memory address _treasury = treasury; // mint shares to the fee recipient IOsToken(_osToken).mint(_treasury, treasuryShares); // update state _cumulativeFeePerShare += SafeCast.toUint192(Math.mulDiv(treasuryShares, _wad, totalShares_)); _lastUpdateTimestamp = uint64(block.timestamp); _totalAssets = SafeCast.toUint128(newTotalAssets); _totalShares = SafeCast.toUint128(totalShares_ + treasuryShares); emit StateUpdated(profitAccrued, treasuryShares, treasuryAssets); } /** * @dev Internal conversion function (from assets to shares) with support for rounding direction. */ function _convertToShares( uint256 assets, uint256 totalShares_, uint256 totalAssets_, Math.Rounding rounding ) internal pure returns (uint256 shares) { // Will revert if assets > 0, totalShares > 0 and totalAssets = 0. // That corresponds to a case where any asset would represent an infinite amount of shares. return (assets == 0 || totalShares_ == 0) ? assets : Math.mulDiv(assets, totalShares_, totalAssets_, rounding); } /** * @dev Internal conversion function (from shares to assets) with support for rounding direction. */ function _convertToAssets( uint256 shares, uint256 totalShares_, uint256 totalAssets_, Math.Rounding rounding ) internal pure returns (uint256) { return (totalShares_ == 0) ? shares : Math.mulDiv(shares, totalAssets_, totalShares_, rounding); } /** * @dev Internal function for calculating assets accumulated since last update */ function _unclaimedAssets() internal view returns (uint256) { // calculate time passed since the last update uint256 timeElapsed; unchecked { // cannot realistically underflow timeElapsed = block.timestamp - _lastUpdateTimestamp; } if (timeElapsed == 0) return 0; return Math.mulDiv(avgRewardPerSecond * _totalAssets, timeElapsed, _wad); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../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. * * 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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol) pragma solidity ^0.8.20; import {Ownable} from "./Ownable.sol"; /** * @dev Contract module which provides access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is specified at deployment time in the constructor for `Ownable`. This * can later be changed with {transferOwnership} and {acceptOwnership}. * * This module is used through inheritance. It will make available all functions * from parent (Ownable). */ abstract contract Ownable2Step is Ownable { address private _pendingOwner; event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner); /** * @dev Returns the address of the pending owner. */ function pendingOwner() public view virtual returns (address) { return _pendingOwner; } /** * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual override onlyOwner { _pendingOwner = newOwner; emit OwnershipTransferStarted(owner(), newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner. * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual override { delete _pendingOwner; super._transferOwnership(newOwner); } /** * @dev The new owner accepts the ownership transfer. */ function acceptOwnership() public virtual { address sender = _msgSender(); if (pendingOwner() != sender) { revert OwnableUnauthorizedAccount(sender); } _transferOwnership(sender); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC1822.sol) pragma solidity ^0.8.20; /** * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified * proxy whose upgrades are fully controlled by the current implementation. */ interface IERC1822Proxiable { /** * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation * address. * * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this * function revert if invoked through a proxy. */ function proxiableUUID() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol) pragma solidity ^0.8.20; interface IERC5267 { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (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; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.22; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import {IERC20Permit} from '@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol'; import {IERC20Metadata} from '@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol'; import {IERC5267} from '@openzeppelin/contracts/interfaces/IERC5267.sol'; /** * @title IOsToken * @author StakeWise * @notice Defines the interface for the OsToken contract */ interface IOsToken is IERC20, IERC20Metadata, IERC20Permit, IERC5267 { /** * @notice Emitted when a controller is updated * @param controller The address of the controller * @param registered Whether the controller is registered or not */ event ControllerUpdated(address indexed controller, bool registered); /** * @notice Returns whether controller is registered or not * @param controller The address of the controller * @return Whether the controller is registered or not */ function controllers(address controller) external view returns (bool); /** * @notice Mint OsToken. Can only be called by the controller. * @param account The address of the account to mint OsToken for * @param value The amount of OsToken to mint */ function mint(address account, uint256 value) external; /** * @notice Burn OsToken. Can only be called by the controller. * @param account The address of the account to burn OsToken for * @param value The amount of OsToken to burn */ function burn(address account, uint256 value) external; /** * @notice Enable or disable the controller. Can only be called by the contract owner. * @param controller The address of the controller * @param registered Whether the controller is registered or not */ function setController(address controller, bool registered) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.22; /** * @title IOsTokenVaultController * @author StakeWise * @notice Defines the interface for the OsTokenVaultController contract */ interface IOsTokenVaultController { /** * @notice Event emitted on minting shares * @param vault The address of the Vault * @param receiver The address that received the shares * @param assets The number of assets collateralized * @param shares The number of tokens the owner received */ event Mint(address indexed vault, address indexed receiver, uint256 assets, uint256 shares); /** * @notice Event emitted on burning shares * @param vault The address of the Vault * @param owner The address that owns the shares * @param assets The total number of assets withdrawn * @param shares The total number of shares burned */ event Burn(address indexed vault, address indexed owner, uint256 assets, uint256 shares); /** * @notice Event emitted on state update * @param profitAccrued The profit accrued since the last update * @param treasuryShares The number of shares minted for the treasury * @param treasuryAssets The number of assets minted for the treasury */ event StateUpdated(uint256 profitAccrued, uint256 treasuryShares, uint256 treasuryAssets); /** * @notice Event emitted on capacity update * @param capacity The amount after which the OsToken stops accepting deposits */ event CapacityUpdated(uint256 capacity); /** * @notice Event emitted on treasury address update * @param treasury The new treasury address */ event TreasuryUpdated(address indexed treasury); /** * @notice Event emitted on fee percent update * @param feePercent The new fee percent */ event FeePercentUpdated(uint16 feePercent); /** * @notice Event emitted on average reward per second update * @param avgRewardPerSecond The new average reward per second */ event AvgRewardPerSecondUpdated(uint256 avgRewardPerSecond); /** * @notice Event emitted on keeper address update * @param keeper The new keeper address */ event KeeperUpdated(address keeper); /** * @notice The OsToken capacity * @return The amount after which the OsToken stops accepting deposits */ function capacity() external view returns (uint256); /** * @notice The DAO treasury address that receives OsToken fees * @return The address of the treasury */ function treasury() external view returns (address); /** * @notice The fee percent (multiplied by 100) * @return The fee percent applied by the OsToken on the rewards */ function feePercent() external view returns (uint64); /** * @notice The address that can update avgRewardPerSecond * @return The address of the keeper contract */ function keeper() external view returns (address); /** * @notice The average reward per second used to mint OsToken rewards * @return The average reward per second earned by the Vaults */ function avgRewardPerSecond() external view returns (uint256); /** * @notice The fee per share used for calculating the fee for every position * @return The cumulative fee per share */ function cumulativeFeePerShare() external view returns (uint256); /** * @notice The total number of shares controlled by the OsToken * @return The total number of shares */ function totalShares() external view returns (uint256); /** * @notice Total assets controlled by the OsToken * @return The total amount of the underlying asset that is "managed" by OsToken */ function totalAssets() external view returns (uint256); /** * @notice Converts shares to assets * @param assets The amount of assets to convert to shares * @return shares The amount of shares that the OsToken would exchange for the amount of assets provided */ function convertToShares(uint256 assets) external view returns (uint256 shares); /** * @notice Converts assets to shares * @param shares The amount of shares to convert to assets * @return assets The amount of assets that the OsToken would exchange for the amount of shares provided */ function convertToAssets(uint256 shares) external view returns (uint256 assets); /** * @notice Updates rewards and treasury fee checkpoint for the OsToken */ function updateState() external; /** * @notice Mint OsToken shares. Can only be called by the registered vault. * @param receiver The address that will receive the shares * @param shares The amount of shares to mint * @return assets The amount of assets minted */ function mintShares(address receiver, uint256 shares) external returns (uint256 assets); /** * @notice Burn shares for withdrawn assets. Can only be called by the registered vault. * @param owner The address that owns the shares * @param shares The amount of shares to burn * @return assets The amount of assets withdrawn */ function burnShares(address owner, uint256 shares) external returns (uint256 assets); /** * @notice Update treasury address. Can only be called by the owner. * @param _treasury The new treasury address */ function setTreasury(address _treasury) external; /** * @notice Update capacity. Can only be called by the owner. * @param _capacity The amount after which the OsToken stops accepting deposits */ function setCapacity(uint256 _capacity) external; /** * @notice Update fee percent. Can only be called by the owner. Cannot be larger than 10 000 (100%). * @param _feePercent The new fee percent */ function setFeePercent(uint16 _feePercent) external; /** * @notice Update keeper address. Can only be called by the owner. * @param _keeper The new keeper address */ function setKeeper(address _keeper) external; /** * @notice Updates average reward per second. Can only be called by the keeper. * @param _avgRewardPerSecond The new average reward per second */ function setAvgRewardPerSecond(uint256 _avgRewardPerSecond) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.22; /** * @title IVaultState * @author StakeWise * @notice Defines the interface for the VaultAdmin contract */ interface IVaultAdmin { /** * @notice Event emitted on metadata ipfs hash update * @param caller The address of the function caller * @param metadataIpfsHash The new metadata IPFS hash */ event MetadataUpdated(address indexed caller, string metadataIpfsHash); /** * @notice The Vault admin * @return The address of the Vault admin */ function admin() external view returns (address); /** * @notice Function for updating the metadata IPFS hash. Can only be called by Vault admin. * @param metadataIpfsHash The new metadata IPFS hash */ function setMetadata(string calldata metadataIpfsHash) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.22; /** * @title IVaultsRegistry * @author StakeWise * @notice Defines the interface for the VaultsRegistry */ interface IVaultsRegistry { /** * @notice Event emitted on a Vault addition * @param caller The address that has added the Vault * @param vault The address of the added Vault */ event VaultAdded(address indexed caller, address indexed vault); /** * @notice Event emitted on adding Vault implementation contract * @param impl The address of the new implementation contract */ event VaultImplAdded(address indexed impl); /** * @notice Event emitted on removing Vault implementation contract * @param impl The address of the removed implementation contract */ event VaultImplRemoved(address indexed impl); /** * @notice Event emitted on whitelisting the factory * @param factory The address of the whitelisted factory */ event FactoryAdded(address indexed factory); /** * @notice Event emitted on removing the factory from the whitelist * @param factory The address of the factory removed from the whitelist */ event FactoryRemoved(address indexed factory); /** * @notice Registered Vaults * @param vault The address of the vault to check whether it is registered * @return `true` for the registered Vault, `false` otherwise */ function vaults(address vault) external view returns (bool); /** * @notice Registered Vault implementations * @param impl The address of the vault implementation * @return `true` for the registered implementation, `false` otherwise */ function vaultImpls(address impl) external view returns (bool); /** * @notice Registered Factories * @param factory The address of the factory to check whether it is whitelisted * @return `true` for the whitelisted Factory, `false` otherwise */ function factories(address factory) external view returns (bool); /** * @notice Function for adding Vault to the registry. Can only be called by the whitelisted Factory. * @param vault The address of the Vault to add */ function addVault(address vault) external; /** * @notice Function for adding Vault implementation contract * @param newImpl The address of the new implementation contract */ function addVaultImpl(address newImpl) external; /** * @notice Function for removing Vault implementation contract * @param impl The address of the removed implementation contract */ function removeVaultImpl(address impl) external; /** * @notice Function for adding the factory to the whitelist * @param factory The address of the factory to add to the whitelist */ function addFactory(address factory) external; /** * @notice Function for removing the factory from the whitelist * @param factory The address of the factory to remove from the whitelist */ function removeFactory(address factory) external; /** * @notice Function for initializing the registry. Can only be called once during the deployment. * @param _owner The address of the owner of the contract */ function initialize(address _owner) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.22; import {IERC1822Proxiable} from '@openzeppelin/contracts/interfaces/draft-IERC1822.sol'; import {IVaultAdmin} from './IVaultAdmin.sol'; /** * @title IVaultVersion * @author StakeWise * @notice Defines the interface for VaultVersion contract */ interface IVaultVersion is IERC1822Proxiable, IVaultAdmin { /** * @notice Vault Unique Identifier * @return The unique identifier of the Vault */ function vaultId() external pure returns (bytes32); /** * @notice Version * @return The version of the Vault implementation contract */ function version() external pure returns (uint8); /** * @notice Implementation * @return The address of the Vault implementation contract */ function implementation() external view returns (address); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity =0.8.22; /** * @title Errors * @author StakeWise * @notice Contains all the custom errors */ library Errors { error AccessDenied(); error InvalidShares(); error InvalidAssets(); error ZeroAddress(); error InsufficientAssets(); error CapacityExceeded(); error InvalidCapacity(); error InvalidSecurityDeposit(); error InvalidFeeRecipient(); error InvalidFeePercent(); error NotHarvested(); error NotCollateralized(); error Collateralized(); error InvalidProof(); error LowLtv(); error RedemptionExceeded(); error InvalidPosition(); error InvalidLtv(); error InvalidHealthFactor(); error InvalidReceivedAssets(); error InvalidTokenMeta(); error UpgradeFailed(); error InvalidValidator(); error InvalidValidators(); error WhitelistAlreadyUpdated(); error DeadlineExpired(); error PermitInvalidSigner(); error InvalidValidatorsRegistryRoot(); error InvalidVault(); error AlreadyAdded(); error AlreadyRemoved(); error InvalidOracles(); error NotEnoughSignatures(); error InvalidOracle(); error TooEarlyUpdate(); error InvalidAvgRewardPerSecond(); error InvalidRewardsRoot(); error HarvestFailed(); error InvalidRedeemFromLtvPercent(); error InvalidLiqThresholdPercent(); error InvalidLiqBonusPercent(); error InvalidLtvPercent(); error InvalidCheckpointIndex(); error InvalidCheckpointValue(); error MaxOraclesExceeded(); error ClaimTooEarly(); }
{ "viaIR": true, "optimizer": { "enabled": true, "runs": 200, "details": { "yul": true } }, "evmVersion": "shanghai", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"inputs":[{"internalType":"address","name":"_keeper","type":"address"},{"internalType":"address","name":"registry","type":"address"},{"internalType":"address","name":"osToken","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint16","name":"_feePercent","type":"uint16"},{"internalType":"uint256","name":"_capacity","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessDenied","type":"error"},{"inputs":[],"name":"CapacityExceeded","type":"error"},{"inputs":[],"name":"InvalidFeePercent","type":"error"},{"inputs":[],"name":"InvalidShares","type":"error"},{"inputs":[],"name":"MathOverflowedMulDiv","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[],"name":"ZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"avgRewardPerSecond","type":"uint256"}],"name":"AvgRewardPerSecondUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"vault","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"capacity","type":"uint256"}],"name":"CapacityUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint16","name":"feePercent","type":"uint16"}],"name":"FeePercentUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"keeper","type":"address"}],"name":"KeeperUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"vault","type":"address"},{"indexed":true,"internalType":"address","name":"receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"assets","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"shares","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","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":"uint256","name":"profitAccrued","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"treasuryShares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"treasuryAssets","type":"uint256"}],"name":"StateUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"treasury","type":"address"}],"name":"TreasuryUpdated","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"avgRewardPerSecond","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"burnShares","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"capacity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"convertToAssets","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"name":"convertToShares","outputs":[{"internalType":"uint256","name":"shares","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cumulativeFeePerShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feePercent","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"keeper","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"shares","type":"uint256"}],"name":"mintShares","outputs":[{"internalType":"uint256","name":"assets","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_avgRewardPerSecond","type":"uint256"}],"name":"setAvgRewardPerSecond","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_capacity","type":"uint256"}],"name":"setCapacity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_feePercent","type":"uint16"}],"name":"setFeePercent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_keeper","type":"address"}],"name":"setKeeper","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_treasury","type":"address"}],"name":"setTreasury","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalAssets","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"updateState","outputs":[],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
60c0346200027257601f62001a8338819003918201601f191683019291906001600160401b0384118385101762000276578160e09284926040968752833981010312620002725762000051816200028a565b9062000060602082016200028a565b916200006e8483016200028a565b906200007d606084016200028a565b936200008c608085016200028a565b9460a08501519361ffff851695868603620002725760c001519033156200025b57620000b8336200029f565b6001600160a01b0393888516156200024a57600280549686166001600160a01b031997881617905560805260a0526001600160c01b03194260c01b16670de0b6b3a7640000176006557f161ab4db855064d603dd1cc5517b1938db43fb85b56aab98c326b307dd1f93569060209062000130620002ea565b806003558951908152a162000144620002ea565b169081156200023957819060055416176005557f7dae230f18360d76a040c81f050aa14eb9d6dc7901b20fc5d855e2a20fe814d15f80a262000185620002ea565b612710821162000228576020620001f393927fcbefe12795a171d23fc26333ec4f03a7478bae6ec54d70e18ff15ebca679407c92620001c362000338565b60058054600160a01b600160e01b03191660a09290921b61ffff60a01b169190911790558551908152a16200029f565b51611271908162000812823960805181818161024f01526107df015260a0518181816102a1015281816108a00152610cfa0152f35b8351638a81d3b360e01b8152600490fd5b855163d92e233d60e01b8152600490fd5b895163d92e233d60e01b8152600490fd5b8851631e4fbdf760e01b81525f6004820152602490fd5b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b51906001600160a01b03821682036200027257565b60018060a01b03199081600154166001555f5460018060a01b0380921680938216175f55167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3565b5f546001600160a01b03163303620002fe57565b60405163118cdaa760e01b8152336004820152602490fd5b919082018092116200032457565b634e487b7160e01b5f52601160045260245ffd5b6200034262000597565b5f81156200056757600754906200035d838360801c62000316565b600554916001600160401b03916200037c60a085901c841687620005d6565b9485156200051957506007546001600160801b03929083169182620005035786945b60a0516001600160a01b039081169190823b1562000272575f90604460409a838c5196879485936340c10f1960e01b85521660048401528c60248401525af18015620004f957620004e2575b5050620003f8838662000652565b6001600160c01b0390818111620004c4578160065491168282160191808311620004b0579084169116174260c01b6001600160c01b031916176006557fb27a3a9979877b12952e21e91eeded34f5ecc7d5147544ca7b58fa9cd85e30be976060979096909590949093909290916200047090620007dd565b926200048a62000484866007549562000316565b620007dd565b169260018060801b03199060801b169116171760075581519384526020840152820152a1565b634e487b7160e01b85526011600452602485fd5b6044908851906306dfcc6560e41b825260c060048301526024820152fd5b908092935011620002765785525f905f80620003ea565b88513d5f823e3d90fd5b62000512878203848962000768565b946200039e565b600680546001600160c01b03164260c01b6001600160c01b03191617905595506001600160801b031994506200055493509150620007dd9050565b60801b169060018060801b031617600755565b5050600654428160c01c036200057a5750565b6001600160c01b03164260c01b6001600160c01b03191617600655565b60065460c01c804214620005d15760045460075460801c908181029181830414901517156200032457620005ce91420390620006f2565b90565b505f90565b90808202905f19818409908280831092039180830392146200064757612710908282111562000635577fbc01a36e2eb1c432ca57a786c226809d495182a9930be0ded288ce703afb7e91940990828211900360fc1b910360041c170290565b60405163227bc15360e01b8152600490fd5b505061271091500490565b670de0b6b3a764000091818302915f1984820993838086109503948086039514620006cf57848311156200063557829109815f038216809204600280826003021880830282030280830282030280830282030280830282030280830282030280920290030293600183805f03040190848311900302920304170290565b505080925015620006de570490565b634e487b7160e01b5f52601260045260245ffd5b90808202905f19818409908280831092039180830392146200075757670de0b6b3a7640000908282111562000635577faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac10669940990828211900360ee1b910360121c170290565b5050670de0b6b3a764000091500490565b9091828202915f1984820993838086109503948086039514620006cf57848311156200063557829109815f038216809204600280826003021880830282030280830282030280830282030280830282030280830282030280920290030293600183805f03040190848311900302920304170290565b6001600160801b0390818111620007f2571690565b604490604051906306dfcc6560e41b8252608060048301526024820152fdfe604060808152600480361015610013575f80fd5b5f915f3560e01c91826301e1d11414610b7e5782630402f19614610ae457826307a2d13a14610ac65782631d8557d714610aac5782633a98ef3914610a85578263528c198a1461079f5782635cfc1a511461078157826361d027b314610759578263715018a6146106f6578263748747e614610671578263752a536d1461064e57826379ba5097146105c55782637fd6f15c1461059a5782638d7d45201461057e5782638da5cb5b1461055757826391915ef81461050c578263a52bbb891461049f578263aced166114610477578263c6e6f5921461041d578263e30c3978146103f5578263ee7a7c041461020c578263f0f442601461018c57505063f2fde38b1461011d575f80fd5b3461018957602036600319011261018957610136610b9a565b61013e6111dd565b600180546001600160a01b0319166001600160a01b0392831690811790915582549091167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227008380a380f35b80fd5b90915034610208576020366003190112610208576101a8610b9a565b6101b06111dd565b6001600160a01b03169182156101fb575050600580546001600160a01b031916821790557f7dae230f18360d76a040c81f050aa14eb9d6dc7901b20fc5d855e2a20fe814d18280a280f35b5163d92e233d60e01b8152fd5b8280fd5b8382346103a257806003193601126103a257610226610b9a565b8151632988bb9f60e21b8152338582015260248035926001600160a01b039290916020908290817f000000000000000000000000000000000000000000000000000000000000000087165afa908115610398575f916103c6575b50156103b65782156103a657610294610c92565b61029d83610c1e565b94827f000000000000000000000000000000000000000000000000000000000000000016803b156103a2578551632770a7eb60e21b81526001600160a01b03841698810198895260208901869052975f91899182908490829060400103925af196871561039857602097610387575b5061031684611208565b90600754916001600160801b03908184160316906001600160801b031961033c89611208565b838286161760801c0360801b16921617176007558351928584528684015216907f5d624aa9c148153ab3446c1b154f660ee7701e549fe9b62dab7171b1c80e6fa2833392a351908152f35b6103919150610c48565b5f8761030c565b85513d5f823e3d90fd5b5f80fd5b8351636edcc52360e01b81528690fd5b8351634ca8886760e01b81528690fd5b6103e8915060203d6020116103ee575b6103e08183610c70565b810190610f06565b87610280565b503d6103d6565b50346103a2575f3660031901126103a25760015490516001600160a01b039091168152602090f35b90346103a25760203660031901126103a257602091356001600160801b0360075416610447610bd1565b908215801561046f575b15610460575050905b51908152f35b6104699261116a565b9061045a565b508015610451565b50346103a2575f3660031901126103a25760025490516001600160a01b039091168152602090f35b90346103a25760203660031901126103a257600254823592906001600160a01b031633036104fe5791602091817f575b153fd68e97b63239f63ca929196a4e398b8157c14ddb6bfc54dad71071cb946104f6610c92565b5551908152a1005b9051634ca8886760e01b8152fd5b346103a25760203660031901126103a2577f161ab4db855064d603dd1cc5517b1938db43fb85b56aab98c326b307dd1f935691602091359061054c6111dd565b8160035551908152a1005b50346103a2575f3660031901126103a2575f5490516001600160a01b039091168152602090f35b90346103a2575f3660031901126103a257602091549051908152f35b50346103a2575f3660031901126103a25760209067ffffffffffffffff60055460a01c169051908152f35b90346103a2575f3660031901126103a257600154916001600160a01b039133838516036106375750506bffffffffffffffffffffffff60a01b8092166001555f549133908316175f553391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3005b60249250519063118cdaa760e01b82523390820152fd5b50346103a2575f3660031901126103a25760209061066a610f1e565b9051908152f35b90346103a25760203660031901126103a25761068b610b9a565b6106936111dd565b6001600160a01b03169182156106e8577f0425bcd291db1d48816f2a98edc7ecaf6dd5c64b973d9e4b3b6b750763dc6c2e60208484816bffffffffffffffffffffffff60a01b600254161760025551908152a1005b905163d92e233d60e01b8152fd5b346103a2575f3660031901126103a25761070e6111dd565b600180546001600160a01b03199081169091555f80549182168155906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b50346103a2575f3660031901126103a25760055490516001600160a01b039091168152602090f35b50346103a2575f3660031901126103a2576020906003549051908152f35b90346103a257806003193601126103a2576107b8610b9a565b8151632988bb9f60e21b815233818501526020936001600160a01b039392916024803592917f00000000000000000000000000000000000000000000000000000000000000008716918890829081855afa908115610a5e575f91610a68575b50159081156109a9575b5061099b5784831692831561098c57821561097d5761083e610c92565b61084783610c1e565b95600754610858888260801c610bb0565b90600354821161096d5761086b86611208565b6001600160801b03918216908216019181831161095a576108946001600160801b031991611208565b60801b169116176007557f00000000000000000000000000000000000000000000000000000000000000001691823b156103a25785516340c10f1960e01b81526001600160a01b039092169082019081526020810184905290915f9183919082908490829060400103925af1801561095057610941575b50825190848252858201527f2f00e3cdd69a77be7ed215ec7b2a36784dd158f921fca79ac29deffa353fe6ee833392a351908152f35b61094a90610c48565b8561090b565b84513d5f823e3d90fd5b601186634e487b7160e01b5f525260245ffd5b87516304ffa0ff60e51b81528590fd5b508351636edcc52360e01b8152fd5b50835163d92e233d60e01b8152fd5b8351634ca8886760e01b8152fd5b8551635c60da1b60e01b815290915087818481335afa908115610a5e57889188915f91610a21575b5087516345da87c560e01b815291168482015291829060249082905afa908115610398575f91610a04575b501587610821565b610a1b9150873d89116103ee576103e08183610c70565b876109fc565b928092508391503d8311610a57575b610a3a8183610c70565b810103126103a2575186811681036103a2578660248992906109d1565b503d610a30565b86513d5f823e3d90fd5b610a7f9150883d8a116103ee576103e08183610c70565b88610817565b50346103a2575f3660031901126103a2576020906001600160801b03600754169051908152f35b346103a2575f3660031901126103a257610ac4610c92565b005b90346103a25760203660031901126103a25761066a60209235610c1e565b90346103a25760203660031901126103a257813561ffff8116928382036103a257610b0d6111dd565b6127108411610b70577fcbefe12795a171d23fc26333ec4f03a7478bae6ec54d70e18ff15ebca679407c6020858585610b44610c92565b6005805467ffffffffffffffff60a01b191660a09290921b61ffff60a01b1691909117905551908152a1005b8251638a81d3b360e01b8152fd5b50346103a2575f3660031901126103a25760209061066a610bd1565b600435906001600160a01b03821682036103a257565b91908201809211610bbd57565b634e487b7160e01b5f52601160045260245ffd5b610bd9610fa7565b8015610c1457610c07610bfb67ffffffffffffffff60055460a01c1683610fdf565b9160075460801c610bb0565b908103908111610bbd5790565b5060075460801c90565b6001600160801b0360075416610c32610bd1565b81610c3c57505090565b610c459261116a565b90565b67ffffffffffffffff8111610c5c57604052565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff821117610c5c57604052565b610c9a610fa7565b5f8115610ed75760075490610cb2838360801c610bb0565b9060055491610cce67ffffffffffffffff8460a01c1686610fdf565b938415610e8357506001600160801b039182600754169182155f14610e705785945b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000811691823b156103a2576040516340c10f1960e01b815291166001600160a01b0316600482015260248101879052905f9082908183816044810103925af18015610e6557610e52575b50610d6d8386611059565b6001600160c01b0390818111610e33578160065491168282160191808311610e1f57928492610ddf9260609a98967fb27a3a9979877b12952e21e91eeded34f5ecc7d5147544ca7b58fa9cd85e30be9c9a989667ffffffffffffffff60c01b4260c01b16931691161717600655611208565b92610df5610df08660075495610bb0565b611208565b16926001600160801b03199060801b169116171760075560405192835260208301526040820152a1565b634e487b7160e01b85526011600452602485fd5b604490604051906306dfcc6560e41b825260c060048301526024820152fd5b610e5d919250610c48565b5f905f610d62565b6040513d5f823e3d90fd5b610e7d868203848861116a565b94610cf0565b600680546001600160c01b03164260c01b6001600160c01b03191617905594506001600160801b0393506fffffffffffffffffffffffffffffffff199250610ecb9150611208565b60801b16911617600755565b5050600654428160c01c03610ee95750565b6001600160c01b03164260c01b6001600160c01b03191617600655565b908160209103126103a2575180151581036103a25790565b6006546001600160c01b0316610f32610fa7565b8015610fa357610f5167ffffffffffffffff60055460a01c1682610fdf565b908115610f9e57610c459291610f8291600754916001600160801b038316809381155f14610f885750509050611059565b90610bb0565b610f9993839160801c01039161116a565b611059565b505090565b5090565b60065460c01c804214610fda5760045460075460801c90818102918183041490151715610bbd57610c45914203906110f6565b505f90565b90808202905f198184099082808310920391808303921461104e57612710908282111561103c577fbc01a36e2eb1c432ca57a786c226809d495182a9930be0ded288ce703afb7e91940990828211900360fc1b910360041c170290565b60405163227bc15360e01b8152600490fd5b505061271091500490565b670de0b6b3a764000091818302915f19848209938380861095039480860395146110d4578483111561103c57829109815f038216809204600280826003021880830282030280830282030280830282030280830282030280830282030280920290030293600183805f03040190848311900302920304170290565b5050809250156110e2570490565b634e487b7160e01b5f52601260045260245ffd5b90808202905f198184099082808310920391808303921461115957670de0b6b3a7640000908282111561103c577faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac10669940990828211900360ee1b910360121c170290565b5050670de0b6b3a764000091500490565b9091828202915f19848209938380861095039480860395146110d4578483111561103c57829109815f038216809204600280826003021880830282030280830282030280830282030280830282030280830282030280920290030293600183805f03040190848311900302920304170290565b5f546001600160a01b031633036111f057565b60405163118cdaa760e01b8152336004820152602490fd5b6001600160801b039081811161121c571690565b604490604051906306dfcc6560e41b8252608060048301526024820152fdfea2646970667358221220c36e28f32f38d67cc249dbf08b2fa9017b2a8c5d5c35fab17b8fea29757568a664736f6c63430008160033000000000000000000000000eeab37e0fe63bf3e122a59fdd892412296f1c5ad00000000000000000000000068ac05e91fb31bdab73f458045ded28768888e630000000000000000000000007c4e3ab659c8753004ff32699c0863f8f7a331f4000000000000000000000000ff2b6d2d5c205b99e2e6f607b6afa3127b9957b6000000000000000000000000ff2b6d2d5c205b99e2e6f607b6afa3127b9957b600000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000d3c21bcecceda1000000
Deployed Bytecode
0x604060808152600480361015610013575f80fd5b5f915f3560e01c91826301e1d11414610b7e5782630402f19614610ae457826307a2d13a14610ac65782631d8557d714610aac5782633a98ef3914610a85578263528c198a1461079f5782635cfc1a511461078157826361d027b314610759578263715018a6146106f6578263748747e614610671578263752a536d1461064e57826379ba5097146105c55782637fd6f15c1461059a5782638d7d45201461057e5782638da5cb5b1461055757826391915ef81461050c578263a52bbb891461049f578263aced166114610477578263c6e6f5921461041d578263e30c3978146103f5578263ee7a7c041461020c578263f0f442601461018c57505063f2fde38b1461011d575f80fd5b3461018957602036600319011261018957610136610b9a565b61013e6111dd565b600180546001600160a01b0319166001600160a01b0392831690811790915582549091167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227008380a380f35b80fd5b90915034610208576020366003190112610208576101a8610b9a565b6101b06111dd565b6001600160a01b03169182156101fb575050600580546001600160a01b031916821790557f7dae230f18360d76a040c81f050aa14eb9d6dc7901b20fc5d855e2a20fe814d18280a280f35b5163d92e233d60e01b8152fd5b8280fd5b8382346103a257806003193601126103a257610226610b9a565b8151632988bb9f60e21b8152338582015260248035926001600160a01b039290916020908290817f00000000000000000000000068ac05e91fb31bdab73f458045ded28768888e6387165afa908115610398575f916103c6575b50156103b65782156103a657610294610c92565b61029d83610c1e565b94827f0000000000000000000000007c4e3ab659c8753004ff32699c0863f8f7a331f416803b156103a2578551632770a7eb60e21b81526001600160a01b03841698810198895260208901869052975f91899182908490829060400103925af196871561039857602097610387575b5061031684611208565b90600754916001600160801b03908184160316906001600160801b031961033c89611208565b838286161760801c0360801b16921617176007558351928584528684015216907f5d624aa9c148153ab3446c1b154f660ee7701e549fe9b62dab7171b1c80e6fa2833392a351908152f35b6103919150610c48565b5f8761030c565b85513d5f823e3d90fd5b5f80fd5b8351636edcc52360e01b81528690fd5b8351634ca8886760e01b81528690fd5b6103e8915060203d6020116103ee575b6103e08183610c70565b810190610f06565b87610280565b503d6103d6565b50346103a2575f3660031901126103a25760015490516001600160a01b039091168152602090f35b90346103a25760203660031901126103a257602091356001600160801b0360075416610447610bd1565b908215801561046f575b15610460575050905b51908152f35b6104699261116a565b9061045a565b508015610451565b50346103a2575f3660031901126103a25760025490516001600160a01b039091168152602090f35b90346103a25760203660031901126103a257600254823592906001600160a01b031633036104fe5791602091817f575b153fd68e97b63239f63ca929196a4e398b8157c14ddb6bfc54dad71071cb946104f6610c92565b5551908152a1005b9051634ca8886760e01b8152fd5b346103a25760203660031901126103a2577f161ab4db855064d603dd1cc5517b1938db43fb85b56aab98c326b307dd1f935691602091359061054c6111dd565b8160035551908152a1005b50346103a2575f3660031901126103a2575f5490516001600160a01b039091168152602090f35b90346103a2575f3660031901126103a257602091549051908152f35b50346103a2575f3660031901126103a25760209067ffffffffffffffff60055460a01c169051908152f35b90346103a2575f3660031901126103a257600154916001600160a01b039133838516036106375750506bffffffffffffffffffffffff60a01b8092166001555f549133908316175f553391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3005b60249250519063118cdaa760e01b82523390820152fd5b50346103a2575f3660031901126103a25760209061066a610f1e565b9051908152f35b90346103a25760203660031901126103a25761068b610b9a565b6106936111dd565b6001600160a01b03169182156106e8577f0425bcd291db1d48816f2a98edc7ecaf6dd5c64b973d9e4b3b6b750763dc6c2e60208484816bffffffffffffffffffffffff60a01b600254161760025551908152a1005b905163d92e233d60e01b8152fd5b346103a2575f3660031901126103a25761070e6111dd565b600180546001600160a01b03199081169091555f80549182168155906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b50346103a2575f3660031901126103a25760055490516001600160a01b039091168152602090f35b50346103a2575f3660031901126103a2576020906003549051908152f35b90346103a257806003193601126103a2576107b8610b9a565b8151632988bb9f60e21b815233818501526020936001600160a01b039392916024803592917f00000000000000000000000068ac05e91fb31bdab73f458045ded28768888e638716918890829081855afa908115610a5e575f91610a68575b50159081156109a9575b5061099b5784831692831561098c57821561097d5761083e610c92565b61084783610c1e565b95600754610858888260801c610bb0565b90600354821161096d5761086b86611208565b6001600160801b03918216908216019181831161095a576108946001600160801b031991611208565b60801b169116176007557f0000000000000000000000007c4e3ab659c8753004ff32699c0863f8f7a331f41691823b156103a25785516340c10f1960e01b81526001600160a01b039092169082019081526020810184905290915f9183919082908490829060400103925af1801561095057610941575b50825190848252858201527f2f00e3cdd69a77be7ed215ec7b2a36784dd158f921fca79ac29deffa353fe6ee833392a351908152f35b61094a90610c48565b8561090b565b84513d5f823e3d90fd5b601186634e487b7160e01b5f525260245ffd5b87516304ffa0ff60e51b81528590fd5b508351636edcc52360e01b8152fd5b50835163d92e233d60e01b8152fd5b8351634ca8886760e01b8152fd5b8551635c60da1b60e01b815290915087818481335afa908115610a5e57889188915f91610a21575b5087516345da87c560e01b815291168482015291829060249082905afa908115610398575f91610a04575b501587610821565b610a1b9150873d89116103ee576103e08183610c70565b876109fc565b928092508391503d8311610a57575b610a3a8183610c70565b810103126103a2575186811681036103a2578660248992906109d1565b503d610a30565b86513d5f823e3d90fd5b610a7f9150883d8a116103ee576103e08183610c70565b88610817565b50346103a2575f3660031901126103a2576020906001600160801b03600754169051908152f35b346103a2575f3660031901126103a257610ac4610c92565b005b90346103a25760203660031901126103a25761066a60209235610c1e565b90346103a25760203660031901126103a257813561ffff8116928382036103a257610b0d6111dd565b6127108411610b70577fcbefe12795a171d23fc26333ec4f03a7478bae6ec54d70e18ff15ebca679407c6020858585610b44610c92565b6005805467ffffffffffffffff60a01b191660a09290921b61ffff60a01b1691909117905551908152a1005b8251638a81d3b360e01b8152fd5b50346103a2575f3660031901126103a25760209061066a610bd1565b600435906001600160a01b03821682036103a257565b91908201809211610bbd57565b634e487b7160e01b5f52601160045260245ffd5b610bd9610fa7565b8015610c1457610c07610bfb67ffffffffffffffff60055460a01c1683610fdf565b9160075460801c610bb0565b908103908111610bbd5790565b5060075460801c90565b6001600160801b0360075416610c32610bd1565b81610c3c57505090565b610c459261116a565b90565b67ffffffffffffffff8111610c5c57604052565b634e487b7160e01b5f52604160045260245ffd5b90601f8019910116810190811067ffffffffffffffff821117610c5c57604052565b610c9a610fa7565b5f8115610ed75760075490610cb2838360801c610bb0565b9060055491610cce67ffffffffffffffff8460a01c1686610fdf565b938415610e8357506001600160801b039182600754169182155f14610e705785945b6001600160a01b037f0000000000000000000000007c4e3ab659c8753004ff32699c0863f8f7a331f4811691823b156103a2576040516340c10f1960e01b815291166001600160a01b0316600482015260248101879052905f9082908183816044810103925af18015610e6557610e52575b50610d6d8386611059565b6001600160c01b0390818111610e33578160065491168282160191808311610e1f57928492610ddf9260609a98967fb27a3a9979877b12952e21e91eeded34f5ecc7d5147544ca7b58fa9cd85e30be9c9a989667ffffffffffffffff60c01b4260c01b16931691161717600655611208565b92610df5610df08660075495610bb0565b611208565b16926001600160801b03199060801b169116171760075560405192835260208301526040820152a1565b634e487b7160e01b85526011600452602485fd5b604490604051906306dfcc6560e41b825260c060048301526024820152fd5b610e5d919250610c48565b5f905f610d62565b6040513d5f823e3d90fd5b610e7d868203848861116a565b94610cf0565b600680546001600160c01b03164260c01b6001600160c01b03191617905594506001600160801b0393506fffffffffffffffffffffffffffffffff199250610ecb9150611208565b60801b16911617600755565b5050600654428160c01c03610ee95750565b6001600160c01b03164260c01b6001600160c01b03191617600655565b908160209103126103a2575180151581036103a25790565b6006546001600160c01b0316610f32610fa7565b8015610fa357610f5167ffffffffffffffff60055460a01c1682610fdf565b908115610f9e57610c459291610f8291600754916001600160801b038316809381155f14610f885750509050611059565b90610bb0565b610f9993839160801c01039161116a565b611059565b505090565b5090565b60065460c01c804214610fda5760045460075460801c90818102918183041490151715610bbd57610c45914203906110f6565b505f90565b90808202905f198184099082808310920391808303921461104e57612710908282111561103c577fbc01a36e2eb1c432ca57a786c226809d495182a9930be0ded288ce703afb7e91940990828211900360fc1b910360041c170290565b60405163227bc15360e01b8152600490fd5b505061271091500490565b670de0b6b3a764000091818302915f19848209938380861095039480860395146110d4578483111561103c57829109815f038216809204600280826003021880830282030280830282030280830282030280830282030280830282030280920290030293600183805f03040190848311900302920304170290565b5050809250156110e2570490565b634e487b7160e01b5f52601260045260245ffd5b90808202905f198184099082808310920391808303921461115957670de0b6b3a7640000908282111561103c577faccb18165bd6fe31ae1cf318dc5b51eee0e1ba569b88cd74c1773b91fac10669940990828211900360ee1b910360121c170290565b5050670de0b6b3a764000091500490565b9091828202915f19848209938380861095039480860395146110d4578483111561103c57829109815f038216809204600280826003021880830282030280830282030280830282030280830282030280830282030280920290030293600183805f03040190848311900302920304170290565b5f546001600160a01b031633036111f057565b60405163118cdaa760e01b8152336004820152602490fd5b6001600160801b039081811161121c571690565b604490604051906306dfcc6560e41b8252608060048301526024820152fdfea2646970667358221220c36e28f32f38d67cc249dbf08b2fa9017b2a8c5d5c35fab17b8fea29757568a664736f6c63430008160033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000eeab37e0fe63bf3e122a59fdd892412296f1c5ad00000000000000000000000068ac05e91fb31bdab73f458045ded28768888e630000000000000000000000007c4e3ab659c8753004ff32699c0863f8f7a331f4000000000000000000000000ff2b6d2d5c205b99e2e6f607b6afa3127b9957b6000000000000000000000000ff2b6d2d5c205b99e2e6f607b6afa3127b9957b600000000000000000000000000000000000000000000000000000000000001f400000000000000000000000000000000000000000000d3c21bcecceda1000000
-----Decoded View---------------
Arg [0] : _keeper (address): 0xeeAb37e0fE63bf3E122A59Fdd892412296f1C5AD
Arg [1] : registry (address): 0x68AC05e91fB31BdAb73f458045dEd28768888e63
Arg [2] : osToken (address): 0x7C4E3AB659C8753004ff32699c0863F8f7A331f4
Arg [3] : _treasury (address): 0xFF2B6d2d5c205b99E2e6f607B6aFA3127B9957B6
Arg [4] : _owner (address): 0xFF2B6d2d5c205b99E2e6f607B6aFA3127B9957B6
Arg [5] : _feePercent (uint16): 500
Arg [6] : _capacity (uint256): 1000000000000000000000000
-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 000000000000000000000000eeab37e0fe63bf3e122a59fdd892412296f1c5ad
Arg [1] : 00000000000000000000000068ac05e91fb31bdab73f458045ded28768888e63
Arg [2] : 0000000000000000000000007c4e3ab659c8753004ff32699c0863f8f7a331f4
Arg [3] : 000000000000000000000000ff2b6d2d5c205b99e2e6f607b6afa3127b9957b6
Arg [4] : 000000000000000000000000ff2b6d2d5c205b99e2e6f607b6afa3127b9957b6
Arg [5] : 00000000000000000000000000000000000000000000000000000000000001f4
Arg [6] : 00000000000000000000000000000000000000000000d3c21bcecceda1000000
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.