LendersVault
View Methods
collection
function collection(
uint256 collectionId
) external view returns (DataTypes.IntentCollection memory)
View-only function to fetch the Intent Collection using the collection number as a parameter. It returns the data associated with that particular collection.
Parameters
Name | Type | Description |
---|---|---|
collectionId | uint256 | The collection number |
Returns
Name | Type | Description |
---|---|---|
_intents[collectionId] | IntentCollection | The intent collection associated with that vault |
intent
function intent(
uint256 collectionId,
uint256 intentId
) external view returns (
address,
address,
bool,
DataTypes.Intent memory)
View-only function to fetch the Intent using collection number and the intent index. It returns the data associated with that particular intent.
Parameters
Name | Type | Description |
---|---|---|
collectionId | uint256 | The collection number |
intentId | uint256 | The intent index from that collection |
Returns
Name | Type | Description |
---|---|---|
collToken | address | Address of the collateral token |
borrowToken | address | Address of the borrow token |
isEnabled | bool | If intent is valid or not |
intents[intentId] | Intent | The complete intent |
Write Methods
createIntentCollection
function createIntentCollection(
DataTypes.IntentCollection calldata _collection
) external onlyOwner returns (uint256 collectionId)
Lender use this function to create a new intent collection for this particular vault. It accepts a custom-defined data-type which comprises of collateral token, borrow token, intent array etc. It returns the index of the new collection.
Parameters
Name | Type | Description |
---|---|---|
_collection | IntentCollection | The collection of all the intents |
Returns
Name | Type | Description |
---|---|---|
collectionId | uint256 | The collection number associated with the vault |
IMPORTANT
Only the owner i.e the Lender who created the vault can call this function.
extendIntentCollection
function extendIntentCollection(
uint256 collectionId,
uint256 newExpiry
) external onlyOwner
Intent collection has a expiresAt value associated with it. The collection would no more be valid after this duration. This function can be used to extend the collection duration. It accepts the collection number and the new expiry time.
Parameters
Name | Type | Description |
---|---|---|
collectionId | uint256 | The collection number |
newExpiry | uint256 | New time expiry |
IMPORTANT
Only the owner can call this function.
setIntentCollectionStatus
function setIntentCollectionStatus(
uint256 collectionId,
bool status
) external onlyOwner
Used to set the validity of the intent collection. It takes the collection number and the status. Status is a boolean which can be true | false. If the status is set to false, the borrower can not borrow using these set of intents.
Parameters
Name | Type | Description |
---|---|---|
collectionId | uint256 | The collection number |
status | bool | Intent status(true or false) |
createLoan
function createLoan(
DataTypes.BorrowParams calldata bParams,
bytes calldata data
) external whenNotPaused nonReentrant returns (address loanContract)
Function is called by the borrower who wants to take a loan from this particular vault. It accepts the details about the borrow including collateral amount, minimum borrow amount etc. All of this is passed as a custom data-type borrowParams. It also takes some data in case of leverage. Empty string is passed for no leverage loans.
Parameters
Name | Type | Description |
---|---|---|
bParams | BorrowParams | The Borrow Parameters set by the borrower |
data | bytes | ABI encoded data that contains info about leverage |
Returns
Name | Type | Description |
---|---|---|
loanContract | address | Address of the deployed loan contract |
withdraw
function withdraw(
address token,
uint256 amount
) external nonReentrant onlyOwner
Function allows the lender to withdraw the funds from the Vault. The Vault may or may not have funds of different assets depending upon whether the borrower was able to pay the loan before the expiration time or not. Hence it takes the token address as a parameter to withdraw the particular token and its amount.
IMPORTANT
Only the owner can call this function.
Parameters
Name | Type | Description |
---|---|---|
token | address | Address of the token |
amount | uint256 | Amount to withdraw |