Skip to content

[feature] derived assets

Son of Odin requested to merge THOR-USD into develop

Related #1255 (closed)

Implements derived assets for THORChain

At the beginning of each block, the network "redraws" each derived pool (ie THOR.BTC, THOR.USD, etc). There is one derived pool per chain, plus THOR.USD.

The derived pool is a "virtual pool". It has no LPs, instead, it has a virtual depth to determine how much "swap fee" someone will pay to enter/exit a derived asset. The swap fee is given to a vault to pay yield to locked THOR.USD.

The virtual depth, as a starting point, is the rune depth of the sum of all the anchor pools of the derived asset (ie THOR.BTC has just one anchor, BTC.BTC, while THOR.USD has several, USDT, USDC, DAI, UST, BUSD). Anchor pools that are not available for trading in one way or another are excluded from the calculation. The price is determined by the median of all the anchor pools. From here, the virtual depth can be more shallow relative to the amount of trade median volume in the anchor pool(s). Higher trade volume makes the derived pool more shallow. If there has been enough volume to move the pool price 15% in 300 blocks (~30min), then the pool can be taken all the way down to 1% of the starting point volume, but no less.

To acquire a derived asset, put the asset name of your derived asset in a swap memo. Same if you want to burn a derived asset.

To enter/exit the USD vault, add/remove liquidity, asym sending THOR.USD only (never rune).

Stagenet testing plan

Best that a few people (3?) do all of these steps at the same time. Will better test the math.

  1. Ensure that each gas asset has a derived asset pool that is Available, a rune depth that is the sum of the rune of the anchor pool(s), and the pool price looks correct.
  2. Swap rune --> THOR.USD, amounts are about correct
  3. Add the THOR.USD to the USD vault, using the add memo. Should send THOR.USD (sending rune will cause a failure/refund)
  4. Swap layer1 BTC --> THOR.BTC, amounts are about correct
  5. Swap layer1 BNB --> THOR.BTC, amounts are about correct. This should get a higher fee because the previous swap should decrease the derived virtual depth
  6. Withdraw from USD vault (using withdraw memo). Check amounts look about right.
Edited by Son of Odin

Merge request reports