-
Notifications
You must be signed in to change notification settings - Fork 608
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
chore: add chosing an exponentAtPriceOne docs #4919
Merged
Merged
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8f95901
add chosing an exponenetAtPriceOne docs
czarcas7ic 8e973ff
increase header sizes
czarcas7ic cc67f8f
center the equation
czarcas7ic bb3c955
Update x/concentrated-liquidity/README.md
czarcas7ic c31bf32
Update x/concentrated-liquidity/README.md
czarcas7ic 5d79255
Update x/concentrated-liquidity/README.md
czarcas7ic 8556ae6
specify asset0 and asset1
czarcas7ic 6c443d5
fix headers
czarcas7ic b4fdd60
Merge branch 'main' into adam/cl-precision-doc
czarcas7ic 47436fb
Merge branch 'main' into adam/cl-precision-doc
ValarDragon 4a5ced3
Merge branch 'main' into adam/cl-precision-doc
czarcas7ic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,6 +284,43 @@ a) Preventing trade at a desirable spot price or | |
b) Having the front end round the tick's actual price to the nearest | ||
human readable/desirable spot price | ||
|
||
## Chosing an Exponent At Price One Value | ||
|
||
The creator of a pool is required to choose an exponenetAtPriceOne as one of the input parameters. As explained previously, this value determines how much the spot price increases or decreases when traversing ticks. The following equation will assist in selecting this value: | ||
|
||
$$exponentAtPriceOne=log_{10}(\frac{D}{P})$$ | ||
|
||
$$P=(\frac{baseAssetInUSD}{quoteAssetInUSD})$$ | ||
|
||
$$D=P-(\frac{baseAssetInUSD}{quoteAssetInUSD+desiredIncrementOfQuoteInUSD})$$ | ||
|
||
### Example 1 | ||
|
||
SHIB is trading at $0.00001070 per SHIB | ||
BTC is trading at $28,000 per BTC | ||
|
||
We want to create a SHIB/BTC concentrated liquidity pool where SHIB is the baseAsset (asset0) and BTC is the quoteAsset (asset1). In terms of the quoteAsset, we want to increment in 10 cent values. | ||
|
||
$$P=(\frac{0.00001070}{28,000})=0.000000000382142857$$ | ||
|
||
$$D=(0.000000000382142857)-(\frac{0.00001070}{28,000+0.10})=0.0000000000000013647910441136$$ | ||
|
||
$$exponentAtPriceOne=log_{10}(\frac{0.0000000000000013647910441136}{0.000000000382142857})=-5.447159582$$ | ||
|
||
We can therefore conclude that we can use an exponent at price one of -5 (slightly under precise) or -6 (slightly over precise) for this base/quote pair and desired price granularity. | ||
|
||
### Example 2 | ||
|
||
Flipping the quoteAsset/baseAsset, for BTC/SHIB, lets determine what the exponentAtPriceOne should be. For SHIB as a quote, centralized exchanges list prices at the 10^-8, so we will set our desired increment to this value. | ||
|
||
$$P=(\frac{28,000}{0.00001070})=2616822429$$ | ||
|
||
$$D=(2616822429)-(\frac{28,000}{0.00001070+0.00000001})=2443345$$ | ||
|
||
$$exponentAtPriceOne=-log_{10}(\frac{2443345}{2616822429})=-3.0297894598783$$ | ||
|
||
We can therefore conclude that we can use an exponent at price one of -3 for this base/quote pair and desired price granularity. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we need to update since exponent at price one is -6 now with 100 tick spacing? |
||
|
||
## Concentrated Liquidity Module Messages | ||
|
||
### `MsgCreatePosition` | ||
|
@@ -490,7 +527,7 @@ is associated with the `concentrated-liquidity` pool, the swap is routed | |
into the relevant module. The routing is done via the mapping from state that was | ||
discussed in the "Pool Creation" section. | ||
|
||
### Liquidity Provision | ||
## Liquidity Provision | ||
|
||
> As an LP, I want to provide liquidity in ranges so that I can achieve greater | ||
capital efficiency | ||
|
@@ -591,7 +628,7 @@ func (k Keeper) withdrawPosition( | |
} | ||
``` | ||
|
||
### Swapping | ||
## Swapping | ||
|
||
> As a trader, I want to be able to swap over a concentrated liquidity pool so | ||
that my trades incur lower slippage | ||
|
@@ -1462,16 +1499,14 @@ This listener executes after a swap in a concentrated liquidity pool. | |
|
||
At the time of this writing, it is only utilized by the `x/twap` module. | ||
|
||
### State | ||
## State | ||
|
||
- global (per-pool) | ||
|
||
- per-tick | ||
|
||
- per-position | ||
|
||
### Placeholder | ||
|
||
## Terminology | ||
|
||
We will use the following terms throughout the document: | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be determining exponent at price one programmatically at pool creation via twap over the past day?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be really cool that if a user provides a desired price increment that the exponent gets selected automatically! Otherwise if the user provides an exponent then it is assumed that they know what they are doing. I will create an issue for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#4922