Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for rebasing tokens #1063

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

feat: add support for rebasing tokens #1063

wants to merge 2 commits into from

Conversation

gregdhill
Copy link
Member

@gregdhill gregdhill commented May 19, 2023

This was very finicky to build and I have low confidence in its production readiness (hence why I'm opening this PR in draft). I will need to review the architecture again with @philippb90 as the system doesn't seem to make sense for LPs - I think they would be economically worse-off.

Closes #1036

Architecture

Concepts:

  • Liquid token: target currency (e.g. KSM)
  • Staking token: derivative (e.g. LKSM)

Requirement: prices always increase (e.g. LKSM is always 1:1 with KSM or can be redeemed for more)

The main idea is that rebasing (staked) tokens in a stable pool are continuously re-pegged to the price of their liquid token otherwise redeeming after a price increase will result in less tokens. When removing or adding liquidity the staking token amount is converted to the target liquid currency and vice versa.

The reason this is required is because we need all assets in a pool to be of equal value.

  1. Staking currency is 1:1 with liquid currency
  2. User adds equal liquidity of both assets
  3. Staking currency is now 2:1 with liquid currency
  4. Liquid currency is now worth twice as much
  5. Pool automatically collects "yield" on income by depositing new liquid tokens into the pool

Problem: some staking tokens are worth more than the liquid currency?

@@ -108,6 +110,10 @@ pub mod pallet {

/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;

/// Convert supported currencies to target asset.
/// NOTE: the price should only ever increase
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a hard requirement?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think theoretically the price can also decrease if a slashing event happens (LSD) or a default without sufficient collateral to cover the debt (qToken).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support dynamically rebasing tokens in StableAmm
3 participants