Skip to content

Latest commit

 

History

History
1555 lines (1209 loc) · 38.2 KB

ILoanTokenModules.md

File metadata and controls

1555 lines (1209 loc) · 38.2 KB

ILoanTokenModules.sol

View Source: contracts/interfaces/ILoanTokenModules.sol

ILoanTokenModules contract

Structs

LoanParams

struct LoanParams {
 bytes32 id,
 bool active,
 address owner,
 address loanToken,
 address collateralToken,
 uint256 minInitialMargin,
 uint256 maintenanceMargin,
 uint256 maxLoanTerm
}

Events

event Transfer(address indexed from, address indexed to, uint256  value);
event Approval(address indexed owner, address indexed spender, uint256  value);
event AllowanceUpdate(address indexed owner, address indexed spender, uint256  valueBefore, uint256  valueAfter);
event Mint(address indexed minter, uint256  tokenAmount, uint256  assetAmount, uint256  price);
event Burn(address indexed burner, uint256  tokenAmount, uint256  assetAmount, uint256  price);
event FlashBorrow(address  borrower, address  target, address  loanToken, uint256  loanAmount);
event SetTransactionLimits(address[]  addresses, uint256[]  limits);
event WithdrawRBTCTo(address indexed to, uint256  amount);
event ToggledFunctionPaused(string  functionId, bool  prevFlag, bool  newFlag);

Functions


setAdmin

function setAdmin(address _admin) external nonpayable

Arguments

Name Type Description
_admin address
Source Code
function setAdmin(address _admin) external;

setPauser

function setPauser(address _pauser) external nonpayable

Arguments

Name Type Description
_pauser address
Source Code
function setPauser(address _pauser) external;

setupLoanParams

function setupLoanParams(struct ILoanTokenModules.LoanParams[] loanParamsList, bool areTorqueLoans) external nonpayable

Arguments

Name Type Description
loanParamsList struct ILoanTokenModules.LoanParams[]
areTorqueLoans bool
Source Code
function setupLoanParams(LoanParams[] calldata loanParamsList, bool areTorqueLoans) external;

disableLoanParams

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

Arguments

Name Type Description
collateralTokens address[]
isTorqueLoans bool[]
Source Code
function disableLoanParams(address[] calldata collateralTokens, bool[] calldata isTorqueLoans)
        external;

setDemandCurve

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

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
    ) external;

toggleFunctionPause

function toggleFunctionPause(string funcId, bool isPaused) external nonpayable

Arguments

Name Type Description
funcId string
isPaused bool
Source Code
function toggleFunctionPause(
        string calldata funcId, /// example: "mint(uint256,uint256)"
        bool isPaused
    ) external;

setTransactionLimits

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

Arguments

Name Type Description
addresses address[]
limits uint256[]
Source Code
function setTransactionLimits(address[] calldata addresses, uint256[] calldata limits)
        external;

changeLoanTokenNameAndSymbol

function changeLoanTokenNameAndSymbol(string _name, string _symbol) external nonpayable

Arguments

Name Type Description
_name string
_symbol string
Source Code
function changeLoanTokenNameAndSymbol(string calldata _name, string calldata _symbol) external;

marginTrade

function marginTrade(bytes32 loanId, uint256 leverageAmount, uint256 loanTokenSent, uint256 collateralTokenSent, address collateralTokenAddress, address trader, uint256 minEntryPrice, bytes loanDataBytes) external payable
returns(uint256, uint256)

Arguments

Name Type Description
loanId bytes32
leverageAmount uint256
loanTokenSent uint256
collateralTokenSent uint256
collateralTokenAddress address
trader address
minEntryPrice uint256
loanDataBytes bytes
Source Code
function marginTrade(
        bytes32 loanId, /// 0 if new loan
        uint256 leverageAmount, /// Expected in x * 10**18 where x is the actual leverage (2, 3, 4, or 5).
        uint256 loanTokenSent,
        uint256 collateralTokenSent,
        address collateralTokenAddress,
        address trader,
        uint256 minEntryPrice, // Value of loan token in collateral.
        bytes calldata loanDataBytes /// Arbitrary order data.
    )
        external
        payable
        returns (
            uint256,
            uint256 /// Returns new principal and new collateral added to trade.
        );

marginTradeAffiliate

function marginTradeAffiliate(bytes32 loanId, uint256 leverageAmount, uint256 loanTokenSent, uint256 collateralTokenSent, address collateralTokenAddress, address trader, uint256 minEntryPrice, address affiliateReferrer, bytes loanDataBytes) external payable
returns(uint256, uint256)

Arguments

Name Type Description
loanId bytes32
leverageAmount uint256
loanTokenSent uint256
collateralTokenSent uint256
collateralTokenAddress address
trader address
minEntryPrice uint256
affiliateReferrer address
loanDataBytes bytes
Source Code
function marginTradeAffiliate(
        bytes32 loanId, // 0 if new loan
        uint256 leverageAmount, // expected in x * 10**18 where x is the actual leverage (2, 3, 4, or 5)
        uint256 loanTokenSent,
        uint256 collateralTokenSent,
        address collateralTokenAddress,
        address trader,
        uint256 minEntryPrice, // Value of loan token in collateral.
        address affiliateReferrer, // The user was brought by the affiliate (referrer).
        bytes calldata loanDataBytes // Arbitrary order data.
    )
        external
        payable
        returns (
            uint256,
            uint256 /// Returns new principal and new collateral added to trade.
        );

borrowInterestRate

function borrowInterestRate() external view
returns(uint256)
Source Code
function borrowInterestRate() external view returns (uint256);

mint

function mint(address receiver, uint256 depositAmount) external nonpayable
returns(mintAmount uint256)

Arguments

Name Type Description
receiver address
depositAmount uint256
Source Code
function mint(address receiver, uint256 depositAmount) external returns (uint256 mintAmount);

burn

function burn(address receiver, uint256 burnAmount) external nonpayable
returns(loanAmountPaid uint256)

Arguments

Name Type Description
receiver address
burnAmount uint256
Source Code
function burn(address receiver, uint256 burnAmount) external returns (uint256 loanAmountPaid);

checkPause

function checkPause(string funcId) external view
returns(isPaused bool)

Arguments

Name Type Description
funcId string
Source Code
function checkPause(string calldata funcId) external view returns (bool isPaused);

nextBorrowInterestRate

function nextBorrowInterestRate(uint256 borrowAmount) external view
returns(uint256)

Arguments

Name Type Description
borrowAmount uint256
Source Code
function nextBorrowInterestRate(uint256 borrowAmount) external view returns (uint256);

totalAssetBorrow

function totalAssetBorrow() external view
returns(uint256)
Source Code
function totalAssetBorrow() external view returns (uint256);

totalAssetSupply

function totalAssetSupply() external view
returns(uint256)
Source Code
function totalAssetSupply() external view returns (uint256);

borrow

function borrow(bytes32 loanId, uint256 withdrawAmount, uint256 initialLoanDuration, uint256 collateralTokenSent, address collateralTokenAddress, address borrower, address receiver, bytes ) external payable
returns(uint256, uint256)

Arguments

Name Type Description
loanId bytes32
withdrawAmount uint256
initialLoanDuration uint256
collateralTokenSent uint256
collateralTokenAddress address
borrower address
receiver address
bytes
Source Code
function borrow(
        bytes32 loanId, /// 0 if new loan.
        uint256 withdrawAmount,
        uint256 initialLoanDuration, /// Duration in seconds.
        uint256 collateralTokenSent, /// If 0, loanId must be provided; any rBTC sent must equal this value.
        address collateralTokenAddress, /// If address(0), this means rBTC and rBTC must be sent with the call or loanId must be provided.
        address borrower,
        address receiver,
        bytes calldata /// loanDataBytes: arbitrary order data (for future use).
    )
        external
        payable
        returns (
            uint256,
            uint256 /// Returns new principal and new collateral added to loan.
        );

transfer

function transfer(address _to, uint256 _value) external nonpayable
returns(bool)

Arguments

Name Type Description
_to address
_value uint256
Source Code
function transfer(address _to, uint256 _value) external returns (bool);

transferFrom

function transferFrom(address _from, address _to, uint256 _value) external nonpayable
returns(bool)

Arguments

Name Type Description
_from address
_to address
_value uint256
Source Code
function transferFrom(
        address _from,
        address _to,
        uint256 _value
    ) external returns (bool);

setLiquidityMiningAddress

function setLiquidityMiningAddress(address LMAddress) external nonpayable

Arguments

Name Type Description
LMAddress address
Source Code
function setLiquidityMiningAddress(address LMAddress) external;

getLiquidityMiningAddress

function getLiquidityMiningAddress() external view
returns(address)
Source Code
function getLiquidityMiningAddress() external view returns (address);

getEstimatedMarginDetails

function getEstimatedMarginDetails(uint256 leverageAmount, uint256 loanTokenSent, uint256 collateralTokenSent, address collateralTokenAddress) external view
returns(principal uint256, collateral uint256, interestRate uint256)

Arguments

Name Type Description
leverageAmount uint256
loanTokenSent uint256
collateralTokenSent uint256
collateralTokenAddress address
Source Code
function getEstimatedMarginDetails(
        uint256 leverageAmount,
        uint256 loanTokenSent,
        uint256 collateralTokenSent,
        address collateralTokenAddress // address(0) means ETH
    )
        external
        view
        returns (
            uint256 principal,
            uint256 collateral,
            uint256 interestRate
        );

getDepositAmountForBorrow

function getDepositAmountForBorrow(uint256 borrowAmount, uint256 initialLoanDuration, address collateralTokenAddress) external view
returns(depositAmount uint256)

Arguments

Name Type Description
borrowAmount uint256
initialLoanDuration uint256
collateralTokenAddress address
Source Code
function getDepositAmountForBorrow(
        uint256 borrowAmount,
        uint256 initialLoanDuration, /// Duration in seconds.
        address collateralTokenAddress /// address(0) means rBTC
    ) external view returns (uint256 depositAmount);

getBorrowAmountForDeposit

function getBorrowAmountForDeposit(uint256 depositAmount, uint256 initialLoanDuration, address collateralTokenAddress) external view
returns(borrowAmount uint256)

Arguments

Name Type Description
depositAmount uint256
initialLoanDuration uint256
collateralTokenAddress address
Source Code
function getBorrowAmountForDeposit(
        uint256 depositAmount,
        uint256 initialLoanDuration, /// Duration in seconds.
        address collateralTokenAddress /// address(0) means rBTC
    ) external view returns (uint256 borrowAmount);

checkPriceDivergence

function checkPriceDivergence(uint256 loanTokenSent, address collateralTokenAddress, uint256 minEntryPrice) external view

Arguments

Name Type Description
loanTokenSent uint256
collateralTokenAddress address
minEntryPrice uint256
Source Code
function checkPriceDivergence(
        uint256 loanTokenSent,
        address collateralTokenAddress,
        uint256 minEntryPrice
    ) external view;

getMaxEscrowAmount

function getMaxEscrowAmount(uint256 leverageAmount) external view
returns(maxEscrowAmount uint256)

Arguments

Name Type Description
leverageAmount uint256
Source Code
function getMaxEscrowAmount(uint256 leverageAmount)
        external
        view
        returns (uint256 maxEscrowAmount);

checkpointPrice

function checkpointPrice(address _user) external view
returns(price uint256)

Arguments

Name Type Description
_user address
Source Code
function checkpointPrice(address _user) external view returns (uint256 price);

assetBalanceOf

function assetBalanceOf(address _owner) external view
returns(uint256)

Arguments

Name Type Description
_owner address
Source Code
function assetBalanceOf(address _owner) external view returns (uint256);

profitOf

function profitOf(address user) external view
returns(int256)

Arguments

Name Type Description
user address
Source Code
function profitOf(address user) external view returns (int256);

tokenPrice

function tokenPrice() external view
returns(price uint256)
Source Code
function tokenPrice() external view returns (uint256 price);

avgBorrowInterestRate

function avgBorrowInterestRate() external view
returns(uint256)
Source Code
function avgBorrowInterestRate() external view returns (uint256);

supplyInterestRate

function supplyInterestRate() external view
returns(uint256)
Source Code
function supplyInterestRate() external view returns (uint256);

nextSupplyInterestRate

function nextSupplyInterestRate(uint256 supplyAmount) external view
returns(uint256)

Arguments

Name Type Description
supplyAmount uint256
Source Code
function nextSupplyInterestRate(uint256 supplyAmount) external view returns (uint256);

totalSupplyInterestRate

function totalSupplyInterestRate(uint256 assetSupply) external view
returns(uint256)

Arguments

Name Type Description
assetSupply uint256
Source Code
function totalSupplyInterestRate(uint256 assetSupply) external view returns (uint256);

loanTokenAddress

function loanTokenAddress() external view
returns(address)
Source Code
function loanTokenAddress() external view returns (address);

getMarginBorrowAmountAndRate

function getMarginBorrowAmountAndRate(uint256 leverageAmount, uint256 depositAmount) external view
returns(uint256, uint256)

Arguments

Name Type Description
leverageAmount uint256
depositAmount uint256
Source Code
function getMarginBorrowAmountAndRate(uint256 leverageAmount, uint256 depositAmount)
        external
        view
        returns (uint256, uint256);

withdrawRBTCTo

function withdrawRBTCTo(address payable _receiverAddress, uint256 _amount) external nonpayable

Arguments

Name Type Description
_receiverAddress address payable
_amount uint256
Source Code
function withdrawRBTCTo(address payable _receiverAddress, uint256 _amount) external;

initialPrice

function initialPrice() external view
returns(uint256)
Source Code
function initialPrice() external view returns (uint256);

mint

function mint(address receiver, uint256 depositAmount, bool useLM) external nonpayable
returns(minted uint256)

Arguments

Name Type Description
receiver address
depositAmount uint256
useLM bool
Source Code
function mint(
        address receiver,
        uint256 depositAmount,
        bool useLM
    ) external returns (uint256 minted);

burn

function burn(address receiver, uint256 burnAmount, bool useLM) external nonpayable
returns(redeemed uint256)

Arguments

Name Type Description
receiver address
burnAmount uint256
useLM bool
Source Code
function burn(
        address receiver,
        uint256 burnAmount,
        bool useLM
    ) external returns (uint256 redeemed);

mintWithBTC

function mintWithBTC(address receiver, bool useLM) external payable
returns(mintAmount uint256)

Arguments

Name Type Description
receiver address
useLM bool
Source Code
function mintWithBTC(address receiver, bool useLM)
        external
        payable
        returns (uint256 mintAmount);

burnToBTC

function burnToBTC(address receiver, uint256 burnAmount, bool useLM) external nonpayable
returns(loanAmountPaid uint256)

Arguments

Name Type Description
receiver address
burnAmount uint256
useLM bool
Source Code
function burnToBTC(
        address receiver,
        uint256 burnAmount,
        bool useLM
    ) external returns (uint256 loanAmountPaid);

pauser

function pauser() external view
returns(address)
Source Code
function pauser() external view returns (address);

liquidityMiningAddress

function liquidityMiningAddress() external view
returns(address)
Source Code
function liquidityMiningAddress() external view returns (address);

name

function name() external view
returns(string)
Source Code
function name() external view returns (string memory);

symbol

function symbol() external view
returns(string)
Source Code
function symbol() external view returns (string memory);

approve

function approve(address _spender, uint256 _value) external nonpayable
returns(bool)

Arguments

Name Type Description
_spender address
_value uint256
Source Code
function approve(address _spender, uint256 _value) external returns (bool);

allowance

function allowance(address _owner, address _spender) external view
returns(uint256)

Arguments

Name Type Description
_owner address
_spender address
Source Code
function allowance(address _owner, address _spender) external view returns (uint256);

balanceOf

function balanceOf(address _owner) external view
returns(uint256)

Arguments

Name Type Description
_owner address
Source Code
function balanceOf(address _owner) external view returns (uint256);

totalSupply

function totalSupply() external view
returns(uint256)
Source Code
function totalSupply() external view returns (uint256);

loanParamsIds

function loanParamsIds(uint256 ) external view
returns(bytes32)

Arguments

Name Type Description
uint256
Source Code
function loanParamsIds(uint256) external view returns (bytes32);

Contracts