Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use github math module for formulas #33

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,32 @@

formulas without orderbook matching (Liquidity Pool Model only)

```math
Price = \frac{Target Coin Pool Amount \times (1 - Pool Fee)}{Source Coin Pool Amount + 2 \times Source Coin Amount}
```
<img src="https://latex.codecogs.com/png.image?\inline\dpi{150}\bg{white}Price&space;=&space;\frac{Target\&space;Coin\&space;Pool\&space;Amount\&space;*\&space;(1&space;-&space;Pool\&space;Fee)}{Source\&space;Coin\&space;Pool\&space;Amount\&space;&plus;\&space;2\&space;*\&space;Source\&space;Coin\&space;Amount}" />

```math
Target Coin Amount = \frac{Source Coin Amount \times Target Coin Pool Amount \times (1 - Pool Fee)}{Source Coin Pool Amount + 2 \times Source Coin Amount}
```

<img src="https://latex.codecogs.com/png.image?\inline\dpi{175}\bg{white}Target\&space;Coin\&space;Amount&space;=&space;\frac{Source\&space;Coin\&space;Amount\&space;*\&space;Target\&space;Coin\&space;Pool\&space;Amount\&space;*\&space;(1&space;-&space;Pool\&space;Fee)}{Source\&space;Coin\&space;Pool\&space;Amount\&space;&plus;\&space;2\&space;*\&space;Source\&space;Coin\&space;Amount}" />

where _Pool Fee = 0.003_ as most common value

#### Osmosis
[Module Gamm documentation](https://docs.osmosis.zone/osmosis-core/modules/gamm)

```math
Price = \frac{Target Coin Pool Amount \times (1 - Pool Fee)}{Source Coin Pool Amount + (1 - Pool Fee) \times Source Coin Amount} \times \frac{Source Coin Pool Weight}{Target Coin Pool Weight}
```

<img src="https://latex.codecogs.com/png.image?\inline\dpi{200}\bg{white}Price&space;=&space;\frac{Target\&space;Coin\&space;Pool\&space;Amount\&space;*\&space;(1&space;-&space;Pool\&space;Fee)}{Source\&space;Coin\&space;Pool\&space;Amount\&space;&plus;\&space;(1&space;-&space;Pool\&space;Fee)\&space;*\&space;Source\&space;Coin\&space;Amount}\&space;*\&space;\frac{Source\&space;Coin\&space;Pool\&space;Weight}{Target\&space;Coin\&space;Pool\&space;Weight}" />

```math
Target Coin Amount = \frac{Source Coin Amount \times Target Coin Pool Amount \times (1 - Pool Fee)}{Source Coin Pool Amount + (1 - Pool Fee) \times Source Coin Amount} \times \frac{Source Coin Pool Weight}{Target Coin Pool Weight}
```

<img src="https://latex.codecogs.com/png.image?\inline\dpi{175}\bg{white}Target\&space;Coin\&space;Amount&space;=&space;\frac{Source\&space;Coin\&space;Amount\&space;*\&space;Target\&space;Coin\&space;Pool\&space;Amount\&space;*\&space;(1&space;-&space;Pool\&space;Fee)}{Source\&space;Coin\&space;Pool\&space;Amount\&space;&plus;\&space;(1&space;-&space;Pool\&space;Fee)\&space;*\&space;Source\&space;Coin\&space;Amount}\&space;*\&space;\frac{Source\&space;Coin\&space;Pool\&space;Weight}{Target\&space;Coin\&space;Pool\&space;Weight}" />

### Analytics
Expand Down Expand Up @@ -84,4 +101,4 @@ pip install -r requirements.txt
run jupyter notebook
```bash
jupyter notebook
```
```