Contract 0x5196A9034955dBADE84CF2e5F53cD3747130fE37

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x350e121d93b24657355a5cb889440c4f0ebc4d4b4d4597a5b820f9c394ebac4e0x60e06040217368182021-11-11 12:51:51238 days 3 hrs ago0xc29f1facff8c228b38e6b7681a73ca55581c1ff7 IN  Create: AssetParametersViewer0 FTM0.082116542789
[ Download CSV Export 
Latest 1 internal transaction
Parent Txn Hash Block From To Value
0x350e121d93b24657355a5cb889440c4f0ebc4d4b4d4597a5b820f9c394ebac4e217368182021-11-11 12:51:51238 days 3 hrs ago 0xc29f1facff8c228b38e6b7681a73ca55581c1ff7  Contract Creation0 FTM
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
AssetParametersViewer

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 4 : AssetParametersViewer.sol
// SPDX-License-Identifier: bsl-1.1

/*
  Copyright 2021 Unit Protocol: Artem Zakharov ([email protected]).
*/
pragma solidity 0.7.6;

pragma experimental ABIEncoderV2;

import "../interfaces/IVaultParameters.sol";
import "../interfaces/vault-managers/parameters/IVaultManagerParameters.sol";
import "../interfaces/vault-managers/parameters/IVaultManagerBorrowFeeParameters.sol";


/**
 * @notice Views collaterals in one request to save node requests and speed up dapps.
 *
 * @dev It makes no sense to clog a node with hundreds of RPC requests and slow a client app/dapp. Since usually
 *      a huge amount of gas is available to node static calls, we can aggregate asset data in a huge batch on the
 *      node's side and pull it to the client.
 */
contract AssetParametersViewer {
    IVaultParameters public immutable vaultParameters;

    IVaultManagerParameters public immutable vaultManagerParameters;
    IVaultManagerBorrowFeeParameters public immutable vaultManagerBorrowFeeParameters;

    struct AssetParameters {
        // asset address
        address asset;

        // Percentage with 3 decimals
        uint stabilityFee;

        // Percentage with 0 decimals
        uint liquidationFee;

        // Percentage with 0 decimals
        uint initialCollateralRatio;

        // Percentage with 0 decimals
        uint liquidationRatio;

        // Percentage with 3 decimals
        uint liquidationDiscount;

        // Devaluation period in blocks
        uint devaluationPeriod;

        // USDP mint limit
        uint tokenDebtLimit;

        // Oracle types enabled for this asset
        uint[] oracles;

        // Percentage with 0 decimals
        uint minColPercent;

        // Percentage with 0 decimals
        uint maxColPercent;

        // Percentage with 2 decimals (basis points)
        uint borrowFee;
    }


    constructor(address _vaultManagerParameters, address _vaultManagerBorrowFeeParameters) {
        IVaultManagerParameters vmp = IVaultManagerParameters(_vaultManagerParameters);
        vaultManagerParameters = vmp;
        vaultParameters = IVaultParameters(vmp.vaultParameters());
        vaultManagerBorrowFeeParameters = IVaultManagerBorrowFeeParameters(_vaultManagerBorrowFeeParameters);
    }

    /**
     * @notice Get parameters of one asset
     * @param asset asset address
     * @param maxOracleTypesToSearch since complete list of oracle types is unknown, we'll check types up to this number
     */
    function getAssetParameters(address asset, uint maxOracleTypesToSearch)
        public
        view
        returns (AssetParameters memory r)
    {
        r.asset = asset;
        r.stabilityFee = vaultParameters.stabilityFee(asset);
        r.liquidationFee = vaultParameters.liquidationFee(asset);

        r.initialCollateralRatio = vaultManagerParameters.initialCollateralRatio(asset);
        r.liquidationRatio = vaultManagerParameters.liquidationRatio(asset);
        r.liquidationDiscount = vaultManagerParameters.liquidationDiscount(asset);
        r.devaluationPeriod = vaultManagerParameters.devaluationPeriod(asset);

        r.tokenDebtLimit = vaultParameters.tokenDebtLimit(asset);

        r.minColPercent = vaultManagerParameters.minColPercent(asset);
        r.maxColPercent = vaultManagerParameters.maxColPercent(asset);

        r.borrowFee = vaultManagerBorrowFeeParameters.getBorrowFee(asset);

        // Memory arrays can't be reallocated so we'll overprovision
        uint[] memory foundOracleTypes = new uint[](maxOracleTypesToSearch);
        uint actualOraclesCount = 0;

        for (uint _type = 0; _type < maxOracleTypesToSearch; ++_type) {
            if (vaultParameters.isOracleTypeEnabled(_type, asset)) {
                foundOracleTypes[actualOraclesCount++] = _type;
            }
        }

        r.oracles = new uint[](actualOraclesCount);
        for (uint i = 0; i < actualOraclesCount; ++i) {
            r.oracles[i] = foundOracleTypes[i];
        }
    }

    /**
     * @notice Get parameters of many assets
     * @param assets asset addresses
     * @param maxOracleTypesToSearch since complete list of oracle types is unknown, we'll check types up to this number
     */
    function getMultiAssetParameters(address[] calldata assets, uint maxOracleTypesToSearch)
        external
        view
        returns (AssetParameters[] memory r)
    {
        uint length = assets.length;
        r = new AssetParameters[](length);
        for (uint i = 0; i < length; ++i) {
            r[i] = getAssetParameters(assets[i], maxOracleTypesToSearch);
        }
    }
}

File 2 of 4 : IVaultParameters.sol
// SPDX-License-Identifier: bsl-1.1

/*
  Copyright 2020 Unit Protocol: Artem Zakharov ([email protected]).
*/
pragma solidity ^0.7.6;

interface IVaultParameters {
    function canModifyVault ( address ) external view returns ( bool );
    function foundation (  ) external view returns ( address );
    function isManager ( address ) external view returns ( bool );
    function isOracleTypeEnabled ( uint256, address ) external view returns ( bool );
    function liquidationFee ( address ) external view returns ( uint256 );
    function setCollateral ( address asset, uint256 stabilityFeeValue, uint256 liquidationFeeValue, uint256 usdpLimit, uint256[] calldata oracles ) external;
    function setFoundation ( address newFoundation ) external;
    function setLiquidationFee ( address asset, uint256 newValue ) external;
    function setManager ( address who, bool permit ) external;
    function setOracleType ( uint256 _type, address asset, bool enabled ) external;
    function setStabilityFee ( address asset, uint256 newValue ) external;
    function setTokenDebtLimit ( address asset, uint256 limit ) external;
    function setVaultAccess ( address who, bool permit ) external;
    function stabilityFee ( address ) external view returns ( uint256 );
    function tokenDebtLimit ( address ) external view returns ( uint256 );
    function vault (  ) external view returns ( address );
    function vaultParameters (  ) external view returns ( address );
}

File 3 of 4 : IVaultManagerParameters.sol
// SPDX-License-Identifier: bsl-1.1

/*
  Copyright 2020 Unit Protocol: Artem Zakharov ([email protected]).
*/
pragma solidity ^0.7.6;

interface IVaultManagerParameters {
    function devaluationPeriod ( address ) external view returns ( uint256 );
    function initialCollateralRatio ( address ) external view returns ( uint256 );
    function liquidationDiscount ( address ) external view returns ( uint256 );
    function liquidationRatio ( address ) external view returns ( uint256 );
    function maxColPercent ( address ) external view returns ( uint256 );
    function minColPercent ( address ) external view returns ( uint256 );
    function setColPartRange ( address asset, uint256 min, uint256 max ) external;
    function setCollateral (
        address asset,
        uint256 stabilityFeeValue,
        uint256 liquidationFeeValue,
        uint256 initialCollateralRatioValue,
        uint256 liquidationRatioValue,
        uint256 liquidationDiscountValue,
        uint256 devaluationPeriodValue,
        uint256 usdpLimit,
        uint256[] calldata oracles,
        uint256 minColP,
        uint256 maxColP
    ) external;
    function setDevaluationPeriod ( address asset, uint256 newValue ) external;
    function setInitialCollateralRatio ( address asset, uint256 newValue ) external;
    function setLiquidationDiscount ( address asset, uint256 newValue ) external;
    function setLiquidationRatio ( address asset, uint256 newValue ) external;
    function vaultParameters (  ) external view returns ( address );
}

File 4 of 4 : IVaultManagerBorrowFeeParameters.sol
// SPDX-License-Identifier: bsl-1.1

/*
  Copyright 2021 Unit Protocol: Artem Zakharov ([email protected]).
*/
pragma solidity ^0.7.6;

interface IVaultManagerBorrowFeeParameters {

    /**
     * @notice 1 = 100% = 10000 basis points
     **/
    function BASIS_POINTS_IN_1() external view returns (uint);

    /**
     * @notice Borrow fee receiver
     **/
    function feeReceiver() external view returns (address);

    /**
     * @notice Sets the borrow fee receiver. Only manager is able to call this function
     * @param newFeeReceiver The address of fee receiver
     **/
    function setFeeReceiver(address newFeeReceiver) external;

    /**
     * @notice Sets the base borrow fee in basis points (1bp = 0.01% = 0.0001). Only manager is able to call this function
     * @param newBaseBorrowFeeBasisPoints The borrow fee in basis points
     **/
    function setBaseBorrowFee(uint16 newBaseBorrowFeeBasisPoints) external;

    /**
     * @notice Sets the borrow fee for a particular collateral in basis points (1bp = 0.01% = 0.0001). Only manager is able to call this function
     * @param asset The address of the main collateral token
     * @param newEnabled Is custom fee enabled for asset
     * @param newFeeBasisPoints The borrow fee in basis points
     **/
    function setAssetBorrowFee(address asset, bool newEnabled, uint16 newFeeBasisPoints) external;

    /**
     * @notice Returns borrow fee for particular collateral in basis points (1bp = 0.01% = 0.0001)
     * @param asset The address of the main collateral token
     * @return feeBasisPoints The borrow fee in basis points
     **/
    function getBorrowFee(address asset) external view returns (uint16 feeBasisPoints);

    /**
     * @notice Returns borrow fee for usdp amount for particular collateral
     * @param asset The address of the main collateral token
     * @return The borrow fee
     **/
    function calcBorrowFeeAmount(address asset, uint usdpAmount) external view returns (uint);
}

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":"_vaultManagerParameters","type":"address"},{"internalType":"address","name":"_vaultManagerBorrowFeeParameters","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"maxOracleTypesToSearch","type":"uint256"}],"name":"getAssetParameters","outputs":[{"components":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"stabilityFee","type":"uint256"},{"internalType":"uint256","name":"liquidationFee","type":"uint256"},{"internalType":"uint256","name":"initialCollateralRatio","type":"uint256"},{"internalType":"uint256","name":"liquidationRatio","type":"uint256"},{"internalType":"uint256","name":"liquidationDiscount","type":"uint256"},{"internalType":"uint256","name":"devaluationPeriod","type":"uint256"},{"internalType":"uint256","name":"tokenDebtLimit","type":"uint256"},{"internalType":"uint256[]","name":"oracles","type":"uint256[]"},{"internalType":"uint256","name":"minColPercent","type":"uint256"},{"internalType":"uint256","name":"maxColPercent","type":"uint256"},{"internalType":"uint256","name":"borrowFee","type":"uint256"}],"internalType":"struct AssetParametersViewer.AssetParameters","name":"r","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"assets","type":"address[]"},{"internalType":"uint256","name":"maxOracleTypesToSearch","type":"uint256"}],"name":"getMultiAssetParameters","outputs":[{"components":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"stabilityFee","type":"uint256"},{"internalType":"uint256","name":"liquidationFee","type":"uint256"},{"internalType":"uint256","name":"initialCollateralRatio","type":"uint256"},{"internalType":"uint256","name":"liquidationRatio","type":"uint256"},{"internalType":"uint256","name":"liquidationDiscount","type":"uint256"},{"internalType":"uint256","name":"devaluationPeriod","type":"uint256"},{"internalType":"uint256","name":"tokenDebtLimit","type":"uint256"},{"internalType":"uint256[]","name":"oracles","type":"uint256[]"},{"internalType":"uint256","name":"minColPercent","type":"uint256"},{"internalType":"uint256","name":"maxColPercent","type":"uint256"},{"internalType":"uint256","name":"borrowFee","type":"uint256"}],"internalType":"struct AssetParametersViewer.AssetParameters[]","name":"r","type":"tuple[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vaultManagerBorrowFeeParameters","outputs":[{"internalType":"contract IVaultManagerBorrowFeeParameters","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vaultManagerParameters","outputs":[{"internalType":"contract IVaultManagerParameters","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vaultParameters","outputs":[{"internalType":"contract IVaultParameters","name":"","type":"address"}],"stateMutability":"view","type":"function"}]

60e060405234801561001057600080fd5b50604051610f13380380610f1383398101604081905261002f91610123565b6000829050806001600160a01b031660a0816001600160a01b031660601b81525050806001600160a01b031663aca345ee6040518163ffffffff1660e01b815260040160206040518083038186803b15801561008a57600080fd5b505afa15801561009e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100c29190610102565b6001600160601b0319606091821b811660805292901b90911660c052506101559050565b80516001600160a01b03811681146100fd57600080fd5b919050565b600060208284031215610113578081fd5b61011c826100e6565b9392505050565b60008060408385031215610135578081fd5b61013e836100e6565b915061014c602084016100e6565b90509250929050565b60805160601c60a05160601c60c05160601c610d536101c06000398060cc52806107bc5250806101c8528061035452806103f5528061049652806105365280610678528061071a5250806101a4528061020e52806102b152806105d752806108b45250610d536000f3fe608060405234801561001057600080fd5b50600436106100575760003560e01c806313084e151461005c57806376359f4c1461007a578063aca345ee1461009a578063b7ebdc0c146100a2578063d904d44c146100aa575b600080fd5b6100646100ca565b6040516100719190610c7f565b60405180910390f35b61008d610088366004610acd565b6100ee565b6040516100719190610c93565b6100646101a2565b6100646101c6565b6100bd6100b8366004610aa4565b6101ea565b6040516100719190610cf3565b7f000000000000000000000000000000000000000000000000000000000000000081565b6060828067ffffffffffffffff8111801561010857600080fd5b5060405190808252806020026020018201604052801561014257816020015b61012f6109fd565b8152602001906001900390816101275790505b50915060005b818110156101995761017a86868381811061015f57fe5b90506020020160208101906101749190610a83565b856101ea565b83828151811061018657fe5b6020908102919091010152600101610148565b50509392505050565b7f000000000000000000000000000000000000000000000000000000000000000081565b7f000000000000000000000000000000000000000000000000000000000000000081565b6101f26109fd565b6001600160a01b038084168252604051634cbd12b960e11b81527f00000000000000000000000000000000000000000000000000000000000000009091169063997a257290610245908690600401610c7f565b60206040518083038186803b15801561025d57600080fd5b505afa158015610271573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102959190610b84565b60208201526040516332008ebd60e21b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063c8023af4906102e6908690600401610c7f565b60206040518083038186803b1580156102fe57600080fd5b505afa158015610312573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103369190610b84565b60408083019190915251635c2e224b60e11b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063b85c449690610389908690600401610c7f565b60206040518083038186803b1580156103a157600080fd5b505afa1580156103b5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103d99190610b84565b6060820152604051631dffddf160e11b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690633bffbbe29061042a908690600401610c7f565b60206040518083038186803b15801561044257600080fd5b505afa158015610456573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061047a9190610b84565b6080820152604051630ad0275160e11b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906315a04ea2906104cb908690600401610c7f565b60206040518083038186803b1580156104e357600080fd5b505afa1580156104f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061051b9190610b84565b60a082015260405162aaddb560e41b81526001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001690630aaddb509061056b908690600401610c7f565b60206040518083038186803b15801561058357600080fd5b505afa158015610597573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105bb9190610b84565b60c082015260405163797191dd60e11b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063f2e323ba9061060c908690600401610c7f565b60206040518083038186803b15801561062457600080fd5b505afa158015610638573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065c9190610b84565b60e082015260405163212ce07560e21b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906384b381d4906106ad908690600401610c7f565b60206040518083038186803b1580156106c557600080fd5b505afa1580156106d9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106fd9190610b84565b6101208201526040516335e9253960e01b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906335e925399061074f908690600401610c7f565b60206040518083038186803b15801561076757600080fd5b505afa15801561077b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061079f9190610b84565b6101408201526040516321d09aa160e21b81526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016906387426a84906107f1908690600401610c7f565b60206040518083038186803b15801561080957600080fd5b505afa15801561081d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108419190610b62565b61ffff1661016082015260008267ffffffffffffffff8111801561086457600080fd5b5060405190808252806020026020018201604052801561088e578160200160208202803683370190505b5090506000805b848110156109685760405163fec0feb360e01b81526001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063fec0feb3906108eb9084908a90600401610d06565b60206040518083038186803b15801561090357600080fd5b505afa158015610917573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061093b9190610b42565b15610960578083838060010194508151811061095357fe5b6020026020010181815250505b600101610895565b508067ffffffffffffffff8111801561098057600080fd5b506040519080825280602002602001820160405280156109aa578160200160208202803683370190505b5061010084015260005b818110156109f4578281815181106109c857fe5b602002602001015184610100015182815181106109e157fe5b60209081029190910101526001016109b4565b50505092915050565b60405180610180016040528060006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001606081526020016000815260200160008152602001600081525090565b80356001600160a01b0381168114610a7e57600080fd5b919050565b600060208284031215610a94578081fd5b610a9d82610a67565b9392505050565b60008060408385031215610ab6578081fd5b610abf83610a67565b946020939093013593505050565b600080600060408486031215610ae1578081fd5b833567ffffffffffffffff80821115610af8578283fd5b818601915086601f830112610b0b578283fd5b813581811115610b19578384fd5b8760208083028501011115610b2c578384fd5b6020928301989097509590910135949350505050565b600060208284031215610b53578081fd5b81518015158114610a9d578182fd5b600060208284031215610b73578081fd5b815161ffff81168114610a9d578182fd5b600060208284031215610b95578081fd5b5051919050565b6001600160a01b03169052565b6000815180845260208085019450808401835b83811015610bd857815187529582019590820190600101610bbc565b509495945050505050565b6000610180610bf3848451610b9c565b6020830151602085015260408301516040850152606083015160608501526080830151608085015260a083015160a085015260c083015160c085015260e083015160e0850152610100808401518282870152610c5183870182610ba9565b6101208681015190880152610140808701519088015261016095860151959096019490945250929392505050565b6001600160a01b0391909116815260200190565b6000602080830181845280855180835260408601915060408482028701019250838701855b82811015610ce657603f19888603018452610cd4858351610be3565b94509285019290850190600101610cb8565b5092979650505050505050565b600060208252610a9d6020830184610be3565b9182526001600160a01b031660208201526040019056fea26469706673582212204ed6bef7e367311505ed78fe0a0e5d4ad0e5b69e8219687f47c8510a0d92e0f064736f6c634300070600330000000000000000000000001c7aea8b6498f0854d1fce542a27ed6a10d71d2f000000000000000000000000b8b807c1841d38443d9a135f0109cf27dac78af4

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

0000000000000000000000001c7aea8b6498f0854d1fce542a27ed6a10d71d2f000000000000000000000000b8b807c1841d38443d9a135f0109cf27dac78af4

-----Decoded View---------------
Arg [0] : _vaultManagerParameters (address): 0x1c7aea8b6498f0854d1fce542a27ed6a10d71d2f
Arg [1] : _vaultManagerBorrowFeeParameters (address): 0xb8b807c1841d38443d9a135f0109cf27dac78af4

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000001c7aea8b6498f0854d1fce542a27ed6a10d71d2f
Arg [1] : 000000000000000000000000b8b807c1841d38443d9a135f0109cf27dac78af4


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Validator ID :
0 FTM

Amount Staked
0

Amount Delegated
0

Staking Total
0

Staking Start Epoch
0

Staking Start Time
0

Proof of Importance
0

Origination Score
0

Validation Score
0

Active
0

Online
0

Downtime
0 s
Address Amount claimed Rewards Created On Epoch Created On
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.