Trading
Overview
There could be up to 4 sources of liquidity for a given option:
AMM - Range Orders
Orderbook / RFQ System
Vaults
External Protocols / Third Parties
AMM
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.
The difference between a pool’s current marketPrice
and getQuoteAMM
in the IPool
interface is the price impact of a potential trade. This is a function of market liquidity and order size, where more a higher ratio of order size to existing liquidity will result in a higher price impact and vice versa.
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.
Orderbook / RFQ System
Makers
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.
Takers
Vaults
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.
External Protocols / Third Parties
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.
Last updated