// File: /contracts/VestingClaim.sol



// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import "./interfaces/ITokenMinter.sol";
import "./interfaces/ITokenLocker.sol";
import "./interfaces/IPrismaVesting.sol";

contract VestingClaim{

    address public immutable escrow;
    address public immutable prismaVesting;
    address public immutable convexproxy;
    address public immutable cvxprisma;

    
    event Claimed(address indexed _address, uint256 _amount);

    constructor(address _proxy, address _cvxprisma, address _escrow, address _prismaVesting){
        convexproxy = _proxy;
        cvxprisma = _cvxprisma;
        escrow = _escrow;
        prismaVesting = _prismaVesting;
    }

    function claimToConvexFull() external{
        claimToConvex(0);
    }

    function claimToConvex(uint256 _amount) public{
        //get previous
        (uint256 beforeAmount,) = ITokenLocker(escrow).getAccountBalances(convexproxy);
        beforeAmount *= ITokenLocker(escrow).lockToTokenRatio();

        //call claim
        IPrismaVesting(prismaVesting).lockFutureClaimsWithReceiver(msg.sender, convexproxy, _amount);

        //get difference
        (uint256 afterAmount,) = ITokenLocker(escrow).getAccountBalances(convexproxy);
        afterAmount *= ITokenLocker(escrow).lockToTokenRatio();

        //mint
        ITokenMinter(cvxprisma).mint(msg.sender, afterAmount - beforeAmount);

        emit Claimed(msg.sender, afterAmount - beforeAmount);
    }

}
// File: /contracts/interfaces/ITokenMinter.sol



// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

interface ITokenMinter{
    function mint(address,uint256) external;
    function burn(address,uint256) external;
    function setOperator(address _operator, bool _active) external;
}
// File: /contracts/interfaces/ITokenLocker.sol



// SPDX-License-Identifier: MIT

pragma solidity 0.8.19;

interface ITokenLocker {
    struct LockData {
        uint amount;
        uint weeksToUnlock;
    }

    function lock(address _account, uint256 _amount, uint256 _weeks) external returns (bool);
    function withdrawExpiredLocks(uint256 _weeks) external returns (bool);
    function withdrawWithPenalty(uint amountToWithdraw) external returns (uint);

    function getAccountBalances(address account) external view returns (uint256 locked, uint256 unlocked);
    function getAccountActiveLocks(
        address account,
        uint minWeeks
    ) external view returns (LockData[] memory lockData, uint frozenAmount);

    function getAccountWeightAt(address account, uint week) external view returns (uint256);

    function getTotalWeightAt(uint week) external view returns (uint256);

    function getWithdrawWithPenaltyAmounts(address account, uint amountToWithdraw) external view returns (uint amountWithdrawn, uint penaltyAmountPaid);

    function lockToTokenRatio() external view returns (uint256);

    function freeze() external;
}

// File: /contracts/interfaces/IPrismaVesting.sol



// SPDX-License-Identifier: MIT

pragma solidity 0.8.19;

//interface for Prisma Vesting.
interface IPrismaVesting {
    function lockFutureClaimsWithReceiver(
        address account,
        address receiver,
        uint256 amount
    ) external;

    function setDelegateApproval(address _delegate, bool _isApproved) external;
}