Skip to main content

Class: Density

Utility wrapper around raw Density values from Mangrove.

Constructors​

constructor​

β€’ new Density(rawDensity, outboundDecimals): Density

Construct a wrapper around a raw Density from Mangrove.

Parameters​

NameTypeDescription
rawDensityBigNumberishA raw Density from Mangrove
outboundDecimalsnumbernumber of decimals for the outbound token

Returns​

Density

Defined in​

@mangrovedao/mangrove.js/src/util/Density.ts:20

Methods​

clone​

β–Έ clone(): Density

Create a copy of this Density object.

Returns​

Density

Defined in​

@mangrovedao/mangrove.js/src/util/Density.ts:29


from96X32​

β–Έ from96X32(density96X32, outbound_decimals): Density

Factory method for creating a Density object from a 96X32 density.

Parameters​

NameTypeDescription
density96X32BigNumberishdensity encoded as a 96X32
outbound_decimalsnumbernumber of decimals for the outbound token

Returns​

Density

a Density object corresponding to the given density

Defined in​

@mangrovedao/mangrove.js/src/util/Density.ts:40


eq​

β–Έ eq(density): boolean

Equality comparison for densities.

Parameters​

NameTypeDescription
densityDensityThe density to compare to

Returns​

boolean

true if the given density is equal to this density; false otherwise

Defined in​

@mangrovedao/mangrove.js/src/util/Density.ts:56


toString​

β–Έ toString(): string

Format the density formatted as a string.

Returns​

string

the density formatted as a 'mantissa * 2^exponent' string

Defined in​

@mangrovedao/mangrove.js/src/util/Density.ts:68


toString​

β–Έ toString(rawDensity): string

Format the density formatted as a string.

Parameters​

NameTypeDescription
rawDensityBigNumberishthe raw density to format

Returns​

string

the density formatted as a 'mantissa * 2^exponent' string

Defined in​

@mangrovedao/mangrove.js/src/util/Density.ts:78


isZero​

β–Έ isZero(): boolean

Check whether the density is zero.

Returns​

boolean

true if the density is zero; false otherwise

Defined in​

@mangrovedao/mangrove.js/src/util/Density.ts:108


getRequiredOutboundForGasreq​

β–Έ getRequiredOutboundForGasreq(gasreq): Big

Get the minimum amount of outbound tokens required for the given amount of gas.

Parameters​

NameTypeDescription
gasreqBigNumberishthe amount of gas to calculate the required outbound for

Returns​

Big

the minimum amount of outbound tokens required for the given amount of gas

Defined in​

@mangrovedao/mangrove.js/src/util/Density.ts:118


getMaximumGasForRawOutbound​

β–Έ getMaximumGasForRawOutbound(rawOutboundAmt): BigNumber

Get the maximum amount of gas an offer may require for the given raw amount of outbound tokens.

Parameters​

NameTypeDescription
rawOutboundAmtBigNumberishthe raw amount of outbound tokens to calculate the maximum gas for

Returns​

BigNumber

the maximum amount of gas an offer may require for the given raw amount of outbound tokens

Defined in​

@mangrovedao/mangrove.js/src/util/Density.ts:133

  • Constructors
    • constructor
  • Methods
    • clone
    • from96X32
    • eq
    • toString
    • toString
    • isZero
    • getRequiredOutboundForGasreq
    • getMaximumGasForRawOutbound