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

  1. A legal agreement is signed between the parties using OpenLaw.

  2. The Credit Delegator (CD) creates a Vault contract by interacting with the AaveCollateralVaultProxy contract, using the deployVault(address _asset) method.

  3. (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.

  4. The CD sets the maximum borrowable amount using increaseLimit(address vault, address spender, uint addedValue).

  5. The CD deposits their aToken collateral into their vault, using deposit(AaveCollateralVault vault, address aToken, uint amount).

  6. The borrower can now borrow the amount needed, by using borrow(AaveCollateralVault vault, address reserve, uint amount).

  7. Once the borrowing position is active, the borrower can repay at anytime by approve-ing the amount to repay on the AaveCollateralVaultProxy, then using repay(AaveCollateralVault vault, address reserve, uint amount).

  8. 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).

    1. 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

_asset

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

_model

uint

The interest rate model. 1 for stable, 2 for variable. Default of 2.

increaseLimit()

function increaseLimit(address vault, address spender, uint addedValue)

Increases the limit of spender by addedValue for credit delegation vault.

Parameter

Type

Description

vault

address

The address of the AaveCollateralVault that was deployed.

spender

address

The address of the spender / borrower whom is able to borrow the funds from the vault.

addedValue

uint

The maximum amount the spender is able to borrow, in base units of the asset. E.g. WBTC has 6 decimals, USDC has 8 decimals, ETH has 18 decimals.

deposit()

function deposit(AaveCollateralVault vault, address aToken, uint amount)

Deposits aToken collateral into the AaveCollateralVault to enable delegated credit.

Parameter

Type

Description

vault

AaveCollateralVault

The address of the AaveCollateralVault that was deployed.

aToken

address

The address of the aToken asset to be used as collateral.

amount

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

vault

AaveCollateralVault

The address of the AaveCollateralVault that was deployed.

reserve

address

The address of the asset to be borrowed.

amount

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

vault

AaveCollateralVault

The address of the AaveCollateralVault that was deployed.

reserve

address

The address of the asset that was borrowed.

amount

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

vault

AaveCollateralVault

The address of the AaveCollateralVault that was deployed.

aToken

address

The address of the aToken asset that was used as collateral.

amount

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