-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #245 from InjectiveLabs/chore/docs-for-calculating…
…-market-price-quantity-tick-size chore: docs for calculating market price quantity tick size
- Loading branch information
Showing
3 changed files
with
80 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Calculations | ||
|
||
Here are some formula formatting values between the chain and UI human-readable. | ||
|
||
### Bridges Supported | ||
|
||
| Topic | Description | | ||
| ------------------------------------------------------- | --------------------------------------- | | ||
| [Market min price tick size](minPriceTickSize.md) | Minimum market order price tick size | | ||
| [Market min quantity tick size](minQuantityTickSzie.md) | Minimum market order quantity tick size | |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Market min price tick size | ||
|
||
The min market price tick size for an order price - if a market has an minPriceTickSick of `0.001` and order submission with the price of `0.0011` will be rejected. | ||
|
||
Note that calculating the formula for calculating a spot and quote market price tick size are different. | ||
|
||
### Spot market | ||
|
||
1. UI human readable to chain format: | ||
Using INJ/USDT market which has 18 base decimals and 6 quote decimals as an example, here's how we convert the value to the chain format: | ||
|
||
```js | ||
const chainFormat = new BigNumberInBase(10) | ||
.pow(quoteDecimal - baseDecimal) | ||
.times(value) | ||
.toFixed() | ||
``` | ||
|
||
1. Chain format to UI human readable format: | ||
Using INJ/USDT market which has 18 base decimals and 6 quote decimals as an example, here's how we convert the value to the UI human readable format: | ||
|
||
```js | ||
const humanReadableFormat = new BigNumber(value) | ||
.shiftedBy(baseDecimals - quoteDecimals) | ||
.toFixed() | ||
``` | ||
|
||
### Derivative market | ||
|
||
1. UI human readable to chain format: | ||
Using INJ/USDT perp market which has 6 quote decimals as an example, here's how we convert the value to the chain format: | ||
|
||
```js | ||
const chainFormat = new BigNumberInBase(10) | ||
.pow(-quoteDecimal) | ||
.times(value) | ||
.toFixed() | ||
``` | ||
|
||
1. Chain format to UI human readable format: | ||
Using INJ/USDT perp market which has 6 quote decimals as an example, here's how we convert the value to the UI human readable format: | ||
|
||
```js | ||
const humanReadableFormat = new BigNumber(value) | ||
.shiftedBy(-quoteDecimals) | ||
.toFixed() | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Market min quantity tick size | ||
|
||
The min market quantity tick size for an order price - if a market has an minQuantityTickSize of `0.001` and order submission with the quantity of `0.0011` will be rejected. | ||
|
||
Note that derivate markets shares the same format for minQuantityTickSize between UI and the chain, so no formatting is required. | ||
|
||
### Spot market | ||
|
||
1. UI human readable to chain format: | ||
Using on a INJ/USDT market which has 18 base decimals and 6 quote decimals as an example, here's how we convert the value to the chain format: | ||
|
||
```js | ||
const chainFormat = new BigNumberInWei(value).toBase(baseDecimals) | ||
``` | ||
|
||
1. Chain format to UI human readable format: | ||
Using INJ/USDT market which has 18 base decimals and 6 quote decimals as an example, here's how we convert the value to the UI human readable format: | ||
|
||
```js | ||
const humanReadableFormat = new BigNumber(minQuantityTickSize) | ||
.shiftedBy(-baseDecimals) | ||
.toFixed() | ||
``` |