Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
Merge master into develop
  • Loading branch information
mangrove-automation authored Oct 26, 2023
2 parents ee94338 + ed3cfca commit de7123b
Show file tree
Hide file tree
Showing 322 changed files with 1,626 additions and 1,472 deletions.
57 changes: 0 additions & 57 deletions docs/FAQ/README.md

This file was deleted.

115 changes: 115 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
---
title: General
sidebar_position: 0
---

# Overview

<div class="text--justify">

Mangrove is an on-chain order book DEX that allows liquidity providers to post arbitrary smart contracts as offers.

</div>


import useBaseUrl from '@docusaurus/useBaseUrl';

<img src={useBaseUrl('img/assets/home_page.png')} width="100%"/>

## Total control over your offers

<div class="text--justify">

Mangrove's order book-based DEX [lists promises instead of locked commitments](./general/high-level/concepts/makers-takers-keepers/README.md). Liquidity can be shared, borrowed, lent somewhere and at the same time displayed on Mangrove, ready to be sourced when (and only when) an offer is taken.

</div>


## Smart offers

<div class="text--justify">

Smart contracts [can be attached to offers](./general/high-level/concepts/smart-offers.md), which gives the Maker total freedom in setting his sourcing trade parameters.

</div>

#### Powerful applications of smart offers

<div class="text--justify">

* [**Reactive liquidity:**](./developers/terms/reactive-liquidity.md) liquidity on offer is not locked on the Mangrove order book. As long as an offer posted on Mangrove is not taken, it can generate yield elsewhere on the chain.

* [**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.

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

* **<font color="#47d77d">Non-custodial:</font>** Mangrove users retain full control over their funds - the exchange does not hold custody of their assets.

</div>

<div>
<a class="button button--primary" href="../developers/strat-lib/getting-started/smart-offer">Post a smart offer</a>
</div>

## Deploy your own composable strategy

<div class="text--justify">

Mangrove enables liquidity providers to incorporate defensive code, post unprovisioned offers, and redisplay liquidity after their offers are taken.
</div>


#### Full control over your strategy parameters

<div class="text--justify">

* [**Amplified liquidity:**](./developers/terms/amplified-liquidity.md) optimize your trading potential by leveraging your liquidity across multiple pairs. For instance, you can create offers on WETH/USDC, WMATIC/USDC and WBTC/USDC pairs with an equal amount of USDC liquidity.

* [**Multi-liquidity sourcing:**](./developers/terms/reactive-liquidity.md) your smart offer on Mangrove can take advantage of liquidity sourcing from other sources and offering it to the taker, allowing for profitable arbitrage opportunities.

* [**Run AMMs strategies:**](./developers/strat-lib/README.md) provide liquidity on Mangrove’s order book in order to maximize your liquidity potential.

</div>

<div>
<a class="button button--primary" href="./developers/strat-lib">Create your strategy</a>
</div>

## Kandel strategy

<div class="text--justify">


[Kandel](./general/kandel/README.md) is an on-chain Automated Market Making strategy that focuses on order flow rather than price. It automatically posts Bids and Asks within your chosen market and price range to buy low and sell high, making a profit through the spread.

</div>

#### Features

<div class="text--justify">

* **<font color="#47d77d">On-chain market making bot</font>** Kandel is a market-making bot equivalent that operates solely on the blockchain. Unlike off-chain market making bots that experience delays, Kandel uses on-chain order flow to repost offers instantly, without any latency.

* **<font color="#47d77d">Profit from the spread:</font>** Kandel follows your configuration parameters to populate Bids and Asks offers. When those are taken, the profits are generated from the difference between the two, known as the spread.”

* **<font color="#47d77d">Compounding:</font>** you have the opportunity to accumulate profits generated from spreads and reinvest them back into your offers, a process commonly known as compounding. On Kandel strategy, you can set the compounding rate.

* **<font color="#47d77d">Price range:</font>** since Kandel is an automated market-making strategy, the price range needs to be set. It consists of the lowest and highest prices in the price grid at which the market maker is willing to post its bids and asks on Mangrove DEX.

* **<font color="#47d77d">Earn extra yield on AAVE:</font>** since the liquidity on offer is not locked on the Mangrove order book, it can generate yield elsewhere on the chain. With Kandel, when an offer is taken, your liquidity can be sourced and redeposited on AAVE.

</div>

<div>
<a class="button button--primary" href="./general/kandel">Deploy your Kandel</a>
</div>

## Mangrove is a secure protocol

<div class="text--justify">

Mangrove is an open-source protocol that has been rigorously [audited](./general/high-level/audits.md) by the highly reputable and expert firm, ChainSec, ensuring the utmost security and reliability.

</div>
17 changes: 17 additions & 0 deletions docs/developers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Developers
sidebar_position: 1
---

# Welcome to the Developers doc

The purpose of the Mangrove Developers doc is to:

* learn about Mangrove [core protocol](./contracts/README.md),
* understand how trading [strategies](./strat-lib/README.md) can be created and plugged in,
* use and integrate our [SDK](./SDK/README.md),
* set up [Keeper and Cleaning bots](./keeper-bots/README.md).


We suggest you start by reading [this introduction](./contracts/README.md).
If there's anything that is missing, or if you have questions, feel free to reach out via [Discord](https://discord.gg/rk9Qthz5YE).
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "Background",
"position": 5,
"collapsed": false
"collapsed": true
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "Getting Started",
"position": 2,
"collapsed": false
"collapsed": true
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebar_position: 2

# Deploy Kandel strategy

This tutorial covers how to deploy a Kandel strategy from a developer standpoint. For more information about Kandel, see the [Kandel documentation](../../kandel/README.md).
This tutorial covers how to deploy a Kandel strategy from a developer standpoint. For more information about Kandel, see the [Kandel documentation](../../../general/kandel/README.md).

## Prerequisites

Expand Down Expand Up @@ -44,12 +44,12 @@ Next, create an instance to manage Kandel strategies (`kandelStrategies`), and l
https://github.com/mangrovedao/mangrove.js/blob/2753b3148231a2541d0055a77a169f8f1381dcd1/examples/tutorials/deploy-kandel.js#L21-L25
```

With this, you can generate a [distribution](../../kandel/how-does-kandel-work/step-by-step-visual-explanation.md#price-distribution) with the minimum recommended amount of liquidity to avoid %%density|density%% issues by:
With this, you can generate a [distribution](../../../general/kandel/how-does-kandel-work/step-by-step-visual-explanation.md#price-distribution) with the minimum recommended amount of liquidity to avoid %%density|density%% issues by:
* Creating a generator
* Calculating minimums per offer
* Calculating the distribution for the given price parameters of `minPrice: 900`, `maxPrice: 1100`, and default ratio

See the API documentation for [calculateMinimumDistribution](../technical-references/code/classes/KandelDistributionGenerator.md#calculateminimumdistribution) for more details on other `priceParams`. In our example here, `midPrice: 1100` is used to set the [current price](../../kandel/how-does-kandel-work/parameters.md), and decide which offers become bids and which become asks.
See the API documentation for [calculateMinimumDistribution](../technical-references/code/classes/KandelDistributionGenerator.md#calculateminimumdistribution) for more details on other `priceParams`. In our example here, `midPrice: 1100` is used to set the [current price](../../../general/kandel/how-does-kandel-work/parameters.md), and decide which offers become bids and which become asks.

```javascript reference
https://github.com/mangrovedao/mangrove.js/blob/2753b3148231a2541d0055a77a169f8f1381dcd1/examples/tutorials/deploy-kandel.js#L27-L58
Expand Down Expand Up @@ -87,10 +87,10 @@ https://github.com/mangrovedao/mangrove.js/blob/2753b3148231a2541d0055a77a169f8f
A brief explanation on the above `seed` parameters:
* `onAave` indicates whether or not the liquidity to be used by Kandel is sitting on AAVE - here, it is not the case (it will be fetched from a wallet)
* `market`: this is the WETH/USDC pair that we previously chose
* `liquiditySharing` indicates whether you are using shared liquidity or not (SDK only, not available via the UI). This refers to the concept [amplified liquidity](../../terms/amplified-liquidity.md).
* `liquiditySharing` indicates whether you are using shared liquidity or not (SDK only, not available via the UI). This refers to the concept [amplified liquidity](/docs/developers/terms/amplified-liquidity.md).
* `gaspriceFactor`:
* By using the `recommendedConfig.gaspriceFactor`, we make sure to select the right amount of gas for our Kandel strategy
* This is also connected to the amount of [bounty](../../terms/bounty.md) to be paid in case of a failure to deliver
* This is also connected to the amount of [bounty](/docs/developers/terms/bounty.md) to be paid in case of a failure to deliver


### Approve transfers
Expand All @@ -103,7 +103,7 @@ https://github.com/mangrovedao/mangrove.js/blob/2753b3148231a2541d0055a77a169f8f

### Populate offers for the distribution

Now that our Kandel instance is deployed, we can [populate the offers](../../kandel/how-does-kandel-work/step-by-step-visual-explanation.md#populating-bids-and-asks) for the distribution.
Now that our Kandel instance is deployed, we can [populate the offers](../../../general/kandel/how-does-kandel-work/step-by-step-visual-explanation.md#populating-bids-and-asks) for the distribution.
This will create offers for the base and quote tokens, and deposit the required amounts of tokens into the Kandel instance.

The offers also need a %%provision|provision%%, hence here the default that we are using can be inspected.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,14 @@ sidebar_position: 1

# Set Up Your Local Environment


:::warning

Mangrove is in the process of being released. For the time being, therefore you must use the prerelease version of the `mangrove.js` package. The installation instructions below reflect this.

:::


import Preamble from './_preparation-pre.md';

<Preamble />

```bash
# To use the mangrove SDK
npm install --save dotenv
npm install --save @mangrovedao/mangrove.js@next
npm install --save @mangrovedao/mangrove.js@latest
```

import Post from './_preparation-post.md';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "Guides",
"position": 3,
"collapsed": false
"collapsed": true
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "Technical Reference",
"position": 4,
"collapsed": false
"collapsed": true
}
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
---
description: The Mangrove DEX is an on-chain, order book-based exchange where offers are code.
title: Introduction
sidebar_position: 1
---


# Introduction

The Mangrove is an [EVM-compatible](https://ethereum.org/en/developers/docs/scaling/sidechains/#evm-compatibility) order book-based exchange protocol (a [DEX](https://ethereum.org/en/defi/)), in which offers can be bound to a [smart contract](https://ethereum.org/en/smart-contracts/).

The order book of Mangrove lists promises to trade, instead of locked commitments.

* Offer makers add [liquidity promises](./background/offer-maker.md) to Mangrove. They own offers in %%offer lists|offer-list%% and manage contracts that react to [offer execution](technical-references/taking-and-making-offers/reactive-offer/executing-offers.md).
* Takers go to Mangrove to [find liquidity](background/offer-taker.md) by executing offers already in Mangrove.
* [Governance](technical-references/governance-parameters/README.md) adjusts Mangrove parameters, sets fees, and opens and closes new markets.
* Offer makers add [liquidity promises](./background/offer-maker.md) to Mangrove. They own offers in %%offer lists|offer-list%% and manage contracts that react to [offer execution](./technical-references/taking-and-making-offers/reactive-offer/executing-offers.md).
* Takers go to Mangrove to [find liquidity](./background/offer-maker.md) by executing offers already in Mangrove.
* [Governance](./technical-references/governance-parameters/README.md) adjusts Mangrove parameters, sets fees, and opens and closes new markets.

> πŸ’‘
> For non technical information about Mangrove, check out the [Concepts](../high-level/README.md) section.
> For non technical information about Mangrove, check out the [Concepts](../) section.
## Where do I start?

A good entry-point to the developer documentation for Mangrove protocol is the [Overview of Mangrove](./technical-references/overview.md) in the Technical Reference section.

## Where can I join the community?

The Mangrove project is open source. Follow and contribute on [GitHub](https://github.com/mangrovedao/), and join the [Mangrove Discord](https://discord.gg/rk9Qthz5YE).


The Mangrove project is open source. Follow and contribute on [GitHub](https://github.com/mangrovedao/), and join the [Mangrove Discord](https://discord.gg/rk9Qthz5YE).
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "Background",
"position": 5,
"collapsed": false
"collapsed": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sidebar_position: 2

An offer on Mangrove usually points to a contract containing the [offer logic](../technical-references/taking-and-making-offers/reactive-offer/maker-contract.md) and specifies what it is ready to deliver and its price. Offer are stored in [offer lists](../technical-references//taking-and-making-offers/offer-list.md).

![When a reactive Offer is matched, the contract implementing its logic is called by Mangrove](../../../static/img/assets/MakerOffer.png)
![When a reactive Offer is matched, the contract implementing its logic is called by Mangrove](/img/assets/MakerOffer.png)

### Creating & Updating offers

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "Getting Started",
"position": 2,
"collapsed": false
"collapsed": true
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "Guides",
"position": 3,
"collapsed": false
"collapsed": true
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "Technical Reference",
"position": 4,
"collapsed": false
"collapsed": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sidebar_position: 1

The illustration below depicts a bird's-eye view of the Mangrove ecosystem. The main actors are depicted as well as their most important interactions.

![A bird's-eye view of Mangrove ecosystem.](../../../static/img/assets/contactMap.png)
![A bird's-eye view of Mangrove ecosystem.](/img/assets/contactMap.png)

The Mangrove contract is depicted in the middle, with the three most important actors interacting with Mangrove around it:

Expand Down Expand Up @@ -55,7 +55,7 @@ This allows makers, for instance, to post another offer to redisplay their liqui

The diagram below summarizes the call sequence induced by a taker order. Notice that first the `makerExecute` functions is executed for all offers, and only subsequently are the `makerPosthook` functions of the offers executed.

![Mangrove call sequence induced by a taker order](../../../static/img/assets/execution.png)
![Mangrove call sequence induced by a taker order](/img/assets/execution.png)

## Where can I read more?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The `MgvCleaner` contract is provided as part of the periphery contracts. Its pu

It has a single function `collect`, with the same signature as as the function for [sniping offers](../taking-and-making-offers/taker-order/README.md#offer-sniping); please refer to that page for a detailed account of the arguments. In brief, for a given pair `(outbound_tkn, inbound_tkn)`, it takes an array of offers `targets` and expects all offers to fail or not to execute. If an offer did not fail, `MgvCleaner` will revert.

This contract may be deployed and used as part of running your own [cleaner keeper bot](/docs/keeper-bots/getting-started/run-a-simple-cleaning-bot.md).
This contract may be deployed and used as part of running your own [cleaner keeper bot](../../../keeper-bots/getting-started/run-a-simple-cleaning-bot.md).

```solidity
function collect(
Expand Down
Loading

0 comments on commit de7123b

Please sign in to comment.