Trading
Last updated
Was this helpful?
Last updated
Was this helpful?
Long (short) options are represented as an in a wallet. It allows any EOA or Contract address to easily transfer, trade, or exercise (settle) the option at a future time. When taking liquidity from any source, a transaction fee will need to be paid. More details on fees can be found .
While all options settle within their respective pools, it’s possible to interact with multiple sources of liquidity for the same option. Users of the or Premia v3 SDK will have easy access to the best quotes from each source. Please see here for more details about receiving a quote.
There could be up to 4 sources of liquidity for a given option:
AMM - Range Orders
Orderbook / RFQ System
Vaults
External Protocols / Third Parties
Interacting with the and System can be done directly via the IPool
interface while and would involve directly corresponding with their contracts or interfaces if not available on the Premia Interface or Premia v3 SDK.
Traders (takers) on the Premia v3 exchange can receive a quote to buy (sell) an option from LPs in an option pool at the given quote price using getQuoteAMM
. If the taker deems the quote acceptable, they can trade
the option and pay (receive) a premium in addition to receiving long (short) option contracts in the form of .
The trade function has 3 inputs: size
, isBuy
, and premiumLimit
. The size
parameter refers to the order size, isBuy
is a boolean to signify trade direction, and premiumLimit
is used for slippage control. If an order trades beyond the premiumLimit
, ie. the average execution price of a buy (sell) order is above (below) the premiumLimit
, the transaction will revert.
It is possible to pay/receive premium/collateral for an option in the token of a user’s choice. This requires the user to define their swap parameters in the form of calldata, which will enable the swap to be executed on-chain before or after the necessary action to convert a token. The swapAndTrade
and tradeAndSwap
functions on each AMM pool can be used to facilitate this feature. More details can be found in the IPool
interface within the Contract section.
A quote will have several parameters, among them a deadline
. The deadline will specify how long a quote will be valid for. Alternatively, orders can be cancelled using cancelQuotesOB
in the IPool
Interface if an order needs to be cancelled before the deadline is reached. Multiple quotes can be cancelled at once by passing a list of quotes. Cancelling quotes can only be done on-chain.
Vaults need to implement the getQuote
function, allowing users to request the vault’s price for a specific option (strike
, maturity
, isCall
), including trade size
and direction (isBuy
). The vault should return both the maxSize
and price
for the trade, including a maxSize
of 0 if the option is not offered by the vault. To enable quotes to be filled, vaults should implement the trade
function with the same parameters as the getQuote
function.
In addition to implementing the above functions, vaults will additionally need to emit an UpdateQuotes()
event (with no parameters) any time the vault’s quotes change, in order for the Premia Interface and Premia v3 SDK to track quote changes.
Anyone interested in learning more about developing vaults on top of Premia v3, Reach out to build with us!
It is entirely possible for other protocols/users/vaults to utilize the pools strictly as a settlement layer and exchange options outside of Premia. To be able to do this, the writeFrom
function can be used.
writeFrom
is a method that will mint both the long and short option, and send each to the designated addresses for underwriter
and longReceiver
. In order to invoke this function, the collateral for the short position must be provided. Using the writeFrom
function will incur a transaction fee equal to 0.3% of the notional value:
Collateral is 1 for calls and the strike price for puts. In other words, the minting fee here is denominated in the collateral of the option.
Market Makers can provide quotes to the Orderbook either via (off-chain) or on-chain via add
within the IOrderbookStream
interface. An on-chain event is emitted with the details of each order. This acts as a transparent/capital efficient database for orders. Off-chain indexers can track the state of the Orderbook through these events.
While takers will fill their order on-chain, the process of getting a quote is done off-chain via the . We index all quotes in our subgraph, which users can get from the .
Once a taker has a quote they would like to fill, the order details need to be passed on-chain. The function can be used to fill a quote using the IPool
Interface.
Traders can verify if a quote is still valid in the Orderbook by calling with the same inputs as . It is also possible to check the fill status of a quote by using .
More details on how the orderbook architecture can be found in Advanced Concepts under
Each vault will have its own unique contract and functions, however, each must implement the IVault
interface to be integrated in the and SDK. If a third party vault correctly implements the IVault
interface, it is eligible to be added to the V3 Vault Registry, which means its quotes will be automatically included in platform-wide quote streams.