Buying / Selling New Calls
Functions to open call contracts, either buying or selling a newAsk or newBid
After a short has put up a newAsk for purchase on the smart contract, another peer may come along and purchase that call from them. In this case, the buyer must confirm that all the details match with the appropriate index of the new ask call they are looking to purchase. Assuming everything matches and the buyer has sufficient funds to pay for it, then the premium price is transferred from the buyer to the seller (fees taken from seller's gross premium). The call is now open, and the call Long position is assigned to the buyer. The call is also immediately turned off from trading, to prevent unwanted sales of the call without consent.
On the opposite side, if a call writer finds a sufficiently attractive newBid, they can sell this call to the long. Similarly, they must confirm all of the same parameters and details match what they are aiming to sell. The smart contract checks that the short has sufficient balance and then pulls the tokens into the smart contract for escrow. In addition, given the premium was already sitting in escrow with the smart contract, that price is now delivered out to the call short (less any fees). Thus the call is now open, and the call.Short is assigned to the new call short (msg.sender), and similarly it is no longer tradeable.
The detail matching is a critical security feature to prevent 'front running' opportunities where call writers / buyers could submit one thing and then change the details just prior to a purchase, something call front running, which would force the potential buyer/seller to buy/sell something they were not intending to.
Copy link