PriceHelper
Last updated
Last updated
Author: Trader Joe
This library contains functions to calculate prices
Calculates the price from the id and the bin step
Parameters
id
uint24
The id
binStep
uint16
The bin step
Returns
price
uint256
The price as a 128.128-binary fixed-point number
Calculates the id from the price and the bin step
Parameters
price
uint256
The price as a 128.128-binary fixed-point number
binStep
uint16
The bin step
Returns
id
uint24
The id
Calculates the base from the bin step, which is 1 + binStep / BASIS_POINT_MAX
Parameters
binStep
uint16
The bin step
Returns
<none>
uint256
base The base
Calculates the exponent from the id, which is id - REAL_ID_SHIFT
Parameters
id
uint24
The id
Returns
<none>
int256
exponent The exponent
Converts a price with 18 decimals to a 128.128-binary fixed-point number
Parameters
price
uint256
The price with 18 decimals
Returns
<none>
uint256
price128x128 The 128.128-binary fixed-point number
Converts a 128.128-binary fixed-point number to a price with 18 decimals
Parameters
price128x128
uint256
The 128.128-binary fixed-point number
Returns
<none>
uint256
price The price with 18 decimals