WrapperFactorLeverageVault.sol
Last updated
Was this helpful?
Last updated
Was this helpful?
stakedNFT
mapping(uint256 => address)
public
A mapping of the wrapper vault NFT id to the owner address.
snapshotBalance
mapping(uint256 => uint256)
public
A snapshot that maps the positionID
with the ERC20Augmented
token balances(which represent underlying Leverage Vault tokens).
factorLeverageVaultAddress
address
public
The address of the underlying Leverage Vault which this contract wraps.
allowedAsset
address
public
The address of the Strategy asset
which the Wrapper Vault contract supports.
allowedDebt
address
public
The address of the Strategy debt
which the Wrapper Vault contract supports.
Emitted when leverage is added to a position.
positionStrategy
address
The address of the strategy contract implemented by the position.
positionId
uint256
The position identifier that uniquely identifies every position on the underlying Leverage Vault.
amount
uint256
The amount of asset
that was added to the position.
debt
uint256
The amount of debt
that was borrowed to open the leverage position.
Emitted when leverage is removed from a position.
positionStrategy
address
The address of the strategy contract implemented by the position.
positionId
uint256
The position identifier that uniquely identifies every position on the underlying Leverage Vault.
amount
uint256
The amount of asset
that was removed from the leveraged position and returned to the owner.
Emitted when a leveraged position is closed and all of the related asset
and debt
is returned to the owner.
positionStrategy
address
The address of the strategy contract implemented by the position.
positionId
uint256
The position identifier that uniquely identifies every position on the underlying Leverage Vault.
assetBalance
uint256
The remaining amount of asset
in the Strategy contract after the leveraged position is closed.
debtBalance
uint256
The remaining amount of debt
in the Strategy contract after the leveraged position is closed.
Emitted when underlying vault tokens are staked into the wrapper vault contract.
positionId
uint256
The position identifier that uniquely identifies the position from the underlying Leverage Vault that was staked into the Wrapper contract.
Emitted when a new position is created on the underlying Leverage Vault contract.
positionId
uint256
The position identifier that uniquely identifies the position that was created in underlying Leverage Vault.
vault
address
The address of the Strategy contract implemented for the position.
Emitted when underlying vault tokens are unstaked and removed from the wrapper vault contract.
positionId
uint256
The position identifier that uniquely identifies the position from the underlying Leverage Vault that was unstaked from the Wrapper contract.
Emitted when asset
is withdrawn from a position.
positionStrategy
address
The address of the strategy contract implemented by the position.
positionId
uint256
The position identifier that uniquely identifies every position on the underlying Leverage Vault.
amount
uint256
The number of asset
that is withdrawn from the position.
Emitted when the Wrapper Vault contract balance for a position is updated with the Strategy contract balances.
positionStrategy
address
The address of the strategy contract implemented by the position.
positionId
uint256
The position identifier that uniquely identifies every position on the underlying Leverage Vault.
oldBalance
uint256
The previous debt balance of the position on the Wrapper Vault contract.
newBalance
uint256
Thew updated balance of the poisiotn on the Wrapper Vault contract.
Emitted when the positionId
's debt is repaid.
positionStrategy
address
The address of the strategy contract implemented by the position.
positionId
uint256
The position identifier that uniquely identifies every position on the underlying Leverage Vault.
amount
uint256
The amount of debt
that was repaid.
Emitted when asset
is supplied to the Strategy contract.
positionStrategy
address
The address of the strategy contract implemented by the position.
positionId
uint256
The position identifier that uniquely identifies every position on the underlying Leverage Vault.
amount
uint256
The amount of asset
supplied to the position.
Emitted when the Strategy implementation contract for the positionId
is upgraded.
positionStrategy
address
The address of the strategy contract that was previously implemented by the position.
positionId
uint256
The position identifier that uniquely identifies every position on the underlying Leverage Vault.
upgradeImplementation
address
The address of the new Strategy contract implemented by the position.
A struct that defines the Leverage Vault initalization format.
_name
string
The name of the vault. This will be used as the name of the ERC20Augmented
token representing vault shares.
_symbol
string
The symbol of the vault. This will be used as the symbol of the ERC20Augmented
token representing vault shares.
_allowedAsset
address
The address of the underlying vault asset
that can be facilitated by the wrapper contract.
_allowedDebt
address
The address of the underlying vault debt
that can be facilitated by the wrapper contract.
_factorLeverageVaultAddress
address
_veFctr
address
_gaugeController
address
The address of the Factor Gauge Controller contract.
_boostController
address
_rewardDuration
uint256
public
initializer
The contract initialization function which initializes the contract with the underlying Leverage Vault configurations as well as the Factor ecosystem contract addresses.
initParams
Memory data that contains the initialization data for the wrapper vault.
public
virtual
override
Transfers the position NFT with the specified id
from the from
address to the to
address. The caller of this function must either be the owner of the NFT or have the necessary allowances to spend the owner's NFT.
The underlying debt of the position NFT is also transferred to the to
address.
from
address
The address of the NFT owner from which to debit the position NFT.
to
address
The address to transfer the position NFT to.
id
uint256
The identifier of the underlying Leverage Vault position NFT to be transferred.
external
nonReentrant
Stakes the provided positionId
NFT in the wrapper contract by transferring it from the msg.sender
to the Wrapper Vault contract address. Wrapper Vault NFTs representing the underlying Leverage Vault position are minted to the msg.sender
.
positionId
uint256
The identifier of the underlying Leverage Vault position NFT to be staked.
Emits the identifier of the position that was staked.
external
nonReentrant
returns
Creates a new position representing the configurations of a depositor's position in the underlying 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 underlying Leverage Vault position NFT is minted to the Wrapper Vault contract while a newly created Wrapper Vault position NFT is sent to the Wrapper Vault contract msg.sender
.
uint256
The newly created position ID.
strategy
The address of the newly deployed strategy contract which was implemented for the position.
Emits the newly created position ID and the implemented strategy address.
external
nonReentrant
Allows the owner the staked Wrapper Vault position to unstake their position from the Wrapper Vault contract (i.e. underlying Leverage Vault position NFT is transferred back to the staker).
The Wrapper Vault position NFT is burned with the corresponding wrapper virtual debt balance (represented by the `ERC20Augmented) is also destroyed.
positionId
uint256
The identifier of the underlying Leverage Vault position NFT to be unstaked.
Emits the identifier of the position that was unstaked.
external
nonReentrant
Allows the position owner
to add leverage towards their specified positionId
.
Transfers the specified amount
of asset
from msg.sender
(i.e. user) to the Wrapper Vault contract
Adds leverage to the provided positionId
by calling addLeverage()
from the implemented Strategy contract
Updates the Wrapper Vault balances which is being tracked via the ERC20Augmented
token
Updates the the positionId
debt balance on the Wrapper Vault contract
positionId
uint256
The identifier of the underlying Leverage Vault position NFT to add leverage to.
amount
uint256
The amount of asset
to supply as collateral for the loan.
debt
uint256
The amount of debt
to flash loan to increase position leverage.
data
bytes
The Balancer userData
which in this context is used for pool-specific instructions needed to do the calculations.
Emits the results of the leverage addition.
external
nonReentrant
Allows the position owner
to supply a specified amount
of asset
to the Wrapper Vault contract which is then supplied to the Strategy lending pool.
positionId
uint256
The identifier of the underlying Leverage Vault position NFT to which asset
is being supplied.
amount
uint256
The amount of asset
to be supplied as collateral for the position.
Emits the result of the supply which includes the address of the corresponding Strategy contract.
external
nonReentrant
Allows the position owner
to remove leverage from their specified positionId
.
Removes the specified amount
of asset
by calling removeLeverage()
from the implemented Strategy contract
Transfer the removed asset
amount to the msg.sender
(i.e. user)
Updates the Wrapper Vault balances which is being tracked via the ERC20Augmented
token
Updates the the positionId
debt balance on the Wrapper Vault contract
positionId
uint256
The identifier of the underlying Leverage Vault position NFT to remove leverage from.
amount
uint256
The amount of asset
being removed.
data
bytes
The Balancer userData
which in this context is used for pool-specific instructions needed to do the calculations.
Emits the results of the leverage removal.
internal
An internal function that facilitates the burning and minting of ERC20Augmented
tokens representing the number of underlying Leverage Vault tokens in the Wrapper Vault contract.
newBalance
uint256
The updated balance maintained by the Wrapper Vault contract.
oldBalance
uint256
The previous virtual balance maintained by the Wrapper Vault contract.
external
nonReentrant
Allows the position owner
to synchronize debt balances between the Wrapper Vault contract and the Strategy contract. The debt balance on the Strategy contract is used to update the Wrapper Vault contract.
positionId
uint256
The identifier of the underlying Leverage Vault position NFT whose balance is to be synced.
Emits the results of the debt balance update.
external
onlyOwner
Allows the position owner
to close their specified positionId
and receive the underlying asset
and debt
. If the asset
amount
specified is greater than the debt value, the position value will be returned in debt
tokens.
Closes the positionId
by calling closeLeverage()
from the implemented Strategy contract
Transfers the asset
and debt
from the closed position to the msg.sender
(i.e. owner)
Updates the Wrapper Vault balances which is being tracked via the ERC20Augmented
token
Updates the the positionId
debt balance on the Wrapper Vault contract
positionId
uint256
The identifier of the underlying Leverage Vault position NFT to be closed.
amount
uint256
The amount of asset
that will be swapped for debt
.
data
bytes
The Balancer userData
which in this context is used for pool-specific instructions needed to do the calculations.
Emits the results of the leverage position closure.
external
nonReentrant
Allows the position owner
to withdraw a specified amount
of their collateralized asset
from the Strategy contract . The withdrawn asset
is credited to the msg.sender
(i.e. user) address.
positionId
uint256
The identifier of the underlying Leverage Vault position NFT to withdraw from.
amount
uint256
The amount of asset
that will be withdrawn.
Emits the withdrawal details.
Allows the position owner
to repay a specified amount
of their positionId
's debt
on the Strategy contract. The ERC20Augmented
balances are burned with the Wrapper Vault contract balances being updated.
positionId
uint256
The identifier of the underlying Leverage Vault position NFT whose debt is being repaid.
amount
uint256
The amount of debt
to be repaid.
Emits the amount of debt
that was repaid as well as the Strategy contract address.
internal
override
from
address
The address of the msg.sender
.
to
address
The address of the token receiver.
amount
uint256
The amount of tokens to be transferred.
internal
override
An internal function that updates the msg.sender
's active balance in the gauge.
from
address
The address of the msg.sender
.
to
address
The address of the token receiver.
amount
uint256
The amount of tokens to be transferred.
internal
view
override
Returns the amount of ERC20Augmented
tokens (i.e. underlying Leverage Vault tokens) that a user
(i.e. staker) has staked into the Wrapper Vault contract.
user
address
The address of the user
.
uint256
The amount of underlying Leverage Vault tokens staked.
internal
view
override
Returns the total amount of underlying vault tokens held by (i.e. staked into) the Wrapper Vault contract.
uint256
The total amount of underlying Leverage Vault tokens held by the wrapper vault contract.
public
view
virtual
override
returns
Returns the encoded Uniform Resource Identifier (URI) of the position id
that is being queried.
id
uint256
The positionId
of the position whose URI data is being queried.
uint256
The encoded URI for the token representing the position in the leverage vault.
public
nonReentrant
returns
user
address
The address of the user that has accured rewards.
uint256[]
external
view
returns
Returns the ordered list of reward tokens that have accrued to the user.
address[]
An array containing the amount of reward tokens redeemed.
external
nonReentrant
Allows the position owner
to claim the Strategy rewards which has accrued to their positionId
. The reward tokens are transferred to the msg.sender
's (i.e. owner
) address.
positionId
address
The identifier of the underlying Leverage Vault position NFT whose debt is being repaid.
token
address
The address of the token receiver.
public
Enables the position owner
to update the underlying Leverage Vault's strategyImplementation
with a newly provided upgradeImplemantation
address.
positionId
address
The identifier of the underlying Leverage Vault position NFT whos estrategy implementation is being updated.
upgradeImplemantation
address
The address of the new Strategy implementation contract.
Emits the address of the newly implemented strategy.
The address of the underlying Factor vault that is wrapped by this contract (i.e. deployed address)
The address of the contract.
The address of the Controller contract.
The reward duration which the rewards for this wrapper vault will be initalized with.
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 .
The ERC20 and ERC721 token contracts that respectively represent Wrapper Vault shares and Wrapper Position NFTs are initialized as part of this function. The related Factor Gauge and contracts are also initialized for the Leverage Vault.
An internal function that updates and rewards prior to a related token transfer.
Enables stakers to claim their accrued rewards.
An array containing the amount of reward tokens redeemed, in the same order as .
FactorVault.sol