FactorLPVault.sol
Contract Overview
FactorLPVault.sol
manages the LP Vault configurations as well as the concentrated liquidity positions created via this vault. Positions in the vault are represented via a ERC721 NFT which is uniquely identified via the positionId
.
The LP Vault builds on top of the Leverage Vault to enable leveraged LP positions thereby significantly amplifying the potential returns. All positions created on this vault share the same initial strategy implementation and LP fees configuration.
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 LP Vault.
Arguments
UpgradeRegistered()
Emitted when a proposed strategy implementation address is registered by the LP Vault owner
.
Arguments
UpgradeRemoved()
Emitted when a proposed strategy implementation is removed from (i.e. deregistered) isUpgrade
by the LP Vault owner
.
Arguments
DescriptorChanged()
Emitted when the leverage descriptor contract address is changed by the LP Vault owner.
Arguments
Structs
PermitData
A struct that defines the signed permit signatures for the LP Vault token0
and token1
.
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
public
initializer
The contract initialization function which initializes the contract with the vault params and initial fee configurations. Defaults the fee recipient to the msg.sender
(i.e. LP vault creator).
Parameters
setAllowedLeverageVault() - external
onlyOwner
external
onlyOwner
Allows the owner
of the LP vault contract to configure the list of permitted underlying Leverage vaults. LP vaults are built atop of Leverage vaults to enable greater capital efficiency through utilizing leveraged positions for liquidity management.
Parameters
createDepositAndExecute() - external
payable
returns
external
payable
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 relevant token amounts are transferred to the newly created Strategy contract address.
The newly created position NFT (representing a position in the LP vault) is sent to the msg.sender
.
Parameters
Returns
Events
permit() - external
payable
external
payable
Handles the ERC20 permit()
function that enables the LP Vault to spend token0
and token1
from the msg.sender
(i.e. depositor) address.
Leverages the Multicallable.sol contract.
Parameters
Allows the owner
of the LP Vault to refund any remaining tokenAddress
in the vault.
Leverages the Multicallable.sol contract.
Parameters
deposit() - external
payable
external
payable
Allows the safe transfer of a specified amount
of token
from the msg.sender
(i.e. depositor) to the LP Vault contract.
Parameters
_decodeParamsPermit() - internal
pure
returns
internal
pure
returns
An internal helper function that facilitates the decoding of permit parameters for LP vault token0
and token1
.
Parameters
Returns
burnPosition() - external
external
Allows the owner
of the position to burn the NFT representing their zero-balance position.
Parameters
tokenURI() - public
view
override
returns
public
view
override
returns
Returns the encoded Uniform Resource Identifier (URI) of the position id
that is being queried.
Parameters
Returns
setDescriptor() - external
onlyOwner
external
onlyOwner
Allows the owner of the LP Vault to change the address of the factorLPDescriptor
.
Events
getNextStrategyAddress() - public
view
returns
public
view
returns
Checks whether the upgrade from baseImplementation
to upgradeImplementation
has been registered by the Leverage Vault owner
.
Parameters
Returns
isRegisteredUpgrade() - external
view
returns
external
view
returns
Checks whether the upgrade from baseImplementation
to upgradeImplementation
has been registered by the LP Vault owner
.
Parameters
Returns
registerUpgrade() - external
onlyOwner
external
onlyOwner
Allows the LP 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
external
onlyOwner
Allows the LP Vault owner
to remove a previously registered strategy upgrade proposal from isUpgrade
.
Parameters
Events
updateImplementation() - external
onlyOwner
external
onlyOwner
Allows the LP Vault owner
to update the strategyImplementation
with a newly provided address.
Parameters
setFeeRecipient() - external
onlyOwner
external
onlyOwner
Allows the LP Vault owner
to update the feeRecipient
with a newly provided address.
Parameters
setChangeRangeFee() - external
onlyOwner
external
onlyOwner
Allows the LP Vault owner
to update the changeRangeFee
that is charged on the collected trading fees that have accrued to the position whose range is being changed.
The original changeRangeFee
is defaulted to 1e15
(i.e. 0.1%). The newFee
provided is scaled by the LP 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
setCompoundFee() - external
onlyOwner
external
onlyOwner
Allows the LP Vault owner
to update the compoundFee
that is charged on the accrued trading fees which is being reinvested (i.e. compounded) into the position.
The original compoundFee
is defaulted to 1e15
(i.e. 0.1%). The newFee
provided is scaled by the LP 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
external
pure
returns
Returns the LP Vault version which is hardcoded based on contract deployment.
Returns
_increaseBalance() - internal
virtual
override
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
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
public
view
override
returns
An internal function that overrides the ERC721 supportsInterface() function that returns true
if this LP Vault contract implements the interface defined by interfaceId
.
Parameters
Returns
receive() - public
view
override
returns
public
view
override
returns
Fallback function that enables the contract to receive ETH.
Last updated