Skip to main content

Class: OfferLogic

Title

The OfferLogic class connects to a Maker contract implementing the IOfferLogic interface.

Constructors​

constructor​

β€’ new OfferLogic(mgv, logic, signer?): OfferLogic

Parameters​

NameType
mgvMangrove
logicstring
signer?SignerOrProvider

Returns​

OfferLogic

Defined in​

@mangrovedao/mangrove.js/src/offerLogic.ts:19

Properties​

mgv​

β€’ mgv: Mangrove

Defined in​

@mangrovedao/mangrove.js/src/offerLogic.ts:14


contract​

β€’ contract: IOfferLogic

Defined in​

@mangrovedao/mangrove.js/src/offerLogic.ts:15


address​

β€’ address: string

Defined in​

@mangrovedao/mangrove.js/src/offerLogic.ts:16


signerOrProvider​

β€’ signerOrProvider: SignerOrProvider

Defined in​

@mangrovedao/mangrove.js/src/offerLogic.ts:17

Methods​

router​

β–Έ router(): Promise<undefined | AbstractRouter>

Returns​

Promise<undefined | AbstractRouter>

the router ethers.js contract responding to the AbstractRouter abi.

Note

Returns this logic's router. If logic has no router this call will return undefined

Defined in​

@mangrovedao/mangrove.js/src/offerLogic.ts:33


hasRouter​

β–Έ hasRouter(): Promise<boolean>

Determines whether the offer logic has a router

Returns​

Promise<boolean>

True if the offer logic has a router, false otherwise.

Defined in​

@mangrovedao/mangrove.js/src/offerLogic.ts:46


approve​

β–Έ approve(tokenId, args?): Promise<ContractTransaction>

Parameters​

NameTypeDescription
tokenIdstring-
args?Objectoptional arg.amount can be used if one wishes to approve a finite amount
args.optSpender?string-
args.optAmount?BigSource-
args.optOverrides?Overrides-

Returns​

Promise<ContractTransaction>

Note

logic approves signer or args.optSpender to spend a certain token on its behalf This has to be done for each token the signer's wishes to ask or bid for.

Defined in​

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


connect​

β–Έ connect(signerOrProvider): OfferLogic

Returns a new OfferLogic object with a different signer or provider connected to its ethers.js contract

Parameters​

NameTypeDescription
signerOrProviderSignerOrProviderthe new signer or provider to connect to the contract.

Returns​

OfferLogic

a new OfferLogic object with a different signer or provider.

Defined in​

@mangrovedao/mangrove.js/src/offerLogic.ts:84


setAdmin​

β–Έ setAdmin(newAdmin, overrides?): Promise<TransactionResponse>

Sets the admin of the contract if the Contract implements the AccessControlled interface.

Parameters​

NameTypeDescription
newAdminstringthe new admin address.
overridesOverridesThe ethers overrides to use when calling the setAdmin function.

Returns​

Promise<TransactionResponse>

The transaction used to set the new admin.

Defined in​

@mangrovedao/mangrove.js/src/offerLogic.ts:93


admin​

β–Έ admin(): Promise<string>

Retrieves the current admin of the contract if the contract implements the AccessControlled interface

Returns​

Promise<string>

The address of the current admin.

Defined in​

@mangrovedao/mangrove.js/src/offerLogic.ts:107


activate​

β–Έ activate(tokenSymbolsOrIds, overrides?): Promise<TransactionResponse>

Parameters​

NameTypeDescription
tokenSymbolsOrIdsstring[]the symbols or IDs of the tokens one wishes the logic to trade
overridesOverridesThe ethers overrides to use when calling the activate function.

Returns​

Promise<TransactionResponse>

The transaction used to activate the OfferLogic.

Note

(contract admin action) activates logic

Defined in​

@mangrovedao/mangrove.js/src/offerLogic.ts:121


getMangroveBalance​

β–Έ getMangroveBalance(): Promise<Big>

Retrieves the provision available on Mangrove for the offer logic, in ethers

Returns​

Promise<Big>

Defined in​

@mangrovedao/mangrove.js/src/offerLogic.ts:132


fundOnMangrove​

β–Έ fundOnMangrove(funds, overrides?): Promise<ContractTransaction>

Adds ethers for provisioning offers on Mangrove for the offer logic.

Parameters​

NameTypeDescription
fundsBigSourceThe amount of funds to add in ethers.
overridesOverridesThe ethers overrides to use when calling the fund function.

Returns​

Promise<ContractTransaction>

The transaction used to fund the offer logic.

Defined in​

@mangrovedao/mangrove.js/src/offerLogic.ts:141


withdrawFromMangrove​

β–Έ withdrawFromMangrove(amount, overrides?): Promise<TransactionResponse>

tx will revert is signer is not the admin of the OfferLogic onchain contract

Parameters​

NameType
amountBigSource
overridesOverrides

Returns​

Promise<TransactionResponse>

Defined in​

@mangrovedao/mangrove.js/src/offerLogic.ts:147


retrieveLockedProvisionForOffer​

β–Έ retrieveLockedProvisionForOffer(market, ba, offerId?): Promise<Big>

Retrieves amount of provision locked for the offer on the offer logic which can be redeemed if the offer is retracted.

Parameters​

NameTypeDescription
marketMarketthe market of the offer
baBAwether the offer is an ask or a bid.
offerId?numberthe id of the offer.

Returns​

Promise<Big>

the amount of provision locked for the offer on the offer logic.

Remarks

Provision is either locked on Mangrove or for, e.g., a forwarder, on the offer logic itself.

Defined in​

@mangrovedao/mangrove.js/src/offerLogic.ts:165


getMissingProvision​

β–Έ getMissingProvision(market, ba, gasreq, opts?): Promise<Big>

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

Parameters​

NameTypeDescription
marketMarketthe market for the offer.
baBAbids or asks
gasreqnumbergas required for the offer execution.
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.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/offerLogic.ts:189

  • Constructors
    • constructor
  • Properties
    • mgv
    • contract
    • address
    • signerOrProvider
  • Methods
    • router
    • hasRouter
    • approve
    • connect
    • setAdmin
    • admin
    • activate
    • getMangroveBalance
    • fundOnMangrove
    • withdrawFromMangrove
    • retrieveLockedProvisionForOffer
    • getMissingProvision