Skip to content

Commit

Permalink
Antoine/more kandel stuff (#196)
Browse files Browse the repository at this point in the history
* adding to FAQ, clarifying Kandel descriptions, adding Taker fee table

* fixing broken links

* modif FAQ

* adding min. volume

* adding min. volume per market #2

* adding link to new min. volume page in FAQ

* reordering FAQ items
  • Loading branch information
frkralj authored Oct 25, 2023
1 parent cc4e49e commit ed3cfca
Show file tree
Hide file tree
Showing 20 changed files with 170 additions and 123 deletions.
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Smart contracts [can be attached to offers](./general/high-level/concepts/smart-

* [**Last look:**](./developers/terms/last-look.md) smart offers allow you to code defensive mechanisms that adjust for market condition changes between offer posting and execution.

* [**Bounty:**](./general/high-level/concepts/bounty.md) every single failed offer is compensated with a bounty,; Keeper bots can make money, and Takers don't lose any.
* [**Bounty:**](./general/high-level/concepts/bounty.md) every single failed offer is compensated with a bounty; Keeper bots can make money, and Takers don't lose any.

* **<font color="#47d77d">Permissionless:</font>** everyone can interact with the core protocol without having to ask permission nor risking to be censored.

Expand Down
17 changes: 17 additions & 0 deletions docs/developers/terms/base-quote.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
id: base-quote
title: Base / Quote
hoverText: Base token is the traded asset, quoted in Quote token.
---

### Base token
It is the token traded at a given price, quoted in the Quote token.

### Quote token
It's the token in which the price of any order is defined on a particular market.

Example:

* On a WETH/USDC pair:
* the Base token is WETH, and the quote is USDC
* prices are displayed in USDC (quote)
69 changes: 62 additions & 7 deletions docs/general/FAQ/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,95 @@ sidebar_position: 2

<details><summary>

## Where can I get Mangrove’s addresses?
### Why do my transactions keep failing?
</summary>

The deployment addresses for the core contract for Mangrove, as well as the most important periphery contracts are available at [Contracts → Deployment Addresses](../../developers/contracts/technical-references/contract-addresses.md).
Here are a few reasons as to why your transactions are failing on Mangrove exchange:
* The amount of gas or slippage you selected is too low - we encourage you to tweak those values and find out what works best for your trades.
* The [density](../../developers/terms/density.md) for your Limit order is too low - if you're trying to place a Limit order with a small amount, your order will fail and will not be executed. Mangrove requires that you provide a token amount greater than the amount of gas the triggered offer requires to be executed (called density).
* You can check the minimum volume required to post a limit order [here](../web-app/trade/how-to-limit-order.md).

💡 Note: if you still want to place a limit order with a small amount (ex: 10 USDC), you can avoid the density check by using [IOC (Immediate Or Cancel)](../web-app/trade/more-on-order-types.md#immediate-or-cancel-ioc) orders.

</details>


<details><summary>

## Who pays the fees on Mangrove?
### Who pays the fees on Mangrove?
</summary>
Fees on Mangrove are paid by the taker: The fee is taken from the tokens that the taker has bought.

Read more about fees here: [Taker fees](../../developers/contracts/technical-references/governance-parameters/local-variables.md#taker-fees).
Read more about fees [here](../web-app/trade/taker-fee.md), and also [here](../../developers/contracts/technical-references/governance-parameters/local-variables.md#taker-fees)
</details>


<details><summary>

### The approval amount for my limit orders seems odd - what is going on?

</summary>

**TL;DR**
* A rule of thumb for limit orders to avoid order failure due to lack of approval is to make sure you approve at least double the amount you target (or infinite approval).
* The easy way to do this is to use the "Use default" option on Metamask when executing an approval.


**Let's now clarify the difference between the "Max" and "Use default" approval values offered by Metamask.**
* "Max" will give you the maximum amount available in your wallet.

* If you have ticked the "allow infinite approval" on Mangrove app, "Use default" will give you an "infinite approval" amount.

* If you have unticked the "allow infinite approval" on Mangrove app, "Use default" will give you the maximum amount available in your wallet based on what you've keyed in. That amount differs **whether you are executing a market order or a limit order**.

**Example (no infinite approval)**

* Market order: if you want to buy some WMATIC with let's say 20 USDT, "Use default" will set the approval amount at _20 + slippage_. For a 2% slippage, the amount to approve would be 20.4 USDT.

* Limit order: if you want to buy some WMATIC for 20 USDT of worth with a limit order (ex: Good til time), "Use default" will set the approval amount at _40 (20 * 2)_.
* If you have multiple open limit orders for the same token, the approvals then need to compound.
* Example: if you create another Good til time limit order for 20 USDT of worth, the approval amount will be 40 (previous limit order) + 40 (new limit order) = 80 USDT.

</details>


<details><summary>

### Where can I get Mangrove’s addresses?
</summary>

The deployment addresses for the core contract for Mangrove, as well as the most important periphery contracts are available at [Contracts → Deployment Addresses](../../developers/contracts/technical-references/contract-addresses.md).
</details>

<details><summary>

### Where is my transaction history?
</summary>

Which order type are you trying to execute?
There are subtle differences between the various limit orders available on our Trade page. They might appear/be processed differently. We encourage you to first read the [More on order types](../web-app/trade/more-on-order-types.md) section.
</details>


<details><summary>

## Who pays the gas on Mangrove?
### Who pays the gas on Mangrove?
</summary>

If the offer succeeds, the gas costs for the [execution of the trade](../../developers/contracts/technical-references/taking-and-making-offers/reactive-offer/executing-offers.md) are paid by the offer taker. If the offer fails the taker is compensated for these gas costs - see [What happens when an offer fails?](#what-happens-when-an-offer-fails)
</details>

<details><summary>

## What happens when an offer fails?
### What happens when an offer fails?
</summary>

Offers in the order book may fail when taken, either because the maker consciously chose to [renege on the offer to trade](../../developers/contracts/background/taker-compensation.md), or because the maker contract reverted for other reasons. In that case, the taker has wasted some gas and will be compensated using the [offer provision](../../developers/contracts/technical-references/taking-and-making-offers/reactive-offer/offer-provision.md) (in native token) that the maker has deposited in Mangrove.
</details>

<details><summary>

## Are Mangrove market orders the same as traditional market orders?
### Are Mangrove market orders the same as traditional market orders?
</summary>

Mangrove's [market orders](../../developers/contracts/technical-references/taking-and-making-offers/taker-order/README.md) are DeFi market orders - which are different from market orders in TradFi:
Expand Down
5 changes: 3 additions & 2 deletions docs/general/kandel/details-on-strats/details-on-strats.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ Kandel, built by Mangrove, is an example of a market making strategy.
Kandel on AAVE works exactly the same as the standard Kandel strategy, with the exception that the [Strategy reserve](../how-does-kandel-work/strategy-reserve.md) (Unallocated and Published liquidity) is deposited on AAVE, thus earning additional yield.
When an offer is matched, the liquidity is sourced from the funds deposited on AAVE. After the offer is executed, the received amount is republished and stored on AAVE.

> 💡
> Kandel and Kandel on AAVE have minimum inventory and gas requirements.
:::info Note
Kandel and Kandel on AAVE have minimum inventory and gas requirements.
:::

Here is more information on the inventory requirements:<br />

Expand Down
20 changes: 13 additions & 7 deletions docs/general/kandel/how-does-kandel-work/choosing-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ sidebar_position: 4

This section goal is to help you develop an intuition to choose your Kandel parameters. It should be taken as an explanation on how the various parameters can impact your Kandel, and how the market conditions (ex: volatility) could be taken into account. It is **not** a trading advice.

> 💡
> As a reminder, Kandel is not intended as a "set and forget" strategy, and needs ongoing maintenance and checks.
:::info Note
As a reminder, Kandel is not intended as a "set and forget" strategy, and needs ongoing maintenance and checks.
:::

We will be going through standard steps you might want a take in order to check the market and deploy a new Kandel.
Essentially, that means that by using discrete AMM such as Kandel, you can fix the level of liquidity you are offering adjusted per volatility. So choosing the spread starts with answering the question - what is the volatility? If you can estimate or predict it well enough, the only thing you need to do is pick the spread (i.e. your parameters for Kandel).
Expand All @@ -20,29 +21,34 @@ Essentially, that means that by using discrete AMM such as Kandel, you can fix t

First, it is good practice to know how often you aim to update your Kandel. Depending on the trading pair you chose, markets can behave very differently.

Example: I will update my Kandel every 24h.
:::info Example
I will update my Kandel every 24h.
:::

## Set your price range

Next, you should try to anticipate how much the market/price will vary during that period you just decided on. You are kind of betting on daily volatility.

Example: I will look at the market volatility for the past 24h, and decide on the price range for my new Kandel.
:::info Example
I will look at the market volatility for the past 24h, and decide on the price range for my new Kandel.
:::

## Ratio

This is the ratio of the progression used to calculate the price grid. You would logically bet on intra-day volatility (few min or hours). If the volatility is increasing, you might want to increase the grid size (space between price points).


:::info Note
* High volatility: spaced out price points (less price points in the chosen range) -> higher ratio
* Low volatility: narrow price points (more price points in the chosen range) -> smaller ratio

:::

## Step size

The general idea to configure your step size, is that a bigger volatility would likely lead to a bigger step size.


## Simple use case
Let's say you want to have a continuous Kandel, and maybe your current paramaters allow you only 2 price points.
Let's say you want to have a continuous Kandel, and maybe your current paramaters allow you only 2 price points:

* The solution to this is instead of having 2 points with a step size = 1, you can configure 16 points with a step size of 8
* That gives you continuity (more price points for a similar interval)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ This section is a detailed explanation of how Kandel works, introducing configur

For a detailed explanation on how to create and manage a Kandel strategy on Mangrove's UI, you can view the [Create a strategy](../../web-app/strategies/create-strat.md) and [Manage a strategy](../../web-app/strategies/manage-strat/README.md) pages on our Web App documentation.

> 💡
> Kandel is not intended as a "set and forget" strategy, and needs ongoing maintenance and checks.
:::info Note
Kandel is not intended as a "set and forget" strategy, and needs ongoing maintenance and checks.
:::

## Vocabulary

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ When we talk about an offer "failing", we mean that it could not execute. An off
* [`makerPosthook()`](../../../developers/strat-lib/technical-references/code/strategies/MangroveOffer/#makerposthook): it is the callback function that is called after the offer execution (i.e. after a successful execution of `makerExecute()`).
* A failure in `makerPosthook()` means the offer cannot update or repost itself after being taken. It does not cancel the trade, since it is called after `makerExecute()`.

> 💡
> For a more visual explanation, see the [call sequence overview](../../../developers/contracts/technical-references/overview#call-sequence-overview) diagram.
:::info Note
For a more visual explanation, see the [call sequence overview](../../../developers/contracts/technical-references/overview#call-sequence-overview) diagram.
:::

## Kandel and `makerExecute()` failure

Expand All @@ -39,8 +40,9 @@ Therefore, since the user is not in charge of writing and maintaining the smart
The main failures that Kandel could run into are linked to reposting Bids and Asks. This has little incidence for the user, nor does it affect the behavior of his Kandel strategy.<br />
Non-reposted liquidity will be placed into the [Unallocated liquidity](./strategy-reserve#unallocated-liquidity) reserve, and the offer will be "empty" for Kandel, until the user replenishes it.<br />

> 💡
:::info Note
> If too many empty offers stack up, it would diminish Kandel's ability to profit from the spread, and therefore the overall generated yield. Kandel is not intended as a "set and forget" strategy, and needs ongoing maintenance and checks.
:::

<br />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sidebar_position: 2

## Setting things up

Before launching your customized Kandel strategy, you will be asked to set specific input parameters. For more information, you can refer to the [Parameters description table](./parameters.md).
Before launching your customized Kandel strategy, you will be asked to set specific input parameters. For more information, you can refer to the [Parameters description table](./parameters.md), as well as the [Choosing parameters](./choosing-parameters.md) section.


## Price distribution
Expand All @@ -23,19 +23,20 @@ Based on the selected **price range**, the price grid is constructed using a geo
The increments are calculated using a key metric called **ratio** (of the geometric progression). Kandel starts from the Min price, all the way up to the Max price.
By default, the ratio is 1%.

> 💡
> In this example, the user selected an ETH/USDC trading pair.
:::info Note
In this example, the user selected an ETH/USDC trading pair.
:::

## Volume distribution

<img src={useBaseUrl('img/assets/volume_distribution.PNG')} width="400px"/><br /><br />

Based on the selected amount of initial liquidity to be deposited, Kandel draws the **volume distribution** (i.e. the initial volume at each price point).
In the example of a uniform volume distribution, the user's liquidity is spread evenly throughout the price grid.<br />
> 💡
>For this explanation, we are conveniently using a 1 ETH allocation for each increment.

:::info Note
For this explanation, we are conveniently using a 1 ETH allocation for each increment. If based on our parameters, our Kandel would create a price grid of 10 points, for example, then we would use 10 ETH in total (1 ETH * 10 price points).
:::

## Populating Bids and Asks

Expand All @@ -51,18 +52,18 @@ Afterwards, the Kandel strategy contract populates the price grid by posting off

<img src={useBaseUrl('img/assets/bid_is_taken.PNG')} width="400px"/><br /><br />

When a **<font color="#5cd19b">bid</font>** is taken, the Kandel strategy contract sends the corresponding amount of **quote tokens** (USDC) and receives a corresponding amount of **base tokens** (ETH).
When a **<font color="#5cd19b">bid</font>** is taken, the Kandel strategy contract sends the corresponding amount of [**quote tokens**](../../../developers/terms/base-quote.md) (USDC) and receives a corresponding amount of [**base tokens**](../../../developers/terms/base-quote.md) (ETH).


## Reposting liquidity as an Ask

<img src={useBaseUrl('img/assets/reposting_liquidity_as_ask.PNG')} width="400px"/><br /><br />

The received amount of **base tokens** (ETH) is used to post a %%dual offer|dual-offer%% at a **step size k=1 above**.

> 💡
> Since the volume objective at the relevant index is 1 ETH, all the received liquidity is used to populate corresponding **<font color="#eb525a">ask</font>**.
The received amount of **base tokens** (ETH) is used to post a %%dual offer|dual-offer%% at a **step size k=1 above**. This is automatically handled by Kandel, it is part of its trading behaviour.

:::info Note
Since the volume objective at the relevant index is 1 ETH, all the received liquidity is used to populate corresponding **<font color="#eb525a">ask</font>**. Our Kandel just received 1 ETH (previous Bid), and is using it all to repost an offer, an Ask (called dual offer).
:::

## Ask is taken

Expand All @@ -85,13 +86,12 @@ In our example:

Therefore, 100% of the spread (or 13 USDC) is reinvested into the strategy. A new **<font color="#5cd19b">bid</font>** at k=1 steps below is reposted, and offers 1,300 USDC for 1.01 ETH.

> 💡
> Calculation:
:::info Calculation
* _Profit = 1,300 USDC - 1,287 USDC = 13 USDC_
* _13 / 1300 = 0.01 = 1%_
* i.e. we made a 1% profit on the spread
* Kandel will repost our **<font color="#5cd19b">bid</font>** to offer _1,287+13 USDC_ for _1*1.01 ETH_, reinvesting the 1% profit we just made

:::

## Another Ask is taken

Expand All @@ -105,5 +105,6 @@ When another **<font color="#eb525a">ask</font>** is taken, once again Kandel se

Similarly to our previous **<font color="#5cd19b">bid</font>**, the received amount of **quote tokens** (USDC) is used to post a dual offer **step size k=1 below**.

> 💡
> If an **<font color="#eb525a">ask</font>** was to be taken next, the profit from the spread would be reinvested into the strategy.
:::info Note
If an **<font color="#eb525a">ask</font>** was to be taken next, the profit from the spread would be reinvested into the strategy.
:::
1 change: 0 additions & 1 deletion docs/general/table-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ sidebar_position: 0
* [How to place a market order](./web-app/trade/how-to-market-order.md)
* [How to place a limit order](./web-app/trade/how-to-limit-order.md)
* [How to track open and past orders](./web-app/trade/how-to-track-open-orders.md)
* [Common issues and resolution](./web-app/trade/common-issues-resolution.md)
* [More on order types](./web-app/trade/approve-buy.md)
* [Strategies](./web-app/strategies/README.md)
* [Create a strategy](./web-app/strategies/create-strat.md)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
* **Polygon mainnet**: you need to be connected to the Polygon mainnet. If you see a "Unsupported Network" pop-up, click "Switch network".
* **Polygon Mumbai testnet**: you need to be connected to the Polygon Mumbai test network.

:::info
:::info Note
If you see a "Unsupported Network" pop-up, click "Switch network".
:::

Expand Down
5 changes: 3 additions & 2 deletions docs/general/web-app/strategies/create-strat.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import useBaseUrl from '@docusaurus/useBaseUrl';

## Step 2/3 - Strategy parameters

:::info
:::info note
Average return: the average monthly return of kandels for this market
:::
:::info

:::info Note
Risk appetite:
* Low: corresponds to a low volatily pair (ex: stable/stable, such as USDC/USDT)
* Medium: corresponds to a medium volatily pair (ex: volatile/stable, such as WBTC/USDT)
Expand Down
5 changes: 3 additions & 2 deletions docs/general/web-app/strategies/manage-strat/overview-tab.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ In the screenshot below, Token A is WETH and Token B is USDC (WETH/USDC market).
<img src={useBaseUrl('img/assets/kandel_offers_list.png')} width="70%"/><br /><br />


👉 **More about <font color="#5cd19b">green</font> / <font color="#eb525a">red</font> / <font color="#a7adcd">grey</font> dots:**
:::info 👉 **More about <font color="#5cd19b">green</font> / <font color="#eb525a">red</font> / <font color="#a7adcd">grey</font> dots:**

1. If you navigate on a green/red dot, the relevant offer is highlighted on the list. You can check the price at which an offer is posted, as well as the base and quote amounts.

2. You are also able to refill empty offers (grey dots) by hovering over them and selecting "Refill offer".
2. You are also able to refill empty offers (grey dots) by hovering over them and selecting "Refill offer".
:::
Loading

0 comments on commit ed3cfca

Please sign in to comment.