ETH Price: $2,966.37 (-2.07%)

Transaction Decoder

Block:
21975651 at Mar-04-2025 07:35:11 PM +UTC
Transaction Fee:
0.000730296174408841 ETH $2.17
Gas Used:
240,469 Gas / 3.036965989 Gwei

Emitted Events:

146 IntegralTimeRelease.DelegateVotesChanged( account=[Sender] 0x9be92e68c71e52269b96e615031f0571bfe7cc7e, oldVotes=0, newVotes=29587594417059407568853 )
147 IntegralTimeRelease.DelegateVotesChanged( account=[Sender] 0x9be92e68c71e52269b96e615031f0571bfe7cc7e, oldVotes=29587594417059407568853, newVotes=0 )
148 IntegralToken.Transfer( from=[Receiver] IntegralTimeRelease, to=[Sender] 0x9be92e68c71e52269b96e615031f0571bfe7cc7e, amount=29587594417059407568853 )
149 IntegralToken.DelegateVotesChanged( account=[Receiver] IntegralTimeRelease, oldVotes=81955742589691376295870220, newVotes=81926154995274316888301367 )
150 IntegralToken.DelegateVotesChanged( account=[Sender] 0x9be92e68c71e52269b96e615031f0571bfe7cc7e, oldVotes=0, newVotes=29587594417059407568853 )
151 IntegralTimeRelease.Claim( claimer=[Sender] 0x9be92e68c71e52269b96e615031f0571bfe7cc7e, receiver=[Sender] 0x9be92e68c71e52269b96e615031f0571bfe7cc7e, option1Amount=26187119014190615580483, option2Amount=3400475402868791988370 )

Account State Difference:

  Address   Before After State Difference Code
(beaverbuild)
9.476556913238682863 Eth9.476783170520782863 Eth0.0002262572821
0x9BE92E68...1bfe7CC7E
0.220048135675149273 Eth
Nonce: 150
0.219317839500740432 Eth
Nonce: 151
0.000730296174408841
0xc8805CeB...66Fb118Ba
0xD502F487...61186Bc98

Execution Trace

IntegralTimeRelease.claim( to=0x9BE92E68C71e52269B96e615031f0571bfe7CC7E )
  • IntegralToken.transfer( to=0x9BE92E68C71e52269B96e615031f0571bfe7CC7E, _amount=29587594417059407568853 ) => ( True )
    File 1 of 2: IntegralTimeRelease
    // SPDX-License-Identifier: GPL-3.0-or-later
    // Deployed with donations via Gitcoin GR9
    pragma solidity 0.7.5;
    // a library for performing various math operations
    library Math {
        function min(uint256 x, uint256 y) internal pure returns (uint256 z) {
            z = x < y ? x : y;
        }
        function max(uint256 x, uint256 y) internal pure returns (uint256 z) {
            z = x > y ? x : y;
        }
        function min32(uint32 x, uint32 y) internal pure returns (uint32 z) {
            z = x < y ? x : y;
        }
        function max32(uint32 x, uint32 y) internal pure returns (uint32 z) {
            z = x > y ? x : y;
        }
        // babylonian method (https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method)
        function sqrt(uint256 y) internal pure returns (uint256 z) {
            if (y > 3) {
                z = y;
                uint256 x = y / 2 + 1;
                while (x < z) {
                    z = x;
                    x = (y / x + x) / 2;
                }
            } else if (y != 0) {
                z = 1;
            }
        }
    }
    // SPDX-License-Identifier: GPL-3.0-or-later
    // Deployed with donations via Gitcoin GR9
    pragma solidity 0.7.5;
    // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
    library SafeMath {
        function add(uint256 x, uint256 y) internal pure returns (uint256 z) {
            require((z = x + y) >= x, 'SM_ADD_OVERFLOW');
        }
        function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {
            z = sub(x, y, 'SM_SUB_UNDERFLOW');
        }
        function sub(
            uint256 x,
            uint256 y,
            string memory message
        ) internal pure returns (uint256 z) {
            require((z = x - y) <= x, message);
        }
        function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {
            require(y == 0 || (z = x * y) / y == x, 'SM_MUL_OVERFLOW');
        }
        function div(uint256 a, uint256 b) internal pure returns (uint256) {
            require(b > 0, 'SM_DIV_BY_ZERO');
            uint256 c = a / b;
            return c;
        }
        function ceil_div(uint256 a, uint256 b) internal pure returns (uint256 c) {
            c = div(a, b);
            if (c == mul(a, b)) {
                return c;
            } else {
                return add(c, 1);
            }
        }
        function safe32(uint256 n) internal pure returns (uint32) {
            require(n < 2**32, 'IS_EXCEEDS_32_BITS');
            return uint32(n);
        }
        function add96(uint96 a, uint96 b) internal pure returns (uint96 c) {
            c = a + b;
            require(c >= a, 'SM_ADD_OVERFLOW');
        }
        function sub96(uint96 a, uint96 b) internal pure returns (uint96) {
            require(b <= a, 'SM_SUB_UNDERFLOW');
            return a - b;
        }
        function mul96(uint96 x, uint96 y) internal pure returns (uint96 z) {
            require(y == 0 || (z = x * y) / y == x, 'SM_MUL_OVERFLOW');
        }
        function div96(uint96 a, uint96 b) internal pure returns (uint96) {
            require(b > 0, 'SM_DIV_BY_ZERO');
            uint96 c = a / b;
            return c;
        }
        function add32(uint32 a, uint32 b) internal pure returns (uint32 c) {
            c = a + b;
            require(c >= a, 'SM_ADD_OVERFLOW');
        }
        function sub32(uint32 a, uint32 b) internal pure returns (uint32) {
            require(b <= a, 'SM_SUB_UNDERFLOW');
            return a - b;
        }
        function mul32(uint32 x, uint32 y) internal pure returns (uint32 z) {
            require(y == 0 || (z = x * y) / y == x, 'SM_MUL_OVERFLOW');
        }
        function div32(uint32 a, uint32 b) internal pure returns (uint32) {
            require(b > 0, 'SM_DIV_BY_ZERO');
            uint32 c = a / b;
            return c;
        }
    }
    // SPDX-License-Identifier: GPL-3.0-or-later
    // Deployed with donations via Gitcoin GR9
    pragma solidity 0.7.5;
    // helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
    library TransferHelper {
        function safeApprove(
            address token,
            address to,
            uint256 value
        ) internal {
            // bytes4(keccak256(bytes('approve(address,uint256)')));
            (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
            require(success && (data.length == 0 || abi.decode(data, (bool))), 'TH_APPROVE_FAILED');
        }
        function safeTransfer(
            address token,
            address to,
            uint256 value
        ) internal {
            // bytes4(keccak256(bytes('transfer(address,uint256)')));
            (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
            require(success && (data.length == 0 || abi.decode(data, (bool))), 'TH_TRANSFER_FAILED');
        }
        function safeTransferFrom(
            address token,
            address from,
            address to,
            uint256 value
        ) internal {
            // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
            (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
            require(success && (data.length == 0 || abi.decode(data, (bool))), 'TH_TRANSFER_FROM_FAILED');
        }
        function safeTransferETH(address to, uint256 value) internal {
            (bool success, ) = to.call{ value: value }(new bytes(0));
            require(success, 'TH_ETH_TRANSFER_FAILED');
        }
    }
    // SPDX-License-Identifier: GPL-3.0-or-later
    // Deployed with donations via Gitcoin GR9
    pragma solidity 0.7.5;
    interface IERC20 {
        event Approval(address indexed owner, address indexed spender, uint256 value);
        event Transfer(address indexed from, address indexed to, uint256 value);
        function name() external view returns (string memory);
        function symbol() external view returns (string memory);
        function decimals() external view returns (uint8);
        function totalSupply() external view returns (uint256);
        function balanceOf(address owner) external view returns (uint256);
        function allowance(address owner, address spender) external view returns (uint256);
        function approve(address spender, uint256 value) external returns (bool);
        function transfer(address to, uint256 value) external returns (bool);
        function transferFrom(
            address from,
            address to,
            uint256 value
        ) external returns (bool);
    }
    // SPDX-License-Identifier: GPL-3.0-or-later
    // Deployed with donations via Gitcoin GR9
    pragma solidity 0.7.5;
    interface IIntegralTimeRelease {
        event OwnerSet(address owner);
        event Claim(address claimer, address receiver, uint256 option1Amount, uint256 option2Amount);
        event Skim(address to, uint256 amount);
        event Option1StopBlockSet(uint256 option1StopBlock);
        event Option2StopBlockSet(uint256 option2StopBlock);
    }
    // SPDX-License-Identifier: GPL-3.0-or-later
    // CODE COPIED FROM COMPOUND PROTOCOL (https://github.com/compound-finance/compound-protocol/tree/b9b14038612d846b83f8a009a82c38974ff2dcfe)
    // Copyright 2020 Compound Labs, Inc.
    // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    // 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    // 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    // CODE WAS SLIGHTLY MODIFIED
    // Deployed with donations via Gitcoin GR9
    pragma solidity 0.7.5;
    import 'SafeMath.sol';
    contract Votes {
        using SafeMath for uint96;
        struct Checkpoint {
            uint32 fromBlock;
            uint96 votes;
        }
        mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;
        mapping(address => uint32) public checkpointsLength;
        event DelegateVotesChanged(address indexed account, uint96 oldVotes, uint96 newVotes);
        function getCurrentVotes(address account) external view returns (uint96) {
            // out of bounds access is safe and returns 0 votes
            return checkpoints[account][checkpointsLength[account] - 1].votes;
        }
        function _getPriorVotes(address account, uint256 blockNumber) internal view returns (uint96) {
            require(blockNumber < block.number, 'VO_NOT_YET_DETERMINED');
            uint32 n = checkpointsLength[account];
            if (n == 0) {
                return 0;
            }
            if (checkpoints[account][n - 1].fromBlock <= blockNumber) {
                return checkpoints[account][n - 1].votes;
            }
            if (checkpoints[account][0].fromBlock > blockNumber) {
                return 0;
            }
            uint32 lower = 0;
            uint32 upper = n - 1;
            while (upper > lower) {
                uint32 center = upper - (upper - lower) / 2;
                Checkpoint memory checkpoint = checkpoints[account][center];
                if (checkpoint.fromBlock == blockNumber) {
                    return checkpoint.votes;
                } else if (checkpoint.fromBlock < blockNumber) {
                    lower = center;
                } else {
                    upper = center - 1;
                }
            }
            return checkpoints[account][lower].votes;
        }
        function _updateVotes(
            address giver,
            address receiver,
            uint96 votes
        ) internal {
            if (giver == receiver || votes == 0) {
                return;
            }
            if (giver != address(0)) {
                uint32 n = checkpointsLength[giver];
                require(n > 0, 'VO_INSUFFICIENT_VOTES');
                // out of bounds access is safe and returns 0 votes
                uint96 oldVotes = checkpoints[giver][n - 1].votes;
                uint96 newVotes = oldVotes.sub96(votes);
                _writeCheckpoint(giver, n, newVotes);
            }
            if (receiver != address(0)) {
                uint32 n = checkpointsLength[receiver];
                // out of bounds access is safe and returns 0 votes
                uint96 oldVotes = checkpoints[receiver][n - 1].votes;
                uint96 newVotes = oldVotes.add96(votes);
                _writeCheckpoint(receiver, n, newVotes);
            }
        }
        function _writeCheckpoint(
            address account,
            uint32 n,
            uint96 votes
        ) internal {
            uint32 blockNumber = safe32(block.number);
            // out of bounds access is safe and returns 0 votes
            uint96 oldVotes = checkpoints[account][n - 1].votes;
            if (n > 0 && checkpoints[account][n - 1].fromBlock == blockNumber) {
                checkpoints[account][n - 1].votes = votes;
            } else {
                checkpoints[account][n] = Checkpoint(blockNumber, votes);
                checkpointsLength[account] = n + 1;
            }
            emit DelegateVotesChanged(account, oldVotes, votes);
        }
        function safe32(uint256 n) internal pure returns (uint32) {
            require(n < 2**32, 'VO_EXCEEDS_32_BITS');
            return uint32(n);
        }
    }
    // SPDX-License-Identifier: GPL-3.0-or-later
    // Deployed with donations via Gitcoin GR9
    pragma solidity 0.7.5;
    import 'Math.sol';
    import 'SafeMath.sol';
    import 'TransferHelper.sol';
    import 'IERC20.sol';
    import 'IIntegralTimeRelease.sol';
    import 'Votes.sol';
    contract IntegralTimeRelease is IIntegralTimeRelease, Votes {
        using SafeMath for uint256;
        using SafeMath for uint96;
        address public immutable token;
        address public owner;
        uint96 public option1TotalAllocations;
        uint96 public option2TotalAllocations;
        uint96 public option1TotalClaimed;
        uint96 public option2TotalClaimed;
        struct Option {
            uint96 allocation;
            uint96 claimed;
            uint32 initBlock;
        }
        mapping(address => Option) public option1;
        mapping(address => Option) public option2;
        uint256 public option1StartBlock;
        uint256 public option1EndBlock;
        uint256 public option1StopBlock;
        uint256 public option2StartBlock;
        uint256 public option2EndBlock;
        uint256 public option2StopBlock;
        uint256 public option1StopSetBlock;
        uint256 public option2StopSetBlock;
        constructor(
            address _token,
            uint256 _option1StartBlock,
            uint256 _option1EndBlock,
            uint256 _option2StartBlock,
            uint256 _option2EndBlock
        ) {
            owner = msg.sender;
            emit OwnerSet(owner);
            token = _token;
            _setOption1Timeframe(_option1StartBlock, _option1EndBlock);
            _setOption2Timeframe(_option2StartBlock, _option2EndBlock);
        }
        function setOwner(address _owner) external {
            require(msg.sender == owner, 'TR_FORBIDDEN');
            owner = _owner;
            emit OwnerSet(owner);
        }
        function _setOption1Timeframe(uint256 _option1StartBlock, uint256 _option1EndBlock) internal {
            require(_option1EndBlock > _option1StartBlock, 'INVALID_OPTION1_TIME_FRAME');
            option1StartBlock = _option1StartBlock;
            option1EndBlock = _option1EndBlock;
            option1StopBlock = _option1EndBlock;
            option1StopSetBlock = _option1EndBlock;
        }
        function _setOption2Timeframe(uint256 _option2StartBlock, uint256 _option2EndBlock) internal {
            require(_option2EndBlock > _option2StartBlock, 'INVALID_OPTION2_TIME_FRAME');
            option2StartBlock = _option2StartBlock;
            option2EndBlock = _option2EndBlock;
            option2StopBlock = _option2EndBlock;
            option2StopSetBlock = _option2EndBlock;
        }
        function initOption1Allocations(address[] calldata wallets, uint96[] calldata amounts) external {
            require(msg.sender == owner, 'TR_FORBIDDEN');
            require(option1StopSetBlock == option1EndBlock, 'TR_STOP_ALREADY_SET');
            require(wallets.length == amounts.length, 'TR_INVALID_LENGTHS');
            uint32 initBlock = safe32(block.number);
            uint96 total = 0;
            for (uint256 i = 0; i < wallets.length; i++) {
                address wallet = wallets[i];
                require(option1[wallet].allocation == 0, 'TR_ALLOCATION_ALREADY_SET');
                uint96 amount = amounts[i];
                require(amount > 0, 'TR_ALLOCATION_ZERO');
                option1[wallet].allocation = amount;
                option1[wallet].initBlock = initBlock;
                total = total.add96(amount);
            }
            option1TotalAllocations = option1TotalAllocations.add96(total);
            require(IERC20(token).balanceOf(address(this)) >= getTokensLeft(), 'TR_INSUFFICIENT_BALANCE');
        }
        function initOption2Allocations(address[] calldata wallets, uint96[] calldata amounts) external {
            require(msg.sender == owner, 'TR_FORBIDDEN');
            require(option2StopSetBlock == option2EndBlock, 'TR_STOP_ALREADY_SET');
            require(wallets.length == amounts.length, 'TR_INVALID_LENGTHS');
            uint32 initBlock = safe32(block.number);
            uint96 total = 0;
            for (uint256 i = 0; i < wallets.length; i++) {
                address wallet = wallets[i];
                require(option2[wallet].allocation == 0, 'TR_ALLOCATION_ALREADY_SET');
                uint96 amount = amounts[i];
                require(amount > 0, 'TR_ALLOCATION_ZERO');
                option2[wallet].allocation = amount;
                option2[wallet].initBlock = initBlock;
                total = total.add96(amount);
            }
            option2TotalAllocations = option2TotalAllocations.add96(total);
            require(IERC20(token).balanceOf(address(this)) >= getTokensLeft(), 'TR_INSUFFICIENT_BALANCE');
        }
        function updateOption1Allocations(address[] calldata wallets, uint96[] calldata amounts) external {
            require(msg.sender == owner, 'TR_FORBIDDEN');
            require(option1StopSetBlock == option1EndBlock, 'TR_STOP_ALREADY_SET');
            require(wallets.length == amounts.length, 'TR_INVALID_LENGTHS');
            for (uint256 i = 0; i < wallets.length; i++) {
                address wallet = wallets[i];
                uint96 amount = amounts[i];
                uint96 oldAmount = option1[wallet].allocation;
                require(oldAmount > 0, 'TR_ALLOCATION_NOT_SET');
                require(getReleasedOption1(wallet) <= amount, 'TR_ALLOCATION_TOO_SMALL');
                option1TotalAllocations = option1TotalAllocations.sub96(oldAmount).add96(amount);
                option1[wallet].allocation = amount;
                uint96 claimed = option1[wallet].claimed;
                if (checkpointsLength[wallet] != 0) {
                    _updateVotes(wallet, address(0), oldAmount.sub96(claimed));
                }
                _updateVotes(address(0), wallet, amount.sub96(claimed));
            }
            require(IERC20(token).balanceOf(address(this)) >= getTokensLeft(), 'TR_INSUFFICIENT_BALANCE');
        }
        function updateOption2Allocations(address[] calldata wallets, uint96[] calldata amounts) external {
            require(msg.sender == owner, 'TR_FORBIDDEN');
            require(option2StopSetBlock == option2EndBlock, 'TR_STOP_ALREADY_SET');
            require(wallets.length == amounts.length, 'TR_INVALID_LENGTHS');
            for (uint256 i = 0; i < wallets.length; i++) {
                address wallet = wallets[i];
                uint96 amount = amounts[i];
                uint96 oldAmount = option2[wallet].allocation;
                require(oldAmount > 0, 'TR_ALLOCATION_NOT_SET');
                require(getReleasedOption2(wallet) <= amount, 'TR_ALLOCATION_TOO_SMALL');
                option2TotalAllocations = option2TotalAllocations.sub96(oldAmount).add96(amount);
                option2[wallet].allocation = amount;
                uint96 claimed = option2[wallet].claimed;
                if (checkpointsLength[wallet] != 0) {
                    _updateVotes(wallet, address(0), oldAmount.sub96(claimed));
                }
                _updateVotes(address(0), wallet, amount.sub96(claimed));
            }
            require(IERC20(token).balanceOf(address(this)) >= getTokensLeft(), 'TR_INSUFFICIENT_BALANCE');
        }
        function getTokensLeft() public view returns (uint96) {
            uint256 allocationTime1 = option1EndBlock.sub(option1StartBlock);
            uint256 claimableTime1 = option1StopBlock.sub(option1StartBlock);
            uint96 allocation1 = safe96(uint256(option1TotalAllocations).mul(claimableTime1).div(allocationTime1));
            uint256 allocationTime2 = option2EndBlock.sub(option2StartBlock);
            uint256 claimableTime2 = option2StopBlock.sub(option2StartBlock);
            uint96 allocation2 = safe96(uint256(option2TotalAllocations).mul(claimableTime2).div(allocationTime2));
            return allocation1.add96(allocation2).sub96(option1TotalClaimed).sub96(option2TotalClaimed);
        }
        function setOption1StopBlock(uint256 _option1StopBlock) external {
            require(msg.sender == owner, 'TR_FORBIDDEN');
            require(option1StopSetBlock == option1EndBlock, 'TR_STOP_ALREADY_SET');
            require(_option1StopBlock >= block.number && _option1StopBlock < option1EndBlock, 'TR_INVALID_BLOCK_NUMBER');
            option1StopBlock = _option1StopBlock;
            option1StopSetBlock = block.number;
            emit Option1StopBlockSet(_option1StopBlock);
        }
        function setOption2StopBlock(uint256 _option2StopBlock) external {
            require(msg.sender == owner, 'TR_FORBIDDEN');
            require(option2StopSetBlock == option2EndBlock, 'TR_STOP_ALREADY_SET');
            require(_option2StopBlock >= block.number && _option2StopBlock < option2EndBlock, 'TR_INVALID_BLOCK_NUMBER');
            option2StopBlock = _option2StopBlock;
            option2StopSetBlock = block.number;
            emit Option2StopBlockSet(_option2StopBlock);
        }
        function skim(address to) external {
            require(msg.sender == owner, 'TR_FORBIDDEN');
            require(to != address(0), 'TR_ADDRESS_ZERO');
            uint256 amount = getExcessTokens();
            TransferHelper.safeTransfer(token, to, amount);
            emit Skim(to, amount);
        }
        function getExcessTokens() public view returns (uint256) {
            return IERC20(token).balanceOf(address(this)).sub(getTokensLeft());
        }
        function getReleasedOption1(address wallet) public view returns (uint96) {
            return _getReleasedOption1ForBlock(wallet, block.number);
        }
        function _getReleasedOption1ForBlock(address wallet, uint256 blockNumber) internal view returns (uint96) {
            if (blockNumber <= option1StartBlock) {
                return 0;
            }
            uint256 elapsed = Math.min(blockNumber, option1StopBlock).sub(option1StartBlock);
            uint256 allocationTime = option1EndBlock.sub(option1StartBlock);
            return safe96(uint256(option1[wallet].allocation).mul(elapsed).div(allocationTime));
        }
        function getReleasedOption2(address wallet) public view returns (uint96) {
            return _getReleasedOption2ForBlock(wallet, block.number);
        }
        function _getReleasedOption2ForBlock(address wallet, uint256 blockNumber) internal view returns (uint96) {
            if (blockNumber <= option2StartBlock) {
                return 0;
            }
            uint256 elapsed = Math.min(blockNumber, option2StopBlock).sub(option2StartBlock);
            uint256 allocationTime = option2EndBlock.sub(option2StartBlock);
            return safe96(uint256(option2[wallet].allocation).mul(elapsed).div(allocationTime));
        }
        function getClaimableOption1(address wallet) external view returns (uint256) {
            return getReleasedOption1(wallet).sub(option1[wallet].claimed);
        }
        function getClaimableOption2(address wallet) external view returns (uint256) {
            return getReleasedOption2(wallet).sub(option2[wallet].claimed);
        }
        function getOption1Allocation(address wallet) external view returns (uint256) {
            return option1[wallet].allocation;
        }
        function getOption1Claimed(address wallet) external view returns (uint256) {
            return option1[wallet].claimed;
        }
        function getOption2Allocation(address wallet) external view returns (uint256) {
            return option2[wallet].allocation;
        }
        function getOption2Claimed(address wallet) external view returns (uint256) {
            return option2[wallet].claimed;
        }
        function claim(address to) external {
            address sender = msg.sender;
            Option memory _option1 = option1[sender];
            Option memory _option2 = option2[sender];
            uint96 _option1Claimed = _option1.claimed;
            uint96 _option2Claimed = _option2.claimed;
            uint96 option1Amount = getReleasedOption1(sender).sub96(_option1Claimed);
            uint96 option2Amount = getReleasedOption2(sender).sub96(_option2Claimed);
            option1[sender].claimed = _option1Claimed.add96(option1Amount);
            option2[sender].claimed = _option2Claimed.add96(option2Amount);
            option1TotalClaimed = option1TotalClaimed.add96(option1Amount);
            option2TotalClaimed = option2TotalClaimed.add96(option2Amount);
            uint96 totalClaimed = option1Amount.add96(option2Amount);
            if (checkpointsLength[sender] == 0) {
                _updateVotes(address(0), sender, _option1.allocation.add96(_option2.allocation));
            }
            _updateVotes(sender, address(0), totalClaimed);
            TransferHelper.safeTransfer(token, to, totalClaimed);
            emit Claim(sender, to, option1Amount, option2Amount);
        }
        function safe96(uint256 n) internal pure returns (uint96) {
            require(n < 2**96, 'IT_EXCEEDS_96_BITS');
            return uint96(n);
        }
        function getPriorVotes(address account, uint256 blockNumber) external view returns (uint96) {
            uint96 option1TotalAllocation = option1[account].allocation;
            uint96 option2TotalAllocation = option2[account].allocation;
            uint96 votes = 0;
            if (checkpointsLength[account] == 0 || checkpoints[account][0].fromBlock > blockNumber) {
                if (option1[account].initBlock <= blockNumber) {
                    votes = votes.add96(option1TotalAllocation);
                }
                if (option2[account].initBlock <= blockNumber) {
                    votes = votes.add96(option2TotalAllocation);
                }
            } else {
                votes = _getPriorVotes(account, blockNumber);
            }
            if (option1StopBlock == option1EndBlock && option2StopBlock == option2EndBlock) {
                return votes;
            }
            if (option1StopSetBlock > blockNumber && option2StopSetBlock > blockNumber) {
                return votes;
            }
            uint96 lockedAllocation1;
            uint96 lockedAllocation2;
            if (blockNumber >= option1StopSetBlock) {
                uint256 allocationTime = option1EndBlock.sub(option1StartBlock);
                uint256 haltedTime = option1EndBlock.sub(option1StopBlock);
                lockedAllocation1 = safe96(uint256(option1TotalAllocation).mul(haltedTime).div(allocationTime));
            }
            if (blockNumber >= option2StopSetBlock) {
                uint256 allocationTime = option2EndBlock.sub(option2StartBlock);
                uint256 haltedTime = option2EndBlock.sub(option2StopBlock);
                lockedAllocation2 = safe96(uint256(option2TotalAllocation).mul(haltedTime).div(allocationTime));
            }
            return votes.sub96(lockedAllocation1).sub96(lockedAllocation2);
        }
    }
    

    File 2 of 2: IntegralToken
    // SPDX-License-Identifier: GPL-3.0-or-later
    // Deployed with donations via Gitcoin GR9
    pragma solidity 0.7.5;
    interface IIntegralToken {
        function mint(address to, uint256 amount) external;
    }
    // SPDX-License-Identifier: GPL-3.0-or-later
    // Deployed with donations via Gitcoin GR9
    pragma solidity 0.7.5;
    // a library for performing overflow-safe math, courtesy of DappHub (https://github.com/dapphub/ds-math)
    library SafeMath {
        function add(uint256 x, uint256 y) internal pure returns (uint256 z) {
            require((z = x + y) >= x, 'SM_ADD_OVERFLOW');
        }
        function sub(uint256 x, uint256 y) internal pure returns (uint256 z) {
            z = sub(x, y, 'SM_SUB_UNDERFLOW');
        }
        function sub(
            uint256 x,
            uint256 y,
            string memory message
        ) internal pure returns (uint256 z) {
            require((z = x - y) <= x, message);
        }
        function mul(uint256 x, uint256 y) internal pure returns (uint256 z) {
            require(y == 0 || (z = x * y) / y == x, 'SM_MUL_OVERFLOW');
        }
        function div(uint256 a, uint256 b) internal pure returns (uint256) {
            require(b > 0, 'SM_DIV_BY_ZERO');
            uint256 c = a / b;
            return c;
        }
        function ceil_div(uint256 a, uint256 b) internal pure returns (uint256 c) {
            c = div(a, b);
            if (c == mul(a, b)) {
                return c;
            } else {
                return add(c, 1);
            }
        }
        function safe32(uint256 n) internal pure returns (uint32) {
            require(n < 2**32, 'IS_EXCEEDS_32_BITS');
            return uint32(n);
        }
        function add96(uint96 a, uint96 b) internal pure returns (uint96 c) {
            c = a + b;
            require(c >= a, 'SM_ADD_OVERFLOW');
        }
        function sub96(uint96 a, uint96 b) internal pure returns (uint96) {
            require(b <= a, 'SM_SUB_UNDERFLOW');
            return a - b;
        }
        function mul96(uint96 x, uint96 y) internal pure returns (uint96 z) {
            require(y == 0 || (z = x * y) / y == x, 'SM_MUL_OVERFLOW');
        }
        function div96(uint96 a, uint96 b) internal pure returns (uint96) {
            require(b > 0, 'SM_DIV_BY_ZERO');
            uint96 c = a / b;
            return c;
        }
        function add32(uint32 a, uint32 b) internal pure returns (uint32 c) {
            c = a + b;
            require(c >= a, 'SM_ADD_OVERFLOW');
        }
        function sub32(uint32 a, uint32 b) internal pure returns (uint32) {
            require(b <= a, 'SM_SUB_UNDERFLOW');
            return a - b;
        }
        function mul32(uint32 x, uint32 y) internal pure returns (uint32 z) {
            require(y == 0 || (z = x * y) / y == x, 'SM_MUL_OVERFLOW');
        }
        function div32(uint32 a, uint32 b) internal pure returns (uint32) {
            require(b > 0, 'SM_DIV_BY_ZERO');
            uint32 c = a / b;
            return c;
        }
    }
    // SPDX-License-Identifier: GPL-3.0-or-later
    // CODE COPIED FROM COMPOUND PROTOCOL (https://github.com/compound-finance/compound-protocol/tree/b9b14038612d846b83f8a009a82c38974ff2dcfe)
    // Copyright 2020 Compound Labs, Inc.
    // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    // 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    // 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    // CODE WAS SLIGHTLY MODIFIED
    // Deployed with donations via Gitcoin GR9
    pragma solidity 0.7.5;
    import 'SafeMath.sol';
    contract Votes {
        using SafeMath for uint96;
        struct Checkpoint {
            uint32 fromBlock;
            uint96 votes;
        }
        mapping(address => mapping(uint32 => Checkpoint)) public checkpoints;
        mapping(address => uint32) public checkpointsLength;
        event DelegateVotesChanged(address indexed account, uint96 oldVotes, uint96 newVotes);
        function getCurrentVotes(address account) external view returns (uint96) {
            // out of bounds access is safe and returns 0 votes
            return checkpoints[account][checkpointsLength[account] - 1].votes;
        }
        function _getPriorVotes(address account, uint256 blockNumber) internal view returns (uint96) {
            require(blockNumber < block.number, 'VO_NOT_YET_DETERMINED');
            uint32 n = checkpointsLength[account];
            if (n == 0) {
                return 0;
            }
            if (checkpoints[account][n - 1].fromBlock <= blockNumber) {
                return checkpoints[account][n - 1].votes;
            }
            if (checkpoints[account][0].fromBlock > blockNumber) {
                return 0;
            }
            uint32 lower = 0;
            uint32 upper = n - 1;
            while (upper > lower) {
                uint32 center = upper - (upper - lower) / 2;
                Checkpoint memory checkpoint = checkpoints[account][center];
                if (checkpoint.fromBlock == blockNumber) {
                    return checkpoint.votes;
                } else if (checkpoint.fromBlock < blockNumber) {
                    lower = center;
                } else {
                    upper = center - 1;
                }
            }
            return checkpoints[account][lower].votes;
        }
        function _updateVotes(
            address giver,
            address receiver,
            uint96 votes
        ) internal {
            if (giver == receiver || votes == 0) {
                return;
            }
            if (giver != address(0)) {
                uint32 n = checkpointsLength[giver];
                require(n > 0, 'VO_INSUFFICIENT_VOTES');
                // out of bounds access is safe and returns 0 votes
                uint96 oldVotes = checkpoints[giver][n - 1].votes;
                uint96 newVotes = oldVotes.sub96(votes);
                _writeCheckpoint(giver, n, newVotes);
            }
            if (receiver != address(0)) {
                uint32 n = checkpointsLength[receiver];
                // out of bounds access is safe and returns 0 votes
                uint96 oldVotes = checkpoints[receiver][n - 1].votes;
                uint96 newVotes = oldVotes.add96(votes);
                _writeCheckpoint(receiver, n, newVotes);
            }
        }
        function _writeCheckpoint(
            address account,
            uint32 n,
            uint96 votes
        ) internal {
            uint32 blockNumber = safe32(block.number);
            // out of bounds access is safe and returns 0 votes
            uint96 oldVotes = checkpoints[account][n - 1].votes;
            if (n > 0 && checkpoints[account][n - 1].fromBlock == blockNumber) {
                checkpoints[account][n - 1].votes = votes;
            } else {
                checkpoints[account][n] = Checkpoint(blockNumber, votes);
                checkpointsLength[account] = n + 1;
            }
            emit DelegateVotesChanged(account, oldVotes, votes);
        }
        function safe32(uint256 n) internal pure returns (uint32) {
            require(n < 2**32, 'VO_EXCEEDS_32_BITS');
            return uint32(n);
        }
    }
    // SPDX-License-Identifier: GPL-3.0-or-later
    // CODE COPIED FROM COMPOUND PROTOCOL (https://github.com/compound-finance/compound-protocol/tree/b9b14038612d846b83f8a009a82c38974ff2dcfe)
    // Copyright 2020 Compound Labs, Inc.
    // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
    // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    // 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    // 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    // CODE WAS SLIGHTLY MODIFIED
    // Deployed with donations via Gitcoin GR9
    pragma solidity 0.7.5;
    import 'IIntegralToken.sol';
    import 'SafeMath.sol';
    import 'Votes.sol';
    contract IntegralToken is IIntegralToken, Votes {
        using SafeMath for uint256;
        using SafeMath for uint96;
        event Transfer(address indexed from, address indexed to, uint256 amount);
        event OwnerSet(address indexed owner);
        event MinterSet(address indexed account, bool isMinter);
        event BurnerSet(address indexed account, bool isBurner);
        event Approval(address indexed owner, address indexed spender, uint256 amount);
        event DelegatesChanged(address indexed account, address indexed oldDelegate, address indexed newDelegate);
        event BlacklistedSet(address indexed account, bool isBlacklisted);
        string public constant name = 'Integral';
        string public constant symbol = 'ITGR';
        uint8 public constant decimals = 18;
        uint256 public totalSupply;
        address public owner;
        mapping(address => bool) public isMinter;
        mapping(address => bool) public isBurner;
        mapping(address => uint96) internal balances;
        mapping(address => mapping(address => uint96)) internal allowances;
        mapping(address => address) public delegates;
        mapping(address => uint256) public nonces;
        mapping(address => bool) public isBlacklisted;
        bytes32 public constant DOMAIN_TYPEHASH =
            keccak256('EIP712Domain(string name,uint256 chainId,address verifyingContract)');
        bytes32 public constant DELEGATION_TYPEHASH =
            keccak256('Delegation(address newDelegate,uint256 nonce,uint256 expiry)');
        constructor(address account, uint256 _initialAmount) {
            owner = msg.sender;
            isMinter[msg.sender] = true;
            isBurner[msg.sender] = true;
            _mint(account, _initialAmount);
        }
        function balanceOf(address account) external view returns (uint256) {
            return balances[account];
        }
        function allowance(address account, address spender) external view returns (uint256) {
            return allowances[account][spender];
        }
        function setOwner(address _owner) external {
            require(msg.sender == owner, 'IT_FORBIDDEN');
            owner = _owner;
            emit OwnerSet(owner);
        }
        function setMinter(address account, bool _isMinter) external {
            require(msg.sender == owner, 'IT_FORBIDDEN');
            isMinter[account] = _isMinter;
            emit MinterSet(account, _isMinter);
        }
        function mint(address to, uint256 _amount) external override {
            require(isMinter[msg.sender], 'IT_ONLY_WHITELISTED');
            require(!isBlacklisted[msg.sender] && !isBlacklisted[to], 'IT_BLACKLISTED');
            _mint(to, _amount);
        }
        function _mint(address to, uint256 _amount) internal {
            uint96 amount = safe96(_amount);
            totalSupply = totalSupply.add(_amount);
            balances[to] = balances[to].add96(amount);
            emit Transfer(address(0), to, _amount);
            _updateVotes(address(0), getDelegate(to), amount);
        }
        function setBurner(address account, bool _isBurner) external {
            require(msg.sender == owner, 'IT_FORBIDDEN');
            isBurner[account] = _isBurner;
            emit BurnerSet(account, _isBurner);
        }
        function burn(uint256 _amount) external {
            require(isBurner[address(0)] || isBurner[msg.sender], 'IT_ONLY_WHITELISTED');
            require(!isBlacklisted[msg.sender], 'IT_BLACKLISTED');
            uint96 amount = safe96(_amount);
            totalSupply = totalSupply.sub(_amount, 'IT_INVALID_BURN_AMOUNT');
            balances[msg.sender] = balances[msg.sender].sub96(amount);
            emit Transfer(msg.sender, address(0), _amount);
            _updateVotes(getDelegate(msg.sender), address(0), amount);
        }
        function approve(address spender, uint256 _amount) external returns (bool) {
            require(!isBlacklisted[msg.sender] && !isBlacklisted[spender], 'IT_BLACKLISTED');
            uint96 amount = _amount == uint256(-1) ? uint96(-1) : safe96(_amount);
            _approve(msg.sender, spender, amount);
            return true;
        }
        function _approve(
            address account,
            address spender,
            uint96 amount
        ) internal {
            require(account != address(0) && spender != address(0), 'IT_ADDRESS_ZERO');
            allowances[account][spender] = amount;
            emit Approval(account, spender, amount);
        }
        function increaseAllowance(address spender, uint256 _extraAmount) external returns (bool) {
            require(!isBlacklisted[msg.sender] && !isBlacklisted[spender], 'IT_BLACKLISTED');
            uint96 extraAmount = safe96(_extraAmount);
            _approve(msg.sender, spender, allowances[msg.sender][spender].add96(extraAmount));
            return true;
        }
        function decreaseAllowance(address spender, uint256 _subtractedAmount) external returns (bool) {
            require(!isBlacklisted[msg.sender] && !isBlacklisted[spender], 'IT_BLACKLISTED');
            uint96 subtractedAmount = safe96(_subtractedAmount);
            uint96 currentAmount = allowances[msg.sender][spender];
            require(currentAmount >= subtractedAmount, 'IT_CANNOT_DECREASE');
            _approve(msg.sender, spender, currentAmount.sub96(subtractedAmount));
            return true;
        }
        function transfer(address to, uint256 _amount) external returns (bool) {
            require(!isBlacklisted[msg.sender] && !isBlacklisted[to], 'IT_BLACKLISTED');
            uint96 amount = safe96(_amount);
            _transferTokens(msg.sender, to, amount);
            return true;
        }
        function transferFrom(
            address from,
            address to,
            uint256 _amount
        ) external returns (bool) {
            address spender = msg.sender;
            require(!isBlacklisted[spender] && !isBlacklisted[from] && !isBlacklisted[to], 'IT_BLACKLISTED');
            uint96 amount = safe96(_amount);
            uint96 spenderAllowance = allowances[from][spender];
            if (spender != from && spenderAllowance != uint96(-1)) {
                uint96 newAllowance = spenderAllowance.sub96(amount);
                _approve(from, spender, newAllowance);
            }
            _transferTokens(from, to, amount);
            return true;
        }
        function _transferTokens(
            address from,
            address to,
            uint96 amount
        ) internal {
            require(to != address(0), 'IT_INVALID_TO');
            balances[from] = balances[from].sub96(amount);
            balances[to] = balances[to].add96(amount);
            emit Transfer(from, to, amount);
            _updateVotes(getDelegate(from), getDelegate(to), amount);
        }
        function getPriorVotes(address account, uint256 blockNumber) public view returns (uint96) {
            return _getPriorVotes(account, blockNumber);
        }
        function getDelegate(address account) public view returns (address) {
            return delegates[account] == address(0) ? account : delegates[account];
        }
        function delegate(address newDelegate) external {
            require(!isBlacklisted[msg.sender] && !isBlacklisted[newDelegate], 'IT_BLACKLISTED');
            require(newDelegate != address(0), 'IT_INVALID_DELEGATE');
            _delegateFrom(msg.sender, newDelegate);
        }
        function _delegateFrom(address from, address newDelegate) internal {
            address oldDelegate = getDelegate(from);
            uint96 delegatorBalance = balances[from];
            delegates[from] = newDelegate;
            emit DelegatesChanged(from, oldDelegate, newDelegate);
            _updateVotes(oldDelegate, newDelegate, delegatorBalance);
        }
        function delegateWithSignature(
            address newDelegate,
            uint256 nonce,
            uint256 expiry,
            uint8 v,
            bytes32 r,
            bytes32 s
        ) external {
            require(!isBlacklisted[msg.sender] && !isBlacklisted[newDelegate], 'IT_BLACKLISTED');
            require(block.timestamp <= expiry, 'IT_SIGNATURE_EXPIRED');
            require(newDelegate != address(0), 'IT_INVALID_DELEGATE');
            bytes32 domainSeparator = keccak256(
                abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this))
            );
            bytes32 structHash = keccak256(abi.encode(DELEGATION_TYPEHASH, newDelegate, nonce, expiry));
            bytes32 digest = keccak256(abi.encodePacked('\\x19\\x01', domainSeparator, structHash));
            address signatory = ecrecover(digest, v, r, s);
            require(signatory != address(0), 'IT_INVALID_SIGNATURE');
            require(nonce == nonces[signatory]++, 'IT_INVALID_NONCE');
            _delegateFrom(signatory, newDelegate);
        }
        function safe96(uint256 n) internal pure returns (uint96) {
            require(n < 2**96, 'IT_EXCEEDS_96_BITS');
            return uint96(n);
        }
        function getChainId() public pure returns (uint256) {
            uint256 chainId;
            assembly {
                chainId := chainid()
            }
            return chainId;
        }
        function setBlacklisted(address account, bool _isBlacklisted) external {
            require(msg.sender == owner, 'IT_FORBIDDEN');
            isBlacklisted[account] = _isBlacklisted;
            emit BlacklistedSet(account, _isBlacklisted);
        }
    }