Skip to content

Latest commit

 

History

History
512 lines (439 loc) · 15.9 KB

PreviousLoanTokenSettingsLowerAdmin.md

File metadata and controls

512 lines (439 loc) · 15.9 KB

PreviousLoanTokenSettingsLowerAdmin.sol

View Source: contracts/mockup/previousLoanToken/PreviousLoanTokenSettingsLowerAdmin.sol

↗ Extends: AdvancedTokenStorage

PreviousLoanTokenSettingsLowerAdmin contract

Contract Members

Constants & Variables

//public members
address public sovrynContractAddress;
address public wrbtcTokenAddress;

//internal members
address internal target_;

Events

event SetTransactionLimits(address[]  addresses, uint256[]  limits);

Modifiers

onlyAdmin

modifier onlyAdmin() internal

Functions


init

function init(address _loanTokenAddress, string _name, string _symbol) public nonpayable onlyOwner 

Arguments

Name Type Description
_loanTokenAddress address
_name string
_symbol string
Source Code
function init(
        address _loanTokenAddress,
        string memory _name,
        string memory _symbol
    ) public onlyOwner {
        loanTokenAddress = _loanTokenAddress;

        name = _name;
        symbol = _symbol;
        decimals = IERC20(loanTokenAddress).decimals();

        initialPrice = 10**18; // starting price of 1
    }

constructor

function () external nonpayable
Source Code
function() external {
        revert("LoanTokenSettingsLowerAdmin - fallback not allowed");
    }

setupLoanParams

function setupLoanParams(struct LoanParamsStruct.LoanParams[] loanParamsList, bool areTorqueLoans) public nonpayable onlyAdmin 

Arguments

Name Type Description
loanParamsList struct LoanParamsStruct.LoanParams[]
areTorqueLoans bool
Source Code
function setupLoanParams(
        LoanParamsStruct.LoanParams[] memory loanParamsList,
        bool areTorqueLoans
    ) public onlyAdmin {
        bytes32[] memory loanParamsIdList;
        address _loanTokenAddress = loanTokenAddress;

        for (uint256 i = 0; i < loanParamsList.length; i++) {
            loanParamsList[i].loanToken = _loanTokenAddress;
            loanParamsList[i].maxLoanTerm = areTorqueLoans ? 0 : 28 days;
        }

        loanParamsIdList = ProtocolSettingsLike(sovrynContractAddress).setupLoanParams(
            loanParamsList
        );
        for (uint256 i = 0; i < loanParamsIdList.length; i++) {
            loanParamsIds[
                uint256(
                    keccak256(
                        abi.encodePacked(
                            loanParamsList[i].collateralToken,
                            areTorqueLoans // isTorqueLoan
                        )
                    )
                )
            ] = loanParamsIdList[i];
        }
    }

disableLoanParams

function disableLoanParams(address[] collateralTokens, bool[] isTorqueLoans) external nonpayable onlyAdmin 

Arguments

Name Type Description
collateralTokens address[]
isTorqueLoans bool[]
Source Code
function disableLoanParams(address[] calldata collateralTokens, bool[] calldata isTorqueLoans)
        external
        onlyAdmin
    {
        require(collateralTokens.length == isTorqueLoans.length, "count mismatch");

        bytes32[] memory loanParamsIdList = new bytes32[](collateralTokens.length);
        for (uint256 i = 0; i < collateralTokens.length; i++) {
            uint256 id =
                uint256(keccak256(abi.encodePacked(collateralTokens[i], isTorqueLoans[i])));
            loanParamsIdList[i] = loanParamsIds[id];
            delete loanParamsIds[id];
        }

        ProtocolSettingsLike(sovrynContractAddress).disableLoanParams(loanParamsIdList);
    }

setDemandCurve

function setDemandCurve(uint256 _baseRate, uint256 _rateMultiplier, uint256 _lowUtilBaseRate, uint256 _lowUtilRateMultiplier, uint256 _targetLevel, uint256 _kinkLevel, uint256 _maxScaleRate) public nonpayable onlyAdmin 

Arguments

Name Type Description
_baseRate uint256
_rateMultiplier uint256
_lowUtilBaseRate uint256
_lowUtilRateMultiplier uint256
_targetLevel uint256
_kinkLevel uint256
_maxScaleRate uint256
Source Code
function setDemandCurve(
        uint256 _baseRate,
        uint256 _rateMultiplier,
        uint256 _lowUtilBaseRate,
        uint256 _lowUtilRateMultiplier,
        uint256 _targetLevel,
        uint256 _kinkLevel,
        uint256 _maxScaleRate
    ) public onlyAdmin {
        require(_rateMultiplier.add(_baseRate) <= WEI_PERCENT_PRECISION, "curve params too high");
        require(
            _lowUtilRateMultiplier.add(_lowUtilBaseRate) <= WEI_PERCENT_PRECISION,
            "curve params too high"
        );

        require(
            _targetLevel <= WEI_PERCENT_PRECISION && _kinkLevel <= WEI_PERCENT_PRECISION,
            "levels too high"
        );

        baseRate = _baseRate;
        rateMultiplier = _rateMultiplier;
        lowUtilBaseRate = _lowUtilBaseRate;
        lowUtilRateMultiplier = _lowUtilRateMultiplier;

        targetLevel = _targetLevel; // 80 ether
        kinkLevel = _kinkLevel; // 90 ether
        maxScaleRate = _maxScaleRate; // 100 ether
    }

toggleFunctionPause

function toggleFunctionPause(string funcId, bool isPaused) public nonpayable onlyAdmin 

Arguments

Name Type Description
funcId string
isPaused bool
Source Code
function toggleFunctionPause(
        string memory funcId, // example: "mint(uint256,uint256)"
        bool isPaused
    ) public onlyAdmin {
        // keccak256("iToken_FunctionPause")
        bytes32 slot =
            keccak256(
                abi.encodePacked(
                    bytes4(keccak256(abi.encodePacked(funcId))),
                    uint256(0xd46a704bc285dbd6ff5ad3863506260b1df02812f4f857c8cc852317a6ac64f2)
                )
            );
        assembly {
            sstore(slot, isPaused)
        }
    }

setTransactionLimits

function setTransactionLimits(address[] addresses, uint256[] limits) public nonpayable onlyOwner 

Arguments

Name Type Description
addresses address[] the token addresses
limits uint256[] the limit denominated in the currency of the token address
Source Code
function setTransactionLimits(address[] memory addresses, uint256[] memory limits)
        public
        onlyOwner
    {
        require(addresses.length == limits.length, "mismatched array lengths");
        for (uint256 i = 0; i < addresses.length; i++) {
            transactionLimit[addresses[i]] = limits[i];
        }
        emit SetTransactionLimits(addresses, limits);
    }

Contracts