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.
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.
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:
HBAR reserves: x โ= 10,000 HBAR USDC reserves: y = 1000 USDC k = x ร y = 10,000 HBAR ร 1,000 USDC = 10,000,000 โ
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 ร (1โ0.003) = 100 HBAR ร 0.997 = 99.7 HBAR
The new reserves, xโฒ and yโฒ, must satisfy the invariant, k:
(x + sโฒ)ร(y โ yโฒ) = k
Solving for yโฒ:
(10,000 + 99.7)ร(1000โyโฒ) = 10,000,000yโฒ = 1000โ10,099.7 / 10,000,000 โโ 9.9 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:
Initialย Price = y/x = 1000 USDC / 10,000 HBAR = 0.1 USDC/HBAR
Final Price = yโฒ/ (x + s) = 990.1 USDC / 10,100 HBAR โ 0.098 USDC/HBAR
Priceย Impactโ= (Final Price - Initial Price) / Initial Price x 100 = (0.098 - 0.1)/0.1 x 100 โ -2%
This trade results in a price impact of approximately -2%.
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ย 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 x (Fee x 5/6) / Liquidity ร 365
Where Fee = 0.30%.
Note: Totalย APR = Feesย APR + Rewardย APR, where Rewardย APR is sourced from yield farming.
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ย APR, calculated using the formula:
Rewardย APR = (w ร EHBAR โร ESAUCEโโ) / Stakedย Liquidity
Where:
w represents the Farm Weight.
EHBAR represents the Annualized Emission Rate of HBAR ($/year).
ESAUCEโ 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.