SaucerSwap
Product
Search
K
Links
Comment on page

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=kxy=k
, for its automated liquidity provision.
xx
and
yy
are the reserves of each token in a given liquidity pool, and k is the product of these reserves. The value of
kk
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
kk
for this pool is calculated using the initial reserves of each token:
HBAR reserves: x=10,000HBARUSDC reserves: y=1000USDCk=x×y=10,000HBAR×1,000USDC=10,000,000\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=100s = 100
HBAR for USDC in this pool. After applying the SaucerSwap protocol's 0.30% fee, the effective amount
ss'
is:
s=s×(10.003)=100HBAR×0.997=99.7HBARs' = s \times (1 - 0.003) = 100 \, \text{HBAR} \times 0.997 = 99.7 \, \text{HBAR}
The new reserves,
xx'
and
yy'
, must satisfy the invariant,
kk
:
(x+s)×(yy)=k(x + s') \times (y - y') = k
Solving for
yy'
:
(10,000+99.7)×(1000y)=10,000,000y=100010,000,00010,099.79.9USDC(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,
xx
and
yy
, is needed to maintain the constant product,
kk
. The price impact is calculated as follows:
Initial Price=yx=1000USDC10,000HBAR=0.1USDC/HBARFinal Price=y(x+s)=990.1USDC10,100HBAR0.098USDC/HBARPrice Impact=Final PriceInitial PriceInitial Price×100=0.0980.10.1×1002%\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 APRFees \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.
Fees APR=24h Volume ×(Fee×56)Liquidity×365\text{Fees APR} = \frac{{24h \text{ Volume } \times \left( \text{Fee} \times \frac{5}{6} \right)}}{{\text{Liquidity}}} \times 365
Where
.

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 APRReward \space APR
, calculated using the formula:
Reward APR=w×EHBAR×ESAUCEStaked Liquidity\text{Reward APR} = \frac{{w \times E_{\text{HBAR}} \times E_{\text{SAUCE}}}}{\text{Staked Liquidity}}
Where:
  • ww
    represents the Farm Weight.
  • EHBARE_\text{HBAR}
    represents the Annualized Emission Rate of HBAR ($/year).
  • ESAUCEE_\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.