FactorLeverageVault.sol

Contract Overview

FactorLeverageVault.sol manages the Leverage Vault configurations as well as the positions created via this vault. Positions in the vault are represented via a ERC721 NFT which is uniquely identified via the positionId.

All positions created on this vault share the same configurations such as asset and debt tokens/pools as well as fee configurations. Each positionId will implement strategy logic via a Strategy contract that is tied to the specific position NFT.

The vault implements OpenZeppelin's upgradeable proxy pattern. The vault owner is able to propose a new strategy contract implementation for the vault and upgrade the vault's strategy implementation if the strategy has been registered.

Properties

Public

Events

PositionCreated()

Emitted when a new position is created on the Leverage Vault.

Arguments

AssetChanged()

Emitted when the lending pool tied to the Leverage Vault asset is changed by the owner of the vault.

Arguments

DebtChanged()

Emitted when the lending pool tied to the Leverage Vault debt is changed by the owner of the vault.

Arguments

UpgradeRegistered()

Emitted when a proposed strategy implementation address is registered by the Leverage Vault owner.

Arguments

UpgradeRemoved()

Emitted when a proposed strategy implementation is removed (i.e. deregistered) from isUpgrade by the Leverage Vault owner.

Arguments

DescriptorChanged()

Emitted when the leverage descriptor contract address is changed by the Leverage Vault owner.

Arguments

Constructor

Factor Vault contracts implements OpenZeppelin's upgradeable contracts design and locks the Vault contract upon initialization to avoid contract takeover by an attacker. More info can be found on OpenZeppelin Docs.

Methods

initialize() - public initializer

The contract initialization function which initializes the contract with the vault params and initial fee scale. Defaults the fee recipient to the msg.sender (i.e. leverage vault creator).

Parameters

createPosition() - external returns

Creates a new position representing the configurations of a depositor's position in the leverage vault (only consists of the position structure and not actual liquidity).

To create the position, a new instance of the strategyImplementation contract is initalized with every newly created position ID for this vault.

The newly created position NFT is sent to the msg.sender.

Parameters

Returns

Events

updateAsset() - external onlyOwner

Allows the owner of the leverage vault contract to change the address of the lending pool tied to the vault's asset.

Parameters

Events

updateDebt() - external onlyOwner

Allows the owner of the leverage vault contract to change the address of the lending pool tied to the vault's debt.

Parameters

Events

burnPosition() - external

Allows the owner of the position to burn (i.e. removes) their zero balance positions.

Returns

tokenURI() - public view override returns

Returns the encoded Uniform Resource Identifier (URI) of the position id that is being queried.

Parameters

Returns

setDescriptor() - external onlyOwner

Allows the owner of the leverage vault to change the address of the factorLeverageDescriptor.

Events

isRegisteredUpgrade() - external view returns

Checks whether the upgrade from baseImplementation to upgradeImplementation has been registered by the Leverage Vault owner.

Parameters

Returns

registerUpgrade() - external onlyOwner

Allows the Leverage Vault owner to register a strategy upgrade from baseImplementation to upgradeImplementation. Proposed strategies must be registered before it can be implemented.

Parameters

Events

removeUpgrade() - external onlyOwner

Allows the Leverage Vault owner to remove a previously registered strategy upgrade proposal from isUpgrade.

Parameters

Events

updateImplementation() - external onlyOwner

Allows the Leverage Vault owner to update the strategyImplementation with a newly provided address.

Parameters

setFeeRecipient() - external onlyOwner

Allows the Leverage Vault owner to update the feeRecipient with a newly provided address.

Parameters

setLeverageFee() - external onlyOwner

Allows the Leverage Vault owner to update the leverageFee that is charged on the leverage portion whenever a position's leverage is changed.

The newFee provided is scaled by the Leverage Vault contract's FEE_SCALE which is defaulted to 1e18 on vault initialization. That is, a newFee of 1e16 is equivalent to 1% fee (i.e. 1e16/1e18).

Parameters

setClaimRewardFee() - external onlyOwner

Allows the Leverage Vault owner to update the claimRewardFee that is charged on the harvested rewards whenever the accrued position rewards are claimed.

The newFee provided is scaled by the Leverage Vault contract's FEE_SCALE which is defaulted to 1e18 on vault initialization. That is, a newFee of 1e16 is equivalent to 1% fee (i.e. 1e16/1e18).

Parameters

version() - external pure returns

Returns the Leverage Vault version which is hardcoded based on contract deployment.

Returns

_increaseBalance() - internal virtual override

An internal function that overrides the ERC721 _increaseBalance() function meant to increase the number of NFT collection tokens held by the account.

Parameters

_update() - internal virtual override returns

An internal function that overrides the ERC721 _update() function meant to update the owner of the tokenId.

Parameters

Returns

supportsInterface() - public view override returns

An internal function that overrides the ERC721 supportsInterface() function that returns true if this Leverage Vault contract implements the interface defined by interfaceId.

Parameters

Returns

Last updated