Lyra Protocol Architecture
The Lyra Protocol is the collection of smart contracts that allow Liquidity Providers (LPs) to provide capital for traders to buy or sell options from/to the market, as per the previously defined mechanism.

Protocol Contracts Outline

We will now outline at a high level what all the contracts aim to achieve before going in depth into the actual flows that occur when trading, providing liquidity and delta hedging. Note: the entire system besides BlackScholes and LyraGlobals has to be deployed per market pair.
Source code for the contracts, per function documentation, tests and deployment locations can be found at:

System Wide

BlackScholes.sol - A collection of mathematical functions required for the computation of option prices as well as necessary option greeks.
LyraGlobals.sol - Manages variables across all OptionMarkets, along with managing access to Synthetix. It also groups access to all variables needed during a trade to reduce the gas costs associated with repetitive inter-contract calls.

Market Specific

LiquidityPool.sol - Holds funds from LPs, which is used for three purposes. The first is collateralising options sold by the OptionMarket, the second is buying options from users and the third is delta hedging.
LiquidityCertificate.sol - An ERC721 token which represents a share of the LiquidityPool. It is minted when users deposit and burned when users withdraw. They can only be withdrawn between rounds.
OptionMarket.sol - The AMM which allows users to buy options (long) or sell options (short). The OptionMarket contract also manages boards/listings and settling expired options.
OptionMarketPricer.sol - Logic for working out the price of an option. Includes the IV impact of the trade, the fee components and the premium.
OptionGreekCache.sol - Aggregates the netDelta and netStdVega of the OptionMarket by iterating over listings. Needs to be called by an external actor as its not feasible to do all the computation through the trade flow. Also because delta/vega change over time and with movements in price and volatility.
OptionToken.sol - An ERC1155 contract that keeps track of user option positions. These positions are transferrable.
ShortCollateral.sol - Holds collateral from users who are selling (shorting) options to the AMM.
PoolHedger.sol - Uses the delta hedging funds from the LiquidityPool to hedge option deltas, so LPs are minimally exposed to movements in the underlying stock price.