feat: add support for rebasing tokens #1063
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
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.
Problem: some staking tokens are worth more than the liquid currency?