IPrimaryLendingPlatform
Overview
License: MIT
Structs info
Ratio
ProjectTokenInfo
LendingTokenInfo
DepositPosition
BorrowPosition
Functions info
grantRole (0x2f2ff15d)
Grants the role to a new account.
Parameters:
role
bytes32
The role to grant.
newModerator
address
The address of the account receiving the role.
revokeRole (0xd547741f)
Revokes the moderator role from an account.
Parameters:
role
bytes32
The role to revoke.
moderator
address
The address of the account losing the role.
setPrimaryLendingPlatformModeratorModerator (0xa0290239)
Sets the address of the new moderator contract by the admin.
Parameters:
newModeratorContract
address
The address of the new moderator contract.
setPriceOracle (0x530e784f)
Sets the address of the new price oracle by the moderator contract.
Parameters:
newPriceOracle
address
The address of the new price oracle contract.
setPrimaryLendingPlatformLeverage (0xa1ab5419)
Sets the address of the new primary index token leverage contract by the moderator contract.
Parameters:
newPrimaryLendingPlatformLeverage
address
The address of the new primary index token leverage contract.
setRelatedContract (0xdcb4252a)
Sets whether an address is a related contract or not by the moderator contract.
Parameters:
relatedContract
address
The address of the contract to be set as related.
isRelated
bool
Boolean to indicate whether the contract is related or not.
removeProjectToken (0x3af44bfa)
Removes a project token from the list by the moderator contract.
Parameters:
projectTokenId
uint256
The ID of the project token to be removed.
projectToken
address
The address of the project token to be removed.
removeLendingToken (0xc1ab02ee)
Removes a lending token from the list by the moderator contract.
Parameters:
lendingTokenId
uint256
The ID of the lending token to be removed.
lendingToken
address
The address of the lending token to be removed.
setBorrowLimitPerCollateralAsset (0x8e85cdfa)
Sets the borrow limit per collateral by the moderator contract.
Parameters:
projectToken
address
The address of the project token.
newBorrowLimit
uint256
The new borrow limit.
setBorrowLimitPerLendingAsset (0x92a39190)
Sets the borrow limit per lending asset by the moderator contract.
Parameters:
lendingToken
address
The address of the lending token.
newBorrowLimit
uint256
The new borrow limit.
setProjectTokenInfo (0x4a5333bc)
Sets the parameters for a project token
Parameters:
projectToken
address
The address of the project token
isDepositPaused
bool
The new pause status for deposit
isWithdrawPaused
bool
The new pause status for withdrawal
loanToValueRatioNumerator
uint8
The numerator of the loan-to-value ratio for the project token
loanToValueRatioDenominator
uint8
The denominator of the loan-to-value ratio for the project token
setLendingTokenInfo (0x821363a0)
Sets the bLendingToken and paused status of a lending token.
Parameters:
lendingToken
address
The address of the lending token.
bLendingToken
address
The address of the bLendingToken.
isPaused
bool
Boolean indicating whether the lending token is paused or unpaused.
loanToValueRatioNumerator
uint8
The numerator of the loan-to-value ratio for the lending token.
loanToValueRatioDenominator
uint8
The denominator of the loan-to-value ratio for the lending token.
deposit (0x47e7ef24)
Deposits project tokens and calculates the deposit position.
Parameters:
projectToken
address
The address of the project token to be deposited.
projectTokenAmount
uint256
The amount of project tokens to be deposited.
depositFromRelatedContracts (0xbf423b75)
Deposits project tokens on behalf of a user from a related contract and calculates the deposit position.
Parameters:
projectToken
address
The address of the project token to be deposited.
projectTokenAmount
uint256
The amount of project tokens to be deposited.
user
address
The address of the user who representative deposit.
beneficiary
address
The address of the beneficiary whose deposit position will be updated.
calcAndTransferDepositPosition (0x556d4704)
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:
projectToken
address
The address of the project token being withdrawn
projectTokenAmount
uint256
The amount of project tokens being withdrawn
user
address
The address of the user whose deposit position is being updated
receiver
address
The address of the user receiving the withdrawn project tokens
Return values:
[0]
uint256
The amount of project tokens transferred to the receiver
calcDepositPosition (0xdf5e6bed)
Calculates the deposit position for a user's deposit of a given amount of a project token.
Parameters:
projectToken
address
The address of the project token being deposited
projectTokenAmount
uint256
The amount of project tokens being deposited
user
address
The address of the user making the deposit
withdraw (0xf3fef3a3)
Allows a user to withdraw a given amount of a project token from their deposit position.
Parameters:
projectToken
address
The address of the project token being withdrawn
projectTokenAmount
uint256
The amount of project tokens being withdrawn
withdrawFromRelatedContracts (0x1132a65f)
Allows a related contract to initiate a withdrawal of a given amount of a project token from a user's deposit position.
Parameters:
projectToken
address
The address of the project token being withdrawn
projectTokenAmount
uint256
The amount of project tokens being withdrawn
user
address
The address of the user whose deposit position is being withdrawn from
beneficiary
address
The address of the user receiving the withdrawn project tokens
Return values:
[0]
uint256
amount of project tokens withdrawn and transferred to the beneficiary
withdraw (0x127b642e)
Allows a user to withdraw a given amount of a project token from their deposit position.
Parameters:
projectToken
address
The address of the project token being withdrawn
projectTokenAmount
uint256
The amount of project tokens being withdrawn
priceIds
bytes32[]
The priceIds need to update.
updateData
bytes[]
The updateData provided by PythNetwork.
withdrawFromRelatedContracts (0x9afab2ec)
Allows a related contract to initiate a withdrawal of a given amount of a project token from a user's deposit position.
Parameters:
projectToken
address
The address of the project token being withdrawn
projectTokenAmount
uint256
The amount of project tokens being withdrawn
user
address
The address of the user whose deposit position is being withdrawn from
beneficiary
address
The address of the user receiving the withdrawn project tokens
priceIds
bytes32[]
The priceIds need to update.
updateData
bytes[]
The updateData provided by PythNetwork.
Return values:
[0]
uint256
amount of project tokens withdrawn and transferred to the beneficiary
borrow (0xf6c0b770)
Allows a user to borrow lending tokens by providing project tokens as collateral.
Parameters:
projectToken
address
The address of the project token being used as collateral.
lendingToken
address
The address of the lending token being borrowed.
lendingTokenAmount
uint256
The amount of lending tokens to be borrowed.
borrowFromRelatedContract (0x07f4a25c)
Allows a related contract to borrow lending tokens on behalf of a user by providing project tokens as collateral.
Parameters:
projectToken
address
The address of the project token being used as collateral.
lendingToken
address
The address of the lending token being borrowed.
lendingTokenAmount
uint256
The amount of lending tokens to be borrowed.
user
address
The address of the user on whose behalf the lending tokens are being borrowed.
Return values:
amount
uint256
of lending tokens borrowed
borrow (0x5224372c)
Allows a user to borrow lending tokens by providing project tokens as collateral.
Parameters:
projectToken
address
The address of the project token being used as collateral.
lendingToken
address
The address of the lending token being borrowed.
lendingTokenAmount
uint256
The amount of lending tokens to be borrowed.
borrowFromRelatedContract (0x284a211e)
Allows a related contract to borrow lending tokens on behalf of a user by providing project tokens as collateral.
Parameters:
projectToken
address
The address of the project token being used as collateral.
lendingToken
address
The address of the lending token being borrowed.
lendingTokenAmount
uint256
The amount of lending tokens to be borrowed.
user
address
The address of the user on whose behalf the lending tokens are being borrowed.
Return values:
amount
uint256
of lending tokens borrowed
getCollateralAvailableToWithdraw (0x72620613)
Calculates the collateral available for withdrawal based on the loan-to-value ratio of a specific project token.
Parameters:
account
address
Address of the user.
projectToken
address
Address of the project token.
lendingToken
address
Address of the lending token.
Return values:
collateralProjectToWithdraw
uint256
The amount of collateral available for withdrawal in the project token.
supply (0xd07ab026)
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:
lendingToken
address
The address of the lending token being supplied.
lendingTokenAmount
uint256
The amount of the lending token being supplied.
priceIds
bytes32[]
An array of price identifiers used to update the price oracle.
updateData
bytes[]
An array of update data used to update the price oracle.
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)
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:
lendingToken
address
Address of the lending token.
lendingTokenAmount
uint256
Amount of lending tokens to be supplied.
user
address
Address of the user.
priceIds
bytes32[]
An array of price identifiers used to update the price oracle.
updateData
bytes[]
An array of update data used to update the price oracle.
redeem (0xe9bae8a8)
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:
lendingToken
address
Address of the lending token.
bLendingTokenAmount
uint256
Amount of bLending tokens to be redeemed.
priceIds
bytes32[]
An array of price identifiers used to update the price oracle.
updateData
bytes[]
An array of update data used to update the price oracle.
redeemFromRelatedContract (0xa62b7bd7)
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:
lendingToken
address
Address of the lending token.
bLendingTokenAmount
uint256
Amount of bLending tokens to be redeemed.
user
address
Address of the user.
priceIds
bytes32[]
An array of price identifiers used to update the price oracle.
updateData
bytes[]
An array of update data used to update the price oracle.
redeemUnderlying (0xb78deb78)
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:
lendingToken
address
Address of the lending token.
lendingTokenAmount
uint256
Amount of lending tokens to be redeemed.
priceIds
bytes32[]
An array of price identifiers used to update the price oracle.
updateData
bytes[]
An array of update data used to update the price oracle.
redeemUnderlyingFromRelatedContract (0x3898b641)
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:
lendingToken
address
Address of the lending token.
lendingTokenAmount
uint256
Amount of lending tokens to be redeemed.
user
address
Address of the user.
calcBorrowPosition (0x2dfee307)
Allows a related contract to calculate the new borrow position of a user.
Parameters:
borrower
address
The address of the user for whom the borrow position is being calculated.
projectToken
address
The address of the project token being used as collateral.
lendingToken
address
The address of the lending token being borrowed.
lendingTokenAmount
uint256
The amount of lending tokens being borrowed.
currentLendingToken
address
The address of the current lending token being used as collateral.
getLendingAvailableToBorrow (0x07445b52)
Calculates the lending token available amount for borrowing.
Parameters:
account
address
Address of the user.
projectToken
address
Address of the project token.
lendingToken
address
Address of the lending token.
Return values:
availableToBorrow
uint256
The amount of lending token available amount for borrowing.
repay (0x1da649cf)
Allows a borrower to repay their outstanding loan for a given project token and lending token.
Parameters:
projectToken
address
The project token's address
lendingToken
address
The lending token's address
lendingTokenAmount
uint256
The amount of lending tokens to repay
Return values:
[0]
uint256
amount of lending tokens actually repaid
repayFromRelatedContract (0xf432e4e2)
Allows a related contract to repay the outstanding loan for a given borrower's project token and lending token.
Parameters:
projectToken
address
The project token's address
lendingToken
address
The lending token's address
lendingTokenAmount
uint256
The amount of lending tokens to repay
repairer
address
The address that initiated the repair transaction
borrower
address
The borrower's address
Return values:
[0]
uint256
amount of lending tokens actually repaid
updateInterestInBorrowPositions (0x9a812edd)
This function is called to update the interest in a borrower's borrow position.
Parameters:
account
address
Address of the borrower.
lendingToken
address
Address of the lending token.
getTokensUpdateFinalPrices (0xef290120)
This function is called when performing operations using token prices, to determine which tokens will need to update their final price.
Parameters:
projectToken
address
Address of the project token.
actualLendingToken
address
Address of the lending token.
isBorrow
bool
Whether getting the list of tokens for updateFinalPrices is related to the borrowing operation or not.
Return values:
[0]
address[]
Array of tokens that need to update final price.
priceOracle (0x2630c12f)
return address of price oracle with interface of PriceProviderAggregator
projectTokens (0xb269449f)
return address project token in array projectTokens
Parameters:
projectTokenId
uint256
- index of project token in array projectTokens
. Numerates from 0 to array length - 1
lendingTokens (0x6f5f74f2)
return address lending token in array lendingTokens
Parameters:
lendingTokenId
uint256
- index of lending token in array lendingTokens
. Numerates from 0 to array length - 1
projectTokenInfo (0x85f4da5c)
Returns the info of the project token.
Return values:
[0]
struct IPrimaryLendingPlatform.ProjectTokenInfo
The address of the project token
lendingTokenInfo (0x3299093b)
Returns the address of the lending token.
Return values:
[0]
struct IPrimaryLendingPlatform.LendingTokenInfo
The address of the lending token.
getRelatedContract (0x2060128e)
Returns whether an address is a related contract or not.
Parameters:
relatedContract
address
The address of the contract to check.
Return values:
[0]
bool
isRelated Boolean indicating whether the contract is related or not.
borrowLimitPerLendingToken (0x9f9184db)
Returns the borrow limit per lending token.
Return values:
[0]
uint256
The address of the lending token.
borrowLimitPerCollateral (0x739d7547)
Returns the borrow limit per collateral token.
Return values:
[0]
uint256
The address of the project token.
totalDepositedProjectToken (0xef867f0f)
return total amount of deposited project token
Parameters:
projectToken
address
- address of project token in array projectTokens
. Numerates from 0 to array length - 1
totalBorrow (0xb090cf22)
return total borrow amount of lendingToken
by projectToken
Parameters:
projectToken
address
- address of project token
lendingToken
address
- address of lending token
pit (0x72d456af)
Returns the PIT (primary index token) value for a given account and position after a position is opened
Parameters:
account
address
Address of the account.
projectToken
address
Address of the project token.
lendingToken
address
Address of the lending token.
Return values:
[0]
uint256
The PIT value.
Formula: pit = $ * LVR
pitCollateral (0x1893be9f)
Returns the PIT (primary index token) value for a given account and collateral before a position is opened
Parameters:
account
address
Address of the account.
projectToken
address
Address of the project token.
Return values:
[0]
uint256
The PIT value.
Formula: pit = $ * LVR
getLendingToken (0x2ce36230)
Returns the actual lending token of a user's borrow position for a specific project token
Parameters:
user
address
The address of the user's borrow position
projectToken
address
The address of the project token
Return values:
actualLendingToken
address
The address of the actual lending token
pitRemaining (0xd1a3d2ae)
Returns the remaining PIT (primary index token) of a user's borrow position
Parameters:
account
address
The address of the user's borrow position
projectToken
address
The address of the project token
lendingToken
address
The address of the lending token
Return values:
remaining
uint256
The remaining PIT of the user's borrow position
totalOutstanding (0xac15382f)
Returns the total outstanding amount of a user's borrow position for a specific project token and lending token
Parameters:
account
address
The address of the user's borrow position
projectToken
address
The address of the project token
lendingToken
address
The address of the lending token
Return values:
[0]
uint256
total outstanding amount of the user's borrow position
healthFactor (0xcc224bff)
Returns the health factor of a user's borrow position for a specific project token and lending token
Parameters:
account
address
The address of the user's borrow position
projectToken
address
The address of the project token
lendingToken
address
The address of the lending token
Return values:
numerator
uint256
The numerator of the health factor
denominator
uint256
The denominator of the health factor
getTokenEvaluation (0x3598a7a9)
Returns the evaluation of a specific token amount in USD
Parameters:
token
address
The address of the token to evaluate
tokenAmount
uint256
The amount of the token to evaluate
Return values:
collateralEvaluation
uint256
the USD evaluation of token by its tokenAmount
in collateral price
capitalEvaluation
uint256
the USD evaluation of token by its tokenAmount
in capital price
lendingTokensLength (0x2412b575)
Returns the length of the lending tokens array
Return values:
[0]
uint256
The length of the lending tokens array
projectTokensLength (0x4a41d29e)
Returns the length of the project tokens array
Return values:
[0]
uint256
The length of the project tokens array
getPosition (0x713390f5)
Returns the details of a user's borrow position for a specific project token and lending token
Parameters:
account
address
The address of the user's borrow position
projectToken
address
The address of the project token
lendingToken
address
The address of the lending token
Return values:
depositedProjectTokenAmount
uint256
The amount of project tokens deposited by the user
loanBody
uint256
The amount of the lending token borrowed by the user
accrual
uint256
The accrued interest of the borrow position
healthFactorNumerator
uint256
The numerator of the health factor
healthFactorDenominator
uint256
The denominator of the health factor
getDepositedAmount (0x0fefc251)
Returns the amount of project tokens deposited by a user for a specific project token and collateral token
Parameters:
projectToken
address
The address of the project token
user
address
The address of the user
Return values:
[0]
uint256
amount of project tokens deposited by the user
getTotalBorrowPerCollateral (0x65647a59)
Get total borrow amount in USD per collateral for a specific project token
Parameters:
projectToken
address
The address of the project token
Return values:
[0]
uint256
The total borrow amount in USD
getTotalBorrowPerLendingToken (0x961540e1)
Get total borrow amount in USD for a specific lending token
Parameters:
lendingToken
address
The address of the lending token
Return values:
[0]
uint256
The total borrow amount in USD
totalOutstandingInUSD (0xb189b70a)
Convert the total outstanding amount of a user's borrow position to USD
Parameters:
account
address
The address of the user account
projectToken
address
The address of the project token
lendingToken
address
The address of the lending token
Return values:
[0]
uint256
The total outstanding amount in USD
getLoanToValueRatio (0xe84dc1b3)
Get the loan to value ratio of a position taken by a project token and a lending token
Parameters:
projectToken
address
The address of the project token
lendingToken
address
The address of the lending token
Return values:
lvrNumerator
uint256
The numerator of the loan to value ratio
lvrDenominator
uint256
The denominator of the loan to value ratio
pitCollateralWithUpdatePrices (0x902b6286)
Returns the PIT (primary index token) value for a given account and collateral before a position is opened after update price.
Parameters:
account
address
Address of the account.
projectToken
address
Address of the project token.
priceIds
bytes32[]
The priceIds need to update.
updateData
bytes[]
The updateData provided by PythNetwork.
Return values:
[0]
uint256
The PIT value.
Formula: pit = $ * LVR
pitRemainingWithUpdatePrices (0xe662d5c5)
Returns the remaining PIT (primary index token) of a user's borrow position after update price.
Parameters:
account
address
The address of the user's borrow position
projectToken
address
The address of the project token
lendingToken
address
The address of the lending token
priceIds
bytes32[]
The priceIds need to update.
updateData
bytes[]
The updateData provided by PythNetwork.
Return values:
[0]
uint256
remaining The remaining PIT of the user's borrow position
estimatedPitRemainingWithUpdatePrices (0x0c0e14a3)
Returns the estimated remaining PIT (primary index token) of a user's borrow position
Parameters:
account
address
The address of the user's borrow position
projectToken
address
The address of the project token
lendingToken
address
The address of the lending token
priceIds
bytes32[]
The priceIds need to update.
updateData
bytes[]
The updateData provided by PythNetwork.
Return values:
[0]
uint256
remaining The estimated remaining PIT of the user's borrow position
getTokenEvaluationWithUpdatePrices (0x4d247b46)
Returns the evaluation of a specific token amount in USD after update price.
Parameters:
token
address
The address of the token to evaluate
tokenAmount
uint256
The amount of the token to evaluate
priceIds
bytes32[]
The priceIds need to update.
updateData
bytes[]
The updateData provided by PythNetwork.
Return values:
[0]
uint256
The evaluated token amount in USD
getPositionWithUpdatePrices (0xa767ebd3)
Returns the details of a user's borrow position for a specific project token and lending token after update price
Parameters:
account
address
The address of the user's borrow position
projectToken
address
The address of the project token
lendingToken
address
The address of the lending token
priceIds
bytes32[]
The priceIds need to update.
updateData
bytes[]
The updateData provided by PythNetwork.
Return values:
depositedProjectTokenAmount
uint256
The amount of project tokens deposited by the user
loanBody
uint256
The amount of the lending token borrowed by the user
accrual
uint256
The accrued interest of the borrow position
healthFactorNumerator
uint256
The numerator of the health factor
healthFactorDenominator
uint256
The denominator of the health factor
totalEstimatedOutstandingInUSDWithUpdatePrices (0x7b78a351)
Returns the total estimated outstanding amount of a user's borrow position to USD after update price.
Parameters:
account
address
The address of the user account
projectToken
address
The address of the project token
lendingToken
address
The address of the lending token
priceIds
bytes32[]
The priceIds need to update.
updateData
bytes[]
The updateData provided by PythNetwork.
Return values:
[0]
uint256
The total estimated outstanding amount in USD
convertPitRemainingWithUpdatePrices (0x07a0e36c)
Convert the remaining pit amount to the corresponding lending token amount after update price.
Parameters:
account
address
The address of the user account
projectToken
address
The address of the project token
lendingToken
address
The address of the lending token
priceIds
bytes32[]
The priceIds need to update.
updateData
bytes[]
The updateData provided by PythNetwork.
Return values:
[0]
uint256
The converted lending token amount
convertEstimatedPitRemainingWithUpdatePrices (0x7200b1ef)
Convert the estimated remaining pit amount to the corresponding lending token amount after update price.
Parameters:
account
address
The address of the user account
projectToken
address
The address of the project token
lendingToken
address
The address of the lending token
priceIds
bytes32[]
The priceIds need to update.
updateData
bytes[]
The updateData provided by PythNetwork.
Return values:
[0]
uint256
The estimated lending token amount
getCollateralAvailableToWithdrawWithUpdatePrices (0x45f0219c)
Calculates the collateral available for withdrawal based on the loan-to-value ratio of a specific project token after update price.
Parameters:
account
address
Address of the user.
projectToken
address
Address of the project token.
lendingToken
address
Address of the lending token.
priceIds
bytes32[]
The priceIds need to update.
updateData
bytes[]
The updateData provided by PythNetwork.
Return values:
collateralProjectToWithdraw
uint256
The amount of collateral available for withdrawal in the project token.
getLendingAvailableToBorrow (0xdc8b040b)
Calculates the lending token available amount for borrowing after update price.
Parameters:
account
address
Address of the user.
projectToken
address
Address of the project token.
lendingToken
address
Address of the lending token.
priceIds
bytes32[]
The priceIds need to update.
updateData
bytes[]
The updateData provided by PythNetwork.
Return values:
availableToBorrow
uint256
The amount of lending token available amount for borrowing.
Last updated