# ⚖️SaucerSwap V1

## Core Concepts

### Introduction

SaucerSwap V1 is an automated market maker (AMM) based on Uniswap V2 smart contracts, adapted to work with the Hedera Token Service (HTS) through the Hedera Smart Contract Service (HSCS). For technical information, refer to the V1 Whitepaper.

The protocol uses a constant product formula, represented by $xy=k$, for its automated liquidity provision. $x$ and $y$ are the reserves of each token in a given liquidity pool, and k is the product of these reserves. The value of $k$ remains constant during swaps, ensuring that the liquidity pool stays balanced and that every swap moves the price along a predetermined bonding curve.

Traders incur a 30 basis-point (0.30%) fee on each swap. Of this fee, 5/6 is allocated to liquidity providers, while the remaining 1/6 is directed to the protocol. The protocol utilizes its share for SAUCE token buybacks, which are subsequently distributed between the Infinity Pool and the DAO.

### Worked Example

Understanding the mechanics of constant product AMMs is essential for traders and liquidity providers. This example provides a detailed walkthrough of a simulated trade and liquidity provision in SaucerSwap V1.

#### Creating a Liquidity Pool

A liquidity provider decides to create a new pool for HBAR and USDC. Given that HBAR is trading at approximately 1/10 the price of USDC on secondary markets, they set an initial deposit ratio that reflects this market price: 10,000 HBAR and 1,000 USDC. If the price is off, arbitrageurs will correct it at the expense of the liquidity provider.

The constant product $k$ for this pool is calculated using the initial reserves of each token:

\begin{align*} \text{HBAR reserves: } x &= 10,000 \, \text{HBAR} \\ \text{USDC reserves: } y &= 1000 \, \text{USDC} \\ k &= x \times y \\ &= 10,000 \, \text{HBAR} \times 1,000 \, \text{USDC} \\ &= 10,000,000 \end{align*}

#### Performing a Swap

A trader wants to swap $s = 100$ HBAR for USDC in this pool. After applying the SaucerSwap protocol's 0.30% fee, the effective amount $s'$ is:

$s' = s \times (1 - 0.003) = 100 \, \text{HBAR} \times 0.997 = 99.7 \, \text{HBAR}$

The new reserves, $x'$ and $y'$, must satisfy the invariant, $k$:

$(x + s') \times (y - y') = k$

Solving for $y'$:

$(10,000 + 99.7) \times (1000 - y') = 10,000,000 \\ y' = 1000 - \frac{10,000,000}{10,099.7} \approx 9.9 \, \text{USDC}$

The trader receives about 9.9 USDC for 100 HBAR. This is slightly less than expected due to price impact. Price impact can be defined as the liquidity "cost" a trader incurs when executing a swap. This cost manifests as a less favorable exchange rate, since an adjustment in the token reserves, $x$ and $y$, is needed to maintain the constant product, $k$. The price impact is calculated as follows:

\begin{align*} \text{Initial Price} &= \frac{y}{x} = \frac{1000 \, \text{USDC}}{10,000 \, \text{HBAR}} = 0.1 \, \text{USDC/HBAR} \\ \text{Final Price} &= \frac{y'}{(x + s)} = \frac{990.1 \, \text{USDC}}{10,100 \, \text{HBAR}} \approx 0.098 \, \text{USDC/HBAR} \\ \text{Price Impact} &= \frac{\text{Final Price} - \text{Initial Price}}{\text{Initial Price}} \times 100 \\ &= \frac{0.098 - 0.1}{0.1} \times 100 \approx -2\% \end{align*}

This trade results in a price impact of approximately -2%.

### Distribution of Fees

In this example, the 0.3 HBAR fee from the trade gets split—0.25 HBAR goes to the liquidity provider and is added to the pool, while 0.05 HBAR goes to the protocol for SAUCE token buybacks.

The addition of 0.25 HBAR to the pool increases the value of each LP token. Liquidity providers can track accumulated fees through the 7-day average $Fees \space APR$ displayed on the interface. Note that the LP token price is not immune to volatility; it is affected by the price movements of the underlyings—specifically HBAR and USDC in this instance.

$\text{Fees APR} = \frac{{24h \text{ Volume } \times \left( \text{Fee} \times \frac{5}{6} \right)}}{{\text{Liquidity}}} \times 365$

Where $Fee = 0.30\%$.

Note: $Total \space APR=Fees \space APR+Reward \space APR$, where $Reward \space APR$ is sourced from yield farming.

## Yield Farm

Yield farming on SaucerSwap allows liquidity providers to stake their LP tokens in the Masterchef contract to earn dual rewards in both HBAR and SAUCE. The Masterchef contract handles LP token staking and unstaking, as well as the automated minting and distribution of SAUCE rewards, according to a pre-set emission schedule.

Rewards are proportional to the size of the liquidity provider's stake, relative to the total staked assets in the pool, and influenced by the pool's weight of overall emissions. The interface tracks these rewards as $Reward \space APR$, calculated using the formula:

$\text{Reward APR} = \frac{{w \times E_{\text{HBAR}} \times E_{\text{SAUCE}}}}{\text{Staked Liquidity}}$

Where:

• $w$ represents the Farm Weight.

• $E_\text{HBAR}$ represents the Annualized Emission Rate of HBAR ($/year). • $E_\text{SAUCE}$ represents the Annualized Emission Rate of SAUCE ($/year).

Current emission rates are 230.62 SAUCE/min and 0.78 HBAR/min. These are allocated to various liquidity pools through a governance process.

Last updated