DelegatedLenderVault
Contract Overview
The DelegatedLenderVault
contract is designed to manage a lending vault with a single active intent at any given time. This intent is derived from a strategy contract that uses an oracle to determine the spot price of a token and applies a discount factor or as the stratgy defines it. The contract supports functionalities such as pausing/unpausing the vault, depositing/withdrawing tokens, setting collection parameters, and creating loans.
Read Methods
1. getPopulatedCollection
Returns
Name | Type | Description |
---|---|---|
invalidHealth | bool | Indicates if the strategy is unhealthy or the vault is paused. |
c | DataTypes.IntentCollection memory | The populated intent collection. |
This function retrieves the current intent data from the strategy and populates the base collection with this data. It also checks if the strategy is unhealthy or if the vault is paused.
2. reentrancyGuardEntered
Returns
Name | Type | Description |
---|---|---|
| bool | Indicates if the reentrancy guard is currently entered. |
This function checks if the reentrancy guard is active, which helps prevent reentrant calls to the contract.
Write Methods
1. initialize
Parameters
Name | Type | Description |
---|---|---|
_strategy | address | The address of the strategy contract. |
_owner | address | The address of the owner. |
Initializes the contract with the provided strategy and owner addresses. It sets up the base collection with default values and transfers ownership to the specified owner.
Notice:
- Modifier: Only the contract owner can call this function.
- Reason: To ensure that only the designated owner can initialize the contract with the correct strategy and ownership details.
2. pauseVault
Pauses the vault, preventing certain actions from being performed. Can only be called by the owner.
Notice:
- Modifier: Only the contract owner can call this function.
- Reason: To allow the owner to pause the vault in case of emergencies or maintenance.
3. unpauseVault
Unpauses the vault, allowing actions to be performed again. Can only be called by the owner.
Notice:
- Modifier: Only the contract owner can call this function.
- Reason: To allow the owner to resume vault operations after an emergency or maintenance.
4. withdraw
Parameters
Name | Type | Description |
---|---|---|
token | address | The address of the token to withdraw. |
amount | uint256 | The amount of tokens to withdraw. |
Withdraws the specified amount of tokens from the vault to the owner's address. Reverts if the amount is zero or exceeds the vault's balance.
Notice:
- Modifier: Only the contract owner can call this function.
- Reason: To ensure that only the owner can withdraw tokens from the vault, maintaining control over the assets.
5. deposit
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of tokens to deposit. |
Deposits the specified amount of tokens into the vault from the owner's address. Reverts if the amount is zero.
Notice:
- Modifier: Only the contract owner can call this function.
- Reason: To ensure that only the owner can deposit tokens into the vault, maintaining control over the assets.
6. setCollectionExpiry
Parameters
Name | Type | Description |
---|---|---|
expiryTimestamp | uint256 | The new expiry timestamp for the collection. |
Sets the expiry timestamp for the base collection. Can be set to a past timestamp.
Notice:
- Modifier: Only the contract owner can call this function.
- Reason: To allow the owner to manage the expiry of the collection, ensuring it aligns with the intended loan terms.
7. setMinMaxLoanAmt
Parameters
Name | Type | Description |
---|---|---|
minLoanAmt | uint256 | The minimum loan amount. |
maxLoanAmt | uint256 | The maximum loan amount. |
Sets the minimum and maximum loan amounts for the base collection. Reverts if the minimum amount is greater than or equal to the maximum amount.
Notice:
- Modifier: Only the contract owner can call this function.
- Reason: To allow the owner to define the acceptable loan amount range, ensuring it aligns with the vault's risk management strategy.
8. setCollectionStatus
Parameters
Name | Type | Description |
---|---|---|
status | bool | The new status of the collection (enabled or disabled). |
Sets the enabled status of the base collection. Can be used to effectively pause the collection.
Notice:
- Modifier: Only the contract owner can call this function.
- Reason: To allow the owner to enable or disable the collection, providing control over the vault's operational status.
9. createLoan
Parameters
Name | Type | Description |
---|---|---|
bParams | DataTypes.BorrowParams calldata | The borrow parameters provided by the borrower. |
data | bytes calldata | Additional data provided by the borrower for sourcing collateral. |
Returns
Name | Type | Description |
---|---|---|
loanContract | address | The address of the newly created loan contract. |
Creates a new loan contract based on the provided borrow parameters. Transfers the loan amount to the borrower and the collateral amount to the loan contract. If additional data is provided, it calls the sourceCollateral function on the borrower.
Notice:
- Modifier: Can be called by any user.
- Reason: To allow borrowers to create loans based on the vault's intent, facilitating the lending process.