IPrimaryLendingPlatform

Overview

License: MIT

interface IPrimaryLendingPlatform

Structs info

Ratio

struct Ratio {
	uint8 numerator;
	uint8 denominator;
}

ProjectTokenInfo

struct ProjectTokenInfo {
	bool isListed;
	bool isDepositPaused;
	bool isWithdrawPaused;
	IPrimaryLendingPlatform.Ratio loanToValueRatio;
}

LendingTokenInfo

struct LendingTokenInfo {
	bool isListed;
	bool isPaused;
	address bLendingToken;
}

DepositPosition

struct DepositPosition {
	uint256 depositedProjectTokenAmount;
}

BorrowPosition

struct BorrowPosition {
	uint256 loanBody;
	uint256 accrual;
}

Functions info

grantRole (0x2f2ff15d)

function grantRole(bytes32 role, address newModerator) external

Grants the role to a new account.

Parameters:

revokeRole (0xd547741f)

function revokeRole(bytes32 role, address moderator) external

Revokes the moderator role from an account.

Parameters:

setPrimaryLendingPlatformModeratorModerator (0xa0290239)

function setPrimaryLendingPlatformModeratorModerator(
    address newModeratorContract
) external

Sets the address of the new moderator contract by the admin.

Parameters:

setPriceOracle (0x530e784f)

function setPriceOracle(address newPriceOracle) external

Sets the address of the new price oracle by the moderator contract.

Parameters:

setPrimaryLendingPlatformLeverage (0xa1ab5419)

function setPrimaryLendingPlatformLeverage(
    address newPrimaryLendingPlatformLeverage
) external

Sets the address of the new primary index token leverage contract by the moderator contract.

Parameters:

setRelatedContract (0xdcb4252a)

function setRelatedContract(address relatedContract, bool isRelated) external

Sets whether an address is a related contract or not by the moderator contract.

Parameters:

removeProjectToken (0x3af44bfa)

function removeProjectToken(
    uint256 projectTokenId,
    address projectToken
) external

Removes a project token from the list by the moderator contract.

Parameters:

removeLendingToken (0xc1ab02ee)

function removeLendingToken(
    uint256 lendingTokenId,
    address lendingToken
) external

Removes a lending token from the list by the moderator contract.

Parameters:

setBorrowLimitPerCollateralAsset (0x8e85cdfa)

function setBorrowLimitPerCollateralAsset(
    address projectToken,
    uint256 newBorrowLimit
) external

Sets the borrow limit per collateral by the moderator contract.

Parameters:

setBorrowLimitPerLendingAsset (0x92a39190)

function setBorrowLimitPerLendingAsset(
    address lendingToken,
    uint256 newBorrowLimit
) external

Sets the borrow limit per lending asset by the moderator contract.

Parameters:

setProjectTokenInfo (0x4a5333bc)

function setProjectTokenInfo(
    address projectToken,
    bool isDepositPaused,
    bool isWithdrawPaused,
    uint8 loanToValueRatioNumerator,
    uint8 loanToValueRatioDenominator
) external

Sets the parameters for a project token

Parameters:

setLendingTokenInfo (0x821363a0)

function setLendingTokenInfo(
    address lendingToken,
    address bLendingToken,
    bool isPaused,
    uint8 loanToValueRatioNumerator,
    uint8 loanToValueRatioDenominator
) external

Sets the bLendingToken and paused status of a lending token.

Parameters:

deposit (0x47e7ef24)

function deposit(address projectToken, uint256 projectTokenAmount) external

Deposits project tokens and calculates the deposit position.

Parameters:

depositFromRelatedContracts (0xbf423b75)

function depositFromRelatedContracts(
    address projectToken,
    uint256 projectTokenAmount,
    address user,
    address beneficiary
) external

Deposits project tokens on behalf of a user from a related contract and calculates the deposit position.

Parameters:

calcAndTransferDepositPosition (0x556d4704)

function calcAndTransferDepositPosition(
    address projectToken,
    uint256 projectTokenAmount,
    address user,
    address receiver
) external returns (uint256)

Decreases the deposited project token amount of the user's deposit position by the given amount, transfers the given amount of project tokens to the receiver, and returns the amount transferred.

Parameters:

Return values:

calcDepositPosition (0xdf5e6bed)

function calcDepositPosition(
    address projectToken,
    uint256 projectTokenAmount,
    address user
) external

Calculates the deposit position for a user's deposit of a given amount of a project token.

Parameters:

withdraw (0xf3fef3a3)

function withdraw(address projectToken, uint256 projectTokenAmount) external

Allows a user to withdraw a given amount of a project token from their deposit position.

Parameters:

withdrawFromRelatedContracts (0x1132a65f)

function withdrawFromRelatedContracts(
    address projectToken,
    uint256 projectTokenAmount,
    address user,
    address beneficiary
) external returns (uint256)

Allows a related contract to initiate a withdrawal of a given amount of a project token from a user's deposit position.

Parameters:

Return values:

withdraw (0x127b642e)

function withdraw(
    address projectToken,
    uint256 projectTokenAmount,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable

Allows a user to withdraw a given amount of a project token from their deposit position.

Parameters:

withdrawFromRelatedContracts (0x9afab2ec)

function withdrawFromRelatedContracts(
    address projectToken,
    uint256 projectTokenAmount,
    address user,
    address beneficiary,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable returns (uint256)

Allows a related contract to initiate a withdrawal of a given amount of a project token from a user's deposit position.

Parameters:

Return values:

borrow (0xf6c0b770)

function borrow(
    address projectToken,
    address lendingToken,
    uint256 lendingTokenAmount,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable

Allows a user to borrow lending tokens by providing project tokens as collateral.

Parameters:

borrowFromRelatedContract (0x07f4a25c)

function borrowFromRelatedContract(
    address projectToken,
    address lendingToken,
    uint256 lendingTokenAmount,
    address user,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable returns (uint256 amount)

Allows a related contract to borrow lending tokens on behalf of a user by providing project tokens as collateral.

Parameters:

Return values:

borrow (0x5224372c)

function borrow(
    address projectToken,
    address lendingToken,
    uint256 lendingTokenAmount
) external

Allows a user to borrow lending tokens by providing project tokens as collateral.

Parameters:

borrowFromRelatedContract (0x284a211e)

function borrowFromRelatedContract(
    address projectToken,
    address lendingToken,
    uint256 lendingTokenAmount,
    address user
) external returns (uint256 amount)

Allows a related contract to borrow lending tokens on behalf of a user by providing project tokens as collateral.

Parameters:

Return values:

getCollateralAvailableToWithdraw (0x72620613)

function getCollateralAvailableToWithdraw(
    address account,
    address projectToken,
    address lendingToken
) external returns (uint256 collateralProjectToWithdraw)

Calculates the collateral available for withdrawal based on the loan-to-value ratio of a specific project token.

Parameters:

Return values:

supply (0xd07ab026)

function supply(
    address lendingToken,
    uint256 lendingTokenAmount,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable

Supplies a specified amount of a lending token to the platform.

Allows a user to supply a specified amount of a lending token to the platform.

Parameters:

Requirements:

  • The lending token is listed.

  • The lending token is not paused.

  • The lending token amount is greater than 0.

  • Minting the bLendingTokens is successful and the minted amount is greater than 0.

Effects:

  • Mints the corresponding bLendingTokens and credits them to the user. |

supplyFromRelatedContract (0xac160433)

function supplyFromRelatedContract(
    address lendingToken,
    uint256 lendingTokenAmount,
    address user,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable

Supplies a certain amount of lending tokens to the platform from a specific user.

Requirements:

  • The lending token is listed.

  • Called by a related contract.

  • The lending token is not paused.

  • The lending token amount is greater than 0.

  • Minting the bLendingTokens is successful and the minted amount is greater than 0.

Effects:

  • Mints the corresponding bLendingTokens and credits them to the user.

Parameters:

redeem (0xe9bae8a8)

function redeem(
    address lendingToken,
    uint256 bLendingTokenAmount,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable

Redeems a specified amount of bLendingToken from the platform.

Function that performs the redemption of bLendingToken and returns the corresponding lending token to user.

Requirements:

  • The lendingToken is listed.

  • The lending token should not be paused.

  • The bLendingTokenAmount should be greater than zero.

  • The redemption of bLendingToken should not result in a redemption error.

Effects:

  • Burns the bLendingTokens from the user.

  • Transfers the corresponding lending tokens to the user.

Parameters:

redeemFromRelatedContract (0xa62b7bd7)

function redeemFromRelatedContract(
    address lendingToken,
    uint256 bLendingTokenAmount,
    address user,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable

Function that performs the redemption of bLendingToken on behalf of a user and returns the corresponding lending token to the user by related contract.

Requirements:

  • The lendingToken is listed. _ - Called by a related contract.

  • The lending token should not be paused.

  • The bLendingTokenAmount should be greater than zero.

  • The redemption of bLendingToken should not result in a redemption error.

Effects:

  • Burns the bLendingTokens from the user.

  • Transfers the corresponding lending tokens to the user.

Parameters:

redeemUnderlying (0xb78deb78)

function redeemUnderlying(
    address lendingToken,
    uint256 lendingTokenAmount,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable

Redeems a specified amount of lendingToken from the platform.

Function that performs the redemption of lending token and returns the corresponding underlying token to user.

Requirements:

  • The lending token is listed.

  • The lending token should not be paused.

  • The lendingTokenAmount should be greater than zero.

  • The redemption of lendingToken should not result in a redemption error.

Effects:

  • Transfers the corresponding underlying tokens to the user.

Parameters:

redeemUnderlyingFromRelatedContract (0x3898b641)

function redeemUnderlyingFromRelatedContract(
    address lendingToken,
    uint256 lendingTokenAmount,
    address user,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable

Function that performs the redemption of lending token on behalf of a user and returns the corresponding underlying token to the user by related contract.

Requirements:

  • The lending token is listed.

  • Called by a related contract.

  • The lending token should not be paused.

  • The lendingTokenAmount should be greater than zero.

  • The redemption of lendingToken should not result in a redemption error.

Effects:

  • Transfers the corresponding underlying tokens to the user.

Parameters:

calcBorrowPosition (0x2dfee307)

function calcBorrowPosition(
    address borrower,
    address projectToken,
    address lendingToken,
    uint256 lendingTokenAmount,
    address currentLendingToken
) external

Allows a related contract to calculate the new borrow position of a user.

Parameters:

getLendingAvailableToBorrow (0x07445b52)

function getLendingAvailableToBorrow(
    address account,
    address projectToken,
    address lendingToken
) external returns (uint256 availableToBorrow)

Calculates the lending token available amount for borrowing.

Parameters:

Return values:

repay (0x1da649cf)

function repay(
    address projectToken,
    address lendingToken,
    uint256 lendingTokenAmount
) external returns (uint256)

Allows a borrower to repay their outstanding loan for a given project token and lending token.

Parameters:

Return values:

repayFromRelatedContract (0xf432e4e2)

function repayFromRelatedContract(
    address projectToken,
    address lendingToken,
    uint256 lendingTokenAmount,
    address repairer,
    address borrower
) external returns (uint256)

Allows a related contract to repay the outstanding loan for a given borrower's project token and lending token.

Parameters:

Return values:

updateInterestInBorrowPositions (0x9a812edd)

function updateInterestInBorrowPositions(
    address account,
    address lendingToken
) external

This function is called to update the interest in a borrower's borrow position.

Parameters:

getTokensUpdateFinalPrices (0xef290120)

function getTokensUpdateFinalPrices(
    address projectToken,
    address actualLendingToken,
    bool isBorrow
) external view returns (address[] memory)

This function is called when performing operations using token prices, to determine which tokens will need to update their final price.

Parameters:

Return values:

priceOracle (0x2630c12f)

function priceOracle() external view returns (address)

return address of price oracle with interface of PriceProviderAggregator

projectTokens (0xb269449f)

function projectTokens(uint256 projectTokenId) external view returns (address)

return address project token in array projectTokens

Parameters:

lendingTokens (0x6f5f74f2)

function lendingTokens(uint256 lendingTokenId) external view returns (address)

return address lending token in array lendingTokens

Parameters:

projectTokenInfo (0x85f4da5c)

function projectTokenInfo(
    address projectToken
) external view returns (IPrimaryLendingPlatform.ProjectTokenInfo memory)

Returns the info of the project token.

Return values:

lendingTokenInfo (0x3299093b)

function lendingTokenInfo(
    address lendingToken
) external view returns (IPrimaryLendingPlatform.LendingTokenInfo memory)

Returns the address of the lending token.

Return values:

getRelatedContract (0x2060128e)

function getRelatedContract(
    address relatedContract
) external view returns (bool)

Returns whether an address is a related contract or not.

Parameters:

Return values:

borrowLimitPerLendingToken (0x9f9184db)

function borrowLimitPerLendingToken(
    address lendingToken
) external view returns (uint256)

Returns the borrow limit per lending token.

Return values:

borrowLimitPerCollateral (0x739d7547)

function borrowLimitPerCollateral(
    address projectToken
) external view returns (uint256)

Returns the borrow limit per collateral token.

Return values:

totalDepositedProjectToken (0xef867f0f)

function totalDepositedProjectToken(
    address projectToken
) external view returns (uint256)

return total amount of deposited project token

Parameters:

totalBorrow (0xb090cf22)

function totalBorrow(
    address projectToken,
    address lendingToken
) external view returns (uint256)

return total borrow amount of lendingToken by projectToken

Parameters:

pit (0x72d456af)

function pit(
    address account,
    address projectToken,
    address lendingToken
) external view returns (uint256)

Returns the PIT (primary index token) value for a given account and position after a position is opened

Parameters:

Return values:

pitCollateral (0x1893be9f)

function pitCollateral(
    address account,
    address projectToken
) external view returns (uint256)

Returns the PIT (primary index token) value for a given account and collateral before a position is opened

Parameters:

Return values:

getLendingToken (0x2ce36230)

function getLendingToken(
    address user,
    address projectToken
) external view returns (address actualLendingToken)

Returns the actual lending token of a user's borrow position for a specific project token

Parameters:

Return values:

pitRemaining (0xd1a3d2ae)

function pitRemaining(
    address account,
    address projectToken,
    address lendingToken
) external view returns (uint256 remaining)

Returns the remaining PIT (primary index token) of a user's borrow position

Parameters:

Return values:

totalOutstanding (0xac15382f)

function totalOutstanding(
    address account,
    address projectToken,
    address lendingToken
) external view returns (uint256)

Returns the total outstanding amount of a user's borrow position for a specific project token and lending token

Parameters:

Return values:

healthFactor (0xcc224bff)

function healthFactor(
    address account,
    address projectToken,
    address lendingToken
) external view returns (uint256 numerator, uint256 denominator)

Returns the health factor of a user's borrow position for a specific project token and lending token

Parameters:

Return values:

getTokenEvaluation (0x3598a7a9)

function getTokenEvaluation(
    address token,
    uint256 tokenAmount
)
    external
    view
    returns (uint256 collateralEvaluation, uint256 capitalEvaluation)

Returns the evaluation of a specific token amount in USD

Parameters:

Return values:

lendingTokensLength (0x2412b575)

function lendingTokensLength() external view returns (uint256)

Returns the length of the lending tokens array

Return values:

projectTokensLength (0x4a41d29e)

function projectTokensLength() external view returns (uint256)

Returns the length of the project tokens array

Return values:

getPosition (0x713390f5)

function getPosition(
    address account,
    address projectToken,
    address lendingToken
)
    external
    view
    returns (
        uint256 depositedProjectTokenAmount,
        uint256 loanBody,
        uint256 accrual,
        uint256 healthFactorNumerator,
        uint256 healthFactorDenominator
    )

Returns the details of a user's borrow position for a specific project token and lending token

Parameters:

Return values:

getDepositedAmount (0x0fefc251)

function getDepositedAmount(
    address projectToken,
    address user
) external view returns (uint256)

Returns the amount of project tokens deposited by a user for a specific project token and collateral token

Parameters:

Return values:

getTotalBorrowPerCollateral (0x65647a59)

function getTotalBorrowPerCollateral(
    address projectToken
) external view returns (uint256)

Get total borrow amount in USD per collateral for a specific project token

Parameters:

Return values:

getTotalBorrowPerLendingToken (0x961540e1)

function getTotalBorrowPerLendingToken(
    address lendingToken
) external view returns (uint256)

Get total borrow amount in USD for a specific lending token

Parameters:

Return values:

totalOutstandingInUSD (0xb189b70a)

function totalOutstandingInUSD(
    address account,
    address projectToken,
    address lendingToken
) external view returns (uint256)

Convert the total outstanding amount of a user's borrow position to USD

Parameters:

Return values:

getLoanToValueRatio (0xe84dc1b3)

function getLoanToValueRatio(
    address projectToken,
    address lendingToken
) external view returns (uint256 lvrNumerator, uint256 lvrDenominator)

Get the loan to value ratio of a position taken by a project token and a lending token

Parameters:

Return values:

pitCollateralWithUpdatePrices (0x902b6286)

function pitCollateralWithUpdatePrices(
    address account,
    address projectToken,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable returns (uint256)

Returns the PIT (primary index token) value for a given account and collateral before a position is opened after update price.

Parameters:

Return values:

pitRemainingWithUpdatePrices (0xe662d5c5)

function pitRemainingWithUpdatePrices(
    address account,
    address projectToken,
    address lendingToken,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable returns (uint256)

Returns the remaining PIT (primary index token) of a user's borrow position after update price.

Parameters:

Return values:

estimatedPitRemainingWithUpdatePrices (0x0c0e14a3)

function estimatedPitRemainingWithUpdatePrices(
    address account,
    address projectToken,
    address lendingToken,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable returns (uint256)

Returns the estimated remaining PIT (primary index token) of a user's borrow position

Parameters:

Return values:

getTokenEvaluationWithUpdatePrices (0x4d247b46)

function getTokenEvaluationWithUpdatePrices(
    address token,
    uint256 tokenAmount,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable returns (uint256)

Returns the evaluation of a specific token amount in USD after update price.

Parameters:

Return values:

getPositionWithUpdatePrices (0xa767ebd3)

function getPositionWithUpdatePrices(
    address account,
    address projectToken,
    address lendingToken,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
)
    external
    payable
    returns (
        uint256 depositedProjectTokenAmount,
        uint256 loanBody,
        uint256 accrual,
        uint256 healthFactorNumerator,
        uint256 healthFactorDenominator
    )

Returns the details of a user's borrow position for a specific project token and lending token after update price

Parameters:

Return values:

totalEstimatedOutstandingInUSDWithUpdatePrices (0x7b78a351)

function totalEstimatedOutstandingInUSDWithUpdatePrices(
    address account,
    address projectToken,
    address lendingToken,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable returns (uint256)

Returns the total estimated outstanding amount of a user's borrow position to USD after update price.

Parameters:

Return values:

convertPitRemainingWithUpdatePrices (0x07a0e36c)

function convertPitRemainingWithUpdatePrices(
    address account,
    address projectToken,
    address lendingToken,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable returns (uint256)

Convert the remaining pit amount to the corresponding lending token amount after update price.

Parameters:

Return values:

convertEstimatedPitRemainingWithUpdatePrices (0x7200b1ef)

function convertEstimatedPitRemainingWithUpdatePrices(
    address account,
    address projectToken,
    address lendingToken,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable returns (uint256)

Convert the estimated remaining pit amount to the corresponding lending token amount after update price.

Parameters:

Return values:

getCollateralAvailableToWithdrawWithUpdatePrices (0x45f0219c)

function getCollateralAvailableToWithdrawWithUpdatePrices(
    address account,
    address projectToken,
    address lendingToken,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable returns (uint256 collateralProjectToWithdraw)

Calculates the collateral available for withdrawal based on the loan-to-value ratio of a specific project token after update price.

Parameters:

Return values:

getLendingAvailableToBorrow (0xdc8b040b)

function getLendingAvailableToBorrow(
    address account,
    address projectToken,
    address lendingToken,
    bytes32[] memory priceIds,
    bytes[] calldata updateData
) external payable returns (uint256 availableToBorrow)

Calculates the lending token available amount for borrowing after update price.

Parameters:

Return values:

Last updated