Class: OfferLogic
Title
The OfferLogic class connects to a Maker contract implementing the IOfferLogic interface.
Constructorsβ
constructorβ
β’ new OfferLogic(mgv
, logic
, signer?
): OfferLogic
Parametersβ
Name | Type |
---|---|
mgv | Mangrove |
logic | string |
signer? | SignerOrProvider |
Returnsβ
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β
Name | Type | Description |
---|---|---|
tokenId | string | - |
args? | Object | optional 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β
Name | Type | Description |
---|---|---|
signerOrProvider | SignerOrProvider | the new signer or provider to connect to the contract. |
Returnsβ
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β
Name | Type | Description |
---|---|---|
newAdmin | string | the new admin address. |
overrides | Overrides | The 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β
Name | Type | Description |
---|---|---|
tokenSymbolsOrIds | string [] | the symbols or IDs of the tokens one wishes the logic to trade |
overrides | Overrides | The 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β
Name | Type | Description |
---|---|---|
funds | BigSource | The amount of funds to add in ethers. |
overrides | Overrides | The 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β
Name | Type |
---|---|
amount | BigSource |
overrides | Overrides |
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β
Name | Type | Description |
---|---|---|
market | Market | the market of the offer |
ba | BA | wether the offer is an ask or a bid. |
offerId? | number | the 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β
Name | Type | Description |
---|---|---|
market | Market | the market for the offer. |
ba | BA | bids or asks |
gasreq | number | gas required for the offer execution. |
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.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/offerLogic.ts:189