AnyHedge Extension: Leverage on Both Sides

1 528
Avatar for GeneralProtocols
1 year ago

Author: Mathieu Geukens

Intro

At General Protocols we continue to innovate to enable Decentralized Finance on Bitcoin Cash. With the alpha of the AnyHedge Whitelabel and the release of BCH Bull around the corner, there is much to look forward to! Meanwhile we have continued to search for ways we can extend the possibilities of the AnyHedge contract. With this blog post we want to reveal something we have been working on: a two-sided leverage AnyHedge contract!

Motivation

AnyHedge allows for one party (the hedge) to stabilize the value of his BCH in the contract against an external asset and for another party (the long) to take on extra volatility risk against this external asset. This means that currently the long side is far more flexible as it allows for any leverage multiplier whereas the hedge only allows to stabilize the value of the contract against an external asset. A clear next step for extending the AnyHedge contract is to enable leveraged shorts. Both speculators and risk-averse users benefit from having the possibility to short with leverage. For speculators this would mean they have the ability to profit in USD from USD/BCH price going down. With only hedging contracts they don't have this option because the contract always returns the same amount of USD by design. For risk-averse users such as merchants, using a leveraged short can be a way to be fully hedged without locking the full amount of money in a contract.

For example, if a merchant goes 2x short with half of their BCH they are still fully protected against volatility but also have funds remaining to cover any unexpected expenses. In other words, leveraged shorts can also be used to hedge against price volatility. There are other tradeoffs in risk that are described in more detail below.

The two-sided leverage extension to the contract is possible because of the May 2022 BCH network upgrade, which introduced native introspection and 64-bit integers. This upgrade allowed for a more efficient AnyHedge contract which has plenty of room left before running into BCH protocol limits. This in turn allows to add additional features and functionality to the contract!

Intuition

Shorting is a method to earn from a declining price. For a 1x short the return is proportional: for each percentage the price declines the short earns a percent on its position. A leveraged short means having a position which earns disproportionately for each percentage decrease in the price and of course also disproportionately loses with each percentage increase in price.

Hedging means holding an asset and shorting this asset so that the effect cancels out and your net price exposure is zero. The point of importance is that your position in the asset is equal to your short position times the leverage of the short position. This means you can hedge 1 BCH by opening 1x short position for 1 BCH or a 2x short position for 0.5 BCH or a 3x short with 0.333 BCH and so forth.

When used correctly, using leveraged shorts can result in higher capital efficiency for a given hedging strategy, at the cost of being exposed to contract liquidation and re-negotiation on the upside. This is why enabling leveraged shorts in AnyHedge is a useful for both speculators and hedgers alike!

Financial aspect

In the AnyHedge contract, the leverage of the long can be seen as a derivative concept from the ratio of funds in the initialization transaction. The leverage of the long and the low liquidation price-point are each other's inverse: a 2x long contract protects the hedge against a 50% price drop, a 3x long protects against a 33% price drop, a 4x long against a 25% drop and so on. The AnyHedge contract does not inherently have a high liquidation price as the hedge is always able to pay the long no matter what percentage price increase.

The two-sided-leverage contract, does have a high liquidation price when choosing a leveraged short (> 1x). For a 2x short the high liquidation price is at a 100% price increase, for a 3x short it is at a 50% increase and for a 4x short it is at a 33% increase. Any leverage long can be combined with any leverage short. The ratio of the short input amount and the long input amount just has to be chosen carefully.

An important implication of this is that a service such as BCH Bull could operate on less capital by instead of matching 5x longs with 1x shorts (where the short needs to lock 4x the amount of the input), it could match a 5x long with a 4x short then the capital locked in the short side of the contract would be equivalent to the long side. In other words, the long contract can be offered by only locking up a fourth of the capital of before, with the tradeoff that now there is a high liquidation at +33% for the contract.

Payout graphs - AnyHedge

The payout graphs (in BCH and in Unit values) of a standard AnyHedge contract with a 3x long look the following way:

On the right graph, the payout for the short in Units is stable regardless of the price change - this is the exact goal of the AnyHedge contract! You can also see on the right graph that the red line and the yellow line have the same slope - they will never intersect and hence there is no high liquidation price point! The low liquidation price point is at -33% which is the inverse of the long leverage as mentioned earlier.

Payout graphs - AnyHedge Two-Sided-Leverage

The payout graphs (in BCH and in Unit values) of a two-sided-leverage contract with a 3x long and a 2x short look like this:

Here the payout for the short is not stable in Units but instead decreasing with price. The slope of the red line is also steeper than the slope of the yellow line on the graph on the right so the high liquidation point is when the two intersect. Here that is at a 100% price increase. The low liquidation point is still the same because the leverage on the long side did not change.

The input of the Short is 1 BCH in both cases but the long side is not equivalent in both cases - the long put in 0.5 BCH in the AnyHedge contract and 1 BCH in the two-sided-leverage contract. This illustrates that twice the amount of BCH in longs can be facilitated with the same amount of BCH on the short side but with twice the leverage.

Upgraded Contract

The two-sided leverage contract was demonstrated to work with a testnet3 transaction on Sept 22nd. The testnet transaction is a 3x short and uses the General Protocols USD/BCH price-oracle. You can see the transaction details on a testnet block explorer, for example that it was 651 bytes in size.

The updated contract is 122 opcodes in size, coming from AnyHedge's 109 opcodes, that's an increase of 13 opcodes (~12%). This is because the contract is more general and hence requires more parameters and more involved mathematics. The payout for the short is calculated in the following way

int calculatedPayoutShort = shortInputSats
                            + (shortInputSats * numeratorLeverageShort * (startingPrice - clampedPrice))
                            / (clampedPrice * denominatorLeverageShort);

int shortSats = max(DUST, calculatedPayoutShort);

The upgraded contract is still in the prototype-stage of development, so it will be a while before the functionality is usable in end-user products but nonetheless we are happy to share our progress so far!

General Protocols Blog

This article forms part of theĀ General Protocols Blog, a collection of cross-platform links showcasing our team's community activity, Bitcoin Cash projects, UTXO development, and general crypto musings.

8
$ 15.40
$ 14.60 from @TheRandomRewarder
$ 0.50 from @nyusternie
$ 0.10 from @btcfork
+ 2
Avatar for GeneralProtocols
1 year ago

Comments