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β
Name | Type |
---|---|
p | ConstructionParams |
Returnsβ
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β
Name | Type | Description |
---|---|---|
offerLogic | OfferLogic | The offer logic. |
offerGasreq | number | The gas required for the offer execution on the offer logic. |
p | Market | { 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β
Name | Type | Description |
---|---|---|
ba | BA | bids or asks |
opts | Object | optional parameters for the calculation. |
opts.id? | number | the id of the offer to update. If undefined, then the offer is a new offer and nothing is locked. |
opts.gasreq? | number | gas required for the offer execution. If undefined, the liquidity provider's gasreq. |
opts.gasprice? | number | gas 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β
Name | Type |
---|---|
opts | Object |
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β
Name | Type |
---|---|
opts | Object |
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β
Name | Type |
---|---|
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β
Name | Type |
---|---|
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β
Name | Type |
---|---|
p | { ba : BA } & OfferParams |
market | KeyResolvedForCalculation |
Returnsβ
Object
Name | Type |
---|---|
tick | number |
gives | Big |
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β
Name | Type |
---|---|
p | OfferParams |
overrides | Overrides |
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β
Name | Type |
---|---|
p | OfferParams |
overrides | Overrides |
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β
Name | Type |
---|---|
p | { ba : BA } & OfferParams |
overrides | Overrides |
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β
Name | Type |
---|---|
id | number |
p | OfferParams |
overrides | PayableOverrides |
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β
Name | Type |
---|---|
id | number |
p | OfferParams |
overrides | PayableOverrides |
Returnsβ
Promise
<{ event
: Log
}>
Defined inβ
@mangrovedao/mangrove.js/src/liquidityProvider.ts:362
updateOfferβ
βΈ updateOffer(id
, p
, overrides?
): Promise
<{ event
: Log
}>
Parametersβ
Name | Type |
---|---|
id | number |
p | { ba : BA } & OfferParams |
overrides | PayableOverrides |
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β
Name | Type | Default value |
---|---|---|
id | number | undefined |
deprovision | boolean | false |
overrides | Overrides | {} |
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β
Name | Type | Default value |
---|---|---|
id | number | undefined |
deprovision | boolean | false |
overrides | Overrides | {} |
Returnsβ
Promise
<void
>
Defined inβ
@mangrovedao/mangrove.js/src/liquidityProvider.ts:452
retractOfferβ
βΈ retractOffer(ba
, id
, deprovision?
, overrides?
): Promise
<void
>
Parametersβ
Name | Type | Default value |
---|---|---|
ba | BA | undefined |
id | number | undefined |
deprovision | boolean | false |
overrides | Overrides | {} |
Returnsβ
Promise
<void
>
Defined inβ
@mangrovedao/mangrove.js/src/liquidityProvider.ts:461