ERC-20
Overview
Max Total Supply
108,349.68987251 xSHADOW
Holders
4
Market
Price
$0.00 @ 0.000000 S
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract (WITH 18 Decimals)
Balance
737.5 xSHADOWValue
$0.00Loading...
Loading
Loading...
Loading
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
XShadow
Compiler Version
v0.8.28+commit.7893614a
Optimization Enabled:
Yes with 1633 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.26; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {Pausable} from "@openzeppelin/contracts/utils/Pausable.sol"; import {Math} from "@openzeppelin/contracts/utils/math/Math.sol"; import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import {IVoter} from "../interfaces/IVoter.sol"; import {IRamsesV3Pool} from "../CL/core/interfaces/IRamsesV3Pool.sol"; import {IXShadow} from "../interfaces/IXShadow.sol"; import {IVoteModule} from "../interfaces/IVoteModule.sol"; contract XShadow is ERC20, IXShadow, Pausable { using EnumerableSet for EnumerableSet.AddressSet; /** Addresses */ /// @inheritdoc IXShadow address public operator; /// @inheritdoc IXShadow address public immutable MINTER; /// @inheritdoc IXShadow address public immutable ACCESS_HUB; /// @inheritdoc IXShadow address public immutable VOTE_MODULE; /// @dev IERC20 declaration of Shadow IERC20 public immutable SHADOW; /// @dev declare IVoter IVoter public immutable VOTER; /// @dev stores the addresses that are exempt from transfer limitations when transferring out EnumerableSet.AddressSet exempt; /// @dev stores the addresses that are exempt from transfer limitations when transferring to them EnumerableSet.AddressSet exemptTo; /// @inheritdoc IXShadow uint256 public lastDistributedPeriod; /// @inheritdoc IXShadow uint256 public pendingRebase; /// @notice denominator uint256 public constant BASIS = 10_000; /// @inheritdoc IXShadow uint256 public constant SLASHING_PENALTY = 5000; /// @inheritdoc IXShadow uint256 public constant MIN_VEST = 14 days; /// @inheritdoc IXShadow uint256 public constant MAX_VEST = 180 days; /// @inheritdoc IXShadow mapping(address => VestPosition[]) public vestInfo; modifier onlyGovernance() { require(msg.sender == ACCESS_HUB, IVoter.NOT_AUTHORIZED(msg.sender)); _; } constructor( address _shadow, address _voter, address _operator, address _accessHub, address _voteModule, address _minter ) ERC20("xShadow", "xSHADOW") { SHADOW = IERC20(_shadow); VOTER = IVoter(_voter); MINTER = _minter; operator = _operator; ACCESS_HUB = _accessHub; VOTE_MODULE = _voteModule; /// @dev exempt voter, operator, and the vote module exempt.add(_voter); exempt.add(operator); exempt.add(VOTE_MODULE); exemptTo.add(VOTE_MODULE); /// @dev grab current period from voter lastDistributedPeriod = IVoter(_voter).getPeriod(); } /// @inheritdoc IXShadow function pause() external onlyGovernance { _pause(); } /// @inheritdoc IXShadow function unpause() external onlyGovernance { _unpause(); } /*****************************************************************/ // ERC20 Overrides and Helpers /*****************************************************************/ function _update( address from, address to, uint256 value ) internal override { /* cases we account for: * * minting and burning * if the "to" is part of the special exemptions * withdraw and deposit calls * if "from" is a gauge or feeDist * */ uint8 _u; if (_isExempted(from, to)) { _u = 1; } else if (VOTER.isGauge(from) || VOTER.isFeeDistributor(from)) { /// @dev add to the exempt set exempt.add(from); _u = 1; } /// @dev if all previous checks are passed require(_u == 1, NOT_WHITELISTED(from)); /// @dev call parent function super._update(from, to, value); } /// @dev internal check for the transfer whitelist function _isExempted( address _from, address _to ) internal view returns (bool) { return (exempt.contains(_from) || _from == address(0) || _to == address(0) || exemptTo.contains(_to)); } /*****************************************************************/ // General use functions /*****************************************************************/ /// @inheritdoc IXShadow function convertEmissionsToken(uint256 _amount) external whenNotPaused { /// @dev ensure the _amount is > 0 require(_amount != 0, ZERO()); /// @dev transfer from the caller to this address SHADOW.transferFrom(msg.sender, address(this), _amount); /// @dev mint the xSHADOW to the caller _mint(msg.sender, _amount); /// @dev emit an event for conversion emit Converted(msg.sender, _amount); } /// @inheritdoc IXShadow function rebase() external whenNotPaused { /// @dev gate to minter and call it on epoch flips require(msg.sender == MINTER, NOT_MINTER()); /// @dev fetch the current period uint256 period = VOTER.getPeriod(); /// @dev if it's a new period (epoch) if ( period > lastDistributedPeriod && /// @dev if the rebase is greater than the Basis pendingRebase >= BASIS ) { /// @dev PvP rebase notified to the voteModule staking contract to stream to xSHADOW /// @dev fetch the current period from voter lastDistributedPeriod = period; /// @dev store the rebase uint256 _temp = pendingRebase; /// @dev zero it out pendingRebase = 0; /// @dev approve SHADOW transferring to voteModule SHADOW.approve(VOTE_MODULE, _temp); /// @dev notify the SHADOW rebase IVoteModule(VOTE_MODULE).notifyRewardAmount(_temp); emit Rebase(msg.sender, _temp); } } /// @inheritdoc IXShadow function exit(uint256 _amount) external whenNotPaused { /// @dev cannot exit a 0 amount require(_amount != 0, ZERO()); /// @dev if it's at least 2 wei it will give a penalty uint256 penalty = ((_amount * SLASHING_PENALTY) / BASIS); uint256 exitAmount = _amount - penalty; /// @dev burn the xShadow from the caller's address _burn(msg.sender, _amount); /// @dev store the rebase earned from the penalty pendingRebase += penalty; /// @dev transfer the exitAmount to the caller SHADOW.transfer(msg.sender, exitAmount); /// @dev emit actual exited amount emit InstantExit(msg.sender, exitAmount); } /// @inheritdoc IXShadow function createVest(uint256 _amount) external whenNotPaused { /// @dev ensure not 0 require(_amount != 0, ZERO()); /// @dev preemptive burn _burn(msg.sender, _amount); /// @dev fetch total length of vests uint256 vestLength = vestInfo[msg.sender].length; /// @dev push new position vestInfo[msg.sender].push( VestPosition( _amount, block.timestamp, block.timestamp + MAX_VEST, vestLength ) ); emit NewVest(msg.sender, vestLength, _amount); } /// @inheritdoc IXShadow function exitVest(uint256 _vestID) external whenNotPaused { VestPosition storage _vest = vestInfo[msg.sender][_vestID]; require(_vest.amount != 0, NO_VEST()); /// @dev store amount in the vest and start time uint256 _amount = _vest.amount; uint256 _start = _vest.start; /// @dev zero out the amount before anything else as a safety measure _vest.amount = 0; /// @dev case: vest has not crossed the minimum vesting threshold /// @dev mint cancelled xShadow back to msg.sender if (block.timestamp < _start + MIN_VEST) { _mint(msg.sender, _amount); emit CancelVesting(msg.sender, _vestID, _amount); } /// @dev case: vest is complete /// @dev send liquid Shadow to msg.sender else if (_vest.maxEnd <= block.timestamp) { SHADOW.transfer(msg.sender, _amount); emit ExitVesting(msg.sender, _vestID, _amount); } /// @dev case: vest is in progress /// @dev calculate % earned based on length of time that has vested /// @dev linear calculations else { /// @dev the base to start at (50%) uint256 base = (_amount * (SLASHING_PENALTY)) / BASIS; /// @dev calculate the extra earned via vesting uint256 vestEarned = ((_amount * (BASIS - SLASHING_PENALTY) * (block.timestamp - _start)) / MAX_VEST) / BASIS; uint256 exitedAmount = base + vestEarned; /// @dev add to the existing pendingRebases pendingRebase += (_amount - exitedAmount); /// @dev transfer underlying to the sender after penalties removed SHADOW.transfer(msg.sender, exitedAmount); emit ExitVesting(msg.sender, _vestID, _amount); } } /*****************************************************************/ // Permissioned functions, timelock/operator gated /*****************************************************************/ /// @inheritdoc IXShadow function operatorRedeem(uint256 _amount) external onlyGovernance { _burn(operator, _amount); SHADOW.transfer(operator, _amount); emit XShadowRedeemed(address(this), _amount); } /// @inheritdoc IXShadow function rescueTrappedTokens( address[] calldata _tokens, uint256[] calldata _amounts ) external onlyGovernance { for (uint256 i = 0; i < _tokens.length; ++i) { /// @dev cant fetch the underlying require(_tokens[i] != address(SHADOW), CANT_RESCUE()); IERC20(_tokens[i]).transfer(operator, _amounts[i]); } } /// @inheritdoc IXShadow function migrateOperator(address _operator) external onlyGovernance { /// @dev ensure operator is different require(operator != _operator, NO_CHANGE()); emit NewOperator(operator, _operator); operator = _operator; } /// @inheritdoc IXShadow function setExemption( address[] calldata _exemptee, bool[] calldata _exempt ) external onlyGovernance { /// @dev ensure arrays of same length require(_exemptee.length == _exempt.length, ARRAY_LENGTHS()); /// @dev loop through all and attempt add/remove based on status for (uint256 i = 0; i < _exempt.length; ++i) { bool success = _exempt[i] ? exempt.add(_exemptee[i]) : exempt.remove(_exemptee[i]); /// @dev emit : (who, status, success) emit Exemption(_exemptee[i], _exempt[i], success); } } /// @inheritdoc IXShadow function setExemptionTo( address[] calldata _exemptee, bool[] calldata _exempt ) external onlyGovernance { /// @dev ensure arrays of same length require(_exemptee.length == _exempt.length, ARRAY_LENGTHS()); /// @dev loop through all and attempt add/remove based on status for (uint256 i = 0; i < _exempt.length; ++i) { bool success = _exempt[i] ? exemptTo.add(_exemptee[i]) : exemptTo.remove(_exemptee[i]); /// @dev emit : (who, status, success) emit Exemption(_exemptee[i], _exempt[i], success); } } /*****************************************************************/ // Getter functions /*****************************************************************/ /// @inheritdoc IXShadow function getBalanceResiding() public view returns (uint256 _amount) { /// @dev simply returns the balance of the underlying return SHADOW.balanceOf(address(this)); } /// @inheritdoc IXShadow function usersTotalVests( address _who ) public view returns (uint256 _length) { /// @dev returns the length of vests return vestInfo[_who].length; } /// @inheritdoc IXShadow function getVestInfo( address _who, uint256 _vestID ) public view returns (VestPosition memory) { return vestInfo[_who][_vestID]; } /// @inheritdoc IXShadow function isExempt(address _who) external view returns (bool _exempt) { return exempt.contains(_who); } /// @inheritdoc IXShadow function emissionsToken() external view returns (address) { return address(SHADOW); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "./IERC20.sol"; import {IERC20Metadata} from "./extensions/IERC20Metadata.sol"; import {Context} from "../../utils/Context.sol"; import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * The default value of {decimals} is 18. To change this, you should override * this function so it returns a different value. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC-20 * applications. */ abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors { mapping(address account => uint256) private _balances; mapping(address account => mapping(address spender => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * All two of these values are immutable: they can only be set once during * construction. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the default value returned by this function, unless * it's overridden. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `value`. */ function transfer(address to, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _transfer(owner, to, value); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 value) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, value); return true; } /** * @dev See {IERC20-transferFrom}. * * Skips emitting an {Approval} event indicating an allowance update. This is not * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve]. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `value`. * - the caller must have allowance for ``from``'s tokens of at least * `value`. */ function transferFrom(address from, address to, uint256 value) public virtual returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, value); _transfer(from, to, value); return true; } /** * @dev Moves a `value` amount of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _transfer(address from, address to, uint256 value) internal { if (from == address(0)) { revert ERC20InvalidSender(address(0)); } if (to == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(from, to, value); } /** * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from` * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding * this function. * * Emits a {Transfer} event. */ function _update(address from, address to, uint256 value) internal virtual { if (from == address(0)) { // Overflow check required: The rest of the code assumes that totalSupply never overflows _totalSupply += value; } else { uint256 fromBalance = _balances[from]; if (fromBalance < value) { revert ERC20InsufficientBalance(from, fromBalance, value); } unchecked { // Overflow not possible: value <= fromBalance <= totalSupply. _balances[from] = fromBalance - value; } } if (to == address(0)) { unchecked { // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply. _totalSupply -= value; } } else { unchecked { // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256. _balances[to] += value; } } emit Transfer(from, to, value); } /** * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0). * Relies on the `_update` mechanism * * Emits a {Transfer} event with `from` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead. */ function _mint(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidReceiver(address(0)); } _update(address(0), account, value); } /** * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply. * Relies on the `_update` mechanism. * * Emits a {Transfer} event with `to` set to the zero address. * * NOTE: This function is not virtual, {_update} should be overridden instead */ function _burn(address account, uint256 value) internal { if (account == address(0)) { revert ERC20InvalidSender(address(0)); } _update(account, address(0), value); } /** * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. * * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument. */ function _approve(address owner, address spender, uint256 value) internal { _approve(owner, spender, value, true); } /** * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event. * * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any * `Approval` event during `transferFrom` operations. * * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to * true using the following override: * * ```solidity * function _approve(address owner, address spender, uint256 value, bool) internal virtual override { * super._approve(owner, spender, value, true); * } * ``` * * Requirements are the same as {_approve}. */ function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual { if (owner == address(0)) { revert ERC20InvalidApprover(address(0)); } if (spender == address(0)) { revert ERC20InvalidSpender(address(0)); } _allowances[owner][spender] = value; if (emitEvent) { emit Approval(owner, spender, value); } } /** * @dev Updates `owner` s allowance for `spender` based on spent `value`. * * Does not update the allowance value in case of infinite allowance. * Revert if not enough allowance is available. * * Does not emit an {Approval} event. */ function _spendAllowance(address owner, address spender, uint256 value) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { if (currentAllowance < value) { revert ERC20InsufficientAllowance(spender, currentAllowance, value); } unchecked { _approve(owner, spender, currentAllowance - value, false); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-20 standard as defined in the ERC. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Pausable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable is Context { bool private _paused; /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); /** * @dev The operation failed because the contract is paused. */ error EnforcedPause(); /** * @dev The operation failed because the contract is not paused. */ error ExpectedPause(); /** * @dev Initializes the contract in unpaused state. */ constructor() { _paused = false; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { _requireNotPaused(); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { _requirePaused(); _; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { if (paused()) { revert EnforcedPause(); } } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { if (!paused()) { revert ExpectedPause(); } } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/math/Math.sol) pragma solidity ^0.8.20; import {Panic} from "../Panic.sol"; import {SafeCast} from "./SafeCast.sol"; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { 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 success flag (no overflow). */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an success flag (no overflow). */ function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an success flag (no overflow). */ function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { 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 success flag (no division by zero). */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero). */ function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant. * * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone. * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute * one branch when needed, making this function more expensive. */ function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) { unchecked { // branchless ternary works because: // b ^ (a ^ b) == a // b ^ 0 == b return b ^ ((a ^ b) * SafeCast.toUint(condition)); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return ternary(a > b, a, b); } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return ternary(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. Panic.panic(Panic.DIVISION_BY_ZERO); } // The following calculation ensures accurate ceiling division without overflow. // Since a is non-zero, (a - 1) / b will not overflow. // The largest possible result occurs when (a - 1) / b is type(uint256).max, // but the largest value we can obtain is type(uint256).max - 1, which happens // when a = type(uint256).max and b = 1. unchecked { return SafeCast.toUint(a > 0) * ((a - 1) / b + 1); } } /** * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * * 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²⁵⁶ and mod 2²⁵⁶ - 1, then use // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2²⁵⁶ + 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²⁵⁶. Also prevents denominator == 0. if (denominator <= prod1) { Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW)); } /////////////////////////////////////////////// // 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²⁵⁶ / 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²⁵⁶. Now that denominator is an odd number, it has an inverse modulo 2²⁵⁶ such // that denominator * inv ≡ 1 mod 2²⁵⁶. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv ≡ 1 mod 2⁴. 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⁸ inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶ inverse *= 2 - denominator * inverse; // inverse mod 2³² inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴ inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸ inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶ // 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²⁵⁶. Since the preconditions guarantee that the outcome is // less than 2²⁵⁶, 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; } } /** * @dev 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) { return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0); } /** * @dev Calculate the modular multiplicative inverse of a number in Z/nZ. * * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0. * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible. * * If the input value is not inversible, 0 is returned. * * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}. */ function invMod(uint256 a, uint256 n) internal pure returns (uint256) { unchecked { if (n == 0) return 0; // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version) // Used to compute integers x and y such that: ax + ny = gcd(a, n). // When the gcd is 1, then the inverse of a modulo n exists and it's x. // ax + ny = 1 // ax = 1 + (-y)n // ax ≡ 1 (mod n) # x is the inverse of a modulo n // If the remainder is 0 the gcd is n right away. uint256 remainder = a % n; uint256 gcd = n; // Therefore the initial coefficients are: // ax + ny = gcd(a, n) = n // 0a + 1n = n int256 x = 0; int256 y = 1; while (remainder != 0) { uint256 quotient = gcd / remainder; (gcd, remainder) = ( // The old remainder is the next gcd to try. remainder, // Compute the next remainder. // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd // where gcd is at most n (capped to type(uint256).max) gcd - remainder * quotient ); (x, y) = ( // Increment the coefficient of a. y, // Decrement the coefficient of n. // Can overflow, but the result is casted to uint256 so that the // next value of y is "wrapped around" to a value between 0 and n - 1. x - y * int256(quotient) ); } if (gcd != 1) return 0; // No inverse exists. return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative. } } /** * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`. * * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that * `a**(p-2)` is the modular multiplicative inverse of a in Fp. * * NOTE: this function does NOT check that `p` is a prime greater than `2`. */ function invModPrime(uint256 a, uint256 p) internal view returns (uint256) { unchecked { return Math.modExp(a, p - 2, p); } } /** * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m) * * Requirements: * - modulus can't be zero * - underlying staticcall to precompile must succeed * * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make * sure the chain you're using it on supports the precompiled contract for modular exponentiation * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, * the underlying function will succeed given the lack of a revert, but the result may be incorrectly * interpreted as 0. */ function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) { (bool success, uint256 result) = tryModExp(b, e, m); if (!success) { Panic.panic(Panic.DIVISION_BY_ZERO); } return result; } /** * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m). * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying * to operate modulo 0 or if the underlying precompile reverted. * * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack * of a revert, but the result may be incorrectly interpreted as 0. */ function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) { if (m == 0) return (false, 0); assembly ("memory-safe") { let ptr := mload(0x40) // | Offset | Content | Content (Hex) | // |-----------|------------|--------------------------------------------------------------------| // | 0x00:0x1f | size of b | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x20:0x3f | size of e | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x40:0x5f | size of m | 0x0000000000000000000000000000000000000000000000000000000000000020 | // | 0x60:0x7f | value of b | 0x<.............................................................b> | // | 0x80:0x9f | value of e | 0x<.............................................................e> | // | 0xa0:0xbf | value of m | 0x<.............................................................m> | mstore(ptr, 0x20) mstore(add(ptr, 0x20), 0x20) mstore(add(ptr, 0x40), 0x20) mstore(add(ptr, 0x60), b) mstore(add(ptr, 0x80), e) mstore(add(ptr, 0xa0), m) // Given the result < m, it's guaranteed to fit in 32 bytes, // so we can use the memory scratch space located at offset 0. success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20) result := mload(0x00) } } /** * @dev Variant of {modExp} that supports inputs of arbitrary length. */ function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) { (bool success, bytes memory result) = tryModExp(b, e, m); if (!success) { Panic.panic(Panic.DIVISION_BY_ZERO); } return result; } /** * @dev Variant of {tryModExp} that supports inputs of arbitrary length. */ function tryModExp( bytes memory b, bytes memory e, bytes memory m ) internal view returns (bool success, bytes memory result) { if (_zeroBytes(m)) return (false, new bytes(0)); uint256 mLen = m.length; // Encode call args in result and move the free memory pointer result = abi.encodePacked(b.length, e.length, mLen, b, e, m); assembly ("memory-safe") { let dataPtr := add(result, 0x20) // Write result on top of args to avoid allocating extra memory. success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen) // Overwrite the length. // result.length > returndatasize() is guaranteed because returndatasize() == m.length mstore(result, mLen) // Set the memory pointer after the returned data. mstore(0x40, add(dataPtr, mLen)) } } /** * @dev Returns whether the provided byte array is zero. */ function _zeroBytes(bytes memory byteArray) private pure returns (bool) { for (uint256 i = 0; i < byteArray.length; ++i) { if (byteArray[i] != 0) { return false; } } return true; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * This method is based on Newton's method for computing square roots; the algorithm is restricted to only * using integer operations. */ function sqrt(uint256 a) internal pure returns (uint256) { unchecked { // Take care of easy edge cases when a == 0 or a == 1 if (a <= 1) { return a; } // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between // the current value as `ε_n = | x_n - sqrt(a) |`. // // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is // bigger than any uint256. // // By noticing that // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)` // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar // to the msb function. uint256 aa = a; uint256 xn = 1; if (aa >= (1 << 128)) { aa >>= 128; xn <<= 64; } if (aa >= (1 << 64)) { aa >>= 64; xn <<= 32; } if (aa >= (1 << 32)) { aa >>= 32; xn <<= 16; } if (aa >= (1 << 16)) { aa >>= 16; xn <<= 8; } if (aa >= (1 << 8)) { aa >>= 8; xn <<= 4; } if (aa >= (1 << 4)) { aa >>= 4; xn <<= 2; } if (aa >= (1 << 2)) { xn <<= 1; } // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1). // // We can refine our estimation by noticing that the middle of that interval minimizes the error. // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2). // This is going to be our x_0 (and ε_0) xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2) // From here, Newton's method give us: // x_{n+1} = (x_n + a / x_n) / 2 // // One should note that: // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a // = ((x_n² + a) / (2 * x_n))² - a // = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a // = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²) // = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²) // = (x_n² - a)² / (2 * x_n)² // = ((x_n² - a) / (2 * x_n))² // ≥ 0 // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n // // This gives us the proof of quadratic convergence of the sequence: // ε_{n+1} = | x_{n+1} - sqrt(a) | // = | (x_n + a / x_n) / 2 - sqrt(a) | // = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) | // = | (x_n - sqrt(a))² / (2 * x_n) | // = | ε_n² / (2 * x_n) | // = ε_n² / | (2 * x_n) | // // For the first iteration, we have a special case where x_0 is known: // ε_1 = ε_0² / | (2 * x_0) | // ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2))) // ≤ 2**(2*e-4) / (3 * 2**(e-1)) // ≤ 2**(e-3) / 3 // ≤ 2**(e-3-log2(3)) // ≤ 2**(e-4.5) // // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n: // ε_{n+1} = ε_n² / | (2 * x_n) | // ≤ (2**(e-k))² / (2 * 2**(e-1)) // ≤ 2**(2*e-2*k) / 2**e // ≤ 2**(e-2*k) xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5) -- special case, see above xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9) -- general case with k = 4.5 xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18) -- general case with k = 9 xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36) -- general case with k = 18 xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72) -- general case with k = 36 xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144) -- general case with k = 72 // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either // sqrt(a) or sqrt(a) + 1. return xn - SafeCast.toUint(xn > a / xn); } } /** * @dev 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a); } } /** * @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; uint256 exp; unchecked { exp = 128 * SafeCast.toUint(value > (1 << 128) - 1); value >>= exp; result += exp; exp = 64 * SafeCast.toUint(value > (1 << 64) - 1); value >>= exp; result += exp; exp = 32 * SafeCast.toUint(value > (1 << 32) - 1); value >>= exp; result += exp; exp = 16 * SafeCast.toUint(value > (1 << 16) - 1); value >>= exp; result += exp; exp = 8 * SafeCast.toUint(value > (1 << 8) - 1); value >>= exp; result += exp; exp = 4 * SafeCast.toUint(value > (1 << 4) - 1); value >>= exp; result += exp; exp = 2 * SafeCast.toUint(value > (1 << 2) - 1); value >>= exp; result += exp; result += SafeCast.toUint(value > 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << result < value); } } /** * @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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 10 ** result < value); } } /** * @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; uint256 isGt; unchecked { isGt = SafeCast.toUint(value > (1 << 128) - 1); value >>= isGt * 128; result += isGt * 16; isGt = SafeCast.toUint(value > (1 << 64) - 1); value >>= isGt * 64; result += isGt * 8; isGt = SafeCast.toUint(value > (1 << 32) - 1); value >>= isGt * 32; result += isGt * 4; isGt = SafeCast.toUint(value > (1 << 16) - 1); value >>= isGt * 16; result += isGt * 2; result += SafeCast.toUint(value > (1 << 8) - 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 + SafeCast.toUint(unsignedRoundsUp(rounding) && 1 << (result << 3) < value); } } /** * @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.1.0) (utils/structs/EnumerableSet.sol) // This file was procedurally generated from scripts/generate/templates/EnumerableSet.js. pragma solidity ^0.8.20; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ```solidity * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. * * [WARNING] * ==== * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure * unusable. * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info. * * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an * array of EnumerableSet. * ==== */ library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position is the index of the value in the `values` array plus 1. // Position 0 is used to mean a value is not in the set. mapping(bytes32 value => uint256) _positions; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._positions[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We cache the value's position to prevent multiple reads from the same storage slot uint256 position = set._positions[value]; if (position != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 valueIndex = position - 1; uint256 lastIndex = set._values.length - 1; if (valueIndex != lastIndex) { bytes32 lastValue = set._values[lastIndex]; // Move the lastValue to the index where the value to delete is set._values[valueIndex] = lastValue; // Update the tracked position of the lastValue (that was just moved) set._positions[lastValue] = position; } // Delete the slot where the moved value was stored set._values.pop(); // Delete the tracked position for the deleted slot delete set._positions[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._positions[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { bytes32[] memory store = _values(set._inner); bytes32[] memory result; assembly ("memory-safe") { result := store } return result; } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly ("memory-safe") { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values in the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly ("memory-safe") { result := store } return result; } }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.26; pragma abicoder v2; interface IVoter { error ACTIVE_GAUGE(address gauge); error GAUGE_INACTIVE(address gauge); error ALREADY_WHITELISTED(address token); error NOT_AUTHORIZED(address caller); error NOT_WHITELISTED(); error NOT_POOL(); error NOT_INIT(); error LENGTH_MISMATCH(); error NO_GAUGE(); error ALREADY_DISTRIBUTED(address gauge, uint256 period); error ZERO_VOTE(address pool); error RATIO_TOO_HIGH(uint256 _xRatio); error VOTE_UNSUCCESSFUL(); event GaugeCreated( address indexed gauge, address creator, address feeDistributor, address indexed pool ); event GaugeKilled(address indexed gauge); event GaugeRevived(address indexed gauge); event Voted(address indexed owner, uint256 weight, address indexed pool); event Abstained(address indexed owner, uint256 weight); event Deposit( address indexed lp, address indexed gauge, address indexed owner, uint256 amount ); event Withdraw( address indexed lp, address indexed gauge, address indexed owner, uint256 amount ); event NotifyReward( address indexed sender, address indexed reward, uint256 amount ); event DistributeReward( address indexed sender, address indexed gauge, uint256 amount ); event EmissionsRatio( address indexed caller, uint256 oldRatio, uint256 newRatio ); event NewGovernor(address indexed sender, address indexed governor); event Whitelisted(address indexed whitelister, address indexed token); event WhitelistRevoked( address indexed forbidder, address indexed token, bool status ); event MainTickSpacingChanged( address indexed token0, address indexed token1, int24 indexed newMainTickSpacing ); event Poke(address indexed user); function initialize( address _emissionsToken, address _legacyFactory, address _gauges, address _feeDistributorFactory, address _minter, address _msig, address _xShadow, address _clFactory, address _clGaugeFactory, address _nfpManager, address _feeRecipientFactory, address _voteModule, address _launcherPlugin ) external; /// @notice denominator basis function BASIS() external view returns (uint256); /// @notice ratio of xShadow emissions globally function xRatio() external view returns (uint256); /// @notice xShadow contract address function xShadow() external view returns (address); /// @notice legacy factory address (uni-v2/stableswap) function legacyFactory() external view returns (address); /// @notice concentrated liquidity factory function clFactory() external view returns (address); /// @notice gauge factory for CL function clGaugeFactory() external view returns (address); /// @notice legacy fee recipient factory function feeRecipientFactory() external view returns (address); /// @notice peripheral NFPManager contract function nfpManager() external view returns (address); /// @notice returns the address of the current governor /// @return _governor address of the governor function governor() external view returns (address _governor); /// @notice the address of the vote module /// @return _voteModule the vote module contract address function voteModule() external view returns (address _voteModule); /// @notice address of the central access Hub function accessHub() external view returns (address); /// @notice the address of the shadow launcher plugin to enable third party launchers /// @return _launcherPlugin the address of the plugin function launcherPlugin() external view returns (address _launcherPlugin); /// @notice distributes emissions from the minter to the voter /// @param amount the amount of tokens to notify function notifyRewardAmount(uint256 amount) external; /// @notice distributes the emissions for a specific gauge /// @param _gauge the gauge address function distribute(address _gauge) external; /// @notice returns the address of the gauge factory /// @param _gaugeFactory gauge factory address function gaugeFactory() external view returns (address _gaugeFactory); /// @notice returns the address of the feeDistributor factory /// @return _feeDistributorFactory feeDist factory address function feeDistributorFactory() external view returns (address _feeDistributorFactory); /// @notice returns the address of the minter contract /// @return _minter address of the minter function minter() external view returns (address _minter); /// @notice check if the gauge is active for governance use /// @param _gauge address of the gauge /// @return _trueOrFalse if the gauge is alive function isAlive(address _gauge) external view returns (bool _trueOrFalse); /// @notice allows the token to be paired with other whitelisted assets to participate in governance /// @param _token the address of the token function whitelist(address _token) external; /// @notice effectively disqualifies a token from governance /// @param _token the address of the token function revokeWhitelist(address _token) external; /// @notice returns if the address is a gauge /// @param gauge address of the gauge /// @return _trueOrFalse boolean if the address is a gauge function isGauge(address gauge) external view returns (bool _trueOrFalse); /// @notice disable a gauge from governance /// @param _gauge address of the gauge function killGauge(address _gauge) external; /// @notice re-activate a dead gauge /// @param _gauge address of the gauge function reviveGauge(address _gauge) external; /// @notice re-cast a tokenID's votes /// @param owner address of the owner function poke(address owner) external; /// @notice sets the main tickspacing of a token pairing /// @param tokenA address of tokenA /// @param tokenB address of tokenB /// @param tickSpacing the main tickspacing to set to function setMainTickSpacing( address tokenA, address tokenB, int24 tickSpacing ) external; /// @notice returns if the address is a fee distributor /// @param _feeDistributor address of the feeDist /// @return _trueOrFalse if the address is a fee distributor function isFeeDistributor( address _feeDistributor ) external view returns (bool _trueOrFalse); /// @notice returns the address of the emission's token /// @return _emissionsToken emissions token contract address function emissionsToken() external view returns (address _emissionsToken); /// @notice returns the address of the pool's gauge, if any /// @param _pool pool address /// @return _gauge gauge address function gaugeForPool(address _pool) external view returns (address _gauge); /// @notice returns the address of the pool's feeDistributor, if any /// @param _gauge address of the gauge /// @return _feeDistributor address of the pool's feedist function feeDistributorForGauge( address _gauge ) external view returns (address _feeDistributor); /// @notice returns the new toPool that was redirected fromPool /// @param fromPool address of the original pool /// @return toPool the address of the redirected pool function poolRedirect( address fromPool ) external view returns (address toPool); /// @notice returns the gauge address of a CL pool /// @param tokenA address of token A in the pair /// @param tokenB address of token B in the pair /// @param tickSpacing tickspacing of the pool /// @return gauge address of the gauge function gaugeForClPool( address tokenA, address tokenB, int24 tickSpacing ) external view returns (address gauge); /// @notice returns the array of all tickspacings for the tokenA/tokenB combination /// @param tokenA address of token A in the pair /// @param tokenB address of token B in the pair /// @return _ts array of all the tickspacings function tickSpacingsForPair( address tokenA, address tokenB ) external view returns (int24[] memory _ts); /// @notice returns the main tickspacing used in the gauge/governance process /// @param tokenA address of token A in the pair /// @param tokenB address of token B in the pair /// @return _ts the main tickspacing function mainTickSpacingForPair( address tokenA, address tokenB ) external view returns (int24 _ts); /// @notice returns the block.timestamp divided by 1 week in seconds /// @return period the period used for gauges function getPeriod() external view returns (uint256 period); /// @notice cast a vote to direct emissions to gauges and earn incentives /// @param owner address of the owner /// @param _pools the list of pools to vote on /// @param _weights an arbitrary weight per pool which will be normalized to 100% regardless of numerical inputs function vote( address owner, address[] calldata _pools, uint256[] calldata _weights ) external; /// @notice reset the vote of an address /// @param owner address of the owner function reset(address owner) external; /// @notice set the governor address /// @param _governor the new governor address function setGovernor(address _governor) external; /// @notice recover stuck emissions /// @param _gauge the gauge address /// @param _period the period function stuckEmissionsRecovery(address _gauge, uint256 _period) external; /// @notice whitelists extra rewards for a gauge /// @param _gauge the gauge to whitelist rewards to /// @param _reward the reward to whitelist function whitelistGaugeRewards(address _gauge, address _reward) external; /// @notice removes a reward from the gauge whitelist /// @param _gauge the gauge to remove the whitelist from /// @param _reward the reward to remove from the whitelist function removeGaugeRewardWhitelist( address _gauge, address _reward ) external; /// @notice creates a legacy gauge for the pool /// @param _pool pool's address /// @return _gauge address of the new gauge function createGauge(address _pool) external returns (address _gauge); /// @notice create a concentrated liquidity gauge /// @param tokenA the address of tokenA /// @param tokenB the address of tokenB /// @param tickSpacing the tickspacing of the pool /// @return _clGauge address of the new gauge function createCLGauge( address tokenA, address tokenB, int24 tickSpacing ) external returns (address _clGauge); /// @notice claim concentrated liquidity gauge rewards for specific NFP token ids /// @param _gauges array of gauges /// @param _tokens two dimensional array for the tokens to claim /// @param _nfpTokenIds two dimensional array for the NFPs function claimClGaugeRewards( address[] calldata _gauges, address[][] calldata _tokens, uint256[][] calldata _nfpTokenIds ) external; /// @notice claim arbitrary rewards from specific feeDists /// @param owner address of the owner /// @param _feeDistributors address of the feeDists /// @param _tokens two dimensional array for the tokens to claim function claimIncentives( address owner, address[] calldata _feeDistributors, address[][] calldata _tokens ) external; /// @notice claim arbitrary rewards from specific gauges /// @param _gauges address of the gauges /// @param _tokens two dimensional array for the tokens to claim function claimRewards( address[] calldata _gauges, address[][] calldata _tokens ) external; /// @notice distribute emissions to a gauge for a specific period /// @param _gauge address of the gauge /// @param _period value of the period function distributeForPeriod(address _gauge, uint256 _period) external; /// @notice attempt distribution of emissions to all gauges function distributeAll() external; /// @notice distribute emissions to gauges by index /// @param startIndex start of the loop /// @param endIndex end of the loop function batchDistributeByIndex( uint256 startIndex, uint256 endIndex ) external; /// @notice returns the votes cast for a tokenID /// @param owner address of the owner /// @return votes an array of votes casted /// @return weights an array of the weights casted per pool function getVotes( address owner, uint256 period ) external view returns (address[] memory votes, uint256[] memory weights); /// @notice returns an array of all the gauges /// @return _gauges the array of gauges function getAllGauges() external view returns (address[] memory _gauges); /// @notice returns an array of all the feeDists /// @return _feeDistributors the array of feeDists function getAllFeeDistributors() external view returns (address[] memory _feeDistributors); /// @notice sets the xShadowRatio default function setGlobalRatio(uint256 _xRatio) external; /// @notice whether the token is whitelisted in governance function isWhitelisted(address _token) external view returns (bool _tf); /// @notice function for removing malicious or stuffed tokens function removeFeeDistributorReward( address _feeDist, address _token ) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; import {IRamsesV3PoolImmutables} from './pool/IRamsesV3PoolImmutables.sol'; import {IRamsesV3PoolState} from './pool/IRamsesV3PoolState.sol'; import {IRamsesV3PoolDerivedState} from './pool/IRamsesV3PoolDerivedState.sol'; import {IRamsesV3PoolActions} from './pool/IRamsesV3PoolActions.sol'; import {IRamsesV3PoolOwnerActions} from './pool/IRamsesV3PoolOwnerActions.sol'; import {IRamsesV3PoolErrors} from './pool/IRamsesV3PoolErrors.sol'; import {IRamsesV3PoolEvents} from './pool/IRamsesV3PoolEvents.sol'; /// @title The interface for a Ramses V3 Pool /// @notice A Ramses pool facilitates swapping and automated market making between any two assets that strictly conform /// to the ERC20 specification /// @dev The pool interface is broken up into many smaller pieces interface IRamsesV3Pool is IRamsesV3PoolImmutables, IRamsesV3PoolState, IRamsesV3PoolDerivedState, IRamsesV3PoolActions, IRamsesV3PoolOwnerActions, IRamsesV3PoolErrors, IRamsesV3PoolEvents { /// @notice if a new period, advance on interaction function _advancePeriod() external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.24; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IVoter} from "./IVoter.sol"; interface IXShadow is IERC20 { struct VestPosition { /// @dev amount of xShadow uint256 amount; /// @dev start unix timestamp uint256 start; /// @dev start + MAX_VEST (end timestamp) uint256 maxEnd; /// @dev vest identifier (starting from 0) uint256 vestID; } error NOT_WHITELISTED(address); error NOT_MINTER(); error ZERO(); error NO_VEST(); error ALREADY_EXEMPT(); error NOT_EXEMPT(); error CANT_RESCUE(); error NO_CHANGE(); error ARRAY_LENGTHS(); error TOO_HIGH(); error VEST_OVERLAP(); event CancelVesting( address indexed user, uint256 indexed vestId, uint256 amount ); event ExitVesting( address indexed user, uint256 indexed vestId, uint256 amount ); event InstantExit(address indexed user, uint256); event NewSlashingPenalty(uint256 penalty); event NewVest( address indexed user, uint256 indexed vestId, uint256 indexed amount ); event NewVestingTimes(uint256 min, uint256 max); event Converted(address indexed user, uint256); event Exemption(address indexed candidate, bool status, bool success); event XShadowRedeemed(address indexed user, uint256); event NewOperator(address indexed o, address indexed n); event Rebase(address indexed caller, uint256 amount); /// @notice returns info on a user's vests function vestInfo( address user, uint256 ) external view returns (uint256 amount, uint256 start, uint256 maxEnd, uint256 vestID); /// @notice address of the emissionsToken function SHADOW() external view returns (IERC20); /// @notice address of the voter function VOTER() external view returns (IVoter); function MINTER() external view returns (address); function ACCESS_HUB() external view returns (address); /// @notice address of the operator function operator() external view returns (address); /// @notice address of the VoteModule function VOTE_MODULE() external view returns (address); /// @notice max slashing amount function SLASHING_PENALTY() external view returns (uint256); /// @notice the minimum vesting length function MIN_VEST() external view returns (uint256); /// @notice the maximum vesting length function MAX_VEST() external view returns (uint256); function emissionsToken() external view returns (address); /// @notice the last period rebases were distributed function lastDistributedPeriod() external view returns (uint256); /// @notice amount of pvp rebase penalties accumulated pending to be distributed function pendingRebase() external view returns (uint256); /// @notice pauses the contract function pause() external; /// @notice unpauses the contract function unpause() external; /*****************************************************************/ // General use functions /*****************************************************************/ /// @dev mints xShadows for each emissionsToken. function convertEmissionsToken(uint256 _amount) external; /// @notice function called by the minter to send the rebases once a week function rebase() external; /** * @dev exit instantly with a penalty * @param _amount amount of xShadows to exit */ function exit(uint256 _amount) external; /// @dev vesting xShadows --> emissionToken functionality function createVest(uint256 _amount) external; /// @dev handles all situations regarding exiting vests function exitVest(uint256 _vestID) external; /*****************************************************************/ // Permissioned functions, timelock/operator gated /*****************************************************************/ /// @dev allows the operator to redeem collected xShadows function operatorRedeem(uint256 _amount) external; /// @dev allows rescue of any non-stake token function rescueTrappedTokens( address[] calldata _tokens, uint256[] calldata _amounts ) external; /// @notice migrates the operator to another contract function migrateOperator(address _operator) external; /// @notice set exemption status for an address function setExemption( address[] calldata _exemptee, bool[] calldata _exempt ) external; function setExemptionTo( address[] calldata _exemptee, bool[] calldata _exempt ) external; /*****************************************************************/ // Getter functions /*****************************************************************/ /// @notice returns the amount of SHADOW within the contract function getBalanceResiding() external view returns (uint256); /// @notice returns the total number of individual vests the user has function usersTotalVests( address _who ) external view returns (uint256 _numOfVests); /// @notice whether the address is exempt /// @param _who who to check /// @return _exempt whether it's exempt function isExempt(address _who) external view returns (bool _exempt); /// @notice returns the vest info for a user /// @param _who who to check /// @param _vestID vest ID to check /// @return VestPosition vest info function getVestInfo(address _who, uint256 _vestID) external view returns (VestPosition memory); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity ^0.8.26; interface IVoteModule { /** Custom Errors */ /// @dev == 0 error ZERO_AMOUNT(); /// @dev if address is not xShadow error NOT_XSHADOW(); /// @dev error for when the cooldown period has not been passed yet error COOLDOWN_ACTIVE(); /// @dev error for when you try to deposit or withdraw for someone who isn't the msg.sender error NOT_VOTEMODULE(); /// @dev error for when the caller is not authorized error UNAUTHORIZED(); /// @dev error for accessHub gated functions error NOT_ACCESSHUB(); /// @dev error for when there is no change of state error NO_CHANGE(); /// @dev error for when address is invalid error INVALID_ADDRESS(); /** Events */ event Deposit(address indexed from, uint256 amount); event Withdraw(address indexed from, uint256 amount); event NotifyReward(address indexed from, uint256 amount); event ClaimRewards(address indexed from, uint256 amount); event ExemptedFromCooldown(address indexed candidate, bool status); event NewDuration(uint256 oldDuration, uint256 newDuration); event NewCooldown(uint256 oldCooldown, uint256 newCooldown); event Delegate( address indexed delegator, address indexed delegatee, bool indexed isAdded ); event SetAdmin( address indexed owner, address indexed operator, bool indexed isAdded ); /** Functions */ function delegates(address) external view returns (address); /// @notice mapping for admins for a specific address /// @param owner the owner to check against /// @return operator the address that is designated as an admin/operator function admins(address owner) external view returns (address operator); function accessHub() external view returns(address); /// @notice returns the last time the reward was modified or periodFinish if the reward has ended function lastTimeRewardApplicable() external view returns (uint256 _ltra); function earned(address account) external view returns (uint256 _reward); /// @notice the time which users can deposit and withdraw function unlockTime() external view returns (uint256 _timestamp); /// @notice the accumulated dust in the contract from precision rollover function dust() external view returns (uint256 _dust); /// @notice claims pending rebase rewards function getReward() external; function rewardPerToken() external view returns (uint256 _rewardPerToken); /// @notice deposits all xShadow in the caller's wallet function depositAll() external; /// @notice deposit a specified amount of xShadow function deposit(uint256 amount) external; /// @notice withdraw all xShadow function withdrawAll() external; /// @notice withdraw a specified amount of xShadow function withdraw(uint256 amount) external; /// @notice check for admin perms /// @param operator the address to check /// @param owner the owner to check against for permissions function isAdminFor( address operator, address owner ) external view returns (bool approved); /// @notice check for delegations /// @param delegate the address to check /// @param owner the owner to check against for permissions function isDelegateFor( address delegate, address owner ) external view returns (bool approved); /// @notice rewards pending to be distributed for the reward period /// @return _left rewards remaining in the period function left() external view returns (uint256 _left); /// @notice used by the xShadow contract to notify pending rebases /// @param amount the amount of Shadow to be notified from exit penalties function notifyRewardAmount(uint256 amount) external; /// @notice the address of the xShadow token (staking/voting token) /// @return _xShadow the address function xShadow() external view returns (address _xShadow); /// @notice address of the voter contract /// @return _voter the voter contract address function voter() external view returns (address _voter); /// @notice returns the total voting power (equal to total supply in the VoteModule) /// @return _totalSupply the total voting power function totalSupply() external view returns (uint256 _totalSupply); /// @notice last time the rewards system was updated function lastUpdateTime() external view returns (uint256 _lastUpdateTime); /// @notice rewards per xShadow /// @return _rewardPerToken the amount of rewards per xShadow function rewardPerTokenStored() external view returns (uint256 _rewardPerToken); /// @notice when the 1800 seconds after notifying are up function periodFinish() external view returns (uint256 _periodFinish); /// @notice calculates the rewards per second /// @return _rewardRate the rewards distributed per second function rewardRate() external view returns (uint256 _rewardRate); /// @notice voting power /// @param user the address to check /// @return amount the staked balance function balanceOf(address user) external view returns (uint256 amount); /// @notice rewards per amount of xShadow's staked function userRewardPerTokenStored( address user ) external view returns (uint256 rewardPerToken); /// @notice the amount of rewards claimable for the user /// @param user the address of the user to check /// @return rewards the stored rewards function storedRewardsPerUser( address user ) external view returns (uint256 rewards); /// @notice delegate voting perms to another address /// @param delegatee who you delegate to /// @dev set address(0) to revoke function delegate(address delegatee) external; /// @notice give admin permissions to a another address /// @param operator the address to give administrative perms to /// @dev set address(0) to revoke function setAdmin(address operator) external; function cooldownExempt(address) external view returns (bool); function setCooldownExemption(address, bool) external; function setNewDuration(uint) external; function setNewCooldown(uint) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.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 ERC-20 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.1) (utils/Context.sol) pragma solidity ^0.8.20; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } function _contextSuffixLength() internal view virtual returns (uint256) { return 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol) pragma solidity ^0.8.20; /** * @dev Standard ERC-20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens. */ interface IERC20Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC20InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC20InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers. * @param spender Address that may be allowed to operate on tokens without being their owner. * @param allowance Amount of tokens a `spender` is allowed to operate with. * @param needed Minimum amount required to perform a transfer. */ error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC20InvalidApprover(address approver); /** * @dev Indicates a failure with the `spender` to be approved. Used in approvals. * @param spender Address that may be allowed to operate on tokens without being their owner. */ error ERC20InvalidSpender(address spender); } /** * @dev Standard ERC-721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20. * Used in balance queries. * @param owner Address of the current owner of a token. */ error ERC721InvalidOwner(address owner); /** * @dev Indicates a `tokenId` whose `owner` is the zero address. * @param tokenId Identifier number of a token. */ error ERC721NonexistentToken(uint256 tokenId); /** * @dev Indicates an error related to the ownership over a particular token. Used in transfers. * @param sender Address whose tokens are being transferred. * @param tokenId Identifier number of a token. * @param owner Address of the current owner of a token. */ error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC721InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC721InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param tokenId Identifier number of a token. */ error ERC721InsufficientApproval(address operator, uint256 tokenId); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC721InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC721InvalidOperator(address operator); } /** * @dev Standard ERC-1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens. */ interface IERC1155Errors { /** * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. * @param balance Current balance for the interacting account. * @param needed Minimum amount required to perform a transfer. * @param tokenId Identifier number of a token. */ error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId); /** * @dev Indicates a failure with the token `sender`. Used in transfers. * @param sender Address whose tokens are being transferred. */ error ERC1155InvalidSender(address sender); /** * @dev Indicates a failure with the token `receiver`. Used in transfers. * @param receiver Address to which tokens are being transferred. */ error ERC1155InvalidReceiver(address receiver); /** * @dev Indicates a failure with the `operator`’s approval. Used in transfers. * @param operator Address that may be allowed to operate on tokens without being their owner. * @param owner Address of the current owner of a token. */ error ERC1155MissingApprovalForAll(address operator, address owner); /** * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals. * @param approver Address initiating an approval operation. */ error ERC1155InvalidApprover(address approver); /** * @dev Indicates a failure with the `operator` to be approved. Used in approvals. * @param operator Address that may be allowed to operate on tokens without being their owner. */ error ERC1155InvalidOperator(address operator); /** * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation. * Used in batch transfers. * @param idsLength Length of the array of token identifiers * @param valuesLength Length of the array of token amounts */ error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol) pragma solidity ^0.8.20; /** * @dev Helper library for emitting standardized panic codes. * * ```solidity * contract Example { * using Panic for uint256; * * // Use any of the declared internal constants * function foo() { Panic.GENERIC.panic(); } * * // Alternatively * function foo() { Panic.panic(Panic.GENERIC); } * } * ``` * * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil]. * * _Available since v5.1._ */ // slither-disable-next-line unused-state library Panic { /// @dev generic / unspecified error uint256 internal constant GENERIC = 0x00; /// @dev used by the assert() builtin uint256 internal constant ASSERT = 0x01; /// @dev arithmetic underflow or overflow uint256 internal constant UNDER_OVERFLOW = 0x11; /// @dev division or modulo by zero uint256 internal constant DIVISION_BY_ZERO = 0x12; /// @dev enum conversion error uint256 internal constant ENUM_CONVERSION_ERROR = 0x21; /// @dev invalid encoding in storage uint256 internal constant STORAGE_ENCODING_ERROR = 0x22; /// @dev empty array pop uint256 internal constant EMPTY_ARRAY_POP = 0x31; /// @dev array out of bounds access uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32; /// @dev resource error (too large allocation or too large array) uint256 internal constant RESOURCE_ERROR = 0x41; /// @dev calling invalid internal function uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51; /// @dev Reverts with a panic code. Recommended to use with /// the internal constants with predefined codes. function panic(uint256 code) internal pure { assembly ("memory-safe") { mstore(0x00, 0x4e487b71) mstore(0x20, code) revert(0x1c, 0x24) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.1.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/bool 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); } /** * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump. */ function toUint(bool b) internal pure returns (uint256 u) { assembly ("memory-safe") { u := iszero(iszero(b)) } } }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that never changes /// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values interface IRamsesV3PoolImmutables { /// @notice The contract that deployed the pool, which must adhere to the IRamsesV3Factory interface /// @return The contract address function factory() external view returns (address); /// @notice The first of the two tokens of the pool, sorted by address /// @return The token contract address function token0() external view returns (address); /// @notice The second of the two tokens of the pool, sorted by address /// @return The token contract address function token1() external view returns (address); /// @notice The pool's fee in hundredths of a bip, i.e. 1e-6 /// @return The fee function fee() external view returns (uint24); /// @notice The pool tick spacing /// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive /// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ... /// This value is an int24 to avoid casting even though it is always positive. /// @return The tick spacing function tickSpacing() external view returns (int24); /// @notice The maximum amount of position liquidity that can use any tick in the range /// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and /// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool /// @return The max amount of liquidity per tick function maxLiquidityPerTick() external view returns (uint128); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that can change /// @notice These methods compose the pool's state, and can change with any frequency including multiple times /// per transaction interface IRamsesV3PoolState { /// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas /// when accessed externally. /// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value /// @return tick The current tick of the pool, i.e. according to the last tick transition that was run. /// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick /// boundary. /// @return observationIndex The index of the last oracle observation that was written, /// @return observationCardinality The current maximum number of observations stored in the pool, /// @return observationCardinalityNext The next maximum number of observations, to be updated when the observation. /// @return feeProtocol The protocol fee for both tokens of the pool. /// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0 /// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee. /// unlocked Whether the pool is currently locked to reentrancy function slot0() external view returns ( uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked ); /// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal0X128() external view returns (uint256); /// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool /// @dev This value can overflow the uint256 function feeGrowthGlobal1X128() external view returns (uint256); /// @notice The amounts of token0 and token1 that are owed to the protocol /// @dev Protocol fees will never exceed uint128 max in either token function protocolFees() external view returns (uint128 token0, uint128 token1); /// @notice The currently in range liquidity available to the pool /// @dev This value has no relationship to the total liquidity across all ticks /// @return The liquidity at the current price of the pool function liquidity() external view returns (uint128); /// @notice Look up information about a specific tick in the pool /// @param tick The tick to look up /// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or /// tick upper /// @return liquidityNet how much liquidity changes when the pool price crosses the tick, /// @return feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0, /// @return feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1, /// @return tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick /// @return secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick, /// @return secondsOutside the seconds spent on the other side of the tick from the current tick, /// @return initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false. /// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0. /// In addition, these values are only relative and must be used only in comparison to previous snapshots for /// a specific position. function ticks( int24 tick ) external view returns ( uint128 liquidityGross, int128 liquidityNet, uint256 feeGrowthOutside0X128, uint256 feeGrowthOutside1X128, int56 tickCumulativeOutside, uint160 secondsPerLiquidityOutsideX128, uint32 secondsOutside, bool initialized ); /// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information function tickBitmap(int16 wordPosition) external view returns (uint256); /// @notice Returns the information about a position by the position's key /// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper /// @return liquidity The amount of liquidity in the position, /// @return feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke, /// @return feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke, /// @return tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke, /// @return tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke function positions( bytes32 key ) external view returns ( uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1 ); /// @notice Returns data about a specific observation index /// @param index The element of the observations array to fetch /// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time /// ago, rather than at a specific index in the array. /// @return blockTimestamp The timestamp of the observation, /// @return tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp, /// @return secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp, /// @return initialized whether the observation has been initialized and the values are safe to use function observations( uint256 index ) external view returns ( uint32 blockTimestamp, int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128, bool initialized ); /// @notice get the period seconds in range of a specific position /// @param period the period number /// @param owner owner address /// @param index position index /// @param tickLower lower bound of range /// @param tickUpper upper bound of range /// @return periodSecondsInsideX96 seconds the position was not in range for the period function positionPeriodSecondsInRange( uint256 period, address owner, uint256 index, int24 tickLower, int24 tickUpper ) external view returns (uint256 periodSecondsInsideX96); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Pool state that is not stored /// @notice Contains view functions to provide information about the pool that is computed rather than stored on the /// blockchain. The functions here may have variable gas costs. interface IRamsesV3PoolDerivedState { /// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp /// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing /// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick, /// you must call it with secondsAgos = [3600, 0]. /// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in /// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio. /// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned /// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp /// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block /// timestamp function observe( uint32[] calldata secondsAgos ) external view returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s); /// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range /// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed. /// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first /// snapshot is taken and the second snapshot is taken. /// @param tickLower The lower tick of the range /// @param tickUpper The upper tick of the range /// @return tickCumulativeInside The snapshot of the tick accumulator for the range /// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range /// @return secondsInside The snapshot of seconds per liquidity for the range function snapshotCumulativesInside( int24 tickLower, int24 tickUpper ) external view returns (int56 tickCumulativeInside, uint160 secondsPerLiquidityInsideX128, uint32 secondsInside); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissionless pool actions /// @notice Contains pool methods that can be called by anyone interface IRamsesV3PoolActions { /// @notice Sets the initial price for the pool /// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value /// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96 function initialize(uint160 sqrtPriceX96) external; /// @notice Adds liquidity for the given recipient/tickLower/tickUpper position /// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback /// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends /// on tickLower, tickUpper, the amount of liquidity, and the current price. /// @param recipient The address for which the liquidity will be created /// @param index The index for which the liquidity will be created /// @param tickLower The lower tick of the position in which to add liquidity /// @param tickUpper The upper tick of the position in which to add liquidity /// @param amount The amount of liquidity to mint /// @param data Any data that should be passed through to the callback /// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback /// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback function mint( address recipient, uint256 index, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1); /// @notice Collects tokens owed to a position /// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity. /// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or /// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the /// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity. /// @param recipient The address which should receive the fees collected /// @param index The index of the position to be collected /// @param tickLower The lower tick of the position for which to collect fees /// @param tickUpper The upper tick of the position for which to collect fees /// @param amount0Requested How much token0 should be withdrawn from the fees owed /// @param amount1Requested How much token1 should be withdrawn from the fees owed /// @return amount0 The amount of fees collected in token0 /// @return amount1 The amount of fees collected in token1 function collect( address recipient, uint256 index, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); /// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position /// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0 /// @dev Fees must be collected separately via a call to #collect /// @param index The index for which the liquidity will be burned /// @param tickLower The lower tick of the position for which to burn liquidity /// @param tickUpper The upper tick of the position for which to burn liquidity /// @param amount How much liquidity to burn /// @return amount0 The amount of token0 sent to the recipient /// @return amount1 The amount of token1 sent to the recipient function burn( uint256 index, int24 tickLower, int24 tickUpper, uint128 amount ) external returns (uint256 amount0, uint256 amount1); /// @notice Swap token0 for token1, or token1 for token0 /// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback /// @param recipient The address to receive the output of the swap /// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0 /// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative) /// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this /// value after the swap. If one for zero, the price cannot be greater than this value after the swap /// @param data Any data to be passed through to the callback /// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive /// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive function swap( address recipient, bool zeroForOne, int256 amountSpecified, uint160 sqrtPriceLimitX96, bytes calldata data ) external returns (int256 amount0, int256 amount1); /// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback /// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback /// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling /// with 0 amount{0,1} and sending the donation amount(s) from the callback /// @param recipient The address which will receive the token0 and token1 amounts /// @param amount0 The amount of token0 to send /// @param amount1 The amount of token1 to send /// @param data Any data to be passed through to the callback function flash( address recipient, uint256 amount0, uint256 amount1, bytes calldata data ) external; /// @notice Increase the maximum number of price and liquidity observations that this pool will store /// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to /// the input observationCardinalityNext. /// @param observationCardinalityNext The desired minimum number of observations for the pool to store function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Permissioned pool actions /// @notice Contains pool methods that may only be called by the factory owner interface IRamsesV3PoolOwnerActions { /// @notice Set the denominator of the protocol's % share of the fees function setFeeProtocol() external; /// @notice Collect the protocol fee accrued to the pool /// @param recipient The address to which collected protocol fees should be sent /// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1 /// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0 /// @return amount0 The protocol fee collected in token0 /// @return amount1 The protocol fee collected in token1 function collectProtocol( address recipient, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1); function setFee(uint24 _fee) external; }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Errors emitted by a pool /// @notice Contains all events emitted by the pool interface IRamsesV3PoolErrors { error LOK(); error TLU(); error TLM(); error TUM(); error AI(); error M0(); error M1(); error AS(); error IIA(); error L(); error F0(); error F1(); error SPL(); }
// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.5.0; /// @title Events emitted by a pool /// @notice Contains all events emitted by the pool interface IRamsesV3PoolEvents { /// @notice Emitted exactly once by a pool when #initialize is first called on the pool /// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize /// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96 /// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool event Initialize(uint160 sqrtPriceX96, int24 tick); /// @notice Emitted when liquidity is minted for a given position /// @param sender The address that minted the liquidity /// @param owner The owner of the position and recipient of any minted liquidity /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity minted to the position range /// @param amount0 How much token0 was required for the minted liquidity /// @param amount1 How much token1 was required for the minted liquidity event Mint( address sender, address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted when fees are collected by the owner of a position /// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees /// @param owner The owner of the position for which fees are collected /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount0 The amount of token0 fees collected /// @param amount1 The amount of token1 fees collected event Collect( address indexed owner, address recipient, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount0, uint128 amount1 ); /// @notice Emitted when a position's liquidity is removed /// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect /// @param owner The owner of the position for which liquidity is removed /// @param tickLower The lower tick of the position /// @param tickUpper The upper tick of the position /// @param amount The amount of liquidity to remove /// @param amount0 The amount of token0 withdrawn /// @param amount1 The amount of token1 withdrawn event Burn( address indexed owner, int24 indexed tickLower, int24 indexed tickUpper, uint128 amount, uint256 amount0, uint256 amount1 ); /// @notice Emitted by the pool for any swaps between token0 and token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the output of the swap /// @param amount0 The delta of the token0 balance of the pool /// @param amount1 The delta of the token1 balance of the pool /// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96 /// @param liquidity The liquidity of the pool after the swap /// @param tick The log base 1.0001 of price of the pool after the swap event Swap( address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick ); /// @notice Emitted by the pool for any flashes of token0/token1 /// @param sender The address that initiated the swap call, and that received the callback /// @param recipient The address that received the tokens from flash /// @param amount0 The amount of token0 that was flashed /// @param amount1 The amount of token1 that was flashed /// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee /// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee event Flash( address indexed sender, address indexed recipient, uint256 amount0, uint256 amount1, uint256 paid0, uint256 paid1 ); /// @notice Emitted by the pool for increases to the number of observations that can be stored /// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index /// just before a mint/swap/burn. /// @param observationCardinalityNextOld The previous value of the next observation cardinality /// @param observationCardinalityNextNew The updated value of the next observation cardinality event IncreaseObservationCardinalityNext( uint16 observationCardinalityNextOld, uint16 observationCardinalityNextNew ); /// @notice Emitted when the protocol fee is changed by the pool /// @param feeProtocol0Old The previous value of the token0 protocol fee /// @param feeProtocol1Old The previous value of the token1 protocol fee /// @param feeProtocol0New The updated value of the token0 protocol fee /// @param feeProtocol1New The updated value of the token1 protocol fee event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New); /// @notice Emitted when the collected protocol fees are withdrawn by the factory owner /// @param sender The address that collects the protocol fees /// @param recipient The address that receives the collected protocol fees /// @param amount0 The amount of token0 protocol fees that is withdrawn /// @param amount0 The amount of token1 protocol fees that is withdrawn event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1); }
{ "remappings": [ "@openzeppelin-contracts-5.1.0/=dependencies/@openzeppelin-contracts-5.1.0/", "@openzeppelin-contracts-upgradeable-5.1.0/=dependencies/@openzeppelin-contracts-upgradeable-5.1.0/", "@forge-std-1.9.4/=dependencies/forge-std-1.9.4/", "@layerzerolabs/=node_modules/@layerzerolabs/", "@layerzerolabs/lz-evm-protocol-v2/=node_modules/@layerzerolabs/lz-evm-protocol-v2/", "@openzeppelin-contracts-upgradeable/=dependencies/@openzeppelin-contracts-upgradeable-5.1.0/", "@openzeppelin-contracts/contracts/=dependencies/@openzeppelin-contracts-5.1.0/", "@openzeppelin/contracts/=dependencies/@openzeppelin-contracts-5.1.0/", "erc4626-tests/=dependencies/erc4626-property-tests-1.0/", "forge-std/=dependencies/forge-std-1.9.4/src/", "permit2/=lib/permit2/", "@openzeppelin-3.4.2/=node_modules/@openzeppelin-3.4.2/", "@openzeppelin-contracts-5.1.0/=dependencies/@openzeppelin-contracts-5.1.0/", "@openzeppelin-contracts-upgradeable-5.1.0/=dependencies/@openzeppelin-contracts-upgradeable-5.1.0/", "@uniswap/=node_modules/@uniswap/", "base64-sol/=node_modules/base64-sol/", "ds-test/=node_modules/ds-test/", "erc4626-property-tests-1.0/=dependencies/erc4626-property-tests-1.0/", "eth-gas-reporter/=node_modules/eth-gas-reporter/", "forge-std-1.9.4/=dependencies/forge-std-1.9.4/src/", "hardhat/=node_modules/hardhat/", "solidity-bytes-utils/=node_modules/solidity-bytes-utils/", "solmate/=node_modules/solmate/" ], "optimizer": { "enabled": true, "runs": 1633 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": true, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_shadow","type":"address"},{"internalType":"address","name":"_voter","type":"address"},{"internalType":"address","name":"_operator","type":"address"},{"internalType":"address","name":"_accessHub","type":"address"},{"internalType":"address","name":"_voteModule","type":"address"},{"internalType":"address","name":"_minter","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ALREADY_EXEMPT","type":"error"},{"inputs":[],"name":"ARRAY_LENGTHS","type":"error"},{"inputs":[],"name":"CANT_RESCUE","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[{"internalType":"address","name":"caller","type":"address"}],"name":"NOT_AUTHORIZED","type":"error"},{"inputs":[],"name":"NOT_EXEMPT","type":"error"},{"inputs":[],"name":"NOT_MINTER","type":"error"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"NOT_WHITELISTED","type":"error"},{"inputs":[],"name":"NO_CHANGE","type":"error"},{"inputs":[],"name":"NO_VEST","type":"error"},{"inputs":[],"name":"TOO_HIGH","type":"error"},{"inputs":[],"name":"VEST_OVERLAP","type":"error"},{"inputs":[],"name":"ZERO","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"vestId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"CancelVesting","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"Converted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"candidate","type":"address"},{"indexed":false,"internalType":"bool","name":"status","type":"bool"},{"indexed":false,"internalType":"bool","name":"success","type":"bool"}],"name":"Exemption","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"vestId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"ExitVesting","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"InstantExit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"o","type":"address"},{"indexed":true,"internalType":"address","name":"n","type":"address"}],"name":"NewOperator","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"penalty","type":"uint256"}],"name":"NewSlashingPenalty","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"vestId","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"NewVest","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"min","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"max","type":"uint256"}],"name":"NewVestingTimes","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"caller","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Rebase","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"","type":"uint256"}],"name":"XShadowRedeemed","type":"event"},{"inputs":[],"name":"ACCESS_HUB","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"BASIS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_VEST","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINTER","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_VEST","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SHADOW","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SLASHING_PENALTY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VOTER","outputs":[{"internalType":"contract IVoter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VOTE_MODULE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"convertEmissionsToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"createVest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emissionsToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"exit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_vestID","type":"uint256"}],"name":"exitVest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getBalanceResiding","outputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_who","type":"address"},{"internalType":"uint256","name":"_vestID","type":"uint256"}],"name":"getVestInfo","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"maxEnd","type":"uint256"},{"internalType":"uint256","name":"vestID","type":"uint256"}],"internalType":"struct IXShadow.VestPosition","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_who","type":"address"}],"name":"isExempt","outputs":[{"internalType":"bool","name":"_exempt","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastDistributedPeriod","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_operator","type":"address"}],"name":"migrateOperator","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"operator","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"operatorRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingRebase","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rebase","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_amounts","type":"uint256[]"}],"name":"rescueTrappedTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_exemptee","type":"address[]"},{"internalType":"bool[]","name":"_exempt","type":"bool[]"}],"name":"setExemption","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_exemptee","type":"address[]"},{"internalType":"bool[]","name":"_exempt","type":"bool[]"}],"name":"setExemptionTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_who","type":"address"}],"name":"usersTotalVests","outputs":[{"internalType":"uint256","name":"_length","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"vestInfo","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"maxEnd","type":"uint256"},{"internalType":"uint256","name":"vestID","type":"uint256"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
61012080604052346103325760c081612ac48038038091610020828561053f565b8339810103126103325761003381610562565b61003f60208301610562565b9161004c60408201610562565b9161005960608301610562565b9061007260a061006b60808601610562565b9401610562565b936040519561008260408861053f565b600787526678536861646f7760c81b6020880152604051966100a560408961053f565b600788526678534841444f5760c81b60208901528051906001600160401b0382116104425760035490600182811c92168015610535575b60208310146104245781601f8493116104c7575b50602090601f8311600114610461575f92610456575b50508160011b915f199060031b1c1916176003555b86516001600160401b03811161044257600454600181811c91168015610438575b602082101461042457601f81116103c1575b506020601f821160011461035457908060209897969594939260049a5f92610349575b50508160011b915f199060031b1c19161788555b600580546001600160a01b0394851660e052919093166101008190526080969096526001600160a81b03191660089190911b610100600160a81b031617905560a05260c0526101d381610576565b506005546101ec9060081c6001600160a01b0316610576565b5060c051610202906001600160a01b0316610576565b5060c051610218906001600160a01b0316610602565b50604051631ed2419560e01b815292839182905afa90811561033e575f91610308575b50600a5560405161244e908161067682396080518181816101f50152610542015260a051818181610289015281816104dd01528181610b4f01528181610cf101528181610f77015281816111a10152818161124e015261133b015260c0518181816106150152610eb2015260e0518181816102b2015281816104400152818161065f015281816108bc01528181610dea01528181610ef5015281816113ba015261165a01526101005181818161059e01528181610caf01528181611c7801528181611ea801526120c10152f35b90506020813d602011610336575b816103236020938361053f565b8101031261033257515f61023b565b5f80fd5b3d9150610316565b6040513d5f823e3d90fd5b015190505f80610171565b601f1982169860045f52815f20995f5b8181106103a9575099600192849260209b9a999897969560049d10610391575b505050811b018855610185565b01515f1960f88460031b161c191690555f8080610384565b838301518c556001909b019a60209384019301610364565b60045f527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b601f830160051c8101916020841061041a575b601f0160051c01905b81811061040f575061014e565b5f8155600101610402565b90915081906103f9565b634e487b7160e01b5f52602260045260245ffd5b90607f169061013c565b634e487b7160e01b5f52604160045260245ffd5b015190505f80610106565b60035f9081528281209350601f198516905b8181106104af5750908460019594939210610497575b505050811b0160035561011b565b01515f1960f88460031b161c191690555f8080610489565b92936020600181928786015181550195019301610473565b60035f529091507fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b601f840160051c8101916020851061052b575b90601f859493920160051c01905b81811061051d57506100f0565b5f8155849350600101610510565b9091508190610502565b91607f16916100dc565b601f909101601f19168101906001600160401b0382119082101761044257604052565b51906001600160a01b038216820361033257565b805f52600760205260405f2054155f146105fd57600654680100000000000000008110156104425760018101806006558110156105e9577ff652222313e28459528d920b65115c16c04f3efc82aaedc97be59f3f377c0d3f018190556006545f9182526007602052604090912055600190565b634e487b7160e01b5f52603260045260245ffd5b505f90565b805f52600960205260405f2054155f146105fd57600854680100000000000000008110156104425760018101806008558110156105e9577ff3f7a9fe364faab93b216da50a3214154f22a0a2b415b23a84c8169e8b636ee3018190556008545f918252600960205260409091205560019056fe6080806040526004361015610012575f80fd5b5f905f3560e01c90816306fdde03146118d15750806308b4bd63146117d1578063095ea7b31461174f57806311147bd6146116dd57806312e82674146115ef57806318160ddd146115d2578063210ca05d14610ed657806323b872dd146114a257806325d64f4b146114865780632cf53bd81461144e578063313ce5671461143357806332fef3cf14611319578063353140d01461122f5780633f4ba83a1461118357806349e8219314611166578063528cfa981461114a578063570ca735146111215780635a8aed66146110765780635c975abb146110545780636379808f14610f5057806370a0823114610f1957806379248d9414610ed65780637dd51d7a14610e935780637f8661a114610d765780638392331114610d595780638456cb5914610cd35780638ebf2fd614610c905780638f7b565b14610c7357806394126bb114610b3057806395d89b4114610a2c578063a9059cbb146109fb578063ab956054146107ef578063ad5dff73146107b5578063af14052c1461051f578063b7f045e914610501578063b989216a146104bd578063bacbf61b146103f2578063beb7dc341461026a578063dd62ed3e1461021c5763fe6d8124146101d6575f80fd5b3461021957806003193601126102195760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b80fd5b5034610219576040366003190112610219576001600160a01b0360406102406119b3565b928261024a6119c9565b9416815260016020522091165f52602052602060405f2054604051908152f35b50346102195761027936611a3d565b90916102b0336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163314611af2565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031693855b8281106102e8578680f35b856001600160a01b036103046102ff848787611b2f565b611b4c565b16146103ca578060206001600160a01b036103266102ff610377958888611b2f565b166001600160a01b0360055460081c169061034284898b611b2f565b35918b60405180978195829463a9059cbb60e01b845260048401602090939291936001600160a01b0360408201951681520152565b03925af19182156103bf57600192610391575b50016102dd565b6103b19060203d81116103b8575b6103a98183611aab565b810190611ada565b505f61038a565b503d61039f565b6040513d8a823e3d90fd5b6004877f512428f9000000000000000000000000000000000000000000000000000000008152fd5b5034610219578060031936011261021957604051907f70a082310000000000000000000000000000000000000000000000000000000082523060048301526020826024816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa9081156104b1579061047a575b602090604051908152f35b506020813d6020116104a9575b8161049460209383611aab565b810103126104a5576020905161046f565b5f80fd5b3d9150610487565b604051903d90823e3d90fd5b503461021957806003193601126102195760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b50346102195780600319360112610219576020600a54604051908152f35b50346104a5575f3660031901126104a557610538611b6d565b6001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016330361078e576040517f1ed241950000000000000000000000000000000000000000000000000000000081526020816004816001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165afa908115610726575f9161075c575b50600a5481118061074e575b6105e2575080f35b600a55600b80545f9091556040517f095ea7b30000000000000000000000000000000000000000000000000000000081527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b038116600483015260248201839052602082806044810103815f6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165af1918215610726576001600160a01b0392610731575b5016803b156104a5575f80916024604051809481937f3c6b16ab0000000000000000000000000000000000000000000000000000000083528760048401525af1801561072657610711575b506040519081527fcf0cf43969b3f0a08a20481cfa1fd31d1023ab827f0babb8d8125862a9c403f860203392a280f35b61071e9192505f90611aab565b5f905f6106e1565b6040513d5f823e3d90fd5b6107499060203d6020116103b8576103a98183611aab565b610696565b50612710600b5410156105da565b90506020813d602011610786575b8161077760209383611aab565b810103126104a557515f6105ce565b3d915061076a565b7e914334000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a55760203660031901126104a5576001600160a01b036107d66119b3565b165f526007602052602060405f20541515604051908152f35b346104a55760203660031901126104a55760043561080b611b6d565b335f52600c6020526108208160405f206119df565b5080549081156109d3576001810154905f81556212750082018083116109bf574210156108815750506108538133611dcf565b6040519081527fcda231b62bdbcfdebaec108470aea3eb3fcc5ebe00d79b6e252850d4bf5c60b560203392a3005b600201544210610935575060405163a9059cbb60e01b81523360048201526024810182905260208180604481015b03815f6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165af1801561072657610918575b506040519081527f902061c3e3f4d419563154f2c22ef4847f185919d82ff921a64559c1dc83bb7660203392a3005b6109309060203d6020116103b8576103a98183611aab565b6108e9565b611388820290828204611388036109bf576109509042611b60565b90611388828402029181830414811517156109bf576109806020916127108062ed4e006108af9604049104611acd565b61099561098d8286611b60565b600b54611acd565b600b5560405163a9059cbb60e01b8152336004820152602481019190915291829081906044820190565b634e487b7160e01b5f52601160045260245ffd5b7f2b5d497a000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a55760403660031901126104a557610a21610a176119b3565b6024359033611fd6565b602060405160018152f35b346104a5575f3660031901126104a5576040515f6004548060011c90600181168015610b26575b602083108114610b1257828552908115610aee5750600114610a90575b610a8c83610a8081850382611aab565b60405191829182611989565b0390f35b91905060045f527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b915f905b808210610ad457509091508101602001610a80610a70565b919260018160209254838588010152019101909291610abc565b60ff191660208086019190915291151560051b84019091019150610a809050610a70565b634e487b7160e01b5f52602260045260245ffd5b91607f1691610a53565b346104a557610b3e36611a3d565b610b76939193336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163314611af2565b808303610c4b575f5b818110610b8857005b80837f0c26de26c21d52b9af1eae2bc6d3c4f03cf66cf139d32166af29b8aed71351926001600160a01b0388610c2a610c0a610bdc878a610c046102ff8f9c8d8160019f8e610be1610bdc848f8b90611b2f565b611b3f565b15610c33576102ff610bfe938f93610bf893611b2f565b166123c3565b9c611b2f565b95611b2f565b946040519384931695839092916020906040830194151583521515910152565b0390a201610b7f565b6102ff610bfe938f93610c4593611b2f565b166122be565b7f3d0084d4000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a5575f3660031901126104a5576020600b54604051908152f35b346104a5575f3660031901126104a55760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b346104a5575f3660031901126104a557610d18336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163314611af2565b610d20611b6d565b600160ff1960055416176005557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b346104a5575f3660031901126104a557602060405162ed4e008152f35b346104a55760203660031901126104a557600435610d92611b6d565b8015610e6b576113888102818104611388036109bf57612710610dc4910461098d610dbd8285611b60565b9333611ba1565b600b5560405163a9059cbb60e01b8152336004820152602481018290526020816044815f7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03165af1801561072657610e4e575b506040519081527fa8a63b0531e55ae709827fb089d01034e24a200ad14dc710dfa9e962005f629a60203392a2005b610e669060203d6020116103b8576103a98183611aab565b610e1f565b7f58fa63ca000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a5575f3660031901126104a55760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b346104a5575f3660031901126104a55760206040516001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000168152f35b346104a55760203660031901126104a5576001600160a01b03610f3a6119b3565b165f525f602052602060405f2054604051908152f35b346104a55760203660031901126104a557610f696119b3565b610f9e336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163314611af2565b600554906001600160a01b038260081c166001600160a01b0382169182821461102c577fffffffffffffffffffffff0000000000000000000000000000000000000000ff9274ffffffffffffffffffffffffffffffffffffffff00927ff1e04d73c4304b5ff164f9d10c7473e2a1593b740674a6107975e2a7001c1e5c5f80a360081b169116176005555f80f35b7fff302aa0000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a5575f3660031901126104a557602060ff600554166040519015158152f35b346104a55760403660031901126104a5576001600160a01b036110976119b3565b5f60606040516110a681611a8f565b8281528260208201528260408201520152165f52600c60205260806110d060243560405f206119df565b506040516110dd81611a8f565b815491828252600181015460208301908152606060036002840154936040860194855201549301928352604051938452516020840152516040830152516060820152f35b346104a5575f3660031901126104a55760206001600160a01b0360055460081c16604051908152f35b346104a5575f3660031901126104a55760206040516127108152f35b346104a5575f3660031901126104a5576020604051621275008152f35b346104a5575f3660031901126104a5576111c8336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163314611af2565b60055460ff8116156112075760ff19166005557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b7f8dfc202b000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a55761123d36611a3d565b611275939193336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163314611af2565b808303610c4b575f5b81811061128757005b80837f0c26de26c21d52b9af1eae2bc6d3c4f03cf66cf139d32166af29b8aed71351926001600160a01b03886112f8610c0a610bdc878a610c046102ff8f9c8d8160019f8e6112db610bdc848f8b90611b2f565b15611301576102ff610bfe938f936112f293611b2f565b16612369565b0390a20161127e565b6102ff610bfe938f9361131393611b2f565b166121e3565b346104a55760203660031901126104a557600435611362336001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000163314611af2565b61137a816001600160a01b0360055460081c16611ba1565b60055460405163a9059cbb60e01b815260089190911c6001600160a01b0316600482015260248101829052602081806044810103815f6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165af1801561072657611416575b506040519081527f2bccc9c67b5a114aacc02e37dd4596d5aa81ee83a8f7a93e36dd0c901bc258c960203092a2005b61142e9060203d6020116103b8576103a98183611aab565b6113e7565b346104a5575f3660031901126104a557602060405160128152f35b346104a55760203660031901126104a5576001600160a01b0361146f6119b3565b165f52600c602052602060405f2054604051908152f35b346104a5575f3660031901126104a55760206040516113888152f35b346104a55760603660031901126104a5576114bb6119b3565b6114c36119c9565b604435906001600160a01b03831692835f52600160205260405f206001600160a01b0333165f5260205260405f20545f198103611506575b50610a219350611fd6565b83811061159e57841561157257331561154657610a21945f52600160205260405f206001600160a01b0333165f526020528360405f2091039055846114fb565b7f94280d62000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b7fe602df05000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b83907ffb8f41b2000000000000000000000000000000000000000000000000000000005f523360045260245260445260645ffd5b346104a5575f3660031901126104a5576020600254604051908152f35b346104a55760203660031901126104a55760043561160b611b6d565b8015610e6b576040517f23b872dd0000000000000000000000000000000000000000000000000000000081523360048201523060248201528160448201526020816064815f6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000165af18015610726576116c0575b506116928133611dcf565b6040519081527fa428517b481b65176e7c35a57b564d5cf943c8462468b8a0f025fa689173f90160203392a2005b6116d89060203d6020116103b8576103a98183611aab565b611687565b346104a55760403660031901126104a5576116f66119b3565b6001600160a01b0360243591165f52600c60205260405f2080548210156104a557608091611723916119df565b508054906001810154906003600282015491015491604051938452602084015260408301526060820152f35b346104a55760403660031901126104a5576117686119b3565b602435903315611572576001600160a01b031690811561154657335f52600160205260405f20825f526020528060405f20556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b346104a55760203660031901126104a5576004356117ed611b6d565b8015610e6b576117fd8133611ba1565b335f908152600c602052604090208054904262ed4e008101919082106109bf576040519061182a82611a8f565b84825260208201924284526040830190815260608301918583528054680100000000000000008110156118bd57611866916001820181556119df565b9490946118aa5760039351855551600185015551600284015551910155337f7d9230ebb47980ddc758fe4e69ea83a89dafbceb45bd45934798477baa5776685f80a4005b634e487b7160e01b5f525f60045260245ffd5b634e487b7160e01b5f52604160045260245ffd5b346104a5575f3660031901126104a5575f6003548060011c9060018116801561197f575b602083108114610b1257828552908115610aee575060011461192157610a8c83610a8081850382611aab565b91905060035f527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b915f905b80821061196557509091508101602001610a80610a70565b91926001816020925483858801015201910190929161194d565b91607f16916118f5565b602060409281835280519182918282860152018484015e5f828201840152601f01601f1916010190565b600435906001600160a01b03821682036104a557565b602435906001600160a01b03821682036104a557565b80548210156119f8575f5260205f209060021b01905f90565b634e487b7160e01b5f52603260045260245ffd5b9181601f840112156104a55782359167ffffffffffffffff83116104a5576020808501948460051b0101116104a557565b60406003198201126104a55760043567ffffffffffffffff81116104a55781611a6891600401611a0c565b929092916024359067ffffffffffffffff82116104a557611a8b91600401611a0c565b9091565b6080810190811067ffffffffffffffff8211176118bd57604052565b90601f8019910116810190811067ffffffffffffffff8211176118bd57604052565b919082018092116109bf57565b908160209103126104a5575180151581036104a55790565b15611afa5750565b6001600160a01b03907f2bc10c33000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b91908110156119f85760051b0190565b3580151581036104a55790565b356001600160a01b03811681036104a55790565b919082039182116109bf57565b60ff60055416611b7957565b7fd93c0665000000000000000000000000000000000000000000000000000000005f5260045ffd5b9091906001600160a01b03168015611da3575f815f52600760205260405f205415801590611d9c575b8015611d94575b8015611d62575b15611c6e5750600160ff815b1603611c5c57805f525f60205260405f2054838110611c42576020845f94957fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef938587528684520360408620558060025403600255604051908152a3565b915063391434e360e21b5f5260045260245260445260645ffd5b630b7b234960e01b5f5260045260245ffd5b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166040519063aa79979b60e01b8252836004830152602082602481845afa918215610726575f92611d41575b508115611ced575b50611cdb575b60ff600191611be4565b50611ce5816123c3565b506001611cd1565b6024915060209060405192838092635397401b60e01b82528760048301525afa908115610726575f91611d22575b505f611ccb565b611d3b915060203d6020116103b8576103a98183611aab565b5f611d1b565b611d5b91925060203d6020116103b8576103a98183611aab565b905f611cc3565b505f805260096020527fec8156718a8372b1db44bb411437d0870f3e3790d4a08526d024ce1b0b668f6b541515611bd8565b506001611bd1565b505f611bca565b7f96c6fd1e000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b6001600160a01b0316908115611faa575f80805260076020527f6d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6df5415801590611fa2575b8015611f9b575b8015611f86575b15611e935750600160ff815b1603611e80577fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602082611e645f94600254611acd565b60025584845283825260408420818154019055604051908152a3565b630b7b234960e01b5f525f60045260245ffd5b60405163aa79979b60e01b81525f60048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316602082602481845afa918215610726575f92611f65575b508115611f11575b50611eff575b60ff600191611e2d565b50611f095f6123c3565b506001611ef5565b6024915060209060405192838092635397401b60e01b82525f60048301525afa908115610726575f91611f46575b505f611eef565b611f5f915060203d6020116103b8576103a98183611aab565b5f611f3f565b611f7f91925060203d6020116103b8576103a98183611aab565b905f611ee7565b50825f52600960205260405f20541515611e21565b505f611e1a565b506001611e13565b7fec442f05000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b6001600160a01b0316908115611da3576001600160a01b0316918215611faa575f825f52600760205260405f2054158015906121c7575b80156121c0575b80156121ab575b156120b75750600160ff815b16036120a457815f525f60205260405f205481811061208b57817fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92602092855f525f84520360405f2055845f525f825260405f20818154019055604051908152a3565b8263391434e360e21b5f5260045260245260445260645ffd5b50630b7b234960e01b5f5260045260245ffd5b6001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000166040519063aa79979b60e01b8252846004830152602082602481845afa918215610726575f9261218a575b508115612136575b50612124575b60ff600191612027565b5061212e826123c3565b50600161211a565b6024915060209060405192838092635397401b60e01b82528860048301525afa908115610726575f9161216b575b505f612114565b612184915060203d6020116103b8576103a98183611aab565b5f612164565b6121a491925060203d6020116103b8576103a98183611aab565b905f61210c565b50835f52600960205260405f2054151561201b565b505f612014565b505f61200d565b80548210156119f8575f5260205f2001905f90565b5f8181526009602052604090205480156122b8575f1981018181116109bf576008545f198101919082116109bf5781810361226a575b5050506008548015612256575f19016122338160086121ce565b8154905f199060031b1b191690556008555f5260096020525f6040812055600190565b634e487b7160e01b5f52603160045260245ffd5b6122a261227b61228c9360086121ce565b90549060031b1c92839260086121ce565b819391549060031b91821b915f19901b19161790565b90555f52600960205260405f20555f8080612219565b50505f90565b5f8181526007602052604090205480156122b8575f1981018181116109bf576006545f198101919082116109bf57818103612331575b5050506006548015612256575f190161230e8160066121ce565b8154905f199060031b1b191690556006555f5260076020525f6040812055600190565b61235361234261228c9360066121ce565b90549060031b1c92839260066121ce565b90555f52600760205260405f20555f80806122f4565b805f52600960205260405f2054155f146123be57600854680100000000000000008110156118bd576123a761228c82600185940160085560086121ce565b9055600854905f52600960205260405f2055600190565b505f90565b805f52600760205260405f2054155f146123be57600654680100000000000000008110156118bd5761240161228c82600185940160065560066121ce565b9055600654905f52600760205260405f205560019056fea264697066735822122002732556a69228ead19c4abdecf3022b51b2911ab19cde5d984ced7053a9bd8a64736f6c634300081c00330000000000000000000000007423e3d8fc6e626be895ee70ae54a68994c4318e000000000000000000000000a3ce58fac4edec6880b185826c405b57300d7d2d0000000000000000000000005be2e859d0c2453c9aa062860ca27711ff5534320000000000000000000000005e7a9eea6988063a4dbb9ccddb3e04c923e8e37f0000000000000000000000001bc0166f81bdfba98aa13493916895e169d10f660000000000000000000000002f7864a1ca29da0396aafa4148bd4169d7639340
Deployed Bytecode
0x6080806040526004361015610012575f80fd5b5f905f3560e01c90816306fdde03146118d15750806308b4bd63146117d1578063095ea7b31461174f57806311147bd6146116dd57806312e82674146115ef57806318160ddd146115d2578063210ca05d14610ed657806323b872dd146114a257806325d64f4b146114865780632cf53bd81461144e578063313ce5671461143357806332fef3cf14611319578063353140d01461122f5780633f4ba83a1461118357806349e8219314611166578063528cfa981461114a578063570ca735146111215780635a8aed66146110765780635c975abb146110545780636379808f14610f5057806370a0823114610f1957806379248d9414610ed65780637dd51d7a14610e935780637f8661a114610d765780638392331114610d595780638456cb5914610cd35780638ebf2fd614610c905780638f7b565b14610c7357806394126bb114610b3057806395d89b4114610a2c578063a9059cbb146109fb578063ab956054146107ef578063ad5dff73146107b5578063af14052c1461051f578063b7f045e914610501578063b989216a146104bd578063bacbf61b146103f2578063beb7dc341461026a578063dd62ed3e1461021c5763fe6d8124146101d6575f80fd5b3461021957806003193601126102195760206040516001600160a01b037f0000000000000000000000002f7864a1ca29da0396aafa4148bd4169d7639340168152f35b80fd5b5034610219576040366003190112610219576001600160a01b0360406102406119b3565b928261024a6119c9565b9416815260016020522091165f52602052602060405f2054604051908152f35b50346102195761027936611a3d565b90916102b0336001600160a01b037f0000000000000000000000005e7a9eea6988063a4dbb9ccddb3e04c923e8e37f163314611af2565b7f0000000000000000000000007423e3d8fc6e626be895ee70ae54a68994c4318e6001600160a01b031693855b8281106102e8578680f35b856001600160a01b036103046102ff848787611b2f565b611b4c565b16146103ca578060206001600160a01b036103266102ff610377958888611b2f565b166001600160a01b0360055460081c169061034284898b611b2f565b35918b60405180978195829463a9059cbb60e01b845260048401602090939291936001600160a01b0360408201951681520152565b03925af19182156103bf57600192610391575b50016102dd565b6103b19060203d81116103b8575b6103a98183611aab565b810190611ada565b505f61038a565b503d61039f565b6040513d8a823e3d90fd5b6004877f512428f9000000000000000000000000000000000000000000000000000000008152fd5b5034610219578060031936011261021957604051907f70a082310000000000000000000000000000000000000000000000000000000082523060048301526020826024816001600160a01b037f0000000000000000000000007423e3d8fc6e626be895ee70ae54a68994c4318e165afa9081156104b1579061047a575b602090604051908152f35b506020813d6020116104a9575b8161049460209383611aab565b810103126104a5576020905161046f565b5f80fd5b3d9150610487565b604051903d90823e3d90fd5b503461021957806003193601126102195760206040516001600160a01b037f0000000000000000000000005e7a9eea6988063a4dbb9ccddb3e04c923e8e37f168152f35b50346102195780600319360112610219576020600a54604051908152f35b50346104a5575f3660031901126104a557610538611b6d565b6001600160a01b037f0000000000000000000000002f7864a1ca29da0396aafa4148bd4169d763934016330361078e576040517f1ed241950000000000000000000000000000000000000000000000000000000081526020816004816001600160a01b037f000000000000000000000000a3ce58fac4edec6880b185826c405b57300d7d2d165afa908115610726575f9161075c575b50600a5481118061074e575b6105e2575080f35b600a55600b80545f9091556040517f095ea7b30000000000000000000000000000000000000000000000000000000081527f0000000000000000000000001bc0166f81bdfba98aa13493916895e169d10f666001600160a01b038116600483015260248201839052602082806044810103815f6001600160a01b037f0000000000000000000000007423e3d8fc6e626be895ee70ae54a68994c4318e165af1918215610726576001600160a01b0392610731575b5016803b156104a5575f80916024604051809481937f3c6b16ab0000000000000000000000000000000000000000000000000000000083528760048401525af1801561072657610711575b506040519081527fcf0cf43969b3f0a08a20481cfa1fd31d1023ab827f0babb8d8125862a9c403f860203392a280f35b61071e9192505f90611aab565b5f905f6106e1565b6040513d5f823e3d90fd5b6107499060203d6020116103b8576103a98183611aab565b610696565b50612710600b5410156105da565b90506020813d602011610786575b8161077760209383611aab565b810103126104a557515f6105ce565b3d915061076a565b7e914334000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a55760203660031901126104a5576001600160a01b036107d66119b3565b165f526007602052602060405f20541515604051908152f35b346104a55760203660031901126104a55760043561080b611b6d565b335f52600c6020526108208160405f206119df565b5080549081156109d3576001810154905f81556212750082018083116109bf574210156108815750506108538133611dcf565b6040519081527fcda231b62bdbcfdebaec108470aea3eb3fcc5ebe00d79b6e252850d4bf5c60b560203392a3005b600201544210610935575060405163a9059cbb60e01b81523360048201526024810182905260208180604481015b03815f6001600160a01b037f0000000000000000000000007423e3d8fc6e626be895ee70ae54a68994c4318e165af1801561072657610918575b506040519081527f902061c3e3f4d419563154f2c22ef4847f185919d82ff921a64559c1dc83bb7660203392a3005b6109309060203d6020116103b8576103a98183611aab565b6108e9565b611388820290828204611388036109bf576109509042611b60565b90611388828402029181830414811517156109bf576109806020916127108062ed4e006108af9604049104611acd565b61099561098d8286611b60565b600b54611acd565b600b5560405163a9059cbb60e01b8152336004820152602481019190915291829081906044820190565b634e487b7160e01b5f52601160045260245ffd5b7f2b5d497a000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a55760403660031901126104a557610a21610a176119b3565b6024359033611fd6565b602060405160018152f35b346104a5575f3660031901126104a5576040515f6004548060011c90600181168015610b26575b602083108114610b1257828552908115610aee5750600114610a90575b610a8c83610a8081850382611aab565b60405191829182611989565b0390f35b91905060045f527f8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b915f905b808210610ad457509091508101602001610a80610a70565b919260018160209254838588010152019101909291610abc565b60ff191660208086019190915291151560051b84019091019150610a809050610a70565b634e487b7160e01b5f52602260045260245ffd5b91607f1691610a53565b346104a557610b3e36611a3d565b610b76939193336001600160a01b037f0000000000000000000000005e7a9eea6988063a4dbb9ccddb3e04c923e8e37f163314611af2565b808303610c4b575f5b818110610b8857005b80837f0c26de26c21d52b9af1eae2bc6d3c4f03cf66cf139d32166af29b8aed71351926001600160a01b0388610c2a610c0a610bdc878a610c046102ff8f9c8d8160019f8e610be1610bdc848f8b90611b2f565b611b3f565b15610c33576102ff610bfe938f93610bf893611b2f565b166123c3565b9c611b2f565b95611b2f565b946040519384931695839092916020906040830194151583521515910152565b0390a201610b7f565b6102ff610bfe938f93610c4593611b2f565b166122be565b7f3d0084d4000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a5575f3660031901126104a5576020600b54604051908152f35b346104a5575f3660031901126104a55760206040516001600160a01b037f000000000000000000000000a3ce58fac4edec6880b185826c405b57300d7d2d168152f35b346104a5575f3660031901126104a557610d18336001600160a01b037f0000000000000000000000005e7a9eea6988063a4dbb9ccddb3e04c923e8e37f163314611af2565b610d20611b6d565b600160ff1960055416176005557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b346104a5575f3660031901126104a557602060405162ed4e008152f35b346104a55760203660031901126104a557600435610d92611b6d565b8015610e6b576113888102818104611388036109bf57612710610dc4910461098d610dbd8285611b60565b9333611ba1565b600b5560405163a9059cbb60e01b8152336004820152602481018290526020816044815f7f0000000000000000000000007423e3d8fc6e626be895ee70ae54a68994c4318e6001600160a01b03165af1801561072657610e4e575b506040519081527fa8a63b0531e55ae709827fb089d01034e24a200ad14dc710dfa9e962005f629a60203392a2005b610e669060203d6020116103b8576103a98183611aab565b610e1f565b7f58fa63ca000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a5575f3660031901126104a55760206040516001600160a01b037f0000000000000000000000001bc0166f81bdfba98aa13493916895e169d10f66168152f35b346104a5575f3660031901126104a55760206040516001600160a01b037f0000000000000000000000007423e3d8fc6e626be895ee70ae54a68994c4318e168152f35b346104a55760203660031901126104a5576001600160a01b03610f3a6119b3565b165f525f602052602060405f2054604051908152f35b346104a55760203660031901126104a557610f696119b3565b610f9e336001600160a01b037f0000000000000000000000005e7a9eea6988063a4dbb9ccddb3e04c923e8e37f163314611af2565b600554906001600160a01b038260081c166001600160a01b0382169182821461102c577fffffffffffffffffffffff0000000000000000000000000000000000000000ff9274ffffffffffffffffffffffffffffffffffffffff00927ff1e04d73c4304b5ff164f9d10c7473e2a1593b740674a6107975e2a7001c1e5c5f80a360081b169116176005555f80f35b7fff302aa0000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a5575f3660031901126104a557602060ff600554166040519015158152f35b346104a55760403660031901126104a5576001600160a01b036110976119b3565b5f60606040516110a681611a8f565b8281528260208201528260408201520152165f52600c60205260806110d060243560405f206119df565b506040516110dd81611a8f565b815491828252600181015460208301908152606060036002840154936040860194855201549301928352604051938452516020840152516040830152516060820152f35b346104a5575f3660031901126104a55760206001600160a01b0360055460081c16604051908152f35b346104a5575f3660031901126104a55760206040516127108152f35b346104a5575f3660031901126104a5576020604051621275008152f35b346104a5575f3660031901126104a5576111c8336001600160a01b037f0000000000000000000000005e7a9eea6988063a4dbb9ccddb3e04c923e8e37f163314611af2565b60055460ff8116156112075760ff19166005557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b7f8dfc202b000000000000000000000000000000000000000000000000000000005f5260045ffd5b346104a55761123d36611a3d565b611275939193336001600160a01b037f0000000000000000000000005e7a9eea6988063a4dbb9ccddb3e04c923e8e37f163314611af2565b808303610c4b575f5b81811061128757005b80837f0c26de26c21d52b9af1eae2bc6d3c4f03cf66cf139d32166af29b8aed71351926001600160a01b03886112f8610c0a610bdc878a610c046102ff8f9c8d8160019f8e6112db610bdc848f8b90611b2f565b15611301576102ff610bfe938f936112f293611b2f565b16612369565b0390a20161127e565b6102ff610bfe938f9361131393611b2f565b166121e3565b346104a55760203660031901126104a557600435611362336001600160a01b037f0000000000000000000000005e7a9eea6988063a4dbb9ccddb3e04c923e8e37f163314611af2565b61137a816001600160a01b0360055460081c16611ba1565b60055460405163a9059cbb60e01b815260089190911c6001600160a01b0316600482015260248101829052602081806044810103815f6001600160a01b037f0000000000000000000000007423e3d8fc6e626be895ee70ae54a68994c4318e165af1801561072657611416575b506040519081527f2bccc9c67b5a114aacc02e37dd4596d5aa81ee83a8f7a93e36dd0c901bc258c960203092a2005b61142e9060203d6020116103b8576103a98183611aab565b6113e7565b346104a5575f3660031901126104a557602060405160128152f35b346104a55760203660031901126104a5576001600160a01b0361146f6119b3565b165f52600c602052602060405f2054604051908152f35b346104a5575f3660031901126104a55760206040516113888152f35b346104a55760603660031901126104a5576114bb6119b3565b6114c36119c9565b604435906001600160a01b03831692835f52600160205260405f206001600160a01b0333165f5260205260405f20545f198103611506575b50610a219350611fd6565b83811061159e57841561157257331561154657610a21945f52600160205260405f206001600160a01b0333165f526020528360405f2091039055846114fb565b7f94280d62000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b7fe602df05000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b83907ffb8f41b2000000000000000000000000000000000000000000000000000000005f523360045260245260445260645ffd5b346104a5575f3660031901126104a5576020600254604051908152f35b346104a55760203660031901126104a55760043561160b611b6d565b8015610e6b576040517f23b872dd0000000000000000000000000000000000000000000000000000000081523360048201523060248201528160448201526020816064815f6001600160a01b037f0000000000000000000000007423e3d8fc6e626be895ee70ae54a68994c4318e165af18015610726576116c0575b506116928133611dcf565b6040519081527fa428517b481b65176e7c35a57b564d5cf943c8462468b8a0f025fa689173f90160203392a2005b6116d89060203d6020116103b8576103a98183611aab565b611687565b346104a55760403660031901126104a5576116f66119b3565b6001600160a01b0360243591165f52600c60205260405f2080548210156104a557608091611723916119df565b508054906001810154906003600282015491015491604051938452602084015260408301526060820152f35b346104a55760403660031901126104a5576117686119b3565b602435903315611572576001600160a01b031690811561154657335f52600160205260405f20825f526020528060405f20556040519081527f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560203392a3602060405160018152f35b346104a55760203660031901126104a5576004356117ed611b6d565b8015610e6b576117fd8133611ba1565b335f908152600c602052604090208054904262ed4e008101919082106109bf576040519061182a82611a8f565b84825260208201924284526040830190815260608301918583528054680100000000000000008110156118bd57611866916001820181556119df565b9490946118aa5760039351855551600185015551600284015551910155337f7d9230ebb47980ddc758fe4e69ea83a89dafbceb45bd45934798477baa5776685f80a4005b634e487b7160e01b5f525f60045260245ffd5b634e487b7160e01b5f52604160045260245ffd5b346104a5575f3660031901126104a5575f6003548060011c9060018116801561197f575b602083108114610b1257828552908115610aee575060011461192157610a8c83610a8081850382611aab565b91905060035f527fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b915f905b80821061196557509091508101602001610a80610a70565b91926001816020925483858801015201910190929161194d565b91607f16916118f5565b602060409281835280519182918282860152018484015e5f828201840152601f01601f1916010190565b600435906001600160a01b03821682036104a557565b602435906001600160a01b03821682036104a557565b80548210156119f8575f5260205f209060021b01905f90565b634e487b7160e01b5f52603260045260245ffd5b9181601f840112156104a55782359167ffffffffffffffff83116104a5576020808501948460051b0101116104a557565b60406003198201126104a55760043567ffffffffffffffff81116104a55781611a6891600401611a0c565b929092916024359067ffffffffffffffff82116104a557611a8b91600401611a0c565b9091565b6080810190811067ffffffffffffffff8211176118bd57604052565b90601f8019910116810190811067ffffffffffffffff8211176118bd57604052565b919082018092116109bf57565b908160209103126104a5575180151581036104a55790565b15611afa5750565b6001600160a01b03907f2bc10c33000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b91908110156119f85760051b0190565b3580151581036104a55790565b356001600160a01b03811681036104a55790565b919082039182116109bf57565b60ff60055416611b7957565b7fd93c0665000000000000000000000000000000000000000000000000000000005f5260045ffd5b9091906001600160a01b03168015611da3575f815f52600760205260405f205415801590611d9c575b8015611d94575b8015611d62575b15611c6e5750600160ff815b1603611c5c57805f525f60205260405f2054838110611c42576020845f94957fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef938587528684520360408620558060025403600255604051908152a3565b915063391434e360e21b5f5260045260245260445260645ffd5b630b7b234960e01b5f5260045260245ffd5b6001600160a01b037f000000000000000000000000a3ce58fac4edec6880b185826c405b57300d7d2d166040519063aa79979b60e01b8252836004830152602082602481845afa918215610726575f92611d41575b508115611ced575b50611cdb575b60ff600191611be4565b50611ce5816123c3565b506001611cd1565b6024915060209060405192838092635397401b60e01b82528760048301525afa908115610726575f91611d22575b505f611ccb565b611d3b915060203d6020116103b8576103a98183611aab565b5f611d1b565b611d5b91925060203d6020116103b8576103a98183611aab565b905f611cc3565b505f805260096020527fec8156718a8372b1db44bb411437d0870f3e3790d4a08526d024ce1b0b668f6b541515611bd8565b506001611bd1565b505f611bca565b7f96c6fd1e000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b6001600160a01b0316908115611faa575f80805260076020527f6d5257204ebe7d88fd91ae87941cb2dd9d8062b64ae5a2bd2d28ec40b9fbf6df5415801590611fa2575b8015611f9b575b8015611f86575b15611e935750600160ff815b1603611e80577fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef602082611e645f94600254611acd565b60025584845283825260408420818154019055604051908152a3565b630b7b234960e01b5f525f60045260245ffd5b60405163aa79979b60e01b81525f60048201527f000000000000000000000000a3ce58fac4edec6880b185826c405b57300d7d2d6001600160a01b0316602082602481845afa918215610726575f92611f65575b508115611f11575b50611eff575b60ff600191611e2d565b50611f095f6123c3565b506001611ef5565b6024915060209060405192838092635397401b60e01b82525f60048301525afa908115610726575f91611f46575b505f611eef565b611f5f915060203d6020116103b8576103a98183611aab565b5f611f3f565b611f7f91925060203d6020116103b8576103a98183611aab565b905f611ee7565b50825f52600960205260405f20541515611e21565b505f611e1a565b506001611e13565b7fec442f05000000000000000000000000000000000000000000000000000000005f525f60045260245ffd5b6001600160a01b0316908115611da3576001600160a01b0316918215611faa575f825f52600760205260405f2054158015906121c7575b80156121c0575b80156121ab575b156120b75750600160ff815b16036120a457815f525f60205260405f205481811061208b57817fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92602092855f525f84520360405f2055845f525f825260405f20818154019055604051908152a3565b8263391434e360e21b5f5260045260245260445260645ffd5b50630b7b234960e01b5f5260045260245ffd5b6001600160a01b037f000000000000000000000000a3ce58fac4edec6880b185826c405b57300d7d2d166040519063aa79979b60e01b8252846004830152602082602481845afa918215610726575f9261218a575b508115612136575b50612124575b60ff600191612027565b5061212e826123c3565b50600161211a565b6024915060209060405192838092635397401b60e01b82528860048301525afa908115610726575f9161216b575b505f612114565b612184915060203d6020116103b8576103a98183611aab565b5f612164565b6121a491925060203d6020116103b8576103a98183611aab565b905f61210c565b50835f52600960205260405f2054151561201b565b505f612014565b505f61200d565b80548210156119f8575f5260205f2001905f90565b5f8181526009602052604090205480156122b8575f1981018181116109bf576008545f198101919082116109bf5781810361226a575b5050506008548015612256575f19016122338160086121ce565b8154905f199060031b1b191690556008555f5260096020525f6040812055600190565b634e487b7160e01b5f52603160045260245ffd5b6122a261227b61228c9360086121ce565b90549060031b1c92839260086121ce565b819391549060031b91821b915f19901b19161790565b90555f52600960205260405f20555f8080612219565b50505f90565b5f8181526007602052604090205480156122b8575f1981018181116109bf576006545f198101919082116109bf57818103612331575b5050506006548015612256575f190161230e8160066121ce565b8154905f199060031b1b191690556006555f5260076020525f6040812055600190565b61235361234261228c9360066121ce565b90549060031b1c92839260066121ce565b90555f52600760205260405f20555f80806122f4565b805f52600960205260405f2054155f146123be57600854680100000000000000008110156118bd576123a761228c82600185940160085560086121ce565b9055600854905f52600960205260405f2055600190565b505f90565b805f52600760205260405f2054155f146123be57600654680100000000000000008110156118bd5761240161228c82600185940160065560066121ce565b9055600654905f52600760205260405f205560019056fea264697066735822122002732556a69228ead19c4abdecf3022b51b2911ab19cde5d984ced7053a9bd8a64736f6c634300081c0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
0000000000000000000000007423e3d8fc6e626be895ee70ae54a68994c4318e000000000000000000000000a3ce58fac4edec6880b185826c405b57300d7d2d0000000000000000000000005be2e859d0c2453c9aa062860ca27711ff5534320000000000000000000000005e7a9eea6988063a4dbb9ccddb3e04c923e8e37f0000000000000000000000001bc0166f81bdfba98aa13493916895e169d10f660000000000000000000000002f7864a1ca29da0396aafa4148bd4169d7639340
-----Decoded View---------------
Arg [0] : _shadow (address): 0x7423E3D8Fc6e626bE895EE70aE54a68994C4318E
Arg [1] : _voter (address): 0xa3Ce58fAc4EDEC6880B185826c405B57300D7d2d
Arg [2] : _operator (address): 0x5Be2e859D0c2453C9aA062860cA27711ff553432
Arg [3] : _accessHub (address): 0x5e7A9eea6988063A4dBb9CcDDB3E04C923E8E37f
Arg [4] : _voteModule (address): 0x1bC0166f81bdfbA98aA13493916895e169d10f66
Arg [5] : _minter (address): 0x2f7864a1Ca29DA0396aafA4148BD4169d7639340
-----Encoded View---------------
6 Constructor Arguments found :
Arg [0] : 0000000000000000000000007423e3d8fc6e626be895ee70ae54a68994c4318e
Arg [1] : 000000000000000000000000a3ce58fac4edec6880b185826c405b57300d7d2d
Arg [2] : 0000000000000000000000005be2e859d0c2453c9aa062860ca27711ff553432
Arg [3] : 0000000000000000000000005e7a9eea6988063a4dbb9ccddb3e04c923e8e37f
Arg [4] : 0000000000000000000000001bc0166f81bdfba98aa13493916895e169d10f66
Arg [5] : 0000000000000000000000002f7864a1ca29da0396aafa4148bd4169d7639340
[ Download: CSV Export ]
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.