S Price: $0.551714 (-0.84%)

Contract Diff Checker

Contract Name:
VestedTotalReader

Contract Source Code:

File 1 of 1 : VestedTotalReader

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

interface IPacaFinance {
    function getVestedTotals(address[] calldata _tokens)
        external
        view
        returns (
            uint256[] memory amounts,
            uint256[] memory usdValues,
            uint256 totalUsd
        );
}

contract VestedTotalReader {
    address public immutable mainContract;
    address[] public tokenList;

    /**
     * @dev Constructor takes the main contract address and 2 individual token addresses.
     */
    constructor(
        address _mainContract,
        address _token1,
        address _token2
    ) {
        require(_mainContract != address(0), "Main contract address cannot be zero");
        mainContract = _mainContract;

        // Add non-zero token addresses to the token list
        if (_token1 != address(0)) tokenList.push(_token1);
        if (_token2 != address(0)) tokenList.push(_token2);
    }

    /**
     * @dev Fetch the total vested USD value for the predefined token list.
     */
    function getTotalVestedUsd() external view returns (uint256) {
        (, , uint256 totalUsd) = IPacaFinance(mainContract).getVestedTotals(tokenList);
        return totalUsd;
    }

    /**
     * @dev Updates the token list for vested queries.
     * Only the owner of the contract should call this in production scenarios (add access control as needed).
     */
    function updateTokenList(address[] calldata _tokens) external {
        require(_tokens.length == 2, "Token list must contain exactly 2 tokens");
        tokenList = _tokens;
    }

    /**
     * @dev Retrieves the current token list.
     */
    function getTokenList() external view returns (address[] memory) {
        return tokenList;
    }
}

Please enter a contract address above to load the contract details and source code.

Context size (optional):