contract dexBlueUtils is dexBlueStorage{
    /** @notice Get the balance of a user for a specific token
      * @param  token  The token address (ETH is address(0))
      * @param  holder The address holding the token
      * @return The amount of the specified token held by the user 
      */
    function getBalance(address token, address holder) view public returns(uint256){
        return balances[token][holder];
    }
    
    /** @notice Get index of a cached token address
      * @param  token  The token address (ETH is address(0))
      * @return The index of the token
      */
    function getTokenIndex(address token) view public returns(uint256){
        return token_indices[token];
    }
    
    /** @notice Get a cached token address from an index
      * @param  index  The index of the token
      * @return The address of the token
      */
    function getTokenFromIndex(uint256 index) view public returns(address){
        return tokens[index];
    }
    
    /** @notice Get the array containing all indexed token addresses
      * @return The array of all indexed token addresses
      */
    function getTokens() view public returns(address[] memory){
        return token_arr;
    }
    
    /** @notice Get index of a cached reserve address
      * @param  reserve  The reserve address
      * @return The index of the reserve
      */
    function getReserveIndex(address reserve) view public returns(uint256){
        return reserve_indices[reserve];
    }
    
    /** @notice Get a cached reserve address from an index
      * @param  index  The index of the reserve
      * @return The address of the reserve
      */
    function getReserveFromIndex(uint256 index) view public returns(address){
        return reserves[index];
    }
    
    /** @notice Get the array containing all publicly available reserve addresses
      * @return The array of addresses of all publicly available reserves
      */
    function getReserves() view public returns(address[] memory){
        return public_reserve_arr;
    }
    
    /** @notice Get the balance a user blocked for a single-signature withdrawal (ETH is address(0))
      * @param  token  The token address (ETH is address(0))
      * @param  holder The address holding the token
      * @return The amount of the specified token blocked by the user 
      */
    function getBlocked(address token, address holder) view public returns(uint256){
        return blocked_for_single_sig_withdrawal[token][holder];
    }
    
    /** @notice Returns the timestamp of the last blocked balance
      * @param  user  Address of the user which blocked funds
      * @return The last unix timestamp the user blocked funds at, which starts the waiting period for single-sig withdrawals 
      */
    function getLastBlockedTimestamp(address user) view public returns(uint256){
        return last_blocked_timestamp[user];
    }
    
    /** @notice We have to check returndatasize after ERC20 tokens transfers, as some tokens are implemented badly (dont return a boolean)
      * @return Whether the last ERC20 transfer failed or succeeded
      */
    function checkERC20TransferSuccess() pure internal returns(bool){
        uint256 success = 0;

        assembly {
            switch returndatasize               // Check the number of bytes the token contract returned
                case 0 {                        // Nothing returned, but contract did not throw > assume our transfer succeeded
                    success := 1
                }
                case 32 {                       // 32 bytes returned, result is the returned bool
                    returndatacopy(0, 0, 32)
                    success := mload(0)
                }
        }

        return success != 0;
    }
}
function getBlocked(address token, address holder) view public returns(uint256){
    return blocked_for_single_sig_withdrawal[token][holder];
}

/** @notice Get the balance a user blocked for a single-signature withdrawal (ETH is address(0))
 * @param  token  The token address (ETH is address(0))
 * @param  holder The address holding the token
 * @return The amount of the specified token blocked by the user 
 */