PrimaryLendingPlatformV2Core
Overview
License: MIT
Core contract for the Primary Lending Platform V2.
Abstract contract that defines the core functionality of the primary lending platform.
Structs info
Ratio
ProjectTokenInfo
LendingTokenInfo
BorrowPosition
Events info
Deposit
Emitted when a user deposits project tokens.
Parameters:
Withdraw
Emitted when a user withdraws project tokens.
Parameters:
Supply
Emitted when a user supplies lending tokens.
Parameters:
Redeem
Emitted when a user redeems bTokens for the underlying token.
Parameters:
RedeemUnderlying
Emitted when a user redeems underlying token for the bToken.
Parameters:
Borrow
Emitted when a user borrows lending tokens.
Parameters:
RepayBorrow
Emitted when a user repays borrowed lending tokens.
Parameters:
SetModeratorContract
Emitted when the moderator contract address is updated.
Parameters:
Constants info
MODERATOR_ROLE (0x797669c9)
State variables info
priceOracle (0x2630c12f)
projectTokens (0xb269449f)
projectTokenInfo (0x85f4da5c)
lendingTokens (0x6f5f74f2)
lendingTokenInfo (0x3299093b)
totalDepositedProjectToken (0xef867f0f)
borrowPosition (0xa9ce9417)
totalBorrow (0xb090cf22)
borrowLimitPerCollateral (0x739d7547)
totalBorrowPerLendingToken (0xc3ee8b6f)
borrowLimitPerLendingToken (0x9f9184db)
isRelatedContract (0x25de3084)
primaryLendingPlatformLeverage (0x10c0bbed)
primaryLendingPlatformModerator (0xf32d0f2f)
Modifiers info
onlyAdmin
Modifier that allows only the admin to call the function.
isProjectTokenListed
Modifier that requires the project token to be listed.
Parameters:
isLendingTokenListed
Modifier that requires the lending token to be listed.
Parameters:
onlyRelatedContracts
Modifier that allows only related contracts to call the function.
onlyModeratorContract
Modifier that allows only the moderator contract to call the function.
Functions info
initialize (0x8129fc1c)
Initializes the contract and sets the name, symbol, and default roles.
setPrimaryLendingPlatformModerator (0x4123cf11)
Sets the address of the new moderator contract for the Primary Lending Platform.
Requirements:
newModeratorContract
cannot be the zero address.Only the admin can call this function.
Parameters:
setPriceOracle (0x530e784f)
Sets the price oracle contract address.
Requirements:
Only the moderator contract can call this function.
Parameters:
setPrimaryLendingPlatformLeverage (0xa1ab5419)
Sets the address of the new primary index token leverage contract by the moderator contract.
Requirements:
Only the moderator contract can call this function.
Parameters:
setRelatedContract (0xdcb4252a)
Sets the related contract status for a given contract address.
Requirements:
The caller must be the moderator contract.
Parameters:
removeProjectToken (0x3af44bfa)
Removes a project token from the platform.
Requirements:
The caller must be the moderator contract.
The project token must exist in the platform.
Parameters:
removeLendingToken (0xc1ab02ee)
Removes a lending token from the platform.
Requirements:
The caller must be the moderator contract.
The lending token address must be valid.
Parameters:
setBorrowLimitPerCollateralAsset (0x8e85cdfa)
Sets the borrow limit for a specific collateral asset.
Requirements:
The caller must be the moderator contract.
Parameters:
setBorrowLimitPerLendingAsset (0x92a39190)
Sets the borrow limit for a specific lending asset.
Requirements:
The caller must be the moderator contract.
Parameters:
setProjectTokenInfo (0x4a5333bc)
Sets the information of a project token.
Requirements:
The caller must be the moderator contract.
Parameters:
setLendingTokenInfo (0x821363a0)
Sets the lending token information for a given lending token.
Requirements:
The caller must be the moderator contract.
Parameters:
deposit (0x47e7ef24)
Deposits project tokens into the platform.
Deposits project tokens and calculates the deposit position.
Requirements:
The project token must be listed.
The project token must not be paused for deposits.
The project token amount must be greater than 0.
Effects:
Transfers the project tokens from the user to the contract.
Calculates the deposit position for the user.
Parameters:
depositFromRelatedContracts (0xbf423b75)
Deposits project tokens from related contracts into the platform.
Requirements:
The project token must be listed.
Caller must be a related contract.
The project token must not be paused for deposits.
The project token amount must be greater than 0.
Effects:
Transfers the project tokens from the user to the contract.
Calculates the deposit position for the user.
Parameters:
calcAndTransferDepositPosition (0x556d4704)
Calculates and transfers the deposit position of a user for a specific project token.
Requirements:
The project token must be listed.
Called by a related contract.
Effects:
Decreases the deposited project token amount in the user's deposit position.
Decreases the total deposited project token amount.
Transfers the project tokens to the receiver.
Parameters:
Return values:
calcDepositPosition (0xdf5e6bed)
Calculates the deposit position for a user based on the project token, project token amount and user address.
Requirements:
The project token must be listed.
Called by a related contract.
Parameters:
getCollateralAvailableToWithdraw (0x72620613)
Calculates the amount of collateral available to withdraw for a given account, project token and lending token.
Parameters:
Return values:
calcBorrowPosition (0x2dfee307)
Allows a related contract to calculate the new borrow position of a user.
Requirements:
The project token must be listed.
The lending token must be listed.
Called by a related contract.
Parameters:
getLendingAvailableToBorrow (0x07445b52)
Calculates the lending token available amount for borrowing.
Parameters:
Return values:
repay (0x1da649cf)
Repays a specified amount of lendingToken for a given project token and lending token.
Allows a borrower to repay their outstanding loan for a given project token and lending token.
Requirements:
The project token must be listed.
The lending token must be listed.
The lending amount must be greater than 0.
The borrower must have an outstanding loan for the given project and lending token before.
Effects: Updates the interest in the borrower's borrow positions for the given lendingToken
.
Repays the specified
lendingTokenAmount
towards the borrower's loan.May fully or partially repay the borrow position, depending on the repayment amount and outstanding loan.
Parameters:
Return values:
repayFromRelatedContract (0xf432e4e2)
Allows a related contract to repay the outstanding loan for a given borrower's project token and lending token.
Requirements:
The project token must be listed.
The lending token must be listed.
Called by a related contract.
The lending amount must be greater than 0.
The borrower must have an outstanding loan for the given project and lending token before.
Effects: Updates the interest in the borrower's borrow positions for the given lendingToken
.
Repays the specified
lendingTokenAmount
towards the borrower's loan.May fully or partially repay the borrow position, depending on the repayment amount and outstanding loan.
Parameters:
Return values:
updateInterestInBorrowPositions (0x9a812edd)
This function is called to update the interest in a borrower's borrow position.
Parameters:
getTokensUpdateFinalPrices (0xef290120)
This function is called when performing operations using token prices, to determine which tokens will need to update their final price.
Parameters:
Return values:
pit (0x72d456af)
Returns the PIT (primary index token) value for a given account and position after a position is opened.
Formula: pit = $ * LVR of position.
Parameters:
Return values:
pitCollateral (0x1893be9f)
Returns the PIT (primary index token) value for a given account and collateral before a position is opened.
Formula: pit = $ * LVR of project token.
Parameters:
Return values:
getLendingToken (0x2ce36230)
Returns the actual lending token of a user's borrow position for a specific project token.
Parameters:
Return values:
pitRemaining (0xd1a3d2ae)
Returns the remaining PIT (primary index token) of a user's borrow position.
Parameters:
Return values:
totalOutstanding (0xac15382f)
Returns the total outstanding amount of a user's borrow position for a specific project token and lending token.
Parameters:
Return values:
healthFactor (0xcc224bff)
Returns the health factor of a user's borrow position for a specific project token and lending token.
Parameters:
Return values:
getTokenEvaluation (0x3598a7a9)
Returns the price of a specific token amount in USD.
Parameters:
Return values:
lendingTokensLength (0x2412b575)
Returns the length of the lending tokens array.
Return values:
projectTokensLength (0x4a41d29e)
Returns the length of the project tokens array.
Return values:
getPosition (0x713390f5)
Returns the details of a user's borrow position for a specific project token and lending token.
Parameters:
Return values:
getDepositedAmount (0x0fefc251)
Returns the amount of project tokens deposited by a user for a specific project token and collateral token.
Parameters:
Return values:
getRelatedContract (0x2060128e)
Returns whether an address is a related contract or not.
Parameters:
Return values:
getTotalBorrowPerCollateral (0x65647a59)
Gets total borrow amount in USD per collateral for a specific project token.
Parameters:
Return values:
getTotalBorrowPerLendingToken (0x961540e1)
Gets total borrow amount in USD for a specific lending token.
Parameters:
Return values:
totalOutstandingInUSD (0xb189b70a)
Converts the total outstanding amount of a user's borrow position to USD.
Parameters:
Return values:
getLoanToValueRatio (0xe84dc1b3)
Gets the loan to value ratio of a position made by a project token and a lending token.
Parameters:
Return values:
Last updated