Skip to main content

BinHelper

Table of contents

Constructors

Methods

Constructors

constructor

new BinHelper(): BinHelper

Returns

BinHelper

Methods

_getBPValue

_getBPValue(_binStep): u256

Returns the (1 + bp) value as a 128.128-decimal fixed-point number

Parameters

NameTypeDescription
_binStepu64The bp value in [1; 100] (referring to 0.01% to 1%)

Returns

u256

The (1+bp) value as a 128.128-decimal fixed-point number

Defined in

assembly/libraries/BinHelper.ts:37


getPriceFromId

getPriceFromId(id, binStep): u256

Returns the price corresponding to the given ID, as a 128.128-binary fixed-point number

Parameters

NameTypeDescription
idu64the id
binStepu64the bin step

Returns

u256

The price corresponding to this id, as a 128.128-binary fixed-point number

Defined in

assembly/libraries/BinHelper.ts:25


power

power(x, y): u256

Returns the value of x^y. It calculates 1 / x^abs(y) if x is bigger than 2^128. At the end of the operations, we invert the result if needed.

Parameters

NameTypeDescription
xu256The unsigned 128.128-binary fixed-point number for which to calculate the power
yi64A relative number without any decimals, needs to be between ]-2^20; 2^20[

Returns

u256

The result of x^y

Defined in

assembly/libraries/BinHelper.ts:59