Sigmadex has a design priority of minimizing the complexity of the core smart contract. Keeping the structure lightweight and simple is detrimental for security as these components will contain large amounts of liquidity and any type of breach could result in a catastrophic event.

### Contract Initialization

When a liquidity provider deposits their collateral into a brand new smart contract, the proposed liquidity token is handled with a specific process.

*$$lp_m=\sqrt{(x_{in})\cdot(y_{in})}$$*

abbreviation | description |
---|---|

lp |
Liquidity Provider |

in |
Capital Injected |

x |
Token A |

y |
Token B |

m |
Tokens Minted |

We propose the *geometric mean *for the number of tokens deposited in order to have an appropriate balance:

*$$(\prod{i=1}^{n}x_i)^\frac{1}{n}=\sqrt[n]{x_1x_2 \cdot \cdot \cdot x_n}$$*

The geometric mean for a series of numbers can be calculated by taking the product of these numbers and raising it to the inverse of the length of the series.

To do this, we add one to each number (so that there are no conflicts with negative %). We then multiply all the numbers together and raise their product to the power of one divided by the count of the numbers in the series.

Finally, we subtract one from the result to get:

*$$[(1+R1)\cdot(1+R2)\cdot(1+R3)...(1+Rn)]^\frac{1}{n}-1$$*

abbreviation | description |
---|---|

R |
Return |

n |
# in Series |

These equations separate the liquidity pool stakes from when the contract was established.

### Adding Liquidity

In order to add **initial** liquidity, a user will have to deposit 2 types of tokens.

**First time:**

- Deposit native tokens (SDEX)
- Deposit root asset tokens (eg. DOT)
- Set initial variables (Oracle Gateway, Price, Time Lock)
- Claim liquidity bits

⚠ WARNING

If variables are not set correctly, pricing and liquidity capital will be affected. Improperly configured contracts may open an arbitrage opportunity that will force the price to move drastically without immediate notice.

**Joining pre-existing liquidity pool addition:**

- Set desired
`timelock`

value - Deposit native tokens (SDEX)
- Deposit root asset tokens (eg. DOT)
- Claim liquidity bits

Adding liquidity consists of depositing an equivalent value of native tokens and the desired secondary token pair (Root Token) into the token’s contract pool.