Skip to content

Latest commit

 

History

History
631 lines (531 loc) · 19.2 KB

ProtocolLike.md

File metadata and controls

631 lines (531 loc) · 19.2 KB

ProtocolLike.sol

View Source: contracts/connectors/loantoken/interfaces/ProtocolLike.sol

ProtocolLike contract

Functions


borrowOrTradeFromPool

function borrowOrTradeFromPool(bytes32 loanParamsId, bytes32 loanId, bool isTorqueLoan, uint256 initialMargin, struct MarginTradeStructHelpers.SentAddresses sentAddresses, struct MarginTradeStructHelpers.SentAmounts sentValues, bytes loanDataBytes) external payable
returns(newPrincipal uint256, newCollateral uint256)

Arguments

Name Type Description
loanParamsId bytes32
loanId bytes32
isTorqueLoan bool
initialMargin uint256
sentAddresses struct MarginTradeStructHelpers.SentAddresses
sentValues struct MarginTradeStructHelpers.SentAmounts
loanDataBytes bytes
Source Code
function borrowOrTradeFromPool(
        bytes32 loanParamsId,
        bytes32 loanId, // if 0, start a new loan
        bool isTorqueLoan,
        uint256 initialMargin,
        MarginTradeStructHelpers.SentAddresses calldata sentAddresses,
        // lender: must match loan if loanId provided
        // borrower: must match loan if loanId provided
        // receiver: receiver of funds (address(0) assumes borrower address)
        // manager: delegated manager of loan unless address(0)
        MarginTradeStructHelpers.SentAmounts calldata sentValues,
        // newRate: new loan interest rate
        // newPrincipal: new loan size (borrowAmount + any borrowed interest)
        // torqueInterest: new amount of interest to escrow for Torque loan (determines initial loan length)
        // loanTokenReceived: total loanToken deposit (amount not sent to borrower in the case of Torque loans)
        // collateralTokenReceived: total collateralToken deposit
        bytes calldata loanDataBytes
    ) external payable returns (uint256 newPrincipal, uint256 newCollateral);

getTotalPrincipal

function getTotalPrincipal(address lender, address loanToken) external view
returns(uint256)

Arguments

Name Type Description
lender address
loanToken address
Source Code
function getTotalPrincipal(address lender, address loanToken) external view returns (uint256);

withdrawAccruedInterest

function withdrawAccruedInterest(address loanToken) external nonpayable

Arguments

Name Type Description
loanToken address
Source Code
function withdrawAccruedInterest(address loanToken) external;

getLenderInterestData

function getLenderInterestData(address lender, address loanToken) external view
returns(interestPaid uint256, interestPaidDate uint256, interestOwedPerDay uint256, interestUnPaid uint256, interestFeePercent uint256, principalTotal uint256)

Arguments

Name Type Description
lender address
loanToken address
Source Code
function getLenderInterestData(address lender, address loanToken)
        external
        view
        returns (
            uint256 interestPaid,
            uint256 interestPaidDate,
            uint256 interestOwedPerDay,
            uint256 interestUnPaid,
            uint256 interestFeePercent,
            uint256 principalTotal
        );

priceFeeds

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

getEstimatedMarginExposure

function getEstimatedMarginExposure(address loanToken, address collateralToken, uint256 loanTokenSent, uint256 collateralTokenSent, uint256 interestRate, uint256 newPrincipal) external view
returns(uint256)

Arguments

Name Type Description
loanToken address
collateralToken address
loanTokenSent uint256
collateralTokenSent uint256
interestRate uint256
newPrincipal uint256
Source Code
function getEstimatedMarginExposure(
        address loanToken,
        address collateralToken,
        uint256 loanTokenSent,
        uint256 collateralTokenSent,
        uint256 interestRate,
        uint256 newPrincipal
    ) external view returns (uint256);

getRequiredCollateral

function getRequiredCollateral(address loanToken, address collateralToken, uint256 newPrincipal, uint256 marginAmount, bool isTorqueLoan) external view
returns(collateralAmountRequired uint256)

Arguments

Name Type Description
loanToken address
collateralToken address
newPrincipal uint256
marginAmount uint256
isTorqueLoan bool
Source Code
function getRequiredCollateral(
        address loanToken,
        address collateralToken,
        uint256 newPrincipal,
        uint256 marginAmount,
        bool isTorqueLoan
    ) external view returns (uint256 collateralAmountRequired);

getBorrowAmount

function getBorrowAmount(address loanToken, address collateralToken, uint256 collateralTokenAmount, uint256 marginAmount, bool isTorqueLoan) external view
returns(borrowAmount uint256)

Arguments

Name Type Description
loanToken address
collateralToken address
collateralTokenAmount uint256
marginAmount uint256
isTorqueLoan bool
Source Code
function getBorrowAmount(
        address loanToken,
        address collateralToken,
        uint256 collateralTokenAmount,
        uint256 marginAmount,
        bool isTorqueLoan
    ) external view returns (uint256 borrowAmount);

isLoanPool

function isLoanPool(address loanPool) external view
returns(bool)

Arguments

Name Type Description
loanPool address
Source Code
function isLoanPool(address loanPool) external view returns (bool);

lendingFeePercent

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

getSwapExpectedReturn

function getSwapExpectedReturn(address sourceToken, address destToken, uint256 sourceTokenAmount) external view
returns(uint256)

Arguments

Name Type Description
sourceToken address
destToken address
sourceTokenAmount uint256
Source Code
function getSwapExpectedReturn(
        address sourceToken,
        address destToken,
        uint256 sourceTokenAmount
    ) external view returns (uint256);

borrowerNonce

function borrowerNonce(address ) external view
returns(uint256)

Arguments

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

closeWithSwap

function closeWithSwap(bytes32 loanId, address receiver, uint256 swapAmount, bool returnTokenIsCollateral, bytes ) external nonpayable
returns(loanCloseAmount uint256, withdrawAmount uint256, withdrawToken address)

Arguments

Name Type Description
loanId bytes32
receiver address
swapAmount uint256
returnTokenIsCollateral bool
bytes
Source Code
function closeWithSwap(
        bytes32 loanId,
        address receiver,
        uint256 swapAmount, // denominated in collateralToken
        bool returnTokenIsCollateral, // true: withdraws collateralToken, false: withdraws loanToken
        bytes calldata // for future use /*loanDataBytes*/
    )
        external
        returns (
            uint256 loanCloseAmount,
            uint256 withdrawAmount,
            address withdrawToken
        );

closeWithDeposit

function closeWithDeposit(bytes32 loanId, address receiver, uint256 depositAmount) external payable
returns(loanCloseAmount uint256, withdrawAmount uint256, withdrawToken address)

Arguments

Name Type Description
loanId bytes32
receiver address
depositAmount uint256
Source Code
function closeWithDeposit(
        bytes32 loanId,
        address receiver,
        uint256 depositAmount // denominated in loanToken
    )
        external
        payable
        returns (
            uint256 loanCloseAmount,
            uint256 withdrawAmount,
            address withdrawToken
        );

Contracts