Skip to content

Tick.fromPrice

Converts a price string to a tick.

Stablecoin DEX Pricing

Imports

Named
import { Tick } from 'ox/tempo'

Examples

import { Tick } from 'ox/tempo'
 
// Price of 1.0 = tick 0
const tick1 = Tick.fromPrice('1.0') // 0
const tick2 = Tick.fromPrice('1.00000') // 0
 
// Price of 1.001 = tick 100
const tick3 = Tick.fromPrice('1.001') // 100
 
// Price of 0.999 = tick -100
const tick4 = Tick.fromPrice('0.999') // -100

Definition

function fromPrice(
  price: fromPrice.Price,
): fromPrice.ReturnType

Source: src/tempo/Tick.ts

Parameters

price

  • Type: fromPrice.Price

The price as a string (e.g., "1.001", "0.999").

Return Type

The tick value.

fromPrice.ReturnType