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

Handling different pool asset's relative value scale #26

Closed
iboss-ptk opened this issue Oct 31, 2023 · 1 comment
Closed

Handling different pool asset's relative value scale #26

iboss-ptk opened this issue Oct 31, 2023 · 1 comment

Comments

@iboss-ptk
Copy link
Collaborator

iboss-ptk commented Oct 31, 2023

In case where we want transmuter to support asset configuration that is not only 1:1, for example:

$$ X_{exponent} = 10^6 $$

$$ Y_{exponent} = 10^{12} $$

we want to create X:Y transmuter pool. so looking at this.

$$ 1 X = 10^6 uX $$

$$ 1 Y = 10^{12} uY $$

Meaning 1 uX should be traded for 10^6 uY.

We introduce normalization factor, similar to how stableswap handles the same case but called it scaling factor.

(note: I think scaling factor term is a bit misleading due to the term scaling implies multiplication but is used for division, so I think normalization factor fits the intent better)

The said factor can be set per denom, so X and Y has normalization_factor of 1 and 10^6 respectively, then we can normalize them via raw_coin_units / normalization_factor.

The factor is calculated by:

$$ \frac{denom_{exponent}}{GCD_{i=0}^{n}(denom_i)} $$

Now that to trade 1 X for 1 Y we normalized them by normalization_factor

$$ \frac{10^6 uX}{1} = 10^6 nuX $$

$$ \frac{10^{12} uY}{10^6} = 10^6 nuY $$

Thus normalized asset is now 1:1.

We can store only normalization factor, since with that, it also allows different transmuting ratio.

@iboss-ptk
Copy link
Collaborator Author

closed by #28

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

No branches or pull requests

1 participant