Creating equitable options based on Hash Time Locked Contracts.
In a Hash Time Locked Contract (HTLC) there is an implied option, this due to the interactions needed to lock tokens on differing chains and the release being controlled by one party.
To recap, an atomic swap (based on a HTLC) is where two parties exchange an agreed set of tokens on different chains without the need for an intermediary.
Alice wants to swap 500 ACME tokens for 1 ETH, within 24 hours, Bob agrees to this transaction. In the “happy flow” the swap proceeds with both parties entering their instructions on the respective chains. The tokens are claimed by Alice, which then releases the tokens to Bob by revealing her key.
- Alice creates a secret key called a “preimage” and stores it locally
- Alice creates an instruction on the ACME chain with Bob’s address and the hash of the preimage
- Bob creates a transaction with Alice’s address and a copy of hash of the preimage sent by Alice on the Ethereum chain
- Alice then claims Bob’s ETH by revealing the preimage
- Bob claims Alice’s ACME tokens as the preimage is revealed
The reason there is a time element is to allow for the differing speeds of the blockchains, where some chains can take longer than others to process transactions. It was not really designed to allow Alice to change her mind as to whether she claimed Bob’s tokens and thus triggering the exchange.
An alternative flow is that steps 1 and 2 are done but Alice does not claim Bob’s tokens (step 3) in the alloted time. The tokens held in the HTLC, which acts as an escrow, are then released once the time limit is passed.
Let’s look at what would happen if the HTLC were set up with a longer time parameter of 90 days. This introduces an implied option, as the tokens are locked for the 90 day period when both parties enter the instructions until a claim is made.
In the example above Alice has the option and could wait to see what the exchange rate is in, say 45 days, and if it is to her advantage she then claims the tokens from Bob. In this scenario Bob has locked his tokens for 90 days with no return, bears the risk that the rate moves against him and has to wait for Alice to exercise the claim or 90 days.
If we look at how this fits in with an option we start to see where the problems lie. An option is a right to buy or sell an underlying asset for a agreed price during a defined time period or a fixed date.
The atomic swap is as follows; Alice has the right to buy (call option) 1 ETH for 500 ACME tokens (strike price) over a 90 day period (an American style option). Note in this case Bob is not paid a premium and this makes the option unfair to Bob and advantageous to Alice. With this asymmetry it is unlikely that Bob would agree to such a transaction.
It is worth noting that the option is attached to the atomic swap and cannot be freely traded. If we examine the scenario where Alice knows that in the next 90 days she will need to swap some ACME tokens for ETH but she is worried about fluctuations in the price, in other words she would like to hedge her up and coming transaction for peace of mind.
What Alice needs, is to buy the right to exchange her ACME tokens for a fixed amount of ETH in the next 90 days. She could, of course, buy the ETH at the current rate and wait until she needs to make the transaction. That might give her some “cash flow” problems and what would happen if she needs the ACME tokens to buy and sell things in the next 90 days?
Let’s revisit the long dated HTLC to see if this can be adapted to work as an option. By starting at the expiry we need to ensure finality of the transaction so that if Alice wishes to exercise the option then she receives the tokens at the agreed swap price (strike). For the purpose of this exercise we look at this option as a form of currency option where the rate is agreed, in this case Alice wants a rate of 520 ACME tokens for 1 ETH, she wants the flexibility of being able to exercise this over the next 90 days. The atomic swap in reality is different to a currency option as there are no interest rates to consider.
Bob sees that today’s exchange rate is around 500 ACME tokens for 1 ETH and is convinced that in the next 90 days it will fall to 400 ACME for 1 ETH and looks at Alice’s strike of 520 ACME for 1 ETH as a high certainty that it will be “out of the money” whereas Alice is looking at the rate climbing to 600 ACME to 1 ETH and she will be “in the money”. Historically the ACME token has had a range of 300 to 900 to ETH over the past 12 months so either Bob or Alice could be right.
Bob offers Alice an option to buy 1 ETH for 520 ACME tokens in 90 days and Alice agrees to pay Bob a premium of 50 ACME tokens. To ensure this transaction happens they create the following;
- Alice creates an instruction to pay Bob 0.1 ETH as an agreed premium and this is held in escrow until Bob creates the counter offer to the atomic swap. In this transaction Alice creates a template of the agreement on the Ethereum chain of the heads of terms to validate Bob’s payment, such as her address, and quantity. This is used to validate Bob’s transaction.
- Alice creates an instruction on the ACME chain to send Bob 520 tokens with Bob’s ETH address, a hash of a preimage and an expiry of 90 days.
- Bob creates a transaction to pay Alice 1 ETH with Alice’s ACME address and preimage hash on the Ethereum chain and an expiry of 90 days. The transaction is validated that it contains the agreed offer and then releases the premium held in escrow to Bob.
- Alice sees that the rate of ACME/ETH is favourable and decides to then claims Bob’s ETH using the preimage
- Bob claims Alice’s ACME tokens as the preimage is revealed
Note to ensure that this transaction takes place it has to make sure that Bob is paid the premium as soon as the swap is booked, Alice cannot claim the atomic swap until the premium is paid, Bob cannot claim the premium until the 2 atomic swap transactions are booked.
Using escrows, locks with preimages can we create a fair option, that pays a premium and has a guarantee that the contract is settled.
The next step is to look at this non fungible option and adapt it to be an instrument in its own right that delivers the swap and can be traded between third parties.
Please note this is a thought experiment and not advice or a recommendation to create, transact or devise securities. The author is not a regulated person.
Acknowledgements
Thanks to Simon Warta who prompted the conversation over a lunch in Spain and who contributed to the article.