KyberSwap Docs
Search
K

FullMath

Handles core maths for multiplication, division, and quadratic root.
GitHub File: fullMath.ts

Constructor

Private constructor that cannot be constructed.

Methods

mulDivRoundingUp() - public static

Divides the product of the params by the given denominator and rounds up to the nearest integer.
result=abdenominatorresult=\lceil{\frac{a{\cdot}b}{denominator}}\rceil

Parameters

Params
Type
Description
a
JSBI
The multiplicand.
b
JSBI
The multiplier.
denominator
JSBI
Denominator to divide the product of the multiplicand and multiplier.

Returns

Type
Description
JSBI
Product of a and b divided by the denominator. Rounded up to the nearest integer.

mulDiv() - public static

Divides the product of the params by the given denominator.
result=abdenominatorresult=\frac{a{\cdot}b}{denominator}

Parameters

Params
Type
Description
a
JSBI
First parameter to multiply.
b
JSBI
Second parameter to multiply.

Returns

Type
Description
JSBI
Product of a and b divided by the denominator.

getSmallerRootOfQuadEqn() - public static

Returns the smaller root of a quadratic equation.
result=bb2acaresult = \frac{b-{\sqrt{{b^2}-ac}}}{a}

Parameters

Params
Type
Description
a
JSBI
First quadratic coefficient.
b
JSBI
Second quadratic coefficient.
c
JSBI
Third quadratic coefficient.

Returns

Type
Description
JSBI
Smallest root of the quadratic equation.