> For the complete documentation index, see [llms.txt](https://docs.mangrove.exchange/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mangrove.exchange/dev/strat-lib/technical-references/api-preferences/core/src/imangrove.md).

# IMangrove

#### DOMAIN\_SEPARATOR[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#domain_separator) <a href="#domain_separator" id="domain_separator"></a>

```
function DOMAIN_SEPARATOR() external view returns (bytes32)
```

See {IERC20Permit-DOMAIN\_SEPARATOR}.

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values)

| Name | Type    | Description           |
| ---- | ------- | --------------------- |
| \[0] | bytes32 | the domain separator. |

#### PERMIT\_TYPEHASH[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#permit_typehash) <a href="#permit_typehash" id="permit_typehash"></a>

```
function PERMIT_TYPEHASH() external pure returns (bytes32)
```

See {IERC20Permit-PERMIT\_TYPEHASH}.

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-1)

| Name | Type    | Description           |
| ---- | ------- | --------------------- |
| \[0] | bytes32 | The permit type hash. |

#### approve[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#approve) <a href="#approve" id="approve"></a>

```
function approve(address outbound_tkn, address inbound_tkn, address spender, uint256 value) external returns (bool)
```

Approves the spender to spend the amount of tokens on behalf of the caller.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters)

| Name          | Type    | Description                                |
| ------------- | ------- | ------------------------------------------ |
| outbound\_tkn | address | The address of the (maker) outbound token. |
| inbound\_tkn  | address | The address of the (maker) inbound token.  |
| spender       | address | The address of the spender.                |
| value         | uint256 | The amount of tokens to approve.           |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-2)

| Name | Type | Description                                  |
| ---- | ---- | -------------------------------------------- |
| \[0] | bool | true If the approval succeeded; always true. |

#### allowance[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#allowance) <a href="#allowance" id="allowance"></a>

```
function allowance(address outbound_tkn, address inbound_tkn, address owner, address spender) external view returns (uint256 amount)
```

Returns the allowance of the spender to spend tokens on behalf of the owner.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-1)

| Name          | Type    | Description                                |
| ------------- | ------- | ------------------------------------------ |
| outbound\_tkn | address | The address of the (maker) outbound token. |
| inbound\_tkn  | address | The address of the (maker) inbound token.  |
| owner         | address | The address of the owner.                  |
| spender       | address | The address of the spender.                |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-3)

| Name   | Type    | Description                                                                  |
| ------ | ------- | ---------------------------------------------------------------------------- |
| amount | uint256 | The amount of tokens the spender is allowed to spend on behalf of the owner. |

#### permit[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#permit) <a href="#permit" id="permit"></a>

```
function permit(address outbound_tkn, address inbound_tkn, address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external
```

Adapted from [Uniswap v2 contract](https://github.com/Uniswap/uniswap-v2-core/blob/55ae25109b7918565867e5c39f1e84b7edd19b2a/contracts/UniswapV2ERC20.sol#L81)

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-2)

| Name          | Type    | Description                                             |
| ------------- | ------- | ------------------------------------------------------- |
| outbound\_tkn | address | The address of the (maker) outbound token.              |
| inbound\_tkn  | address | The address of the (maker) inbound token.               |
| owner         | address | The address of the owner.                               |
| spender       | address | The address of the spender.                             |
| value         | uint256 | The amount of tokens to approve.                        |
| deadline      | uint256 | The deadline after which the permit is no longer valid. |
| v             | uint8   | The signature v parameter.                              |
| r             | bytes32 | The signature r parameter.                              |
| s             | bytes32 | The signature s parameter.                              |

#### nonces[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#nonces) <a href="#nonces" id="nonces"></a>

```
function nonces(address owner) external view returns (uint256 nonce)
```

See {IERC20Permit-nonces}.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-3)

| Name  | Type    | Description               |
| ----- | ------- | ------------------------- |
| owner | address | The address of the owner. |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-4)

| Name  | Type    | Description                     |
| ----- | ------- | ------------------------------- |
| nonce | uint256 | The current nonce of the owner. |

#### marketOrderByTick[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#marketorderbytick) <a href="#marketorderbytick" id="marketorderbytick"></a>

```
function marketOrderByTick(struct OLKey olKey, Tick maxTick, uint256 fillVolume, bool fillWants) external returns (uint256 takerGot, uint256 takerGave, uint256 bounty, uint256 feePaid)
```

Performs a market order on a specified offer list taking offers up to a limit price.

\_The market order stops when there are no more offers at or below `maxTick`, when the end of the book has been reached, or:

* If `fillWants` is true, the market order stops when `fillVolume` units of `olKey.outbound_tkn` have been obtained. To buy a specific volume of `olKey.outbound_tkn` at any price, set `fillWants` to true, set `fillVolume` to the volume you want to buy, and set `maxTick` to the `MAX_TICK` constant.
* If `fillWants` is false, the market order stops when `fillVolume` units of `olKey.inbound_tkn` have been paid. To sell a specific volume of `olKey.inbound_tkn` at any price, set `fillWants` to false, set `fillVolume` to the volume you want to sell, and set `maxTick` to the `MAX_TICK` constant.\_

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-4)

| Name       | Type         | Description                                                                                                                                                                            |
| ---------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| olKey      | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`.                                                                                          |
| maxTick    | Tick         | Must be `>= MIN_TICK` and `<= MAX_TICK`. The log of the limit price the taker is ready to pay (meaning: the log base 1.0001 of the ratio of inbound tokens over outbound tokens).      |
| fillVolume | uint256      | Must be `<= MAX_SAFE_VOLUME`. If `fillWants` is true, the amount of `olKey.outbound_tkn` the taker wants to buy; otherwise, the amount of `olKey.inbound_tkn` the taker wants to sell. |
| fillWants  | bool         | If true, the matching engine tries to get the taker all they want; otherwise, the matching engine tries to sell all that the taker gives. In both cases subject to the price limit.    |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-5)

| Name      | Type    | Description                                                                          |
| --------- | ------- | ------------------------------------------------------------------------------------ |
| takerGot  | uint256 | The amount of `olKey.outbound_tkn` the taker got.                                    |
| takerGave | uint256 | The amount of `olKey.inbound_tkn` the taker gave.                                    |
| bounty    | uint256 | The amount of native token the taker got as a bounty due to failing offers (in wei). |
| feePaid   | uint256 | The amount of `olKey.outbound_tkn` the taker paid as a fee to Mangrove.              |

#### marketOrderByTickCustom[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#marketorderbytickcustom) <a href="#marketorderbytickcustom" id="marketorderbytickcustom"></a>

```
function marketOrderByTickCustom(struct OLKey olKey, Tick maxTick, uint256 fillVolume, bool fillWants, uint256 maxGasreqForFailingOffers) external returns (uint256 takerGot, uint256 takerGave, uint256 bounty, uint256 feePaid)
```

Performs a market order on a specified offer list taking offers up to a limit price, while allowing to specify a custom `maxGasreqForFailingOffers`.

*Mangrove stops a market order after it has gone through failing offers such that their cumulative `gasreq` is greater than the global `maxGasreqForFailingOffers` parameter. This function can be used by the taker to override the default `maxGasreqForFailingOffers` parameter.*

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-5)

| Name                      | Type         | Description                                                                                                                                                                            |
| ------------------------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| olKey                     | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`.                                                                                          |
| maxTick                   | Tick         | Must be `>= MIN_TICK` and `<= MAX_TICK`. The log of the limit price the taker is ready to pay (meaning: the log base 1.0001 of the ratio of inbound tokens over outbound tokens).      |
| fillVolume                | uint256      | Must be `<= MAX_SAFE_VOLUME`. If `fillWants` is true, the amount of `olKey.outbound_tkn` the taker wants to buy; otherwise, the amount of `olKey.inbound_tkn` the taker wants to sell. |
| fillWants                 | bool         | If true, the matching engine tries to get the taker all they want; otherwise, the matching engine tries to sell all that the taker gives. In both cases subject to the price limit.    |
| maxGasreqForFailingOffers | uint256      | The maximum allowed gas required for failing offers (in wei).                                                                                                                          |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-6)

| Name      | Type    | Description                                                                          |
| --------- | ------- | ------------------------------------------------------------------------------------ |
| takerGot  | uint256 | The amount of `olKey.outbound_tkn` the taker got.                                    |
| takerGave | uint256 | The amount of `olKey.inbound_tkn` the taker gave.                                    |
| bounty    | uint256 | The amount of native token the taker got as a bounty due to failing offers (in wei). |
| feePaid   | uint256 | The amount of `olKey.outbound_tkn` the taker paid as a fee to Mangrove.              |

#### marketOrderByVolume[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#marketorderbyvolume) <a href="#marketorderbyvolume" id="marketorderbyvolume"></a>

```
function marketOrderByVolume(struct OLKey olKey, uint256 takerWants, uint256 takerGives, bool fillWants) external returns (uint256 takerGot, uint256 takerGave, uint256 bounty, uint256 feePaid)
```

Performs a market order on a specified offer list taking offers up to a limit price defined by a ratio `inbound_tkn/outbound_tkn` of volumes.

*This function is just a wrapper for `marketOrderByTick`, see that function for details. When deriving the tick, then `takerWants = 0` has a special meaning and the tick for the highest possible ratio between wants and gives will be used, and if `takerGives = 0` and `takerWants != 0`, then the tick for the lowest possible ratio will be used.*

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-6)

| Name       | Type         | Description                                                                                                                                                                                                                                   |
| ---------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| olKey      | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`.                                                                                                                                                 |
| takerWants | uint256      | Must be `<= MAX_SAFE_VOLUME`. The amount the taker wants. This is used along with `takerGives` to derive a max price (`maxTick`) which is the lowest allowed tick in the offer list such that `log_1.0001(takerGives/takerWants) <= maxTick`. |
| takerGives | uint256      | Must be `<= MAX_SAFE_VOLUME`. The amount the taker gives. This is used along with `takerWants` to derive a max price (`maxTick`) which is the lowest allowed tick in the offer list such that `log_1.0001(takerGives/takerWants) <= maxTick`. |
| fillWants  | bool         | If true, the matching engine tries to get the taker all they want; otherwise, the matching engine tries to sell all that the taker gives. In both cases subject to the price limit.                                                           |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-7)

| Name      | Type    | Description                                                                          |
| --------- | ------- | ------------------------------------------------------------------------------------ |
| takerGot  | uint256 | The amount of `olKey.outbound_tkn` the taker got.                                    |
| takerGave | uint256 | The amount of `olKey.inbound_tkn` the taker gave.                                    |
| bounty    | uint256 | The amount of native token the taker got as a bounty due to failing offers (in wei). |
| feePaid   | uint256 | The amount of `olKey.outbound_tkn` the taker paid as a fee to Mangrove.              |

#### marketOrderForByTick[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#marketorderforbytick) <a href="#marketorderforbytick" id="marketorderforbytick"></a>

```
function marketOrderForByTick(struct OLKey olKey, Tick maxTick, uint256 fillVolume, bool fillWants, address taker) external returns (uint256 takerGot, uint256 takerGave, uint256 bounty, uint256 feePaid)
```

Performs a market order on a specified offer list taking offers up to a limit price for a specified taker.

*The `bounty` will be sent to `msg.sender` but transfers will be for `taker`. Requires prior permission. See also `marketOrderByTick`.*

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-7)

| Name       | Type         | Description                                                                                                                                                                                                                                  |
| ---------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| olKey      | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`.                                                                                                                                                |
| maxTick    | Tick         | Must be `>= MIN_TICK` and `<= MAX_TICK`. The log of the limit price the taker is ready to pay (meaning: the log base 1.0001 of the ratio of inbound tokens over outbound tokens).                                                            |
| fillVolume | uint256      | Must be `<= MAX_SAFE_VOLUME`. If `fillWants` is true, the amount of `olKey.outbound_tkn` the taker wants to buy; otherwise, the amount of `olKey.inbound_tkn` the taker wants to sell.                                                       |
| fillWants  | bool         | If true, the matching engine tries to get the taker all they want; otherwise, the matching engine tries to sell all that the taker gives. In both cases subject to the price limit.                                                          |
| taker      | address      | The taker from which amounts will be transferred from and to. If the `msg.sender`'s allowance for the given `olKey.outbound_tkn`,`olKey.inbound_tkn` is strictly less than the total amount eventually spent by `taker`, the call will fail. |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-8)

| Name      | Type    | Description                                                                          |
| --------- | ------- | ------------------------------------------------------------------------------------ |
| takerGot  | uint256 | The amount of `olKey.outbound_tkn` the taker got.                                    |
| takerGave | uint256 | The amount of `olKey.inbound_tkn` the taker gave.                                    |
| bounty    | uint256 | The amount of native token the taker got as a bounty due to failing offers (in wei). |
| feePaid   | uint256 | The amount of `olKey.outbound_tkn` the taker paid as a fee to Mangrove.              |

#### marketOrderForByVolume[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#marketorderforbyvolume) <a href="#marketorderforbyvolume" id="marketorderforbyvolume"></a>

```
function marketOrderForByVolume(struct OLKey olKey, uint256 takerWants, uint256 takerGives, bool fillWants, address taker) external returns (uint256 takerGot, uint256 takerGave, uint256 bounty, uint256 feePaid)
```

Performs a market order on a specified offer list taking offers up to a limit price defined by a ratio `inbound_tkn/outbound_tkn` of volumes for a specified taker.

*The `bounty` will be send to `msg.sender` but transfers will be for `taker`. Requires prior permission. See also `marketOrderByVolume`.*

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-8)

| Name       | Type         | Description                                                                                                                                                                                                                                       |
| ---------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| olKey      | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`.                                                                                                                                                     |
| takerWants | uint256      | Must be `<= MAX_SAFE_VOLUME`. The amount the taker wants. This is used along with `takerGives` to derive a max price (`maxTick`) which is the lowest allowed tick in the offer list such that `log_1.0001(takerGives/takerWants) <= maxTick`.     |
| takerGives | uint256      | Must be `<= MAX_SAFE_VOLUME`. The amount the taker gives. This is used along with `takerGives` to derive a max price (`maxTick`) which is the lowest allowed tick in the offer list such that `log_1.0001(takerGives/takerWants) <= maxTick`.     |
| fillWants  | bool         | If true, the matching engine tries to get the taker all they want; otherwise, the matching engine tries to sell all that the taker gives. In both cases subject to the price limit.                                                               |
| taker      | address      | The taker from which amounts will be transferred from and to the. If the `msg.sender`'s allowance for the given `olKey.outbound_tkn`,`olKey.inbound_tkn` are strictly less than the total amount eventually spent by `taker`, the call will fail. |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-9)

| Name      | Type    | Description                                                                          |
| --------- | ------- | ------------------------------------------------------------------------------------ |
| takerGot  | uint256 | The amount of `olKey.outbound_tkn` the taker got.                                    |
| takerGave | uint256 | The amount of `olKey.inbound_tkn` the taker gave.                                    |
| bounty    | uint256 | The amount of native token the taker got as a bounty due to failing offers (in wei). |
| feePaid   | uint256 | The amount of native token the taker paid as a fee (in wei of `olKey.outbound_tkn`). |

#### cleanByImpersonation[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#cleanbyimpersonation) <a href="#cleanbyimpersonation" id="cleanbyimpersonation"></a>

```
function cleanByImpersonation(struct OLKey olKey, struct MgvLib.CleanTarget[] targets, address taker) external returns (uint256 successes, uint256 bounty)
```

Cleans multiple offers, i.e. executes them and removes them from the book if they fail, transferring the failure penalty as bounty to the caller.

\_If an offer succeeds, the execution of that offer is reverted, it stays in the book, and no bounty is paid; The `cleanByImpersonation` function itself will not revert. Note that Mangrove won't attempt to execute an offer if the values in a target don't match its offer. To distinguish between a non-executed clean and a failed clean (due to the offer itself not failing), you must inspect the log (see `MgvLib.sol`) or check the received bounty. Any `taker` can be impersonated when cleaning because:

* The function reverts if the offer succeeds, reverting any token transfers.
* After a `clean` where the offer has failed, all ERC20 token transfers have also been reverted -- but the sender will still have received the bounty of the failing offers. \*/\_

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-9)

| Name    | Type                         | Description                                                                                              |
| ------- | ---------------------------- | -------------------------------------------------------------------------------------------------------- |
| olKey   | struct OLKey                 | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`.            |
| targets | struct MgvLib.CleanTarget\[] | The offers to clean, identified by their (`offerId, tick, gasreq, takerWants`) that will make them fail. |
| taker   | address                      | The taker used for transfers (should be able to deliver token amounts).                                  |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-10)

| Name      | Type    | Description                                |
| --------- | ------- | ------------------------------------------ |
| successes | uint256 | The number of successfully cleaned offers. |
| bounty    | uint256 | The total bounty received by the caller.   |

#### receive[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#receive) <a href="#receive" id="receive"></a>

```
receive() external payable
```

Adds funds to Mangrove for the caller (the maker) to use for provisioning offers.

#### fund[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#fund) <a href="#fund" id="fund"></a>

```
function fund() external payable
```

Adds funds to Mangrove for the caller (the maker) to use for provisioning offers.

#### fund[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#fund-1) <a href="#fund-1" id="fund-1"></a>

```
function fund(address maker) external payable
```

Adds funds to Mangrove for the maker to use for provisioning offers.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-10)

| Name  | Type    | Description                 |
| ----- | ------- | --------------------------- |
| maker | address | The maker to add funds for. |

#### withdraw[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#withdraw) <a href="#withdraw" id="withdraw"></a>

```
function withdraw(uint256 amount) external returns (bool noRevert)
```

Withdraws the caller's (the maker's) free native tokens (funds for provisioning offers not locked by an offer) by transferring them to the caller.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-11)

| Name   | Type    | Description             |
| ------ | ------- | ----------------------- |
| amount | uint256 | The amount to withdraw. |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-11)

| Name     | Type | Description                     |
| -------- | ---- | ------------------------------- |
| noRevert | bool | Whether the transfer succeeded. |

#### balanceOf[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#balanceof) <a href="#balanceof" id="balanceof"></a>

```
function balanceOf(address maker) external view returns (uint256 balance)
```

Gets the maker's free balance of native tokens (funds for provisioning offers not locked by an offer).

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-12)

| Name  | Type    | Description                       |
| ----- | ------- | --------------------------------- |
| maker | address | The maker to get the balance for. |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-12)

| Name    | Type    | Description                                                                                       |
| ------- | ------- | ------------------------------------------------------------------------------------------------- |
| balance | uint256 | The maker's free balance of native tokens (funds for provisioning offers not locked by an offer). |

#### newOfferByTick[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#newofferbytick) <a href="#newofferbytick" id="newofferbytick"></a>

```
function newOfferByTick(struct OLKey olKey, Tick tick, uint256 gives, uint256 gasreq, uint256 gasprice) external payable returns (uint256 offerId)
```

Creates a new offer on Mangrove, where the caller is the maker. The maker can implement the `IMaker` interface to be called during offer execution.

*The gasreq and gasprice are used to derive the provision which will be used to pay a penalty if the offer fails. This function is payable to enable delivery of the provision along with the offer creation.*

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-13)

| Name     | Type         | Description                                                                                                                                                                                                          |
| -------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| olKey    | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`.                                                                                                                        |
| tick     | Tick         | Must be `>= MIN_TICK` and `<= MAX_TICK`. The `tick` induces a price which is `1.0001^tick`. The actual tick of the offer will be the smallest tick `offerTick > tick` that satisfies `offerTick % tickSpacing == 0`. |
| gives    | uint256      | Must be `<= MAX_SAFE_VOLUME`. The amount of `olKey.outbound_tkn` the maker gives.                                                                                                                                    |
| gasreq   | uint256      | The amount of gas required to execute the offer logic in the maker's `IMaker` implementation. This will limit the gas available, and the offer will fail if it spends more.                                          |
| gasprice | uint256      | The maximum gas price the maker is willing to pay a penalty for due to failing execution.                                                                                                                            |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-13)

| Name    | Type    | Description                                                                                                |
| ------- | ------- | ---------------------------------------------------------------------------------------------------------- |
| offerId | uint256 | The id of the offer on Mangrove. Can be used to retract or update the offer (even to reuse a taken offer). |

#### newOfferByVolume[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#newofferbyvolume) <a href="#newofferbyvolume" id="newofferbyvolume"></a>

```
function newOfferByVolume(struct OLKey olKey, uint256 wants, uint256 gives, uint256 gasreq, uint256 gasprice) external payable returns (uint256 offerId)
```

Creates a new offer on Mangrove, where the caller is the maker. The maker can implement the `IMaker` interface to be called during offer execution.

*This function is just a wrapper for `newOfferByTick`, see that function for details.*

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-14)

| Name     | Type         | Description                                                                                                                                                                                                                                                                                          |
| -------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| olKey    | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`.                                                                                                                                                                                                        |
| wants    | uint256      | Must be less than MAX\_SAFE\_VOLUME. The amount of `olKey.inbound_tkn` the maker wants. This is used along with `gives` to derive a tick (price). which is the lowest allowed tick in the offer list such that `log_1.0001(takerGives/takerWants) <= maxTick`.                                       |
| gives    | uint256      | Must be less than MAX\_SAFE\_VOLUME. The amount of `olKey.outbound_tkn` the maker gives. This is used along with `wants` to derive a tick (price). which is the lowest allowed tick in the offer list such that `log_1.0001(takerGives/takerWants) <= maxTick`. Must be less than MAX\_SAFE\_VOLUME. |
| gasreq   | uint256      | The amount of gas required to execute the offer logic in the maker's `IMaker` implementation. This will limit the gas available, and the offer will fail if it spends more.                                                                                                                          |
| gasprice | uint256      | The maximum gas price the maker is willing to pay a penalty for due to failing execution.                                                                                                                                                                                                            |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-14)

| Name    | Type    | Description                                                                                                |
| ------- | ------- | ---------------------------------------------------------------------------------------------------------- |
| offerId | uint256 | The id of the offer on Mangrove. Can be used to retract or update the offer (even to reuse a taken offer). |

#### updateOfferByTick[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#updateofferbytick) <a href="#updateofferbytick" id="updateofferbytick"></a>

```
function updateOfferByTick(struct OLKey olKey, Tick tick, uint256 gives, uint256 gasreq, uint256 gasprice, uint256 offerId) external payable
```

Updates an existing offer on Mangrove, where the caller is the maker.

*See `newOfferByTick` for additional details.*

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-15)

| Name     | Type         | Description                                                                                                                                                                                                          |
| -------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| olKey    | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`.                                                                                                                        |
| tick     | Tick         | Must be `>= MIN_TICK` and `<= MAX_TICK`. The `tick` induces a price which is `1.0001^tick`. The actual tick of the offer will be the smallest tick `offerTick > tick` that satisfies `offerTick % tickSpacing == 0`. |
| gives    | uint256      | The amount of `olKey.outbound_tkn` the maker gives. Must be less than MAX\_SAFE\_VOLUME.                                                                                                                             |
| gasreq   | uint256      | The amount of gas required to execute the offer logic in the maker's `IMaker` implementation.                                                                                                                        |
| gasprice | uint256      | The maximum gas price the maker is willing to pay a penalty for due to failing execution.                                                                                                                            |
| offerId  | uint256      | The id of the offer on Mangrove.                                                                                                                                                                                     |

#### updateOfferByVolume[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#updateofferbyvolume) <a href="#updateofferbyvolume" id="updateofferbyvolume"></a>

```
function updateOfferByVolume(struct OLKey olKey, uint256 wants, uint256 gives, uint256 gasreq, uint256 gasprice, uint256 offerId) external payable
```

Updates an existing, owned offer on Mangrove, where the caller is the maker.

*This function is just a wrapper for `updateOfferByTick`, see that function for details.*

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-16)

| Name     | Type         | Description                                                                                                                                                                                                                                                     |
| -------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| olKey    | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`.                                                                                                                                                                   |
| wants    | uint256      | The amount of `olKey.inbound_tkn` the maker wants. This is used along with `gives` to derive a tick (price). which is the lowest allowed tick in the offer list such that `log_1.0001(takerGives/takerWants) <= maxTick`.                                       |
| gives    | uint256      | The amount of `olKey.outbound_tkn` the maker gives. This is used along with `wants` to derive a tick (price). which is the lowest allowed tick in the offer list such that `log_1.0001(takerGives/takerWants) <= maxTick`. Must be less than MAX\_SAFE\_VOLUME. |
| gasreq   | uint256      | The amount of gas required to execute the offer logic in the maker's `IMaker` implementation.                                                                                                                                                                   |
| gasprice | uint256      | The maximum gas price the maker is willing to pay a penalty for due to failing execution.                                                                                                                                                                       |
| offerId  | uint256      | The id of the offer on Mangrove.                                                                                                                                                                                                                                |

#### retractOffer[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#retractoffer) <a href="#retractoffer" id="retractoffer"></a>

```
function retractOffer(struct OLKey olKey, uint256 offerId, bool deprovision) external returns (uint256 provision)
```

Retracts an offer from Mangrove, where the caller is the maker.

*`withdraw` can be used to withdraw the funds after deprovisioning. Leaving funds provisioned can be used to save gas if offer is later updated.*

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-17)

| Name        | Type         | Description                                                                                     |
| ----------- | ------------ | ----------------------------------------------------------------------------------------------- |
| olKey       | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`.   |
| offerId     | uint256      | The id of the offer on Mangrove.                                                                |
| deprovision | bool         | Whether to deprovision the offer, i.e, return the provision to the maker's balance on Mangrove. |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-15)

| Name      | Type    | Description                                                      |
| --------- | ------- | ---------------------------------------------------------------- |
| provision | uint256 | The amount of native token deprovisioned for the offer (in wei). |

#### global[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#global) <a href="#global" id="global"></a>

```
function global() external view returns (Global _global)
```

Gets the global configuration for Mangrove.

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-16)

| Name     | Type   | Description                            |
| -------- | ------ | -------------------------------------- |
| \_global | Global | The global configuration for Mangrove. |

#### local[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#local) <a href="#local" id="local"></a>

```
function local(struct OLKey olKey) external view returns (Local _local)
```

Gets the local configuration for a specific offer list.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-18)

| Name  | Type         | Description                                                                                   |
| ----- | ------------ | --------------------------------------------------------------------------------------------- |
| olKey | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`. |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-17)

| Name    | Type  | Description                                 |
| ------- | ----- | ------------------------------------------- |
| \_local | Local | The local configuration for the offer list. |

#### config[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#config) <a href="#config" id="config"></a>

```
function config(struct OLKey olKey) external view returns (Global _global, Local _local)
```

Gets the global configuration for Mangrove and local the configuration for a specific offer list.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-19)

| Name  | Type         | Description                                                                                   |
| ----- | ------------ | --------------------------------------------------------------------------------------------- |
| olKey | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`. |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-18)

| Name     | Type   | Description                                 |
| -------- | ------ | ------------------------------------------- |
| \_global | Global | The global configuration for Mangrove.      |
| \_local  | Local  | The local configuration for the offer list. |

#### locked[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#locked) <a href="#locked" id="locked"></a>

```
function locked(struct OLKey olKey) external view returns (bool)
```

Determines whether the reentrancy lock is in effect for the offer list.

*The lock protects modifying or inspecting the offer list while an order is in progress.*

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-20)

| Name  | Type         | Description                                                                                   |
| ----- | ------------ | --------------------------------------------------------------------------------------------- |
| olKey | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`. |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-19)

| Name | Type | Description                       |
| ---- | ---- | --------------------------------- |
| \[0] | bool | true If locked; otherwise, false. |

#### best[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#best) <a href="#best" id="best"></a>

```
function best(struct OLKey olKey) external view returns (uint256 offerId)
```

Gets the `offerId` of the best offer in the offer list.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-21)

| Name  | Type         | Description                                                                                   |
| ----- | ------------ | --------------------------------------------------------------------------------------------- |
| olKey | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`. |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-20)

| Name    | Type    | Description                                        |
| ------- | ------- | -------------------------------------------------- |
| offerId | uint256 | The `offerId` of the best offer on the offer list. |

#### olKeys[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#olkeys) <a href="#olkeys" id="olkeys"></a>

```
function olKeys(bytes32 olKeyHash) external view returns (struct OLKey olKey)
```

Gets the offer list key with the given hash (if the offer list key has been activated at least once).

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-22)

| Name      | Type    | Description                     |
| --------- | ------- | ------------------------------- |
| olKeyHash | bytes32 | The hash of the offer list key. |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-21)

| Name  | Type         | Description |
| ----- | ------------ | ----------- |
| olKey | struct OLKey | The olKey.  |

#### offers[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#offers) <a href="#offers" id="offers"></a>

```
function offers(struct OLKey olKey, uint256 offerId) external view returns (Offer offer)
```

Gets an offer in packed format.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-23)

| Name    | Type         | Description                                                                                   |
| ------- | ------------ | --------------------------------------------------------------------------------------------- |
| olKey   | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`. |
| offerId | uint256      | The `offerId` of the offer on the offer list.                                                 |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-22)

| Name  | Type  | Description                 |
| ----- | ----- | --------------------------- |
| offer | Offer | The offer in packed format. |

#### offerDetails[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#offerdetails) <a href="#offerdetails" id="offerdetails"></a>

```
function offerDetails(struct OLKey olKey, uint256 offerId) external view returns (OfferDetail offerDetail)
```

Gets an offer's details in packed format.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-24)

| Name    | Type         | Description                                                                                   |
| ------- | ------------ | --------------------------------------------------------------------------------------------- |
| olKey   | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`. |
| offerId | uint256      | The `offerId` of the offer on the offer list.                                                 |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-23)

| Name        | Type        | Description                         |
| ----------- | ----------- | ----------------------------------- |
| offerDetail | OfferDetail | The offer details in packed format. |

#### offerData[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#offerdata) <a href="#offerdata" id="offerdata"></a>

```
function offerData(struct OLKey olKey, uint256 offerId) external view returns (Offer offer, OfferDetail offerDetail)
```

Gets both an offer and its details in packed format.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-25)

| Name    | Type         | Description                                                                                   |
| ------- | ------------ | --------------------------------------------------------------------------------------------- |
| olKey   | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`. |
| offerId | uint256      | The `offerId` of the offer on the offer list.                                                 |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-24)

| Name        | Type        | Description                         |
| ----------- | ----------- | ----------------------------------- |
| offer       | Offer       | The offer in packed format.         |
| offerDetail | OfferDetail | The offer details in packed format. |

#### governance[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#governance) <a href="#governance" id="governance"></a>

```
function governance() external view returns (address)
```

Gets the governance address.

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-25)

| Name | Type    | Description             |
| ---- | ------- | ----------------------- |
| \[0] | address | The governance address. |

#### activate[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#activate) <a href="#activate" id="activate"></a>

```
function activate(struct OLKey olKey, uint256 fee, uint256 density96X32, uint256 offer_gasbase) external
```

Activates an offer list.

*If the flipped offer list is active then the offer lists are expected to have the same `tickSpacing`.*

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-26)

| Name           | Type         | Description                                                                                                         |
| -------------- | ------------ | ------------------------------------------------------------------------------------------------------------------- |
| olKey          | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`.                       |
| fee            | uint256      | In basis points, of `olKey.outbound_tkn` given to the taker. This fee is sent to Mangrove. Fee is capped to \~2.5%. |
| density96X32   | uint256      | The density of the offer list used to define a minimum offer volume. See `setDensity96X32`.                         |
| offer\_gasbase | uint256      | The gasbase of the offer list used to define a minimum provision necessary for offers. See `setGasbase`.            |

#### deactivate[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#deactivate) <a href="#deactivate" id="deactivate"></a>

```
function deactivate(struct OLKey olKey) external
```

Deactivates an offer list.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-27)

| Name  | Type         | Description                                                                                   |
| ----- | ------------ | --------------------------------------------------------------------------------------------- |
| olKey | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`. |

#### kill[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#kill) <a href="#kill" id="kill"></a>

```
function kill() external
```

Kills the Mangrove instance. A dead instance cannot have offers executed or funds received, but offers can be retracted and funds can be withdrawn.

#### setDensity96X32[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#setdensity96x32) <a href="#setdensity96x32" id="setdensity96x32"></a>

```
function setDensity96X32(struct OLKey olKey, uint256 density96X32) external
```

Sets the density.

*Useless if `global.useOracle != 0` and oracle returns a valid density.*

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-28)

| Name         | Type         | Description                                                                                                                                                                |
| ------------ | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| olKey        | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`.                                                                              |
| density96X32 | uint256      | Is given as a 96.32 fixed point number. It will be stored as a 9-bit float and be approximated towards 0. The maximum error is 20%. See `DensityLib` for more information. |

#### setFee[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#setfee) <a href="#setfee" id="setfee"></a>

```
function setFee(struct OLKey olKey, uint256 fee) external
```

Sets the fee for the offer list.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-29)

| Name  | Type         | Description                                                                                                         |
| ----- | ------------ | ------------------------------------------------------------------------------------------------------------------- |
| olKey | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`.                       |
| fee   | uint256      | In basis points, of `olKey.outbound_tkn` given to the taker. This fee is sent to Mangrove. Fee is capped to \~2.5%. |

#### setGasbase[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#setgasbase) <a href="#setgasbase" id="setgasbase"></a>

```
function setGasbase(struct OLKey olKey, uint256 offer_gasbase) external
```

Sets the gasbase for the offer list.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-30)

| Name           | Type         | Description                                                                                                                                                                                                                                               |
| -------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| olKey          | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`.                                                                                                                                                             |
| offer\_gasbase | uint256      | The gasbase of the offer list used to define a minimum provision necessary for offers. Represents the gas overhead used by processing the offer inside Mangrove + the overhead of initiating an entire order. Stored in thousands in a maximum of 9 bits. |

#### setGasmax[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#setgasmax) <a href="#setgasmax" id="setgasmax"></a>

```
function setGasmax(uint256 gasmax) external
```

Sets the gasmax for Mangrove, the maximum amount of gas an offer can require to execute.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-31)

| Name   | Type    | Description                                                                  |
| ------ | ------- | ---------------------------------------------------------------------------- |
| gasmax | uint256 | The maximum amount of gas required to execute an offer. Must fit in 24 bits. |

#### setMaxRecursionDepth[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#setmaxrecursiondepth) <a href="#setmaxrecursiondepth" id="setmaxrecursiondepth"></a>

```
function setMaxRecursionDepth(uint256 maxRecursionDepth) external
```

Sets the maximum number of times a market order can recursively execute offers. This is a protection against stack overflows.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-32)

| Name              | Type    | Description                                                                |
| ----------------- | ------- | -------------------------------------------------------------------------- |
| maxRecursionDepth | uint256 | The maximum number of times a market order can recursively execute offers. |

#### setMaxGasreqForFailingOffers[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#setmaxgasreqforfailingoffers) <a href="#setmaxgasreqforfailingoffers" id="setmaxgasreqforfailingoffers"></a>

```
function setMaxGasreqForFailingOffers(uint256 maxGasreqForFailingOffers) external
```

Sets the maximum cumulative `gasreq` for failing offers during a market order before doing a partial fill.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-33)

| Name                      | Type    | Description                                                                                                    |
| ------------------------- | ------- | -------------------------------------------------------------------------------------------------------------- |
| maxGasreqForFailingOffers | uint256 | The maximum cumulative `gasreq` for failing offers during a market order before doing a partial fill. 32 bits. |

#### setGasprice[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#setgasprice) <a href="#setgasprice" id="setgasprice"></a>

```
function setGasprice(uint256 gasprice) external
```

Sets the gasprice (in Mwei, 26 bits).

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-34)

| Name     | Type    | Description                      |
| -------- | ------- | -------------------------------- |
| gasprice | uint256 | The gasprice (in Mwei, 26 bits). |

#### setGovernance[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#setgovernance) <a href="#setgovernance" id="setgovernance"></a>

```
function setGovernance(address governanceAddress) external
```

Sets a new governance address.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-35)

| Name              | Type    | Description                 |
| ----------------- | ------- | --------------------------- |
| governanceAddress | address | The new governance address. |

#### setMonitor[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#setmonitor) <a href="#setmonitor" id="setmonitor"></a>

```
function setMonitor(address monitor) external
```

Sets the monitor/oracle. The `monitor/oracle` can provide real-time values for `gasprice` and `density` to Mangrove. It can also receive liquidity event notifications.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-36)

| Name    | Type    | Description                     |
| ------- | ------- | ------------------------------- |
| monitor | address | The new monitor/oracle address. |

#### setNotify[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#setnotify) <a href="#setnotify" id="setnotify"></a>

```
function setNotify(bool notify) external
```

Sets whether Mangrove notifies the Monitor when and offer is taken.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-37)

| Name   | Type | Description                                                    |
| ------ | ---- | -------------------------------------------------------------- |
| notify | bool | Whether Mangrove notifies the Monitor when and offer is taken. |

#### setUseOracle[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#setuseoracle) <a href="#setuseoracle" id="setuseoracle"></a>

```
function setUseOracle(bool useOracle) external
```

Sets whether Mangrove uses the monitor as oracle for `gasprice` and `density` values.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-38)

| Name      | Type | Description                                                                      |
| --------- | ---- | -------------------------------------------------------------------------------- |
| useOracle | bool | Whether Mangrove uses the monitor as oracle for `gasprice` and `density` values. |

#### withdrawERC20[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#withdrawerc20) <a href="#withdrawerc20" id="withdrawerc20"></a>

```
function withdrawERC20(address tokenAddress, uint256 value) external
```

Transfer ERC20 tokens to governance.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-39)

| Name         | Type    | Description                       |
| ------------ | ------- | --------------------------------- |
| tokenAddress | address | The address of the ERC20 token.   |
| value        | uint256 | The amount of tokens to transfer. |

#### leafs[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#leafs) <a href="#leafs" id="leafs"></a>

```
function leafs(struct OLKey olKey, int256 index) external view returns (Leaf)
```

Gets a leaf.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-40)

| Name  | Type         | Description                                                                                   |
| ----- | ------------ | --------------------------------------------------------------------------------------------- |
| olKey | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`. |
| index | int256       | The index.                                                                                    |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-26)

| Name | Type | Description |
| ---- | ---- | ----------- |
| \[0] | Leaf | The leaf.   |

#### level3s[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#level3s) <a href="#level3s" id="level3s"></a>

```
function level3s(struct OLKey olKey, int256 index) external view returns (Field)
```

Gets a level 3 field.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-41)

| Name  | Type         | Description                                                                                   |
| ----- | ------------ | --------------------------------------------------------------------------------------------- |
| olKey | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`. |
| index | int256       | The index.                                                                                    |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-27)

| Name | Type  | Description |
| ---- | ----- | ----------- |
| \[0] | Field | The field.  |

#### level2s[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#level2s) <a href="#level2s" id="level2s"></a>

```
function level2s(struct OLKey olKey, int256 index) external view returns (Field)
```

Gets a level 2 field.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-42)

| Name  | Type         | Description                                                                                   |
| ----- | ------------ | --------------------------------------------------------------------------------------------- |
| olKey | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`. |
| index | int256       | The index.                                                                                    |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-28)

| Name | Type  | Description |
| ---- | ----- | ----------- |
| \[0] | Field | The field.  |

#### level1s[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#level1s) <a href="#level1s" id="level1s"></a>

```
function level1s(struct OLKey olKey, int256 index) external view returns (Field)
```

Gets a level 1 field.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-43)

| Name  | Type         | Description                                                                                   |
| ----- | ------------ | --------------------------------------------------------------------------------------------- |
| olKey | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`. |
| index | int256       | The index.                                                                                    |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-29)

| Name | Type  | Description |
| ---- | ----- | ----------- |
| \[0] | Field | Yhe field.  |

#### root[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#root) <a href="#root" id="root"></a>

```
function root(struct OLKey olKey) external view returns (Field)
```

Gets the root from local.

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-44)

| Name  | Type         | Description                                                                                   |
| ----- | ------------ | --------------------------------------------------------------------------------------------- |
| olKey | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`. |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-30)

| Name | Type  | Description |
| ---- | ----- | ----------- |
| \[0] | Field | The root.   |

#### flashloan[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#flashloan) <a href="#flashloan" id="flashloan"></a>

```
function flashloan(struct MgvLib.SingleOrder sor, address taker) external returns (uint256 gasused, bytes32 makerData)
```

Internal function used to flashloan tokens from taker to maker, for maker to source the promised liquidity.

*Not to be called externally - only external to be able to revert.*

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-45)

| Name  | Type                      | Description                      |
| ----- | ------------------------- | -------------------------------- |
| sor   | struct MgvLib.SingleOrder | Data about an order-offer match. |
| taker | address                   | The taker.                       |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-31)

| Name      | Type    | Description                                |
| --------- | ------- | ------------------------------------------ |
| gasused   | uint256 | The amount of gas used for `makerExecute`. |
| makerData | bytes32 | The data returned by `makerExecute`.       |

#### internalCleanByImpersonation[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#internalcleanbyimpersonation) <a href="#internalcleanbyimpersonation" id="internalcleanbyimpersonation"></a>

```
function internalCleanByImpersonation(struct OLKey olKey, uint256 offerId, Tick tick, uint256 gasreq, uint256 takerWants, address taker) external returns (uint256 bounty)
```

Internal function used to clean failing offers.

*Not to be called externally - only external to be able to revert.*

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-46)

| Name       | Type         | Description                                                                                                                                                                                                          |
| ---------- | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| olKey      | struct OLKey | The offer list key given by (maker) `outbound_tkn`, (maker) `inbound_tkn`, and `tickSpacing`.                                                                                                                        |
| offerId    | uint256      | The id of the offer on Mangrove.                                                                                                                                                                                     |
| tick       | Tick         | Must be `>= MIN_TICK` and `<= MAX_TICK`. The `tick` induces a price which is `1.0001^tick`. The actual tick of the offer will be the smallest tick `offerTick > tick` that satisfies `offerTick % tickSpacing == 0`. |
| gasreq     | uint256      | The gas required for the offer.                                                                                                                                                                                      |
| takerWants | uint256      | Must be `<= MAX_SAFE_VOLUME`. The amount of `olKey.outbound_tkn` the taker wants.                                                                                                                                    |
| taker      | address      | The taker used for transfers (should be able to deliver token amounts).                                                                                                                                              |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-32)

| Name   | Type    | Description      |
| ------ | ------- | ---------------- |
| bounty | uint256 | The bounty paid. |

#### fallback[​](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#fallback) <a href="#fallback" id="fallback"></a>

```
fallback(bytes callData) external returns (bytes)
```

Fall back function (forwards calls to `MgvAppendix`).

**Parameters**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#parameters-47)

| Name     | Type  | Description    |
| -------- | ----- | -------------- |
| callData | bytes | The call data. |

**Return Values**[**​**](https://old.docs.mangrove.exchange/developers/strat-lib/technical-references/code/core/src/IMangrove#return-values-33)

| Name | Type  | Description |
| ---- | ----- | ----------- |
| \[0] | bytes | The result. |

| Name | Type  | Description |
| ---- | ----- | ----------- |
| \[0] | bytes | The result. |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mangrove.exchange/dev/strat-lib/technical-references/api-preferences/core/src/imangrove.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
