Feature Tip: Add private address tag to any address under My Name Tag !
More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 162,094 transactions
(More than 25 Pending Txns)
View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Loading...
Loading
Contract Source Code Verified (Exact Match)
Contract Name:
DelegatedClaimCampaigns
Compiler Version
v0.8.24+commit.e11b9ed9
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.24; import './libraries/TransferHelper.sol'; import './interfaces/IVestingPlans.sol'; import './interfaces/ILockupPlans.sol'; import './interfaces/IDelegatePlan.sol'; import './interfaces/IERC20Votes.sol'; import '@openzeppelin/contracts/utils/ReentrancyGuard.sol'; import '@openzeppelin/contracts/utils/cryptography/MerkleProof.sol'; import '@openzeppelin/contracts/token/ERC721/IERC721.sol'; import '@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol'; import '@openzeppelin/contracts/utils/cryptography/EIP712.sol'; import '@openzeppelin/contracts/utils/cryptography/ECDSA.sol'; import '@openzeppelin/contracts/utils/Nonces.sol'; /// @title ClaimCampaigns - The smart contract to distribute your tokens to the community via claims /// @notice This tool allows token projects to safely, securely and efficiently distribute your tokens in large scale to your community, whereby they can claim them based on your criteria of wallet address and amount. contract DelegatedClaimCampaigns is ERC721Holder, ReentrancyGuard, EIP712, Nonces { /// @dev this claimhash is used for EIP712 signing of the claim functions bytes32 private constant CLAIM_TYPEHASH = keccak256('Claim(bytes16 campaignId,address claimer,uint256 claimAmount,uint256 nonce,uint256 expiry)'); bytes32 private constant MULITCLAIM_TYPEHASH = keccak256( 'MultiClaim(bytes16 campaignId,address claimer,uint256 claimAmount,uint256 nonce,uint256 expiry,uint256 numberOfClaims)' ); bytes32 private constant DELEGATINGCLAIM_TYPEHASH = keccak256( 'DelegatingClaim(bytes16 campaignId,address claimer,uint256 claimAmount,address delegatee,uint256 nonce,uint256 expiry)' ); mapping(address => bool) public tokenLockers; /// @dev an enum defining the different types of claims to be made /// @param Unlocked means that tokens claimed are liquid and not locked at all /// @param Locked means that the tokens claimed will be locked inside a TokenLockups plan /// @param Vesting means the tokens claimed will be locked inside a TokenVesting plan enum TokenLockup { Unlocked, Locked, Vesting } /// @notice the struct that defines the Locked and Vesting parameters for each vesting /// @dev this can be ignored for Unlocked claim campaigns /// @param tokenLocker is the address of the TokenLockup or TokenVesting plans contract that will lock the tokens /// @param start is the start date when the unlock / vesting begins /// @param cliff is the single cliff date for unlocking and vesting plans, when all tokens prior to the cliff remained locked and unvested /// @param period is the amount of seconds in each discrete period. /// @param periods is the total number of periods that the tokens will be locked or vested for struct ClaimLockup { address tokenLocker; uint256 start; uint256 cliff; uint256 period; uint256 periods; } /// @notice Campaign is the struct that defines a claim campaign in general. The Campaign is related to a one time use, related to a merkle tree that pre defines all of the wallets and amounts those wallets can claim /// once the amount is 0, the campaign is ended. The campaign can also be terminated at any time. /// @param manager is the address of the campaign manager who is in charge of cancelling the campaign - AND if the campaign is setup for vesting, this address will be used as the vestingAdmin wallet for all of the vesting plans created /// the manager is typically the msg.sender wallet, but can be defined as something else in case. /// @param token is the address of the token to be claimed by the wallets, which is pulled into the contract during the campaign /// @param amount is the total amount of tokens left in the Campaign. this starts out as the entire amount in the campaign, and gets reduced each time a claim is made /// @param start is the start time of the campaign when ppl can begin claiming their tokens /// @param end is a unix time that can be used as a safety mechanism to put a hard end date for a campaign, this can also be far far in the future to effectively be forever claims /// @param tokenLockup is the enum (uint8) that describes how and if the tokens will be locked or vesting when they are claimed. If set to unlocked, claimants will just get the tokens, but if they are Locked / vesting, they will receive the NFT Tokenlockup plan or vesting plan /// @param root is the root of the merkle tree used for the claims. /// @param delegating is a boolean defining whether the claims need to be delegated when claimed or not struct Campaign { address manager; address token; uint256 amount; uint256 start; uint256 end; TokenLockup tokenLockup; bytes32 root; bool delegating; } /// @dev this is for the EIP712 signatures used for claiming tokens on behalf of users /// @param nonce is the nonce of the claimer, which is used to prevent replay attacks /// @param expiry is the expiry time of the claim, which is used to prevent replay attacks /// @param v is the v value of the signature /// @param r is the r value of the signature /// @param s is the s value of the signature struct SignatureParams { uint256 nonce; uint256 expiry; uint8 v; bytes32 r; bytes32 s; } /// @dev we use UUIDs or CIDs to map to a specific unique campaign. The UUID or CID is typically generated when the merkle tree is created, and then that id or cid is the identifier of the file in S3 or IPFS mapping(bytes16 => Campaign) public campaigns; /// @dev the same UUID is maped to the ClaimLockup details for the specific campaign mapping(bytes16 => ClaimLockup) public claimLockups; /// @dev this maps the UUID that have already been used, so that a campaign cannot be duplicated mapping(bytes16 => bool) public usedIds; mapping(bytes16 => uint256) private _campaignBlockNumber; //maps campaign id to a wallet address, which is flipped to true when claimed mapping(bytes16 => mapping(address => bool)) public claimed; //maps campaign id to the vesting admin address when the campaign is a vesting campaign mapping(bytes16 => address) private _vestingAdmins; // events event CampaignStarted(bytes16 indexed id, Campaign campaign, uint256 totalClaimers); event ClaimLockupCreated(bytes16 indexed id, ClaimLockup claimLockup); event CampaignCancelled(bytes16 indexed id); event LockedTokensClaimed( bytes16 indexed id, address indexed claimer, uint256 indexed tokenId, uint256 amountClaimed, uint256 amountRemaining ); event UnlockedTokensClaimed( bytes16 indexed id, address indexed claimer, uint256 amountClaimed, uint256 amountRemaining ); event Claimed(address indexed recipient, uint256 indexed amount); /// @notice the constructor of the contract, which sets the name and version of the EIP712 contract constructor(string memory name, string memory version, address[] memory _tokenLockups) EIP712(name, version) { for (uint256 i = 0; i < _tokenLockups.length; i++) { tokenLockers[_tokenLockups[i]] = true; } } /**********EXTERNAL CREATE& CANCEL CLAIMS FUNCTIONS********************************************************************************************/ /// @notice primary function for creating an unlocked claims campaign. This function will pull the amount of tokens in the campaign struct, and map the campaign to the id. /// @dev the merkle tree needs to be pre-generated, so that you can upload the root and the uuid for the function /// @param id is the uuid or CID of the file that stores the merkle tree /// @param campaign is the struct of the campaign info, including the total amount tokens to be distributed via claims, and the root of the merkle tree /// @param totalClaimers is the total number of claimers that can claim from the campaign function createUnlockedCampaign(bytes16 id, Campaign memory campaign, uint256 totalClaimers) external nonReentrant { require(!usedIds[id], 'in use'); require(id != bytes16(0), '0_id'); usedIds[id] = true; require(campaign.token != address(0), '0_address'); require(campaign.manager != address(0), '0_manager'); require(campaign.amount > 0, '0_amount'); require(campaign.end > block.timestamp && campaign.end > campaign.start, 'end error'); require(campaign.tokenLockup == TokenLockup.Unlocked, 'locked'); if (campaign.delegating) { require(IERC20Votes(campaign.token).delegates(address(this)) == address(0), '!erc20votes'); } TransferHelper.transferTokens(campaign.token, msg.sender, address(this), campaign.amount); campaigns[id] = campaign; _campaignBlockNumber[id] = block.number; emit CampaignStarted(id, campaign, totalClaimers); } /// @notice primary function for creating an locked or vesting claims campaign. This function will pull the amount of tokens in the campaign struct, and map the campaign and claimLockup to the id. /// additionally it will check that the lockup details are valid, and perform an allowance increase to the contract for when tokens are claimed they can be pulled. /// @dev the merkle tree needs to be pre-generated, so that you can upload the root and the uuid for the function /// @param id is the uuid or CID of the file that stores the merkle tree /// @param campaign is the struct of the campaign info, including the total amount tokens to be distributed via claims, and the root of the merkle tree, plus the lockup type of either 1 (lockup) or 2 (vesting) /// @param claimLockup is the struct that defines the characteristics of the lockup for each token claimed. /// @param vestingAdmin is the address of the vesting admin, which is used for the vesting plans, and is typically the msg.sender function createLockedCampaign( bytes16 id, Campaign memory campaign, ClaimLockup memory claimLockup, address vestingAdmin, uint256 totalClaimers ) external nonReentrant { require(!usedIds[id], 'in use'); require(id != bytes16(0), '0_id'); usedIds[id] = true; require(campaign.token != address(0), '0_address'); require(campaign.manager != address(0), '0_manager'); require(campaign.amount > 0, '0_amount'); require(campaign.end > block.timestamp && campaign.end > campaign.start, 'end error'); require(campaign.tokenLockup != TokenLockup.Unlocked, '!locked'); require(claimLockup.periods > 0, '0_periods'); require(claimLockup.period > 0, '0_period'); require(tokenLockers[claimLockup.tokenLocker], 'invalid locker'); if (campaign.delegating) { require(IERC20Votes(campaign.token).delegates(address(this)) == address(0), '!erc20votes'); } if (campaign.tokenLockup == TokenLockup.Vesting) { require(vestingAdmin != address(0), '0_admin'); _vestingAdmins[id] = vestingAdmin; } require(claimLockup.tokenLocker != address(0), 'invalide locker'); TransferHelper.transferTokens(campaign.token, msg.sender, address(this), campaign.amount); claimLockups[id] = claimLockup; campaigns[id] = campaign; _campaignBlockNumber[id] = block.number; emit ClaimLockupCreated(id, claimLockup); emit CampaignStarted(id, campaign, totalClaimers); } /// @notice this function allows the campaign manager to cancel an ongoing campaign at anytime. Cancelling a campaign will return any unclaimed tokens, and then prevent anyone from claiming additional tokens /// @param campaignIds is the id of the campaign to be cancelled function cancelCampaigns(bytes16[] memory campaignIds) external nonReentrant { for (uint256 i = 0; i < campaignIds.length; i++) { Campaign memory campaign = campaigns[campaignIds[i]]; require(campaign.manager == msg.sender, '!manager'); require(_campaignBlockNumber[campaignIds[i]] < block.number, 'same block'); require((IERC20(campaign.token).allowance(address(this), claimLockups[campaignIds[i]].tokenLocker)) == 0, 'allowance error'); delete campaigns[campaignIds[i]]; delete claimLockups[campaignIds[i]]; TransferHelper.withdrawTokens(campaign.token, msg.sender, campaign.amount); emit CampaignCancelled(campaignIds[i]); } } /***************EXTERNAL CLAIMING FUNCTIONS***************************************************************************************************/ /// @notice the primary function for claiming tokens from a campaign if there is no delegation requirement /// @param campaignId is the id of the campaign to claim from /// @param proof is the proof of the leaf in the merkle tree /// @param claimAmount is the amount of tokens to claim /// @dev the function checks that the claimer has not already claimed, and that the campaign is not delegating, and then calls the internal claim function function claim(bytes16 campaignId, bytes32[] calldata proof, uint256 claimAmount) external nonReentrant { require(!claimed[campaignId][msg.sender], 'already claimed'); require(!campaigns[campaignId].delegating, 'must delegate'); if (campaigns[campaignId].tokenLockup == TokenLockup.Unlocked) { _claimUnlockedTokens(campaignId, proof, msg.sender, claimAmount); } else { _claimLockedTokens(campaignId, proof, msg.sender, claimAmount); } } /// @notice function to claim tokens from multiple campaigns assuming none of them require delegation /// @param campaignIds is the id of the campaign to claim from /// @param proofs is the proof of the leaf in the merkle tree /// @param claimAmounts is the amount of tokens to claim function claimMultiple( bytes16[] calldata campaignIds, bytes32[][] calldata proofs, uint256[] calldata claimAmounts ) external nonReentrant { require(campaignIds.length == proofs.length, 'length mismatch'); require(campaignIds.length == claimAmounts.length, 'length mismatch'); uint256 claimNum = campaignIds.length; for (uint256 i; i < claimNum; ++i) { require(!claimed[campaignIds[i]][msg.sender], 'already claimed'); require(!campaigns[campaignIds[i]].delegating, 'must delegate'); if (campaigns[campaignIds[i]].tokenLockup == TokenLockup.Unlocked) { _claimUnlockedTokens(campaignIds[i], proofs[i], msg.sender, claimAmounts[i]); } else { _claimLockedTokens(campaignIds[i], proofs[i], msg.sender, claimAmounts[i]); } } } /// @notice function to claim tokens using the EIP712 signature for claiming on behalf of a user /// @param campaignId is the id of the campaign to claim from /// @param proof is the proof of the leaf in the merkle tree /// @param claimer is the address of the beneficial owner of the claim /// @param claimAmount is the amount of tokens to claim /// @param claimSignature is the signature provided by the beneficial owner (the claimer) to the user of the function to claim on their behalf function claimWithSig( bytes16 campaignId, bytes32[] calldata proof, address claimer, uint256 claimAmount, SignatureParams memory claimSignature ) external nonReentrant { require(!claimed[campaignId][claimer], 'already claimed'); require(!campaigns[campaignId].delegating, 'must delegate'); require(claimSignature.expiry > block.timestamp, 'claim expired'); address signer = ECDSA.recover( _hashTypedDataV4( keccak256( abi.encode(CLAIM_TYPEHASH, campaignId, claimer, claimAmount, claimSignature.nonce, claimSignature.expiry) ) ), claimSignature.v, claimSignature.r, claimSignature.s ); require(signer == claimer, 'invalid claim signature'); _useCheckedNonce(claimer, claimSignature.nonce); if (campaigns[campaignId].tokenLockup == TokenLockup.Unlocked) { _claimUnlockedTokens(campaignId, proof, claimer, claimAmount); } else { _claimLockedTokens(campaignId, proof, claimer, claimAmount); } } function claimMultipleWithSig( bytes16[] calldata campaignIds, bytes32[][] calldata proofs, address claimer, uint256[] calldata claimAmounts, SignatureParams memory claimSignature ) external nonReentrant { require(campaignIds.length == proofs.length, 'length mismatch'); require(campaignIds.length == claimAmounts.length, 'length mismatch'); require(claimSignature.expiry > block.timestamp, 'claim expired'); address signer = ECDSA.recover( _hashTypedDataV4( keccak256( abi.encode( MULITCLAIM_TYPEHASH, campaignIds[0], claimer, claimAmounts[0], claimSignature.nonce, claimSignature.expiry, campaignIds.length ) ) ), claimSignature.v, claimSignature.r, claimSignature.s ); require(signer == claimer, 'invalid claim signature'); _useCheckedNonce(claimer, claimSignature.nonce); uint256 claimNum = campaignIds.length; for (uint256 i; i < claimNum; ++i) { require(!claimed[campaignIds[i]][claimer], 'already claimed'); require(!campaigns[campaignIds[i]].delegating, 'must delegate'); if (campaigns[campaignIds[i]].tokenLockup == TokenLockup.Unlocked) { _claimUnlockedTokens(campaignIds[i], proofs[i], claimer, claimAmounts[i]); } else { _claimLockedTokens(campaignIds[i], proofs[i], claimer, claimAmounts[i]); } } } /// @notice function to claim and delegate tokens in a single transaction. This is required when a claim is delegating, but can also be used for a claim not requiring it, but if the end user wants to claim and delegate in a single transaction /// @param campaignId is the id of the campaign to claim from /// @param proof is the proof of the leaf in the merkle tree /// @param claimAmount is the amount of tokens to claim /// @param delegatee is the address of the wallet to delegate the claim to /// @param delegationSignature is a signature required Only if the user is claiming unlocked tokens, used to call the delegateWithSig function on the ERC20Votes token contract /// @dev the delegation signature is not require and empty entries can be passed in if the campaign is locked or vesting function claimAndDelegate( bytes16 campaignId, bytes32[] memory proof, uint256 claimAmount, address delegatee, SignatureParams memory delegationSignature ) external nonReentrant { require(delegatee != address(0), '0_delegatee'); require(!claimed[campaignId][msg.sender], 'already claimed'); if (campaigns[campaignId].tokenLockup == TokenLockup.Unlocked) { _claimUnlockedAndDelegate( campaignId, proof, msg.sender, claimAmount, delegatee, delegationSignature.nonce, delegationSignature.expiry, delegationSignature.v, delegationSignature.r, delegationSignature.s ); } else { _claimLockedAndDelegate(campaignId, proof, msg.sender, claimAmount, delegatee); } } /// @notice function to claim and delegate tokens using the EIP712 signature for claiming on behalf of a user /// @param campaignId is the id of the campaign to claim from /// @param proof is the proof of the leaf in the merkle tree /// @param claimer is the address of the beneficial owner of the claim /// @param claimAmount is the amount of tokens to claim /// @param claimSignature is the signature provided by the beneficial owner (the claimer) to the user of the function to claim on their behalf /// @param delegatee is the address of the wallet to delegate the claim to /// @param delegationSignature is a signature required Only if the user is claiming unlocked tokens, used to call the delegateWithSig function on the ERC20Votes token contract /// @dev the delegation signature is not require and empty entries can be passed in if the campaign is locked or vesting function claimAndDelegateWithSig( bytes16 campaignId, bytes32[] memory proof, address claimer, uint256 claimAmount, SignatureParams memory claimSignature, address delegatee, SignatureParams memory delegationSignature ) external nonReentrant { require(delegatee != address(0), '0_delegatee'); require(!claimed[campaignId][claimer], 'already claimed'); require(claimSignature.expiry > block.timestamp, 'claim expired'); address signer = ECDSA.recover( _hashTypedDataV4( keccak256( abi.encode( DELEGATINGCLAIM_TYPEHASH, campaignId, claimer, claimAmount, delegatee, claimSignature.nonce, claimSignature.expiry ) ) ), claimSignature.v, claimSignature.r, claimSignature.s ); require(signer == claimer, 'invalid claim signature'); _useCheckedNonce(claimer, claimSignature.nonce); if (campaigns[campaignId].tokenLockup == TokenLockup.Unlocked) { _claimUnlockedAndDelegate( campaignId, proof, claimer, claimAmount, delegatee, delegationSignature.nonce, delegationSignature.expiry, delegationSignature.v, delegationSignature.r, delegationSignature.s ); } else { _claimLockedAndDelegate(campaignId, proof, claimer, claimAmount, delegatee); } } /*****INTERNAL CLAIMINIG FUNCTIONS**********************************************************************************************/ /// @notice internal function to claim unlocked tokens without delegation /// @param campaignId is the id of the campaign to claim from /// @param proof is the proof of the leaf in the merkle tree /// @param claimer is the address of the beneficial owner of the claim /// @param claimAmount is the amount of tokens to claim /// @dev the function assumes that signature validation has already been completed, so no need to check that the one claiming is the claimer - as tokens will be delivered to the claimer regardless /// the function checks that the campaign has started, that it has not ended, that the proof is valid with the inputs of root, proof, claimer, and claim amount /// it checks that the campaign is funded - though this require statement should never be triggered its here as an extra layer of security /// it checks that the token lockup type is unlocked /// then the function will set the claimed mapping to true so that the claimer cannot claim again /// it will reduce the amount of tokens in the campaign by the claim amount /// if the campaign amount is 0, then the campaign is deleted as it is complete and over /// then the tokens are transferred to the claimer function _claimUnlockedTokens( bytes16 campaignId, bytes32[] memory proof, address claimer, uint256 claimAmount ) internal returns (address token) { Campaign memory campaign = campaigns[campaignId]; require(campaign.start <= block.timestamp, '!started'); require(campaign.end > block.timestamp, 'campaign ended'); require(verify(campaign.root, proof, claimer, claimAmount), '!eligible'); require(campaign.amount >= claimAmount, 'campaign unfunded'); require(campaign.tokenLockup == TokenLockup.Unlocked, '!unlocked'); claimed[campaignId][claimer] = true; campaigns[campaignId].amount -= claimAmount; if (campaigns[campaignId].amount == 0) { delete campaigns[campaignId]; } TransferHelper.withdrawTokens(campaign.token, claimer, claimAmount); emit UnlockedTokensClaimed(campaignId, claimer, claimAmount, campaigns[campaignId].amount); return campaign.token; } /// @notice internal function to claim unlocked tokens and delegate /// @param campaignId is the id of the campaign to claim from /// @param proof is the proof of the leaf in the merkle tree /// @param claimer is the address of the beneficial owner of the claim /// @param claimAmount is the amount of tokens to claim /// @param delegatee is the address of the wallet to delegate the claim to /// @param nonce is the nonce of the claimer, which is used to prevent replay attacks /// @param expiry is the expiry time of the claim, which is used to prevent replay attacks /// @param v is the v value of the signature /// @param r is the r value of the signature /// @param s is the s value of the signature /// @dev this function calls the above internal function to claimUnlockedTokens and then now that the tokens are in the claimers wallet /// it uses the delegatebySig function on ERC20Votes to delegate the claimers wallet to the delegatee /// it checks that the actual delegation was completed correctly and reverts if not /// @dev if the token does not conform to the ERC20Votes interface with the delegateBySig function then it will revert function _claimUnlockedAndDelegate( bytes16 campaignId, bytes32[] memory proof, address claimer, uint256 claimAmount, address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s ) internal { address token = _claimUnlockedTokens(campaignId, proof, claimer, claimAmount); address delegatedTo = IERC20Votes(token).delegates(claimer); if (delegatedTo != delegatee) { IERC20Votes(token).delegateBySig(delegatee, nonce, expiry, v, r, s); delegatedTo = IERC20Votes(token).delegates(claimer); require(delegatedTo == delegatee, 'delegation failed'); } emit Claimed(claimer, claimAmount); } /// @notice internal function to claim locked tokens without delegation /// @param campaignId is the id of the campaign to claim from /// @param proof is the proof of the leaf in the merkle tree /// @param claimer is the address of the beneficial owner of the claim /// @param claimAmount is the amount of tokens to claim /// @dev the function checks that the campaign has started, that it has not ended, that the proof is valid with the inputs of root, proof, claimer, and claim amount /// it checks that the campaign is funded - though this require statement should never be triggered its here as an extra layer of security, and then it reduces the campaign amount by the claim amount /// if the campaign amount is 0, then the campaign is deleted as it is complete and over /// the function calculates the rate to be used for the lockup or vesting plan based on the number of periods and the claim amount /// then it creates a lockup plan or vesting plan based on the tokenLockup type in the campaign struct function _claimLockedTokens( bytes16 campaignId, bytes32[] memory proof, address claimer, uint256 claimAmount ) internal { Campaign memory campaign = campaigns[campaignId]; ClaimLockup memory c = claimLockups[campaignId]; require(campaign.start <= block.timestamp, '!started'); require(campaign.end > block.timestamp, 'campaign ended'); require(verify(campaign.root, proof, claimer, claimAmount), '!eligible'); require(campaign.amount >= claimAmount, 'campaign unfunded'); claimed[campaignId][claimer] = true; campaigns[campaignId].amount -= claimAmount; if (campaigns[campaignId].amount == 0) { delete campaigns[campaignId]; delete claimLockups[campaignId]; } uint256 rate; if (claimAmount % c.periods == 0) { rate = claimAmount / c.periods; } else { rate = claimAmount / c.periods + 1; } uint256 start = c.start == 0 ? block.timestamp : c.start; uint256 tokenId; SafeERC20.safeIncreaseAllowance(IERC20(campaign.token), c.tokenLocker, claimAmount); if (campaign.tokenLockup == TokenLockup.Locked) { tokenId = ILockupPlans(c.tokenLocker).createPlan( claimer, campaign.token, claimAmount, start, c.cliff, rate, c.period ); } else { tokenId = IVestingPlans(c.tokenLocker).createPlan( claimer, campaign.token, claimAmount, start, c.cliff, rate, c.period, _vestingAdmins[campaignId], true ); } require((IERC20(campaign.token).allowance(address(this), c.tokenLocker)) == 0, 'allowance error'); emit LockedTokensClaimed(campaignId, claimer, tokenId, claimAmount, campaigns[campaignId].amount); } /// @notice internal function to claim locked tokens and delegate /// @param campaignId is the id of the campaign to claim from /// @param proof is the proof of the leaf in the merkle tree /// @param claimer is the address of the beneficial owner of the claim /// @param claimAmount is the amount of tokens to claim /// @param delegatee is the address of the wallet to delegate the claim to /// @dev the function checks that the campaign has started, that it has not ended, that the proof is valid with the inputs of root, proof, claimer, and claim amount /// it checks that the campaign is funded - though this require statement should never be triggered its here as an extra layer of security /// it checks that the token is an ERC20Votes type token to save gas if it is not /// it sets the claimed mapping to true so that the claimer cannot claim again /// it reduces the campaign amount by the claim amount /// if the campaign amount is 0, then the campaign is deleted as it is complete and over /// the function calculates the rate to be used for the lockup or vesting plan based on the number of periods and the claim amount /// then it creates a lockup plan or vesting plan based on the tokenLockup type in the campaign struct. /// the lockup or vesting plan is issued to this contract address - since only the owner can delegate the plan, and then it delegates the plan to the delegatee /// after delegation is complete, then it transfers the plan to the claimer /// and for vesting it transfers the vesting admin to the vesting admin function _claimLockedAndDelegate( bytes16 campaignId, bytes32[] memory proof, address claimer, uint256 claimAmount, address delegatee ) internal { Campaign memory campaign = campaigns[campaignId]; ClaimLockup memory c = claimLockups[campaignId]; require(campaign.start <= block.timestamp, '!started'); require(campaign.end > block.timestamp, 'campaign ended'); require(verify(campaign.root, proof, claimer, claimAmount), '!eligible'); require(campaign.amount >= claimAmount, 'campaign unfunded'); claimed[campaignId][claimer] = true; campaigns[campaignId].amount -= claimAmount; if (campaigns[campaignId].amount == 0) { delete campaigns[campaignId]; delete claimLockups[campaignId]; } uint256 rate; if (claimAmount % c.periods == 0) { rate = claimAmount / c.periods; } else { rate = claimAmount / c.periods + 1; } uint256 start = c.start == 0 ? block.timestamp : c.start; uint256 tokenId; SafeERC20.safeIncreaseAllowance(IERC20(campaign.token), c.tokenLocker, claimAmount); if (campaign.tokenLockup == TokenLockup.Locked) { tokenId = ILockupPlans(c.tokenLocker).createPlan( address(this), campaign.token, claimAmount, start, c.cliff, rate, c.period ); IDelegatePlan(c.tokenLocker).delegate(tokenId, delegatee); IERC721(c.tokenLocker).transferFrom(address(this), claimer, tokenId); } else { tokenId = IVestingPlans(c.tokenLocker).createPlan( address(this), campaign.token, claimAmount, start, c.cliff, rate, c.period, address(this), true ); IDelegatePlan(c.tokenLocker).delegate(tokenId, delegatee); IERC721(c.tokenLocker).transferFrom(address(this), claimer, tokenId); IVestingPlans(c.tokenLocker).changeVestingPlanAdmin(tokenId, _vestingAdmins[campaignId]); } require((IERC20(campaign.token).allowance(address(this), c.tokenLocker)) == 0, 'allowance error'); emit Claimed(claimer, claimAmount); emit LockedTokensClaimed(campaignId, claimer, tokenId, claimAmount, campaigns[campaignId].amount); } /// @dev the internal verify function from the open zepellin library. /// this function inputs the root, proof, wallet address of the claimer, and amount of tokens, and then computes the validity of the leaf with the proof and root. /// @param root is the root of the merkle tree /// @param proof is the proof for the specific leaf /// @param claimer is the address of the claimer used in making the leaf /// @param amount is the amount of tokens to be claimed, the other piece of data in the leaf function verify(bytes32 root, bytes32[] memory proof, address claimer, uint256 amount) public pure returns (bool) { bytes32 leaf = keccak256(bytes.concat(keccak256(abi.encode(claimer, amount)))); require(MerkleProof.verify(proof, root, leaf), 'Invalid proof'); return true; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5267.sol) pragma solidity ^0.8.20; interface IERC5267 { /** * @dev MAY be emitted to signal that the domain could have changed. */ event EIP712DomainChanged(); /** * @dev returns the fields and values that describe the domain separator used by this contract for EIP-712 * signature. */ function eip712Domain() external view returns ( bytes1 fields, string memory name, string memory version, uint256 chainId, address verifyingContract, bytes32 salt, uint256[] memory extensions ); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. * * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't * need to send a transaction, and thus is not required to hold Ether at all. * * ==== Security Considerations * * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be * considered as an intention to spend the allowance in any specific way. The second is that because permits have * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be * generally recommended is: * * ```solidity * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public { * try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {} * doThing(..., value); * } * * function doThing(..., uint256 value) public { * token.safeTransferFrom(msg.sender, address(this), value); * ... * } * ``` * * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also * {SafeERC20-safeTransferFrom}). * * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so * contracts should have entry points that don't rely on permit. */ interface IERC20Permit { /** * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens, * given ``owner``'s signed approval. * * IMPORTANT: The same issues {IERC20-approve} has related to transaction * ordering also apply here. * * Emits an {Approval} event. * * Requirements: * * - `spender` cannot be the zero address. * - `deadline` must be a timestamp in the future. * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` * over the EIP712-formatted function arguments. * - the signature must use ``owner``'s current nonce (see {nonces}). * * For more information on the signature format, see the * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP * section]. * * CAUTION: See Security Considerations above. */ function permit( address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s ) external; /** * @dev Returns the current nonce for `owner`. This value must be * included whenever a signature is generated for {permit}. * * Every successful call to {permit} increases ``owner``'s nonce by one. This * prevents a signature from being used multiple times. */ function nonces(address owner) external view returns (uint256); /** * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}. */ // solhint-disable-next-line func-name-mixedcase function DOMAIN_SEPARATOR() external view returns (bytes32); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the value of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the value of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves a `value` amount of tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 value) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets a `value` amount of tokens as the allowance of `spender` over the * caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 value) external returns (bool); /** * @dev Moves a `value` amount of tokens from `from` to `to` using the * allowance mechanism. `value` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 value) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol) pragma solidity ^0.8.20; import {IERC20} from "../IERC20.sol"; import {IERC20Permit} from "../extensions/IERC20Permit.sol"; import {Address} from "../../../utils/Address.sol"; /** * @title SafeERC20 * @dev Wrappers around ERC20 operations that throw on failure (when the token * contract returns false). Tokens that return no value (and instead revert or * throw on failure) are also supported, non-reverting calls are assumed to be * successful. * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, * which allows you to call the safe operations as `token.safeTransfer(...)`, etc. */ library SafeERC20 { using Address for address; /** * @dev An operation with an ERC20 token failed. */ error SafeERC20FailedOperation(address token); /** * @dev Indicates a failed `decreaseAllowance` request. */ error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease); /** * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeTransfer(IERC20 token, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value))); } /** * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful. */ function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value))); } /** * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. */ function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { uint256 oldAllowance = token.allowance(address(this), spender); forceApprove(token, spender, oldAllowance + value); } /** * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no * value, non-reverting calls are assumed to be successful. */ function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal { unchecked { uint256 currentAllowance = token.allowance(address(this), spender); if (currentAllowance < requestedDecrease) { revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease); } forceApprove(token, spender, currentAllowance - requestedDecrease); } } /** * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value, * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval * to be set to zero before setting it to a non-zero value, such as USDT. */ function forceApprove(IERC20 token, address spender, uint256 value) internal { bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value)); if (!_callOptionalReturnBool(token, approvalCall)) { _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0))); _callOptionalReturn(token, approvalCall); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). */ function _callOptionalReturn(IERC20 token, bytes memory data) private { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. bytes memory returndata = address(token).functionCall(data); if (returndata.length != 0 && !abi.decode(returndata, (bool))) { revert SafeERC20FailedOperation(address(token)); } } /** * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement * on the return value: the return value is optional (but if data is returned, it must not be false). * @param token The token targeted by the call. * @param data The call data (encoded using abi.encode or one of its variants). * * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead. */ function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) { // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false // and not revert is the subcall reverts. (bool success, bytes memory returndata) = address(token).call(data); return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.20; import {IERC165} from "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external; /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or * {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon * a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom(address from, address to, uint256 tokenId) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom(address from, address to, uint256 tokenId) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the address zero. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.20; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721Receiver { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be * reverted. * * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/utils/ERC721Holder.sol) pragma solidity ^0.8.20; import {IERC721Receiver} from "../IERC721Receiver.sol"; /** * @dev Implementation of the {IERC721Receiver} interface. * * Accepts all token transfers. * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or * {IERC721-setApprovalForAll}. */ abstract contract ERC721Holder is IERC721Receiver { /** * @dev See {IERC721Receiver-onERC721Received}. * * Always returns `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received(address, address, uint256, bytes memory) public virtual returns (bytes4) { return this.onERC721Received.selector; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol) pragma solidity ^0.8.20; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev The ETH balance of the account is not enough to perform the operation. */ error AddressInsufficientBalance(address account); /** * @dev There's no code at `target` (it is not a contract). */ error AddressEmptyCode(address target); /** * @dev A call to an address target failed. The target may have reverted. */ error FailedInnerCall(); /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { if (address(this).balance < amount) { revert AddressInsufficientBalance(address(this)); } (bool success, ) = recipient.call{value: amount}(""); if (!success) { revert FailedInnerCall(); } } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason or custom error, it is bubbled * up by this function (like regular Solidity function calls). However, if * the call reverted with no returned reason, this function reverts with a * {FailedInnerCall} error. * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCallWithValue(target, data, 0); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { if (address(this).balance < value) { revert AddressInsufficientBalance(address(this)); } (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an * unsuccessful call. */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata ) internal view returns (bytes memory) { if (!success) { _revert(returndata); } else { // only check if target is a contract if the call was successful and the return data is empty // otherwise we already know that it was a contract if (returndata.length == 0 && target.code.length == 0) { revert AddressEmptyCode(target); } return returndata; } } /** * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the * revert reason or with a default {FailedInnerCall} error. */ function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) { if (!success) { _revert(returndata); } else { return returndata; } } /** * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}. */ function _revert(bytes memory returndata) private pure { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert FailedInnerCall(); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.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 an error. This will not * return address(0) without also returning an error description. Errors are documented using an enum (error type) * and a bytes32 providing additional information about the error. * * If no error is returned, then the address can 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 v5.0.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 // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MerkleProof.sol) pragma solidity ^0.8.20; /** * @dev These functions deal with verification of Merkle Tree proofs. * * The tree and the proofs can be generated using our * https://github.com/OpenZeppelin/merkle-tree[JavaScript library]. * You will find a quickstart guide in the readme. * * WARNING: You should avoid using leaf values that are 64 bytes long prior to * hashing, or use a hash function other than keccak256 for hashing leaves. * This is because the concatenation of a sorted pair of internal nodes in * the Merkle tree could be reinterpreted as a leaf value. * OpenZeppelin's JavaScript library generates Merkle trees that are safe * against this attack out of the box. */ library MerkleProof { /** *@dev The multiproof provided is not valid. */ error MerkleProofInvalidMultiproof(); /** * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree * defined by `root`. For this, a `proof` must be provided, containing * sibling hashes on the branch from the leaf to the root of the tree. Each * pair of leaves and each pair of pre-images are assumed to be sorted. */ function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProof(proof, leaf) == root; } /** * @dev Calldata version of {verify} */ function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) { return processProofCalldata(proof, leaf) == root; } /** * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt * hash matches the root of the tree. When processing the proof, the pairs * of leafs & pre-images are assumed to be sorted. */ function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Calldata version of {processProof} */ function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) { bytes32 computedHash = leaf; for (uint256 i = 0; i < proof.length; i++) { computedHash = _hashPair(computedHash, proof[i]); } return computedHash; } /** * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}. * * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details. */ function multiProofVerify( bytes32[] memory proof, bool[] memory proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProof(proof, proofFlags, leaves) == root; } /** * @dev Calldata version of {multiProofVerify} * * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details. */ function multiProofVerifyCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32 root, bytes32[] memory leaves ) internal pure returns (bool) { return processMultiProofCalldata(proof, proofFlags, leaves) == root; } /** * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false * respectively. * * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer). */ function processMultiProof( bytes32[] memory proof, bool[] memory proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the Merkle tree. uint256 leavesLen = leaves.length; uint256 proofLen = proof.length; uint256 totalHashes = proofFlags.length; // Check proof validity. if (leavesLen + proofLen != totalHashes + 1) { revert MerkleProofInvalidMultiproof(); } // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { if (proofPos != proofLen) { revert MerkleProofInvalidMultiproof(); } unchecked { return hashes[totalHashes - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Calldata version of {processMultiProof}. * * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details. */ function processMultiProofCalldata( bytes32[] calldata proof, bool[] calldata proofFlags, bytes32[] memory leaves ) internal pure returns (bytes32 merkleRoot) { // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of // the Merkle tree. uint256 leavesLen = leaves.length; uint256 proofLen = proof.length; uint256 totalHashes = proofFlags.length; // Check proof validity. if (leavesLen + proofLen != totalHashes + 1) { revert MerkleProofInvalidMultiproof(); } // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop". bytes32[] memory hashes = new bytes32[](totalHashes); uint256 leafPos = 0; uint256 hashPos = 0; uint256 proofPos = 0; // At each step, we compute the next hash using two values: // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we // get the next hash. // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the // `proof` array. for (uint256 i = 0; i < totalHashes; i++) { bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]; bytes32 b = proofFlags[i] ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++]) : proof[proofPos++]; hashes[i] = _hashPair(a, b); } if (totalHashes > 0) { if (proofPos != proofLen) { revert MerkleProofInvalidMultiproof(); } unchecked { return hashes[totalHashes - 1]; } } else if (leavesLen > 0) { return leaves[0]; } else { return proof[0]; } } /** * @dev Sorts the pair (a, b) and hashes the result. */ function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) { return a < b ? _efficientHash(a, b) : _efficientHash(b, a); } /** * @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory. */ function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) { /// @solidity memory-safe-assembly assembly { mstore(0x00, a) mstore(0x20, b) value := keccak256(0x00, 0x40) } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/cryptography/MessageHashUtils.sol) 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 `messageHash` 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) { 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) { 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 v5.0.0) (utils/introspection/IERC165.sol) pragma solidity ^0.8.20; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165 { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/Math.sol) pragma solidity ^0.8.20; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { /** * @dev Muldiv operation overflow. */ error MathOverflowedMulDiv(); enum Rounding { Floor, // Toward negative infinity Ceil, // Toward positive infinity Trunc, // Toward zero Expand // Away from zero } /** * @dev Returns the addition of two unsigned integers, with an overflow flag. */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds towards infinity instead * of rounding towards zero. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { if (b == 0) { // Guarantee the same behavior as in a regular Solidity division. return a / b; } // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or * denominator == 0. * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by * Uniswap Labs also under MIT license. */ function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0 = x * y; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { // Solidity will revert if denominator == 0, unlike the div opcode on its own. // The surrounding unchecked block does not change this fact. // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic. return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. if (denominator <= prod1) { revert MathOverflowedMulDiv(); } /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. // Always >= 1. See https://cs.stackexchange.com/q/138556/92363. uint256 twos = denominator & (0 - denominator); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also // works in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded * towards zero. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (unsignedRoundsUp(rounding) && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (unsignedRoundsUp(rounding) && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10 of a positive value rounded towards zero. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10 ** 64) { value /= 10 ** 64; result += 64; } if (value >= 10 ** 32) { value /= 10 ** 32; result += 32; } if (value >= 10 ** 16) { value /= 10 ** 16; result += 16; } if (value >= 10 ** 8) { value /= 10 ** 8; result += 8; } if (value >= 10 ** 4) { value /= 10 ** 4; result += 4; } if (value >= 10 ** 2) { value /= 10 ** 2; result += 2; } if (value >= 10 ** 1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (unsignedRoundsUp(rounding) && 10 ** result < value ? 1 : 0); } } /** * @dev Return the log in base 256 of a positive value rounded towards zero. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 256, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (unsignedRoundsUp(rounding) && 1 << (result << 3) < value ? 1 : 0); } } /** * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers. */ function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) { return uint8(rounding) % 2 == 1; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/math/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); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/Nonces.sol) 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 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 { uint256 current = _useNonce(owner); if (nonce != current) { revert InvalidAccountNonce(owner, current); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.0) (utils/ReentrancyGuard.sol) pragma solidity ^0.8.20; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied to functions to make sure there are no nested * (reentrant) calls to them. * * Note that because there is a single `nonReentrant` guard, functions marked as * `nonReentrant` may not call one another. This can be worked around by making * those functions `private`, and then adding `external` `nonReentrant` entry * points to them. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant NOT_ENTERED = 1; uint256 private constant ENTERED = 2; uint256 private _status; /** * @dev Unauthorized reentrant call. */ error ReentrancyGuardReentrantCall(); constructor() { _status = NOT_ENTERED; } /** * @dev Prevents a contract from calling itself, directly or indirectly. * Calling a `nonReentrant` function from another `nonReentrant` * function is not supported. It is possible to prevent this from happening * by making the `nonReentrant` function external, and making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be NOT_ENTERED if (_status == ENTERED) { revert ReentrancyGuardReentrantCall(); } // Any calls to nonReentrant after this point will fail _status = ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = NOT_ENTERED; } /** * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a * `nonReentrant` function in the call stack. */ function _reentrancyGuardEntered() internal view returns (bool) { return _status == ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v5.0.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 v5.0.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 v5.0.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: BUSL-1.1 pragma solidity 0.8.24; interface IDelegatePlan { function delegate(uint256 planId, address delegatee) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.24; interface IERC20Votes { function delegate(address delegatee) external; function delegates(address wallet) external view returns (address delegate); function delegateBySig(address delegatee, uint256 nonce, uint256 expiry, uint8 v, bytes32 r, bytes32 s) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.24; interface ILockupPlans { function createPlan( address recipient, address token, uint256 amount, uint256 start, uint256 cliff, uint256 rate, uint256 period ) external returns (uint256); }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.24; interface IVestingPlans { function createPlan( address recipient, address token, uint256 amount, uint256 start, uint256 cliff, uint256 rate, uint256 period, address vestingAdmin, bool adminTransferOBO ) external returns (uint256); function changeVestingPlanAdmin(uint256 planId, address newVestingAdmin) external; }
// SPDX-License-Identifier: BUSL-1.1 pragma solidity 0.8.24; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol'; library TransferHelper { using SafeERC20 for IERC20; /// @notice Internal function used for standard ERC20 transferFrom method /// @notice it contains a pre and post balance check /// @notice as well as a check on the msg.senders balance /// @param token is the address of the ERC20 being transferred /// @param from is the remitting address /// @param to is the location where they are being delivered function transferTokens( address token, address from, address to, uint256 amount ) internal { uint256 priorBalance = IERC20(token).balanceOf(address(to)); require(IERC20(token).balanceOf(from) >= amount, 'THL01'); SafeERC20.safeTransferFrom(IERC20(token), from, to, amount); uint256 postBalance = IERC20(token).balanceOf(address(to)); require(postBalance - priorBalance == amount, 'THL02'); } /// @notice Internal function is used with standard ERC20 transfer method /// @notice this function ensures that the amount received is the amount sent with pre and post balance checking /// @param token is the ERC20 contract address that is being transferred /// @param to is the address of the recipient /// @param amount is the amount of tokens that are being transferred function withdrawTokens( address token, address to, uint256 amount ) internal { uint256 priorBalance = IERC20(token).balanceOf(address(to)); SafeERC20.safeTransfer(IERC20(token), to, amount); uint256 postBalance = IERC20(token).balanceOf(address(to)); require(postBalance - priorBalance == amount, 'THL02'); } }
{ "optimizer": { "enabled": true, "runs": 200 }, "viaIR": true, "evmVersion": "paris", "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"},{"internalType":"address[]","name":"_tokenLockups","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"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":[],"name":"FailedInnerCall","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":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"string","name":"str","type":"string"}],"name":"StringTooLong","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes16","name":"id","type":"bytes16"}],"name":"CampaignCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes16","name":"id","type":"bytes16"},{"components":[{"internalType":"address","name":"manager","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"end","type":"uint256"},{"internalType":"enum DelegatedClaimCampaigns.TokenLockup","name":"tokenLockup","type":"uint8"},{"internalType":"bytes32","name":"root","type":"bytes32"},{"internalType":"bool","name":"delegating","type":"bool"}],"indexed":false,"internalType":"struct DelegatedClaimCampaigns.Campaign","name":"campaign","type":"tuple"},{"indexed":false,"internalType":"uint256","name":"totalClaimers","type":"uint256"}],"name":"CampaignStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes16","name":"id","type":"bytes16"},{"components":[{"internalType":"address","name":"tokenLocker","type":"address"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"cliff","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"periods","type":"uint256"}],"indexed":false,"internalType":"struct DelegatedClaimCampaigns.ClaimLockup","name":"claimLockup","type":"tuple"}],"name":"ClaimLockupCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":true,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claimed","type":"event"},{"anonymous":false,"inputs":[],"name":"EIP712DomainChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes16","name":"id","type":"bytes16"},{"indexed":true,"internalType":"address","name":"claimer","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountClaimed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountRemaining","type":"uint256"}],"name":"LockedTokensClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes16","name":"id","type":"bytes16"},{"indexed":true,"internalType":"address","name":"claimer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountClaimed","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountRemaining","type":"uint256"}],"name":"UnlockedTokensClaimed","type":"event"},{"inputs":[{"internalType":"bytes16","name":"","type":"bytes16"}],"name":"campaigns","outputs":[{"internalType":"address","name":"manager","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"end","type":"uint256"},{"internalType":"enum DelegatedClaimCampaigns.TokenLockup","name":"tokenLockup","type":"uint8"},{"internalType":"bytes32","name":"root","type":"bytes32"},{"internalType":"bool","name":"delegating","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes16[]","name":"campaignIds","type":"bytes16[]"}],"name":"cancelCampaigns","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes16","name":"campaignId","type":"bytes16"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"claimAmount","type":"uint256"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes16","name":"campaignId","type":"bytes16"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"uint256","name":"claimAmount","type":"uint256"},{"internalType":"address","name":"delegatee","type":"address"},{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct DelegatedClaimCampaigns.SignatureParams","name":"delegationSignature","type":"tuple"}],"name":"claimAndDelegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes16","name":"campaignId","type":"bytes16"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"address","name":"claimer","type":"address"},{"internalType":"uint256","name":"claimAmount","type":"uint256"},{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct DelegatedClaimCampaigns.SignatureParams","name":"claimSignature","type":"tuple"},{"internalType":"address","name":"delegatee","type":"address"},{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct DelegatedClaimCampaigns.SignatureParams","name":"delegationSignature","type":"tuple"}],"name":"claimAndDelegateWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes16","name":"","type":"bytes16"}],"name":"claimLockups","outputs":[{"internalType":"address","name":"tokenLocker","type":"address"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"cliff","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"periods","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes16[]","name":"campaignIds","type":"bytes16[]"},{"internalType":"bytes32[][]","name":"proofs","type":"bytes32[][]"},{"internalType":"uint256[]","name":"claimAmounts","type":"uint256[]"}],"name":"claimMultiple","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes16[]","name":"campaignIds","type":"bytes16[]"},{"internalType":"bytes32[][]","name":"proofs","type":"bytes32[][]"},{"internalType":"address","name":"claimer","type":"address"},{"internalType":"uint256[]","name":"claimAmounts","type":"uint256[]"},{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct DelegatedClaimCampaigns.SignatureParams","name":"claimSignature","type":"tuple"}],"name":"claimMultipleWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes16","name":"campaignId","type":"bytes16"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"address","name":"claimer","type":"address"},{"internalType":"uint256","name":"claimAmount","type":"uint256"},{"components":[{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct DelegatedClaimCampaigns.SignatureParams","name":"claimSignature","type":"tuple"}],"name":"claimWithSig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes16","name":"","type":"bytes16"},{"internalType":"address","name":"","type":"address"}],"name":"claimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes16","name":"id","type":"bytes16"},{"components":[{"internalType":"address","name":"manager","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"end","type":"uint256"},{"internalType":"enum DelegatedClaimCampaigns.TokenLockup","name":"tokenLockup","type":"uint8"},{"internalType":"bytes32","name":"root","type":"bytes32"},{"internalType":"bool","name":"delegating","type":"bool"}],"internalType":"struct DelegatedClaimCampaigns.Campaign","name":"campaign","type":"tuple"},{"components":[{"internalType":"address","name":"tokenLocker","type":"address"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"cliff","type":"uint256"},{"internalType":"uint256","name":"period","type":"uint256"},{"internalType":"uint256","name":"periods","type":"uint256"}],"internalType":"struct DelegatedClaimCampaigns.ClaimLockup","name":"claimLockup","type":"tuple"},{"internalType":"address","name":"vestingAdmin","type":"address"},{"internalType":"uint256","name":"totalClaimers","type":"uint256"}],"name":"createLockedCampaign","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes16","name":"id","type":"bytes16"},{"components":[{"internalType":"address","name":"manager","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"end","type":"uint256"},{"internalType":"enum DelegatedClaimCampaigns.TokenLockup","name":"tokenLockup","type":"uint8"},{"internalType":"bytes32","name":"root","type":"bytes32"},{"internalType":"bool","name":"delegating","type":"bool"}],"internalType":"struct DelegatedClaimCampaigns.Campaign","name":"campaign","type":"tuple"},{"internalType":"uint256","name":"totalClaimers","type":"uint256"}],"name":"createUnlockedCampaign","outputs":[],"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":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"tokenLockers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes16","name":"","type":"bytes16"}],"name":"usedIds","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"root","type":"bytes32"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"address","name":"claimer","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"verify","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"}]
Contract Creation Code
610160604090808252346200024d57620044c0803803809162000023828562000268565b833981016060828203126200024d5781516001600160401b0393908481116200024d578262000054918501620002b1565b906020808501518681116200024d578462000071918701620002b1565b9482810151908782116200024d570184601f820112156200024d5780519487861162000252576005918660051b90855197620000b08684018a62000268565b885284808901928201019283116200024d578401905b8282106200022c5750505060019160009160018355620000e6866200030c565b96610120978852620000f889620004c4565b96610140978852838151910120988960e0528381519101209861010099808b524660a052875190858201927f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f84528983015260608201524660808201523060a082015260a0815260c081019b818d10908d111762000218578798999a9b8798525190206080523060c05283945b620001d9575b5050505050505191613ea493846200061c8539608051846137c9015260a05184613894015260c05184613793015260e051846138180152518361383e01525182611208015251816112310152f35b8051851015620002125784821b81018301516001600160a01b0316845260048352868420805460ff191687179055938501938562000185565b6200018b565b634e487b7160e01b86526041600452602486fd5b81516001600160a01b03811681036200024d578152908401908401620000c6565b600080fd5b634e487b7160e01b600052604160045260246000fd5b601f909101601f19168101906001600160401b038211908210176200025257604052565b60005b838110620002a05750506000910152565b81810151838201526020016200028f565b81601f820112156200024d5780516001600160401b038111620002525760405192620002e8601f8301601f19166020018562000268565b818452602082840101116200024d576200030991602080850191016200028c565b90565b8051602090818110156200038a5750601f8251116200034857808251920151908083106200033957501790565b82600019910360031b1b161790565b6044906200037c9260405193849263305a27a960e01b8452806004850152825192839182602487015286860191016200028c565b601f01601f19168101030190fd5b9192916001600160401b038111620002525760019182548381811c91168015620004b9575b82821014620004a357601f81116200046a575b5080601f831160011462000402575081929394600092620003f6575b5050600019600383901b1c191690821b17905560ff90565b015190503880620003de565b90601f198316958460005282600020926000905b88821062000452575050838596971062000438575b505050811b01905560ff90565b015160001960f88460031b161c191690553880806200042b565b80878596829496860151815501950193019062000416565b8360005283601f83600020920160051c820191601f850160051c015b82811062000496575050620003c2565b6000815501849062000486565b634e487b7160e01b600052602260045260246000fd5b90607f1690620003af565b805160209081811015620004f15750601f8251116200034857808251920151908083106200033957501790565b906001600160401b0382116200025257600254926001938481811c9116801562000610575b83821014620004a357601f8111620005d6575b5081601f84116001146200056a57509282939183926000946200055e575b50501b916000199060031b1c19161760025560ff90565b01519250388062000547565b919083601f198116600260005284600020946000905b88838310620005bb5750505010620005a1575b505050811b0160025560ff90565b015160001960f88460031b161c1916905538808062000593565b85870151885590960195948501948793509081019062000580565b600260005284601f84600020920160051c820191601f860160051c015b8281106200060357505062000529565b60008155018590620005f3565b90607f16906200051656fe6080604052600436101561001257600080fd5b60003560e01c806301a36e74146117c6578063150b7a0214611738578063215506d5146114d05780634a3067b9146113d957806350b4aebe146113365780637ecebe00146112fc57806384b0196e146111f2578063857c2c3114610ec0578063891f4e4214610de857806398a87e7f14610827578063bcecbd9d146107e7578063cff144f714610794578063d4b52e0b146105d8578063d69564fb14610425578063d6eecb00146103b7578063eb58c5fe1461035a578063f0e1a347146101265763f4285c3c146100e257600080fd5b34610121576020366003190112610121576001600160a01b03610103611aa0565b166000526004602052602060ff604060002054166040519015158152f35b600080fd5b34610121576101e036600319011261012157610140611bd0565b6024356001600160401b0381116101215761015f903690600401611cd3565b610167611a8a565b61017036611b69565b90610179611acc565b9360a036610143190112610121576040519261019484611aff565b61014435845261016435602085015260ff61018435166101843503610121576101843560408501526101a43560608501526101c43560808501526101d661229b565b6001600160a01b03906102dd906102d68884166101f48115156120f5565b6001600160801b03198616948560005260096020526102cf6102c66102ad604060002094848c16958660005260205261023560ff6040600020541615611e29565b6020880161024581514210611d7c565b885190516040519160208301937f640a59a20906a79f8bd88ba47b4f8870df6f557ab421b6dc70f365a62d801cbc85528d6040850152896060850152606435608085015260a084015260c083015260e082015260e081526102a581611ae3565b5190206122be565b60ff6040880151166060880151906080890151926138ba565b9092919261394a565b1614611ddd565b51846122e4565b600052600560205260ff6005604060002001541660038110156103445761032f576103289483519060208501519260ff604087015116946080606088015197015197606435926134d2565b6001600055005b915061033f939260643592612d82565b610328565b634e487b7160e01b600052602160045260246000fd5b3461012157604036600319011261012157610373611bd0565b61037b611ab6565b906001600160801b031916600052600960205260406000209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b34610121576020366003190112610121576001600160801b03196103d9611bd0565b16600052600660205260a06040600020600180831b0381541690600181015490600281015460046003830154920154926040519485526020850152604084015260608301526080820152f35b34610121576101203660031901126101215761043f611bd0565b6001600160401b036024358181116101215761045f903690600401611a5a565b9092610469611a8a565b916064359361047736611b69565b9061048061229b565b6001600160801b03198416806000526020916009835260406000209360018060a01b0391828916958660005285526104c060ff6040600020541615611e29565b83600052600585526104dd60ff6007604060002001541615611e67565b848201956104ed87514210611d7c565b825196519360405194878601987f4b614858b2ad407d12dcaf770b145488ee78f1b566a389e1b49f074ba73318b58a528760408801528360608801528d608088015260a087015260c086015260c0855260e0850192858410908411176105c2576102cf6102c66102ad60059a6105739861056c976040525190206122be565b51876122e4565b6000525260ff600560406000200154166003811015610344576105ad576105a59461059f913691611c85565b90612998565b506001600055005b61033f946105bc913691611c85565b906124bf565b634e487b7160e01b600052604160045260246000fd5b34610121576060366003190112610121576001600160401b0360043581811161012157610609903690600401611a5a565b60249291929160243581811161012157610627903690600401611a5a565b909160443590811161012157610641903690600401611a5a565b93909561064c61229b565b610657838314611d3e565b610662858314611d3e565b60005b828110610673576001600055005b6001600160801b03198061069061068b848787611db8565b611dc8565b16600052602060098152604060002033600052815260ff916106b9836040600020541615611e29565b806106c861068b868989611db8565b1660005260059182918282526106e8856007604060002001541615611e67565b6106f661068b878a8a611db8565b16600052526040600020015416600381101561077f5790808988888888886001981560001461075d57956107428161059f9461073c61068b8361074a976107559d611db8565b96611ea3565b959096611db8565b359333933691611c85565b505b01610665565b95610742816105bc9461073c61068b8361074a9761077a9d611db8565b610757565b87634e487b7160e01b60005260216004526000fd5b34610121576080366003190112610121576024356001600160401b038111610121576107dd6107c96020923690600401611cd3565b6107d1611a8a565b606435916004356121b1565b6040519015158152f35b34610121576020366003190112610121576001600160801b0319610809611bd0565b166000526007602052602060ff604060002054166040519015158152f35b346101215761020036600319011261012157610841611bd0565b61084a36611be7565b9060a0366101231901126101215760405161086481611aff565b61086c611acc565b81526101443560208201526101643560408201526101843560608201526101a43560808201526101c4356001600160a01b0381168103610121576108ae61229b565b6001600160801b0319831660005260076020526108d360ff6040600020541615611ee7565b6108e86001600160801b031984161515611f1c565b6001600160801b031983166000908152600760209081526040909120805460ff19166001179055840151610926906001600160a01b03161515611f4e565b835161093c906001600160a01b03161515611f86565b61094b60408501511515611fbe565b61096360808501514281119081610dda575b50611ff5565b60a084015160038110156103445715610dab57608082015115610d7a57606082015115610d4a5781516001600160a01b031660009081526004602052604090205460ff1615610d145760e0840151610c85575b60a0840151600381101561034457600214610c0b575b5080516001600160a01b031615610bd457602083015160408401516109fd91309033906001600160a01b0316612bba565b6001600160801b031982166000526006602052604060002060018060a01b038251166001600160601b0360a01b82541617815560208201516001820155604082015160028201556060820151600382015560046080830151910155600560205260406000209160018060a01b038451166001600160601b0360a01b8454161783556001830160018060a01b036020860151166001600160601b0360a01b825416179055604084015160028401556060840151600384015560808401516004840155600583019160a08501516003811015610344577fc1d41f85682afff3c8291bb0c88f077fa6a77781d61c4941bd0344a6b780db9c94610bca94610b2d9260ff8019835416911617905560c08701516006820155600760e0880151151591019060ff801983541691151516179055565b6001600160801b0319821660005260086020524360406000205560806040519160018060a01b038151168352602081015160208401526040810151604084015260608101516060840152015160808201527fce04f3b9b2dfc43b1d1e78376db74a3b32c0a78daaf34efc81334908359448fc60a06001600160801b0319841692a26040519182916001600160801b031916946101e4359083612086565b0390a26001600055005b60405162461bcd60e51b815260206004820152600f60248201526e34b73b30b634b232903637b1b5b2b960891b6044820152606490fd5b6001600160a01b03811615610c56576001600160801b031983166000908152600a6020526040902080546001600160a01b0319166001600160a01b03909216919091179055836109cc565b60405162461bcd60e51b8152602060048201526007602482015266182fb0b236b4b760c91b6044820152606490fd5b602084810151604051632c3e6f0f60e11b81523060048201529190829060249082906001600160a01b03165afa8015610d0857610cd491600091610cd9575b506001600160a01b03161561204c565b6109b6565b610cfb915060203d602011610d01575b610cf38183611b48565b81019061202d565b86610cc4565b503d610ce9565b6040513d6000823e3d90fd5b60405162461bcd60e51b815260206004820152600e60248201526d34b73b30b634b2103637b1b5b2b960911b6044820152606490fd5b60405162461bcd60e51b81526020600482015260086024820152670c17dc195c9a5bd960c21b6044820152606490fd5b60405162461bcd60e51b8152602060048201526009602482015268305f706572696f647360b81b6044820152606490fd5b60405162461bcd60e51b8152602060048201526007602482015266085b1bd8dad95960ca1b6044820152606490fd5b90506060860151108661095d565b3461012157606036600319011261012157610e01611bd0565b6024356001600160401b03811161012157610e20903690600401611a5a565b60449291923591610e2f61229b565b6001600160801b03198116806000526009602052604060002033600052602052610e6160ff6040600020541615611e29565b806000526005602052610e7f60ff6007604060002001541615611e67565b600052600560205260ff60056040600020015416600381101561034457610eb05761059f6105a59433933691611c85565b6105bc61033f9433933691611c85565b346101215760208060031936011261012157600435906001600160401b038211610121573660238301121561012157816004013591602490610f0184611c6e565b90610f0f6040519283611b48565b848252838201602460059660051b8301019136831161012157602401905b8282106111d257505050610f3f61229b565b60005b8151811015610328576001600160801b03199081610f60828561212f565b5116600052858552604060002091604051610f7a81611ae3565b60018060a01b03808554168252806001860154168883019081526002860154926040810193845260038088015460608301526004880154608083015260ff90818d8a015416908110156111bd5760a083015260076006988981015460c0850152015416151560e082015282339151160361118e5783610ff9868961212f565b51166000526008895243604060002054101561115d57611065898383511686611022898c61212f565b51166000908152898352604090819020549051636eb1769f60e11b81523060048201529086166001600160a01b0316602482015292839190829081906044820190565b03915afa908115610d0857600091611127575b509060019661108c6110f095949315612143565b85611097888b61212f565b51166000528b8b526110ac6040600020612181565b856110b7888b61212f565b51166000528a526110e4604060002060046000918281558260018201558260028201558260038201550155565b511690519033906136a3565b6110fa828561212f565b51167f88511e0182a386da19fdcadcde158de4729b63240d9a034ce75f3cb0dc5288a5600080a201610f42565b93929190508984813d8311611156575b6111418183611b48565b81010312610121579251919290916001611078565b503d611137565b60405162461bcd60e51b8152600481018a9052600a818a01526973616d6520626c6f636b60b01b6044820152606490fd5b60405162461bcd60e51b8152600481018a90526008818a01526710b6b0b730b3b2b960c11b6044820152606490fd5b8a634e487b7160e01b60005260216004526000fd5b81356001600160801b031981168103610121578152908501908501610f2d565b346101215760003660031901126101215761122c7f0000000000000000000000000000000000000000000000000000000000000000613b2f565b6112557f0000000000000000000000000000000000000000000000000000000000000000613c59565b6040516020808201928284106001600160401b038511176105c2579160206112af85946112a1979660405260008452604051978897600f60f81b895260e0858a015260e0890190611cfe565b908782036040890152611cfe565b91466060870152306080870152600060a087015285830360c0870152519182815201929160005b8281106112e557505050500390f35b8351855286955093810193928101926001016112d6565b34610121576020366003190112610121576001600160a01b0361131d611aa0565b1660005260036020526020604060002054604051908152f35b34610121576020366003190112610121576001600160801b0319611358611bd0565b166000526005602052610100604060002060018060a01b03908181541691600182015416906113cb6002820154600383015460048401549060ff6005860154169260ff600760068801549701541696604051988952602089015260408801526060870152608086015260a0850190611cf1565b60c0830152151560e0820152f35b3461012157610120366003190112610121576113f3611bd0565b6024356001600160401b03811161012157611412903690600401611cd3565b606435916001600160a01b038316906044358285036101215761144761143736611b69565b9361144061229b565b15156120f5565b6001600160801b0319821680600052600960205260406000203360005260205261147960ff6040600020541615611e29565b600052600560205260ff600560406000200154166003811015610344576114c2576103289483519060208501519260ff60408701511694608060608801519701519733916134d2565b915061033f93923391612d82565b3461012157610140366003190112610121576114ea611bd0565b6114f336611be7565b906114fc61229b565b6001600160801b031916908160005260206007815261152360ff6040600020541615611ee7565b61152e831515611f1c565b826000526007815260406000209160ff19926001848254161790558181019160018060a01b0390611563828551161515611f4e565b611571828451161515611f86565b604083019161158283511515611fbe565b6080840161159a8151428111908161172a5750611ff5565b60a085019384516003811015610344576116fc5760e0860196875161169d575b6115cd8482511683519030903390612bba565b896000526005855260406000209380885116906001600160601b0360a01b9182875416178655600186019251169082541617905551600283015560608501516003830155516004820155600581019251906003821015610344576007610bca96856116809460ff7fc1d41f85682afff3c8291bb0c88f077fa6a77781d61c4941bd0344a6b780db9c9b6008995416911617905560c0870151600684015551151591019060ff801983541691151516179055565b856000525243604060002055604051918291610124359083612086565b6024858583511660405192838092632c3e6f0f60e11b82523060048301525afa908115610d08576116da9186916000916116df575b50161561204c565b6115ba565b6116f69150883d8a11610d0157610cf38183611b48565b8d6116d2565b60405162461bcd60e51b81526004810185905260066024820152651b1bd8dad95960d21b6044820152606490fd5b90506060870151108a61095d565b3461012157608036600319011261012157611751611aa0565b5061175a611ab6565b506064356001600160401b03811161012157366023820112156101215780600401359061178682611bb5565b916117946040519384611b48565b8083523660248284010111610121576000928160246020940184830137010152604051630a85bd0160e11b8152602090f35b3461012157610120366003190112610121576001600160401b03600435818111610121576117f8903690600401611a5a565b60249291923582811161012157611813903690600401611a5a565b9261181c611a8a565b9060643590811161012157611835903690600401611a5a565b92909361184136611b69565b9561184a61229b565b611855818314611d3e565b611860858314611d3e565b60209687810161187281514210611d7c565b8315611a44576118818a611dc8565b908715611a44576119358361192e8b61190b8e8c9851965190604051908101917fe0834d61096d4599076d6c957b5b672653288def456b9f887441a132f0e6bf6f83526001600160801b0319809a16604083015260018060a01b03809b1698899586606085015235608084015260a083015260c08201528b60e082015260e081526102a581611ae3565b966102cf6102c660ff9960ff6040880151166060880151906080890151926138ba565b51886122e4565b60005b858110611946576001600055005b838b846119b78f858b828561196261068b858561068b98611db8565b166000526009875260406000208a6000528752611986886040600020541615611e29565b8561199561068b858585611db8565b1660005260058097526119b2886007604060002001541615611e67565b611db8565b16600052808d526040600020015416906003821015610344578a8a8a8f848a8c8e9360019915600014611a215792611a0881611a199994611a0261068b83611a109761059f9a611db8565b97611ea3565b979093611db8565b35943691611c85565b505b01611938565b92611a0881611a3f9994611a0261068b83611a10976105bc9a611db8565b611a1b565b634e487b7160e01b600052603260045260246000fd5b9181601f84011215610121578235916001600160401b038311610121576020808501948460051b01011161012157565b604435906001600160a01b038216820361012157565b600435906001600160a01b038216820361012157565b602435906001600160a01b038216820361012157565b61012435906001600160a01b038216820361012157565b61010081019081106001600160401b038211176105c257604052565b60a081019081106001600160401b038211176105c257604052565b6001600160401b0381116105c257604052565b604081019081106001600160401b038211176105c257604052565b90601f801991011681019081106001600160401b038211176105c257604052565b60a09060831901126101215760405190611b8282611aff565b81608435815260a435602082015260c43560ff8116810361012157604082015260e4356060820152608061010435910152565b6001600160401b0381116105c257601f01601f191660200190565b600435906001600160801b03198216820361012157565b6101009060231901126101215760405190611c0182611ae3565b816001600160a01b03602435818116810361012157825260443590811681036101215760208201526064356040820152608435606082015260a435608082015260c43560038110156101215760a082015260e43560c0820152610104359081151582036101215760e00152565b6001600160401b0381116105c25760051b60200190565b9291611c9082611c6e565b91611c9e6040519384611b48565b829481845260208094019160051b810192831161012157905b828210611cc45750505050565b81358152908301908301611cb7565b9080601f8301121561012157816020611cee93359101611c85565b90565b9060038210156103445752565b919082519283825260005b848110611d2a575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201611d09565b15611d4557565b60405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b6044820152606490fd5b15611d8357565b60405162461bcd60e51b815260206004820152600d60248201526c18db185a5b48195e1c1a5c9959609a1b6044820152606490fd5b9190811015611a445760051b0190565b356001600160801b0319811681036101215790565b15611de457565b60405162461bcd60e51b815260206004820152601760248201527f696e76616c696420636c61696d207369676e61747572650000000000000000006044820152606490fd5b15611e3057565b60405162461bcd60e51b815260206004820152600f60248201526e185b1c9958591e4818db185a5b5959608a1b6044820152606490fd5b15611e6e57565b60405162461bcd60e51b815260206004820152600d60248201526c6d7573742064656c656761746560981b6044820152606490fd5b9190811015611a445760051b81013590601e19813603018212156101215701908135916001600160401b038311610121576020018260051b36038113610121579190565b15611eee57565b60405162461bcd60e51b8152602060048201526006602482015265696e2075736560d01b6044820152606490fd5b15611f2357565b606460405162461bcd60e51b81526020600482015260046024820152630c17da5960e21b6044820152fd5b15611f5557565b60405162461bcd60e51b8152602060048201526009602482015268305f6164647265737360b81b6044820152606490fd5b15611f8d57565b60405162461bcd60e51b8152602060048201526009602482015268182fb6b0b730b3b2b960b91b6044820152606490fd5b15611fc557565b60405162461bcd60e51b81526020600482015260086024820152670c17d85b5bdd5b9d60c21b6044820152606490fd5b15611ffc57565b60405162461bcd60e51b815260206004820152600960248201526832b7321032b93937b960b91b6044820152606490fd5b9081602091031261012157516001600160a01b03811681036101215790565b1561205357565b60405162461bcd60e51b815260206004820152600b60248201526a216572633230766f74657360a81b6044820152606490fd5b610100909392919360e061012082019560018060a01b0380825116845260208201511660208401526040810151604084015260608101516060840152608081015160808401526120de60a082015160a0850190611cf1565b60c081015160c08401520151151560e08201520152565b156120fc57565b60405162461bcd60e51b815260206004820152600b60248201526a305f64656c65676174656560a81b6044820152606490fd5b8051821015611a445760209160051b010190565b1561214a57565b60405162461bcd60e51b815260206004820152600f60248201526e30b63637bbb0b731b29032b93937b960891b6044820152606490fd5b60076000918281558260018201558260028201558260038201558260048201558260058201558260068201550155565b604080516001600160a01b03909416602080860191825285830196909652929591949093919290916121f081606081015b03601f198101835282611b48565b51902060405182810191825282815261220881611b2d565b519020916000925b865184101561225557612223848861212f565b51908560008383101561224657505060005282526001846000205b930192612210565b9091600193825285522061223e565b92509450929150036122675750600190565b6064906040519062461bcd60e51b82526004820152600d60248201526c24b73b30b634b210383937b7b360991b6044820152fd5b6002600054146122ac576002600055565b604051633ee5aeb560e01b8152600490fd5b6042906122c9613790565b906040519161190160f01b8352600283015260228201522090565b6001600160a01b038116600090815260036020526040902080546001810190915591829003612311575050565b6040516301d4b62360e61b81526001600160a01b039190911660048201526024810191909152604490fd5b1561234357565b60405162461bcd60e51b8152602060048201526008602482015267085cdd185c9d195960c21b6044820152606490fd5b1561237a57565b60405162461bcd60e51b815260206004820152600e60248201526d18d85b5c185a59db88195b99195960921b6044820152606490fd5b156123b757565b60405162461bcd60e51b815260206004820152600960248201526821656c696769626c6560b81b6044820152606490fd5b156123ef57565b60405162461bcd60e51b815260206004820152601160248201527018d85b5c185a59db881d5b999d5b991959607a1b6044820152606490fd5b9190820391821161243557565b634e487b7160e01b600052601160045260246000fd5b8115612455570690565b634e487b7160e01b600052601260045260246000fd5b8115612455570490565b94600197929461010097929a999461012088019b8a8060a01b0397888092168a5216602089015260408801526060870152608086015260a085015260c08401521660e08201520152565b919290926001600160801b031983166000526005602052604060002093604051946124e986611ae3565b80546001600160a01b039081168752600182015416602087015260028101546040870152600380820154606088015260048201546080880152600582015460ff16908110156103445760ff9160079160a0890152600681015460c0890152015416151560e08601526001600160801b0319841660005260066020526125e06125db848460406000209460046040519661258188611aff565b60018060a01b038154168852600181015460208901526002810154604089015260038101546060890152015460808701526125c260608b015142101561233c565b6125d14260808c015111612373565b60c08a01516121b1565b6123b0565b6125f083604087015110156123e8565b6001600160801b0319841660008181526009602090815260408083206001600160a01b03871684528252808320805460ff1916600117905592825260059052206002018054612640908590612428565b90556001600160801b031984166000526005602052604060002060028101541561295e575b5061267460808201518461244b565b61292e5761268660808201518461246b565b602082015180612928575042905b602087015183516126b39187916001600160a01b0390811691166139b9565b60a0870151600381101561034457602091869160010361286c5784518984015160408088015160608901519151632744bf0b60e11b81526001600160a01b038b81166004830152938416602482015260448101969096526064860197909752608485019690965260a484019290925260c48301949094529092839160e4918391600091165af1908115610d0857600091612838575b5061278c91602091965b8201519051604051636eb1769f60e11b81523060048201526001600160a01b03918216602482015293849290911690829081906044820190565b03915afa908115610d08576000916127f8575b50600080516020613e4f833981519152916127bc60409215612143565b6001600160801b03198516600052600560205260028260002001548251948552602085015260018060a01b0316936001600160801b03191692a4565b90506020813d602011612830575b8161281360209383611b48565b810103126101215751600080516020613e4f83398151915261279f565b3d9150612806565b90506020813d602011612864575b8161285360209383611b48565b81010312610121575161278c612748565b3d9150612846565b60018060a01b03855116906000876128d38c8760018060a01b0391015116938c60408b01519160608c0151916001600160801b0319168652600a8a5260018060a01b03604087205416926040519b8c9a8b998a9863050fbad760e01b8a5260048a01612475565b03925af1908115610d08576000916128f4575b5061278c9160209196612752565b90506020813d602011612920575b8161290f60209383611b48565b81010312610121575161278c6128e6565b3d9150612902565b90612694565b61293c60808201518461246b565b600181018091111561268657634e487b7160e01b600052601160045260246000fd5b61296790612181565b6006602052612992604060002060046000918281558260018201558260028201558260038201550155565b38612665565b9190916001600160801b031916600093818552602090600582526040918287209683516129c481611ae3565b60018060a01b03988981541682528960018201541698848301998a526002820154918784019283526003810154606085019081526004820154906080860191825260ff6005840154169560a08101966003811015612b72578a95612a7397958f92612a6b96612a5c6125db978b97612a65948f5260e060ff600760068901549860c08501998a5201541615159101525142101561233c565b42905111612373565b516121b1565b5110156123e8565b516003811015612b5e57612b2e579060028483877feda9c5842f9de63a524e4bafcab717969b8cfdb8bbd1533e39497520dbc112759796955260098452612b06858383209a8d81169b8c85528752848420600160ff198254161790558a8452600587528585852001612ae6838254612428565b90558a8452600587528484208681015415612b1f575b508d8d51166136a3565b87815260058452200154908351928352820152a3511690565b612b2890612181565b38612afc565b835162461bcd60e51b8152600481018390526009602482015268085d5b9b1bd8dad95960ba1b6044820152606490fd5b634e487b7160e01b82526021600452602482fd5b634e487b7160e01b89526021600452602489fd5b15612b8d57565b60405162461bcd60e51b81526020600482015260056024820152642a2426181960d91b6044820152606490fd5b604080516370a0823160e01b8082526001600160a01b038087166004840181905292979693959481169460209491858a6024818a5afa998a15612d485760009a612d53575b508751908482528216600482015285816024818a5afa908115612d4857908991600091612d17575b5010612ceb5786516323b872dd60e01b868201526001600160a01b039182166024808301919091529290911660448201526064810188905284939290612c7a90612c7481608481016121e2565b87613d49565b86519586938492835260048301525afa928315612ce15750600092612cb1575b5050612caf92612ca991612428565b14612b86565b565b90809250813d8311612cda575b612cc88183611b48565b81010312610121575182612ca9612c9a565b503d612cbe565b513d6000823e3d90fd5b865162461bcd60e51b815260048101869052600560248201526454484c303160d81b6044820152606490fd5b809250878092503d8311612d41575b612d308183611b48565b810103126101215788905138612c27565b503d612d26565b88513d6000823e3d90fd5b9099508581813d8311612d7b575b612d6b8183611b48565b8101031261012157519838612bff565b503d612d61565b9290916000926001600160801b03198516845260056020526040842060405190612dab82611ae3565b80546001600160a01b039081168352600182015416602083015260028101546040830152600380820154606084015260048201546080840152600582015460ff16908110156134be5760ff9160079160a0850152600681015460c0850152015416151560e08201526001600160801b0319861685526006602052612e9b6125db85856040892095600460405197612e4189611aff565b60018060a01b038154168952600181015460208a0152600281015460408a0152600381015460608a015201546080880152612e82606087015142101561233c565b612e9142608088015111612373565b60c08601516121b1565b612eab84604083015110156123e8565b6001600160801b031986168086526009602090815260408088206001600160a01b03871689528252808820805460ff191660011790559187526005905285206002018054612efa908690612428565b90556001600160801b031986168552600560205260408520600281015415613485575b50612f2c60808301518561244b565b61345757612f3e60808301518561246b565b6020830151806134525750425b60208301518451612f6a9188916001600160a01b0390811691166139b9565b60a0830151600381101561343e576020919060010361324a5784518285015160408088015160608901519151632744bf0b60e11b81523060048201526001600160a01b039384166024820152604481018c90526064810195909552608485015260a484019590955260c48301949094529092839160e49183918b91165af19081156131e2578691613218575b508251909788916001600160a01b031690813b156132145760405163022eee0960e21b8152600481018490526001600160a01b039190911660248201529087908290604490829084905af18015613209579087916131f1575b505082516001600160a01b031690813b156131ed576040516323b872dd60e01b81523060048201526001600160a01b038616602482015260448101919091529086908290606490829084905af180156131e2579086916131ca575b50506020908101519151604051636eb1769f60e11b81523060048201526001600160a01b039182166024820152928391168180604481015b03915afa9081156131bf57849161317d575b5090600080516020613e4f8339815191529261311260409315612143565b8251946002908490836001600160a01b0386167fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a8380a36001600160801b0319891681526005602052200154908552602085015260018060a01b0316936001600160801b03191692a4565b9190506020823d6020116131b7575b8161319960209383611b48565b81010312610121579051600080516020613e4f8339815191526130f4565b3d915061318c565b6040513d86823e3d90fd5b6131d390611b1a565b6131de5784386130aa565b8480fd5b6040513d88823e3d90fd5b8680fd5b6131fa90611b1a565b61320557853861304f565b8580fd5b6040513d89823e3d90fd5b8780fd5b90506020813d602011613242575b8161323360209383611b48565b81010312610121575138612ff6565b3d9150613226565b60018060a01b0385511660018060a01b03838601511691898961329160408a01519560608b0151604051998a988997889663050fbad760e01b885230953060048a01612475565b03925af19081156131e257869161340c575b508251909788916001600160a01b031690813b156132145760405163022eee0960e21b8152600481018490526001600160a01b039190911660248201529087908290604490829084905af18015613209576133f9575b5082516001600160a01b0316803b156131ed576040516323b872dd60e01b81523060048201526001600160a01b0386166024820152604481018390529087908290606490829084905af18015613209579087916133e5575b505082516001600160801b031988168752600a60205260408720546001600160a01b0390811692911690813b15613214576040516323ed81fb60e01b815260048101919091526001600160a01b0392909216602483015286908290604490829084905af180156131e2579086916133d1575b50506130e291602091612752565b6133da90611b1a565b6131de5784386133c3565b6133ee90611b1a565b613205578538613351565b61340590969196611b1a565b94386132f9565b90506020813d602011613436575b8161342760209383611b48565b810103126132055751386132a3565b3d915061341a565b634e487b7160e01b88526021600452602488fd5b612f4b565b61346560808301518561246b565b6001810180911115612f3e57634e487b7160e01b86526011600452602486fd5b61348e90612181565b60066020526134b86040862060046000918281558260018201558260028201558260038201550155565b38612f1d565b634e487b7160e01b87526021600452602487fd5b92826134e592829b999598979698612998565b9260009660018060a01b0398898096169460409788519b8c96632c3e6f0f60e11b809852169b8c600482015260209a8b826024818c5afa918215613699578a9998979695949392918a918f8f909461367a575b505016998a911603613576575b5050505050505050505050807fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a91a3565b863b1561367657895163061e6d2960e51b8152600481018a90526024810195909552604485015260ff166064840152608483015260a4820152878160c48183875af1801561366c57613659575b508590602486518094819382528b60048301525afa90811561364f578691613632575b5016036135fb57808080808080808080613545565b60649250519062461bcd60e51b82526004820152601160248201527019195b1959d85d1a5bdb8819985a5b1959607a1b6044820152fd5b6136499150853d8711610d0157610cf38183611b48565b386135e6565b84513d88823e3d90fd5b96613665879298611b1a565b96906135c3565b86513d8a823e3d90fd5b8b80fd5b613691929450803d10610d0157610cf38183611b48565b91388e613538565b8b513d8f823e3d90fd5b6040516370a0823160e01b8082526001600160a01b03848116600484018190529295946020949091169291908487602481875afa968715610d085760009761375b575b5060405163a9059cbb60e01b818701526001600160a01b0390911660248281019190915260448201879052859392909161372d9061372781606481016121e2565b86613d49565b6040519485938492835260048301525afa918215610d0857600092612cb1575050612caf92612ca991612428565b9096508481819493943d8311613789575b6137768183611b48565b81010312610121575195909190846136e6565b503d61376c565b307f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03161480613891575b156137eb577f000000000000000000000000000000000000000000000000000000000000000090565b60405160208101907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f82527f000000000000000000000000000000000000000000000000000000000000000060408201527f000000000000000000000000000000000000000000000000000000000000000060608201524660808201523060a082015260a0815260c081018181106001600160401b038211176105c25760405251902090565b507f000000000000000000000000000000000000000000000000000000000000000046146137c2565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841161393e57926020929160ff608095604051948552168484015260408301526060820152600092839182805260015afa156139325780516001600160a01b0381161561392957918190565b50809160019190565b604051903d90823e3d90fd5b50505060009160039190565b6004811015610344578061395c575050565b600181036139765760405163f645eedf60e01b8152600490fd5b600281036139975760405163fce698f760e01b815260048101839052602490fd5b6003146139a15750565b602490604051906335e2f38360e21b82526004820152fd5b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152602094838216949192908682604481895afa918215610d0857600092613b00575b5081018091116124355760405163095ea7b360e01b8782018181526001600160a01b0385166024840152604480840194909452928252909590916000908190613a4760648a611b48565b88519082855af190613a57613dbb565b82613acd575b5081613ac2575b5015613a73575b505050505050565b604051958601521660248401526000604484015260448352608083018381106001600160401b038211176105c257613ab793613ab29160405282613d49565b613d49565b388080808080613a6b565b90503b151538613a64565b809192505190888215928315613ae8575b5050509038613a5d565b613af89350820181019101613d31565b388881613ade565b9091508681813d8311613b28575b613b188183611b48565b81010312610121575190386139fd565b503d613b0e565b60ff8114613b6d5760ff811690601f8211613b5b5760405191613b5183611b2d565b8252602082015290565b604051632cd44ac360e21b8152600490fd5b506040516000600190600154918260011c9060018416938415613c4f575b6020948584108114613c3b5783875286949392918115613c1b5750600114613bbc575b5050611cee92500382611b48565b9093915060016000527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6936000915b818310613c03575050611cee93508201013880613bae565b85548784018501529485019486945091830191613beb565b915050611cee94925060ff191682840152151560051b8201013880613bae565b634e487b7160e01b85526022600452602485fd5b91607f1691613b8b565b60ff8114613c7b5760ff811690601f8211613b5b5760405191613b5183611b2d565b5060405160006002549060018260011c9060018416938415613d27575b6020948584108114613c3b5783875286949392918115613c1b5750600114613cc8575050611cee92500382611b48565b9093915060026000527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace936000915b818310613d0f575050611cee93508201013880613bae565b85548784018501529485019486945091830191613cf7565b91607f1691613c98565b90816020910312610121575180151581036101215790565b600080613d729260018060a01b03169360208151910182865af1613d6b613dbb565b9083613deb565b8051908115159182613da0575b5050613d885750565b60249060405190635274afe760e01b82526004820152fd5b613db39250602080918301019101613d31565b153880613d7f565b3d15613de6573d90613dcc82611bb5565b91613dda6040519384611b48565b82523d6000602084013e565b606090565b90613e125750805115613e0057805190602001fd5b604051630a12f52160e11b8152600490fd5b81511580613e45575b613e23575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b15613e1b56feb73fa52621a0eab1e12dfeda1e46cb8d3faf8f59e22cf6c2610c680eced3ebc3a2646970667358221220f0814d03b4a5b289d5623c86f9dcc841d94bb5386bc2a2f0e9c87b6fe6d8510f64736f6c63430008180033000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000e436c61696d43616d706169676e730000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000002cde9919e81b20b4b33dd562a48a84b54c48f00c0000000000000000000000001bb64af7fe05fc69c740609267d2abe3e119ef820000000000000000000000001961a23409ca59eedca6a99c97e4087dad75248600000000000000000000000073cd8626b3cd47b009e68380720cfe6679a3ec3d000000000000000000000000a600ec7db69dfcd21f19face5b209a55eab7a7c0000000000000000000000000de8465d44ebfc761ee3525740e06c916886e1aeb
Deployed Bytecode
0x6080604052600436101561001257600080fd5b60003560e01c806301a36e74146117c6578063150b7a0214611738578063215506d5146114d05780634a3067b9146113d957806350b4aebe146113365780637ecebe00146112fc57806384b0196e146111f2578063857c2c3114610ec0578063891f4e4214610de857806398a87e7f14610827578063bcecbd9d146107e7578063cff144f714610794578063d4b52e0b146105d8578063d69564fb14610425578063d6eecb00146103b7578063eb58c5fe1461035a578063f0e1a347146101265763f4285c3c146100e257600080fd5b34610121576020366003190112610121576001600160a01b03610103611aa0565b166000526004602052602060ff604060002054166040519015158152f35b600080fd5b34610121576101e036600319011261012157610140611bd0565b6024356001600160401b0381116101215761015f903690600401611cd3565b610167611a8a565b61017036611b69565b90610179611acc565b9360a036610143190112610121576040519261019484611aff565b61014435845261016435602085015260ff61018435166101843503610121576101843560408501526101a43560608501526101c43560808501526101d661229b565b6001600160a01b03906102dd906102d68884166101f48115156120f5565b6001600160801b03198616948560005260096020526102cf6102c66102ad604060002094848c16958660005260205261023560ff6040600020541615611e29565b6020880161024581514210611d7c565b885190516040519160208301937f640a59a20906a79f8bd88ba47b4f8870df6f557ab421b6dc70f365a62d801cbc85528d6040850152896060850152606435608085015260a084015260c083015260e082015260e081526102a581611ae3565b5190206122be565b60ff6040880151166060880151906080890151926138ba565b9092919261394a565b1614611ddd565b51846122e4565b600052600560205260ff6005604060002001541660038110156103445761032f576103289483519060208501519260ff604087015116946080606088015197015197606435926134d2565b6001600055005b915061033f939260643592612d82565b610328565b634e487b7160e01b600052602160045260246000fd5b3461012157604036600319011261012157610373611bd0565b61037b611ab6565b906001600160801b031916600052600960205260406000209060018060a01b0316600052602052602060ff604060002054166040519015158152f35b34610121576020366003190112610121576001600160801b03196103d9611bd0565b16600052600660205260a06040600020600180831b0381541690600181015490600281015460046003830154920154926040519485526020850152604084015260608301526080820152f35b34610121576101203660031901126101215761043f611bd0565b6001600160401b036024358181116101215761045f903690600401611a5a565b9092610469611a8a565b916064359361047736611b69565b9061048061229b565b6001600160801b03198416806000526020916009835260406000209360018060a01b0391828916958660005285526104c060ff6040600020541615611e29565b83600052600585526104dd60ff6007604060002001541615611e67565b848201956104ed87514210611d7c565b825196519360405194878601987f4b614858b2ad407d12dcaf770b145488ee78f1b566a389e1b49f074ba73318b58a528760408801528360608801528d608088015260a087015260c086015260c0855260e0850192858410908411176105c2576102cf6102c66102ad60059a6105739861056c976040525190206122be565b51876122e4565b6000525260ff600560406000200154166003811015610344576105ad576105a59461059f913691611c85565b90612998565b506001600055005b61033f946105bc913691611c85565b906124bf565b634e487b7160e01b600052604160045260246000fd5b34610121576060366003190112610121576001600160401b0360043581811161012157610609903690600401611a5a565b60249291929160243581811161012157610627903690600401611a5a565b909160443590811161012157610641903690600401611a5a565b93909561064c61229b565b610657838314611d3e565b610662858314611d3e565b60005b828110610673576001600055005b6001600160801b03198061069061068b848787611db8565b611dc8565b16600052602060098152604060002033600052815260ff916106b9836040600020541615611e29565b806106c861068b868989611db8565b1660005260059182918282526106e8856007604060002001541615611e67565b6106f661068b878a8a611db8565b16600052526040600020015416600381101561077f5790808988888888886001981560001461075d57956107428161059f9461073c61068b8361074a976107559d611db8565b96611ea3565b959096611db8565b359333933691611c85565b505b01610665565b95610742816105bc9461073c61068b8361074a9761077a9d611db8565b610757565b87634e487b7160e01b60005260216004526000fd5b34610121576080366003190112610121576024356001600160401b038111610121576107dd6107c96020923690600401611cd3565b6107d1611a8a565b606435916004356121b1565b6040519015158152f35b34610121576020366003190112610121576001600160801b0319610809611bd0565b166000526007602052602060ff604060002054166040519015158152f35b346101215761020036600319011261012157610841611bd0565b61084a36611be7565b9060a0366101231901126101215760405161086481611aff565b61086c611acc565b81526101443560208201526101643560408201526101843560608201526101a43560808201526101c4356001600160a01b0381168103610121576108ae61229b565b6001600160801b0319831660005260076020526108d360ff6040600020541615611ee7565b6108e86001600160801b031984161515611f1c565b6001600160801b031983166000908152600760209081526040909120805460ff19166001179055840151610926906001600160a01b03161515611f4e565b835161093c906001600160a01b03161515611f86565b61094b60408501511515611fbe565b61096360808501514281119081610dda575b50611ff5565b60a084015160038110156103445715610dab57608082015115610d7a57606082015115610d4a5781516001600160a01b031660009081526004602052604090205460ff1615610d145760e0840151610c85575b60a0840151600381101561034457600214610c0b575b5080516001600160a01b031615610bd457602083015160408401516109fd91309033906001600160a01b0316612bba565b6001600160801b031982166000526006602052604060002060018060a01b038251166001600160601b0360a01b82541617815560208201516001820155604082015160028201556060820151600382015560046080830151910155600560205260406000209160018060a01b038451166001600160601b0360a01b8454161783556001830160018060a01b036020860151166001600160601b0360a01b825416179055604084015160028401556060840151600384015560808401516004840155600583019160a08501516003811015610344577fc1d41f85682afff3c8291bb0c88f077fa6a77781d61c4941bd0344a6b780db9c94610bca94610b2d9260ff8019835416911617905560c08701516006820155600760e0880151151591019060ff801983541691151516179055565b6001600160801b0319821660005260086020524360406000205560806040519160018060a01b038151168352602081015160208401526040810151604084015260608101516060840152015160808201527fce04f3b9b2dfc43b1d1e78376db74a3b32c0a78daaf34efc81334908359448fc60a06001600160801b0319841692a26040519182916001600160801b031916946101e4359083612086565b0390a26001600055005b60405162461bcd60e51b815260206004820152600f60248201526e34b73b30b634b232903637b1b5b2b960891b6044820152606490fd5b6001600160a01b03811615610c56576001600160801b031983166000908152600a6020526040902080546001600160a01b0319166001600160a01b03909216919091179055836109cc565b60405162461bcd60e51b8152602060048201526007602482015266182fb0b236b4b760c91b6044820152606490fd5b602084810151604051632c3e6f0f60e11b81523060048201529190829060249082906001600160a01b03165afa8015610d0857610cd491600091610cd9575b506001600160a01b03161561204c565b6109b6565b610cfb915060203d602011610d01575b610cf38183611b48565b81019061202d565b86610cc4565b503d610ce9565b6040513d6000823e3d90fd5b60405162461bcd60e51b815260206004820152600e60248201526d34b73b30b634b2103637b1b5b2b960911b6044820152606490fd5b60405162461bcd60e51b81526020600482015260086024820152670c17dc195c9a5bd960c21b6044820152606490fd5b60405162461bcd60e51b8152602060048201526009602482015268305f706572696f647360b81b6044820152606490fd5b60405162461bcd60e51b8152602060048201526007602482015266085b1bd8dad95960ca1b6044820152606490fd5b90506060860151108661095d565b3461012157606036600319011261012157610e01611bd0565b6024356001600160401b03811161012157610e20903690600401611a5a565b60449291923591610e2f61229b565b6001600160801b03198116806000526009602052604060002033600052602052610e6160ff6040600020541615611e29565b806000526005602052610e7f60ff6007604060002001541615611e67565b600052600560205260ff60056040600020015416600381101561034457610eb05761059f6105a59433933691611c85565b6105bc61033f9433933691611c85565b346101215760208060031936011261012157600435906001600160401b038211610121573660238301121561012157816004013591602490610f0184611c6e565b90610f0f6040519283611b48565b848252838201602460059660051b8301019136831161012157602401905b8282106111d257505050610f3f61229b565b60005b8151811015610328576001600160801b03199081610f60828561212f565b5116600052858552604060002091604051610f7a81611ae3565b60018060a01b03808554168252806001860154168883019081526002860154926040810193845260038088015460608301526004880154608083015260ff90818d8a015416908110156111bd5760a083015260076006988981015460c0850152015416151560e082015282339151160361118e5783610ff9868961212f565b51166000526008895243604060002054101561115d57611065898383511686611022898c61212f565b51166000908152898352604090819020549051636eb1769f60e11b81523060048201529086166001600160a01b0316602482015292839190829081906044820190565b03915afa908115610d0857600091611127575b509060019661108c6110f095949315612143565b85611097888b61212f565b51166000528b8b526110ac6040600020612181565b856110b7888b61212f565b51166000528a526110e4604060002060046000918281558260018201558260028201558260038201550155565b511690519033906136a3565b6110fa828561212f565b51167f88511e0182a386da19fdcadcde158de4729b63240d9a034ce75f3cb0dc5288a5600080a201610f42565b93929190508984813d8311611156575b6111418183611b48565b81010312610121579251919290916001611078565b503d611137565b60405162461bcd60e51b8152600481018a9052600a818a01526973616d6520626c6f636b60b01b6044820152606490fd5b60405162461bcd60e51b8152600481018a90526008818a01526710b6b0b730b3b2b960c11b6044820152606490fd5b8a634e487b7160e01b60005260216004526000fd5b81356001600160801b031981168103610121578152908501908501610f2d565b346101215760003660031901126101215761122c7f436c61696d43616d706169676e7300000000000000000000000000000000000e613b2f565b6112557f3200000000000000000000000000000000000000000000000000000000000001613c59565b6040516020808201928284106001600160401b038511176105c2579160206112af85946112a1979660405260008452604051978897600f60f81b895260e0858a015260e0890190611cfe565b908782036040890152611cfe565b91466060870152306080870152600060a087015285830360c0870152519182815201929160005b8281106112e557505050500390f35b8351855286955093810193928101926001016112d6565b34610121576020366003190112610121576001600160a01b0361131d611aa0565b1660005260036020526020604060002054604051908152f35b34610121576020366003190112610121576001600160801b0319611358611bd0565b166000526005602052610100604060002060018060a01b03908181541691600182015416906113cb6002820154600383015460048401549060ff6005860154169260ff600760068801549701541696604051988952602089015260408801526060870152608086015260a0850190611cf1565b60c0830152151560e0820152f35b3461012157610120366003190112610121576113f3611bd0565b6024356001600160401b03811161012157611412903690600401611cd3565b606435916001600160a01b038316906044358285036101215761144761143736611b69565b9361144061229b565b15156120f5565b6001600160801b0319821680600052600960205260406000203360005260205261147960ff6040600020541615611e29565b600052600560205260ff600560406000200154166003811015610344576114c2576103289483519060208501519260ff60408701511694608060608801519701519733916134d2565b915061033f93923391612d82565b3461012157610140366003190112610121576114ea611bd0565b6114f336611be7565b906114fc61229b565b6001600160801b031916908160005260206007815261152360ff6040600020541615611ee7565b61152e831515611f1c565b826000526007815260406000209160ff19926001848254161790558181019160018060a01b0390611563828551161515611f4e565b611571828451161515611f86565b604083019161158283511515611fbe565b6080840161159a8151428111908161172a5750611ff5565b60a085019384516003811015610344576116fc5760e0860196875161169d575b6115cd8482511683519030903390612bba565b896000526005855260406000209380885116906001600160601b0360a01b9182875416178655600186019251169082541617905551600283015560608501516003830155516004820155600581019251906003821015610344576007610bca96856116809460ff7fc1d41f85682afff3c8291bb0c88f077fa6a77781d61c4941bd0344a6b780db9c9b6008995416911617905560c0870151600684015551151591019060ff801983541691151516179055565b856000525243604060002055604051918291610124359083612086565b6024858583511660405192838092632c3e6f0f60e11b82523060048301525afa908115610d08576116da9186916000916116df575b50161561204c565b6115ba565b6116f69150883d8a11610d0157610cf38183611b48565b8d6116d2565b60405162461bcd60e51b81526004810185905260066024820152651b1bd8dad95960d21b6044820152606490fd5b90506060870151108a61095d565b3461012157608036600319011261012157611751611aa0565b5061175a611ab6565b506064356001600160401b03811161012157366023820112156101215780600401359061178682611bb5565b916117946040519384611b48565b8083523660248284010111610121576000928160246020940184830137010152604051630a85bd0160e11b8152602090f35b3461012157610120366003190112610121576001600160401b03600435818111610121576117f8903690600401611a5a565b60249291923582811161012157611813903690600401611a5a565b9261181c611a8a565b9060643590811161012157611835903690600401611a5a565b92909361184136611b69565b9561184a61229b565b611855818314611d3e565b611860858314611d3e565b60209687810161187281514210611d7c565b8315611a44576118818a611dc8565b908715611a44576119358361192e8b61190b8e8c9851965190604051908101917fe0834d61096d4599076d6c957b5b672653288def456b9f887441a132f0e6bf6f83526001600160801b0319809a16604083015260018060a01b03809b1698899586606085015235608084015260a083015260c08201528b60e082015260e081526102a581611ae3565b966102cf6102c660ff9960ff6040880151166060880151906080890151926138ba565b51886122e4565b60005b858110611946576001600055005b838b846119b78f858b828561196261068b858561068b98611db8565b166000526009875260406000208a6000528752611986886040600020541615611e29565b8561199561068b858585611db8565b1660005260058097526119b2886007604060002001541615611e67565b611db8565b16600052808d526040600020015416906003821015610344578a8a8a8f848a8c8e9360019915600014611a215792611a0881611a199994611a0261068b83611a109761059f9a611db8565b97611ea3565b979093611db8565b35943691611c85565b505b01611938565b92611a0881611a3f9994611a0261068b83611a10976105bc9a611db8565b611a1b565b634e487b7160e01b600052603260045260246000fd5b9181601f84011215610121578235916001600160401b038311610121576020808501948460051b01011161012157565b604435906001600160a01b038216820361012157565b600435906001600160a01b038216820361012157565b602435906001600160a01b038216820361012157565b61012435906001600160a01b038216820361012157565b61010081019081106001600160401b038211176105c257604052565b60a081019081106001600160401b038211176105c257604052565b6001600160401b0381116105c257604052565b604081019081106001600160401b038211176105c257604052565b90601f801991011681019081106001600160401b038211176105c257604052565b60a09060831901126101215760405190611b8282611aff565b81608435815260a435602082015260c43560ff8116810361012157604082015260e4356060820152608061010435910152565b6001600160401b0381116105c257601f01601f191660200190565b600435906001600160801b03198216820361012157565b6101009060231901126101215760405190611c0182611ae3565b816001600160a01b03602435818116810361012157825260443590811681036101215760208201526064356040820152608435606082015260a435608082015260c43560038110156101215760a082015260e43560c0820152610104359081151582036101215760e00152565b6001600160401b0381116105c25760051b60200190565b9291611c9082611c6e565b91611c9e6040519384611b48565b829481845260208094019160051b810192831161012157905b828210611cc45750505050565b81358152908301908301611cb7565b9080601f8301121561012157816020611cee93359101611c85565b90565b9060038210156103445752565b919082519283825260005b848110611d2a575050826000602080949584010152601f8019910116010190565b602081830181015184830182015201611d09565b15611d4557565b60405162461bcd60e51b815260206004820152600f60248201526e0d8cadccee8d040dad2e6dac2e8c6d608b1b6044820152606490fd5b15611d8357565b60405162461bcd60e51b815260206004820152600d60248201526c18db185a5b48195e1c1a5c9959609a1b6044820152606490fd5b9190811015611a445760051b0190565b356001600160801b0319811681036101215790565b15611de457565b60405162461bcd60e51b815260206004820152601760248201527f696e76616c696420636c61696d207369676e61747572650000000000000000006044820152606490fd5b15611e3057565b60405162461bcd60e51b815260206004820152600f60248201526e185b1c9958591e4818db185a5b5959608a1b6044820152606490fd5b15611e6e57565b60405162461bcd60e51b815260206004820152600d60248201526c6d7573742064656c656761746560981b6044820152606490fd5b9190811015611a445760051b81013590601e19813603018212156101215701908135916001600160401b038311610121576020018260051b36038113610121579190565b15611eee57565b60405162461bcd60e51b8152602060048201526006602482015265696e2075736560d01b6044820152606490fd5b15611f2357565b606460405162461bcd60e51b81526020600482015260046024820152630c17da5960e21b6044820152fd5b15611f5557565b60405162461bcd60e51b8152602060048201526009602482015268305f6164647265737360b81b6044820152606490fd5b15611f8d57565b60405162461bcd60e51b8152602060048201526009602482015268182fb6b0b730b3b2b960b91b6044820152606490fd5b15611fc557565b60405162461bcd60e51b81526020600482015260086024820152670c17d85b5bdd5b9d60c21b6044820152606490fd5b15611ffc57565b60405162461bcd60e51b815260206004820152600960248201526832b7321032b93937b960b91b6044820152606490fd5b9081602091031261012157516001600160a01b03811681036101215790565b1561205357565b60405162461bcd60e51b815260206004820152600b60248201526a216572633230766f74657360a81b6044820152606490fd5b610100909392919360e061012082019560018060a01b0380825116845260208201511660208401526040810151604084015260608101516060840152608081015160808401526120de60a082015160a0850190611cf1565b60c081015160c08401520151151560e08201520152565b156120fc57565b60405162461bcd60e51b815260206004820152600b60248201526a305f64656c65676174656560a81b6044820152606490fd5b8051821015611a445760209160051b010190565b1561214a57565b60405162461bcd60e51b815260206004820152600f60248201526e30b63637bbb0b731b29032b93937b960891b6044820152606490fd5b60076000918281558260018201558260028201558260038201558260048201558260058201558260068201550155565b604080516001600160a01b03909416602080860191825285830196909652929591949093919290916121f081606081015b03601f198101835282611b48565b51902060405182810191825282815261220881611b2d565b519020916000925b865184101561225557612223848861212f565b51908560008383101561224657505060005282526001846000205b930192612210565b9091600193825285522061223e565b92509450929150036122675750600190565b6064906040519062461bcd60e51b82526004820152600d60248201526c24b73b30b634b210383937b7b360991b6044820152fd5b6002600054146122ac576002600055565b604051633ee5aeb560e01b8152600490fd5b6042906122c9613790565b906040519161190160f01b8352600283015260228201522090565b6001600160a01b038116600090815260036020526040902080546001810190915591829003612311575050565b6040516301d4b62360e61b81526001600160a01b039190911660048201526024810191909152604490fd5b1561234357565b60405162461bcd60e51b8152602060048201526008602482015267085cdd185c9d195960c21b6044820152606490fd5b1561237a57565b60405162461bcd60e51b815260206004820152600e60248201526d18d85b5c185a59db88195b99195960921b6044820152606490fd5b156123b757565b60405162461bcd60e51b815260206004820152600960248201526821656c696769626c6560b81b6044820152606490fd5b156123ef57565b60405162461bcd60e51b815260206004820152601160248201527018d85b5c185a59db881d5b999d5b991959607a1b6044820152606490fd5b9190820391821161243557565b634e487b7160e01b600052601160045260246000fd5b8115612455570690565b634e487b7160e01b600052601260045260246000fd5b8115612455570490565b94600197929461010097929a999461012088019b8a8060a01b0397888092168a5216602089015260408801526060870152608086015260a085015260c08401521660e08201520152565b919290926001600160801b031983166000526005602052604060002093604051946124e986611ae3565b80546001600160a01b039081168752600182015416602087015260028101546040870152600380820154606088015260048201546080880152600582015460ff16908110156103445760ff9160079160a0890152600681015460c0890152015416151560e08601526001600160801b0319841660005260066020526125e06125db848460406000209460046040519661258188611aff565b60018060a01b038154168852600181015460208901526002810154604089015260038101546060890152015460808701526125c260608b015142101561233c565b6125d14260808c015111612373565b60c08a01516121b1565b6123b0565b6125f083604087015110156123e8565b6001600160801b0319841660008181526009602090815260408083206001600160a01b03871684528252808320805460ff1916600117905592825260059052206002018054612640908590612428565b90556001600160801b031984166000526005602052604060002060028101541561295e575b5061267460808201518461244b565b61292e5761268660808201518461246b565b602082015180612928575042905b602087015183516126b39187916001600160a01b0390811691166139b9565b60a0870151600381101561034457602091869160010361286c5784518984015160408088015160608901519151632744bf0b60e11b81526001600160a01b038b81166004830152938416602482015260448101969096526064860197909752608485019690965260a484019290925260c48301949094529092839160e4918391600091165af1908115610d0857600091612838575b5061278c91602091965b8201519051604051636eb1769f60e11b81523060048201526001600160a01b03918216602482015293849290911690829081906044820190565b03915afa908115610d08576000916127f8575b50600080516020613e4f833981519152916127bc60409215612143565b6001600160801b03198516600052600560205260028260002001548251948552602085015260018060a01b0316936001600160801b03191692a4565b90506020813d602011612830575b8161281360209383611b48565b810103126101215751600080516020613e4f83398151915261279f565b3d9150612806565b90506020813d602011612864575b8161285360209383611b48565b81010312610121575161278c612748565b3d9150612846565b60018060a01b03855116906000876128d38c8760018060a01b0391015116938c60408b01519160608c0151916001600160801b0319168652600a8a5260018060a01b03604087205416926040519b8c9a8b998a9863050fbad760e01b8a5260048a01612475565b03925af1908115610d08576000916128f4575b5061278c9160209196612752565b90506020813d602011612920575b8161290f60209383611b48565b81010312610121575161278c6128e6565b3d9150612902565b90612694565b61293c60808201518461246b565b600181018091111561268657634e487b7160e01b600052601160045260246000fd5b61296790612181565b6006602052612992604060002060046000918281558260018201558260028201558260038201550155565b38612665565b9190916001600160801b031916600093818552602090600582526040918287209683516129c481611ae3565b60018060a01b03988981541682528960018201541698848301998a526002820154918784019283526003810154606085019081526004820154906080860191825260ff6005840154169560a08101966003811015612b72578a95612a7397958f92612a6b96612a5c6125db978b97612a65948f5260e060ff600760068901549860c08501998a5201541615159101525142101561233c565b42905111612373565b516121b1565b5110156123e8565b516003811015612b5e57612b2e579060028483877feda9c5842f9de63a524e4bafcab717969b8cfdb8bbd1533e39497520dbc112759796955260098452612b06858383209a8d81169b8c85528752848420600160ff198254161790558a8452600587528585852001612ae6838254612428565b90558a8452600587528484208681015415612b1f575b508d8d51166136a3565b87815260058452200154908351928352820152a3511690565b612b2890612181565b38612afc565b835162461bcd60e51b8152600481018390526009602482015268085d5b9b1bd8dad95960ba1b6044820152606490fd5b634e487b7160e01b82526021600452602482fd5b634e487b7160e01b89526021600452602489fd5b15612b8d57565b60405162461bcd60e51b81526020600482015260056024820152642a2426181960d91b6044820152606490fd5b604080516370a0823160e01b8082526001600160a01b038087166004840181905292979693959481169460209491858a6024818a5afa998a15612d485760009a612d53575b508751908482528216600482015285816024818a5afa908115612d4857908991600091612d17575b5010612ceb5786516323b872dd60e01b868201526001600160a01b039182166024808301919091529290911660448201526064810188905284939290612c7a90612c7481608481016121e2565b87613d49565b86519586938492835260048301525afa928315612ce15750600092612cb1575b5050612caf92612ca991612428565b14612b86565b565b90809250813d8311612cda575b612cc88183611b48565b81010312610121575182612ca9612c9a565b503d612cbe565b513d6000823e3d90fd5b865162461bcd60e51b815260048101869052600560248201526454484c303160d81b6044820152606490fd5b809250878092503d8311612d41575b612d308183611b48565b810103126101215788905138612c27565b503d612d26565b88513d6000823e3d90fd5b9099508581813d8311612d7b575b612d6b8183611b48565b8101031261012157519838612bff565b503d612d61565b9290916000926001600160801b03198516845260056020526040842060405190612dab82611ae3565b80546001600160a01b039081168352600182015416602083015260028101546040830152600380820154606084015260048201546080840152600582015460ff16908110156134be5760ff9160079160a0850152600681015460c0850152015416151560e08201526001600160801b0319861685526006602052612e9b6125db85856040892095600460405197612e4189611aff565b60018060a01b038154168952600181015460208a0152600281015460408a0152600381015460608a015201546080880152612e82606087015142101561233c565b612e9142608088015111612373565b60c08601516121b1565b612eab84604083015110156123e8565b6001600160801b031986168086526009602090815260408088206001600160a01b03871689528252808820805460ff191660011790559187526005905285206002018054612efa908690612428565b90556001600160801b031986168552600560205260408520600281015415613485575b50612f2c60808301518561244b565b61345757612f3e60808301518561246b565b6020830151806134525750425b60208301518451612f6a9188916001600160a01b0390811691166139b9565b60a0830151600381101561343e576020919060010361324a5784518285015160408088015160608901519151632744bf0b60e11b81523060048201526001600160a01b039384166024820152604481018c90526064810195909552608485015260a484019590955260c48301949094529092839160e49183918b91165af19081156131e2578691613218575b508251909788916001600160a01b031690813b156132145760405163022eee0960e21b8152600481018490526001600160a01b039190911660248201529087908290604490829084905af18015613209579087916131f1575b505082516001600160a01b031690813b156131ed576040516323b872dd60e01b81523060048201526001600160a01b038616602482015260448101919091529086908290606490829084905af180156131e2579086916131ca575b50506020908101519151604051636eb1769f60e11b81523060048201526001600160a01b039182166024820152928391168180604481015b03915afa9081156131bf57849161317d575b5090600080516020613e4f8339815191529261311260409315612143565b8251946002908490836001600160a01b0386167fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a8380a36001600160801b0319891681526005602052200154908552602085015260018060a01b0316936001600160801b03191692a4565b9190506020823d6020116131b7575b8161319960209383611b48565b81010312610121579051600080516020613e4f8339815191526130f4565b3d915061318c565b6040513d86823e3d90fd5b6131d390611b1a565b6131de5784386130aa565b8480fd5b6040513d88823e3d90fd5b8680fd5b6131fa90611b1a565b61320557853861304f565b8580fd5b6040513d89823e3d90fd5b8780fd5b90506020813d602011613242575b8161323360209383611b48565b81010312610121575138612ff6565b3d9150613226565b60018060a01b0385511660018060a01b03838601511691898961329160408a01519560608b0151604051998a988997889663050fbad760e01b885230953060048a01612475565b03925af19081156131e257869161340c575b508251909788916001600160a01b031690813b156132145760405163022eee0960e21b8152600481018490526001600160a01b039190911660248201529087908290604490829084905af18015613209576133f9575b5082516001600160a01b0316803b156131ed576040516323b872dd60e01b81523060048201526001600160a01b0386166024820152604481018390529087908290606490829084905af18015613209579087916133e5575b505082516001600160801b031988168752600a60205260408720546001600160a01b0390811692911690813b15613214576040516323ed81fb60e01b815260048101919091526001600160a01b0392909216602483015286908290604490829084905af180156131e2579086916133d1575b50506130e291602091612752565b6133da90611b1a565b6131de5784386133c3565b6133ee90611b1a565b613205578538613351565b61340590969196611b1a565b94386132f9565b90506020813d602011613436575b8161342760209383611b48565b810103126132055751386132a3565b3d915061341a565b634e487b7160e01b88526021600452602488fd5b612f4b565b61346560808301518561246b565b6001810180911115612f3e57634e487b7160e01b86526011600452602486fd5b61348e90612181565b60066020526134b86040862060046000918281558260018201558260028201558260038201550155565b38612f1d565b634e487b7160e01b87526021600452602487fd5b92826134e592829b999598979698612998565b9260009660018060a01b0398898096169460409788519b8c96632c3e6f0f60e11b809852169b8c600482015260209a8b826024818c5afa918215613699578a9998979695949392918a918f8f909461367a575b505016998a911603613576575b5050505050505050505050807fd8138f8a3f377c5259ca548e70e4c2de94f129f5a11036a15b69513cba2b426a91a3565b863b1561367657895163061e6d2960e51b8152600481018a90526024810195909552604485015260ff166064840152608483015260a4820152878160c48183875af1801561366c57613659575b508590602486518094819382528b60048301525afa90811561364f578691613632575b5016036135fb57808080808080808080613545565b60649250519062461bcd60e51b82526004820152601160248201527019195b1959d85d1a5bdb8819985a5b1959607a1b6044820152fd5b6136499150853d8711610d0157610cf38183611b48565b386135e6565b84513d88823e3d90fd5b96613665879298611b1a565b96906135c3565b86513d8a823e3d90fd5b8b80fd5b613691929450803d10610d0157610cf38183611b48565b91388e613538565b8b513d8f823e3d90fd5b6040516370a0823160e01b8082526001600160a01b03848116600484018190529295946020949091169291908487602481875afa968715610d085760009761375b575b5060405163a9059cbb60e01b818701526001600160a01b0390911660248281019190915260448201879052859392909161372d9061372781606481016121e2565b86613d49565b6040519485938492835260048301525afa918215610d0857600092612cb1575050612caf92612ca991612428565b9096508481819493943d8311613789575b6137768183611b48565b81010312610121575195909190846136e6565b503d61376c565b307f0000000000000000000000005ae97e4770b7034c7ca99ab7edc26a18a23cb4126001600160a01b03161480613891575b156137eb577fdf84aed6fc1e48bd2d5cac5ed78a472ed57cd7e97ec8a102a8b5bbc86b8ed71e90565b60405160208101907f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f82527f39332aa01f799511dc634f3087469340022d328c636c488576d040209aa0837a60408201527fad7c5bef027816a800da1736444fb58a807ef4c9603b7848673f7e3a68eb14a560608201524660808201523060a082015260a0815260c081018181106001600160401b038211176105c25760405251902090565b507f000000000000000000000000000000000000000000000000000000000000000146146137c2565b91907f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0841161393e57926020929160ff608095604051948552168484015260408301526060820152600092839182805260015afa156139325780516001600160a01b0381161561392957918190565b50809160019190565b604051903d90823e3d90fd5b50505060009160039190565b6004811015610344578061395c575050565b600181036139765760405163f645eedf60e01b8152600490fd5b600281036139975760405163fce698f760e01b815260048101839052602490fd5b6003146139a15750565b602490604051906335e2f38360e21b82526004820152fd5b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152602094838216949192908682604481895afa918215610d0857600092613b00575b5081018091116124355760405163095ea7b360e01b8782018181526001600160a01b0385166024840152604480840194909452928252909590916000908190613a4760648a611b48565b88519082855af190613a57613dbb565b82613acd575b5081613ac2575b5015613a73575b505050505050565b604051958601521660248401526000604484015260448352608083018381106001600160401b038211176105c257613ab793613ab29160405282613d49565b613d49565b388080808080613a6b565b90503b151538613a64565b809192505190888215928315613ae8575b5050509038613a5d565b613af89350820181019101613d31565b388881613ade565b9091508681813d8311613b28575b613b188183611b48565b81010312610121575190386139fd565b503d613b0e565b60ff8114613b6d5760ff811690601f8211613b5b5760405191613b5183611b2d565b8252602082015290565b604051632cd44ac360e21b8152600490fd5b506040516000600190600154918260011c9060018416938415613c4f575b6020948584108114613c3b5783875286949392918115613c1b5750600114613bbc575b5050611cee92500382611b48565b9093915060016000527fb10e2d527612073b26eecdfd717e6a320cf44b4afac2b0732d9fcbe2b7fa0cf6936000915b818310613c03575050611cee93508201013880613bae565b85548784018501529485019486945091830191613beb565b915050611cee94925060ff191682840152151560051b8201013880613bae565b634e487b7160e01b85526022600452602485fd5b91607f1691613b8b565b60ff8114613c7b5760ff811690601f8211613b5b5760405191613b5183611b2d565b5060405160006002549060018260011c9060018416938415613d27575b6020948584108114613c3b5783875286949392918115613c1b5750600114613cc8575050611cee92500382611b48565b9093915060026000527f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace936000915b818310613d0f575050611cee93508201013880613bae565b85548784018501529485019486945091830191613cf7565b91607f1691613c98565b90816020910312610121575180151581036101215790565b600080613d729260018060a01b03169360208151910182865af1613d6b613dbb565b9083613deb565b8051908115159182613da0575b5050613d885750565b60249060405190635274afe760e01b82526004820152fd5b613db39250602080918301019101613d31565b153880613d7f565b3d15613de6573d90613dcc82611bb5565b91613dda6040519384611b48565b82523d6000602084013e565b606090565b90613e125750805115613e0057805190602001fd5b604051630a12f52160e11b8152600490fd5b81511580613e45575b613e23575090565b604051639996b31560e01b81526001600160a01b039091166004820152602490fd5b50803b15613e1b56feb73fa52621a0eab1e12dfeda1e46cb8d3faf8f59e22cf6c2610c680eced3ebc3a2646970667358221220f0814d03b4a5b289d5623c86f9dcc841d94bb5386bc2a2f0e9c87b6fe6d8510f64736f6c63430008180033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000e436c61696d43616d706169676e730000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001320000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000000000000000000000002cde9919e81b20b4b33dd562a48a84b54c48f00c0000000000000000000000001bb64af7fe05fc69c740609267d2abe3e119ef820000000000000000000000001961a23409ca59eedca6a99c97e4087dad75248600000000000000000000000073cd8626b3cd47b009e68380720cfe6679a3ec3d000000000000000000000000a600ec7db69dfcd21f19face5b209a55eab7a7c0000000000000000000000000de8465d44ebfc761ee3525740e06c916886e1aeb
-----Decoded View---------------
Arg [0] : name (string): ClaimCampaigns
Arg [1] : version (string): 2
Arg [2] : _tokenLockups (address[]): 0x2CDE9919e81b20B4B33DD562a48a84b54C48F00C,0x1bb64AF7FE05fc69c740609267d2AbE3e119Ef82,0x1961A23409CA59EEDCA6a99c97E4087DaD752486,0x73cD8626b3cD47B009E68380720CFE6679A3Ec3D,0xA600EC7Db69DFCD21f19face5B209a55EAb7a7C0,0xdE8465D44eBfC761Ee3525740E06C916886E1aEB
-----Encoded View---------------
14 Constructor Arguments found :
Arg [0] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [1] : 00000000000000000000000000000000000000000000000000000000000000a0
Arg [2] : 00000000000000000000000000000000000000000000000000000000000000e0
Arg [3] : 000000000000000000000000000000000000000000000000000000000000000e
Arg [4] : 436c61696d43616d706169676e73000000000000000000000000000000000000
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [6] : 3200000000000000000000000000000000000000000000000000000000000000
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000006
Arg [8] : 0000000000000000000000002cde9919e81b20b4b33dd562a48a84b54c48f00c
Arg [9] : 0000000000000000000000001bb64af7fe05fc69c740609267d2abe3e119ef82
Arg [10] : 0000000000000000000000001961a23409ca59eedca6a99c97e4087dad752486
Arg [11] : 00000000000000000000000073cd8626b3cd47b009e68380720cfe6679a3ec3d
Arg [12] : 000000000000000000000000a600ec7db69dfcd21f19face5b209a55eab7a7c0
Arg [13] : 000000000000000000000000de8465d44ebfc761ee3525740e06c916886e1aeb
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|---|---|---|---|---|
ETH | 63.81% | $0.006564 | 1,661,760,506.9927 | $10,907,096.98 | |
ETH | 28.54% | $0.282992 | 17,241,847.2921 | $4,879,304.85 | |
ETH | 6.28% | $2.5 | 429,150.4818 | $1,072,876.2 | |
ETH | 0.64% | $0.111903 | 976,284.0585 | $109,249.12 | |
ETH | 0.17% | $0.062204 | 468,486.6124 | $29,141.57 | |
ETH | 0.06% | $0.381378 | 27,114.16 | $10,340.74 | |
ETH | 0.03% | $0.023374 | 191,434 | $4,474.64 | |
ETH | 0.02% | $0.05787 | 44,470.31 | $2,573.5 | |
ETH | <0.01% | $0.077195 | 15,119.73 | $1,167.16 | |
BASE | 0.10% | $0.072402 | 241,390.24 | $17,477.14 | |
BASE | 0.09% | $0.055722 | 268,351.28 | $14,953.07 | |
BASE | 0.04% | $0.019779 | 372,783.8 | $7,373.22 | |
BSC | 0.08% | $1.86 | 7,316.3319 | $13,638.04 | |
BSC | 0.01% | $0.075329 | 28,600 | $2,154.41 | |
BSC | 0.01% | $0.007747 | 246,613.91 | $1,910.47 | |
BSC | <0.01% | $0.010828 | 85 | $0.9203 | |
LINEA | 0.06% | $0.013724 | 706,713.53 | $9,699.11 | |
OP | 0.05% | $2.16 | 3,803.259 | $8,222.69 | |
POL | <0.01% | $1 | 1,344.99 | $1,347.68 | |
POL | <0.01% | $0.006201 | 61,032.39 | $378.43 |
Loading...
Loading
[ 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.