Skip to main content

Class: LiquidityProvider

The LiquidityProvider class connects an offerLogic (or an EOA) to a market. It posts onchain offers.

Constructors​

constructor​

β€’ new LiquidityProvider(p): LiquidityProvider

Parameters​

NameType
pConstructionParams

Returns​

LiquidityProvider

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:63

Properties​

mgv​

β€’ mgv: Mangrove

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:54


logic​

β€’ Optional logic: OfferLogic

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:55


contract​

β€’ Optional contract: ILiquidityProvider

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:56


eoa​

β€’ Optional eoa: string

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:57


market​

β€’ market: Market

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:58


prettyP​

β€’ prettyP: PrettyPrint

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:59


gasreq​

β€’ gasreq: number

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:60


trade​

β€’ trade: Trade

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:61

Methods​

connect​

β–Έ connect(offerLogic, offerGasreq, p): Promise<LiquidityProvider>

Connects the logic to a Market in order to pass market orders. This assumes the underlying contract of offer logic is an ILiquidityProvider.

Parameters​

NameTypeDescription
offerLogicOfferLogicThe offer logic.
offerGasreqnumberThe gas required for the offer execution on the offer logic.
pMarket | { base: string ; quote: string ; tickSpacing: number ; bookOptions?: BookOptions }The market to connect to. Can be a Market object or a market descriptor.

Returns​

Promise<LiquidityProvider>

A LiquidityProvider.

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:89


computeOfferProvision​

β–Έ computeOfferProvision(ba, opts?): Promise<Big>

Gets the missing provision in ethers for an offer to be posted or updated with the given parameters, while taking already locked provision into account.

Parameters​

NameTypeDescription
baBAbids or asks
optsObjectoptional parameters for the calculation.
opts.id?numberthe id of the offer to update. If undefined, then the offer is a new offer and nothing is locked.
opts.gasreq?numbergas required for the offer execution. If undefined, the liquidity provider's gasreq.
opts.gasprice?numbergas price to use for the calculation. If undefined, then Mangrove's current gas price is used.

Returns​

Promise<Big>

the additional required provision, in ethers.

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:126


computeBidProvision​

β–Έ computeBidProvision(opts?): Promise<Big>

Gets the missing provision in ethers for a bid using computeOfferProvision.

Parameters​

NameType
optsObject
opts.id?number
opts.gasreq?number
opts.gasprice?number

Returns​

Promise<Big>

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:156


computeAskProvision​

β–Έ computeAskProvision(opts?): Promise<Big>

Gets the missing provision in ethers for an ask using computeOfferProvision.

Parameters​

NameType
optsObject
opts.id?number
opts.gasreq?number
opts.gasprice?number

Returns​

Promise<Big>

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:163


asks​

β–Έ asks(): Offer[]

List all of the maker's asks in the cache

Returns​

Offer[]

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:170


bids​

β–Έ bids(): Offer[]

List all of the maker's bids in the cache

Returns​

Offer[]

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:180


consoleAsks​

β–Έ consoleAsks(filter?): void

Pretty prints the current state of the asks for the maker

Parameters​

NameType
filter?prettyPrintFilter

Returns​

void

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:190


consoleBids​

β–Έ consoleBids(filter?): void

Pretty prints the current state of the bids for the maker

Parameters​

NameType
filter?prettyPrintFilter

Returns​

void

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:195


normalizeOfferParams​

β–Έ normalizeOfferParams(p, market): Object

Given offer params (bids/asks + price info as wants&gives or price&volume), return {tick,gives,fund}

Parameters​

NameType
p{ ba: BA } & OfferParams
marketKeyResolvedForCalculation

Returns​

Object

NameType
ticknumber
givesBig
fund?BigSource

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:203


newAsk​

β–Έ newAsk(p, overrides?): Promise<{ id: number ; event: Log }>

Post a new ask

Parameters​

NameType
pOfferParams
overridesOverrides

Returns​

Promise<{ id: number ; event: Log }>

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:238


newBid​

β–Έ newBid(p, overrides?): Promise<{ id: number ; event: Log }>

Post a new bid

Parameters​

NameType
pOfferParams
overridesOverrides

Returns​

Promise<{ id: number ; event: Log }>

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:246


newOffer​

β–Έ newOffer(p, overrides?): Promise<{ id: number ; event: Log }>

Parameters​

NameType
p{ ba: BA } & OfferParams
overridesOverrides

Returns​

Promise<{ id: number ; event: Log }>

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:267


updateAsk​

β–Έ updateAsk(id, p, overrides?): Promise<{ event: Log }>

to change volume and price of the offer, and update its gas requirement and fund 0.01 ether to maker balance

Parameters​

NameType
idnumber
pOfferParams
overridesPayableOverrides

Returns​

Promise<{ event: Log }>

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:353


updateBid​

β–Έ updateBid(id, p, overrides?): Promise<{ event: Log }>

Update an existing offer

Parameters​

NameType
idnumber
pOfferParams
overridesPayableOverrides

Returns​

Promise<{ event: Log }>

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:362


updateOffer​

β–Έ updateOffer(id, p, overrides?): Promise<{ event: Log }>

Parameters​

NameType
idnumber
p{ ba: BA } & OfferParams
overridesPayableOverrides

Returns​

Promise<{ event: Log }>

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:374


retractAsk​

β–Έ retractAsk(id, deprovision?, overrides?): Promise<void>

Cancel an ask. If deprovision is true, will return the offer's provision to the maker balance at Mangrove.

Parameters​

NameTypeDefault value
idnumberundefined
deprovisionbooleanfalse
overridesOverrides{}

Returns​

Promise<void>

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:443


retractBid​

β–Έ retractBid(id, deprovision?, overrides?): Promise<void>

Cancel a bid. If deprovision is true, will return the offer's provision to the maker balance at Mangrove.

Parameters​

NameTypeDefault value
idnumberundefined
deprovisionbooleanfalse
overridesOverrides{}

Returns​

Promise<void>

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:452


retractOffer​

β–Έ retractOffer(ba, id, deprovision?, overrides?): Promise<void>

Parameters​

NameTypeDefault value
baBAundefined
idnumberundefined
deprovisionbooleanfalse
overridesOverrides{}

Returns​

Promise<void>

Defined in​

@mangrovedao/mangrove.js/src/liquidityProvider.ts:461

  • Constructors
    • constructor
  • Properties
    • mgv
    • logic
    • contract
    • eoa
    • market
    • prettyP
    • gasreq
    • trade
  • Methods
    • connect
    • computeOfferProvision
    • computeBidProvision
    • computeAskProvision
    • asks
    • bids
    • consoleAsks
    • consoleBids
    • normalizeOfferParams
    • newAsk
    • newBid
    • newOffer
    • updateAsk
    • updateBid
    • updateOffer
    • retractAsk
    • retractBid
    • retractOffer