Vaults

In Backd, vaults contain the logic for allocating funds to yield-farming strategies. Each liquidity pool has a pool-specific vault, which contains the logic for allocating funds of the pool’s underlying asset to a strategy. A vault allocates a portion of the total deposits it receives to a strategy, while the remainder is kept idle to reduce gas withdrawal costs.

Vaults are single strategy vaults, i.e. only one strategy can be active per vault. The vault is responsible for harvesting strategy profits, as well as withdraw strategy funds should the strategy exceed the allowed debt limit.

Vaults do not need to be interacted with by anyone apart from the vault’s liquidity pool and the admin. Funds can only ever be withdrawn from the vault to the liquidity pool.

The admin is able to update the following vault parameters:

  • targetAllocation: Ratio of underlying funds that should be allocated to strategy.

  • bound: Symmetric deviation bound for target allocation ratio.

  • performanceFee: Fee charged on harvested profits.

  • strategistFee: Share of performance fee that will be paid to strategist.

  • reserveFactor: Share of profits that should be kept as an emergency reserve.

  • debtLimit: Maximum debt (percentage) that a strategy may make before funds are pulled out from it.

  • strategy: Strategy of the vault.

  • strategist: Strategist of the vault’s current strategy.

There are several contracts and accounts a vault interacts with:

  • pool: The liquidity pool that deposits into and withdraws from the vault.

  • reserve: The vault’s reserve that contains a share of the harvested profits in case a strategy ever makes a loss.

  • treasury: The protocol’s treasury, which receives a portion of the profits. These funds are allocated to Backd governance token holders.

  • strategist: The creator of the vault’s active strategy, who receives a profit share.

  • strategy: The strategy currently in place to generate yield with vault deposits.

Vault Information

Vault.getUnderlying() public view returns (address)

Get the underlying asset of a vault. This will return address(0) if the underlying asset is ETH.

Vault.getTotalUnderlying() external view override returns (uint256)

Get the total underlying held by the vault. This includes the strategy allocation.

Note

This does not include unharvested profits or losses.

Vault.currentAllocated() public view returns (uint256)

Get the total amount of underlying funds allocated to strategy since last harvest.

Vault.pool() public view returns (address)

Get the liquidity pool of the vault.

Vault.bound() public view returns (uint256)

Get the allowed symmetric bound for target allocation (e.g. +- 5%).

Vault.strategyActive() public view returns (bool)

Get whether the current strategy of the vault is active.

Vault.performanceFee() public view returns (uint256)

Get the performance fee charged on strategy profits when these are harvested.

Vault.strategistFee() public view returns (uint256)

Get the fee paid to the strategist of the strategy currently in use.

Vault.strategist() public view returns (address)

Get address of the strategist (creator of the strategy currently in used).

Vault.reserve() public view returns (address)

Get address of the vault’s reserve.

Vault.reserveFactor() public view returns (address)

Get percentage that will be charged on profits and allocated to the vault’s reserve.

Vault.treasury() public view returns (address)

Get address of treasury.

Vault.debtLimit() public view returns (uint256)

Get the default debt limit assigned to a strategy.

Vault.totalDebt() public view returns (uint256)

Get the total debt of a strategy.

Vault.getStrategy() external view returns (address)

Get the current strategy of the vault.

Vault.waitingForRemovalAllocated() public view returns (uint256)

Get amount of underlying funds that are pending for removal from strategies.

Vault.getAllocatedToStrategyWaitingForRemoval(address strategy) external view returns (uint256)

Get amount of underlying funds that are pending for removal for a given strategy.

Admin Methods

Vault.activateStrategy() external returns (bool)

Activate a new strategy.

Note

A new strategy must first be prepared and executed before it can be activated.

Vault.deactivateStrategy() external returns (bool)

Deactivate the current strategy. If the current strategy is deactivated, no more funds will be allocated to it.

Vault.withdraw(uint256 amount) external returns (bool)

Withdraw a specified amount of underlying from vault to the vault’s pool. If the specified amount exceeds idle funds, an amount of funds is withdrawn from the strategy such that it will achieve the target allocation after the withdrawal.

  • amount: Amount to withdraw from vault.

Vault.withdrawAllFromStrategy() public

Withdraw all funds from the strategy to the vault.

Vault.withdrawAll() external

Withdraw all funds from vault and transfer them to the vault’s pool.

Vault.deposit() external

Allocate funds from vault to strategy (according to target allocation). This is called after a vault’s liquidity pool transfers underlying funds to the vault. This can be called by the admin should the vault need to rebalance.

Vault.harvest() external

Harvest strategy profits.

Setters

Setters across Backd contracts employ a prepare/execute/reset pattern, whereby a parameter that should be set needs to first be prepared. After a time delay specified by the constant ADMIN_DELAY (set to 3 days) the prepared parameter update can be executed by calling the execute method. If a parameter update has not been executed yet, it may be reset via the reset method.

Note

The setter methods prepare and reset can only be called by a contract’s admin. The setter method execute may be called by anyone.

Vault.executeNewStrategy() external returns (address)

Execute a previously prepared strategy.

When this is called, harvest() is called on the current strategy in place and all funds are withdrawn from it. The current strategy is deactivated and the total debt is reset to 0, prior to setting and activating the new strategy.

Vault.executePerformanceFee() external returns (address)

Execute a previously prepared performance fee. This is the fee that is charged on profits.

Vault.executeTargetAllocation() external returns (address)

Execute a previously prepared target allocation. This is the percentage of funds held by the vault that should be allocated to the strategy.

Vault.executeReserveFee() external returns (address)

Execute a previously prepared reserve fee. This is the share of the performance fee that shall be allocated to the vault’s reserve.

Vault.executeBound() external returns (uint256)

Execute a previously prepared new deviation bound for the strategy allocation. This also triggers a possible rebalance of funds allocated to the strategy.

Vault.executeStrategistFee() external returns (uint256)

Execute a previously prepared strategist fee. This is the share of the performance fee charged on profits that goes to the strategist of the respective strategy.

Note

The strategistFee and reserveFee can not exceed 1. Any left over funds from the performance fee get transferred to the treasury of the vault.