ERC-20
Overview
Max Total Supply
25,299,039.791082 ERC20 ***
Holders
608
Market
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract (WITH 6 Decimals)
Balance
239.677893 ERC20 ***Value
$0.00Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
USDG
Compiler Version
v0.8.21+commit.d9974bed
Optimization Enabled:
Yes with 1000000 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.17; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol"; import {UniswapV2Library} from "@/libraries/UniswapV2Library.sol"; import {IVetoCouncil} from "@/interfaces/IVetoCouncil.sol"; import {Glow} from "@/GLOW.sol"; /** * @title USDG * @notice A contract for swapping USDC for USDG * - the contract takes in USDC and mints USDG * - the contract can only be used EOA's and by allowlisted contracts * - Allow listed contracts include Core Glow Contracts and a GCC/USDG Pair * - USDG is part of the Glow Protocol's Guarded Launch program. * - After the Glow Protocol's Guarded Launch program, USDG will be replaced with USDC */ contract USDG is ERC20Permit, Ownable { error ErrIsContract(); error ErrNotVetoCouncilMember(); error ErrPermanentlyFrozen(); error ToCannotBeUSDCReceiver(); error ErrCannotSwapZero(); /* -------------------------------------------------------------------------- */ /* immutables */ /* -------------------------------------------------------------------------- */ /** * @notice the USDC token */ ERC20Permit public immutable USDC; /** * @notice the address to receive USDC */ address public immutable USDC_RECEIVER; /** * @notice the uniswap v2 factory */ address public immutable UNISWAP_V2_FACTORY; /** * @notice the veto council contract */ IVetoCouncil public immutable vetoCouncilContract; /* -------------------------------------------------------------------------- */ /* state vars */ /* -------------------------------------------------------------------------- */ /** * @notice if true, transfers are permanently frozen * @dev - only veto council agents can set this to true */ bool public permanentlyFreezeTransfers; /* -------------------------------------------------------------------------- */ /* mappings */ /* -------------------------------------------------------------------------- */ /** * @notice the list of contracts that can receive USDG * @dev contracts must be added to this list before they can receive or send USDG * - EOA's can always receive and send USDG */ mapping(address => bool) public allowlistedContracts; /* -------------------------------------------------------------------------- */ /* events */ /* -------------------------------------------------------------------------- */ /** * @notice Emitted when the contract is permanently frozen */ event PermanentFreeze(); /* -------------------------------------------------------------------------- */ /* constructor */ /* -------------------------------------------------------------------------- */ /** * @param _usdc the USDC token * @param _usdcReceiver the address to receive USDC from the `swap` function * @param _owner the owner of the contract * @param _univ2Factory the uniswap v2 factory * @param _glow the glow token * @param _gcc the gcc token * @param _holdingContract the holding contract * @param _vetoCouncilContract the veto council contract * @param _impactCatalyst the impact catalyst contract */ constructor( address _usdc, address _usdcReceiver, address _owner, address _univ2Factory, address _glow, address _gcc, address _holdingContract, address _vetoCouncilContract, address _impactCatalyst ) payable Ownable(_owner) ERC20("Guarded USDC ", "USDG-GLOW") ERC20Permit("Guarded USDC") { USDC = ERC20Permit(_usdc); USDC_RECEIVER = _usdcReceiver; UNISWAP_V2_FACTORY = _univ2Factory; allowlistedContracts[_usdcReceiver] = true; allowlistedContracts[_holdingContract] = true; //Allowlist the glow/usdg and the gcc/usdg pair address glowUSDGPair = getPair(UNISWAP_V2_FACTORY, address(this), _glow); allowlistedContracts[glowUSDGPair] = true; address gccUSDGPair = getPair(UNISWAP_V2_FACTORY, address(this), _gcc); allowlistedContracts[gccUSDGPair] = true; vetoCouncilContract = IVetoCouncil(_vetoCouncilContract); allowlistedContracts[_impactCatalyst] = true; } /* -------------------------------------------------------------------------- */ /* mint */ /* -------------------------------------------------------------------------- */ /** * @notice Mints USDG {to} * @param to address to mint USDG * @param amount amount of USDG to mint * @dev only allowlisted contracts and EOA's can mint USDG * @dev USDG is minted 1:1 with USDC */ function swap(address to, uint256 amount) public { if (to == USDC_RECEIVER) revert ToCannotBeUSDCReceiver(); if (amount == 0) revert ErrCannotSwapZero(); uint256 balBefore = USDC.balanceOf(USDC_RECEIVER); USDC.transferFrom(msg.sender, USDC_RECEIVER, amount); uint256 balAfter = USDC.balanceOf(USDC_RECEIVER); amount = balAfter - balBefore; _mint(to, amount); } /* -------------------------------------------------------------------------- */ /* veto council */ /* -------------------------------------------------------------------------- */ /** * @notice Freezes transfers permanently * @dev only veto council members can call this function * @dev after this function is called, all transfers are permanently frozen */ function freezeContract() external { if (!vetoCouncilContract.isCouncilMember(msg.sender)) { revert ErrNotVetoCouncilMember(); } permanentlyFreezeTransfers = true; emit PermanentFreeze(); } /* -------------------------------------------------------------------------- */ /* overrides */ /* -------------------------------------------------------------------------- */ /** * @notice the decimals of USDG * @dev matches the decimals of USDC * @return decimals - the decimals of USDG */ function decimals() public view virtual override returns (uint8) { return 6; } /** * @dev override transfers to make sure that only EOA's and allowlisted contracts can send or receive USDG * @param from the address to send USDG from * @param to the address to send USDG to * @param value the amount of USDG to send */ function _update(address from, address to, uint256 value) internal override(ERC20) { if (permanentlyFreezeTransfers) { revert ErrPermanentlyFrozen(); } _revertIfNotAllowlistedContract(from); _revertIfNotAllowlistedContract(to); super._update(from, to, value); } /** * @dev reverts if the address is a contract and not allowlisted */ function _revertIfNotAllowlistedContract(address _address) internal view { if (_isContract(_address)) { if (!allowlistedContracts[_address]) { revert ErrIsContract(); } } } /** * @dev returns true if the address is a contract * @param _address the address to check * @return isContract - true if the address is a contract */ function _isContract(address _address) internal view returns (bool isContract) { assembly { isContract := gt(extcodesize(_address), 0) } } /** * @notice Returns the univ2 pair for a given factory and token * @param factory the univ2 factory * @param _tokenA the first token * @param _tokenB the second token * @return pair - the univ2 pair */ function getPair(address factory, address _tokenA, address _tokenB) internal view virtual returns (address pair) { pair = UniswapV2Library.pairFor(factory, _tokenA, _tokenB); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/ERC20Permit.sol) pragma solidity ^0.8.20; import {IERC20Permit} from "./IERC20Permit.sol"; import {ERC20} from "../ERC20.sol"; import {ECDSA} from "../../../utils/cryptography/ECDSA.sol"; import {EIP712} from "../../../utils/cryptography/EIP712.sol"; import {Nonces} from "../../../utils/Nonces.sol"; /** * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ abstract contract ERC20Permit is ERC20, IERC20Permit, EIP712, Nonces { // solhint-disable-next-line var-name-mixedcase bytes32 private constant _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"); /** * @dev Permit deadline has expired. */ error ERC2612ExpiredSignature(uint256 deadline); /** * @dev Mismatched signature. */ error ERC2612InvalidSigner(address signer, address owner); /** * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`. * * It's a good idea to use the same `name` that is defined as the ERC20 token name. */ constructor(string memory name) EIP712(name, "1") {} /** * @dev See {IERC20Permit-permit}. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) public virtual { if (block.timestamp > deadline) { revert ERC2612ExpiredSignature(deadline); } bytes32 structHash = keccak256(abi.encode(_PERMIT_TYPEHASH, owner, spender, value, _useNonce(owner), deadline)); bytes32 hash = _hashTypedDataV4(structHash); address signer = ECDSA.recover(hash, v, r, s); if (signer != owner) { revert ERC2612InvalidSigner(signer, owner); } _approve(owner, spender, value); } /** * @dev See {IERC20Permit-nonces}. */ function nonces(address owner) public view virtual override(IERC20Permit, Nonces) returns (uint256) { return super.nonces(owner); } /** * @dev See {IERC20Permit-DOMAIN_SEPARATOR}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view virtual returns (bytes32) { return _domainSeparatorV4(); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol) pragma solidity ^0.8.20; import {Context} from "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * The initial owner is set to the address provided by the deployer. This can * later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; /** * @dev The caller account is not authorized to perform an operation. */ error OwnableUnauthorizedAccount(address account); /** * @dev The owner is not a valid owner account. (eg. `address(0)`) */ error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the address provided by the deployer as the initial owner. */ constructor(address initialOwner) { _transferOwnership(initialOwner); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { if (owner() != _msgSender()) { revert OwnableUnauthorizedAccount(_msgSender()); } } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby disabling any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { if (newOwner == address(0)) { revert OwnableInvalidOwner(address(0)); } _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
pragma solidity ^0.8.19; import {IUniswapV2Pair} from "@/interfaces/IUniswapV2Pair.sol"; library UniswapV2Library { // returns sorted token addresses, used to handle return values from pairs sorted in this order function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) { require(tokenA != tokenB, "UniswapV2Library: IDENTICAL_ADDRESSES"); (token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA); require(token0 != address(0), "UniswapV2Library: ZERO_ADDRESS"); } // calculates the CREATE2 address for a pair without making any external calls function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) { (address token0, address token1) = sortTokens(tokenA, tokenB); pair = address( uint160( uint256( keccak256( abi.encodePacked( hex"ff", factory, keccak256(abi.encodePacked(token0, token1)), hex"96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f" // init code hash ) ) ) ) ); } // fetches and sorts the reserves for a pair function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint256 reserveA, uint256 reserveB) { (address token0,) = sortTokens(tokenA, tokenB); (uint256 reserve0, uint256 reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves(); (reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0); } // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset function quote(uint256 amountA, uint256 reserveA, uint256 reserveB) internal pure returns (uint256 amountB) { require(amountA > 0, "UniswapV2Library: INSUFFICIENT_AMOUNT"); require(reserveA > 0 && reserveB > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY"); amountB = amountA * (reserveB) / reserveA; } // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut) internal pure returns (uint256 amountOut) { require(amountIn > 0, "UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT"); require(reserveIn > 0 && reserveOut > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY"); uint256 amountInWithFee = amountIn * (997); uint256 numerator = amountInWithFee * (reserveOut); uint256 denominator = reserveIn * (1000) + (amountInWithFee); amountOut = numerator / denominator; } // given an output amount of an asset and pair reserx ves, returns a required input amount of the other asset function getAmountIn(uint256 amountOut, uint256 reserveIn, uint256 reserveOut) internal pure returns (uint256 amountIn) { require(amountOut > 0, "UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT"); require(reserveIn > 0 && reserveOut > 0, "UniswapV2Library: INSUFFICIENT_LIQUIDITY"); uint256 numerator = reserveIn * (amountOut) * (1000); uint256 denominator = reserveOut - (amountOut) * (997); amountIn = (numerator / denominator) + (1); } // // performs chained getAmountOut calculations on any number of pairs // function getAmountsOut(address factory, uint256 amountIn, address[] memory path) // internal // view // returns (uint256[] memory amounts) // { // require(path.length >= 2, "UniswapV2Library: INVALID_PATH"); // amounts = new uint[](path.length); // amounts[0] = amountIn; // for (uint256 i; i < path.length - 1; i++) { // (uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i], path[i + 1]); // amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut); // } // } // // performs chained getAmountIn calculations on any number of pairs // function getAmountsIn(address factory, uint256 amountOut, address[] memory path) // internal // view // returns (uint256[] memory amounts) // { // require(path.length >= 2, "UniswapV2Library: INVALID_PATH"); // amounts = new uint[](path.length); // amounts[amounts.length - 1] = amountOut; // for (uint256 i = path.length - 1; i > 0; i--) { // (uint256 reserveIn, uint256 reserveOut) = getReserves(factory, path[i - 1], path[i]); // amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut); // } // } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; interface IVetoCouncil { /* -------------------------------------------------------------------------- */ /* errors */ /* -------------------------------------------------------------------------- */ error CallerNotGovernance(); error NoRewards(); error ZeroAddressInConstructor(); error MaxCouncilMembersExceeded(); /* -------------------------------------------------------------------------- */ /* events */ /* -------------------------------------------------------------------------- */ /** * @param oldMember The address of the member to be slashed or removed * @param newMember The address of the new member (0 = no new member) * @param slashOldMember Whether to slash the member or not */ event VetoCouncilSeatsEdited(address indexed oldMember, address indexed newMember, bool slashOldMember); /** * @dev emitted when a council member is paid out * @param account The address of the council member * @param amountNow The amount paid out now * @param amountToBeVested The amount to be vested */ event CouncilMemberPayout(address indexed account, uint256 amountNow, uint256 amountToBeVested); /* -------------------------------------------------------------------------- */ /* state-changing */ /* -------------------------------------------------------------------------- */ /** * @notice Add or remove a council member * @param oldMember The address of the member to be slashed or removed * @param newMember The address of the new member (0 = no new member) * @param slashOldMember Whether to slash the member or not * @return - true if the council member was added or removed, false if nothing was done * - the function should return false if the new member is already a council member * - if the old member is not a council member, the function should return false * - if the old member is a council member and the new member is the same as the old member, the function should return false * - by adding a new member there would be more than 7 council members, the function should return false */ function addAndRemoveCouncilMember(address oldMember, address newMember, bool slashOldMember) external returns (bool); /** * @notice Payout the council member * @param member The address of the council member * @param nonce The payout nonce to claim from * @param sync Whether to sync the vesting schedule or not * @param members The addresses of the council members that were active at `nonce` */ function claimPayout(address member, uint256 nonce, bool sync, address[] memory members) external; /* -------------------------------------------------------------------------- */ /* view */ /* -------------------------------------------------------------------------- */ /** * @notice returns true if the member is a council member * @param member The address of the member to be checked * @return - true if the member is a council member */ function isCouncilMember(address member) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; import {IGlow} from "./interfaces/IGlow.sol"; import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol"; import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol"; import {_GENESIS_TIMESTAMP} from "@/Constants/Constants.sol"; /** * @title Glow * @author DavidVorick * @author 0xSimon(twitter) - OxSimbo(github) * @notice The Glow token is the backbone of the protocol * - Solar farms are rewarded with glow tokens as they produce solar * - GCA's (Glow Certification Agents) and Veto Council Members are rewarded in GLOW * - for their contributions * - The Grants Treasury is rewarded in GLOW for their contributions * - Holders can anchor (stake) glow to earn voting power in governance * - anchoring lasts 5 years from the point of unstaking */ contract Glow is ERC20, ERC20Permit, IGlow { /* -------------------------------------------------------------------------- */ /* constants */ /* -------------------------------------------------------------------------- */ /// @notice The cooldown period after unstaking before a user can claim their tokens uint256 private constant _STAKE_COOLDOWN_PERIOD = 365 days * 5; /// @notice The amount of GLW that is minted per second for the GCA and Miner Pool /// @notice 185,000 GLW per week /// @dev 175,000 to miners /// @dev 10,000 to the GCAs uint256 public constant GCA_AND_MINER_POOL_INFLATION_PER_SECOND = 185_000 * 1 ether / uint256(7 days); /// @notice The amount of GLW that is minted per second for the Veto Council /// @notice 5,000 GLW per week uint256 public constant VETO_COUNCIL_INFLATION_PER_SECOND = 5_000 * 1 ether / uint256(7 days); /// @notice The amount of GLW that is minted per second for the Grants Treasury /// @notice 40,000 GLW per week uint256 public constant GRANTS_TREASURY_INFLATION_PER_SECOND = 40_000 * 1 ether / uint256(7 days); /// @notice the maximum number of times a user can unstake without clearing their unstaked positions /// @notice before they are forced to wait 1 day before staking again uint256 public constant MAX_UNSTAKES_BEFORE_EMERGENCY_COOLDOWN = 100; /// @notice the cooldown period once users stake over 100 times uint256 public constant EMERGENCY_COOLDOWN_PERIOD = 1 days; /* -------------------------------------------------------------------------- */ /* immutables */ /* -------------------------------------------------------------------------- */ /// @notice The address of the Early Liquidity Contract // solhint-disable-next-line var-name-mixedcase address public immutable EARLY_LIQUIDITY_ADDRESS; /// @notice the GCA And Miner Pool address address public immutable GCA_AND_MINER_POOL_ADDRESS; /// @notice the Veto Council address address public immutable VETO_COUNCIL_ADDRESS; /// @notice the Grants Treasury address address public immutable GRANTS_TREASURY_ADDRESS; /* -------------------------------------------------------------------------- */ /* state vars */ /* -------------------------------------------------------------------------- */ /// @notice The last time the GCA and Miner Pool claimed GLW uint256 public gcaAndMinerPoolLastClaimedTimestamp; /// @notice The last time the Veto Council claimed GLW uint256 public vetoCouncilLastClaimedTimestamp; /// @notice The last time the Grants Treasury claimed GLW uint256 public grantsTreasuryLastClaimedTimestamp; /* -------------------------------------------------------------------------- */ /* mappings */ /* -------------------------------------------------------------------------- */ /// @notice stores the total amount of GLOW staked by a user mapping(address => uint256) public numStaked; /// @notice stores the unstaked positions of a user mapping(address => mapping(uint256 => UnstakedPosition)) private _unstakedPositions; /// @notice stores the head of the unstaked positions of a user /// @dev the head is the last index with data. If we need to push, we push at head + 1 /// @dev if the head is zero, there may or may not be data. mapping(address => Pointers) private _unstakedPositionPointers; /// @notice stores the last time a user staked in case the user has over 100 staked positions mapping(address => uint256) public emergencyLastUnstakeTimestamp; /* -------------------------------------------------------------------------- */ /* constructor */ /* -------------------------------------------------------------------------- */ /* * @notice Sets the immutable variables (GENESIS_TIMESTAMP, EARLY_LIQUIDITY_ADDRESS) * @notice sends 12 million GLW to the Early Liquidity Contract and 96 million GLW to the unlocker contract * @param _earlyLiquidityAddress The address of the Early Liquidity Contract * @param _vestingContract The address of the vesting contract * @param _gcaAndMinerPoolAddress The address of the GCA and Miner Pool * @param _vetoCouncilAddress The address of the Veto Council * @param _grantsTreasuryAddress The address of the Grants Treasury */ constructor( address _earlyLiquidityAddress, address _vestingContract, address _gcaAndMinerPoolAddress, address _vetoCouncilAddress, address _grantsTreasuryAddress ) payable ERC20("Glow", "GLW-BETA") ERC20Permit("Glow") { EARLY_LIQUIDITY_ADDRESS = _earlyLiquidityAddress; GCA_AND_MINER_POOL_ADDRESS = _gcaAndMinerPoolAddress; VETO_COUNCIL_ADDRESS = _vetoCouncilAddress; GRANTS_TREASURY_ADDRESS = _grantsTreasuryAddress; _handleConstructorMint(_earlyLiquidityAddress, _vestingContract, _grantsTreasuryAddress); } /* -------------------------------------------------------------------------- */ /* staking */ /* -------------------------------------------------------------------------- */ /** * @inheritdoc IGlow * @dev if the user has unstaked positions that have already expired, * - the function will auto claim those tokens for the user */ function stake(uint256 stakeAmount) external { //Cannot stake zero tokens if (stakeAmount == 0) _revert(IGlow.CannotStakeZeroTokens.selector); //Find head tail in the mapping IGlow.Pointers memory pointers = _unstakedPositionPointers[msg.sender]; uint256 head = pointers.head; //Init the unstakedTotal uint256 amountInUserUnstakePool; //Init the new head uint256 newHead = head; uint256 tail = pointers.tail; //We need to loop through starting from the head (newest positions) for (uint256 i = head; i >= tail; --i) { //load the posiiton from storage into memory UnstakedPosition memory position = _unstakedPositions[msg.sender][i]; //increase the amount in the user unstake pool //by the amount that is in the position we are on amountInUserUnstakePool += position.amount; //If it's exactly equal, that means the data will be fully cleared //And the head moves to i-1 or 0(if fully empty now) if (amountInUserUnstakePool == stakeAmount) { //If i is 0 and the amount is exactly zero, //that means we can restart the unstaked positions from scratch if (i == 0) { newHead = 0; delete _unstakedPositions[msg.sender][newHead]; } //If i is not zero, we can just move the head to i-1 else { newHead = i - 1; } break; } //If the amount in the user unstake pool is greater than the stake amount //That means we overshot and we need to pull back the amount we overshot by if (amountInUserUnstakePool > stakeAmount) { uint256 overshoot = amountInUserUnstakePool - stakeAmount; //Let;s say we are at 49 in the stake pool, and then the current position has 10. //and we wanted to stake a total of 50 //Once we add the amount in this pool, we have a total of 59 in the stake pool amount. //That means we overshot by 59-50, and the new amount in the stake pool //Should be the overshot amount. //Instead of having 10 in the latest pool, we have 9 since we needed to pull 1 newHead = i; //If we overshot, the head stays the same and it does indeed still have data _unstakedPositions[msg.sender][i].amount = SafeCast.toUint192(overshoot); break; } //If we have reached the tail (oldest position) and we still haven't overshot //We delete the tail if (i == tail) { if (stakeAmount > amountInUserUnstakePool) { delete _unstakedPositions[msg.sender][tail]; } newHead = tail; break; } } //If the new head is not equal to the old head, we update the head in storage //We use this equality check to prevent redundant sstores if (newHead != head) { _unstakedPositionPointers[msg.sender].head = SafeCast.toUint128(newHead); } //If the stake amount is greater than the amount in the user unstake pool //Then we need to transfer the difference from the user to the contract if (stakeAmount > amountInUserUnstakePool) { uint256 amountGlowToTransfer = stakeAmount - amountInUserUnstakePool; _transfer(msg.sender, address(this), amountGlowToTransfer); } //Note: We don't handle the zero case since that would be a redundant transfer //Increase the number of tokens staked by the user numStaked[msg.sender] += stakeAmount; //Emit the Stake event emit IGlow.Stake(msg.sender, stakeAmount); } /** * @inheritdoc IGlow */ function unstake(uint256 amount) external { //Revert on zero amount if (amount == 0) _revert(IGlow.CannotUnstakeZeroTokens.selector); //Load the number of tokens staked by the user uint256 numAccountStaked = numStaked[msg.sender]; //if the user is unstaking more than they have staked, we revert if (amount > numAccountStaked) { _revert(IGlow.UnstakeAmountExceedsStakedBalance.selector); } //Find the length of the unstaked positions starting at the tail //This gives us the # of unstaked positions that the user has IGlow.Pointers memory pointers = _unstakedPositionPointers[msg.sender]; uint256 adjustedLenBefore = pointers.head - pointers.tail + 1; uint256 indexInMappingToPushTo = pointers.head + 1; if (pointers.head == pointers.tail) { if (_unstakedPositions[msg.sender][pointers.head].amount == 0) { adjustedLenBefore = 0; indexInMappingToPushTo = pointers.head; } } //if adjustlenBefore >= 99 // we + 2 to proactively set emergencyLastUpdate when length will be 99 so the 100th unstake will trigger cooldown if (adjustedLenBefore + 2 > MAX_UNSTAKES_BEFORE_EMERGENCY_COOLDOWN) { uint256 lastUnstakedTimestamp = emergencyLastUnstakeTimestamp[msg.sender]; //Handle the zero case if (lastUnstakedTimestamp == 0) { emergencyLastUnstakeTimestamp[msg.sender] = block.timestamp; // if the user has unstaked before, we need to check if they are in cooldown } else if (block.timestamp - lastUnstakedTimestamp < EMERGENCY_COOLDOWN_PERIOD) { _revert(IGlow.UnstakingOnEmergencyCooldown.selector); // if the user is not in cooldown, we need to update the timestamp } else { emergencyLastUnstakeTimestamp[msg.sender] = block.timestamp; } } //Decrease the number of tokens staked by the user numStaked[msg.sender] = numAccountStaked - amount; _unstakedPositions[msg.sender][indexInMappingToPushTo] = UnstakedPosition({ amount: SafeCast.toUint192(amount), cooldownEnd: SafeCast.toUint64(block.timestamp + _STAKE_COOLDOWN_PERIOD) }); pointers = Pointers({head: SafeCast.toUint128(indexInMappingToPushTo), tail: pointers.tail}); _unstakedPositionPointers[msg.sender] = pointers; emit IGlow.Unstake(msg.sender, amount); } /** * @inheritdoc IGlow */ function claimUnstakedTokens(uint256 amount) external { //Cannot claim zero tokens if (amount == 0) _revert(IGlow.CannotClaimZeroTokens.selector); uint256 claimableTotal; //Cache len]0 IGlow.Pointers memory pointers = _unstakedPositionPointers[msg.sender]; uint256 head = pointers.head; uint256 tail = pointers.tail; uint256 newTail = tail; //Loop through the unstaked positions until claimableTotal >= amount //Tail will also be <= len so no risk of underflow //Tail should also remain close to len since we delete unstaked positions as we claim them //and we restrict the number of unstaked positions to 100 before a cooldown is enforced on the user for (uint256 i = tail; i <= head; ++i) { //Read the position from storage UnstakedPosition storage position = _unstakedPositions[msg.sender][i]; //if block.timestamp <= position.cooldownEnd //If the position is not ready to be claimed, we revert // - this is so because we can't claim tokens that are not ready to be claimed // - and positions are chronologically ordered, so if one position is not ready to be claimed, // - all following positions are not ready to be claimed // - therefore, we can revert early since we'll never have enough tokens to fulfill the claim if (position.cooldownEnd >= block.timestamp) { _revert(IGlow.InsufficientClaimableBalance.selector); } //Increment the claimableTotal by the position amount claimableTotal += position.amount; //If the claimableTotal is equal to the amount, we need to delete the old position and increment the newTail // - since the old unstaked positions EXACTLY fulfill the amount if (claimableTotal == amount) { newTail = i + 1; if (newTail > head) { newTail = head; } //Update the tail in storage _unstakedPositionPointers[msg.sender] = Pointers({head: SafeCast.toUint128(head), tail: SafeCast.toUint128(newTail)}); //delete the position for a gas refund delete _unstakedPositions[msg.sender][i]; //transfer the amount to the user _transfer(address(this), msg.sender, amount); //emit the claim event emit IGlow.ClaimUnstakedGLW(msg.sender, amount); return; } //If the claimableTotal is greater than the amount, we need to deduct from the position in storage // and the tail will stay the same since the unstaked position still has some tokens left if (claimableTotal > amount) { //New tail is equal to i newTail = i; //Check redundancy before sstoring the new tail if (newTail != tail) { _unstakedPositionPointers[msg.sender] = Pointers({head: SafeCast.toUint128(head), tail: SafeCast.toUint128(newTail)}); } //Calculate the amount that is left in the position after the claim uint256 amountLeftInPosition = claimableTotal - amount; //Update the position amount in storage position.amount = SafeCast.toUint192(amountLeftInPosition); //Transfer the amount to the user _transfer(address(this), msg.sender, amount); //Emit the claim event emit IGlow.ClaimUnstakedGLW(msg.sender, amount); return; } //When looping, we delete all unstaked positions that are consumed // as part of the token claim delete _unstakedPositions[msg.sender][i]; } _revert(IGlow.InsufficientClaimableBalance.selector); } /* -------------------------------------------------------------------------- */ /* inflation */ /* -------------------------------------------------------------------------- */ /** * @inheritdoc IGlow */ function claimGLWFromGCAAndMinerPool() external returns (uint256) { //If the address is not set, we revert if (_isZeroAddress(GCA_AND_MINER_POOL_ADDRESS)) _revert(IGlow.AddressNotSet.selector); //If the caller is not the GCA and Miner Pool, we revert if (msg.sender != GCA_AND_MINER_POOL_ADDRESS) _revert(IGlow.CallerNotGCA.selector); //Read the timestamp from storage uint256 timestampInStorage = gcaAndMinerPoolLastClaimedTimestamp; //If the timestamp is zero, we set it to the genesis timestamp // else we set it to the timestamp in storage uint256 timestampToClaimFrom = timestampInStorage == 0 ? GENESIS_TIMESTAMP() : timestampInStorage; //Calculate the seconds since the last claim uint256 secondsSinceLastClaim = block.timestamp - timestampToClaimFrom; //Calculate the amount to claim uint256 amountToClaim = secondsSinceLastClaim * GCA_AND_MINER_POOL_INFLATION_PER_SECOND; //If the amount to claim is zero, we return zero and exit if (amountToClaim == 0) return 0; //if the amount is not zero, we update the timestamp in storage gcaAndMinerPoolLastClaimedTimestamp = block.timestamp; //and we mint the amount to the GCA and Miner Pool _mint(GCA_AND_MINER_POOL_ADDRESS, amountToClaim); //we then return the amount to claim return amountToClaim; } /** * @inheritdoc IGlow */ function claimGLWFromVetoCouncil() external returns (uint256) { //If the address is not set, we revert if (_isZeroAddress(VETO_COUNCIL_ADDRESS)) _revert(IGlow.AddressNotSet.selector); //If the caller is not the Veto Council, we revert if (msg.sender != VETO_COUNCIL_ADDRESS) _revert(IGlow.CallerNotVetoCouncil.selector); //Read the timestamp from storage uint256 timestampInStorage = vetoCouncilLastClaimedTimestamp; //If the timestamp is zero, we set it to the genesis timestamp // else we set it to the timestamp in storage uint256 timestampToClaimFrom = timestampInStorage == 0 ? GENESIS_TIMESTAMP() : timestampInStorage; //Calculate the seconds since the last claim uint256 secondsSinceLastClaim = block.timestamp - timestampToClaimFrom; //Calculate the amount to claim uint256 amountToClaim = secondsSinceLastClaim * VETO_COUNCIL_INFLATION_PER_SECOND; //If the amount to claim is zero, we return zero and exit if (amountToClaim == 0) return 0; //if the amount is not zero, we update the timestamp in storage vetoCouncilLastClaimedTimestamp = block.timestamp; //and we mint the amount to the Veto Council _mint(VETO_COUNCIL_ADDRESS, amountToClaim); //we then return the amount to claim return amountToClaim; } /** * @inheritdoc IGlow */ function claimGLWFromGrantsTreasury() external returns (uint256) { //If the address is not set, we revert if (_isZeroAddress(GRANTS_TREASURY_ADDRESS)) _revert(IGlow.AddressNotSet.selector); //If the caller is not the Grants Treasury, we revert if (msg.sender != GRANTS_TREASURY_ADDRESS) _revert(IGlow.CallerNotGrantsTreasury.selector); //Read the timestamp from storage uint256 timestampInStorage = grantsTreasuryLastClaimedTimestamp; //If the timestamp is zero, we set it to the genesis timestamp // else we set it to the timestamp in storage uint256 timestampToClaimFrom = timestampInStorage == 0 ? GENESIS_TIMESTAMP() : timestampInStorage; //Calculate the seconds since the last claim uint256 secondsSinceLastClaim = block.timestamp - timestampToClaimFrom; //Calculate the amount to claim uint256 amountToClaim = secondsSinceLastClaim * GRANTS_TREASURY_INFLATION_PER_SECOND; //If the amount to claim is zero, we return zero and exit if (amountToClaim == 0) return 0; //if the amount is not zero, we update the timestamp in storage grantsTreasuryLastClaimedTimestamp = block.timestamp; //and we mint the amount to the Grants Treasury _mint(GRANTS_TREASURY_ADDRESS, amountToClaim); //we then return the amount to claim return amountToClaim; } /* -------------------------------------------------------------------------- */ /* view functions */ /* -------------------------------------------------------------------------- */ /** * @inheritdoc IGlow */ function unstakedPositionsOf(address account) external view returns (UnstakedPosition[] memory) { IGlow.Pointers memory pointers = _unstakedPositionPointers[account]; uint256 start = pointers.tail; uint256 end = pointers.head + 1; UnstakedPosition[] memory positions = new UnstakedPosition[](end - start); if (pointers.tail == pointers.head) { UnstakedPosition memory position = _unstakedPositions[account][pointers.head]; if (position.amount == 0) { // solhint-disable-next-line no-inline-assembly assembly { mstore(positions, 0) } return positions; } positions[0] = position; ++start; } unchecked { //Start is always less than end so no risk of underflow //start should also be close to end since we delete unstaked positions as we claim them // and we restrict the number of unstaked positions to 100 before a cooldown is enforced on the user for (uint256 i = start; i < end; ++i) { UnstakedPosition memory position = _unstakedPositions[account][i]; //If the tail is zero and the amount is zero, that means //There has never been a stake, because if there had been a stake, //The amount wouldn't be empty, //And if the amount is empty that means that there has been a claim on that position //And the tail would not be zero if (i == 0) { if (position.amount == 0) { // solhint-disable-next-line no-inline-assembly assembly { //set the length to 0 in memory mstore(positions, 0) } break; } } //No addition, therefore no risk of overflow //i always >= start so no risk of underflow positions[i - start] = position; } return positions; } } /** * @notice returns the tail of the unstaked positions for the user * @param account the account to get the tail for * @return the tail of the unstaked positions for the user */ function accountUnstakedPositionPointers(address account) external view returns (IGlow.Pointers memory) { return _unstakedPositionPointers[account]; } /** * @inheritdoc IGlow */ function unstakedPositionsOf(address account, uint256 start, uint256 end) external view returns (UnstakedPosition[] memory) { IGlow.Pointers memory pointers = _unstakedPositionPointers[account]; start = start + pointers.tail; end = end + pointers.tail; if (end > pointers.head + 1) { end = pointers.head + 1; } //If the start is greater than the end, we return an empty array if (start >= end) { return new UnstakedPosition[](0); } UnstakedPosition[] memory positions = new UnstakedPosition[](end - start); if (pointers.tail == pointers.head) { UnstakedPosition memory position = _unstakedPositions[account][pointers.head]; if (position.amount == 0) { // solhint-disable-next-line no-inline-assembly assembly { mstore(positions, 0) } return positions; } positions[0] = position; ++start; } unchecked { //Start is always less than end so no risk of underflow //start should also be close to end since we delete unstaked positions as we claim them // and we restrict the number of unstaked positions to 100 before a cooldown is enforced on the user for (uint256 i = start; i < end; ++i) { UnstakedPosition memory position = _unstakedPositions[account][i]; //If the tail is zero and the amount is zero, that means //There has never been a stake, because if there had been a stake, //The amount wouldn't be empty, //And if the amount is empty that means that there has been a claim on that position //And the tail would not be zero if (i == 0) { if (position.amount == 0) { // solhint-disable-next-line no-inline-assembly assembly { //set the length to 0 in memory mstore(positions, 0) } break; } } //No addition, therefore no risk of overflow //i always >= start so no risk of underflow positions[i - start] = position; } return positions; } } /** * @inheritdoc IGlow */ function gcaInflationData() external view returns (uint256, uint256 totalAlreadyClaimed, uint256 totalToClaim) { if (_isZeroAddress(GCA_AND_MINER_POOL_ADDRESS)) _revert(IGlow.AddressNotSet.selector); uint256 timestampInStorage = gcaAndMinerPoolLastClaimedTimestamp; uint256 timestampToClaimFrom = timestampInStorage == 0 ? GENESIS_TIMESTAMP() : timestampInStorage; uint256 secondsSinceLastClaim = block.timestamp - timestampToClaimFrom; totalToClaim = secondsSinceLastClaim * GCA_AND_MINER_POOL_INFLATION_PER_SECOND; totalAlreadyClaimed = timestampToClaimFrom - GENESIS_TIMESTAMP(); return (timestampInStorage, totalAlreadyClaimed, totalToClaim); } /** * @inheritdoc IGlow */ function vetoCouncilInflationData() external view returns (uint256, uint256 totalAlreadyClaimed, uint256 totalToClaim) { if (_isZeroAddress(VETO_COUNCIL_ADDRESS)) _revert(IGlow.AddressNotSet.selector); uint256 timestampInStorage = vetoCouncilLastClaimedTimestamp; uint256 timestampToClaimFrom = timestampInStorage == 0 ? GENESIS_TIMESTAMP() : timestampInStorage; uint256 secondsSinceLastClaim = block.timestamp - timestampToClaimFrom; totalToClaim = secondsSinceLastClaim * VETO_COUNCIL_INFLATION_PER_SECOND; totalAlreadyClaimed = timestampToClaimFrom - GENESIS_TIMESTAMP(); return (timestampInStorage, totalAlreadyClaimed, totalToClaim); } /** * @inheritdoc IGlow */ function grantsTreasuryInflationData() external view returns (uint256, uint256 totalAlreadyClaimed, uint256 totalToClaim) { if (_isZeroAddress(GRANTS_TREASURY_ADDRESS)) _revert(IGlow.AddressNotSet.selector); uint256 timestampInStorage = grantsTreasuryLastClaimedTimestamp; uint256 timestampToClaimFrom = timestampInStorage == 0 ? GENESIS_TIMESTAMP() : timestampInStorage; uint256 secondsSinceLastClaim = block.timestamp - timestampToClaimFrom; totalToClaim = secondsSinceLastClaim * GRANTS_TREASURY_INFLATION_PER_SECOND; totalAlreadyClaimed = timestampToClaimFrom - GENESIS_TIMESTAMP(); return (timestampInStorage, totalAlreadyClaimed, totalToClaim); } /* -------------------------------------------------------------------------- */ /* one time setters */ /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ /* getters */ /* -------------------------------------------------------------------------- */ /// @notice The timestamp of the genesis block function GENESIS_TIMESTAMP() public view virtual returns (uint256) { return _GENESIS_TIMESTAMP; } /* -------------------------------------------------------------------------- */ /* constructor mint virtual */ /* -------------------------------------------------------------------------- */ /** * @notice Mints the initial supply of GLOW * @param _earlyLiquidityAddress The address of the early liquidity contract * @param _vestingContract The address of the vesting contract * @param _grantsTreasryAddress The address of the grants treasury */ function _handleConstructorMint( address _earlyLiquidityAddress, address _vestingContract, address _grantsTreasryAddress ) internal virtual { _mint(_earlyLiquidityAddress, 12_000_000 ether); _mint(_vestingContract, 96_000_000 ether); } /* -------------------------------------------------------------------------- */ /* privte utils */ /* -------------------------------------------------------------------------- */ /** * @notice Returns the smaller of two numbers * @param a The first number * @param b The second number */ function _min(uint256 a, uint256 b) private pure returns (uint256) { return a < b ? a : b; } /** * @notice More efficiently reverts with a bytes4 selector * @param selector The selector to revert with */ function _revert(bytes4 selector) internal pure { // solhint-disable-next-line no-inline-assembly assembly { mstore(0x0, selector) revert(0x0, 0x04) } } /** * @notice More efficient address(0) check */ function _isZeroAddress(address _address) internal pure returns (bool isZero) { // solhint-disable-next-line no-inline-assembly assembly { isZero := iszero(_address) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.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 ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ 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 Indicates a failed `decreaseAllowance` request. */ error ERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @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}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * 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 Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `requestedDecrease`. * * NOTE: Although this function is designed to avoid double spending with {approval}, * it can still be frontrunned, preventing any attempt of allowance reduction. */ function decreaseAllowance(address spender, uint256 requestedDecrease) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); if (currentAllowance < requestedDecrease) { revert ERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } unchecked { _approve(owner, spender, currentAllowance - requestedDecrease); } 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`, by transferring it to address(0). * 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. */ function _approve(address owner, address spender, uint256 value) internal virtual { _approve(owner, spender, value, true); } /** * @dev Alternative version of {_approve} with an optional flag that can 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: * ``` * 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. * * Might 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 v4.9.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.20; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSA { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS } /** * @dev The signature derives the `address(0)`. */ error ECDSAInvalidSignature(); /** * @dev The signature has an invalid length. */ error ECDSAInvalidSignatureLength(uint256 length); /** * @dev The signature has an S value that is in the upper half order. */ error ECDSAInvalidSignatureS(bytes32 s); /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError, bytes32) { if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. /// @solidity memory-safe-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else { return (address(0), RecoverError.InvalidSignatureLength, bytes32(signature.length)); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM precompile allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {MessageHashUtils-toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, signature); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] */ function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError, bytes32) { unchecked { bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); // We do not check for an overflow here since the shift operation results in 0 or 1. uint8 v = uint8((uint256(vs) >> 255) + 27); return tryRecover(hash, v, r, s); } } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. */ function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, r, vs); _throwError(error, errorArg); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError, bytes32) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS, s); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature, bytes32(0)); } return (signer, RecoverError.NoError, bytes32(0)); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) { (address recovered, RecoverError error, bytes32 errorArg) = tryRecover(hash, v, r, s); _throwError(error, errorArg); return recovered; } /** * @dev Optionally reverts with the corresponding custom error according to the `error` argument provided. */ function _throwError(RecoverError error, bytes32 errorArg) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert ECDSAInvalidSignature(); } else if (error == RecoverError.InvalidSignatureLength) { revert ECDSAInvalidSignatureLength(uint256(errorArg)); } else if (error == RecoverError.InvalidSignatureS) { revert ECDSAInvalidSignatureS(errorArg); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.20; import {MessageHashUtils} from "./MessageHashUtils.sol"; import {ShortStrings, ShortString} from "../ShortStrings.sol"; import {IERC5267} from "../../interfaces/IERC5267.sol"; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding scheme specified in the EIP requires a domain separator and a hash of the typed structured data, whose * encoding is very generic and therefore its implementation in Solidity is not feasible, thus this contract * does not implement the encoding itself. Protocols need to implement the type-specific encoding they need in order to * produce the hash of their typed data using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * NOTE: In the upgradeable version of this contract, the cached values will correspond to the address, and the domain * separator of the implementation contract. This will cause the {_domainSeparatorV4} function to always rebuild the * separator from the immutable values, which is cheaper than accessing a cached version in cold storage. * * @custom:oz-upgrades-unsafe-allow state-variable-immutable */ abstract contract EIP712 is IERC5267 { using ShortStrings for *; bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to // invalidate the cached domain separator if the chain id changes. bytes32 private immutable _cachedDomainSeparator; uint256 private immutable _cachedChainId; address private immutable _cachedThis; bytes32 private immutable _hashedName; bytes32 private immutable _hashedVersion; ShortString private immutable _name; ShortString private immutable _version; string private _nameFallback; string private _versionFallback; /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ constructor(string memory name, string memory version) { _name = name.toShortStringWithFallback(_nameFallback); _version = version.toShortStringWithFallback(_versionFallback); _hashedName = keccak256(bytes(name)); _hashedVersion = keccak256(bytes(version)); _cachedChainId = block.chainid; _cachedDomainSeparator = _buildDomainSeparator(); _cachedThis = address(this); } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { if (address(this) == _cachedThis && block.chainid == _cachedChainId) { return _cachedDomainSeparator; } else { return _buildDomainSeparator(); } } function _buildDomainSeparator() private view returns (bytes32) { return keccak256(abi.encode(_TYPE_HASH, _hashedName, _hashedVersion, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return MessageHashUtils.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev See {IERC-5267}. */ function eip712Domain() public view virtual returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { return ( hex"0f", // 01111 _EIP712Name(), _EIP712Version(), block.chainid, address(this), bytes32(0), new uint256[](0) ); } /** * @dev The name parameter for the EIP712 domain. * * NOTE: By default this function reads _name which is an immutable value. * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). */ // solhint-disable-next-line func-name-mixedcase function _EIP712Name() internal view returns (string memory) { return _name.toStringWithFallback(_nameFallback); } /** * @dev The version parameter for the EIP712 domain. * * NOTE: By default this function reads _version which is an immutable value. * It only reads from storage if necessary (in case the value is too large to fit in a ShortString). */ // solhint-disable-next-line func-name-mixedcase function _EIP712Version() internal view returns (string memory) { return _version.toStringWithFallback(_versionFallback); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; /** * @dev Provides tracking nonces for addresses. Nonces will only increment. */ abstract contract Nonces { /** * @dev The nonce used for an `account` is not the expected current nonce. */ error InvalidAccountNonce(address account, uint256 currentNonce); mapping(address account => uint256) private _nonces; /** * @dev Returns an the next unused nonce for an address. */ function nonces(address owner) public view virtual returns (uint256) { return _nonces[owner]; } /** * @dev Consumes a nonce. * * Returns the current value and increments nonce. */ function _useNonce(address owner) internal virtual returns (uint256) { // For each account, the nonce has an initial value of 0, can only be incremented by one, and cannot be // decremented or reset. This guarantees that the nonce never overflows. unchecked { // It is important to do x++ and not ++x here. return _nonces[owner]++; } } /** * @dev Same as {_useNonce} but checking that `nonce` is the next valid for `owner`. */ function _useCheckedNonce(address owner, uint256 nonce) internal virtual returns (uint256) { uint256 current = _useNonce(owner); if (nonce != current) { revert InvalidAccountNonce(owner, current); } return current; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.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; } }
pragma solidity ^0.8.0; interface IUniswapV2Pair { event Approval(address indexed owner, address indexed spender, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value); function name() external pure returns (string memory); function symbol() external pure returns (string memory); function decimals() external pure returns (uint8); function totalSupply() external view returns (uint256); function balanceOf(address owner) external view returns (uint256); function allowance(address owner, address spender) external view returns (uint256); function approve(address spender, uint256 value) external returns (bool); function transfer(address to, uint256 value) external returns (bool); function transferFrom(address from, address to, uint256 value) external returns (bool); function DOMAIN_SEPARATOR() external view returns (bytes32); function PERMIT_TYPEHASH() external pure returns (bytes32); function nonces(address owner) external view returns (uint256); function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external; event Mint(address indexed sender, uint256 amount0, uint256 amount1); event Burn(address indexed sender, uint256 amount0, uint256 amount1, address indexed to); event Swap( address indexed sender, uint256 amount0In, uint256 amount1In, uint256 amount0Out, uint256 amount1Out, address indexed to ); event Sync(uint112 reserve0, uint112 reserve1); function MINIMUM_LIQUIDITY() external pure returns (uint256); function factory() external view returns (address); function token0() external view returns (address); function token1() external view returns (address); function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast); function price0CumulativeLast() external view returns (uint256); function price1CumulativeLast() external view returns (uint256); function kLast() external view returns (uint256); function mint(address to) external returns (uint256 liquidity); function burn(address to) external returns (uint256 amount0, uint256 amount1); function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data) external; function skim(address to) external; function sync() external; function initialize(address, address) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IGlow is IERC20 { /* -------------------------------------------------------------------------- */ /* errors */ /* -------------------------------------------------------------------------- */ error UnstakeAmountExceedsStakedBalance(); error InsufficientClaimableBalance(); error CannotStakeZeroTokens(); error CannotUnstakeZeroTokens(); error AddressAlreadySet(); error AddressNotSet(); error CallerNotGCA(); error CallerNotVetoCouncil(); error CallerNotGrantsTreasury(); error UnstakingOnEmergencyCooldown(); error ZeroAddressNotAllowed(); error DuplicateAddressNotAllowed(); error CannotClaimZeroTokens(); /* -------------------------------------------------------------------------- */ /* events */ /* -------------------------------------------------------------------------- */ /** * @notice Emitted when a user stakes GLOW * @param user The address of the user that is staking * @param amount The amount staked */ event Stake(address indexed user, uint256 amount); /** * @notice Emitted when a user unstakes GLOW * @param user The address of the user that is unstaking * @param amount The amount unstaked */ event Unstake(address indexed user, uint256 amount); /** * @notice Emitted when a user claims GLOW from there unstaked positions * @param user The address of the user that is claiming * @param amount The amount claimed */ event ClaimUnstakedGLW(address indexed user, uint256 amount); /* -------------------------------------------------------------------------- */ /* structs */ /* -------------------------------------------------------------------------- */ /** * @notice represents an unstaked position * @param amount The amount of GLOW unstaked * @param cooldownEnd The timestamp when the user can reclaim the tokens */ struct UnstakedPosition { uint192 amount; uint64 cooldownEnd; } /** * @dev helper for managing tail and head in a mapping * @param tail the tail of the mapping * @param head the head of the mapping * @dev the head is the last index with data. If we need to push, we push at head + 1 * @dev there are edge cases where head == tail and there is data, * - and conversely, head == tail and there is no data * - These special cases are handled in the code */ struct Pointers { uint128 tail; uint128 head; } /* -------------------------------------------------------------------------- */ /* staking */ /* -------------------------------------------------------------------------- */ /** * @notice The entry point for a user to stake glow. * @notice A user earns 1 ratify/reject vote per glw staked * @param amount The amount of GLOW to stake */ function stake(uint256 amount) external; /** * @notice The entry point for a user to unstake glow. * @param amount The amount of GLOW to unstake */ function unstake(uint256 amount) external; /* -------------------------------------------------------------------------- */ /* inflation */ /* -------------------------------------------------------------------------- */ /** * @notice Entry point for users to claim unstaked tokens that are no longer on cooldown * @param amount The amount of tokens to claim * @dev emits a ```ClaimUnstakedGLW``` event */ function claimUnstakedTokens(uint256 amount) external; /** * @notice Allows the GCA and Miner Pool Contract to claim GLW from inflation * @notice The GCA and Miner Pool Contract receives 185,00 * 1e18 tokens per week */ function claimGLWFromGCAAndMinerPool() external returns (uint256); /** * @notice Allows the Veto Council to claim GLW from inflation * @notice The veto council receives 5,000 * 1e18 tokens per week */ function claimGLWFromVetoCouncil() external returns (uint256); /** * @notice Allows the Grants Treasury to claim GLW from inflation * @notice The grants treasury receives 40,000 * 1e18 tokens per week */ function claimGLWFromGrantsTreasury() external returns (uint256); /* -------------------------------------------------------------------------- */ /* view unstaked positions */ /* -------------------------------------------------------------------------- */ /** * @notice Returns the unstaked positions of a user * @param account The address of the user */ function unstakedPositionsOf(address account) external view returns (UnstakedPosition[] memory); /** * @notice Returns the unstaked positions of a user * @param account The address of the user * @param start The start index of the positions to return * @param end The end index of the positions to return */ function unstakedPositionsOf(address account, uint256 start, uint256 end) external view returns (UnstakedPosition[] memory); /* -------------------------------------------------------------------------- */ /* view inflation data */ /* -------------------------------------------------------------------------- */ /** * @return lastClaimTimestamp The last time the GCA and Miner Pool Contract claimed GLW * @return totalAlreadyClaimed The total amount of GLW already claimed by the GCA and Miner Pool Contract * @return totalToClaim The total amount of GLW available to claim by the GCA and Miner Pool Contract */ function gcaInflationData() external view returns (uint256 lastClaimTimestamp, uint256 totalAlreadyClaimed, uint256 totalToClaim); /** * @return lastClaimTimestamp The last time the Veto Council claimed GLW * @return totalAlreadyClaimed The total amount of GLW already claimed by the Veto Council * @return totalToClaim The total amount of GLW available to claim by the Veto Council */ function vetoCouncilInflationData() external view returns (uint256 lastClaimTimestamp, uint256 totalAlreadyClaimed, uint256 totalToClaim); /** * @return lastClaimTimestamp The last time the Grants Treasury claimed GLW * @return totalAlreadyClaimed The total amount of GLW already claimed by the Grants Treasury * @return totalToClaim The total amount of GLW available to claim by the Grants Treasury */ function grantsTreasuryInflationData() external view returns (uint256 lastClaimTimestamp, uint256 totalAlreadyClaimed, uint256 totalToClaim); /* -------------------------------------------------------------------------- */ /* view */ /* -------------------------------------------------------------------------- */ /** * @return the genesis timestamp */ function GENESIS_TIMESTAMP() external view returns (uint256); /** * @notice the total amount of GLW currently staked by {account} * @return numStaked total amount of GLW currently staked by {account} * @param account the address of the account to get the staked balance of */ function numStaked(address account) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SafeCast.sol) // This file was procedurally generated from scripts/generate/templates/SafeCast.js. pragma solidity ^0.8.20; /** * @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow * checks. * * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can * easily result in undesired exploitation or bugs, since developers usually * assume that overflows raise errors. `SafeCast` restores this intuition by * reverting the transaction when such an operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeCast { /** * @dev Value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value); /** * @dev An int value doesn't fit in an uint of `bits` size. */ error SafeCastOverflowedIntToUint(int256 value); /** * @dev Value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedIntDowncast(uint8 bits, int256 value); /** * @dev An uint value doesn't fit in an int of `bits` size. */ error SafeCastOverflowedUintToInt(uint256 value); /** * @dev Returns the downcasted uint248 from uint256, reverting on * overflow (when the input is greater than largest uint248). * * Counterpart to Solidity's `uint248` operator. * * Requirements: * * - input must fit into 248 bits */ function toUint248(uint256 value) internal pure returns (uint248) { if (value > type(uint248).max) { revert SafeCastOverflowedUintDowncast(248, value); } return uint248(value); } /** * @dev Returns the downcasted uint240 from uint256, reverting on * overflow (when the input is greater than largest uint240). * * Counterpart to Solidity's `uint240` operator. * * Requirements: * * - input must fit into 240 bits */ function toUint240(uint256 value) internal pure returns (uint240) { if (value > type(uint240).max) { revert SafeCastOverflowedUintDowncast(240, value); } return uint240(value); } /** * @dev Returns the downcasted uint232 from uint256, reverting on * overflow (when the input is greater than largest uint232). * * Counterpart to Solidity's `uint232` operator. * * Requirements: * * - input must fit into 232 bits */ function toUint232(uint256 value) internal pure returns (uint232) { if (value > type(uint232).max) { revert SafeCastOverflowedUintDowncast(232, value); } return uint232(value); } /** * @dev Returns the downcasted uint224 from uint256, reverting on * overflow (when the input is greater than largest uint224). * * Counterpart to Solidity's `uint224` operator. * * Requirements: * * - input must fit into 224 bits */ function toUint224(uint256 value) internal pure returns (uint224) { if (value > type(uint224).max) { revert SafeCastOverflowedUintDowncast(224, value); } return uint224(value); } /** * @dev Returns the downcasted uint216 from uint256, reverting on * overflow (when the input is greater than largest uint216). * * Counterpart to Solidity's `uint216` operator. * * Requirements: * * - input must fit into 216 bits */ function toUint216(uint256 value) internal pure returns (uint216) { if (value > type(uint216).max) { revert SafeCastOverflowedUintDowncast(216, value); } return uint216(value); } /** * @dev Returns the downcasted uint208 from uint256, reverting on * overflow (when the input is greater than largest uint208). * * Counterpart to Solidity's `uint208` operator. * * Requirements: * * - input must fit into 208 bits */ function toUint208(uint256 value) internal pure returns (uint208) { if (value > type(uint208).max) { revert SafeCastOverflowedUintDowncast(208, value); } return uint208(value); } /** * @dev Returns the downcasted uint200 from uint256, reverting on * overflow (when the input is greater than largest uint200). * * Counterpart to Solidity's `uint200` operator. * * Requirements: * * - input must fit into 200 bits */ function toUint200(uint256 value) internal pure returns (uint200) { if (value > type(uint200).max) { revert SafeCastOverflowedUintDowncast(200, value); } return uint200(value); } /** * @dev Returns the downcasted uint192 from uint256, reverting on * overflow (when the input is greater than largest uint192). * * Counterpart to Solidity's `uint192` operator. * * Requirements: * * - input must fit into 192 bits */ function toUint192(uint256 value) internal pure returns (uint192) { if (value > type(uint192).max) { revert SafeCastOverflowedUintDowncast(192, value); } return uint192(value); } /** * @dev Returns the downcasted uint184 from uint256, reverting on * overflow (when the input is greater than largest uint184). * * Counterpart to Solidity's `uint184` operator. * * Requirements: * * - input must fit into 184 bits */ function toUint184(uint256 value) internal pure returns (uint184) { if (value > type(uint184).max) { revert SafeCastOverflowedUintDowncast(184, value); } return uint184(value); } /** * @dev Returns the downcasted uint176 from uint256, reverting on * overflow (when the input is greater than largest uint176). * * Counterpart to Solidity's `uint176` operator. * * Requirements: * * - input must fit into 176 bits */ function toUint176(uint256 value) internal pure returns (uint176) { if (value > type(uint176).max) { revert SafeCastOverflowedUintDowncast(176, value); } return uint176(value); } /** * @dev Returns the downcasted uint168 from uint256, reverting on * overflow (when the input is greater than largest uint168). * * Counterpart to Solidity's `uint168` operator. * * Requirements: * * - input must fit into 168 bits */ function toUint168(uint256 value) internal pure returns (uint168) { if (value > type(uint168).max) { revert SafeCastOverflowedUintDowncast(168, value); } return uint168(value); } /** * @dev Returns the downcasted uint160 from uint256, reverting on * overflow (when the input is greater than largest uint160). * * Counterpart to Solidity's `uint160` operator. * * Requirements: * * - input must fit into 160 bits */ function toUint160(uint256 value) internal pure returns (uint160) { if (value > type(uint160).max) { revert SafeCastOverflowedUintDowncast(160, value); } return uint160(value); } /** * @dev Returns the downcasted uint152 from uint256, reverting on * overflow (when the input is greater than largest uint152). * * Counterpart to Solidity's `uint152` operator. * * Requirements: * * - input must fit into 152 bits */ function toUint152(uint256 value) internal pure returns (uint152) { if (value > type(uint152).max) { revert SafeCastOverflowedUintDowncast(152, value); } return uint152(value); } /** * @dev Returns the downcasted uint144 from uint256, reverting on * overflow (when the input is greater than largest uint144). * * Counterpart to Solidity's `uint144` operator. * * Requirements: * * - input must fit into 144 bits */ function toUint144(uint256 value) internal pure returns (uint144) { if (value > type(uint144).max) { revert SafeCastOverflowedUintDowncast(144, value); } return uint144(value); } /** * @dev Returns the downcasted uint136 from uint256, reverting on * overflow (when the input is greater than largest uint136). * * Counterpart to Solidity's `uint136` operator. * * Requirements: * * - input must fit into 136 bits */ function toUint136(uint256 value) internal pure returns (uint136) { if (value > type(uint136).max) { revert SafeCastOverflowedUintDowncast(136, value); } return uint136(value); } /** * @dev Returns the downcasted uint128 from uint256, reverting on * overflow (when the input is greater than largest uint128). * * Counterpart to Solidity's `uint128` operator. * * Requirements: * * - input must fit into 128 bits */ function toUint128(uint256 value) internal pure returns (uint128) { if (value > type(uint128).max) { revert SafeCastOverflowedUintDowncast(128, value); } return uint128(value); } /** * @dev Returns the downcasted uint120 from uint256, reverting on * overflow (when the input is greater than largest uint120). * * Counterpart to Solidity's `uint120` operator. * * Requirements: * * - input must fit into 120 bits */ function toUint120(uint256 value) internal pure returns (uint120) { if (value > type(uint120).max) { revert SafeCastOverflowedUintDowncast(120, value); } return uint120(value); } /** * @dev Returns the downcasted uint112 from uint256, reverting on * overflow (when the input is greater than largest uint112). * * Counterpart to Solidity's `uint112` operator. * * Requirements: * * - input must fit into 112 bits */ function toUint112(uint256 value) internal pure returns (uint112) { if (value > type(uint112).max) { revert SafeCastOverflowedUintDowncast(112, value); } return uint112(value); } /** * @dev Returns the downcasted uint104 from uint256, reverting on * overflow (when the input is greater than largest uint104). * * Counterpart to Solidity's `uint104` operator. * * Requirements: * * - input must fit into 104 bits */ function toUint104(uint256 value) internal pure returns (uint104) { if (value > type(uint104).max) { revert SafeCastOverflowedUintDowncast(104, value); } return uint104(value); } /** * @dev Returns the downcasted uint96 from uint256, reverting on * overflow (when the input is greater than largest uint96). * * Counterpart to Solidity's `uint96` operator. * * Requirements: * * - input must fit into 96 bits */ function toUint96(uint256 value) internal pure returns (uint96) { if (value > type(uint96).max) { revert SafeCastOverflowedUintDowncast(96, value); } return uint96(value); } /** * @dev Returns the downcasted uint88 from uint256, reverting on * overflow (when the input is greater than largest uint88). * * Counterpart to Solidity's `uint88` operator. * * Requirements: * * - input must fit into 88 bits */ function toUint88(uint256 value) internal pure returns (uint88) { if (value > type(uint88).max) { revert SafeCastOverflowedUintDowncast(88, value); } return uint88(value); } /** * @dev Returns the downcasted uint80 from uint256, reverting on * overflow (when the input is greater than largest uint80). * * Counterpart to Solidity's `uint80` operator. * * Requirements: * * - input must fit into 80 bits */ function toUint80(uint256 value) internal pure returns (uint80) { if (value > type(uint80).max) { revert SafeCastOverflowedUintDowncast(80, value); } return uint80(value); } /** * @dev Returns the downcasted uint72 from uint256, reverting on * overflow (when the input is greater than largest uint72). * * Counterpart to Solidity's `uint72` operator. * * Requirements: * * - input must fit into 72 bits */ function toUint72(uint256 value) internal pure returns (uint72) { if (value > type(uint72).max) { revert SafeCastOverflowedUintDowncast(72, value); } return uint72(value); } /** * @dev Returns the downcasted uint64 from uint256, reverting on * overflow (when the input is greater than largest uint64). * * Counterpart to Solidity's `uint64` operator. * * Requirements: * * - input must fit into 64 bits */ function toUint64(uint256 value) internal pure returns (uint64) { if (value > type(uint64).max) { revert SafeCastOverflowedUintDowncast(64, value); } return uint64(value); } /** * @dev Returns the downcasted uint56 from uint256, reverting on * overflow (when the input is greater than largest uint56). * * Counterpart to Solidity's `uint56` operator. * * Requirements: * * - input must fit into 56 bits */ function toUint56(uint256 value) internal pure returns (uint56) { if (value > type(uint56).max) { revert SafeCastOverflowedUintDowncast(56, value); } return uint56(value); } /** * @dev Returns the downcasted uint48 from uint256, reverting on * overflow (when the input is greater than largest uint48). * * Counterpart to Solidity's `uint48` operator. * * Requirements: * * - input must fit into 48 bits */ function toUint48(uint256 value) internal pure returns (uint48) { if (value > type(uint48).max) { revert SafeCastOverflowedUintDowncast(48, value); } return uint48(value); } /** * @dev Returns the downcasted uint40 from uint256, reverting on * overflow (when the input is greater than largest uint40). * * Counterpart to Solidity's `uint40` operator. * * Requirements: * * - input must fit into 40 bits */ function toUint40(uint256 value) internal pure returns (uint40) { if (value > type(uint40).max) { revert SafeCastOverflowedUintDowncast(40, value); } return uint40(value); } /** * @dev Returns the downcasted uint32 from uint256, reverting on * overflow (when the input is greater than largest uint32). * * Counterpart to Solidity's `uint32` operator. * * Requirements: * * - input must fit into 32 bits */ function toUint32(uint256 value) internal pure returns (uint32) { if (value > type(uint32).max) { revert SafeCastOverflowedUintDowncast(32, value); } return uint32(value); } /** * @dev Returns the downcasted uint24 from uint256, reverting on * overflow (when the input is greater than largest uint24). * * Counterpart to Solidity's `uint24` operator. * * Requirements: * * - input must fit into 24 bits */ function toUint24(uint256 value) internal pure returns (uint24) { if (value > type(uint24).max) { revert SafeCastOverflowedUintDowncast(24, value); } return uint24(value); } /** * @dev Returns the downcasted uint16 from uint256, reverting on * overflow (when the input is greater than largest uint16). * * Counterpart to Solidity's `uint16` operator. * * Requirements: * * - input must fit into 16 bits */ function toUint16(uint256 value) internal pure returns (uint16) { if (value > type(uint16).max) { revert SafeCastOverflowedUintDowncast(16, value); } return uint16(value); } /** * @dev Returns the downcasted uint8 from uint256, reverting on * overflow (when the input is greater than largest uint8). * * Counterpart to Solidity's `uint8` operator. * * Requirements: * * - input must fit into 8 bits */ function toUint8(uint256 value) internal pure returns (uint8) { if (value > type(uint8).max) { revert SafeCastOverflowedUintDowncast(8, value); } return uint8(value); } /** * @dev Converts a signed int256 into an unsigned uint256. * * Requirements: * * - input must be greater than or equal to 0. */ function toUint256(int256 value) internal pure returns (uint256) { if (value < 0) { revert SafeCastOverflowedIntToUint(value); } return uint256(value); } /** * @dev Returns the downcasted int248 from int256, reverting on * overflow (when the input is less than smallest int248 or * greater than largest int248). * * Counterpart to Solidity's `int248` operator. * * Requirements: * * - input must fit into 248 bits */ function toInt248(int256 value) internal pure returns (int248 downcasted) { downcasted = int248(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(248, value); } } /** * @dev Returns the downcasted int240 from int256, reverting on * overflow (when the input is less than smallest int240 or * greater than largest int240). * * Counterpart to Solidity's `int240` operator. * * Requirements: * * - input must fit into 240 bits */ function toInt240(int256 value) internal pure returns (int240 downcasted) { downcasted = int240(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(240, value); } } /** * @dev Returns the downcasted int232 from int256, reverting on * overflow (when the input is less than smallest int232 or * greater than largest int232). * * Counterpart to Solidity's `int232` operator. * * Requirements: * * - input must fit into 232 bits */ function toInt232(int256 value) internal pure returns (int232 downcasted) { downcasted = int232(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(232, value); } } /** * @dev Returns the downcasted int224 from int256, reverting on * overflow (when the input is less than smallest int224 or * greater than largest int224). * * Counterpart to Solidity's `int224` operator. * * Requirements: * * - input must fit into 224 bits */ function toInt224(int256 value) internal pure returns (int224 downcasted) { downcasted = int224(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(224, value); } } /** * @dev Returns the downcasted int216 from int256, reverting on * overflow (when the input is less than smallest int216 or * greater than largest int216). * * Counterpart to Solidity's `int216` operator. * * Requirements: * * - input must fit into 216 bits */ function toInt216(int256 value) internal pure returns (int216 downcasted) { downcasted = int216(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(216, value); } } /** * @dev Returns the downcasted int208 from int256, reverting on * overflow (when the input is less than smallest int208 or * greater than largest int208). * * Counterpart to Solidity's `int208` operator. * * Requirements: * * - input must fit into 208 bits */ function toInt208(int256 value) internal pure returns (int208 downcasted) { downcasted = int208(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(208, value); } } /** * @dev Returns the downcasted int200 from int256, reverting on * overflow (when the input is less than smallest int200 or * greater than largest int200). * * Counterpart to Solidity's `int200` operator. * * Requirements: * * - input must fit into 200 bits */ function toInt200(int256 value) internal pure returns (int200 downcasted) { downcasted = int200(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(200, value); } } /** * @dev Returns the downcasted int192 from int256, reverting on * overflow (when the input is less than smallest int192 or * greater than largest int192). * * Counterpart to Solidity's `int192` operator. * * Requirements: * * - input must fit into 192 bits */ function toInt192(int256 value) internal pure returns (int192 downcasted) { downcasted = int192(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(192, value); } } /** * @dev Returns the downcasted int184 from int256, reverting on * overflow (when the input is less than smallest int184 or * greater than largest int184). * * Counterpart to Solidity's `int184` operator. * * Requirements: * * - input must fit into 184 bits */ function toInt184(int256 value) internal pure returns (int184 downcasted) { downcasted = int184(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(184, value); } } /** * @dev Returns the downcasted int176 from int256, reverting on * overflow (when the input is less than smallest int176 or * greater than largest int176). * * Counterpart to Solidity's `int176` operator. * * Requirements: * * - input must fit into 176 bits */ function toInt176(int256 value) internal pure returns (int176 downcasted) { downcasted = int176(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(176, value); } } /** * @dev Returns the downcasted int168 from int256, reverting on * overflow (when the input is less than smallest int168 or * greater than largest int168). * * Counterpart to Solidity's `int168` operator. * * Requirements: * * - input must fit into 168 bits */ function toInt168(int256 value) internal pure returns (int168 downcasted) { downcasted = int168(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(168, value); } } /** * @dev Returns the downcasted int160 from int256, reverting on * overflow (when the input is less than smallest int160 or * greater than largest int160). * * Counterpart to Solidity's `int160` operator. * * Requirements: * * - input must fit into 160 bits */ function toInt160(int256 value) internal pure returns (int160 downcasted) { downcasted = int160(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(160, value); } } /** * @dev Returns the downcasted int152 from int256, reverting on * overflow (when the input is less than smallest int152 or * greater than largest int152). * * Counterpart to Solidity's `int152` operator. * * Requirements: * * - input must fit into 152 bits */ function toInt152(int256 value) internal pure returns (int152 downcasted) { downcasted = int152(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(152, value); } } /** * @dev Returns the downcasted int144 from int256, reverting on * overflow (when the input is less than smallest int144 or * greater than largest int144). * * Counterpart to Solidity's `int144` operator. * * Requirements: * * - input must fit into 144 bits */ function toInt144(int256 value) internal pure returns (int144 downcasted) { downcasted = int144(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(144, value); } } /** * @dev Returns the downcasted int136 from int256, reverting on * overflow (when the input is less than smallest int136 or * greater than largest int136). * * Counterpart to Solidity's `int136` operator. * * Requirements: * * - input must fit into 136 bits */ function toInt136(int256 value) internal pure returns (int136 downcasted) { downcasted = int136(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(136, value); } } /** * @dev Returns the downcasted int128 from int256, reverting on * overflow (when the input is less than smallest int128 or * greater than largest int128). * * Counterpart to Solidity's `int128` operator. * * Requirements: * * - input must fit into 128 bits */ function toInt128(int256 value) internal pure returns (int128 downcasted) { downcasted = int128(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(128, value); } } /** * @dev Returns the downcasted int120 from int256, reverting on * overflow (when the input is less than smallest int120 or * greater than largest int120). * * Counterpart to Solidity's `int120` operator. * * Requirements: * * - input must fit into 120 bits */ function toInt120(int256 value) internal pure returns (int120 downcasted) { downcasted = int120(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(120, value); } } /** * @dev Returns the downcasted int112 from int256, reverting on * overflow (when the input is less than smallest int112 or * greater than largest int112). * * Counterpart to Solidity's `int112` operator. * * Requirements: * * - input must fit into 112 bits */ function toInt112(int256 value) internal pure returns (int112 downcasted) { downcasted = int112(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(112, value); } } /** * @dev Returns the downcasted int104 from int256, reverting on * overflow (when the input is less than smallest int104 or * greater than largest int104). * * Counterpart to Solidity's `int104` operator. * * Requirements: * * - input must fit into 104 bits */ function toInt104(int256 value) internal pure returns (int104 downcasted) { downcasted = int104(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(104, value); } } /** * @dev Returns the downcasted int96 from int256, reverting on * overflow (when the input is less than smallest int96 or * greater than largest int96). * * Counterpart to Solidity's `int96` operator. * * Requirements: * * - input must fit into 96 bits */ function toInt96(int256 value) internal pure returns (int96 downcasted) { downcasted = int96(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(96, value); } } /** * @dev Returns the downcasted int88 from int256, reverting on * overflow (when the input is less than smallest int88 or * greater than largest int88). * * Counterpart to Solidity's `int88` operator. * * Requirements: * * - input must fit into 88 bits */ function toInt88(int256 value) internal pure returns (int88 downcasted) { downcasted = int88(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(88, value); } } /** * @dev Returns the downcasted int80 from int256, reverting on * overflow (when the input is less than smallest int80 or * greater than largest int80). * * Counterpart to Solidity's `int80` operator. * * Requirements: * * - input must fit into 80 bits */ function toInt80(int256 value) internal pure returns (int80 downcasted) { downcasted = int80(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(80, value); } } /** * @dev Returns the downcasted int72 from int256, reverting on * overflow (when the input is less than smallest int72 or * greater than largest int72). * * Counterpart to Solidity's `int72` operator. * * Requirements: * * - input must fit into 72 bits */ function toInt72(int256 value) internal pure returns (int72 downcasted) { downcasted = int72(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(72, value); } } /** * @dev Returns the downcasted int64 from int256, reverting on * overflow (when the input is less than smallest int64 or * greater than largest int64). * * Counterpart to Solidity's `int64` operator. * * Requirements: * * - input must fit into 64 bits */ function toInt64(int256 value) internal pure returns (int64 downcasted) { downcasted = int64(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(64, value); } } /** * @dev Returns the downcasted int56 from int256, reverting on * overflow (when the input is less than smallest int56 or * greater than largest int56). * * Counterpart to Solidity's `int56` operator. * * Requirements: * * - input must fit into 56 bits */ function toInt56(int256 value) internal pure returns (int56 downcasted) { downcasted = int56(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(56, value); } } /** * @dev Returns the downcasted int48 from int256, reverting on * overflow (when the input is less than smallest int48 or * greater than largest int48). * * Counterpart to Solidity's `int48` operator. * * Requirements: * * - input must fit into 48 bits */ function toInt48(int256 value) internal pure returns (int48 downcasted) { downcasted = int48(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(48, value); } } /** * @dev Returns the downcasted int40 from int256, reverting on * overflow (when the input is less than smallest int40 or * greater than largest int40). * * Counterpart to Solidity's `int40` operator. * * Requirements: * * - input must fit into 40 bits */ function toInt40(int256 value) internal pure returns (int40 downcasted) { downcasted = int40(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(40, value); } } /** * @dev Returns the downcasted int32 from int256, reverting on * overflow (when the input is less than smallest int32 or * greater than largest int32). * * Counterpart to Solidity's `int32` operator. * * Requirements: * * - input must fit into 32 bits */ function toInt32(int256 value) internal pure returns (int32 downcasted) { downcasted = int32(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(32, value); } } /** * @dev Returns the downcasted int24 from int256, reverting on * overflow (when the input is less than smallest int24 or * greater than largest int24). * * Counterpart to Solidity's `int24` operator. * * Requirements: * * - input must fit into 24 bits */ function toInt24(int256 value) internal pure returns (int24 downcasted) { downcasted = int24(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(24, value); } } /** * @dev Returns the downcasted int16 from int256, reverting on * overflow (when the input is less than smallest int16 or * greater than largest int16). * * Counterpart to Solidity's `int16` operator. * * Requirements: * * - input must fit into 16 bits */ function toInt16(int256 value) internal pure returns (int16 downcasted) { downcasted = int16(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(16, value); } } /** * @dev Returns the downcasted int8 from int256, reverting on * overflow (when the input is less than smallest int8 or * greater than largest int8). * * Counterpart to Solidity's `int8` operator. * * Requirements: * * - input must fit into 8 bits */ function toInt8(int256 value) internal pure returns (int8 downcasted) { downcasted = int8(value); if (downcasted != value) { revert SafeCastOverflowedIntDowncast(8, value); } } /** * @dev Converts an unsigned uint256 into a signed int256. * * Requirements: * * - input must be less than or equal to maxInt256. */ function toInt256(uint256 value) internal pure returns (int256) { // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive if (value > uint256(type(int256).max)) { revert SafeCastOverflowedUintToInt(value); } return int256(value); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.19; uint256 constant _BUCKET_DURATION = uint256(7 days); uint256 constant _GENESIS_TIMESTAMP = 1700352000;
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. */ interface IERC20Metadata is IERC20 { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; /** * @dev Standard ERC20 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 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 ERC721 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens. */ interface IERC721Errors { /** * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-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 ERC1155 Errors * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 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 pragma solidity ^0.8.20; import {Strings} from "../Strings.sol"; /** * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing. * * The library provides methods for generating a hash of a message that conforms to the * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712] * specifications. */ library MessageHashUtils { /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing a bytes32 `messageHash` with * `"\x19Ethereum Signed Message:\n32"` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * NOTE: The `hash` parameter is intended to be the result of hashing a raw message with * keccak256, although any bytes32 value can be safely used because the final digest will * be re-hashed. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes32 messageHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { mstore(0x00, "\x19Ethereum Signed Message:\n32") // 32 is the bytes-length of messageHash mstore(0x1c, messageHash) // 0x1c (28) is the length of the prefix digest := keccak256(0x00, 0x3c) // 0x3c is the length of the prefix (0x1c) + messageHash (0x20) } } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x45` (`personal_sign` messages). * * The digest is calculated by prefixing an arbitrary `message` with * `"\x19Ethereum Signed Message:\n" + len(message)` and hashing the result. It corresponds with the * hash signed when using the https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] JSON-RPC method. * * See {ECDSA-recover}. */ function toEthSignedMessageHash(bytes memory message) internal pure returns (bytes32 digest) { return keccak256(bytes.concat("\x19Ethereum Signed Message:\n", bytes(Strings.toString(message.length)), message)); } /** * @dev Returns the keccak256 digest of an EIP-191 signed data with version * `0x00` (data with intended validator). * * The digest is calculated by prefixing an arbitrary `data` with `"\x19\x00"` and the intended * `validator` address. Then hashing the result. * * See {ECDSA-recover}. */ function toDataWithIntendedValidatorHash( address validator, bytes memory data ) internal pure returns (bytes32 digest) { return keccak256(abi.encodePacked(hex"19_00", validator, data)); } /** * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`). * * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with * `\x19\x01` and hashing the result. It corresponds to the hash signed by the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712. * * See {ECDSA-recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 digest) { /// @solidity memory-safe-assembly assembly { let ptr := mload(0x40) mstore(ptr, hex"19_01") mstore(add(ptr, 0x02), domainSeparator) mstore(add(ptr, 0x22), structHash) digest := keccak256(ptr, 0x42) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/ShortStrings.sol) pragma solidity ^0.8.20; import {StorageSlot} from "./StorageSlot.sol"; // | string | 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA | // | length | 0x BB | type ShortString is bytes32; /** * @dev This library provides functions to convert short memory strings * into a `ShortString` type that can be used as an immutable variable. * * Strings of arbitrary length can be optimized using this library if * they are short enough (up to 31 bytes) by packing them with their * length (1 byte) in a single EVM word (32 bytes). Additionally, a * fallback mechanism can be used for every other case. * * Usage example: * * ```solidity * contract Named { * using ShortStrings for *; * * ShortString private immutable _name; * string private _nameFallback; * * constructor(string memory contractName) { * _name = contractName.toShortStringWithFallback(_nameFallback); * } * * function name() external view returns (string memory) { * return _name.toStringWithFallback(_nameFallback); * } * } * ``` */ library ShortStrings { // Used as an identifier for strings longer than 31 bytes. bytes32 private constant _FALLBACK_SENTINEL = 0x00000000000000000000000000000000000000000000000000000000000000FF; error StringTooLong(string str); error InvalidShortString(); /** * @dev Encode a string of at most 31 chars into a `ShortString`. * * This will trigger a `StringTooLong` error is the input string is too long. */ function toShortString(string memory str) internal pure returns (ShortString) { bytes memory bstr = bytes(str); if (bstr.length > 31) { revert StringTooLong(str); } return ShortString.wrap(bytes32(uint256(bytes32(bstr)) | bstr.length)); } /** * @dev Decode a `ShortString` back to a "normal" string. */ function toString(ShortString sstr) internal pure returns (string memory) { uint256 len = byteLength(sstr); // using `new string(len)` would work locally but is not memory safe. string memory str = new string(32); /// @solidity memory-safe-assembly assembly { mstore(str, len) mstore(add(str, 0x20), sstr) } return str; } /** * @dev Return the length of a `ShortString`. */ function byteLength(ShortString sstr) internal pure returns (uint256) { uint256 result = uint256(ShortString.unwrap(sstr)) & 0xFF; if (result > 31) { revert InvalidShortString(); } return result; } /** * @dev Encode a string into a `ShortString`, or write it to storage if it is too long. */ function toShortStringWithFallback(string memory value, string storage store) internal returns (ShortString) { if (bytes(value).length < 32) { return toShortString(value); } else { StorageSlot.getStringSlot(store).value = value; return ShortString.wrap(_FALLBACK_SENTINEL); } } /** * @dev Decode a string that was encoded to `ShortString` or written to storage using {setWithFallback}. */ function toStringWithFallback(ShortString value, string storage store) internal pure returns (string memory) { if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) { return toString(value); } else { return store; } } /** * @dev Return the length of a string that was encoded to `ShortString` or written to storage using {setWithFallback}. * * WARNING: This will return the "byte length" of the string. This may not reflect the actual length in terms of * actual characters as the UTF-8 encoding of a single character can span over multiple bytes. */ function byteLengthWithFallback(ShortString value, string storage store) internal view returns (uint256) { if (ShortString.unwrap(value) != _FALLBACK_SENTINEL) { return byteLength(value); } else { return bytes(store).length; } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC5267.sol) pragma solidity ^0.8.20; interface IERC5267 { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) pragma solidity ^0.8.20; import {Math} from "./math/Math.sol"; import {SignedMath} from "./math/SignedMath.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _HEX_DIGITS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev The `value` string doesn't fit in the specified `length`. */ error StringsInsufficientHexLength(uint256 value, uint256 length); /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _HEX_DIGITS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `int256` to its ASCII `string` decimal representation. */ function toStringSigned(int256 value) internal pure returns (string memory) { return string.concat(value < 0 ? "-" : "", toString(SignedMath.abs(value))); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { uint256 localValue = value; bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_DIGITS[localValue & 0xf]; localValue >>= 4; } if (localValue != 0) { revert StringsInsufficientHexLength(value, length); } return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } /** * @dev Returns true if the two strings are equal. */ function equal(string memory a, string memory b) internal pure returns (bool) { return bytes(a).length == bytes(b).length && keccak256(bytes(a)) == keccak256(bytes(b)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol) // This file was procedurally generated from scripts/generate/templates/StorageSlot.js. pragma solidity ^0.8.20; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ```solidity * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(newImplementation.code.length > 0); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` */ library StorageSlot { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } struct StringSlot { string value; } struct BytesSlot { bytes value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` with member `value` located at `slot`. */ function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `StringSlot` representation of the string storage pointer `store`. */ function getStringSlot(string storage store) internal pure returns (StringSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } /** * @dev Returns an `BytesSlot` with member `value` located at `slot`. */ function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := slot } } /** * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`. */ function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) { /// @solidity memory-safe-assembly assembly { r.slot := store.slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.9.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol) pragma solidity ^0.8.20; /** * @dev Standard signed math utilities missing in the Solidity language. */ library SignedMath { /** * @dev Returns the largest of two signed numbers. */ function max(int256 a, int256 b) internal pure returns (int256) { return a > b ? a : b; } /** * @dev Returns the smallest of two signed numbers. */ function min(int256 a, int256 b) internal pure returns (int256) { return a < b ? a : b; } /** * @dev Returns the average of two signed numbers without overflow. * The result is rounded towards zero. */ function average(int256 a, int256 b) internal pure returns (int256) { // Formula from the book "Hacker's Delight" int256 x = (a & b) + ((a ^ b) >> 1); return x + (int256(uint256(x) >> 255) & (a ^ b)); } /** * @dev Returns the absolute unsigned value of a signed value. */ function abs(int256 n) internal pure returns (uint256) { unchecked { // must be unchecked in order to support `n = type(int256).min` return uint256(n >= 0 ? n : -n); } } }
{ "remappings": [ "forge-std/=lib/forge-std/src/", "solmate/=lib/solmate/src/", "ds-test/=lib/forge-std/lib/ds-test/src/", "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "@/=src/", "@solady/=lib/solady/src/", "@unifapv2/=src/UnifapV2/", "clones/=lib/clones-with-immutable-args/src/", "@openzeppelin/=lib/openzeppelin-contracts/contracts/", "@clones/=lib/unifap-v2/lib/clones-with-immutable-args/src/", "@ds/=lib/unifap-v2/lib/ds-test/src/", "@solmate/=lib/unifap-v2/lib/solmate/src/", "@std/=lib/unifap-v2/lib/forge-std/src/", "abdk-libraries-solidity/=lib/abdk-libraries-solidity/", "clones-with-immutable-args/=lib/clones-with-immutable-args/src/", "clones/=lib/unifap-v2/lib/clones-with-immutable-args/src/", "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "solady/=lib/solady/", "unifap-v2/=lib/unifap-v2/src/" ], "optimizer": { "enabled": true, "runs": 1000000 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "paris", "libraries": { "src/libraries/HalfLife.sol": { "HalfLife": "0xcf4d7552ca9f07c474d69e89a88943fabb60b199" }, "src/libraries/HalfLifeCarbonCreditAuction.sol": { "HalfLifeCarbonCreditAuction": "0xd178525026bafc51d045a2e98b0c79a526d446de" } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_usdc","type":"address"},{"internalType":"address","name":"_usdcReceiver","type":"address"},{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_univ2Factory","type":"address"},{"internalType":"address","name":"_glow","type":"address"},{"internalType":"address","name":"_gcc","type":"address"},{"internalType":"address","name":"_holdingContract","type":"address"},{"internalType":"address","name":"_vetoCouncilContract","type":"address"},{"internalType":"address","name":"_impactCatalyst","type":"address"}],"stateMutability":"payable","type":"constructor"},{"inputs":[],"name":"ECDSAInvalidSignature","type":"error"},{"inputs":[{"internalType":"uint256","name":"length","type":"uint256"}],"name":"ECDSAInvalidSignatureLength","type":"error"},{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"ECDSAInvalidSignatureS","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"currentAllowance","type":"uint256"},{"internalType":"uint256","name":"requestedDecrease","type":"uint256"}],"name":"ERC20FailedDecreaseAllowance","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":[{"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"ERC2612ExpiredSignature","type":"error"},{"inputs":[{"internalType":"address","name":"signer","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"ERC2612InvalidSigner","type":"error"},{"inputs":[],"name":"ErrCannotSwapZero","type":"error"},{"inputs":[],"name":"ErrIsContract","type":"error"},{"inputs":[],"name":"ErrNotVetoCouncilMember","type":"error"},{"inputs":[],"name":"ErrPermanentlyFrozen","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"currentNonce","type":"uint256"}],"name":"InvalidAccountNonce","type":"error"},{"inputs":[],"name":"InvalidShortString","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"inputs":[],"name":"ToCannotBeUSDCReceiver","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":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[],"name":"PermanentFreeze","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"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UNISWAP_V2_FACTORY","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDC","outputs":[{"internalType":"contract ERC20Permit","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDC_RECEIVER","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":"","type":"address"}],"name":"allowlistedContracts","outputs":[{"internalType":"bool","name":"","type":"bool"}],"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":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"requestedDecrease","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"eip712Domain","outputs":[{"internalType":"bytes1","name":"fields","type":"bytes1"},{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"uint256","name":"chainId","type":"uint256"},{"internalType":"address","name":"verifyingContract","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256[]","name":"extensions","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"freezeContract","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"permanentlyFreezeTransfers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"swap","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":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vetoCouncilContract","outputs":[{"internalType":"contract IVetoCouncil","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
6101e06040526040516200263838038062002638833981016040819052620000279162000570565b866040518060400160405280600c81526020016b47756172646564205553444360a01b81525080604051806040016040528060018152602001603160f81b8152506040518060400160405280600d81526020016c023bab0b93232b2102aa9a2219609d1b81525060405180604001604052806009815260200168555344472d474c4f5760b81b8152508160039081620000c19190620006d0565b506004620000d08282620006d0565b50620000e2915083905060056200027f565b61012052620000f38160066200027f565b61014052815160208084019190912060e052815190820120610100524660a0526200018160e05161010051604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201529081019290925260608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60805250503060c052506200019681620002b8565b506001600160a01b03898116610160528881166101808190528782166101a08190526000918252600960205260408083208054600160ff199182168117909255948816845290832080549094161790925590620001f59030886200030a565b6001600160a01b0381166000908152600960205260408120805460ff191660011790556101a051919250906200022d9030886200030a565b6001600160a01b039081166000908152600960205260408082208054600160ff1991821681179092559784166101c0529590921681522080549094169092179092555062000811975050505050505050565b60006020835110156200029f57620002978362000321565b9050620002b2565b81620002ac8482620006d0565b5060ff90505b92915050565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000620003198484846200036d565b949350505050565b600080829050601f8151111562000358578260405163305a27a960e01b81526004016200034f91906200079c565b60405180910390fd5b80516200036582620007ec565b179392505050565b600080806200037d858562000456565b6040516001600160601b0319606084811b8216602084015283901b1660348201529193509150869060480160405160208183030381529060405280519060200120604051602001620004349291907fff00000000000000000000000000000000000000000000000000000000000000815260609290921b6001600160601b031916600183015260158201527f96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f603582015260550190565b60408051601f1981840301815291905280516020909101209695505050505050565b600080826001600160a01b0316846001600160a01b031603620004ca5760405162461bcd60e51b815260206004820152602560248201527f556e697377617056324c6962726172793a204944454e544943414c5f41444452604482015264455353455360d81b60648201526084016200034f565b826001600160a01b0316846001600160a01b031610620004ec578284620004ef565b83835b90925090506001600160a01b0382166200054c5760405162461bcd60e51b815260206004820152601e60248201527f556e697377617056324c6962726172793a205a45524f5f41444452455353000060448201526064016200034f565b9250929050565b80516001600160a01b03811681146200056b57600080fd5b919050565b60008060008060008060008060006101208a8c0312156200059057600080fd5b6200059b8a62000553565b9850620005ab60208b0162000553565b9750620005bb60408b0162000553565b9650620005cb60608b0162000553565b9550620005db60808b0162000553565b9450620005eb60a08b0162000553565b9350620005fb60c08b0162000553565b92506200060b60e08b0162000553565b91506200061c6101008b0162000553565b90509295985092959850929598565b634e487b7160e01b600052604160045260246000fd5b600181811c908216806200065657607f821691505b6020821081036200067757634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620006cb57600081815260208120601f850160051c81016020861015620006a65750805b601f850160051c820191505b81811015620006c757828155600101620006b2565b5050505b505050565b81516001600160401b03811115620006ec57620006ec6200062b565b6200070481620006fd845462000641565b846200067d565b602080601f8311600181146200073c5760008415620007235750858301515b600019600386901b1c1916600185901b178555620006c7565b600085815260208120601f198616915b828110156200076d578886015182559484019460019091019084016200074c565b50858210156200078c5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b600060208083528351808285015260005b81811015620007cb57858101830151858201604001528201620007ad565b506000604082860101526040601f19601f8301168501019250505092915050565b80516020808301519190811015620006775760001960209190910360031b1b16919050565b60805160a05160c05160e05161010051610120516101405161016051610180516101a0516101c051611d68620008d0600039600081816101f9015261073c015260006103760152600081816102940152818161086c0152818161096601528181610a410152610b200152600081816103290152818161099101528181610a730152610b4b015260006111a301526000611176015260006110540152600061102c01526000610f8701526000610fb101526000610fdb0152611d686000f3fe608060405234801561001057600080fd5b50600436106101ae5760003560e01c806389a30271116100ee578063a584a9b511610097578063d505accf11610071578063d505accf146103fe578063dd62ed3e14610411578063f19a1eea14610457578063f2fde38b1461047a57600080fd5b8063a584a9b5146103d0578063a9059cbb146103d8578063d004f0f7146103eb57600080fd5b806399d8fae3116100c857806399d8fae314610371578063a457c2d714610398578063a46ba7f9146103ab57600080fd5b806389a30271146103245780638da5cb5b1461034b57806395d89b411461036957600080fd5b80633644e5151161015b57806370a082311161013557806370a08231146102b6578063715018a6146102ec5780637ecebe00146102f657806384b0196e1461030957600080fd5b80633644e51514610274578063395093511461027c57806359dd83031461028f57600080fd5b806318160ddd1161018c57806318160ddd1461024057806323b872dd14610252578063313ce5671461026557600080fd5b806306fdde03146101b3578063095ea7b3146101d157806314672d0c146101f4575b600080fd5b6101bb61048d565b6040516101c891906119f7565b60405180910390f35b6101e46101df366004611a3a565b61051f565b60405190151581526020016101c8565b61021b7f000000000000000000000000000000000000000000000000000000000000000081565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101c8565b6002545b6040519081526020016101c8565b6101e4610260366004611a64565b610539565b604051600681526020016101c8565b61024461055d565b6101e461028a366004611a3a565b61056c565b61021b7f000000000000000000000000000000000000000000000000000000000000000081565b6102446102c4366004611aa0565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6102f46105b8565b005b610244610304366004611aa0565b6105cc565b6103116105f7565b6040516101c89796959493929190611abb565b61021b7f000000000000000000000000000000000000000000000000000000000000000081565b60085473ffffffffffffffffffffffffffffffffffffffff1661021b565b6101bb610659565b61021b7f000000000000000000000000000000000000000000000000000000000000000081565b6101e46103a6366004611a3a565b610668565b6008546101e49074010000000000000000000000000000000000000000900460ff1681565b6102f461070e565b6101e46103e6366004611a3a565b61085c565b6102f46103f9366004611a3a565b61086a565b6102f461040c366004611b7a565b610bd6565b61024461041f366004611bed565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101e4610465366004611aa0565b60096020526000908152604090205460ff1681565b6102f4610488366004611aa0565b610d83565b60606003805461049c90611c20565b80601f01602080910402602001604051908101604052809291908181526020018280546104c890611c20565b80156105155780601f106104ea57610100808354040283529160200191610515565b820191906000526020600020905b8154815290600101906020018083116104f857829003601f168201915b5050505050905090565b60003361052d818585610de7565b60019150505b92915050565b600033610547858285610df9565b610552858585610ec2565b506001949350505050565b6000610567610f6d565b905090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919061052d90829086906105b3908790611ca2565b610de7565b6105c06110a5565b6105ca60006110f8565b565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260076020526040812054610533565b60006060806000806000606061060b61116f565b61061361119c565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b60606004805461049c90611c20565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610701576040517fa60f030c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8616600482015260248101829052604481018590526064015b60405180910390fd5b6105528286868403610de7565b6040517febd7dc520000000000000000000000000000000000000000000000000000000081523360048201527f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff169063ebd7dc5290602401602060405180830381865afa158015610798573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107bc9190611cb5565b6107f2576040517f611e185700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001790556040517fb901bee11718c35d0b5ecb003f82e92281569daeafdb28796e4f33a86f7d499890600090a1565b60003361052d818585610ec2565b7f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036108ef576040517f4e1ad8b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600003610929576040517f9d4aa6c400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000811660048301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906370a0823190602401602060405180830381865afa1580156109da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fe9190611cd7565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000081166024830152604482018590529192507f0000000000000000000000000000000000000000000000000000000000000000909116906323b872dd906064016020604051808303816000875af1158015610abe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae29190611cb5565b506040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000811660048301526000917f0000000000000000000000000000000000000000000000000000000000000000909116906370a0823190602401602060405180830381865afa158015610b94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb89190611cd7565b9050610bc48282611cf0565b9250610bd084846111c9565b50505050565b83421115610c13576040517f62791302000000000000000000000000000000000000000000000000000000008152600481018590526024016106f8565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9888888610c6d8c73ffffffffffffffffffffffffffffffffffffffff16600090815260076020526040902080546001810190915590565b60408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610cd582611229565b90506000610ce582878787611271565b90508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610d6c576040517f4b800e4600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301528b1660248201526044016106f8565b610d778a8a8a610de7565b50505050505050505050565b610d8b6110a5565b73ffffffffffffffffffffffffffffffffffffffff8116610ddb576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016106f8565b610de4816110f8565b50565b610df4838383600161129f565b505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610bd05781811015610eb3576040517ffb8f41b200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260248101829052604481018390526064016106f8565b610bd08484848403600061129f565b73ffffffffffffffffffffffffffffffffffffffff8316610f12576040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600060048201526024016106f8565b73ffffffffffffffffffffffffffffffffffffffff8216610f62576040517fec442f05000000000000000000000000000000000000000000000000000000008152600060048201526024016106f8565b610df48383836113e7565b60003073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016148015610fd357507f000000000000000000000000000000000000000000000000000000000000000046145b15610ffd57507f000000000000000000000000000000000000000000000000000000000000000090565b610567604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527f0000000000000000000000000000000000000000000000000000000000000000918101919091527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60085473ffffffffffffffffffffffffffffffffffffffff1633146105ca576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016106f8565b6008805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60606105677f00000000000000000000000000000000000000000000000000000000000000006005611459565b60606105677f00000000000000000000000000000000000000000000000000000000000000006006611459565b73ffffffffffffffffffffffffffffffffffffffff8216611219576040517fec442f05000000000000000000000000000000000000000000000000000000008152600060048201526024016106f8565b611225600083836113e7565b5050565b6000610533611236610f6d565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b60008060008061128388888888611504565b92509250925061129382826115fe565b50909695505050505050565b73ffffffffffffffffffffffffffffffffffffffff84166112ef576040517fe602df05000000000000000000000000000000000000000000000000000000008152600060048201526024016106f8565b73ffffffffffffffffffffffffffffffffffffffff831661133f576040517f94280d62000000000000000000000000000000000000000000000000000000008152600060048201526024016106f8565b73ffffffffffffffffffffffffffffffffffffffff80851660009081526001602090815260408083209387168352929052208290558015610bd0578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516113d991815260200190565b60405180910390a350505050565b60085474010000000000000000000000000000000000000000900460ff161561143c576040517ffa035d1a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61144583611702565b61144e82611702565b610df4838383611768565b606060ff83146114735761146c83611913565b9050610533565b81805461147f90611c20565b80601f01602080910402602001604051908101604052809291908181526020018280546114ab90611c20565b80156114f85780601f106114cd576101008083540402835291602001916114f8565b820191906000526020600020905b8154815290600101906020018083116114db57829003601f168201915b50505050509050610533565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561153f57506000915060039050826115f4565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015611593573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff81166115ea575060009250600191508290506115f4565b9250600091508190505b9450945094915050565b600082600381111561161257611612611d03565b0361161b575050565b600182600381111561162f5761162f611d03565b03611666576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600282600381111561167a5761167a611d03565b036116b4576040517ffce698f7000000000000000000000000000000000000000000000000000000008152600481018290526024016106f8565b60038260038111156116c8576116c8611d03565b03611225576040517fd78bce0c000000000000000000000000000000000000000000000000000000008152600481018290526024016106f8565b803b15610de45773ffffffffffffffffffffffffffffffffffffffff811660009081526009602052604090205460ff16610de4576040517f7d3bdde500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff83166117a05780600260008282546117959190611ca2565b909155506118529050565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015611826576040517fe450d38c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260248101829052604481018390526064016106f8565b73ffffffffffffffffffffffffffffffffffffffff841660009081526020819052604090209082900390555b73ffffffffffffffffffffffffffffffffffffffff821661187b576002805482900390556118a7565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090208054820190555b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161190691815260200190565b60405180910390a3505050565b6060600061192083611952565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b600060ff8216601f811115610533576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000815180845260005b818110156119b95760208185018101518683018201520161199d565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b602081526000611a0a6020830184611993565b9392505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114611a3557600080fd5b919050565b60008060408385031215611a4d57600080fd5b611a5683611a11565b946020939093013593505050565b600080600060608486031215611a7957600080fd5b611a8284611a11565b9250611a9060208501611a11565b9150604084013590509250925092565b600060208284031215611ab257600080fd5b611a0a82611a11565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e081840152611af760e084018a611993565b8381036040850152611b09818a611993565b6060850189905273ffffffffffffffffffffffffffffffffffffffff8816608086015260a0850187905284810360c0860152855180825283870192509083019060005b81811015611b6857835183529284019291840191600101611b4c565b50909c9b505050505050505050505050565b600080600080600080600060e0888a031215611b9557600080fd5b611b9e88611a11565b9650611bac60208901611a11565b95506040880135945060608801359350608088013560ff81168114611bd057600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215611c0057600080fd5b611c0983611a11565b9150611c1760208401611a11565b90509250929050565b600181811c90821680611c3457607f821691505b602082108103611c6d577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561053357610533611c73565b600060208284031215611cc757600080fd5b81518015158114611a0a57600080fd5b600060208284031215611ce957600080fd5b5051919050565b8181038181111561053357610533611c73565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fdfea2646970667358221220635cbd00891b9eba0415d5a212868cca40a374dee6b51b6b80e931f1d7dbb7a364736f6c63430008150033000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c5174bbf649a92f9941e981af68aaa14dd814f850000000000000000000000005a57a85b5162136026874aef76249af1f5149e5e0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f000000000000000000000000f4fbc617a5733eaaf9af08e1ab816b103388d8b600000000000000000000000021c46173591f39afc1d2b634b74c98f0576a272b000000000000000000000000d5970622b740a2ea5a5574616c193968b10e1297000000000000000000000000a3a32d3c9a5a593bc35d69bacbe2df5ea2c3cf5c000000000000000000000000552fbb4e0269fd5036daf72ec006aaf6c958f4fa
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106101ae5760003560e01c806389a30271116100ee578063a584a9b511610097578063d505accf11610071578063d505accf146103fe578063dd62ed3e14610411578063f19a1eea14610457578063f2fde38b1461047a57600080fd5b8063a584a9b5146103d0578063a9059cbb146103d8578063d004f0f7146103eb57600080fd5b806399d8fae3116100c857806399d8fae314610371578063a457c2d714610398578063a46ba7f9146103ab57600080fd5b806389a30271146103245780638da5cb5b1461034b57806395d89b411461036957600080fd5b80633644e5151161015b57806370a082311161013557806370a08231146102b6578063715018a6146102ec5780637ecebe00146102f657806384b0196e1461030957600080fd5b80633644e51514610274578063395093511461027c57806359dd83031461028f57600080fd5b806318160ddd1161018c57806318160ddd1461024057806323b872dd14610252578063313ce5671461026557600080fd5b806306fdde03146101b3578063095ea7b3146101d157806314672d0c146101f4575b600080fd5b6101bb61048d565b6040516101c891906119f7565b60405180910390f35b6101e46101df366004611a3a565b61051f565b60405190151581526020016101c8565b61021b7f000000000000000000000000a3a32d3c9a5a593bc35d69bacbe2df5ea2c3cf5c81565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101c8565b6002545b6040519081526020016101c8565b6101e4610260366004611a64565b610539565b604051600681526020016101c8565b61024461055d565b6101e461028a366004611a3a565b61056c565b61021b7f000000000000000000000000c5174bbf649a92f9941e981af68aaa14dd814f8581565b6102446102c4366004611aa0565b73ffffffffffffffffffffffffffffffffffffffff1660009081526020819052604090205490565b6102f46105b8565b005b610244610304366004611aa0565b6105cc565b6103116105f7565b6040516101c89796959493929190611abb565b61021b7f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb4881565b60085473ffffffffffffffffffffffffffffffffffffffff1661021b565b6101bb610659565b61021b7f0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f81565b6101e46103a6366004611a3a565b610668565b6008546101e49074010000000000000000000000000000000000000000900460ff1681565b6102f461070e565b6101e46103e6366004611a3a565b61085c565b6102f46103f9366004611a3a565b61086a565b6102f461040c366004611b7a565b610bd6565b61024461041f366004611bed565b73ffffffffffffffffffffffffffffffffffffffff918216600090815260016020908152604080832093909416825291909152205490565b6101e4610465366004611aa0565b60096020526000908152604090205460ff1681565b6102f4610488366004611aa0565b610d83565b60606003805461049c90611c20565b80601f01602080910402602001604051908101604052809291908181526020018280546104c890611c20565b80156105155780601f106104ea57610100808354040283529160200191610515565b820191906000526020600020905b8154815290600101906020018083116104f857829003601f168201915b5050505050905090565b60003361052d818585610de7565b60019150505b92915050565b600033610547858285610df9565b610552858585610ec2565b506001949350505050565b6000610567610f6d565b905090565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919061052d90829086906105b3908790611ca2565b610de7565b6105c06110a5565b6105ca60006110f8565b565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260076020526040812054610533565b60006060806000806000606061060b61116f565b61061361119c565b604080516000808252602082019092527f0f000000000000000000000000000000000000000000000000000000000000009b939a50919850469750309650945092509050565b60606004805461049c90611c20565b33600081815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff8716845290915281205490919083811015610701576040517fa60f030c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8616600482015260248101829052604481018590526064015b60405180910390fd5b6105528286868403610de7565b6040517febd7dc520000000000000000000000000000000000000000000000000000000081523360048201527f000000000000000000000000a3a32d3c9a5a593bc35d69bacbe2df5ea2c3cf5c73ffffffffffffffffffffffffffffffffffffffff169063ebd7dc5290602401602060405180830381865afa158015610798573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107bc9190611cb5565b6107f2576040517f611e185700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600880547fffffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffff16740100000000000000000000000000000000000000001790556040517fb901bee11718c35d0b5ecb003f82e92281569daeafdb28796e4f33a86f7d499890600090a1565b60003361052d818585610ec2565b7f000000000000000000000000c5174bbf649a92f9941e981af68aaa14dd814f8573ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036108ef576040517f4e1ad8b000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80600003610929576040517f9d4aa6c400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c5174bbf649a92f9941e981af68aaa14dd814f85811660048301526000917f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48909116906370a0823190602401602060405180830381865afa1580156109da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fe9190611cd7565b6040517f23b872dd00000000000000000000000000000000000000000000000000000000815233600482015273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c5174bbf649a92f9941e981af68aaa14dd814f8581166024830152604482018590529192507f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48909116906323b872dd906064016020604051808303816000875af1158015610abe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ae29190611cb5565b506040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000c5174bbf649a92f9941e981af68aaa14dd814f85811660048301526000917f000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48909116906370a0823190602401602060405180830381865afa158015610b94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb89190611cd7565b9050610bc48282611cf0565b9250610bd084846111c9565b50505050565b83421115610c13576040517f62791302000000000000000000000000000000000000000000000000000000008152600481018590526024016106f8565b60007f6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9888888610c6d8c73ffffffffffffffffffffffffffffffffffffffff16600090815260076020526040902080546001810190915590565b60408051602081019690965273ffffffffffffffffffffffffffffffffffffffff94851690860152929091166060840152608083015260a082015260c0810186905260e0016040516020818303038152906040528051906020012090506000610cd582611229565b90506000610ce582878787611271565b90508973ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610d6c576040517f4b800e4600000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301528b1660248201526044016106f8565b610d778a8a8a610de7565b50505050505050505050565b610d8b6110a5565b73ffffffffffffffffffffffffffffffffffffffff8116610ddb576040517f1e4fbdf7000000000000000000000000000000000000000000000000000000008152600060048201526024016106f8565b610de4816110f8565b50565b610df4838383600161129f565b505050565b73ffffffffffffffffffffffffffffffffffffffff8381166000908152600160209081526040808320938616835292905220547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8114610bd05781811015610eb3576040517ffb8f41b200000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8416600482015260248101829052604481018390526064016106f8565b610bd08484848403600061129f565b73ffffffffffffffffffffffffffffffffffffffff8316610f12576040517f96c6fd1e000000000000000000000000000000000000000000000000000000008152600060048201526024016106f8565b73ffffffffffffffffffffffffffffffffffffffff8216610f62576040517fec442f05000000000000000000000000000000000000000000000000000000008152600060048201526024016106f8565b610df48383836113e7565b60003073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000e010ec500720be9ef3f82129e7ed2ee1fb7955f216148015610fd357507f000000000000000000000000000000000000000000000000000000000000000146145b15610ffd57507f675e564d1f4eb8ff6fc4742ce6f98e5d956a7109adf5a583837aa3e69293b95b90565b610567604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f60208201527fc4b6504c334351e0dbe6c0f29bbe9a856f0ebafd9f4522da8d2ada9f2cbf8518918101919091527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608201524660808201523060a082015260009060c00160405160208183030381529060405280519060200120905090565b60085473ffffffffffffffffffffffffffffffffffffffff1633146105ca576040517f118cdaa70000000000000000000000000000000000000000000000000000000081523360048201526024016106f8565b6008805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b60606105677f477561726465642055534443000000000000000000000000000000000000000c6005611459565b60606105677f31000000000000000000000000000000000000000000000000000000000000016006611459565b73ffffffffffffffffffffffffffffffffffffffff8216611219576040517fec442f05000000000000000000000000000000000000000000000000000000008152600060048201526024016106f8565b611225600083836113e7565b5050565b6000610533611236610f6d565b836040517f19010000000000000000000000000000000000000000000000000000000000008152600281019290925260228201526042902090565b60008060008061128388888888611504565b92509250925061129382826115fe565b50909695505050505050565b73ffffffffffffffffffffffffffffffffffffffff84166112ef576040517fe602df05000000000000000000000000000000000000000000000000000000008152600060048201526024016106f8565b73ffffffffffffffffffffffffffffffffffffffff831661133f576040517f94280d62000000000000000000000000000000000000000000000000000000008152600060048201526024016106f8565b73ffffffffffffffffffffffffffffffffffffffff80851660009081526001602090815260408083209387168352929052208290558015610bd0578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516113d991815260200190565b60405180910390a350505050565b60085474010000000000000000000000000000000000000000900460ff161561143c576040517ffa035d1a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61144583611702565b61144e82611702565b610df4838383611768565b606060ff83146114735761146c83611913565b9050610533565b81805461147f90611c20565b80601f01602080910402602001604051908101604052809291908181526020018280546114ab90611c20565b80156114f85780601f106114cd576101008083540402835291602001916114f8565b820191906000526020600020905b8154815290600101906020018083116114db57829003601f168201915b50505050509050610533565b600080807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a084111561153f57506000915060039050826115f4565b604080516000808252602082018084528a905260ff891692820192909252606081018790526080810186905260019060a0016020604051602081039080840390855afa158015611593573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff81166115ea575060009250600191508290506115f4565b9250600091508190505b9450945094915050565b600082600381111561161257611612611d03565b0361161b575050565b600182600381111561162f5761162f611d03565b03611666576040517ff645eedf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600282600381111561167a5761167a611d03565b036116b4576040517ffce698f7000000000000000000000000000000000000000000000000000000008152600481018290526024016106f8565b60038260038111156116c8576116c8611d03565b03611225576040517fd78bce0c000000000000000000000000000000000000000000000000000000008152600481018290526024016106f8565b803b15610de45773ffffffffffffffffffffffffffffffffffffffff811660009081526009602052604090205460ff16610de4576040517f7d3bdde500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff83166117a05780600260008282546117959190611ca2565b909155506118529050565b73ffffffffffffffffffffffffffffffffffffffff831660009081526020819052604090205481811015611826576040517fe450d38c00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8516600482015260248101829052604481018390526064016106f8565b73ffffffffffffffffffffffffffffffffffffffff841660009081526020819052604090209082900390555b73ffffffffffffffffffffffffffffffffffffffff821661187b576002805482900390556118a7565b73ffffffffffffffffffffffffffffffffffffffff821660009081526020819052604090208054820190555b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161190691815260200190565b60405180910390a3505050565b6060600061192083611952565b604080516020808252818301909252919250600091906020820181803683375050509182525060208101929092525090565b600060ff8216601f811115610533576040517fb3512b0c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000815180845260005b818110156119b95760208185018101518683018201520161199d565b5060006020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b602081526000611a0a6020830184611993565b9392505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114611a3557600080fd5b919050565b60008060408385031215611a4d57600080fd5b611a5683611a11565b946020939093013593505050565b600080600060608486031215611a7957600080fd5b611a8284611a11565b9250611a9060208501611a11565b9150604084013590509250925092565b600060208284031215611ab257600080fd5b611a0a82611a11565b7fff00000000000000000000000000000000000000000000000000000000000000881681526000602060e081840152611af760e084018a611993565b8381036040850152611b09818a611993565b6060850189905273ffffffffffffffffffffffffffffffffffffffff8816608086015260a0850187905284810360c0860152855180825283870192509083019060005b81811015611b6857835183529284019291840191600101611b4c565b50909c9b505050505050505050505050565b600080600080600080600060e0888a031215611b9557600080fd5b611b9e88611a11565b9650611bac60208901611a11565b95506040880135945060608801359350608088013560ff81168114611bd057600080fd5b9699959850939692959460a0840135945060c09093013592915050565b60008060408385031215611c0057600080fd5b611c0983611a11565b9150611c1760208401611a11565b90509250929050565b600181811c90821680611c3457607f821691505b602082108103611c6d577f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b50919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b8082018082111561053357610533611c73565b600060208284031215611cc757600080fd5b81518015158114611a0a57600080fd5b600060208284031215611ce957600080fd5b5051919050565b8181038181111561053357610533611c73565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fdfea2646970667358221220635cbd00891b9eba0415d5a212868cca40a374dee6b51b6b80e931f1d7dbb7a364736f6c63430008150033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48000000000000000000000000c5174bbf649a92f9941e981af68aaa14dd814f850000000000000000000000005a57a85b5162136026874aef76249af1f5149e5e0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f000000000000000000000000f4fbc617a5733eaaf9af08e1ab816b103388d8b600000000000000000000000021c46173591f39afc1d2b634b74c98f0576a272b000000000000000000000000d5970622b740a2ea5a5574616c193968b10e1297000000000000000000000000a3a32d3c9a5a593bc35d69bacbe2df5ea2c3cf5c000000000000000000000000552fbb4e0269fd5036daf72ec006aaf6c958f4fa
-----Decoded View---------------
Arg [0] : _usdc (address): 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
Arg [1] : _usdcReceiver (address): 0xc5174BBf649a92F9941e981af68AaA14Dd814F85
Arg [2] : _owner (address): 0x5a57A85b5162136026874aeF76249af1F5149e5E
Arg [3] : _univ2Factory (address): 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f
Arg [4] : _glow (address): 0xf4fbC617A5733EAAF9af08E1Ab816B103388d8B6
Arg [5] : _gcc (address): 0x21C46173591f39AfC1d2B634b74c98F0576A272B
Arg [6] : _holdingContract (address): 0xd5970622b740a2eA5A5574616c193968b10e1297
Arg [7] : _vetoCouncilContract (address): 0xA3A32d3c9a5A593bc35D69BACbe2dF5Ea2C3cF5C
Arg [8] : _impactCatalyst (address): 0x552Fbb4E0269fd5036daf72Ec006AAF6C958F4Fa
-----Encoded View---------------
9 Constructor Arguments found :
Arg [0] : 000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48
Arg [1] : 000000000000000000000000c5174bbf649a92f9941e981af68aaa14dd814f85
Arg [2] : 0000000000000000000000005a57a85b5162136026874aef76249af1f5149e5e
Arg [3] : 0000000000000000000000005c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f
Arg [4] : 000000000000000000000000f4fbc617a5733eaaf9af08e1ab816b103388d8b6
Arg [5] : 00000000000000000000000021c46173591f39afc1d2b634b74c98f0576a272b
Arg [6] : 000000000000000000000000d5970622b740a2ea5a5574616c193968b10e1297
Arg [7] : 000000000000000000000000a3a32d3c9a5a593bc35d69bacbe2df5ea2c3cf5c
Arg [8] : 000000000000000000000000552fbb4e0269fd5036daf72ec006aaf6c958f4fa
Loading...
Loading
Loading...
Loading
[ 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.