[feature] Trade Account
Trade accounts grant professional traders (mostly arb bots) a methodology to execute instant trades on THORChain, without involving Layer1 transactions on external blockchains. This creates a new type of asset, backed by the network security rather than the liquidity in a pool (synths), or by the rune asset (derived assets).
Arb bots can now arb the pools faster and with more capital efficiency than synths do today. This is because a synth adds or removes from one side of the pool depth but not the other, causing the pool to move half the distance in terms of price. For example a $100 RUNE --> BTC swap requires $200 of BTC synths to be burned to correct the price. Trade accounts have twice the efficiency so $100 RUNE --> BTC swap would require $100 from trade accounts to correct the price.
For clarity purposes, this new asset will be referred to as a trade asset in the context of this article.
How it works
Users can deposit Layer1 assets into the network placed outside the pool. This action mints a trade asset in a 1:1 ratio into a new cosmos module (trade module), not held in wallets. The user gets accredited shares of this module relative to their deposit vs module depth (using same math used for savers tracking). The user can now swap trade asset <> RUNE (or other trade asset) to and from the trade module. Because this occurs completely within THORNode, execution times are fast and efficient.
Security
Historically, the network has not allowed L1 assets outside of the pools as assets outside of the pools cann't be arb'ed out if bond value decreases. To address this concern, if L1 assets in the Asgard vaults exceed the bond value, trade assets are sold/liquidated (reducing liability) to buy rune and are deposited into the bond module (increasing security). This creates the necessary incentives to ensure economic security is retained, giving proper incentives for more bond to show up (extra yield), and trade assets to leave (avoid haircut).
In addition, the calculation of the incentive pendulum would operate based on L1 assets vs bond, rather than pool depths vs bond. This will help ensure there will always be "space" for arbs to exist in the network and be able to arb the pool effectively (vs synths hitting caps). This change has already been made to add liquidity but hasn't been applied to the pendulum.
Limit Orders
Limit orders can be built using these trade assets. This creates an even more effective and efficient tool for arbs to arb the pools. This is because they can proactively arb the network, rather than reactively.
Implementation Details
- The incentive pendulum needs to be rewritten to swing based on L1 asset value in all asgard vaults vs bond value
- Create a new trade account deposit handler. Send in L1 and memo
+trade:thor1xxxxxxxxxxxxxxxxxx
- Create a new trade account withdraw handler. Send TC txn with memo
-trade:<asset>:<quantity>
- Create an
endblock
routine that checks bond value vs asset value. If asset value exceeds bond value, liquidate appropriate trade assets into run and deposit that rune into the bond module (increasing security).
To accomplish this, calculate how much the L1 assets are worth in rune, diff these two numbers, and if L1 asset value is greater than the effective bond, get the rune value between them. Next, index the value of the trade assets in the trade module. Swap trade assets relative to their total value from the diff, to the bond module.