Credit Delegation
This section is for users whom have already set up an optional agreement on OpenLaw.
For examples that don't use OpenLaw, see Fair Launch Capital vault or yborrow.finance.
If you're looking to utilise Credit Delegation in some way, we'd love to hear about your use case on our Developer Discord.
Credit Delegation is a feature of Aave which allows a Credit Delegator to delegate the credit of their account's position to a Borrower. The terms of the Credit Delegation are decided and agreed between the parties off-chain, using OpenLaw.
Overview
A legal agreement is signed between the parties using OpenLaw.
The Credit Delegator (CD) creates a Vault contract by interacting with the
AaveCollateralVaultProxy
contract, using thedeployVault(address _asset)
method.(Optional) The CD sets a borrow rate model, using
setModel(AaveCollateralVault vault, uint model)
. If this call is not made, then a variable rate model is used by default.The CD sets the maximum borrowable amount using
increaseLimit(address vault, address spender, uint addedValue)
.The CD deposits their aToken collateral into their vault, using
deposit(AaveCollateralVault vault, address aToken, uint amount)
.The borrower can now borrow the amount needed, by using
borrow(AaveCollateralVault vault, address reserve, uint amount)
.Once the borrowing position is active, the borrower can repay at anytime by
approve
-ing the amount to repay on theAaveCollateralVaultProxy
, then usingrepay(AaveCollateralVault vault, address reserve, uint amount)
.When the terms of the agreement are finished, or at any point that the CD considers appropriate, the aToken collateral can be withdrawn using
withdraw(AaveCollateralVault vault, address aToken, uint amount)
.The borrow position must be fully repaid before all aToken collateral can be withdrawn.
Important Considerations
Ensure that the Loan To Value (LTV) is sufficiently healthy.
Ensure that the aToken used in the vault can be used as collateral.
Deployed Contracts
OpenLaw Loan Agreement
An open source example of an OpenLaw loan agreement can be found here. This can be used (and improved) by anyone, however before signing the contract, the parties should seek legal counsel.
Audits
The Credit Delegation contract has been audited by PeckShield and can be downloaded below:
Methods
deployVault()
function deployVault(address _asset)
Deploys a vault with _asset
to be borrowed.
Parameter | Type | Description |
| address | address of the asset to be borrowed. |
Returns the address of the newly deployed AaveCollateralVault.
setModel()
function setModel(uint _model)
Changes the interest rate model between stable or variable interest rate.
Parameter | Type | Description |
| uint | The interest rate model. |
increaseLimit()
function increaseLimit(address vault, address spender, uint addedValue)
Increases the limit of spender
by addedValue
for credit delegation vault
.
Parameter | Type | Description |
| address | The address of the |
| address | The address of the spender / borrower whom is able to borrow the funds from the vault. |
| uint | The maximum amount the |
deposit()
function deposit(AaveCollateralVault vault, address aToken, uint amount)
Deposits aToken collateral into the AaveCollateralVault
to enable delegated credit.
Parameter | Type | Description |
| AaveCollateralVault | The address of the |
| address | The address of the aToken asset to be used as collateral. |
| uint | The amount to be deposited, in base units of the asset. E.g. WBTC has 6 decimals, USDC has 8 decimals, ETH has 18 decimals. |
borrow()
function borrow(AaveCollateralVault vault, address reserve, uint amount)
Only the spender
can call this method to borrow the amount under the maximum borrowable amount.
Parameter | Type | Description |
| AaveCollateralVault | The address of the |
| address | The address of the asset to be borrowed. |
| uint | The amount to be borrowed, in base units of the asset. E.g. WBTC has 6 decimals, USDC has 8 decimals, ETH has 18 decimals. |
repay()
function repay(AaveCollateralVault vault, address reserve, uint amount)
A vault's borrowed amount can be repaid by calling this method.
Before calling repay()
, the sender must approve()
the AaveCollateralVaultProxy
for the amount
to be repaid.
Any amount sent above the total borrowed amount is considered additional interest for the Credit Delegator.
Parameter | Type | Description |
| AaveCollateralVault | The address of the |
| address | The address of the asset that was borrowed. |
| uint | The amount to be repaid, in base units of the asset. E.g. WBTC has 6 decimals, USDC has 8 decimals, ETH has 18 decimals. |
withdraw()
function withdraw(AaveCollateralVault vault, address aToken, uint amount)
The Credit Delegator can withdraw the aToken collateral when appropriate.
Ensure that the borrow position has been fully repaid, otherwise it will not be possible to withdraw the entire amount of aToken collateral.
Parameter | Type | Description |
| AaveCollateralVault | The address of the |
| address | The address of the aToken asset that was used as collateral. |
| uint | The amount of aTokens to withdraw, in base units of the asset. E.g. WBTC has 6 decimals, USDC has 8 decimals, ETH has 18 decimals. |
Last updated