Personally I do not know how they could be implemented but I am going to attach an FTX article detailing how they did it. I believe the key is in the rebalance part, maybe with the improved rebalance function ALPACA alrealy has.
How Do Leveraged Tokens Work?
Each leveraged token gets its price action by trading FTX perpetual futures. For instance, say that you want to create $10,000 of ETHBULL. To do so you send in $10,000, and the ETHBULL account on FTX buys $30,000 worth of ETH perpetual futures. Thus, ETHBULL is now 3x long ETH.
You can also redeem leveraged tokens for their net asset value. To do that, you can send your $10,000 of ETHBULL back to FTX, and redeem it. This will destroy the token; cause the ETHBULL account to sell back the $30,000 worth of futures; and credit your account with $10,000.
This creation and redemption mechanism is what ultimately enforces that the leveraged tokens are worth what they’re supposed to be.
Why Use Leveraged Tokens?
There are three reasons to use leveraged tokens.
Managing Risk
BULL/BEAR/HEDGE tokens will automatically reinvest profits into the underlying asset; so if your leveraged token position makes money, the tokens will automatically put on 3x leveraged positions with that.
Conversely, BULL/BEAR/HEDGE tokens will automatically reduce risk if they lose money. If you put on a 3x long ETH position and over the course of a month ETH falls 33%, your position will be liquidated and you will have nothing left. But if you instead buy ETHBULL, the leveraged token will automatically sell off some of its ETH as markets go down–likely avoiding liquidation so that it still has assets left even after a 33% down move.
HALF tokens are the opposite. Because they’re only 1/2 leveraged, HALF tokens will sell off their underlying when it goes up and buy it back when it goes down.
Managing Margin
You can buy leveraged tokens just like normal ERC20 tokens on a spot market. No need to manage collateral, margin, liquidation prices, or anything like that; you just spend $10,000 on ETHBULL and have a 3x leveraged long coin.
ERC20 Tokens
Leveraged tokens are ERC20 tokens. That means that–unlike margin positions–you can withdraw them from your account! You go to your wallet and send leveraged tokens to any ETH wallet. This means you can custody your own leveraged tokens; it also means you can send them to other platforms that list the leveraged tokens, like Gopax or BitMax.
How Do Leveraged Tokens Rebalance?
Every day at 00:02:00 UTC the leveraged tokens ‘rebalance’. That means that each leveraged token trades on FTX in order to once again reach its target leverage.
For instance, say that the current holdings of ETHBULL are -$20,000 and + 150 ETH per token, and ETH is trading at $210. ETHBULL has a net asset value of (-$20,000 + 150*$210) = $11,500 per token, and an ETH exposure of 150*$210 = $31,500 per token. Thus its leverage is 2.74x, and so it needs to buy more ETH in order to return to 3x leverage, and will do so at 00:02:00 UTC.
Thus, every day each BULL/BEAR/HEDGE token reinvests profits if it made money. If it lost money, it sells off some of its position, reducing its leverage back to 3x in order to avoid liquidation risk.
In addition, any token will rebalance if an intraday move causes its leverage to be 33% higher than its target. So if markets move down enough that BULL token is 4x leveraged it will rebalance. This corresponds to market moves of roughly 11.15% for BULL tokens, 6.7% for BEAR tokens, and 30% for HEDGE tokens. HALF tokens do not have intraday rebalances; since they are 1/2 leveraged they cannot get liquidated.
This means that leveraged tokens can give up to 3x leverage without much risk of liquidation. It would require a 33% market move to liquidate a 3x leveraged token, but the token will generally rebalance within a 6-12% market move, reducing its risk and returning to 3x leveraged.
Specifically, the way rebalances happen is:
- FTX periodically monitors for LT leverages. If any 3x LT leverage goes above 4x in magnitude, it triggers a rebalance for that LT.
- When a rebalance is triggered, FTX calculates the number of units of the underlying the LT needs to buy/sell to return to 3x leverage, marked to prices at that time.
- The formula for this is:
1. Desired position (DP): [Target Leverage] * NAV / [underlying mark price]
2. Current Position (CP): current holdings per token of the underlying
3. Rebalance size: (DP - CP) * [LT tokens outstanding]
- FTX then sends orders in the associated FTX perpetual futures orderbook to rebalance (e.g. ETH-PERP for ETHBULL/ETHBEAR). It sends a maximum of $4m of orders per 10 seconds until it has sent the desired total size. These are all normal, public IOCs that trade against the prevailing bids/offers in the orderbook at the time.
- Note that this ignores difference between the underlying price when a rebalance is triggered and when it happens; ignores fees; and may have rounding errors.
…