An abstract contract which contains the core logic and storage for the FraxlendPair
The constructor
function is called on deployment
The initialize
function is called immediately after deployment
This function can only be called by the deployer
The _totalAssetAvailable
function returns the total balance of Asset Tokens in the contract
The _isSolvent
function determines if a given borrower is solvent given an exchange rate
The _isPastMaturity
function determines if the current block timestamp is past the maturityDate date
Checks for solvency AFTER executing contract code
Checks if msg.sender is an approved Borrower
Checks if msg.sender and _receiver are both an approved Lender
Ensure function is not called when passed maturity
The AddInterest
event is emitted when interest is accrued by borrowers
The UpdateRate
event is emitted when the interest rate is updated
The addInterest
function is a public implementation of _addInterest and allows 3rd parties to trigger interest accrual
The _addInterest
function is invoked prior to every external function and is used to accrue interest and update interest rate
Can only called once per block
The UpdateExchangeRate
event is emitted when the Collateral:Asset exchange rate is updated
The updateExchangeRate
function is the external implementation of _updateExchangeRate.
This function is invoked at most once per block as these queries can be expensive
The _updateExchangeRate
function retrieves the latest exchange rate. i.e how much collateral to buy 1e18 asset.
This function is invoked at most once per block as these queries can be expensive
The _deposit
function is the internal implementation for lending assets
Caller must invoke ERC20.approve
on the Asset Token contract prior to calling function
The deposit
function allows a user to Lend Assets by specifying the amount of Asset Tokens to lend
Caller must invoke ERC20.approve
on the Asset Token contract prior to calling function
The mint
function allows a user to Lend assets by specifying the number of Assets Shares (fTokens) to mint
Caller must invoke ERC20.approve
on the Asset Token contract prior to calling function
The _redeem
function is an internal implementation which allows a Lender to pull their Asset Tokens out of the Pair
Caller must invoke ERC20.approve
on the Asset Token contract prior to calling function
The redeem
function allows the caller to redeem their Asset Shares for Asset Tokens
The withdraw
function allows a user to redeem their Asset Shares for a specified amount of Asset Tokens
The BorrowAsset
event is emitted when a borrower increases their position
The _borrowAsset
function is the internal implementation for borrowing assets
The borrowAsset
function allows a user to open/increase a borrow position
Borrower must call ERC20.approve
on the Collateral Token contract if applicable
The _addCollateral
function is an internal implementation for adding collateral to a borrowers position
The addCollateral
function allows the caller to add Collateral Token to a borrowers position
msg.sender must call ERC20.approve() on the Collateral Token contract prior to invocation
The RemoveCollateral
event is emitted when collateral is removed from a borrower's position
The _removeCollateral
function is the internal implementation for removing collateral from a borrower's position
The removeCollateral
function is used to remove collateral from msg.sender's borrow position
msg.sender must be solvent after invocation or transaction will revert
The RepayAsset
event is emitted whenever a debt position is repaid
The _repayAsset
function is the internal implementation for repaying a borrow position
The payer must have called ERC20.approve() on the Asset Token contract prior to invocation
The repayAsset
function allows the caller to pay down the debt for a given borrower.
Caller must first invoke ERC20.approve()
for the Asset Token contract
The Liquidate
event is emitted when a liquidation occurs
The liquidate
function allows a third party to repay a borrower's debt if they have become insolvent
Caller must invoke ERC20.approve
on the Asset Token contract prior to calling Liquidate()
The LeveragedPosition
event is emitted when a borrower takes out a new leveraged position
The leveragedPosition
function allows a user to enter a leveraged borrow position with minimal upfront Collateral
Caller must invoke ERC20.approve()
on the Collateral Token contract prior to calling function
The RepayAssetWithCollateral
event is emitted whenever repayAssetWithCollateral()
is invoked
The repayAssetWithCollateral
function allows a borrower to repay their debt using existing collateral in contract