The lyra-vaults
repo is a round-based options vault able to both buy and sell options against the Lyra options market. It is intended to be used as an example project to showcase how a vault might interact with Lyra contracts, testing/deployment tools provided by the @lyrafinance/protocol SDK and various options strategies.
yarn install --frozen-lockfile
yarn test
yarn coverage
see Integration Testing for hardhat testing against a full local Lyra market without need for mocks.
- Before round start
manager
sets themanagementFee
,performanceFee
,managementRecipient
,lyraRewardRecipient
, vaultcap
,manager
also sets the strategy contract which will determine what/when to trade viaLyraVault.setStrategy()
- users
LyraVault.deposit()
the base ERC20 into the vault while getting an allocation of ERC20 vault shares in return
- On round start
manager
callsLyraVault.startNextRound(boardId)
to set the board which will be traded- unlocked funds from last round are accounted for
- queued withdrawals/deposits from last round are processed
- During round
- anyone can "poke" the vault to
trade(strikeId)
orreducePosition(positionId, closeAmount)
- the strategy contract determines whether the requested trade or reducePosition are valid
- if valid, strategy will transfer required funds from
LyraVault
to itself and execute the trade - Premiums earned and option positions are all held by the strategy until
reducePosition()
is called or round ends
- anyone can "poke" the vault to
- On round end
- unlocked funds from last round are accounted for
- all funds are moved from the strategy contract back to the vault.
Note: to accrue lyra trading rewards, Lyra must whitelist the strategy contract to make sure
(a) inherit the LyraAdapter.sol
with no modifications to _open/close/forceClosePosition
functions
(b) the strategy contract must not be upgradeable
The vault structure is broken down into 3x main components:
- vault accounting - contracts/libraries in
core/
andlibraries/
that manage share deposit/withdrawal/NAV logic as well as roll-over logic between rounds. - strategy - contracts in
strategies/
that determine what positions to trade. Everytime a trade is made,StrategyBase.sol
takes funds from theLyraVault.sol
and keep earned premiums until a position is partially closed or the round is ended. - @lyrafinance/protocol - uses
LyraAdapter.sol
to interact with Lyra and accrue trading rewards
This component breakdown accommodates wide range of option strategies as only the contracts in the strategy
component need to be swapped out for a novel options strategy.