ABI & Code

Public Repo

ABI

FraxlendPairCore

An abstract contract which contains the core logic and storage for the FraxlendPair

constructor

constructor(bytes _configData, bytes _immutables, uint256 _maxLTV, uint256 _liquidationFee, uint256 _maturityDate, uint256 _penaltyRate, bool _isBorrowerWhitelistActive, bool _isLenderWhitelistActive) internal

The constructor function is called on deployment

initialize

function initialize(string _name, address[] _approvedBorrowers, address[] _approvedLenders, bytes _rateInitCallData) external

The initialize function is called immediately after deployment

This function can only be called by the deployer

_totalAssetAvailable

function _totalAssetAvailable(struct VaultAccount _totalAsset, struct VaultAccount _totalBorrow) internal pure returns (uint256)

The _totalAssetAvailable function returns the total balance of Asset Tokens in the contract

_isSolvent

function _isSolvent(address _borrower, uint256 _exchangeRate) internal view returns (bool)

The _isSolvent function determines if a given borrower is solvent given an exchange rate

_isPastMaturity

function _isPastMaturity() internal view returns (bool)

The _isPastMaturity function determines if the current block timestamp is past the maturityDate date

isSolvent

modifier isSolvent(address _borrower)

Checks for solvency AFTER executing contract code

approvedBorrower

modifier approvedBorrower()

Checks if msg.sender is an approved Borrower

approvedLender

modifier approvedLender(address _receiver)

Checks if msg.sender and _receiver are both an approved Lender

isNotPastMaturity

modifier isNotPastMaturity()

Ensure function is not called when passed maturity

AddInterest

event AddInterest(uint256 _interestEarned, uint256 _rate, uint256 _deltaTime, uint256 _feesAmount, uint256 _feesShare)

The AddInterest event is emitted when interest is accrued by borrowers

UpdateRate

event UpdateRate(uint256 _ratePerSec, uint256 _deltaTime, uint256 _utilizationRate, uint256 _newRatePerSec)

The UpdateRate event is emitted when the interest rate is updated

addInterest

function addInterest() external returns (uint256 _interestEarned, uint256 _feesAmount, uint256 _feesShare, uint64 _newRate)

The addInterest function is a public implementation of _addInterest and allows 3rd parties to trigger interest accrual

_addInterest

function _addInterest() internal returns (uint256 _interestEarned, uint256 _feesAmount, uint256 _feesShare, uint64 _newRate)

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

UpdateExchangeRate

event UpdateExchangeRate(uint256 _rate)

The UpdateExchangeRate event is emitted when the Collateral:Asset exchange rate is updated

updateExchangeRate

function updateExchangeRate() external returns (uint256 _exchangeRate)

The updateExchangeRate function is the external implementation of _updateExchangeRate.

This function is invoked at most once per block as these queries can be expensive

_updateExchangeRate

function _updateExchangeRate() internal returns (uint256 _exchangeRate)

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

_deposit

function _deposit(struct VaultAccount _totalAsset, uint128 _amount, uint128 _shares, address _receiver) internal

The _deposit function is the internal implementation for lending assets

Caller must invoke ERC20.approve on the Asset Token contract prior to calling function

deposit

function deposit(uint256 _amount, address _receiver) external returns (uint256 _sharesReceived)

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

mint

function mint(uint256 _shares, address _receiver) external returns (uint256 _amountReceived)

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

_redeem

function _redeem(struct VaultAccount _totalAsset, uint128 _amountToReturn, uint128 _shares, address _receiver, address _owner) internal

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

redeem

function redeem(uint256 _shares, address _receiver, address _owner) external returns (uint256 _amountToReturn)

The redeem function allows the caller to redeem their Asset Shares for Asset Tokens

withdraw

function withdraw(uint256 _amount, address _receiver, address _owner) external returns (uint256 _shares)

The withdraw function allows a user to redeem their Asset Shares for a specified amount of Asset Tokens

BorrowAsset

event BorrowAsset(address _borrower, address _receiver, uint256 _borrowAmount, uint256 _sharesAdded)

The BorrowAsset event is emitted when a borrower increases their position

_borrowAsset

function _borrowAsset(uint128 _borrowAmount, address _receiver) internal returns (uint256 _sharesAdded)

The _borrowAsset function is the internal implementation for borrowing assets

borrowAsset

function borrowAsset(uint256 _borrowAmount, uint256 _collateralAmount, address _receiver) external returns (uint256 _shares)

The borrowAsset function allows a user to open/increase a borrow position

Borrower must call ERC20.approve on the Collateral Token contract if applicable

_addCollateral

function _addCollateral(address _sender, uint256 _collateralAmount, address _borrower) internal

The _addCollateral function is an internal implementation for adding collateral to a borrowers position

addCollateral

function addCollateral(uint256 _collateralAmount, address _borrower) external

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

RemoveCollateral

event RemoveCollateral(address _sender, uint256 _collateralAmount, address _receiver, address _borrower)

The RemoveCollateral event is emitted when collateral is removed from a borrower's position

_removeCollateral

function _removeCollateral(uint256 _collateralAmount, address _receiver, address _borrower) internal

The _removeCollateral function is the internal implementation for removing collateral from a borrower's position

removeCollateral

function removeCollateral(uint256 _collateralAmount, address _receiver) external

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

RepayAsset

event RepayAsset(address _sender, address _borrower, uint256 _amountToRepay, uint256 _shares)

The RepayAsset event is emitted whenever a debt position is repaid

_repayAsset

function _repayAsset(struct VaultAccount _totalBorrow, uint128 _amountToRepay, uint128 _shares, address _payer, address _borrower) internal

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

repayAsset

function repayAsset(uint256 _shares, address _borrower) external returns (uint256 _amountToRepay)

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

Liquidate

event Liquidate(address _borrower, uint256 _collateralForLiquidator, uint256 _shares)

The Liquidate event is emitted when a liquidation occurs

liquidate

function liquidate(uint256 _shares, address _borrower) external returns (uint256 _collateralForLiquidator)

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()

LeveragedPosition

event LeveragedPosition(address _borrower, address _swapperAddress, uint256 _borrowAmount, uint256 _borrowShares, uint256 _initialCollateralAmount, uint256 _amountCollateralOut)

The LeveragedPosition event is emitted when a borrower takes out a new leveraged position

leveragedPosition

function leveragedPosition(address _swapperAddress, uint256 _borrowAmount, uint256 _initialCollateralAmount, uint256 _amountCollateralOutMin, address[] _path) external returns (uint256 _totalCollateralBalance)

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

RepayAssetWithCollateral

event RepayAssetWithCollateral(address _borrower, address _swapperAddress, uint256 _collateralToSwap, uint256 _amountAssetOut, uint256 _sharesRepaid)

The RepayAssetWithCollateral event is emitted whenever repayAssetWithCollateral() is invoked

repayAssetWithCollateral

function repayAssetWithCollateral(address _swapperAddress, uint256 _collateralToSwap, uint256 _amountAssetOutMin, address[] _path) external returns (uint256 _amountAssetOut)

The repayAssetWithCollateral function allows a borrower to repay their debt using existing collateral in contract

Last updated