# Step-by-step visual explanation

### Setting things up <a href="#setting-things-up" id="setting-things-up"></a>

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, as well as the Choosing parameters section.

<figure><img src="https://3197749937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdT1ftsp-ASVL0f7MSf%2Fuploads%2FzGfgc1CRyZZMvRmp1xak%2Fwhite_background_image.png?alt=media&#x26;token=42db42f2-8d30-4b5b-a187-3f3760cdb10d" alt=""><figcaption></figcaption></figure>

Based on the selected **price range** and either the `number of offers` or `ratio`, the price grid is constructed using a geometric progression. The `min` and `max` prices of the user inputs are the limits of the grid.

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% (due to ticks it will not be exactly 1%).

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

<figure><img src="https://3197749937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdT1ftsp-ASVL0f7MSf%2Fuploads%2FoVpnHmO5m7tmPpJGhDAi%2Fvolume_distribution_white_bg.png?alt=media&#x26;token=fbf9dc81-ea83-4b4d-933b-fd3fb4209cab" alt=""><figcaption></figcaption></figure>

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>

**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 <a href="#populating-bids-and-asks" id="populating-bids-and-asks"></a>

<figure><img src="https://3197749937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdT1ftsp-ASVL0f7MSf%2Fuploads%2FvZFbAeWosI7kgoNfrz47%2Fonly_outer_background_white.png?alt=media&#x26;token=abe298a5-8d26-40ae-932d-45ba4a5c47ba" alt=""><figcaption></figcaption></figure>

Afterwards, the Kandel strategy contract populates the price grid by posting offers:

* **Bids** are posted from min price to mid price (current price)
* **Asks** are on the other side of the book, from mid price to max price

### Bid is taken <a href="#bid-is-taken" id="bid-is-taken"></a>

<figure><img src="https://3197749937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdT1ftsp-ASVL0f7MSf%2Fuploads%2F7EdEYeiboW6DfnC3KsL3%2Fouter_background_white_bidtaken%20(1).png?alt=media&#x26;token=5bac54e2-74fa-4289-9695-9528945e28c2" alt=""><figcaption></figcaption></figure>

When a **bid** is taken, the Kandel strategy contract sends the corresponding amount of **quote tokens** (USDC) and receives a corresponding amount of **base tokens** (ETH).

### Reposting liquidity as an Ask <a href="#reposting-liquidity-as-an-ask" id="reposting-liquidity-as-an-ask"></a>

<figure><img src="https://3197749937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdT1ftsp-ASVL0f7MSf%2Fuploads%2F2bfQU4pB3wpjwUBEmEWF%2Fouter_background_white_repost.png?alt=media&#x26;token=f127ad41-4180-41ec-b85e-53372ea4afb4" alt=""><figcaption></figcaption></figure>

The received amount of **base tokens** (ETH) is used to post a dual offer at a **step size k=1 above**. This is automatically handled by Kandel, it is part of its trading behaviour.

**Note** : Since the volume objective at the relevant index is 1 ETH, all the received liquidity is used to populate corresponding **ask**. 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 <a href="#ask-is-taken" id="ask-is-taken"></a>

<figure><img src="https://3197749937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdT1ftsp-ASVL0f7MSf%2Fuploads%2FDrW070BAs8mei6m1LXJa%2Fouter_background_white_asktaken.png?alt=media&#x26;token=393081b4-500a-4f60-b0a8-dbc02b763249" alt=""><figcaption></figcaption></figure>

Inversely to the **bid** example, when an ask is taken, the Kandel strategy contract sends the corresponding amount of **base tokens** (ETH) and receives a corresponding amount of **quote tokens** (USDC).

### Reposting liquidity as an Bid <a href="#reposting-liquidity-as-an-bid" id="reposting-liquidity-as-an-bid"></a>

<figure><img src="https://3197749937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdT1ftsp-ASVL0f7MSf%2Fuploads%2F4y7YVExXz21dagjLQoFT%2Fouter_background_white_repost_final.png?alt=media&#x26;token=d4b6a9b5-ba73-4c5f-bef2-29d86183bdcb" alt=""><figcaption></figcaption></figure>

The received amount of **quote tokens** (USDC) is used to post a dual offer **step size k=1 below**.

In our example:

* We just received 1,300 USDC for sending 1 ETH through our **ask**
* Previously, we sent 1,287 USDC and received 1 ETH through our **bid**

Therefore, 13 USDC is reinvested into the strategy. A new **bid** at k=1 steps below is reposted, and offers 1,300 USDC for 1.01 ETH.

**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 **bid** to offer *1,287+13 USDC* for *1\*1.01 ETH*, reinvesting the 1% profit we just made

### Another Ask is taken <a href="#another-ask-is-taken" id="another-ask-is-taken"></a>

<figure><img src="https://3197749937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdT1ftsp-ASVL0f7MSf%2Fuploads%2FN8pu4t8Jqd5dMl9OWYt2%2Fouter_background_white_ask_1313.png?alt=media&#x26;token=e83617f7-f78b-4554-8e67-b9b649e52185" alt=""><figcaption></figcaption></figure>

When another **ask** is taken, once again Kandel sends the corresponding amount of **base tokens** (ETH) and receives a corresponding amount of **quote tokens** (USDC).

### Reposting liquidity as a Bid #2 <a href="#reposting-liquidity-as-a-bid-2" id="reposting-liquidity-as-a-bid-2"></a>

<figure><img src="https://3197749937-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdT1ftsp-ASVL0f7MSf%2Fuploads%2Fbc9Fs6wlyciAZmQtOjFw%2Fouter_background_white_repost_2600.png?alt=media&#x26;token=a8670c61-3241-4af4-b98e-0ee1a428a16f" alt=""><figcaption></figcaption></figure>

Similarly to our previous **bid**, the received amount of **quote tokens** (USDC) is used to post a dual offer **step size k=1 below**.

Note :

If an **ask** was to be taken next, the profit from the spread would be reinvested into the strategy.
