ETH Price: $2,505.76 (+0.16%)

Contract

0x92959998ffb49Ab5A07cf0fE29CbA47ABc7328A5
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Cancel Proposal178182572023-08-01 6:07:59459 days ago1690870079IN
0x92959998...ABc7328A5
0 ETH0.0012235518.23447281
Cancel Proposal178182562023-08-01 6:07:47459 days ago1690870067IN
0x92959998...ABc7328A5
0 ETH0.0012738617.71690388
Cancel Proposal178182562023-08-01 6:07:47459 days ago1690870067IN
0x92959998...ABc7328A5
0 ETH0.0012738617.71690388
Cancel Proposal178182552023-08-01 6:07:35459 days ago1690870055IN
0x92959998...ABc7328A5
0 ETH0.0012227517.00611245
Cancel Proposal178182542023-08-01 6:07:11459 days ago1690870031IN
0x92959998...ABc7328A5
0 ETH0.0012123616.86161365
Cancel Proposal178182542023-08-01 6:07:11459 days ago1690870031IN
0x92959998...ABc7328A5
0 ETH0.0012123616.86161365
Cancel Proposal178182532023-08-01 6:06:59459 days ago1690870019IN
0x92959998...ABc7328A5
0 ETH0.0012125516.86417088
Cancel Proposal178182522023-08-01 6:06:47459 days ago1690870007IN
0x92959998...ABc7328A5
0 ETH0.0011991116.67734258
Cancel Proposal178182512023-08-01 6:06:35459 days ago1690869995IN
0x92959998...ABc7328A5
0 ETH0.0012400717.24697006
Cancel Proposal178182512023-08-01 6:06:35459 days ago1690869995IN
0x92959998...ABc7328A5
0 ETH0.0012400717.24697006
Cancel Proposal178182482023-08-01 6:05:59459 days ago1690869959IN
0x92959998...ABc7328A5
0 ETH0.0012910517.95594367
Cancel Proposal178182472023-08-01 6:05:47459 days ago1690869947IN
0x92959998...ABc7328A5
0 ETH0.0012720117.69115415
Cancel Proposal178182472023-08-01 6:05:47459 days ago1690869947IN
0x92959998...ABc7328A5
0 ETH0.0012720117.69115415
Cancel Proposal178182462023-08-01 6:05:35459 days ago1690869935IN
0x92959998...ABc7328A5
0 ETH0.001131715.739732
Cancel Proposal178182462023-08-01 6:05:35459 days ago1690869935IN
0x92959998...ABc7328A5
0 ETH0.001131715.739732
Cancel Proposal178182452023-08-01 6:05:23459 days ago1690869923IN
0x92959998...ABc7328A5
0 ETH0.0011567616.0883433
Cancel Proposal178182432023-08-01 6:04:59459 days ago1690869899IN
0x92959998...ABc7328A5
0 ETH0.0011653116.20722343
Cancel Proposal178182422023-08-01 6:04:47459 days ago1690869887IN
0x92959998...ABc7328A5
0 ETH0.0011501315.99608618
Cancel Proposal178182412023-08-01 6:04:35459 days ago1690869875IN
0x92959998...ABc7328A5
0 ETH0.0011885416.53027721
Cancel Proposal178182402023-08-01 6:04:23459 days ago1690869863IN
0x92959998...ABc7328A5
0 ETH0.0012238717.02171774
Cancel Proposal178182402023-08-01 6:04:23459 days ago1690869863IN
0x92959998...ABc7328A5
0 ETH0.0012238717.02171774
Cancel Proposal178182392023-08-01 6:04:11459 days ago1690869851IN
0x92959998...ABc7328A5
0 ETH0.0012075216.7943356
Cancel Proposal178182392023-08-01 6:04:11459 days ago1690869851IN
0x92959998...ABc7328A5
0 ETH0.0012075216.7943356
Cancel Proposal178182382023-08-01 6:03:59459 days ago1690869839IN
0x92959998...ABc7328A5
0 ETH0.0012231617.01173454
Cancel Proposal178182382023-08-01 6:03:59459 days ago1690869839IN
0x92959998...ABc7328A5
0 ETH0.0012231617.01173454
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0xD8413518...1b56ACDB4
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
CrowdFundHYPCPool

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 15 : CrowdFundHYPCPool.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "../interfaces/ICHYPC.sol";
import "../interfaces/IHYPC.sol";
import "../interfaces/IHYPCSwap.sol";

/**
    @title  Crowd Funded HyPC Pool
    @author Barry Rowe, David Liendo
    @notice This contract allows users to pool their HyPC together to swap for a c_HyPC that can be used to back
            a license in the HyperCycle ecosystem. Because of the initial high volume of HyPC required for
            a swap, a pooling contract is useful for users wanting to have HyPC back their license. In this
            case, a license holder creates a proposal in the pool for 1 c_HyPC to back their license. They put up
            some backing HyPC as collateral for this loan, that will be used as interest payments for the users
            that provide HyPC for the proposal.

            As an example, a manager wants to borrow a c_HyPC for 18 months (78 weeks). The manager puts up 
            50,000 HyPC as collateral to act as interest for the user that deposit to this proposal. This means
            that the yearly APR for a depositor to the proposal will be: 50,000/524,288 * (26/39) = 0.063578288
            or roughly 6.35% (26 being the number of 2 week periods in a year, and 39 the number of 2 week
            periods in the proposal's term). The depositors can then claim this interest every period (2 weeks) 
            until the end of the proposal, at which point they can then withdraw and get back their initial 
            deposit. While the proposal is active, the c_HyPC is held by the pool contract itself, though the 
            manager that created the proposal can change the assignement of the swapped for c_HyPC.
*/

contract CrowdFundHYPCPool is ERC721Holder, Ownable, ReentrancyGuard {
    using SafeERC20 for IHYPC;

    struct ContractProposal {
        address owner;
        uint256 term;
        uint256 interestRateAPR;
        uint256 deadline;
        string assignmentString;
        uint256 startTime;
        uint256 depositedAmount;
        uint256 backingFunds;
        uint256 status;
        uint256 tokenId;
    }

    struct UserDeposit {
        uint256 amount;
        uint256 proposalIndex;
        uint256 interestTime;
    }

    ContractProposal[] public proposals;
    mapping(address => UserDeposit[]) public userDeposits;

    /// @notice The HyPC ERC20 contract
    IHYPC public immutable HYPCToken;

    /// @notice The c_HyPC ERC721 contract
    ICHYPC public immutable HYPCNFT;

    /// @notice The HyPC/c_HyPC swapping contract
    IHYPCSwap public immutable SwapContract;

    //Timing is done PER WEEK, with the assumption that 1 year = 52 weeks
    uint256 private constant _2_WEEKS = 60 * 60 * 24 * 14;
    uint256 private constant _1_MONTH = 60 * 60 * 24 * 7 * 4; //4 weeks
    uint256 private constant _18_MONTHS = 60 * 60 * 24 * 7 * 78; //78 weeks
    uint256 private constant _24_MONTHS = 60 * 60 * 24 * 7 * 104; //104 weeks
    uint256 private constant _36_MONTHS = 60 * 60 * 24 * 7 * 156; //156 weeks

    uint256 private constant PENDING = 0;
    uint256 private constant STARTED = 1;
    uint256 private constant CANCELLED = 2;
    uint256 private constant COMPLETED = 3;

    uint256 private constant SIX_DECIMALS = 10**6;
    uint256 private constant PERIODS_PER_YEAR = 26;

    /// @notice The amount of HyPC needed to swap for each proposal. 
    uint256 public constant REQUESTED_AMOUNT = (2**19)*SIX_DECIMALS;

    /** 
        @notice The pool fee set by the pool owner for each created proposal. This is given in HyPC with
                6 decimals.
    */
    uint256 public poolFee = 0;

    //Events
    /// @dev   The event for when a manager creates a proposal.
    /// @param proposalIndex: the proposal that was created
    /// @param owner: the proposal creator's address
    /// @param assignmentString: the assignment to give to the c_HyPC token when the proposal is filled
    /// @param deadline: the deadline in blocktime seconds for this proposal to be filled.
    event ProposalCreated(
        uint256 indexed proposalIndex,
        address indexed owner,
        string assignmentString,
        uint256 deadline
    );

    /// @dev   The event for when a proposal is canceled by its creator
    /// @param proposalIndex: the proposal that was canceled
    /// @param owner: The creator's address
    event ProposalCanceled(uint256 indexed proposalIndex, address indexed owner);

    /// @dev   The event for when a proposal is finished by its creator
    /// @param proposalIndex: the proposal that was finished
    /// @param owner: the creator of the proposal
    event ProposalFinished(uint256 indexed proposalIndex, address indexed owner);

    /// @dev   The event for when a user submits a deposit towards a proposal
    /// @param proposalIndex: the proposal this deposit was made towards
    /// @param user: the user address that submitted this deposit
    /// @param amount: the amount of HyPC the user deposited to this proposal.
    event DepositCreated(
        uint256 indexed proposalIndex,
        address indexed user,
        uint256 amount
    );

    /// @dev   The event for when a user withdraws a previously created deposit
    /// @param depositIndex: the user's deposit index that was withdrawn
    /// @param user: the user's address
    /// @param amount: the amount of HyPC that was withdrawn.
    event WithdrawDeposit(
        uint256 indexed depositIndex,
        address indexed user,
        uint256 amount
    );

    /// @dev   The event for when a user updates their deposit and gets interest.
    /// @param depositIndex: the deposit index for this user
    /// @param user: the address of the user
    /// @param interestChange: the amount of HyPC interest given to this user for this update.
    event UpdateDeposit(
        uint256 indexed depositIndex,
        address indexed user,
        uint256 interestChange
    );

    /// @dev   The event for when a user transfers their deposit to another user.
    /// @param depositIndex: the deposit index for this user
    /// @param user: the address of the user
    /// @param to: the address that this deposit was sent to
    /// @param amount: the amount of HyPC in this deposit.
    event TransferDeposit(
        uint256 indexed depositIndex,
        address indexed user,
        address indexed to,
        uint256 amount
    );

    /// @dev   The event for when a manager changes the assigned string of a proposal.
    /// @param proposalIndex: Index of the changed proposal.
    /// @param owner: the address of the proposal's owner.
    /// @param assignment: string that the proposal's assignment was changed to
    /// @param assignmentRef: String reference to the value of assignment 
    event AssignmentChanged(
        uint256 indexed proposalIndex,
        address indexed owner,
        string indexed assignment,
        string assignmentRef
    );

    //Modifiers
    /// @dev   Checks that this proposal index has been created.
    /// @param proposalIndex: the proposal index to check
    /// @param proposalsArray: the array that stores proposals.
    modifier validIndex(uint256 proposalIndex, ContractProposal[] storage proposalsArray) {
        require(proposalIndex < proposalsArray.length, "Invalid index.");
        _;
    }

    /// @dev   Checks that the transaction sender is the proposal owner
    /// @param proposalIndex: the proposal index to check ownership of.
    modifier proposalOwner(uint256 proposalIndex) {
        require(
            msg.sender == proposals[proposalIndex].owner,
            "Must be owner of proposal."
        );
        _;
    }

    /// @dev   Checks that the transaction sender's deposit index is valid.
    /// @param depositIndex: the sender's index to check.
    modifier validDeposit(uint256 depositIndex) {
        require(
            depositIndex < userDeposits[msg.sender].length,
            "Invalid deposit."
        );
        _;
    }

    /**
        @dev   The constructor takes in the HyPC token, c_HyPC token, and Swap contract addresses to populate
               the contract interfaces.
        @param hypcTokenAddress: the address for the HyPC token contract.
        @param hypcNFTAddress: the address for the CHyPC token contract.
        @param swapContractAddress: the address of the Swap contract.
    */
    constructor(
        address hypcTokenAddress,
        address hypcNFTAddress,
        address swapContractAddress
    ) {
        require(hypcTokenAddress != address(0), "Invalid Token.");
        require(hypcNFTAddress != address(0), "Invalid NFT.");
        require(swapContractAddress != address(0), "Invalid swap contract.");

        HYPCToken = IHYPC(hypcTokenAddress);
        HYPCNFT = ICHYPC(hypcNFTAddress);
        SwapContract = IHYPCSwap(swapContractAddress);
    }

    /// @notice Allows the owner of the pool to set the fee on proposal creation.
    /// @param  fee: the fee in HyPC to charge the proposal creator on creation.
    function setPoolFee(uint256 fee) external onlyOwner {
        poolFee = fee;
    }

    /**
        @notice Allows someone to create a proposal to have HyPC pooled together to swap for a c_HyPC token and
                have that token be given a specified assignment string. The creator specifies the term length
                for this proposal and supplies an amount of HyPC to act as interest for the depositors of the
                proposal.
        @param  termNum: either 0, 1, or 2, corresponding to 18 months, 24 months or 36 months respectively.
        @param  backingFunds: the amount of HyPC that the creator puts up to create the proposal, which acts
                as the interest to give to the depositors during the course of the proposal's term.
        @param  assignmentString: the string to be assigned to the c_HyPC swapped for when this proposal is
                filled and started.
        @param  deadline: the block timestamp that this proposal must be filled by in order to be started.
        @param  specifiedFee: The fee that the creator expects to pay.
        @dev    The specifiedFee parameter is used to prevent a pool owner from front-running a transaction
                to increase the poolFee after a creator has submitted a transaction.
        @dev    The interest rate calculation for the variable interestRateAPR is described in the contract's
                comment section. The only difference here is that there is an extra term in the numerator of
                SIX_DECIMALS since we can't have floating point numbers by default in solidity.
    */
    function createProposal(
        uint256 termNum,
        uint256 backingFunds,
        string memory assignmentString,
        uint256 deadline,
        uint256 specifiedFee
    ) external nonReentrant {
        require(
            termNum < 3,
            "termNum must be 0, 1, or 2 (18 months, 24 months, or 36 months)."
        );
        require(deadline > block.timestamp, "deadline must be in the future.");
        require(backingFunds > 0, "backingFunds must be positive.");
        require(
            bytes(assignmentString).length > 0,
            "assignmentString must be non-empty."
        );
        require(specifiedFee == poolFee, "Pool fee doesn't match.");

        uint256 termLength;
        if (termNum == 0) {
            termLength = _18_MONTHS;
        } else if (termNum == 1) {
            termLength = _24_MONTHS;
        } else {
            termLength = _36_MONTHS;
        }

        uint256 requiredFunds = 524288*SIX_DECIMALS;
        uint256 periods = termLength / _2_WEEKS;

        uint256 interestRateAPR = (backingFunds * PERIODS_PER_YEAR*SIX_DECIMALS) /
            (requiredFunds * periods);

        proposals.push(
            ContractProposal({
                owner: msg.sender,
                term: termLength,
                interestRateAPR: interestRateAPR,
                deadline: deadline,
                backingFunds: backingFunds,
                tokenId: 0,
                assignmentString: assignmentString,
                startTime: 0,
                status: PENDING,
                depositedAmount: 0
            })
        );

        HYPCToken.safeTransferFrom(msg.sender, address(this), backingFunds);
        HYPCToken.safeTransferFrom(msg.sender, owner(), poolFee);
        emit ProposalCreated(
            proposals.length,
            msg.sender,
            assignmentString,
            deadline
        );
    }

    /**
        @notice Lets a user creates a deposit for a pending proposal and submit the specified amount of 
                HyPC to back it.

        @param  proposalIndex: the proposal index that the user wants to back.
        @param  amount: the amount of HyPC the user wishes to deposit towards this proposal.
    */  
    function createDeposit(
        uint256 proposalIndex,
        uint256 amount
    ) external nonReentrant validIndex(proposalIndex, proposals) {
        ContractProposal storage proposalData = proposals[proposalIndex];
        require(proposalData.status == PENDING, "Proposal not open.");
        require(
            block.timestamp < proposalData.deadline,
            "Proposal has expired."
        );
        require(amount > 0, "HYPC amount must be positive.");
        require(proposalData.depositedAmount + amount <= REQUESTED_AMOUNT,
                "Total HyPC deposit must not exceed the requested amount.");
 
        //Register deposit into proposal's array
        proposalData.depositedAmount += amount;

        //Register user's deposit
        userDeposits[msg.sender].push(
            UserDeposit({
                proposalIndex: proposalIndex,
                amount: amount,
                interestTime: 0
            })
        );
        HYPCToken.safeTransferFrom(msg.sender, address(this), amount);
        emit DepositCreated(proposalIndex, msg.sender, amount); 
    }

    /**
        @notice Lets a user that owns a deposit for a proposal to transfer the ownership of that
                deposit to another user. This is useful for liquidity since deposit can be tied up for
                fairly long periods of time.
        @param  depositIndex: the index of this users deposits array that they wish to transfer.
        @param  to: the address of the user to send this deposit to
        @dev    Deposit objects are deleted from the deposits array after being transferred. The deposit is 
                deleted and the last entry of the array is copied to that index so the array can be decreased
                in length, so we can avoid iterating through the array.
    */
    function transferDeposit(uint256 depositIndex, address to) external validDeposit(depositIndex) {
        require(to != msg.sender, "Can not transfer deposit to yourself.");

        //Copy deposit to the new address
        userDeposits[to].push(userDeposits[msg.sender][depositIndex]);
        uint256 amount = userDeposits[msg.sender][depositIndex].amount;

        //Delete this user deposit now.
        //If the deposit is not the last one, then swap it with the last one.         
        if (
            userDeposits[msg.sender].length > 1 &&
            depositIndex < userDeposits[msg.sender].length - 1
        ) {
            delete userDeposits[msg.sender][depositIndex];
            userDeposits[msg.sender][depositIndex] = userDeposits[msg.sender][
                userDeposits[msg.sender].length - 1
            ];
        }
        userDeposits[msg.sender].pop();
        emit TransferDeposit(depositIndex, msg.sender, to, amount);
    }

    /**
        @notice Marks a proposal as started after it has received enough HyPC. At this point the proposal swaps
                the HyPC for c_HyPC and sets the timestamp for the length of the term and interest payment
                periods.
        @param  proposalIndex: the proposal to start.
    */
    function startProposal(
        uint256 proposalIndex
    ) external nonReentrant validIndex(proposalIndex, proposals) {
        ContractProposal storage proposalData = proposals[proposalIndex];
        require(proposalData.status == PENDING, "Proposal not open.");
        require(
            block.timestamp < proposalData.deadline,
            "Proposal has expired."
        );
        require(proposalData.depositedAmount == REQUESTED_AMOUNT,
                "Proposal's requested HyPC must be filled in order to be started.");
 
        //Start the proposal now:
        proposalData.status = STARTED;
        proposalData.startTime = block.timestamp;
        uint256 tokenId = SwapContract.nfts(0);
        proposalData.tokenId = tokenId;

        //Swap for CHYPC
        //approve first...
        HYPCToken.safeApprove(address(SwapContract), 524288*SIX_DECIMALS);
        SwapContract.swap();
        //Assign CHYPC
        HYPCNFT.assign(tokenId, proposalData.assignmentString);
    }

    /**
        @notice If a proposal hasn't been started yet, then the creator can cancel it and get back their
                backing HyPC. Users who have deposited can then withdraw their deposits with the withdrawDeposit
                function given below.
        @param  proposalIndex: the proposal index to be cancel.
    */
    function cancelProposal(
        uint256 proposalIndex
    )
        external
        nonReentrant
        validIndex(proposalIndex, proposals)
        proposalOwner(proposalIndex)
    {
        require(
            proposals[proposalIndex].status == PENDING,
            "Proposal must be pending."
        );
        uint256 amount = proposals[proposalIndex].backingFunds;
        proposals[proposalIndex].backingFunds = 0;
        proposals[proposalIndex].status = CANCELLED;
        HYPCToken.safeTransfer(msg.sender, amount);

        emit ProposalCanceled(proposalIndex, msg.sender);
    }

    /**
        @notice Allows a user to withdraw their deposit from a proposal if that proposal has been canceled,
                passed its deadline, has not been started yet, or has come to term. For the case of a proposal
                that has come to term, then the user has to update their deposit to claim any remaining 
                interest first.
        @param  depositIndex: the index of this user's deposits array that they wish to withdraw.
    */
    function withdrawDeposit(uint256 depositIndex) external validDeposit(depositIndex) {
        uint256 proposalIndex = userDeposits[msg.sender][depositIndex]
            .proposalIndex;
        ContractProposal storage proposalData = proposals[proposalIndex];
        uint256 status = proposalData.status;

        require(
            status == PENDING || status == CANCELLED || status == COMPLETED,
            "Proposal must be pending, cancelled, or completed."
        );

        if (status == COMPLETED) {
            require(
                userDeposits[msg.sender][depositIndex].interestTime ==
                    proposalData.startTime + proposalData.term,
                "Deposit must be updated before it is withdrawn."
            );
        }

        proposalData.depositedAmount -= userDeposits[msg.sender][depositIndex]
            .amount;
        uint256 amount = userDeposits[msg.sender][depositIndex].amount;

        //Delete this user deposit now.
        //If the deposit is not the last one, then swap it with the last one. 
        if (
            userDeposits[msg.sender].length > 1 &&
            depositIndex < userDeposits[msg.sender].length - 1
        ) {
            delete userDeposits[msg.sender][depositIndex];
            userDeposits[msg.sender][depositIndex] = userDeposits[msg.sender][
                userDeposits[msg.sender].length - 1
            ];
        }
        userDeposits[msg.sender].pop();

        HYPCToken.safeTransfer(msg.sender, amount);

        emit WithdrawDeposit(depositIndex, msg.sender, amount);
    }

    /**
        @notice Updates a user's deposit and sends them the accumulated interest from the amount of two week
                periods that have passed.
        @param  depositIndex: the index of this user's deposits array that they wish to update.
        @dev    The interestChange variable takes the user's deposit amount and multiplies it by the 
                proposal's calculated interestRateAPR to get the the yearly interest for this deposit with
                6 extra decimal places. It divides this by the number of periods in a year to get the interest
                from one two-week period, and multiplies it by the number of two week periods that have passed
                since this function was called to account for periods that were previously skipped. Finally,
                it divides the result by SIX_DECIMALS to remove the extra decimal places.
    */
    function updateDeposit(uint256 depositIndex) external nonReentrant validDeposit(depositIndex) {
        //get some interest from this deposit
        UserDeposit storage deposit = userDeposits[msg.sender][depositIndex];
        ContractProposal storage proposalData = proposals[
            deposit.proposalIndex
        ];

        require(
            proposalData.status == STARTED || proposalData.status == COMPLETED,
            "Proposal not started or completed."
        );

        if (deposit.interestTime == 0) {
            deposit.interestTime = proposalData.startTime;
        }

        uint256 endTime = block.timestamp;
        if (endTime > proposalData.startTime + proposalData.term) {
            endTime = proposalData.startTime + proposalData.term;
        }

        uint256 periods = (endTime - deposit.interestTime) / _2_WEEKS;
        require(
            periods > 0,
            "Not enough time has passed since last interest period."
        );

        uint256 interestChange = (deposit.amount * periods *
            proposalData.interestRateAPR) / (PERIODS_PER_YEAR * SIX_DECIMALS);

        //send this interestChange to the user and update both the backing funds and the interest time;
        deposit.interestTime += periods * _2_WEEKS;
 
        proposalData.backingFunds -= interestChange;
        HYPCToken.safeTransfer(msg.sender, interestChange);
        emit UpdateDeposit(depositIndex, msg.sender, interestChange);
    }

    /**
        @notice This completes the proposal after it has come to term, unassigns the c_HyPC and redeems it for
                HyPC, so it can be given back to the depositors.
        @param  proposalIndex: the proposal's index to complete.
    */
    function completeProposal(uint256 proposalIndex) 
        external 
        nonReentrant
        validIndex(proposalIndex, proposals) {
        ContractProposal storage proposalData = proposals[proposalIndex];
        require(proposalData.status == STARTED, "Proposal must be in started state.");
 
        require (block.timestamp >= proposalData.startTime + proposalData.term,
            "Proposal must have reached the end of its term." );

        proposalData.status = COMPLETED;
        //unassign token and redeem it.
        HYPCNFT.assign(proposalData.tokenId, "");
        HYPCNFT.approve(address(SwapContract), proposalData.tokenId);
        SwapContract.redeem(proposalData.tokenId);
    }

    /**
        @notice This allows the creator of a completed proposal to claim any left over backingFunds interest
                after all users have withdrawn their deposits from this proposal.
        @param  proposalIndex: the proposal's index to be finished.
    */
    function finishProposal(
        uint256 proposalIndex
    )
        external 
        nonReentrant
        validIndex(proposalIndex, proposals)
        proposalOwner(proposalIndex)
    {
        require(
            proposals[proposalIndex].status == COMPLETED,
            "Proposal must be completed."
        );
        require(
            proposals[proposalIndex].depositedAmount == 0,
            "All users must be withdrawn from proposal."
        );
        require(
            proposals[proposalIndex].backingFunds > 0,
            "Some backing funds must be left over."
        );
        uint256 amountToSend = proposals[proposalIndex].backingFunds;
        proposals[proposalIndex].backingFunds = 0;

        HYPCToken.safeTransfer(
            msg.sender,
            amountToSend
        );

        emit ProposalFinished(proposalIndex, msg.sender);
    }
 
    /**
        @notice This allows a proposal creator to change the assignment of a c_HyPC token that was swapped for
                in a fulfilled proposal.
        @param  proposalIndex: the proposal's index to have its c_HyPC assignment changed.
    */
    function changeAssignment(uint256 proposalIndex, string memory assignmentString) external validIndex(proposalIndex, proposals) proposalOwner(proposalIndex) {
        require(proposals[proposalIndex].status == STARTED, "Proposal must be in started state.");
        uint256 tokenId = proposals[proposalIndex].tokenId;
        HYPCNFT.assign(tokenId, assignmentString);

        emit AssignmentChanged(proposalIndex, msg.sender, assignmentString, assignmentString);
    }

    //Getters
    /// @notice Returns a user's deposits
    /// @param  user: the user's address.
    /// @return The UserDeposits array for this user
    function getUserDeposits(address user) external view returns(UserDeposit[] memory) {
        return userDeposits[user];
    }

    /// @notice Returns a specific deposit for a user
    /// @param user: the user's address
    /// @param depositIndex: the user's deposit index to be returned.
    /// @return The UserDeposit object at the index for this user
    function getDeposit(address user, uint256 depositIndex) external view returns(UserDeposit memory) {
        return userDeposits[user][depositIndex];
    }

    /// @notice Returns the length of a user's deposits array
    /// @param  user: the user's address
    /// @return The length of the user deposits array.
    function getDepositsLength(address user) external view returns(uint256) {
        return userDeposits[user].length;
    }

    /// @notice Returns the proposal object at the given index.
    /// @param  proposalIndex: the proposal's index to be returned
    /// @return The ContractProposal object for the given index.
    function getProposal(uint256 proposalIndex) external view returns(ContractProposal memory) {
        return proposals[proposalIndex];
    }
    
    /// @notice Returns the total number of proposals submitted to the contract so far.
    /// @return The length of the contract proposals array.
    function getProposalsLength() external view returns(uint256) {
        return proposals.length;
    }
}

File 2 of 15 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

File 3 of 15 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @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;

    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
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // 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;
    }
}

File 4 of 15 : draft-IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 5 of 15 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @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 amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` 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 amount) 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 `amount` 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 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` 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 amount
    ) external returns (bool);
}

File 6 of 15 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/draft-IERC20Permit.sol";
import "../../../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;

    function safeTransfer(
        IERC20 token,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(
        IERC20 token,
        address from,
        address to,
        uint256 value
    ) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        require(
            (value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        uint256 newAllowance = token.allowance(address(this), spender) + value;
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(
        IERC20 token,
        address spender,
        uint256 value
    ) internal {
        unchecked {
            uint256 oldAllowance = token.allowance(address(this), spender);
            require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
            uint256 newAllowance = oldAllowance - value;
            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
        }
    }

    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
    }

    /**
     * @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, "SafeERC20: low-level call failed");
        if (returndata.length > 0) {
            // Return data is optional
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 7 of 15 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../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 caller.
     *
     * 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);
}

File 8 of 15 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @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);
}

File 9 of 15 : ERC721Holder.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol)

pragma solidity ^0.8.0;

import "../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}.
 */
contract ERC721Holder is IERC721Receiver {
    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address,
        address,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    }
}

File 10 of 15 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @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://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @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, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * 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.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @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`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) 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(errorMessage);
        }
    }
}

File 11 of 15 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

File 12 of 15 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @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);
}

File 13 of 15 : ICHYPC.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";

/// @notice Interface for the CHYPC.sol contract.
interface ICHYPC is IERC721 {
    /**
     * Accesses the assignment function of c_HyPC so the swap can remove 
     * the assignment data when a token is redeemed or swapped.
     */
    /// @notice Assigns a string to the given c_HyPC token.
    function assign(
        uint256 tokenId,
        string memory data
    ) external;

    /// @notice Returns the assigned string for this token.
    function getAssignment(
        uint256 tokenId
    ) external view  returns (string memory);
}

File 14 of 15 : IHYPC.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/// @notice Interface for the HyperCycleToken.sol contract.
interface IHYPC is IERC20 {
    /*
     * Accesses the ERC20 functions of the HYPC contract. The burn function
     * is also exposed for future contracts.
    */
    /// @notice Burns an amount of the HyPC ERC20.
    function burn(uint256 amount) external;
}

File 15 of 15 : IHYPCSwap.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

/// @notice Interface for the HYPCSwap.sol contract.
interface IHYPCSwap {
    /**
     * Accesses the addNFT function so that the CHYPC contract can
     * add the newly created NFT into this contract.
     */

    /// @notice Returns the nfts array inside the swap contract.
    function nfts(uint256 tokenId) external returns (uint256);

    /// @notice Adds a c_HyPC token to the swap contract from the c_HyPC contract.
    function addNFT(
        uint256 tokenId
    ) external;

    /// @notice Redeems a c_HyPC token for its amount of backing HyPC.
    function redeem(uint256 tokenId) external;

    /// @notice Swaps 524288 HyPC for 1 c_HyPC.
    function swap() external;
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"hypcTokenAddress","type":"address"},{"internalType":"address","name":"hypcNFTAddress","type":"address"},{"internalType":"address","name":"swapContractAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"proposalIndex","type":"uint256"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"string","name":"assignment","type":"string"},{"indexed":false,"internalType":"string","name":"assignmentRef","type":"string"}],"name":"AssignmentChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"proposalIndex","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"DepositCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"proposalIndex","type":"uint256"},{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"ProposalCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"proposalIndex","type":"uint256"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"string","name":"assignmentString","type":"string"},{"indexed":false,"internalType":"uint256","name":"deadline","type":"uint256"}],"name":"ProposalCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"proposalIndex","type":"uint256"},{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"ProposalFinished","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"depositIndex","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"TransferDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"depositIndex","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"interestChange","type":"uint256"}],"name":"UpdateDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"depositIndex","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawDeposit","type":"event"},{"inputs":[],"name":"HYPCNFT","outputs":[{"internalType":"contract ICHYPC","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"HYPCToken","outputs":[{"internalType":"contract IHYPC","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REQUESTED_AMOUNT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SwapContract","outputs":[{"internalType":"contract IHYPCSwap","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalIndex","type":"uint256"}],"name":"cancelProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalIndex","type":"uint256"},{"internalType":"string","name":"assignmentString","type":"string"}],"name":"changeAssignment","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalIndex","type":"uint256"}],"name":"completeProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalIndex","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"createDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"termNum","type":"uint256"},{"internalType":"uint256","name":"backingFunds","type":"uint256"},{"internalType":"string","name":"assignmentString","type":"string"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint256","name":"specifiedFee","type":"uint256"}],"name":"createProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalIndex","type":"uint256"}],"name":"finishProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"depositIndex","type":"uint256"}],"name":"getDeposit","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"proposalIndex","type":"uint256"},{"internalType":"uint256","name":"interestTime","type":"uint256"}],"internalType":"struct CrowdFundHYPCPool.UserDeposit","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getDepositsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalIndex","type":"uint256"}],"name":"getProposal","outputs":[{"components":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"term","type":"uint256"},{"internalType":"uint256","name":"interestRateAPR","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"string","name":"assignmentString","type":"string"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"depositedAmount","type":"uint256"},{"internalType":"uint256","name":"backingFunds","type":"uint256"},{"internalType":"uint256","name":"status","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"internalType":"struct CrowdFundHYPCPool.ContractProposal","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getProposalsLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getUserDeposits","outputs":[{"components":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"proposalIndex","type":"uint256"},{"internalType":"uint256","name":"interestTime","type":"uint256"}],"internalType":"struct CrowdFundHYPCPool.UserDeposit[]","name":"","type":"tuple[]"}],"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":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"proposals","outputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"term","type":"uint256"},{"internalType":"uint256","name":"interestRateAPR","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"string","name":"assignmentString","type":"string"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"depositedAmount","type":"uint256"},{"internalType":"uint256","name":"backingFunds","type":"uint256"},{"internalType":"uint256","name":"status","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"fee","type":"uint256"}],"name":"setPoolFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"proposalIndex","type":"uint256"}],"name":"startProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"depositIndex","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"transferDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"depositIndex","type":"uint256"}],"name":"updateDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"userDeposits","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"proposalIndex","type":"uint256"},{"internalType":"uint256","name":"interestTime","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"depositIndex","type":"uint256"}],"name":"withdrawDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"}]

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106101a95760003560e01c8063715018a6116100f9578063c7f758a811610097578063e88385cd11610071578063e88385cd14610400578063e8d3cad514610427578063f2fde38b14610450578063f4cd78b01461046357600080fd5b8063c7f758a8146103ba578063e0a8f6f5146103da578063e171d1c1146103ed57600080fd5b80639501dc87116100d35780639501dc8714610379578063a53276571461038c578063b18e71f21461039f578063bc378a73146103b257600080fd5b8063715018a614610358578063879ee88c146103605780638da5cb5b1461036857600080fd5b80631e52ac3811610166578063273932781161014057806327393278146102ff5780632a5bf6d21461031257806333289a46146103325780635114ec351461034557600080fd5b80631e52ac38146102a557806326bfee04146102cc5780632726b506146102df57600080fd5b8063013cf08b146101ae57806303acfedb146101e0578063089fe6aa1461021f57806308f4333314610236578063119e9d6414610264578063150b7a0214610279575b600080fd5b6101c16101bc366004612b89565b610476565b6040516101d79a99989796959493929190612bf2565b60405180910390f35b6102077f000000000000000000000000ea7b7dc089c9a4a916b5a7a37617f59fd54e37e481565b6040516001600160a01b0390911681526020016101d7565b61022860045481565b6040519081526020016101d7565b610249610244366004612c72565b61056b565b604080519384526020840192909252908201526060016101d7565b610277610272366004612b89565b6105ad565b005b61028c610287366004612d28565b610887565b6040516001600160e01b031990911681526020016101d7565b6102077f0000000000000000000000000b84dcf0d13678c68ba9ca976c02eaaa0a44932b81565b6102776102da366004612da4565b610898565b6102f26102ed366004612c72565b610b76565b6040516101d79190612dd0565b61027761030d366004612b89565b610c04565b610325610320366004612df1565b610eba565b6040516101d79190612e13565b610277610340366004612b89565b610f4d565b610277610353366004612b89565b61135e565b6102776116d9565b6102286116ed565b6000546001600160a01b0316610207565b610277610387366004612b89565b611700565b61027761039a366004612e95565b61170d565b6102776103ad366004612edc565b6118cb565b600254610228565b6103cd6103c8366004612b89565b611b80565b6040516101d79190612efe565b6102776103e8366004612b89565b611d24565b6102776103fb366004612f9b565b611efa565b6102077f0000000000000000000000004f95846e806f19ba137b6f85f823db44f0483f0c81565b610228610435366004612df1565b6001600160a01b031660009081526003602052604090205490565b61027761045e366004612df1565b6123a0565b610277610471366004612b89565b612416565b6002818154811061048657600080fd5b60009182526020909120600a9091020180546001820154600283015460038401546004850180546001600160a01b039095169650929491939092906104ca90612ffd565b80601f01602080910402602001604051908101604052809291908181526020018280546104f690612ffd565b80156105435780601f1061051857610100808354040283529160200191610543565b820191906000526020600020905b81548152906001019060200180831161052657829003601f168201915b505050505090806005015490806006015490806007015490806008015490806009015490508a565b6003602052816000526040600020818154811061058757600080fd5b600091825260209091206003909102018054600182015460029092015490935090915083565b6105b56126d6565b33600090815260036020526040902054819081106105ee5760405162461bcd60e51b81526004016105e590613037565b60405180910390fd5b33600090815260036020526040812080548490811061060f5761060f613061565b906000526020600020906003020190506000600282600101548154811061063857610638613061565b90600052602060002090600a0201905060018160080154148061065f575060038160080154145b6106b65760405162461bcd60e51b815260206004820152602260248201527f50726f706f73616c206e6f742073746172746564206f7220636f6d706c657465604482015261321760f11b60648201526084016105e5565b81600201546000036106cd57600581015460028301555b6001810154600582015442916106e29161308d565b81111561070057816001015482600501546106fd919061308d565b90505b60006212750084600201548361071691906130a0565b61072091906130b3565b9050600081116107915760405162461bcd60e51b815260206004820152603660248201527f4e6f7420656e6f7567682074696d6520686173207061737365642073696e6365604482015275103630b9ba1034b73a32b932b9ba103832b934b7b21760511b60648201526084016105e5565b60006107a1620f4240601a6130d5565b600285015486546107b39085906130d5565b6107bd91906130d5565b6107c791906130b3565b90506107d662127500836130d5565b8560020160008282546107e9919061308d565b925050819055508084600701600082825461080491906130a0565b9091555061083e90506001600160a01b037f000000000000000000000000ea7b7dc089c9a4a916b5a7a37617f59fd54e37e416338361272f565b604051818152339088907faaefa0ee57d3b65e30ed500fcf5218dc4011dedc9ca2adfdc6ef1858632d464d9060200160405180910390a350505050505061088460018055565b50565b630a85bd0160e11b5b949350505050565b33600090815260036020526040902054829081106108c85760405162461bcd60e51b81526004016105e590613037565b336001600160a01b0383160361092e5760405162461bcd60e51b815260206004820152602560248201527f43616e206e6f74207472616e73666572206465706f73697420746f20796f757260448201526439b2b6331760d91b60648201526084016105e5565b6001600160a01b038216600090815260036020526040808220338352912080548590811061095e5761095e613061565b60009182526020808320845460018181018755958552828520600394850290920180549185029092019081558582015495810195909555600290810154940193909355338252909152604081208054859081106109bd576109bd613061565b60009182526020808320600392830201543384529190526040909120549091506001108015610a06575033600090815260036020526040902054610a03906001906130a0565b84105b15610ae457336000908152600360205260409020805485908110610a2c57610a2c613061565b6000918252602080832060039283020183815560018082018590556002909101849055338452919052604090912080549091610a67916130a0565b81548110610a7757610a77613061565b906000526020600020906003020160036000336001600160a01b03166001600160a01b031681526020019081526020016000208581548110610abb57610abb613061565b600091825260209091208254600390920201908155600180830154908201556002918201549101555b336000908152600360205260409020805480610b0257610b026130ec565b600082815260208120600360001990930192830201818155600181018290556002015590556040516001600160a01b03841690339086907f9760205eb671b6795c9537b7823bdcddce07afd2f3d58cf90cf52cd1e1138c6290610b689086815260200190565b60405180910390a450505050565b610b9a60405180606001604052806000815260200160008152602001600081525090565b6001600160a01b0383166000908152600360205260409020805483908110610bc457610bc4613061565b9060005260206000209060030201604051806060016040529081600082015481526020016001820154815260200160028201548152505090505b92915050565b610c0c6126d6565b600280548291908210610c315760405162461bcd60e51b81526004016105e590613102565b8260028181548110610c4557610c45613061565b60009182526020909120600a90910201546001600160a01b03163314610c7d5760405162461bcd60e51b81526004016105e59061312a565b600360028581548110610c9257610c92613061565b90600052602060002090600a02016008015414610cf15760405162461bcd60e51b815260206004820152601b60248201527f50726f706f73616c206d75737420626520636f6d706c657465642e000000000060448201526064016105e5565b60028481548110610d0457610d04613061565b90600052602060002090600a020160060154600014610d785760405162461bcd60e51b815260206004820152602a60248201527f416c6c207573657273206d7573742062652077697468647261776e2066726f6d60448201526910383937b837b9b0b61760b11b60648201526084016105e5565b600060028581548110610d8d57610d8d613061565b90600052602060002090600a02016007015411610dfa5760405162461bcd60e51b815260206004820152602560248201527f536f6d65206261636b696e672066756e6473206d757374206265206c6566742060448201526437bb32b91760d91b60648201526084016105e5565b600060028581548110610e0f57610e0f613061565b90600052602060002090600a0201600701549050600060028681548110610e3857610e38613061565b600091825260209091206007600a909202010155610e806001600160a01b037f000000000000000000000000ea7b7dc089c9a4a916b5a7a37617f59fd54e37e416338361272f565b604051339086907f867eabc55a8ac1bf0c7f26d0d4902538fd1165506b0fe99946359e9bd4d07fb690600090a35050505061088460018055565b6001600160a01b0381166000908152600360209081526040808320805482518185028101850190935280835260609492939192909184015b82821015610f425783829060005260206000209060030201604051806060016040529081600082015481526020016001820154815260200160028201548152505081526020019060010190610ef2565b505050509050919050565b3360009081526003602052604090205481908110610f7d5760405162461bcd60e51b81526004016105e590613037565b336000908152600360205260408120805484908110610f9e57610f9e613061565b9060005260206000209060030201600101549050600060028281548110610fc757610fc7613061565b90600052602060002090600a020190506000816008015490506000811480610fef5750600281145b80610ffa5750600381145b6110615760405162461bcd60e51b815260206004820152603260248201527f50726f706f73616c206d7573742062652070656e64696e672c2063616e63656c6044820152713632b2161037b91031b7b6b83632ba32b21760711b60648201526084016105e5565b60038103611115578160010154826005015461107d919061308d565b33600090815260036020526040902080548790811061109e5761109e613061565b906000526020600020906003020160020154146111155760405162461bcd60e51b815260206004820152602f60248201527f4465706f736974206d7573742062652075706461746564206265666f7265206960448201526e3a1034b9903bb4ba34323930bbb71760891b60648201526084016105e5565b33600090815260036020526040902080548690811061113657611136613061565b90600052602060002090600302016000015482600601600082825461115b91906130a0565b909155505033600090815260036020526040812080548790811061118157611181613061565b600091825260208083206003928302015433845291905260409091205490915060011080156111ca5750336000908152600360205260409020546111c7906001906130a0565b86105b156112a8573360009081526003602052604090208054879081106111f0576111f0613061565b600091825260208083206003928302018381556001808201859055600290910184905533845291905260409091208054909161122b916130a0565b8154811061123b5761123b613061565b906000526020600020906003020160036000336001600160a01b03166001600160a01b03168152602001908152602001600020878154811061127f5761127f613061565b600091825260209091208254600390920201908155600180830154908201556002918201549101555b3360009081526003602052604090208054806112c6576112c66130ec565b6000828152602081206003600019909301928302018181556001810182905560020155905561131f6001600160a01b037f000000000000000000000000ea7b7dc089c9a4a916b5a7a37617f59fd54e37e416338361272f565b604051818152339087907f1ffeac9754334c2d6c3e520537d050e250fca6bd5e266e4b5cf7215b0def97749060200160405180910390a3505050505050565b6113666126d6565b60028054829190821061138b5760405162461bcd60e51b81526004016105e590613102565b6000600284815481106113a0576113a0613061565b90600052602060002090600a0201905060008160080154146113f95760405162461bcd60e51b8152602060048201526012602482015271283937b837b9b0b6103737ba1037b832b71760711b60448201526064016105e5565b806003015442106114445760405162461bcd60e51b8152602060048201526015602482015274283937b837b9b0b6103430b99032bc3834b932b21760591b60448201526064016105e5565b611454620f4240620800006130d5565b8160060154146114ce576040805162461bcd60e51b81526020600482015260248101919091527f50726f706f73616c2773207265717565737465642048795043206d757374206260448201527f652066696c6c656420696e206f7264657220746f20626520737461727465642e60648201526084016105e5565b6001600882015542600582015560405163265aa62160e01b8152600060048201819052907f0000000000000000000000004f95846e806f19ba137b6f85f823db44f0483f0c6001600160a01b03169063265aa621906024016020604051808303816000875af1158015611545573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115699190613161565b6009830181905590506115d77f0000000000000000000000004f95846e806f19ba137b6f85f823db44f0483f0c6115a6620f4240620800006130d5565b6001600160a01b037f000000000000000000000000ea7b7dc089c9a4a916b5a7a37617f59fd54e37e4169190612797565b7f0000000000000000000000004f95846e806f19ba137b6f85f823db44f0483f0c6001600160a01b0316638119c0656040518163ffffffff1660e01b8152600401600060405180830381600087803b15801561163257600080fd5b505af1158015611646573d6000803e3d6000fd5b505060405163da95b76960e01b81526001600160a01b037f0000000000000000000000000b84dcf0d13678c68ba9ca976c02eaaa0a44932b16925063da95b769915061169a9084906004808801910161317a565b600060405180830381600087803b1580156116b457600080fd5b505af11580156116c8573d6000803e3d6000fd5b505050505050505061088460018055565b6116e16128ac565b6116eb6000612906565b565b6116fd620f4240620800006130d5565b81565b6117086128ac565b600455565b6002805483919082106117325760405162461bcd60e51b81526004016105e590613102565b836002818154811061174657611746613061565b60009182526020909120600a90910201546001600160a01b0316331461177e5760405162461bcd60e51b81526004016105e59061312a565b60016002868154811061179357611793613061565b90600052602060002090600a020160080154146117c25760405162461bcd60e51b81526004016105e59061320d565b6000600286815481106117d7576117d7613061565b90600052602060002090600a02016009015490507f0000000000000000000000000b84dcf0d13678c68ba9ca976c02eaaa0a44932b6001600160a01b031663da95b76982876040518363ffffffff1660e01b815260040161183992919061324f565b600060405180830381600087803b15801561185357600080fd5b505af1158015611867573d6000803e3d6000fd5b50505050846040516118799190613268565b6040518091039020336001600160a01b0316877ff8356fe4ac858abcf98422dd658449ebd2f3446916cd4ea3cdc7c2bf4dc69591886040516118bb9190613284565b60405180910390a4505050505050565b6118d36126d6565b6002805483919082106118f85760405162461bcd60e51b81526004016105e590613102565b60006002858154811061190d5761190d613061565b90600052602060002090600a0201905060008160080154146119665760405162461bcd60e51b8152602060048201526012602482015271283937b837b9b0b6103737ba1037b832b71760711b60448201526064016105e5565b806003015442106119b15760405162461bcd60e51b8152602060048201526015602482015274283937b837b9b0b6103430b99032bc3834b932b21760591b60448201526064016105e5565b60008411611a015760405162461bcd60e51b815260206004820152601d60248201527f4859504320616d6f756e74206d75737420626520706f7369746976652e00000060448201526064016105e5565b611a11620f4240620800006130d5565b848260060154611a21919061308d565b1115611a955760405162461bcd60e51b815260206004820152603860248201527f546f74616c2048795043206465706f736974206d757374206e6f74206578636560448201527f6564207468652072657175657374656420616d6f756e742e000000000000000060648201526084016105e5565b83816006016000828254611aa9919061308d565b909155505033600081815260036020818152604080842081516060810183528a81528084018c81529281018681528254600181810185559388529490962090519390940290930191825551918101919091559051600290910155611b39907f000000000000000000000000ea7b7dc089c9a4a916b5a7a37617f59fd54e37e46001600160a01b0316903087612956565b604051848152339086907fbe57b55595bfb8f6ba81e2e42dddbd5c7e0661ad3e3ea41ebe1787c121964dac9060200160405180910390a3505050611b7c60018055565b5050565b611bdf60405180610140016040528060006001600160a01b031681526020016000815260200160008152602001600081526020016060815260200160008152602001600081526020016000815260200160008152602001600081525090565b60028281548110611bf257611bf2613061565b90600052602060002090600a0201604051806101400160405290816000820160009054906101000a90046001600160a01b03166001600160a01b03166001600160a01b03168152602001600182015481526020016002820154815260200160038201548152602001600482018054611c6990612ffd565b80601f0160208091040260200160405190810160405280929190818152602001828054611c9590612ffd565b8015611ce25780601f10611cb757610100808354040283529160200191611ce2565b820191906000526020600020905b815481529060010190602001808311611cc557829003601f168201915b50505050508152602001600582015481526020016006820154815260200160078201548152602001600882015481526020016009820154815250509050919050565b611d2c6126d6565b600280548291908210611d515760405162461bcd60e51b81526004016105e590613102565b8260028181548110611d6557611d65613061565b60009182526020909120600a90910201546001600160a01b03163314611d9d5760405162461bcd60e51b81526004016105e59061312a565b600060028581548110611db257611db2613061565b90600052602060002090600a02016008015414611e115760405162461bcd60e51b815260206004820152601960248201527f50726f706f73616c206d7573742062652070656e64696e672e0000000000000060448201526064016105e5565b600060028581548110611e2657611e26613061565b90600052602060002090600a0201600701549050600060028681548110611e4f57611e4f613061565b90600052602060002090600a0201600701819055506002808681548110611e7857611e78613061565b600091825260209091206008600a909202010155611ec06001600160a01b037f000000000000000000000000ea7b7dc089c9a4a916b5a7a37617f59fd54e37e416338361272f565b604051339086907f253042c67143aeb6d431bb762d75e5905f18fa7850b7b9edb31fedb7c362d7e890600090a35050505061088460018055565b611f026126d6565b60038510611f7a576040805162461bcd60e51b81526020600482015260248101919091527f7465726d4e756d206d75737420626520302c20312c206f72203220283138206d60448201527f6f6e7468732c203234206d6f6e7468732c206f72203336206d6f6e746873292e60648201526084016105e5565b428211611fc95760405162461bcd60e51b815260206004820152601f60248201527f646561646c696e65206d75737420626520696e20746865206675747572652e0060448201526064016105e5565b600084116120195760405162461bcd60e51b815260206004820152601e60248201527f6261636b696e6746756e6473206d75737420626520706f7369746976652e000060448201526064016105e5565b60008351116120765760405162461bcd60e51b815260206004820152602360248201527f61737369676e6d656e74537472696e67206d757374206265206e6f6e2d656d706044820152623a3c9760e91b60648201526084016105e5565b60045481146120c75760405162461bcd60e51b815260206004820152601760248201527f506f6f6c2066656520646f65736e2774206d617463682e00000000000000000060448201526064016105e5565b6000856000036120dc57506302cfd3006120f6565b856001036120ef57506303bfc4006120f6565b5063059fa6005b6000612108620f4240620800006130d5565b9050600061211962127500846130b3565b9050600061212782846130d5565b620f4240612136601a8b6130d5565b61214091906130d5565b61214a91906130b3565b604080516101408101825233815260208101878152918101838152606082018a8152608083018c8152600060a0850181905260c0850181905260e085018f90526101008501819052610120850181905260028054600181018255915284517f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace600a90920291820180546001600160a01b0319166001600160a01b0390921691909117815595517f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5acf82015592517f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ad084015590517f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ad18301555193945090927f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ad29091019061229590826132e5565b5060a0820151600582015560c0820151600682015560e082015160078201556101008201516008820155610120909101516009909101556123016001600160a01b037f000000000000000000000000ea7b7dc089c9a4a916b5a7a37617f59fd54e37e41633308b612956565b61234c336123176000546001600160a01b031690565b6004546001600160a01b037f000000000000000000000000ea7b7dc089c9a4a916b5a7a37617f59fd54e37e416929190612956565b6002546040513391907f98120a6aaa04295520ab4e01c6c1235dd316e822cc9ff31db7b3f197366d18bd90612384908b908b906133a5565b60405180910390a35050505061239960018055565b5050505050565b6123a86128ac565b6001600160a01b03811661240d5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016105e5565b61088481612906565b61241e6126d6565b6002805482919082106124435760405162461bcd60e51b81526004016105e590613102565b60006002848154811061245857612458613061565b90600052602060002090600a02019050600181600801541461248c5760405162461bcd60e51b81526004016105e59061320d565b806001015481600501546124a0919061308d565b4210156125075760405162461bcd60e51b815260206004820152602f60248201527f50726f706f73616c206d7573742068617665207265616368656420746865206560448201526e37321037b31034ba39903a32b9369760891b60648201526084016105e5565b6003600882015560098101546040805163da95b76960e01b815260048101929092526024820152600060448201527f0000000000000000000000000b84dcf0d13678c68ba9ca976c02eaaa0a44932b6001600160a01b03169063da95b76990606401600060405180830381600087803b15801561258357600080fd5b505af1158015612597573d6000803e3d6000fd5b50505050600981015460405163095ea7b360e01b81526001600160a01b037f0000000000000000000000004f95846e806f19ba137b6f85f823db44f0483f0c8116600483015260248201929092527f0000000000000000000000000b84dcf0d13678c68ba9ca976c02eaaa0a44932b9091169063095ea7b390604401600060405180830381600087803b15801561262d57600080fd5b505af1158015612641573d6000803e3d6000fd5b505050600982015460405163db006a7560e01b81526001600160a01b037f0000000000000000000000004f95846e806f19ba137b6f85f823db44f0483f0c16925063db006a75916126989160040190815260200190565b600060405180830381600087803b1580156126b257600080fd5b505af11580156126c6573d6000803e3d6000fd5b5050505050505061088460018055565b6002600154036127285760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016105e5565b6002600155565b6040516001600160a01b03831660248201526044810182905261279290849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b031990931692909217909152612994565b505050565b8015806128115750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa1580156127eb573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061280f9190613161565b155b61287c5760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016105e5565b6040516001600160a01b03831660248201526044810182905261279290849063095ea7b360e01b9060640161275b565b6000546001600160a01b031633146116eb5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016105e5565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6040516001600160a01b038085166024830152831660448201526064810182905261298e9085906323b872dd60e01b9060840161275b565b50505050565b60006129e9826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612a669092919063ffffffff16565b8051909150156127925780806020019051810190612a0791906133c7565b6127925760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016105e5565b6060610890848460008585600080866001600160a01b03168587604051612a8d9190613268565b60006040518083038185875af1925050503d8060008114612aca576040519150601f19603f3d011682016040523d82523d6000602084013e612acf565b606091505b5091509150612ae087838387612aeb565b979650505050505050565b60608315612b5a578251600003612b53576001600160a01b0385163b612b535760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016105e5565b5081610890565b6108908383815115612b6f5781518083602001fd5b8060405162461bcd60e51b81526004016105e59190613284565b600060208284031215612b9b57600080fd5b5035919050565b60005b83811015612bbd578181015183820152602001612ba5565b50506000910152565b60008151808452612bde816020860160208601612ba2565b601f01601f19169290920160200192915050565b600061014060018060a01b038d1683528b60208401528a6040840152896060840152806080840152612c268184018a612bc6565b60a0840198909852505060c081019490945260e08401929092526101008301526101209091015295945050505050565b80356001600160a01b0381168114612c6d57600080fd5b919050565b60008060408385031215612c8557600080fd5b612c8e83612c56565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff80841115612ccd57612ccd612c9c565b604051601f8501601f19908116603f01168101908282118183101715612cf557612cf5612c9c565b81604052809350858152868686011115612d0e57600080fd5b858560208301376000602087830101525050509392505050565b60008060008060808587031215612d3e57600080fd5b612d4785612c56565b9350612d5560208601612c56565b925060408501359150606085013567ffffffffffffffff811115612d7857600080fd5b8501601f81018713612d8957600080fd5b612d9887823560208401612cb2565b91505092959194509250565b60008060408385031215612db757600080fd5b82359150612dc760208401612c56565b90509250929050565b81518152602080830151908201526040808301519082015260608101610bfe565b600060208284031215612e0357600080fd5b612e0c82612c56565b9392505050565b6020808252825182820181905260009190848201906040850190845b81811015612e6957612e568385518051825260208082015190830152604090810151910152565b9284019260609290920191600101612e2f565b50909695505050505050565b600082601f830112612e8657600080fd5b612e0c83833560208501612cb2565b60008060408385031215612ea857600080fd5b82359150602083013567ffffffffffffffff811115612ec657600080fd5b612ed285828601612e75565b9150509250929050565b60008060408385031215612eef57600080fd5b50508035926020909101359150565b60208152612f186020820183516001600160a01b03169052565b602082015160408201526040820151606082015260608201516080820152600060808301516101408060a0850152612f54610160850183612bc6565b915060a085015160c085015260c085015160e085015260e0850151610100818187015280870151915050610120818187015280870151838701525050508091505092915050565b600080600080600060a08688031215612fb357600080fd5b8535945060208601359350604086013567ffffffffffffffff811115612fd857600080fd5b612fe488828901612e75565b9598949750949560608101359550608001359392505050565b600181811c9082168061301157607f821691505b60208210810361303157634e487b7160e01b600052602260045260246000fd5b50919050565b60208082526010908201526f24b73b30b634b2103232b837b9b4ba1760811b604082015260600190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b80820180821115610bfe57610bfe613077565b81810381811115610bfe57610bfe613077565b6000826130d057634e487b7160e01b600052601260045260246000fd5b500490565b8082028115828204841417610bfe57610bfe613077565b634e487b7160e01b600052603160045260246000fd5b6020808252600e908201526d24b73b30b634b21034b73232bc1760911b604082015260600190565b6020808252601a908201527f4d757374206265206f776e6572206f662070726f706f73616c2e000000000000604082015260600190565b60006020828403121561317357600080fd5b5051919050565b828152600060206040818401526000845461319481612ffd565b80604087015260606001808416600081146131b657600181146131d0576131fe565b60ff1985168984015283151560051b8901830195506131fe565b896000528660002060005b858110156131f65781548b82018601529083019088016131db565b8a0184019650505b50939998505050505050505050565b60208082526022908201527f50726f706f73616c206d75737420626520696e20737461727465642073746174604082015261329760f11b606082015260800190565b8281526040602082015260006108906040830184612bc6565b6000825161327a818460208701612ba2565b9190910192915050565b602081526000612e0c6020830184612bc6565b601f82111561279257600081815260208120601f850160051c810160208610156132be5750805b601f850160051c820191505b818110156132dd578281556001016132ca565b505050505050565b815167ffffffffffffffff8111156132ff576132ff612c9c565b6133138161330d8454612ffd565b84613297565b602080601f83116001811461334857600084156133305750858301515b600019600386901b1c1916600185901b1785556132dd565b600085815260208120601f198616915b8281101561337757888601518255948401946001909101908401613358565b50858210156133955787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b6040815260006133b86040830185612bc6565b90508260208301529392505050565b6000602082840312156133d957600080fd5b81518015158114612e0c57600080fdfea26469706673582212208ab51d61e17bf2b732f24dcc64fb48a6cc7e588ebacd4646cba4d13a561842a464736f6c63430008130033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
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.