Liquidity providers automatically underwrite options purchased by users of the Premia pools.
When an option is purchased, the following steps happen in a transaction:
Scans intervals required to underwrite position
Mints tokens for interval owners
Calculates option expiration date
Places purchased option in ordered list, by expiration date
Updates starting point of Free Capital
An option is purchased spanning two liquidity intervals, #0 fully and #1 partially.
Suppose we have an option buyer, purchasing option A (assume it's an ETH/DAI call). The buy order will scan as many liquidity intervals as are needed to cover the position. In example above, Option A will cover entirely the liquidity in interval #0 and partially interval #1.
The transaction will mint ERC-1155 tokens for both LP interval owners (#0 and #1). The tokens store the following info:
Once the option is purchased, the liquidity interval is updated. In our example, the Free Liquidity starting point is incremented by +1 (i.e. now Free Liquidity starts from interval #1), and interval #1 size is updated from 3 ETH to 2 ETH (by -1).
The liquidity interval queue updates after each purchase.
Whenever an option is purchased, its' expiration is calculated, and it is placed in a list, ordered by expiration times (this is necessary to keep track of expired options, as described in the next section).
The options are organized by expiration for efficient processing.
The transaction also mints an ERC-1155 token for the buyer, embedding all defining option characteristics me