Write
Creating a OTC deal using deposited token balance
Last updated
Creating a OTC deal using deposited token balance
Last updated
To write a hedge the msg.sender must have a sufficient balance of the tokens being hedged, under the userBalanceMap[msg.sender]
storage.
All deals on our platform are collateralized fully by both parties, amounts and type of collateral to be put up for each deal depend on the type of hedge.
Call Option
Put Option
Equity Swap
Loan Request
Writing a deal (hedge or loan) utilizes the lockedinuse storage under userBalanceMap[msg.sender]
as described in the below topic.
Every deal has to have underlying assets, these are the tokens being hedged or loaned.
Hedge writer always has to provide collateral, thus the payoff (if any) to the taker is always in underlying assets.
Hedge taker collateral type is determined by the type of deal. Options taker collateral is asked in the form of underlying tokens paired currency. Swap taker collateral is asked in the form of underlying tokens being hedged.
Premium or cost must be stipulated, depending on the type of deal the currency of the premium is determined automatically and fixed.
A duration must be stipulated, which is the lifespan of the deal being written, and should be a value > block.timestamp.
writeHedge
FunctionThis function is unified to handle the writing of all hedge types (options and swaps) and will also handle loan request writing.
All deals written have an incrementing global ID counter to avoid same storage saving in the mapping hedgeMap
.
Two helper functions are used in the process getWithdrawableBalance
to check if writer has sufficient balance, and getUnderlyingValue
to determine the startValue
of the deal in its paired currency.
All inputs should meet requirement and if successful, a hedgeCreated
event is emitted to signify the writing of the deal.
Currently the writeHedge
function only supports a single token type as the underlying asset of collateral for a deal, in future equity swaps and loans will have the capability to bundle a group of tokens into a basket of underlying assets for a deal.