Class: TickPriceHelper
Constructorsβ
constructorβ
β’ new TickPriceHelper(ba
, market
): TickPriceHelper
Ctor
Parametersβ
Name | Type | Description |
---|---|---|
ba | BA | bids or asks |
market | KeyResolvedForCalculation | the decimals for the market |
Returnsβ
Defined inβ
@mangrovedao/mangrove.js/src/util/tickPriceHelper.ts:21
Propertiesβ
baβ
β’ Readonly
ba: BA
Defined inβ
@mangrovedao/mangrove.js/src/util/tickPriceHelper.ts:13
marketβ
β’ Readonly
market: KeyResolvedForCalculation
Defined inβ
@mangrovedao/mangrove.js/src/util/tickPriceHelper.ts:14
Methodsβ
priceFromTickβ
βΈ priceFromTick(tick
, roundingMode
): Big
Calculates the price at a given raw offer list tick.
Parametersβ
Name | Type | Description |
---|---|---|
tick | number | tick to calculate price for (is coerced to nearest bin) |
roundingMode | RoundingMode | the rounding mode for coercing tick to a representable tick. See RoundingMode. roundDown is to a lower price, roundUp is to a higher price. |
Returnsβ
Big
price at tick (not to be confused with offer list ratio).
Defined inβ
@mangrovedao/mangrove.js/src/util/tickPriceHelper.ts:66
tickFromPriceβ
βΈ tickFromPrice(price
, roundingMode
): number
Calculates the raw offer list tick (coerced to nearest bin) at a given order book price (not to be confused with offer list ratio).
Parametersβ
Name | Type | Description |
---|---|---|
price | BigSource | price to calculate tick for |
roundingMode | RoundingMode | See RoundingMode roundDown is to a lower tick, roundUp is to a higher tick. |
Returnsβ
number
raw offer list tick (coerced to nearest bin) for price
Defined inβ
@mangrovedao/mangrove.js/src/util/tickPriceHelper.ts:97
coercePriceβ
βΈ coercePrice(price
, roundingMode
): Big
Coerces a price to a representable price on a tick. Note that due to rounding, coercing a coerced price may yield a price on an adjacent tick.
Parametersβ
Name | Type | Description |
---|---|---|
price | BigSource | price to coerce |
roundingMode | RoundingMode | See RoundingMode roundUp is to a higher price, roundDown is to a lower price. |
Returnsβ
Big
the price coerced to nearest representable tick
Defined inβ
@mangrovedao/mangrove.js/src/util/tickPriceHelper.ts:124
inboundFromOutboundβ
βΈ inboundFromOutbound(tick
, outboundAmount
, roundingMode
): Big
Calculates the inbound amount from an outbound amount at a given tick.
Parametersβ
Name | Type | Description |
---|---|---|
tick | number | tick to calculate the amount for (coerced to nearest bin) |
outboundAmount | BigSource | amount to calculate the inbound amount for |
roundingMode | RoundingMode | See RoundingMode. roundDown is to a lower tick, roundUp is to a higher tick and usage of inboundFromOutboundUp |
Returnsβ
Big
inbound amount.
Defined inβ
@mangrovedao/mangrove.js/src/util/tickPriceHelper.ts:154
outboundFromInboundβ
βΈ outboundFromInbound(tick
, inboundAmount
, roundingMode
): Big
Calculates the outbound amount from an inbound amount at a given tick.
Parametersβ
Name | Type | Description |
---|---|---|
tick | number | tick to calculate the amount for (coerced to nearest bin) |
inboundAmount | BigSource | amount to calculate the outbound amount for |
roundingMode | RoundingMode | See RoundingMode. roundDown is to a lower tick, roundUp is to a higher tick and usage of outboundFromInboundUp |
Returnsβ
Big
inbound amount.
Defined inβ
@mangrovedao/mangrove.js/src/util/tickPriceHelper.ts:179
volumeForGivesAndPriceβ
βΈ volumeForGivesAndPrice(gives
, price
): Big
Determine the volume of an offer from the amount of token to give and the price.
Parametersβ
Name | Type | Description |
---|---|---|
gives | BigSource | amount of token to give |
price | BigSource | price of the offer |
Returnsβ
Big
the volume of the offer.
Defined inβ
@mangrovedao/mangrove.js/src/util/tickPriceHelper.ts:203
tickFromVolumesβ
βΈ tickFromVolumes(inboundVolume
, outboundVolume
, roundingMode
): number
Calculates the tick (coerced to nearest bin) from inbound and outbound volumes.
Parametersβ
Name | Type | Description |
---|---|---|
inboundVolume | BigSource | inbound amount to calculate the tick for |
outboundVolume | BigSource | outbound amount to calculate the tick for |
roundingMode | RoundingMode | See RoundingMode. roundDown is to a lower tick, roundUp is to a higher tick. |
Returnsβ
number
raw offer list tick (coerced to nearest bin) for volumes
Defined inβ
@mangrovedao/mangrove.js/src/util/tickPriceHelper.ts:214
coerceTickβ
βΈ coerceTick(tick
, roundingMode
): number
Coerce a tick to its nearest bin
Parametersβ
Name | Type | Description |
---|---|---|
tick | number | tick to coerce |
roundingMode | RoundingMode | See RoundingMode. roundDown is to a lower tick, roundUp is to a higher tick. |
Returnsβ
number
tick coerced to its nearest bin
Defined inβ
@mangrovedao/mangrove.js/src/util/tickPriceHelper.ts:257
isTickExactβ
βΈ isTickExact(tick
): boolean
Check if tick is exact, as in it does not change when coerced due to tick spacing
Parametersβ
Name | Type | Description |
---|---|---|
tick | number | tick to check |
Returnsβ
boolean
true if tick is exact; otherwise, false
Defined inβ
@mangrovedao/mangrove.js/src/util/tickPriceHelper.ts:268
rawRatioFromTickβ
βΈ rawRatioFromTick(tick
, roundingMode
): Big
Calculates the raw ratio as a Big with big precision.
NB: Raw ratios do not take token decimals into account.
Parametersβ
Name | Type | Description |
---|---|---|
tick | number | tick to calculate the ratio for (coerced to nearest bin) |
roundingMode | RoundingMode | the rounding mode for coercing tick to a representable tick. See RoundingMode |
Returnsβ
Big
ratio as a Big.
Defined inβ
@mangrovedao/mangrove.js/src/util/tickPriceHelper.ts:321
tickFromRawRatioβ
βΈ tickFromRawRatio(rawRatio
, roundingMode
): number
Converts a raw ratio as a Big to a tick (coerced to nearest bin).
NB: Raw ratios do not take token decimals into account. NB: This is a lossy conversions since ticks are discrete and ratios are not.
Parametersβ
Name | Type | Description |
---|---|---|
rawRatio | Big | inbound/outbound ratio to calculate the tick for |
roundingMode | RoundingMode | the rounding mode for coercing tick to a representable tick. See RoundingMode |
Returnsβ
number
a tick (coerced to nearest bin) that approximates the given ratio.
Defined inβ
@mangrovedao/mangrove.js/src/util/tickPriceHelper.ts:345
rawRatioToMantissaExponentβ
βΈ rawRatioToMantissaExponent(ratio
): Object
Parametersβ
Name | Type |
---|---|
ratio | Big |
Returnsβ
Object
Name | Type |
---|---|
man | BigNumber |
exp | BigNumber |
Defined inβ
@mangrovedao/mangrove.js/src/util/tickPriceHelper.ts:366