Synapse Protocol

Search…

Milestones & Governance

synapse API

Protocol Fees

How bridging and swap fees at Synapse Protocol work.

What is a Stableswap, exactly?

Let us assume we are already familiar with Uniswap AMM model: . This model is simple and effective, allowing the prices of the assets in the pool to track supply and demand. However, if we were to attempt a swap that was large relative to the liquidity contained in the pool, we would get rekt by slippage. Stableswaps are a mathematical improvement that optimize the model for assets that are intended to have prices that remain stable relative to one another. Because of this, stableswap pools can also contain more than two assets, unlike your traditional Uniswap AMM pool. Instead of the simple model, a special function is used to relate the prices of the assets contained in a stableswap to one another. This function is more complex, and can also have more than two parameters (as shown by a, b, c, etc.) but the exact formula is not necessary in order to discuss how this model affects the protocol's fee structure.

`x * y = k`

`x * y = k`

`F(a, b, c, ...)`

Let us do so by way of an example. Suppose the stableswap pool has three assets, **ACash**, **BCash**, **CCash**, with the respective balance of each token in the AMM pool represented by **A**, **B**, and **C**, such that . Let us say we want to swap **x **tokens of **ACash **to **CCash**. The Pool's new **ACash **balance is **A **+ **x**, so now we need to find **y**, the amount of **CCash **that we will receive. This is found by solving .

`F(A, B, C) = k`

`F(A + x, B, C - y) = k`

Now to calculate fees - if the swap fee is 0.04%, that means that 0.04% of **y** (or **CCash**, in this example) will be fees and **99.96%** **of y** will be sent to us as a result. We sent **x** tokens of **ACash**, received **99.96% * y** tokens of **CCash**, and **0.04% * y** tokens of **CCash **were paid as fees. Swap complete! Notice that *the stableswap fee is applied to received assets*. In addition, some percentage of this fee is generally reserved for the protocol as an *admin fee*. This fee can range from 0 to 100%, is applied only to the fee paid on the swap, and does not impact the user performing the swap. It does directly impact how much liquidity providers (LPs) earn from swaps in that pool. For instance, if the admin fee is 60%, the treasury will receive **0.04% * 0.6 * y**, and LPs will receive **0.04% * 0.4 * y **from this transaction.

Now that we understand the basics of a stableswap AMM, let us dive a bit deeper into how its LPs interact with its pools. When LPs deposit assets, they receive LP tokens in exchange for their deposit. When a stableswap pool is initialized, each LP token is worth ~1 token of **A**/**B**/**C**,** **on average. As swaps are performed using the liquidity in the pool, fees from those swaps accrue to the pool. This results in the LP tokens contained in that pool gaining value versus the assets which were deposited. This gain can be quantified by the "**virtual price**" of each LP token, which increases from a baseline value of 1 as more fees come in. For example, if the virtual price of an LP token is 1.01, that means 1 LP token is worth 1.01 **A**, **B**, or **C **token - in other words, a 1% return on initial deposits.

So what happens when we deposit assets into an existing stableswap pool? We can deposit a single asset, or a mix of the assets contained within. Because the pool needs to remain balanced to maintain , a deposit actually combines two actions behind the scenes. First, a "virtual swap" is made for us. Let us say we supply only one asset, **x **tokens of **ACash**. A virtual swap is made to make the proportion of your supplied assets equal to the ideal proportions of the pool. This means that some part of those **x ACash **tokens are swapped for **BCash**, and some for **CCash**. As a result the tokens you deposit go from [**x**, 0, 0] to [**d**, **e**, **f**] - **d **tokens of **ACash**, **e **tokens of **BCash**, and **f **tokens of **CCash**. The fee for the "virtual swap" associated with such a deposit is on average 50% of the usual swap fee, but will depend on the balance of assets in the pool at the time of deposit. Our swapped set of [**d**, **e**, **f**] tokens is now deposited into the pool, with no adverse effects on pool balance.
**Note: ***If we were to supply a perfectly balanced proportion of [***d***, ***e***, ***f***] in the first place then no swap would be made and no fees would be charged on deposit.*

`F(A, B, C) = k`

The same logic can be applied to withdrawals from the pool, in the reverse direction. Now the mix of [**d**, **e**, **f**] tokens is what we will receive, if we withdraw a combo of all three assets. If we want to withdraw only **ACash**, the **BCash** and **CCash** part of the basket is "virtually swapped" for **ACash**, to go from [**d**, **e**, **f**] to [**x**, 0, 0]. We will receive **x **tokens of **ACash**, and will have to pay fees on this "virtual swap" to do so since it results in the pool becoming unbalanced. The fee associated with withdrawal is also 50% of the usual swap fee, on average, but will again depend on the balance of assets in the pool at the time of deposit.
**Note: ***This means if we deposit a single asset in the pool and immediately withdraw liquidity as a different single asset, on average we will pay 50% + 50% = 100% of the usual swap fee. No free swaps!*

There are two types of Synapse nUSD pools. There is the "nexus" pool on Ethereum, and there are other nUSD pools on Aurora, Avalanche, BNB Chain, Boba, Fantom, Harmony and Polygon. The nexus pool is a basic stableswap pool of USDC, USDT, DAI. **The LP token for this pool is nUSD**, itself, and can be bridged to other chains: whenever a user bridges a stable from Ethereum to another chain, he deposit the stable into the nexus pool on Ethereum and a nUSD token is minted, on the chain he wants to bridge to. The nUSD pools on other chains include nUSD and the base stabkes on that chain: for example USDC.e, USDT.e and DAI.e on Avalanche.

Given that, what do a bridge transactions look like in terms of the pools and assets used? Let us look at some examples:

- 1.
**Bridging Avalanche USDC.e to BNB Chain BUSD**- 1.Avalanche USDC.e is swapped for Avalanche nUSD
- 2.Avalanche nUSD is bridged to BNB Chain nUSD (in practice, it is burn on Avalanche and minted back on BNB Chain)
- 3.BNB Chain nUSD is swapped for BNB Chain BUSD.

- 2.
**Bridging ETH USDT to Avalanche USDC.e**- 1.ETH USDT is supplied to the nexus pool in exchange for nUSD
- 2.ETH nUSD is bridged to Avalanche
- 3.Avalanche nUSD is swapped for Avalanche USDC.e.

- 3.
**Bridging Avalanche USDC.e to ETH USDC**- 1.Avalanche USDC.e is swapped for Avalanche nUSD
- 2.Avalanche nUSD is bridged to ETH nUSD
- 3.ETH USDT is withdrawn from the nexus pool.

Alright, prepare for some math. Let us divide all Synapse fees into these categories:

So, what are the costs for the following actions?

- 1.
**Bridging USDT from Ethereum to non-Ethereum chains**(or vice versa)- 1.ERC-20 USDT is supplied to the nexus pool ->
**0.5 * a**% - 2.nUSD is bridged from Ethereum ->
**b**% - 3.nUSD is swapped for USDT on that chain ->
**a**% Total = (**1.5a**+**b**)% charged in fees

- 2.
**Bridging USDT from non-Ethereum chains to non-Ethereum chains**- 1.Local USDT is swapped for nUSD ->
**a**% - 2.nUSD is bridged to other chain ->
**b**% - 3.nUSD is swapped for USDT ->
**a**% Total = (**2a + b**)% charged in fees

- 3.
**Swapping USDT for USDC on the same chain**- 1.USDT swapped for USDC ->
**a**% Total:**a**%

As you can see, the most expensive swap you can make is to swap between stables on non-Ethereum chains - this is because as the bridged asset **and** nUSD must be swapped twice when bridging between non-Ethereum chains but can swapped directly into stables when bridging from or to Ethereum.

Please note that these are **average** fees, assuming that the pool is balanced already or assuming that enough transactions are occurring that such imbalances even out over time. It is possible to get discounted fees or even get paid for swapping or bridging into assets that are over-supplied; conversely, it can be more expensive than average to swap into a specific asset on a different chain if it is under-supplied. Pay attention to the price impact monitor - it is your friend!

Last modified 2mo ago