Overview
ETH Balance
0 ETH
ETH Value
$0.00More Info
Private Name Tags
ContractCreator
Latest 1 internal transaction
Advanced mode:
Parent Transaction Hash | Block | From | To | |||
---|---|---|---|---|---|---|
128536711 | 15 days ago | Contract Creation | 0 ETH |
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
SignerValidator
Compiler Version
v0.8.26+commit.8a97fa7a
Optimization Enabled:
Yes with 10000 runs
Other Settings:
cancun EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.24; import {Ownable} from "@solady/auth/Ownable.sol"; import {SignatureCheckerLib} from "@solady/utils/SignatureCheckerLib.sol"; import {EIP712} from "@solady/utils/EIP712.sol"; import {ACloneable} from "contracts/shared/ACloneable.sol"; import {BoostError} from "contracts/shared/BoostError.sol"; import {IncentiveBits} from "contracts/shared/IncentiveBits.sol"; import {AValidator} from "contracts/validators/AValidator.sol"; import {ASignerValidator} from "contracts/validators/ASignerValidator.sol"; /// @title Signer Validator /// @notice A simple implementation of a Validator that verifies a given signature and checks the recovered address against a set of authorized signers contract SignerValidator is ASignerValidator, Ownable, EIP712 { using SignatureCheckerLib for address; using IncentiveBits for IncentiveBits.IncentiveMap; /// @dev track claimed incentives using this bitmap IncentiveBits.IncentiveMap _used; /// @dev address allowed to call validate address internal _validatorCaller; bytes32 internal constant _SIGNER_VALIDATOR_TYPEHASH = keccak256("SignerValidatorData(uint256 boostId,uint8 incentiveQuantity,address claimant,bytes incentiveData)"); /// @notice Construct a new SignerValidator /// @dev Because this contract is a base implementation, it should not be initialized through the constructor. Instead, it should be cloned and initialized using the {initialize} function. constructor() { _disableInitializers(); } /// @notice Initialize the contract with the list of authorized signers /// @param data_ The compressed list of authorized signers /// @dev The first address in the list will be the initial owner of the contract function initialize(bytes calldata data_) public virtual override initializer { (address[] memory signers_, address validatorCaller_) = abi.decode(data_, (address[], address)); _initializeOwner(signers_[0]); _validatorCaller = validatorCaller_; for (uint256 i = 0; i < signers_.length; i++) { signers[signers_[i]] = true; } } /// Validate that the action has been completed successfully by constructing a payload and checking the signature against it /// @inheritdoc AValidator function validate(uint256 boostId, uint256 incentiveId, address claimant, bytes calldata claimData) public virtual override returns (bool) { if (msg.sender != _validatorCaller) revert BoostError.Unauthorized(); (BoostClaimData memory claim) = abi.decode(claimData, (BoostClaimData)); (SignerValidatorInputParams memory validatorData) = abi.decode(claim.validatorData, (SignerValidatorInputParams)); bytes32 hash = hashSignerData(boostId, validatorData.incentiveQuantity, claimant, claim.incentiveData); if (uint256(validatorData.incentiveQuantity) <= incentiveId) { revert BoostError.InvalidIncentive(validatorData.incentiveQuantity, incentiveId); } if (!signers[validatorData.signer]) revert BoostError.Unauthorized(); // Mark the incentive as claimed to prevent replays // checks internally if the incentive has already been claimed _used.setOrThrow(hash, incentiveId); // Return the result of the signature check // no need for a sig prefix since it's encoded by the EIP712 lib return validatorData.signer.isValidSignatureNow(hash, validatorData.signature); } /// @notice Set the authorized status of a signer /// @param signers_ The list of signers to update /// @param authorized_ The authorized status of each signer function setAuthorized(address[] calldata signers_, bool[] calldata authorized_) external override onlyOwner { if (signers_.length != authorized_.length) revert BoostError.LengthMismatch(); for (uint256 i = 0; i < signers_.length; i++) { signers[signers_[i]] = authorized_[i]; } } /// @inheritdoc ASignerValidator function setValidatorCaller(address newCaller) external override onlyOwner { _validatorCaller = newCaller; } function hashSignerData(uint256 boostId, uint8 incentiveQuantity, address claimant, bytes memory incentiveData) public view returns (bytes32 hashedSignerData) { return _hashTypedData( keccak256( abi.encode(_SIGNER_VALIDATOR_TYPEHASH, boostId, incentiveQuantity, claimant, keccak256(incentiveData)) ) ); } function _domainNameAndVersion() internal pure virtual override returns (string memory name, string memory version) { name = "SignerValidator"; version = "1"; } function _domainNameAndVersionMayChange() internal pure override returns (bool result) { result = true; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Simple single owner authorization mixin. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/auth/Ownable.sol) /// /// @dev Note: /// This implementation does NOT auto-initialize the owner to `msg.sender`. /// You MUST call the `_initializeOwner` in the constructor / initializer. /// /// While the ownable portion follows /// [EIP-173](https://eips.ethereum.org/EIPS/eip-173) for compatibility, /// the nomenclature for the 2-step ownership handover may be unique to this codebase. abstract contract Ownable { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The caller is not authorized to call the function. error Unauthorized(); /// @dev The `newOwner` cannot be the zero address. error NewOwnerIsZeroAddress(); /// @dev The `pendingOwner` does not have a valid handover request. error NoHandoverRequest(); /// @dev Cannot double-initialize. error AlreadyInitialized(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EVENTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The ownership is transferred from `oldOwner` to `newOwner`. /// This event is intentionally kept the same as OpenZeppelin's Ownable to be /// compatible with indexers and [EIP-173](https://eips.ethereum.org/EIPS/eip-173), /// despite it not being as lightweight as a single argument event. event OwnershipTransferred(address indexed oldOwner, address indexed newOwner); /// @dev An ownership handover to `pendingOwner` has been requested. event OwnershipHandoverRequested(address indexed pendingOwner); /// @dev The ownership handover to `pendingOwner` has been canceled. event OwnershipHandoverCanceled(address indexed pendingOwner); /// @dev `keccak256(bytes("OwnershipTransferred(address,address)"))`. uint256 private constant _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE = 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0; /// @dev `keccak256(bytes("OwnershipHandoverRequested(address)"))`. uint256 private constant _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE = 0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d; /// @dev `keccak256(bytes("OwnershipHandoverCanceled(address)"))`. uint256 private constant _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE = 0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STORAGE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The owner slot is given by: /// `bytes32(~uint256(uint32(bytes4(keccak256("_OWNER_SLOT_NOT")))))`. /// It is intentionally chosen to be a high value /// to avoid collision with lower slots. /// The choice of manual storage layout is to enable compatibility /// with both regular and upgradeable contracts. bytes32 internal constant _OWNER_SLOT = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927; /// The ownership handover slot of `newOwner` is given by: /// ``` /// mstore(0x00, or(shl(96, user), _HANDOVER_SLOT_SEED)) /// let handoverSlot := keccak256(0x00, 0x20) /// ``` /// It stores the expiry timestamp of the two-step ownership handover. uint256 private constant _HANDOVER_SLOT_SEED = 0x389a75e1; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* INTERNAL FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Override to return true to make `_initializeOwner` prevent double-initialization. function _guardInitializeOwner() internal pure virtual returns (bool guard) {} /// @dev Initializes the owner directly without authorization guard. /// This function must be called upon initialization, /// regardless of whether the contract is upgradeable or not. /// This is to enable generalization to both regular and upgradeable contracts, /// and to save gas in case the initial owner is not the caller. /// For performance reasons, this function will not check if there /// is an existing owner. function _initializeOwner(address newOwner) internal virtual { if (_guardInitializeOwner()) { /// @solidity memory-safe-assembly assembly { let ownerSlot := _OWNER_SLOT if sload(ownerSlot) { mstore(0x00, 0x0dc149f0) // `AlreadyInitialized()`. revert(0x1c, 0x04) } // Clean the upper 96 bits. newOwner := shr(96, shl(96, newOwner)) // Store the new value. sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner)))) // Emit the {OwnershipTransferred} event. log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner) } } else { /// @solidity memory-safe-assembly assembly { // Clean the upper 96 bits. newOwner := shr(96, shl(96, newOwner)) // Store the new value. sstore(_OWNER_SLOT, newOwner) // Emit the {OwnershipTransferred} event. log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, 0, newOwner) } } } /// @dev Sets the owner directly without authorization guard. function _setOwner(address newOwner) internal virtual { if (_guardInitializeOwner()) { /// @solidity memory-safe-assembly assembly { let ownerSlot := _OWNER_SLOT // Clean the upper 96 bits. newOwner := shr(96, shl(96, newOwner)) // Emit the {OwnershipTransferred} event. log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner) // Store the new value. sstore(ownerSlot, or(newOwner, shl(255, iszero(newOwner)))) } } else { /// @solidity memory-safe-assembly assembly { let ownerSlot := _OWNER_SLOT // Clean the upper 96 bits. newOwner := shr(96, shl(96, newOwner)) // Emit the {OwnershipTransferred} event. log3(0, 0, _OWNERSHIP_TRANSFERRED_EVENT_SIGNATURE, sload(ownerSlot), newOwner) // Store the new value. sstore(ownerSlot, newOwner) } } } /// @dev Throws if the sender is not the owner. function _checkOwner() internal view virtual { /// @solidity memory-safe-assembly assembly { // If the caller is not the stored owner, revert. if iszero(eq(caller(), sload(_OWNER_SLOT))) { mstore(0x00, 0x82b42900) // `Unauthorized()`. revert(0x1c, 0x04) } } } /// @dev Returns how long a two-step ownership handover is valid for in seconds. /// Override to return a different value if needed. /// Made internal to conserve bytecode. Wrap it in a public function if needed. function _ownershipHandoverValidFor() internal view virtual returns (uint64) { return 48 * 3600; } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* PUBLIC UPDATE FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Allows the owner to transfer the ownership to `newOwner`. function transferOwnership(address newOwner) public payable virtual onlyOwner { /// @solidity memory-safe-assembly assembly { if iszero(shl(96, newOwner)) { mstore(0x00, 0x7448fbae) // `NewOwnerIsZeroAddress()`. revert(0x1c, 0x04) } } _setOwner(newOwner); } /// @dev Allows the owner to renounce their ownership. function renounceOwnership() public payable virtual onlyOwner { _setOwner(address(0)); } /// @dev Request a two-step ownership handover to the caller. /// The request will automatically expire in 48 hours (172800 seconds) by default. function requestOwnershipHandover() public payable virtual { unchecked { uint256 expires = block.timestamp + _ownershipHandoverValidFor(); /// @solidity memory-safe-assembly assembly { // Compute and set the handover slot to `expires`. mstore(0x0c, _HANDOVER_SLOT_SEED) mstore(0x00, caller()) sstore(keccak256(0x0c, 0x20), expires) // Emit the {OwnershipHandoverRequested} event. log2(0, 0, _OWNERSHIP_HANDOVER_REQUESTED_EVENT_SIGNATURE, caller()) } } } /// @dev Cancels the two-step ownership handover to the caller, if any. function cancelOwnershipHandover() public payable virtual { /// @solidity memory-safe-assembly assembly { // Compute and set the handover slot to 0. mstore(0x0c, _HANDOVER_SLOT_SEED) mstore(0x00, caller()) sstore(keccak256(0x0c, 0x20), 0) // Emit the {OwnershipHandoverCanceled} event. log2(0, 0, _OWNERSHIP_HANDOVER_CANCELED_EVENT_SIGNATURE, caller()) } } /// @dev Allows the owner to complete the two-step ownership handover to `pendingOwner`. /// Reverts if there is no existing ownership handover requested by `pendingOwner`. function completeOwnershipHandover(address pendingOwner) public payable virtual onlyOwner { /// @solidity memory-safe-assembly assembly { // Compute and set the handover slot to 0. mstore(0x0c, _HANDOVER_SLOT_SEED) mstore(0x00, pendingOwner) let handoverSlot := keccak256(0x0c, 0x20) // If the handover does not exist, or has expired. if gt(timestamp(), sload(handoverSlot)) { mstore(0x00, 0x6f5e8818) // `NoHandoverRequest()`. revert(0x1c, 0x04) } // Set the handover slot to 0. sstore(handoverSlot, 0) } _setOwner(pendingOwner); } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* PUBLIC READ FUNCTIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the owner of the contract. function owner() public view virtual returns (address result) { /// @solidity memory-safe-assembly assembly { result := sload(_OWNER_SLOT) } } /// @dev Returns the expiry timestamp for the two-step ownership handover to `pendingOwner`. function ownershipHandoverExpiresAt(address pendingOwner) public view virtual returns (uint256 result) { /// @solidity memory-safe-assembly assembly { // Compute the handover slot. mstore(0x0c, _HANDOVER_SLOT_SEED) mstore(0x00, pendingOwner) // Load the handover slot. result := sload(keccak256(0x0c, 0x20)) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* MODIFIERS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Marks a function as only callable by the owner. modifier onlyOwner() virtual { _checkOwner(); _; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Signature verification helper that supports both ECDSA signatures from EOAs /// and ERC1271 signatures from smart contract wallets like Argent and Gnosis safe. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/SignatureCheckerLib.sol) /// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/SignatureChecker.sol) /// /// @dev Note: /// - The signature checking functions use the ecrecover precompile (0x1). /// - The `bytes memory signature` variants use the identity precompile (0x4) /// to copy memory internally. /// - Unlike ECDSA signatures, contract signatures are revocable. /// - As of Solady version 0.0.134, all `bytes signature` variants accept both /// regular 65-byte `(r, s, v)` and EIP-2098 `(r, vs)` short form signatures. /// See: https://eips.ethereum.org/EIPS/eip-2098 /// This is for calldata efficiency on smart accounts prevalent on L2s. /// /// WARNING! Do NOT use signatures as unique identifiers: /// - Use a nonce in the digest to prevent replay attacks on the same contract. /// - Use EIP-712 for the digest to prevent replay attacks across different chains and contracts. /// EIP-712 also enables readable signing of typed data for better user safety. /// This implementation does NOT check if a signature is non-malleable. library SignatureCheckerLib { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* SIGNATURE CHECKING OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns whether `signature` is valid for `signer` and `hash`. /// If `signer` is a smart contract, the signature is validated with ERC1271. /// Otherwise, the signature is validated with `ECDSA.recover`. function isValidSignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool isValid) { /// @solidity memory-safe-assembly assembly { // Clean the upper 96 bits of `signer` in case they are dirty. for { signer := shr(96, shl(96, signer)) } signer {} { let m := mload(0x40) mstore(0x00, hash) mstore(0x40, mload(add(signature, 0x20))) // `r`. if eq(mload(signature), 64) { let vs := mload(add(signature, 0x40)) mstore(0x20, add(shr(255, vs), 27)) // `v`. mstore(0x60, shr(1, shl(1, vs))) // `s`. let t := staticcall( gas(), // Amount of gas left for the transaction. 1, // Address of `ecrecover`. 0x00, // Start of input. 0x80, // Size of input. 0x01, // Start of output. 0x20 // Size of output. ) // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise. if iszero(or(iszero(returndatasize()), xor(signer, mload(t)))) { isValid := 1 mstore(0x60, 0) // Restore the zero slot. mstore(0x40, m) // Restore the free memory pointer. break } } if eq(mload(signature), 65) { mstore(0x20, byte(0, mload(add(signature, 0x60)))) // `v`. mstore(0x60, mload(add(signature, 0x40))) // `s`. let t := staticcall( gas(), // Amount of gas left for the transaction. 1, // Address of `ecrecover`. 0x00, // Start of input. 0x80, // Size of input. 0x01, // Start of output. 0x20 // Size of output. ) // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise. if iszero(or(iszero(returndatasize()), xor(signer, mload(t)))) { isValid := 1 mstore(0x60, 0) // Restore the zero slot. mstore(0x40, m) // Restore the free memory pointer. break } } mstore(0x60, 0) // Restore the zero slot. mstore(0x40, m) // Restore the free memory pointer. let f := shl(224, 0x1626ba7e) mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`. mstore(add(m, 0x04), hash) let d := add(m, 0x24) mstore(d, 0x40) // The offset of the `signature` in the calldata. // Copy the `signature` over. let n := add(0x20, mload(signature)) pop(staticcall(gas(), 4, signature, n, add(m, 0x44), n)) // forgefmt: disable-next-item isValid := and( // Whether the returndata is the magic value `0x1626ba7e` (left-aligned). eq(mload(d), f), // Whether the staticcall does not revert. // This must be placed at the end of the `and` clause, // as the arguments are evaluated from right to left. staticcall( gas(), // Remaining gas. signer, // The `signer` address. m, // Offset of calldata in memory. add(returndatasize(), 0x44), // Length of calldata in memory. d, // Offset of returndata. 0x20 // Length of returndata to write. ) ) break } } } /// @dev Returns whether `signature` is valid for `signer` and `hash`. /// If `signer` is a smart contract, the signature is validated with ERC1271. /// Otherwise, the signature is validated with `ECDSA.recover`. function isValidSignatureNowCalldata(address signer, bytes32 hash, bytes calldata signature) internal view returns (bool isValid) { /// @solidity memory-safe-assembly assembly { // Clean the upper 96 bits of `signer` in case they are dirty. for { signer := shr(96, shl(96, signer)) } signer {} { let m := mload(0x40) mstore(0x00, hash) if eq(signature.length, 64) { let vs := calldataload(add(signature.offset, 0x20)) mstore(0x20, add(shr(255, vs), 27)) // `v`. mstore(0x40, calldataload(signature.offset)) // `r`. mstore(0x60, shr(1, shl(1, vs))) // `s`. let t := staticcall( gas(), // Amount of gas left for the transaction. 1, // Address of `ecrecover`. 0x00, // Start of input. 0x80, // Size of input. 0x01, // Start of output. 0x20 // Size of output. ) // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise. if iszero(or(iszero(returndatasize()), xor(signer, mload(t)))) { isValid := 1 mstore(0x60, 0) // Restore the zero slot. mstore(0x40, m) // Restore the free memory pointer. break } } if eq(signature.length, 65) { mstore(0x20, byte(0, calldataload(add(signature.offset, 0x40)))) // `v`. calldatacopy(0x40, signature.offset, 0x40) // `r`, `s`. let t := staticcall( gas(), // Amount of gas left for the transaction. 1, // Address of `ecrecover`. 0x00, // Start of input. 0x80, // Size of input. 0x01, // Start of output. 0x20 // Size of output. ) // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise. if iszero(or(iszero(returndatasize()), xor(signer, mload(t)))) { isValid := 1 mstore(0x60, 0) // Restore the zero slot. mstore(0x40, m) // Restore the free memory pointer. break } } mstore(0x60, 0) // Restore the zero slot. mstore(0x40, m) // Restore the free memory pointer. let f := shl(224, 0x1626ba7e) mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`. mstore(add(m, 0x04), hash) let d := add(m, 0x24) mstore(d, 0x40) // The offset of the `signature` in the calldata. mstore(add(m, 0x44), signature.length) // Copy the `signature` over. calldatacopy(add(m, 0x64), signature.offset, signature.length) // forgefmt: disable-next-item isValid := and( // Whether the returndata is the magic value `0x1626ba7e` (left-aligned). eq(mload(d), f), // Whether the staticcall does not revert. // This must be placed at the end of the `and` clause, // as the arguments are evaluated from right to left. staticcall( gas(), // Remaining gas. signer, // The `signer` address. m, // Offset of calldata in memory. add(signature.length, 0x64), // Length of calldata in memory. d, // Offset of returndata. 0x20 // Length of returndata to write. ) ) break } } } /// @dev Returns whether the signature (`r`, `vs`) is valid for `signer` and `hash`. /// If `signer` is a smart contract, the signature is validated with ERC1271. /// Otherwise, the signature is validated with `ECDSA.recover`. function isValidSignatureNow(address signer, bytes32 hash, bytes32 r, bytes32 vs) internal view returns (bool isValid) { /// @solidity memory-safe-assembly assembly { // Clean the upper 96 bits of `signer` in case they are dirty. for { signer := shr(96, shl(96, signer)) } signer {} { let m := mload(0x40) mstore(0x00, hash) mstore(0x20, add(shr(255, vs), 27)) // `v`. mstore(0x40, r) // `r`. mstore(0x60, shr(1, shl(1, vs))) // `s`. let t := staticcall( gas(), // Amount of gas left for the transaction. 1, // Address of `ecrecover`. 0x00, // Start of input. 0x80, // Size of input. 0x01, // Start of output. 0x20 // Size of output. ) // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise. if iszero(or(iszero(returndatasize()), xor(signer, mload(t)))) { isValid := 1 mstore(0x60, 0) // Restore the zero slot. mstore(0x40, m) // Restore the free memory pointer. break } let f := shl(224, 0x1626ba7e) mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`. mstore(add(m, 0x04), hash) let d := add(m, 0x24) mstore(d, 0x40) // The offset of the `signature` in the calldata. mstore(add(m, 0x44), 65) // Length of the signature. mstore(add(m, 0x64), r) // `r`. mstore(add(m, 0x84), mload(0x60)) // `s`. mstore8(add(m, 0xa4), mload(0x20)) // `v`. // forgefmt: disable-next-item isValid := and( // Whether the returndata is the magic value `0x1626ba7e` (left-aligned). eq(mload(d), f), // Whether the staticcall does not revert. // This must be placed at the end of the `and` clause, // as the arguments are evaluated from right to left. staticcall( gas(), // Remaining gas. signer, // The `signer` address. m, // Offset of calldata in memory. 0xa5, // Length of calldata in memory. d, // Offset of returndata. 0x20 // Length of returndata to write. ) ) mstore(0x60, 0) // Restore the zero slot. mstore(0x40, m) // Restore the free memory pointer. break } } } /// @dev Returns whether the signature (`v`, `r`, `s`) is valid for `signer` and `hash`. /// If `signer` is a smart contract, the signature is validated with ERC1271. /// Otherwise, the signature is validated with `ECDSA.recover`. function isValidSignatureNow(address signer, bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal view returns (bool isValid) { /// @solidity memory-safe-assembly assembly { // Clean the upper 96 bits of `signer` in case they are dirty. for { signer := shr(96, shl(96, signer)) } signer {} { let m := mload(0x40) mstore(0x00, hash) mstore(0x20, and(v, 0xff)) // `v`. mstore(0x40, r) // `r`. mstore(0x60, s) // `s`. let t := staticcall( gas(), // Amount of gas left for the transaction. 1, // Address of `ecrecover`. 0x00, // Start of input. 0x80, // Size of input. 0x01, // Start of output. 0x20 // Size of output. ) // `returndatasize()` will be `0x20` upon success, and `0x00` otherwise. if iszero(or(iszero(returndatasize()), xor(signer, mload(t)))) { isValid := 1 mstore(0x60, 0) // Restore the zero slot. mstore(0x40, m) // Restore the free memory pointer. break } let f := shl(224, 0x1626ba7e) mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`. mstore(add(m, 0x04), hash) let d := add(m, 0x24) mstore(d, 0x40) // The offset of the `signature` in the calldata. mstore(add(m, 0x44), 65) // Length of the signature. mstore(add(m, 0x64), r) // `r`. mstore(add(m, 0x84), s) // `s`. mstore8(add(m, 0xa4), v) // `v`. // forgefmt: disable-next-item isValid := and( // Whether the returndata is the magic value `0x1626ba7e` (left-aligned). eq(mload(d), f), // Whether the staticcall does not revert. // This must be placed at the end of the `and` clause, // as the arguments are evaluated from right to left. staticcall( gas(), // Remaining gas. signer, // The `signer` address. m, // Offset of calldata in memory. 0xa5, // Length of calldata in memory. d, // Offset of returndata. 0x20 // Length of returndata to write. ) ) mstore(0x60, 0) // Restore the zero slot. mstore(0x40, m) // Restore the free memory pointer. break } } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* ERC1271 OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns whether `signature` is valid for `hash` for an ERC1271 `signer` contract. function isValidERC1271SignatureNow(address signer, bytes32 hash, bytes memory signature) internal view returns (bool isValid) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) let f := shl(224, 0x1626ba7e) mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`. mstore(add(m, 0x04), hash) let d := add(m, 0x24) mstore(d, 0x40) // The offset of the `signature` in the calldata. // Copy the `signature` over. let n := add(0x20, mload(signature)) pop(staticcall(gas(), 4, signature, n, add(m, 0x44), n)) // forgefmt: disable-next-item isValid := and( // Whether the returndata is the magic value `0x1626ba7e` (left-aligned). eq(mload(d), f), // Whether the staticcall does not revert. // This must be placed at the end of the `and` clause, // as the arguments are evaluated from right to left. staticcall( gas(), // Remaining gas. signer, // The `signer` address. m, // Offset of calldata in memory. add(returndatasize(), 0x44), // Length of calldata in memory. d, // Offset of returndata. 0x20 // Length of returndata to write. ) ) } } /// @dev Returns whether `signature` is valid for `hash` for an ERC1271 `signer` contract. function isValidERC1271SignatureNowCalldata( address signer, bytes32 hash, bytes calldata signature ) internal view returns (bool isValid) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) let f := shl(224, 0x1626ba7e) mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`. mstore(add(m, 0x04), hash) let d := add(m, 0x24) mstore(d, 0x40) // The offset of the `signature` in the calldata. mstore(add(m, 0x44), signature.length) // Copy the `signature` over. calldatacopy(add(m, 0x64), signature.offset, signature.length) // forgefmt: disable-next-item isValid := and( // Whether the returndata is the magic value `0x1626ba7e` (left-aligned). eq(mload(d), f), // Whether the staticcall does not revert. // This must be placed at the end of the `and` clause, // as the arguments are evaluated from right to left. staticcall( gas(), // Remaining gas. signer, // The `signer` address. m, // Offset of calldata in memory. add(signature.length, 0x64), // Length of calldata in memory. d, // Offset of returndata. 0x20 // Length of returndata to write. ) ) } } /// @dev Returns whether the signature (`r`, `vs`) is valid for `hash` /// for an ERC1271 `signer` contract. function isValidERC1271SignatureNow(address signer, bytes32 hash, bytes32 r, bytes32 vs) internal view returns (bool isValid) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) let f := shl(224, 0x1626ba7e) mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`. mstore(add(m, 0x04), hash) let d := add(m, 0x24) mstore(d, 0x40) // The offset of the `signature` in the calldata. mstore(add(m, 0x44), 65) // Length of the signature. mstore(add(m, 0x64), r) // `r`. mstore(add(m, 0x84), shr(1, shl(1, vs))) // `s`. mstore8(add(m, 0xa4), add(shr(255, vs), 27)) // `v`. // forgefmt: disable-next-item isValid := and( // Whether the returndata is the magic value `0x1626ba7e` (left-aligned). eq(mload(d), f), // Whether the staticcall does not revert. // This must be placed at the end of the `and` clause, // as the arguments are evaluated from right to left. staticcall( gas(), // Remaining gas. signer, // The `signer` address. m, // Offset of calldata in memory. 0xa5, // Length of calldata in memory. d, // Offset of returndata. 0x20 // Length of returndata to write. ) ) } } /// @dev Returns whether the signature (`v`, `r`, `s`) is valid for `hash` /// for an ERC1271 `signer` contract. function isValidERC1271SignatureNow(address signer, bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal view returns (bool isValid) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) let f := shl(224, 0x1626ba7e) mstore(m, f) // `bytes4(keccak256("isValidSignature(bytes32,bytes)"))`. mstore(add(m, 0x04), hash) let d := add(m, 0x24) mstore(d, 0x40) // The offset of the `signature` in the calldata. mstore(add(m, 0x44), 65) // Length of the signature. mstore(add(m, 0x64), r) // `r`. mstore(add(m, 0x84), s) // `s`. mstore8(add(m, 0xa4), v) // `v`. // forgefmt: disable-next-item isValid := and( // Whether the returndata is the magic value `0x1626ba7e` (left-aligned). eq(mload(d), f), // Whether the staticcall does not revert. // This must be placed at the end of the `and` clause, // as the arguments are evaluated from right to left. staticcall( gas(), // Remaining gas. signer, // The `signer` address. m, // Offset of calldata in memory. 0xa5, // Length of calldata in memory. d, // Offset of returndata. 0x20 // Length of returndata to write. ) ) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* HASHING OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns an Ethereum Signed Message, created from a `hash`. /// This produces a hash corresponding to the one signed with the /// [`eth_sign`](https://eth.wiki/json-rpc/API#eth_sign) /// JSON-RPC method as part of EIP-191. function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 result) { /// @solidity memory-safe-assembly assembly { mstore(0x20, hash) // Store into scratch space for keccak256. mstore(0x00, "\x00\x00\x00\x00\x19Ethereum Signed Message:\n32") // 28 bytes. result := keccak256(0x04, 0x3c) // `32 * 2 - (32 - 28) = 60 = 0x3c`. } } /// @dev Returns an Ethereum Signed Message, created from `s`. /// This produces a hash corresponding to the one signed with the /// [`eth_sign`](https://eth.wiki/json-rpc/API#eth_sign) /// JSON-RPC method as part of EIP-191. /// Note: Supports lengths of `s` up to 999999 bytes. function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32 result) { /// @solidity memory-safe-assembly assembly { let sLength := mload(s) let o := 0x20 mstore(o, "\x19Ethereum Signed Message:\n") // 26 bytes, zero-right-padded. mstore(0x00, 0x00) // Convert the `s.length` to ASCII decimal representation: `base10(s.length)`. for { let temp := sLength } 1 {} { o := sub(o, 1) mstore8(o, add(48, mod(temp, 10))) temp := div(temp, 10) if iszero(temp) { break } } let n := sub(0x3a, o) // Header length: `26 + 32 - o`. // Throw an out-of-offset error (consumes all gas) if the header exceeds 32 bytes. returndatacopy(returndatasize(), returndatasize(), gt(n, 0x20)) mstore(s, or(mload(0x00), mload(n))) // Temporarily store the header. result := keccak256(add(s, sub(0x20, n)), add(n, sLength)) mstore(s, sLength) // Restore the length. } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EMPTY CALLDATA HELPERS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns an empty calldata bytes. function emptySignature() internal pure returns (bytes calldata signature) { /// @solidity memory-safe-assembly assembly { signature.length := 0 } } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Contract for EIP-712 typed structured data hashing and signing. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/EIP712.sol) /// @author Modified from Solbase (https://github.com/Sol-DAO/solbase/blob/main/src/utils/EIP712.sol) /// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/EIP712.sol) /// /// @dev Note, this implementation: /// - Uses `address(this)` for the `verifyingContract` field. /// - Does NOT use the optional EIP-712 salt. /// - Does NOT use any EIP-712 extensions. /// This is for simplicity and to save gas. /// If you need to customize, please fork / modify accordingly. abstract contract EIP712 { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CONSTANTS AND IMMUTABLES */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev `keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")`. bytes32 internal constant _DOMAIN_TYPEHASH = 0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f; uint256 private immutable _cachedThis; uint256 private immutable _cachedChainId; bytes32 private immutable _cachedNameHash; bytes32 private immutable _cachedVersionHash; bytes32 private immutable _cachedDomainSeparator; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CONSTRUCTOR */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Cache the hashes for cheaper runtime gas costs. /// In the case of upgradeable contracts (i.e. proxies), /// or if the chain id changes due to a hard fork, /// the domain separator will be seamlessly calculated on-the-fly. constructor() { _cachedThis = uint256(uint160(address(this))); _cachedChainId = block.chainid; string memory name; string memory version; if (!_domainNameAndVersionMayChange()) (name, version) = _domainNameAndVersion(); bytes32 nameHash = _domainNameAndVersionMayChange() ? bytes32(0) : keccak256(bytes(name)); bytes32 versionHash = _domainNameAndVersionMayChange() ? bytes32(0) : keccak256(bytes(version)); _cachedNameHash = nameHash; _cachedVersionHash = versionHash; bytes32 separator; if (!_domainNameAndVersionMayChange()) { /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Load the free memory pointer. mstore(m, _DOMAIN_TYPEHASH) mstore(add(m, 0x20), nameHash) mstore(add(m, 0x40), versionHash) mstore(add(m, 0x60), chainid()) mstore(add(m, 0x80), address()) separator := keccak256(m, 0xa0) } } _cachedDomainSeparator = separator; } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* FUNCTIONS TO OVERRIDE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Please override this function to return the domain name and version. /// ``` /// function _domainNameAndVersion() /// internal /// pure /// virtual /// returns (string memory name, string memory version) /// { /// name = "Solady"; /// version = "1"; /// } /// ``` /// /// Note: If the returned result may change after the contract has been deployed, /// you must override `_domainNameAndVersionMayChange()` to return true. function _domainNameAndVersion() internal view virtual returns (string memory name, string memory version); /// @dev Returns if `_domainNameAndVersion()` may change /// after the contract has been deployed (i.e. after the constructor). /// Default: false. function _domainNameAndVersionMayChange() internal pure virtual returns (bool result) {} /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* HASHING OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the EIP-712 domain separator. function _domainSeparator() internal view virtual returns (bytes32 separator) { if (_domainNameAndVersionMayChange()) { separator = _buildDomainSeparator(); } else { separator = _cachedDomainSeparator; if (_cachedDomainSeparatorInvalidated()) separator = _buildDomainSeparator(); } } /// @dev Returns the hash of the fully encoded EIP-712 message for this domain, /// given `structHash`, as defined in /// https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct. /// /// The hash can be used together with {ECDSA-recover} to obtain the signer of a message: /// ``` /// bytes32 digest = _hashTypedData(keccak256(abi.encode( /// keccak256("Mail(address to,string contents)"), /// mailTo, /// keccak256(bytes(mailContents)) /// ))); /// address signer = ECDSA.recover(digest, signature); /// ``` function _hashTypedData(bytes32 structHash) internal view virtual returns (bytes32 digest) { // We will use `digest` to store the domain separator to save a bit of gas. if (_domainNameAndVersionMayChange()) { digest = _buildDomainSeparator(); } else { digest = _cachedDomainSeparator; if (_cachedDomainSeparatorInvalidated()) digest = _buildDomainSeparator(); } /// @solidity memory-safe-assembly assembly { // Compute the digest. mstore(0x00, 0x1901000000000000) // Store "\x19\x01". mstore(0x1a, digest) // Store the domain separator. mstore(0x3a, structHash) // Store the struct hash. digest := keccak256(0x18, 0x42) // Restore the part of the free memory slot that was overwritten. mstore(0x3a, 0) } } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EIP-5267 OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev See: https://eips.ethereum.org/EIPS/eip-5267 function eip712Domain() public view virtual returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ) { fields = hex"0f"; // `0b01111`. (name, version) = _domainNameAndVersion(); chainId = block.chainid; verifyingContract = address(this); salt = salt; // `bytes32(0)`. extensions = extensions; // `new uint256[](0)`. } /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* PRIVATE HELPERS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Returns the EIP-712 domain separator. function _buildDomainSeparator() private view returns (bytes32 separator) { // We will use `separator` to store the name hash to save a bit of gas. bytes32 versionHash; if (_domainNameAndVersionMayChange()) { (string memory name, string memory version) = _domainNameAndVersion(); separator = keccak256(bytes(name)); versionHash = keccak256(bytes(version)); } else { separator = _cachedNameHash; versionHash = _cachedVersionHash; } /// @solidity memory-safe-assembly assembly { let m := mload(0x40) // Load the free memory pointer. mstore(m, _DOMAIN_TYPEHASH) mstore(add(m, 0x20), separator) // Name hash. mstore(add(m, 0x40), versionHash) mstore(add(m, 0x60), chainid()) mstore(add(m, 0x80), address()) separator := keccak256(m, 0xa0) } } /// @dev Returns if the cached domain separator has been invalidated. function _cachedDomainSeparatorInvalidated() private view returns (bool result) { uint256 cachedChainId = _cachedChainId; uint256 cachedThis = _cachedThis; /// @solidity memory-safe-assembly assembly { result := iszero(and(eq(chainid(), cachedChainId), eq(address(), cachedThis))) } } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.24; import {Initializable} from "@solady/utils/Initializable.sol"; import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; /// @title ACloneable /// @notice A contract that can be cloned and initialized only once abstract contract ACloneable is Initializable, ERC165 { /// @notice Thrown when an inheriting contract does not implement the initializer function error InitializerNotImplemented(); /// @notice Thrown when the provided initialization data is invalid /// @dev This error indicates that the given data is not valid for the implementation (i.e. does not decode to the expected types) error InvalidInitializationData(); /// @notice Thrown when the contract has already been initialized error CloneAlreadyInitialized(); /// @notice Initialize the clone with the given arbitrary data /// @param - The compressed initialization data (if required) /// @dev The data is expected to be ABI encoded bytes compressed using {LibZip-cdCompress} /// @dev All implementations must override this function to initialize the contract function initialize(bytes calldata) public virtual initializer { revert InitializerNotImplemented(); } /// @notice /// @param - Return a cloneable's unique identifier for downstream consumers to differentiate various targets /// @dev All implementations must override this function function getComponentInterface() public pure virtual returns (bytes4); /// @inheritdoc ERC165 /// @notice Check if the contract supports the given interface /// @param interfaceId The interface identifier /// @return True if the contract supports the interface function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(ACloneable).interfaceId || super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.24; /// @title BoostError /// @notice Standardized errors for the Boost protocol /// @dev Some of these errors are introduced by third-party libraries, rather than Boost contracts directly, and are copied here for clarity and ease of testing. library BoostError { /// @notice Thrown when a claim attempt fails error ClaimFailed(address caller, bytes data); /// @notice Thrown when there are insufficient funds for an operation error InsufficientFunds(address asset, uint256 available, uint256 required); /// @notice Thrown when a non-conforming instance for a given type is encountered error InvalidInstance(bytes4 expectedInterface, address instance); /// @notice Thrown when an invalid initialization is attempted error InvalidInitialization(); /// @notice Thrown when the length of two arrays are not equal error LengthMismatch(); /// @notice Thrown when a method is not implemented error NotImplemented(); /// @notice Thrown when a previously used signature is replayed error Replayed(address signer, bytes32 hash, bytes signature); /// @notice Thrown when a transfer fails for an unknown reason error TransferFailed(address asset, address to, uint256 amount); /// @notice Thrown when the requested action is unauthorized error Unauthorized(); /// @notice Thrown when an incentive id exceeds the available incentives error InvalidIncentive(uint8 available, uint256 id); /// @notice thrown when an incentiveId is larger than 7 error IncentiveToBig(uint8 incentiveId); /// @notice thrown when an incentiveId is already claimed against error IncentiveClaimed(uint8 incentiveId); /// @notice thrown when a clawback attempt result in a zero amount error ClawbackFailed(address caller, bytes data); /// @notice thrown when an address has claimed the maximum possible quantity error MaximumClaimed(address claimant); /// @notice thrown when an impossible math percentage is calculated error InvalidPercentage(uint256 percent); /// @notice thrown when a payout fails due to a zero-balance payout error ZeroBalancePayout(); }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.24; import {BoostError} from "contracts/shared/BoostError.sol"; library IncentiveBits { /// @dev The set of used claimed incentives for a given hash (for replay protection) struct IncentiveMap { mapping(bytes32 => uint8) map; } /// @notice an internal helper that manages the incentive bitmask /// @dev this supports a maximum of 8 incentives for a given boost /// @param bitmap the bitmap struct to operate on /// @param hash the claim hash used to key on the incentive bitmap /// @param incentive the incentive id to set in the bitmap function setOrThrow(IncentiveMap storage bitmap, bytes32 hash, uint256 incentive) internal { bytes4 invalidSelector = BoostError.IncentiveToBig.selector; bytes4 claimedSelector = BoostError.IncentiveClaimed.selector; /// @solidity memory-safe-assembly assembly { if gt(incentive, 7) { // if the incentive is larger the 7 (the highest bit index) // we revert mstore(0, invalidSelector) mstore(4, incentive) revert(0x00, 0x24) } mstore(0x20, bitmap.slot) mstore(0x00, hash) let storageSlot := keccak256(0x00, 0x40) // toggle the value that was stored inline on stack with xor let updatedStorageValue := xor(sload(storageSlot), shl(incentive, 1)) // isolate the toggled bit and see if it's been unset back to zero let alreadySet := xor(1, and(1, shr(incentive, updatedStorageValue))) if alreadySet { // revert if the stored value was unset mstore(0, claimedSelector) mstore(4, incentive) revert(0x00, 0x24) } // otherwise store the newly set value sstore(storageSlot, updatedStorageValue) } } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.24; import {ACloneable} from "contracts/shared/ACloneable.sol"; /// @title Boost Validator /// @notice Abstract contract for a generic Validator within the Boost protocol /// @dev Validator classes are expected to decode the calldata for implementation-specific handling. If no data is required, calldata should be empty. abstract contract AValidator is ACloneable { /// @notice Validate that a given user has completed an acction successfully /// @param boostId The Id from the available boosts /// @param incentiveId The Id from the available boost incentives to be claimed /// @param claimant The address of the user claiming the incentive /// @param data The encoded payload to be validated /// @return True if the action has been validated based on the data payload /// @dev The decompressed payload contains freeform bytes that are entirely implementation-specific function validate(uint256 boostId, uint256 incentiveId, address claimant, bytes calldata data) external virtual returns (bool); /// @inheritdoc ACloneable function supportsInterface(bytes4 interfaceId) public view virtual override(ACloneable) returns (bool) { return interfaceId == type(AValidator).interfaceId || super.supportsInterface(interfaceId); } /// @inheritdoc ACloneable function getComponentInterface() public pure virtual override(ACloneable) returns (bytes4) { return type(AValidator).interfaceId; } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.24; import {SignatureCheckerLib} from "@solady/utils/SignatureCheckerLib.sol"; import {BoostError} from "contracts/shared/BoostError.sol"; import {ACloneable} from "contracts/shared/ACloneable.sol"; import {IBoostClaim} from "contracts/shared/IBoostClaim.sol"; import {AValidator} from "contracts/validators/AValidator.sol"; /// @title Signer Validator /// @notice A simple implementation of a Validator that verifies a given signature and checks the recovered address against a set of authorized signers abstract contract ASignerValidator is IBoostClaim, AValidator { struct SignerValidatorInputParams { address signer; bytes signature; uint8 incentiveQuantity; } struct SignerValidatorData { uint8 incentiveQuantity; address claimant; uint256 boostId; bytes incentiveData; } /// @dev The set of authorized signers mapping(address => bool) public signers; /// @notice Set the authorized status of a signer /// @param signers_ The list of signers to update /// @param authorized_ The authorized status of each signer function setAuthorized(address[] calldata signers_, bool[] calldata authorized_) external virtual; /// @notice update the authorized caller of the validator function /// @param newCaller the new authorized caller of the validator function function setValidatorCaller(address newCaller) external virtual; /// @inheritdoc ACloneable function getComponentInterface() public pure virtual override returns (bytes4) { return type(ASignerValidator).interfaceId; } /// @inheritdoc ACloneable function supportsInterface(bytes4 interfaceId) public view virtual override(AValidator) returns (bool) { return interfaceId == type(ASignerValidator).interfaceId || super.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; /// @notice Initializable mixin for the upgradeable contracts. /// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/Initializable.sol) /// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/proxy/utils/Initializable.sol) abstract contract Initializable { /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* CUSTOM ERRORS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The contract is already initialized. error InvalidInitialization(); /// @dev The contract is not initializing. error NotInitializing(); /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* EVENTS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Triggered when the contract has been initialized. event Initialized(uint64 version); /// @dev `keccak256(bytes("Initialized(uint64)"))`. bytes32 private constant _INTIALIZED_EVENT_SIGNATURE = 0xc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* STORAGE */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev The default initializable slot is given by: /// `bytes32(~uint256(uint32(bytes4(keccak256("_INITIALIZABLE_SLOT")))))`. /// /// Bits Layout: /// - [0] `initializing` /// - [1..64] `initializedVersion` bytes32 private constant _INITIALIZABLE_SLOT = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffbf601132; /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/ /* OPERATIONS */ /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/ /// @dev Override to return a custom storage slot if required. function _initializableSlot() internal pure virtual returns (bytes32) { return _INITIALIZABLE_SLOT; } /// @dev Guards an initializer function so that it can be invoked at most once. /// /// You can guard a function with `onlyInitializing` such that it can be called /// through a function guarded with `initializer`. /// /// This is similar to `reinitializer(1)`, except that in the context of a constructor, /// an `initializer` guarded function can be invoked multiple times. /// This can be useful during testing and is not expected to be used in production. /// /// Emits an {Initialized} event. modifier initializer() virtual { bytes32 s = _initializableSlot(); /// @solidity memory-safe-assembly assembly { let i := sload(s) // Set `initializing` to 1, `initializedVersion` to 1. sstore(s, 3) // If `!(initializing == 0 && initializedVersion == 0)`. if i { // If `!(address(this).code.length == 0 && initializedVersion == 1)`. if iszero(lt(extcodesize(address()), eq(shr(1, i), 1))) { mstore(0x00, 0xf92ee8a9) // `InvalidInitialization()`. revert(0x1c, 0x04) } s := shl(shl(255, i), s) // Skip initializing if `initializing == 1`. } } _; /// @solidity memory-safe-assembly assembly { if s { // Set `initializing` to 0, `initializedVersion` to 1. sstore(s, 2) // Emit the {Initialized} event. mstore(0x20, 1) log1(0x20, 0x20, _INTIALIZED_EVENT_SIGNATURE) } } } /// @dev Guards an reinitialzer function so that it can be invoked at most once. /// /// You can guard a function with `onlyInitializing` such that it can be called /// through a function guarded with `reinitializer`. /// /// Emits an {Initialized} event. modifier reinitializer(uint64 version) virtual { bytes32 s = _initializableSlot(); /// @solidity memory-safe-assembly assembly { version := and(version, 0xffffffffffffffff) // Clean upper bits. let i := sload(s) // If `initializing == 1 || initializedVersion >= version`. if iszero(lt(and(i, 1), lt(shr(1, i), version))) { mstore(0x00, 0xf92ee8a9) // `InvalidInitialization()`. revert(0x1c, 0x04) } // Set `initializing` to 1, `initializedVersion` to `version`. sstore(s, or(1, shl(1, version))) } _; /// @solidity memory-safe-assembly assembly { // Set `initializing` to 0, `initializedVersion` to `version`. sstore(s, shl(1, version)) // Emit the {Initialized} event. mstore(0x20, version) log1(0x20, 0x20, _INTIALIZED_EVENT_SIGNATURE) } } /// @dev Guards a function such that it can only be called in the scope /// of a function guarded with `initializer` or `reinitializer`. modifier onlyInitializing() virtual { _checkInitializing(); _; } /// @dev Reverts if the contract is not initializing. function _checkInitializing() internal view virtual { bytes32 s = _initializableSlot(); /// @solidity memory-safe-assembly assembly { if iszero(and(1, sload(s))) { mstore(0x00, 0xd7e6bcf8) // `NotInitializing()`. revert(0x1c, 0x04) } } } /// @dev Locks any future initializations by setting the initialized version to `2**64 - 1`. /// /// Calling this in the constructor will prevent the contract from being initialized /// or reinitialized. It is recommended to use this to lock implementation contracts /// that are designed to be called through proxies. /// /// Emits an {Initialized} event the first time it is successfully called. function _disableInitializers() internal virtual { bytes32 s = _initializableSlot(); /// @solidity memory-safe-assembly assembly { let i := sload(s) if and(i, 1) { mstore(0x00, 0xf92ee8a9) // `InvalidInitialization()`. revert(0x1c, 0x04) } let uint64max := shr(192, s) // Computed to save bytecode. if iszero(eq(shr(1, i), uint64max)) { // Set `initializing` to 0, `initializedVersion` to `2**64 - 1`. sstore(s, shl(1, uint64max)) // Emit the {Initialized} event. mstore(0x20, uint64max) log1(0x20, 0x20, _INTIALIZED_EVENT_SIGNATURE) } } } /// @dev Returns the highest version that has been initialized. function _getInitializedVersion() internal view virtual returns (uint64 version) { bytes32 s = _initializableSlot(); /// @solidity memory-safe-assembly assembly { version := shr(1, sload(s)) } } /// @dev Returns whether the contract is currently initializing. function _isInitializing() internal view virtual returns (bool result) { bytes32 s = _initializableSlot(); /// @solidity memory-safe-assembly assembly { result := and(1, sload(s)) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/ERC165.sol) pragma solidity ^0.8.20; import {IERC165} from "./IERC165.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` */ abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.24; interface IBoostClaim { /// @notice A higher order struct for encoding and decoding arbitrary claims struct BoostClaimData { bytes validatorData; bytes incentiveData; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC-165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[ERC]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
{ "remappings": [ "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/", "@openzeppelin-upgrades/contracts/=lib/openzeppelin-contracts-upgradeable/contracts/", "ds-test/=lib/forge-std/lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "@solady/=lib/solady/src/", "@eigenlayer/contracts/=lib/eigenlayer-contracts/src/contracts/", "@eigenlayer-middleware/=lib/eigenlayer-middleware/src/", "eigenlayer-contracts/=lib/eigenlayer-middleware/lib/eigenlayer-contracts/", "@eth-infinitism/account-abstraction/=lib/account-abstraction/contracts/", "@boost/contracts/=contracts/", "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/", "account-abstraction/=lib/account-abstraction/contracts/", "eigenlayer-middleware/=lib/eigenlayer-middleware/src/", "hardhat/=node_modules/hardhat/", "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/", "openzeppelin-contracts/=lib/openzeppelin-contracts/", "solady/=lib/solady/src/" ], "optimizer": { "enabled": true, "runs": 10000 }, "metadata": { "useLiteralContent": false, "bytecodeHash": "ipfs", "appendCBOR": true }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "cancun", "viaIR": false, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AlreadyInitialized","type":"error"},{"inputs":[],"name":"CloneAlreadyInitialized","type":"error"},{"inputs":[],"name":"InitializerNotImplemented","type":"error"},{"inputs":[{"internalType":"uint8","name":"available","type":"uint8"},{"internalType":"uint256","name":"id","type":"uint256"}],"name":"InvalidIncentive","type":"error"},{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"InvalidInitializationData","type":"error"},{"inputs":[],"name":"LengthMismatch","type":"error"},{"inputs":[],"name":"NewOwnerIsZeroAddress","type":"error"},{"inputs":[],"name":"NoHandoverRequest","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pendingOwner","type":"address"}],"name":"OwnershipHandoverRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"cancelOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"completeOwnershipHandover","outputs":[],"stateMutability":"payable","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":"getComponentInterface","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"boostId","type":"uint256"},{"internalType":"uint8","name":"incentiveQuantity","type":"uint8"},{"internalType":"address","name":"claimant","type":"address"},{"internalType":"bytes","name":"incentiveData","type":"bytes"}],"name":"hashSignerData","outputs":[{"internalType":"bytes32","name":"hashedSignerData","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"data_","type":"bytes"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"result","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"pendingOwner","type":"address"}],"name":"ownershipHandoverExpiresAt","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"requestOwnershipHandover","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"signers_","type":"address[]"},{"internalType":"bool[]","name":"authorized_","type":"bool[]"}],"name":"setAuthorized","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newCaller","type":"address"}],"name":"setValidatorCaller","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"signers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"boostId","type":"uint256"},{"internalType":"uint256","name":"incentiveId","type":"uint256"},{"internalType":"address","name":"claimant","type":"address"},{"internalType":"bytes","name":"claimData","type":"bytes"}],"name":"validate","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]
Contract Creation Code
610120604052348015610010575f80fd5b50306080524660a0525f60c081905260e081905261010052610030610035565b610096565b63409feecd19805460018116156100535763f92ee8a95f526004601cfd5b8160c01c808260011c14610091578060011b8355806020527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602080a15b505050565b60805160a05160c05160e051610100516116406100c45f395f50505f50505f50505f50505f50506116405ff3fe6080604052600436106100ef575f3560e01c8063736c0d5b11610087578063d3de6e7511610057578063d3de6e751461029f578063f04e283e146102cc578063f2fde38b146102df578063fee81cf4146102f2575f80fd5b8063736c0d5b146101d857806384b0196e146102065780638da5cb5b1461022d578063a1d2756f14610280575f80fd5b8063439fab91116100c2578063439fab911461018a57806354d1f13d146101a9578063703b6900146101b1578063715018a6146101d0575f80fd5b806301ffc9a7146100f3578063256929621461012757806328d6183b146101315780634359d28a1461016b575b5f80fd5b3480156100fe575f80fd5b5061011261010d366004610e8e565b610323565b60405190151581526020015b60405180910390f35b61012f61037e565b005b34801561013c575f80fd5b506040517fb8ce7b2200000000000000000000000000000000000000000000000000000000815260200161011e565b348015610176575f80fd5b5061012f610185366004610f15565b6103cb565b348015610195575f80fd5b5061012f6101a4366004610fbf565b6104c7565b61012f61064f565b3480156101bc575f80fd5b506101126101cb36600461101f565b610688565b61012f610814565b3480156101e3575f80fd5b506101126101f2366004611084565b5f6020819052908152604090205460ff1681565b348015610211575f80fd5b5061021a610827565b60405161011e97969594939291906110eb565b348015610238575f80fd5b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275460405173ffffffffffffffffffffffffffffffffffffffff909116815260200161011e565b34801561028b575f80fd5b5061012f61029a366004611084565b6108cf565b3480156102aa575f80fd5b506102be6102b93660046112f4565b61091e565b60405190815260200161011e565b61012f6102da366004611084565b6109b1565b61012f6102ed366004611084565b6109ee565b3480156102fd575f80fd5b506102be61030c366004611084565b63389a75e1600c9081525f91909152602090205490565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167fb8ce7b22000000000000000000000000000000000000000000000000000000001480610378575061037882610a14565b92915050565b5f6202a30067ffffffffffffffff164201905063389a75e1600c52335f52806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f80a250565b6103d3610a69565b82811461040c576040517fff633a3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5b838110156104c0578282828181106104285761042861135c565b905060200201602081019061043d9190611389565b5f808787858181106104515761045161135c565b90506020020160208101906104669190611084565b73ffffffffffffffffffffffffffffffffffffffff16815260208101919091526040015f2080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001691151591909117905560010161040e565b5050505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffbf60113280546003825580156105185760018160011c14303b1061050f5763f92ee8a95f526004601cfd5b818160ff1b1b91505b505f80610527848601866113b8565b9150915061054d825f815181106105405761054061135c565b6020026020010151610a9e565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790555f5b82518110156106125760015f808584815181106105ae576105ae61135c565b60209081029190910181015173ffffffffffffffffffffffffffffffffffffffff1682528101919091526040015f2080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001691151591909117905560010161058f565b505050801561064a576002815560016020527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602080a15b505050565b63389a75e1600c52335f525f6020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c925f80a2565b6002545f9073ffffffffffffffffffffffffffffffffffffffff1633146106db576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6106e88385018561147f565b90505f815f0151806020019051810190610702919061153f565b90505f61071989836040015189866020015161091e565b905087826040015160ff16116107715760408083015190517f17c66bc700000000000000000000000000000000000000000000000000000000815260ff90911660048201526024810189905260440160405180910390fd5b815173ffffffffffffffffffffffffffffffffffffffff165f9081526020819052604090205460ff166107d0576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6107dc6001828a610b01565b602082015182516108079173ffffffffffffffffffffffffffffffffffffffff909116908390610b8f565b9998505050505050505050565b61081c610a69565b6108255f610c9a565b565b7f0f000000000000000000000000000000000000000000000000000000000000006060805f8080836108bd604080518082018252600f81527f5369676e657256616c696461746f7200000000000000000000000000000000006020808301919091528251808401909352600183527f31000000000000000000000000000000000000000000000000000000000000009083015291565b97989097965046955030945091925090565b6108d7610a69565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b8051602080830191909120604080517ffea51d5bd45bcd3c2ecc3679b43a3b80b0bd0923f8c16f822455b8cdecd9852f93810193909352820186905260ff8516606083015273ffffffffffffffffffffffffffffffffffffffff8416608083015260a08201525f906109a89060c00160405160208183030381529060405280519060200120610cff565b95945050505050565b6109b9610a69565b63389a75e1600c52805f526020600c2080544211156109df57636f5e88185f526004601cfd5b5f90556109eb81610c9a565b50565b6109f6610a69565b8060601b610a0b57637448fbae5f526004601cfd5b6109eb81610c9a565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f5912b89c000000000000000000000000000000000000000000000000000000001480610378575061037882610d2b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927543314610825576382b429005f526004601cfd5b73ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927819055805f7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b7f3f57fc5c000000000000000000000000000000000000000000000000000000007f4de1225a000000000000000000000000000000000000000000000000000000006007831115610b5857815f528260045260245ffd5b84602052835f5260405f206001841b81541880851c6001166001188015610b8557835f528560045260245ffd5b5090555050505050565b73ffffffffffffffffffffffffffffffffffffffff909216915f8315610c9357604051835f5260208301516040526040835103610c08576040830151601b8160ff1c016020528060011b60011c606052506020600160805f60015afa805186183d1517610c0657505f606052604052506001610c93565b505b6041835103610c4b5760608301515f1a60205260408301516060526020600160805f60015afa805186183d1517610c4957505f606052604052506001610c93565b505b5f60605280604052631626ba7e60e01b808252846004830152602482016040815284516020018060448501828860045afa505060208160443d01858a5afa9051909114169150505b9392505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927805473ffffffffffffffffffffffffffffffffffffffff9092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a355565b5f610d08610dc1565b6719010000000000005f908152601a91909152603a928352604260182092525090565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f6ab67a0d00000000000000000000000000000000000000000000000000000000148061037857507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610378565b5f805f80610e33604080518082018252600f81527f5369676e657256616c696461746f7200000000000000000000000000000000006020808301919091528251808401909352600183527f31000000000000000000000000000000000000000000000000000000000000009083015291565b8151602092830120815191830191909120604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8152938401929092529082015246606082015230608082015260a09020949350505050565b5f60208284031215610e9e575f80fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610c93575f80fd5b5f8083601f840112610edd575f80fd5b50813567ffffffffffffffff811115610ef4575f80fd5b6020830191508360208260051b8501011115610f0e575f80fd5b9250929050565b5f805f8060408587031215610f28575f80fd5b843567ffffffffffffffff811115610f3e575f80fd5b610f4a87828801610ecd565b909550935050602085013567ffffffffffffffff811115610f69575f80fd5b610f7587828801610ecd565b95989497509550505050565b5f8083601f840112610f91575f80fd5b50813567ffffffffffffffff811115610fa8575f80fd5b602083019150836020828501011115610f0e575f80fd5b5f8060208385031215610fd0575f80fd5b823567ffffffffffffffff811115610fe6575f80fd5b610ff285828601610f81565b90969095509350505050565b73ffffffffffffffffffffffffffffffffffffffff811681146109eb575f80fd5b5f805f805f60808688031215611033575f80fd5b8535945060208601359350604086013561104c81610ffe565b9250606086013567ffffffffffffffff811115611067575f80fd5b61107388828901610f81565b969995985093965092949392505050565b5f60208284031215611094575f80fd5b8135610c9381610ffe565b5f81518084528060208401602086015e5f6020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b7fff000000000000000000000000000000000000000000000000000000000000008816815260e060208201525f61112560e083018961109f565b8281036040840152611137818961109f565b6060840188905273ffffffffffffffffffffffffffffffffffffffff8716608085015260a0840186905283810360c0850152845180825260208087019350909101905f5b8181101561119957835183526020938401939092019160010161117b565b50909b9a5050505050505050505050565b60ff811681146109eb575f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6040516060810167ffffffffffffffff81118282101715611208576112086111b8565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611255576112556111b8565b604052919050565b5f67ffffffffffffffff821115611276576112766111b8565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b5f82601f8301126112b1575f80fd5b81356112c46112bf8261125d565b61120e565b8181528460208386010111156112d8575f80fd5b816020850160208301375f918101602001919091529392505050565b5f805f8060808587031215611307575f80fd5b843593506020850135611319816111aa565b9250604085013561132981610ffe565b9150606085013567ffffffffffffffff811115611344575f80fd5b611350878288016112a2565b91505092959194509250565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f60208284031215611399575f80fd5b81358015158114610c93575f80fd5b80356113b381610ffe565b919050565b5f80604083850312156113c9575f80fd5b823567ffffffffffffffff8111156113df575f80fd5b8301601f810185136113ef575f80fd5b803567ffffffffffffffff811115611409576114096111b8565b8060051b6114196020820161120e565b91825260208184018101929081019088841115611434575f80fd5b6020850194505b83851015611462578435925061145083610ffe565b8282526020948501949091019061143b565b8096505050505050611476602084016113a8565b90509250929050565b5f6020828403121561148f575f80fd5b813567ffffffffffffffff8111156114a5575f80fd5b8201604081850312156114b6575f80fd5b6040805190810167ffffffffffffffff811182821017156114d9576114d96111b8565b604052813567ffffffffffffffff8111156114f2575f80fd5b6114fe868285016112a2565b825250602082013567ffffffffffffffff81111561151a575f80fd5b611526868285016112a2565b602083015250949350505050565b80516113b3816111aa565b5f6020828403121561154f575f80fd5b815167ffffffffffffffff811115611565575f80fd5b820160608185031215611576575f80fd5b61157e6111e5565b815161158981610ffe565b8152602082015167ffffffffffffffff8111156115a4575f80fd5b8201601f810186136115b4575f80fd5b80516115c26112bf8261125d565b8181528760208385010111156115d6575f80fd5b8160208401602083015e5f602083830101528060208501525050506115fd60408301611534565b604082015294935050505056fea26469706673582212203abfc51ad1a96d31837d40ddf9f15690842175b1f4442e2faf9193fead7b99f464736f6c634300081a0033
Deployed Bytecode
0x6080604052600436106100ef575f3560e01c8063736c0d5b11610087578063d3de6e7511610057578063d3de6e751461029f578063f04e283e146102cc578063f2fde38b146102df578063fee81cf4146102f2575f80fd5b8063736c0d5b146101d857806384b0196e146102065780638da5cb5b1461022d578063a1d2756f14610280575f80fd5b8063439fab91116100c2578063439fab911461018a57806354d1f13d146101a9578063703b6900146101b1578063715018a6146101d0575f80fd5b806301ffc9a7146100f3578063256929621461012757806328d6183b146101315780634359d28a1461016b575b5f80fd5b3480156100fe575f80fd5b5061011261010d366004610e8e565b610323565b60405190151581526020015b60405180910390f35b61012f61037e565b005b34801561013c575f80fd5b506040517fb8ce7b2200000000000000000000000000000000000000000000000000000000815260200161011e565b348015610176575f80fd5b5061012f610185366004610f15565b6103cb565b348015610195575f80fd5b5061012f6101a4366004610fbf565b6104c7565b61012f61064f565b3480156101bc575f80fd5b506101126101cb36600461101f565b610688565b61012f610814565b3480156101e3575f80fd5b506101126101f2366004611084565b5f6020819052908152604090205460ff1681565b348015610211575f80fd5b5061021a610827565b60405161011e97969594939291906110eb565b348015610238575f80fd5b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffff748739275460405173ffffffffffffffffffffffffffffffffffffffff909116815260200161011e565b34801561028b575f80fd5b5061012f61029a366004611084565b6108cf565b3480156102aa575f80fd5b506102be6102b93660046112f4565b61091e565b60405190815260200161011e565b61012f6102da366004611084565b6109b1565b61012f6102ed366004611084565b6109ee565b3480156102fd575f80fd5b506102be61030c366004611084565b63389a75e1600c9081525f91909152602090205490565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167fb8ce7b22000000000000000000000000000000000000000000000000000000001480610378575061037882610a14565b92915050565b5f6202a30067ffffffffffffffff164201905063389a75e1600c52335f52806020600c2055337fdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d5f80a250565b6103d3610a69565b82811461040c576040517fff633a3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5b838110156104c0578282828181106104285761042861135c565b905060200201602081019061043d9190611389565b5f808787858181106104515761045161135c565b90506020020160208101906104669190611084565b73ffffffffffffffffffffffffffffffffffffffff16815260208101919091526040015f2080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001691151591909117905560010161040e565b5050505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffbf60113280546003825580156105185760018160011c14303b1061050f5763f92ee8a95f526004601cfd5b818160ff1b1b91505b505f80610527848601866113b8565b9150915061054d825f815181106105405761054061135c565b6020026020010151610a9e565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83161790555f5b82518110156106125760015f808584815181106105ae576105ae61135c565b60209081029190910181015173ffffffffffffffffffffffffffffffffffffffff1682528101919091526040015f2080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001691151591909117905560010161058f565b505050801561064a576002815560016020527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2602080a15b505050565b63389a75e1600c52335f525f6020600c2055337ffa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c925f80a2565b6002545f9073ffffffffffffffffffffffffffffffffffffffff1633146106db576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6106e88385018561147f565b90505f815f0151806020019051810190610702919061153f565b90505f61071989836040015189866020015161091e565b905087826040015160ff16116107715760408083015190517f17c66bc700000000000000000000000000000000000000000000000000000000815260ff90911660048201526024810189905260440160405180910390fd5b815173ffffffffffffffffffffffffffffffffffffffff165f9081526020819052604090205460ff166107d0576040517f82b4290000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6107dc6001828a610b01565b602082015182516108079173ffffffffffffffffffffffffffffffffffffffff909116908390610b8f565b9998505050505050505050565b61081c610a69565b6108255f610c9a565b565b7f0f000000000000000000000000000000000000000000000000000000000000006060805f8080836108bd604080518082018252600f81527f5369676e657256616c696461746f7200000000000000000000000000000000006020808301919091528251808401909352600183527f31000000000000000000000000000000000000000000000000000000000000009083015291565b97989097965046955030945091925090565b6108d7610a69565b600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff92909216919091179055565b8051602080830191909120604080517ffea51d5bd45bcd3c2ecc3679b43a3b80b0bd0923f8c16f822455b8cdecd9852f93810193909352820186905260ff8516606083015273ffffffffffffffffffffffffffffffffffffffff8416608083015260a08201525f906109a89060c00160405160208183030381529060405280519060200120610cff565b95945050505050565b6109b9610a69565b63389a75e1600c52805f526020600c2080544211156109df57636f5e88185f526004601cfd5b5f90556109eb81610c9a565b50565b6109f6610a69565b8060601b610a0b57637448fbae5f526004601cfd5b6109eb81610c9a565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f5912b89c000000000000000000000000000000000000000000000000000000001480610378575061037882610d2b565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927543314610825576382b429005f526004601cfd5b73ffffffffffffffffffffffffffffffffffffffff167fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927819055805f7f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08180a350565b7f3f57fc5c000000000000000000000000000000000000000000000000000000007f4de1225a000000000000000000000000000000000000000000000000000000006007831115610b5857815f528260045260245ffd5b84602052835f5260405f206001841b81541880851c6001166001188015610b8557835f528560045260245ffd5b5090555050505050565b73ffffffffffffffffffffffffffffffffffffffff909216915f8315610c9357604051835f5260208301516040526040835103610c08576040830151601b8160ff1c016020528060011b60011c606052506020600160805f60015afa805186183d1517610c0657505f606052604052506001610c93565b505b6041835103610c4b5760608301515f1a60205260408301516060526020600160805f60015afa805186183d1517610c4957505f606052604052506001610c93565b505b5f60605280604052631626ba7e60e01b808252846004830152602482016040815284516020018060448501828860045afa505060208160443d01858a5afa9051909114169150505b9392505050565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffff74873927805473ffffffffffffffffffffffffffffffffffffffff9092169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a355565b5f610d08610dc1565b6719010000000000005f908152601a91909152603a928352604260182092525090565b5f7fffffffff0000000000000000000000000000000000000000000000000000000082167f6ab67a0d00000000000000000000000000000000000000000000000000000000148061037857507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610378565b5f805f80610e33604080518082018252600f81527f5369676e657256616c696461746f7200000000000000000000000000000000006020808301919091528251808401909352600183527f31000000000000000000000000000000000000000000000000000000000000009083015291565b8151602092830120815191830191909120604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f8152938401929092529082015246606082015230608082015260a09020949350505050565b5f60208284031215610e9e575f80fd5b81357fffffffff0000000000000000000000000000000000000000000000000000000081168114610c93575f80fd5b5f8083601f840112610edd575f80fd5b50813567ffffffffffffffff811115610ef4575f80fd5b6020830191508360208260051b8501011115610f0e575f80fd5b9250929050565b5f805f8060408587031215610f28575f80fd5b843567ffffffffffffffff811115610f3e575f80fd5b610f4a87828801610ecd565b909550935050602085013567ffffffffffffffff811115610f69575f80fd5b610f7587828801610ecd565b95989497509550505050565b5f8083601f840112610f91575f80fd5b50813567ffffffffffffffff811115610fa8575f80fd5b602083019150836020828501011115610f0e575f80fd5b5f8060208385031215610fd0575f80fd5b823567ffffffffffffffff811115610fe6575f80fd5b610ff285828601610f81565b90969095509350505050565b73ffffffffffffffffffffffffffffffffffffffff811681146109eb575f80fd5b5f805f805f60808688031215611033575f80fd5b8535945060208601359350604086013561104c81610ffe565b9250606086013567ffffffffffffffff811115611067575f80fd5b61107388828901610f81565b969995985093965092949392505050565b5f60208284031215611094575f80fd5b8135610c9381610ffe565b5f81518084528060208401602086015e5f6020828601015260207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011685010191505092915050565b7fff000000000000000000000000000000000000000000000000000000000000008816815260e060208201525f61112560e083018961109f565b8281036040840152611137818961109f565b6060840188905273ffffffffffffffffffffffffffffffffffffffff8716608085015260a0840186905283810360c0850152845180825260208087019350909101905f5b8181101561119957835183526020938401939092019160010161117b565b50909b9a5050505050505050505050565b60ff811681146109eb575f80fd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6040516060810167ffffffffffffffff81118282101715611208576112086111b8565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff81118282101715611255576112556111b8565b604052919050565b5f67ffffffffffffffff821115611276576112766111b8565b50601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b5f82601f8301126112b1575f80fd5b81356112c46112bf8261125d565b61120e565b8181528460208386010111156112d8575f80fd5b816020850160208301375f918101602001919091529392505050565b5f805f8060808587031215611307575f80fd5b843593506020850135611319816111aa565b9250604085013561132981610ffe565b9150606085013567ffffffffffffffff811115611344575f80fd5b611350878288016112a2565b91505092959194509250565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f60208284031215611399575f80fd5b81358015158114610c93575f80fd5b80356113b381610ffe565b919050565b5f80604083850312156113c9575f80fd5b823567ffffffffffffffff8111156113df575f80fd5b8301601f810185136113ef575f80fd5b803567ffffffffffffffff811115611409576114096111b8565b8060051b6114196020820161120e565b91825260208184018101929081019088841115611434575f80fd5b6020850194505b83851015611462578435925061145083610ffe565b8282526020948501949091019061143b565b8096505050505050611476602084016113a8565b90509250929050565b5f6020828403121561148f575f80fd5b813567ffffffffffffffff8111156114a5575f80fd5b8201604081850312156114b6575f80fd5b6040805190810167ffffffffffffffff811182821017156114d9576114d96111b8565b604052813567ffffffffffffffff8111156114f2575f80fd5b6114fe868285016112a2565b825250602082013567ffffffffffffffff81111561151a575f80fd5b611526868285016112a2565b602083015250949350505050565b80516113b3816111aa565b5f6020828403121561154f575f80fd5b815167ffffffffffffffff811115611565575f80fd5b820160608185031215611576575f80fd5b61157e6111e5565b815161158981610ffe565b8152602082015167ffffffffffffffff8111156115a4575f80fd5b8201601f810186136115b4575f80fd5b80516115c26112bf8261125d565b8181528760208385010111156115d6575f80fd5b8160208401602083015e5f602083830101528060208501525050506115fd60408301611534565b604082015294935050505056fea26469706673582212203abfc51ad1a96d31837d40ddf9f15690842175b1f4442e2faf9193fead7b99f464736f6c634300081a0033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.