Risk Assessment: Synthetix Atomic Swaps
A risk assessment of Synthetix atomic swaps for Curve veCRV holders and LPs
Abstract
Synthetix has gained much attention recently, owing to 1inch’s integration of its “atomic swaps” feature with Curve. Synthetix fee revenues have risen dramatically thanks to this relatively new feature, resulting in positive knock-on effects on Curve with increased volume to the sUSD and sETH/ETH pools. Here we explain the atomic swap mechanism with a particular focus on its usage with Curve and assess relevant risks veCRV holders and LPs.
A TL;DR for people looking for a quick summary:
The Synthetix protocol aims to facilitate no-slippage swaps of synthetic assets (“synths”). The counterparty for every trade are the “stakers,” who bear the risk from adverse selection.
The primary way of minting synths is to put up SNX collateral to mint sUSD, which is a stablecoin always assumed to be worth 1 USD in the protocol.
The minted debt is not tracked as an absolute quantity but through debt shares, which enable the calculation of the staker's percentage of the total outstanding debt ("debt pool").
As synths are swapped with zero slippage for other synths, e.g., sETH or sBTC, the composition of the debt pool changes, exposing stakers to different market risks. The protocol takes swap fees.
To unstake, a staker must pay back his sUSD-denominated debt, which may have changed from the initial debt balance since it is tracked as a proportion of the debt pool.
A staker can utilize the minted sUSD to hedge his short exposure to the debt pool or as part of an overall strategy. Common hedging techniques include mirroring debt pool composition or using the dhedge mirror token.
Stakers are compensated for their risk by receiving a portion of trading fees and SNX inflationary rewards.
If SNX price drops or the sUSD prices of synths increase, this affects the staker's collateralization ratio (C-Ratio).
Governance monitors overall market conditions and maintains up-to-date parameters to give the system sufficient liquidity while protecting against insolvency. Key parameters are the target and liquidation C-Ratios, currently 400% and 150%, respectively. Financial incentives and the liquidation mechanism encourage stakers to keep their C-Ratios not too far below 400%.
Stakers must maintain a C-Ratio of at least 150% to avoid being flagged for liquidation and have a C-Ratio of at least 400% to claim incentives weekly.
Since incentives are based on the debt amount, a staker seeking to make full use of their SNX collateral should keep their C-Ratio a healthy buffer above 150% while increasing to 400% to claim weekly.
Since the protocol’s inception, the reliance on an off-chain oracle created a frontrunning risk allowing arbitrageurs to profit at the expense of stakers. A series of fixes have addressed this issue, culminating in the fee reclamation workflow, which requires a secondary transaction to settle a trade.
“Atomic Swaps” enable Synthetix to fully integrate with DEXes such as Curve by removing the need for a secondary transaction while maintaining adequate safeguards. Direct integration with Curve (SIP-268) allows further efficiencies.
Synth pricing for atomic swaps is determined through a combination of on-chain (Uniswap V3) and off-chain (Chainlink) oracles to protect against frontrunning and price manipulation.
The biggest risk to the protocol is stakers being unable to manage their risk. This can happen during both market turmoil and clear directionality. Rapid changes to the debt pool leave stakers unhedged, increasing the likelihood of protocol insolvency.
Synthetix works with Gauntlet to simulate worst-case scenarios and identify necessary structural or parameter changes. Since the protocol is also sensitive to parameter changes in adjacent protocols such as Curve, both Synthetix and Curve should benefit by maintaining open lines of communication when making changes.
There is an audit for most upgrades and every recent release; however, these generally are limited in scope to the changes and rely upon a deep understanding of the prior code. The protocol would benefit from a thorough system audit from an audit company other than their regular auditor, Iosiro.
Useful links
Synthetix Protocol
Overview
The Synthetix protocol aims to facilitate no-slippage swaps of synthetic assets. Prices of the synthetics ("synths") are determined by a combination of on-chain and off-chain oracles with the value of the synths backed by collateral. Synths are created by staking SNX tokens, the governance token of the protocol, and taking out debt against the staked tokens. The debt is combined into one "debt pool," and each staker must actively manage their short exposure to the debt pool. Stakers receive compensation in the form of trading fees and SNX rewards.
Synthetix development is fast-moving with rapid iteration based on feedback from a strong community. See the upcoming Synthetix 2022 Release Milestones for details on v3, which makes significant changes to the protocol that may alter our risk considerations.
Synths & Staking
The primary synth is sUSD, a stablecoin always assumed to be worth 1 USD on the protocol. Each staker puts up SNX collateral and can create a corresponding amount of sUSD allowed by the target collateralization ratio (C-Ratio). This minting process is the primary way new synths are introduced into the system.
The minted sUSD is considered debt, and the staker is issued debt shares to enable the calculation of the staker's percentage of the total outstanding debt. The sUSD can then be exchanged for other synths (e.g., sBTC) or other stablecoins e.g., USDC. Swaps between synths can be done through the protocol at zero slippage with a transaction fee.
When a synth swap occurs, the synth being sold is burned, and the synth being purchased is minted. The exchange rate is determined according to prices defined by the respective oracles. As synths are swapped, the composition of the debt pool changes, thus exposing stakers to different market risks.
To unstake collateral, a staker must pay back all outstanding debt, which is denominated in sUSD. Because this is computed as a percentage of total outstanding debt in the system, it may be considerably different from the initial debt balance.
Two other ways of minting synths are less commonly used but play a role in improving synth liquidity and managing debt pool exposure:
the multi-collateral loan system (SIP-97): allows minting synth equivalents using ETH or ERC20 collateral. Borrowers have a fixed debt, do not get incentives, and pay borrowing fees that go to stakers. Minted synths are added to the debt pool.
wrappers (SIP-112, SIP-182): allows a 1-1 exchange of an asset to synth equivalent. Debt is added to the debt pool as the difference of minted synth and underlying, making the pool short the underlying (hence giving stakers long exposure to the underlying).
It is interesting to see that volumes are going up and the number of unique traders has stayed stagnant, implying a small group, such as arbitrageurs, do the majority of the volume: https://dune.com/drethereum/Synthetix-Futures:-Overview.
Debt Pool
The Synthetix Debt Pool can be viewed here and on the official Synthetix dashboard.
As participants of the protocol take profits, the collateral could become insufficient to back the outstanding debt. For example, if the prices of synths increase relative to sUSD, the supply of sUSD would increase as profit is taken in sUSD without a corresponding increase in collateral. Thus the debt pool must consider the price fluctuation of all outstanding debt.
This is achieved by calculating a staker's debt as a percentage of the total debt when sUSD is minted. As the value of total outstanding debt fluctuates, a staker's portion of that debt changes accordingly.
For example, suppose the debt pool is split 50:50 between sUSD and sBTC, and the underlying price of BTC doubles. The staker's total debt has increased by 50%. Stakers must, therefore, vigilantly monitor the collateralization ratio not to be liquidated.
This means that when staking SNX, the staker creates a debt obligation that allows traders to change the form of the debt to their advantage. As this is the same as effectively writing an option, i.e., "shorting gamma," it is wise to "delta-hedge" the position.
Commonly this is done by holding a portfolio that mirrors the composition of the debt pool and updating it periodically as the debt pool changes. The fees and rewards earned from staking serve to compensate the staker for the costs of maintaining the hedge position.
Note that the staker may also need to partially liquidate this hedging portfolio as required to maintain the minimum collateralization ratio and avoid liquidation.
Collateralization Ratios
The current target collateralization ratio (C-Ratio) on Synthetix is 400%. This means that when staking or minting, the ratio of staked SNX to minted debt cannot fall below 4. The system is designed to incentivize stakers to maintain their C-Ratios near this level to maintain solvency while providing sufficient liquidity.
The C-Ratio is maintained through a combination of financial incentives and the liquidation mechanism.
Financial Incentives
The financial incentives consist of fees from swaps and inflationary rewards. Stakers are issued these incentives based on their overall contribution to the debt pool. This means they should seek to maintain their C-Ratio at or below the target C-Ratio of 400% to receive the maximum rewards. Stakers must claim their earned fees and rewards weekly and have a C-Ratio of at least 400% when claiming. Unclaimed fees and rewards are returned to their respective pools for distribution during the next week.
SNX is distributed through inflationary rewards. The current target staking ratio is 65%, meaning if the percentage of staked SNX is between 60-70%, weekly inflation is reduced by 2.5%. It is reduced or increased by 5% depending on whether the staked percentage is greater or less than the target window.
Liquidation Mechanism
The solvency of the Synthetix protocol is ultimately backstopped by its liquidation mechanism (SIP-148).
Once a staker's C-Ratio falls below 150%, the staked SNX is flagged for liquidation. If the C-Ratio is not restored to at least 400% within 12 hours, the outstanding debt is settled by transferring it to stakers with healthy C-Ratios, who receive the backing SNX with a penalty fee (30% of the total). The liquidated staker keeps any remaining SNX.
The liquidated SNX collected in this way contributes to staker C-Ratio but is not immediately available. It is stored in escrow and distributed after 12 months to stakers based on the proportion of debt held. This incentivizes stakers to maintain C-Ratios during crises.
A staker flagged for liquidation has the option to self-liquidate, incurring a lower penalty of 20%. This incentivizes earlier liquidations during crises to avoid a sudden spike. Sudden sell-offs exert significant downward pricing pressure and can lead to a “death spiral.”
The Evolution of Synthetix Swaps on Layer 1
Since the early days, it has been noted that the reliance on off-chain oracle creates a risk of frontrunning by opportunists.
Arbitrageurs can monitor the mempool for upcoming price updates. For example, if an upward revision in the price is detected, it is possible to quickly purchase the synth (“buy low”) and then reverse the swap (“sell high”) after the update is fully processed. This arbitrage profit comes at the expense of both stakers and users; stakers take on additional risk due to the increase in debt, while users may suffer from less liquidity as stakers burn sUSD to maintain their C-Ratios.
A series of fixes have been deployed to address this issue, culminating in the current hybrid of SIP-37 (fee reclamation) and SIP-120 (atomic exchange).
(See here for an overview of all SIPs)
The key SIPs leading up to fee reclamation are:
Oracle pausing (SIP-7): Before executing a price update, the oracle submits a transaction that puts a hold on all swaps and only releases the hold when the update has propagated fully.
Gas price limit (SIP-12): The freeze on swap transactions during oracle updates quickly became a major pain point for users. SIP-12 introduced a gas oracle to limit gas prices for trades. Since oracle updates purposefully used a significantly higher gas price, it was extremely likely they would be mined prior to any trades attempting to front-run.
Chainlink migration (SIP-32, SIP-36): While the migration was done primarily to further decentralization, moving to Chainlink changed the attack surface considerably for frontrunners. However, SIP-12 remained in place due to Chainlink's 1% deviation threshold and semi-daily heartbeat.
Fee Reclamation and Rebates
SIP-12 helped to address the issue of front-running but created other issues in its place. As oracle updates don’t occur every block, some users experienced frequent failures from fluctuations in the max gas limits.
SIP-37 was created in January 2020 and introduced fee reclamations and rebates. The aim was to penalize frontrunning by deducting a fee if an oracle update led to a profit and issuing a rebate if the update led to a loss. This entailed a waiting period to assess if a fee or rebate was due. Only after this period was over could the traded synth be deemed "settled," i.e., available for trading.
This settlement period broke composability, i.e., the ability to interact in a single transaction with other DeFi protocols, and has been extended several times. The current waiting period is 6 minutes.
Curve Cross-Asset Swaps
The settlement period for fee reclamation poses a problem when integrating Synthetix as one leg of a swap strategy involving other DEXes.
This led to the proposal for "virtual synths," or tokenized claims to the proceeds of unsettled Synthetix trades. Virtual synths allowed Curve to facilitate swaps between unlike assets instead of pegged assets only (although a secondary transaction after the swap would be required to complete the trade).
Ultimately, however, Curve chose to create its own system of "cross-asset swaps" on January 17, 2021. This new mechanism enabled users to swap a vanilla token for its synth equivalent via Curve and then use Synthetix to swap it for a different synth.
The implementation bypassed the reclamation waiting period problem by issuing an NFT for the unsettled synth. The user could make a secondary transaction using the NFT to settle the initial transaction and either withdraw the received synth or perform another swap via Curve. The total costs for the procedure would be slippage and transaction fees on Curve and a 0.38% fee paid to Synthetix.
Not long after this, however, Synthetix proposed its new Atomic Swap feature in February 2021. The implementation was released in November 2021, taking advantage of the release of Uniswap V3 in the meantime.
Atomic Swaps
Atomic Swaps enable Synthetix to fully integrate with DEXes such as Curve. By offering an instant settlement of trades, an ETH to USDC swap can be routed as follows:
ETH (1)----> sETH (2)----> sUSD (3)----> USDC
Legs 1 and 3 are done through Curve, while leg 2 with zero slippage is done through Synthetix. Here is a good tweetstorm with how the Synthetix atomic swaps became a reality:
The key concept behind this innovation is that while on-chain pricing is vulnerable to flash loan attacks and off-chain pricing is vulnerable to frontrunning, a combination of both methods (off and on-chain) can make arbitrage difficult and expensive.
At a high level, the methodology is analogous to a traditional market-maker quoting wider spreads as the market becomes more volatile.
In determining the price, Synthetix uses the least favorable of four values:
Chainlink
: Chainlink price oracleUniTwap
: Uniswap V3 time-weighted average price (TWAP)UniSpot
: Uniswap V3 spot price from the previous blockUniLive
: Uniswap V3 spot price from current block (added in SIP-264)
This pricing approach is designed to mitigate manipulation and be robust against extreme market conditions.
The Chainlink
value mitigates on-chain price manipulation via flash loan and sandwich attacks. The Uniswap values mitigate oracle frontrunning by using a combination of the latest on-chain pricing from Uniswap pools. Each Uniswap value has its strengths and weaknesses, necessitating the use of all values.
While it is in theory possible to manipulate the UniSpot
value with a large trade, the attacker is thereby exposed to adverse price movements during the holding period before the next block is mined. Similarly, attempting to affect the UniTwap
value results in continued exposure to risk over a period of multiple blocks.
The UniLive
value was added in SIP-264 to combat latency arbitrages, i.e., trades that frontran Uniswap arbitrages.
Significant deviations between Chainlink and DEX pricing are expected to occur during times of high market volatility and volume. In such periods, the atomic exchange function complements the existing reclamation flow. If atomic swap pricing lags the unbuffered Chainlink value, fee reclamation will enable superior trade execution.
Conversely, when atomic swap pricing results in a better outcome than the Chainlink price, traders can take advantage of this with a fee reclamation swap and arbitrage the difference.
When there is clear market directionality, CEXes tend to outrun DEXes, thus exposing the debt pool to frontrunning risk. Synthetix tested various scenarios and implemented the following safeguards for atomic exchanges in such conditions:
Additional transaction fees (which effectively neutralizes most frontrunning strategies)
A volatility circuit breaker to automatically disable/enable atomic exchange between specific assets when the number of oracle updates exceeds the configured threshold
The requirement to use sUSD as a source or destination synth, as requiring multiple reads from Chainlink, increases the potential for oracle abuse.
To decrease risk, the atomic swap assets, volume limits, and pricing-related parameter tweaks began at conservative levels and were gradually eased in.
SIP-198 was created in December 2021 and updated atomic swaps by:
Using only the Chainlink price for certain synths (“pure Chainlink price”)
No further requirement for sUSD as a source/destination currency
Removing the buffer parameter for Chainlink prices
See SIP-264 for clarifications of the pricing methodology.
Security audits
https://docs.synthetix.io/contracts/audits/ (old audits, up to Feb '21)
https://docs.synthetix.io/releases/ (see audit attached to each release)
The following links contain audits for the various improvement proposals discussed above:
SIP-37: https://www.iosiro.com/audits/synthetix-sip37-smart-contract-audit
SIP-120: https://iosiro.com/audits/synthetix-alkaid-release-smart-contract-audit
SIP-37: https://www.iosiro.com/audits/synthetix-sip37-smart-contract-audit
Synthetix has submitted to multiple audits, both separately for each SIP and subsequent releases. Many of these audits were performed by the firm Iosiro (0 mentions on the REKT Leader board).
While the audits provide a thorough review of the smart contract code, they do not appear to address economic or systemic risks in any depth. SIP-120, for example, works in tandem with SIP-37 and its updates to protect Synthetix as a whole. However, there is no analysis of the interaction between Atomic Exchange and Fee Reclamation mechanisms. Only the contracts new to SIP-120 have been assessed.
It would be good to get an audit of core components from other audit companies than Iosiro since the Synthetix codebase is not formally verified. There is currently an active Synthetix bug bounty program of 100K paid out in SNX or sUSD on Immunefi.
Risks to Curve
Synth depeg
As with any pegged asset, a synth can lose its peg putting liquidity providers at risk. The lynchpin of the Synthetix protocol is sUSD, whose depeg would cause all other synths to depeg. Ultimately sUSD derives its value from being backed by sufficient SNX collateral.
"Wrappers" (SIP-112, SIP-182) enable the 1:1 minting of synths from their equivalents, e.g., sETH from ETH. Their original purpose was to help keep synths from going above peg due to greater demand than supply; however, in times of market turmoil, such as the UST depeg, the supply of wrapped collateral has acted as reserves protecting against depeg.
Using its native governance token as collateral makes the protocol susceptible to a “death spiral,” a reflexive phenomenon where perceived instability can create even greater instability. Rumors of protocol insolvency, perhaps sparked by inadequate hedging by a majority of stakers, can cause non-staking SNX holders to dump, causing lowered C-Ratios for stakers. If this reaches the point of mass liquidations, this will fuel more panic and dumping, causing a cascade of further liquidations.
An off-chain circuit breaker mechanism exists to handle such a situation (see SIP-55 and SIP-231), but while it may protect Synthetix, plausibly, any extended downtime during market turmoil would cause a depeg, harming Curve LPs.
Curve pools impacting Synthetix
Due to the symbiotic nature of the Synthetix protocol, there is a feedback loop where improper or suboptimal functioning of Curve synth pools can lead to mismanaged risk by Synthetix stakers, causing a reflexive downward spiral, as discussed in the previous section.
Synthetix creates value by acting as an OTC protocol where stakers are the counterparties to each trade, i.e., a price is agreed upon plus a fee, and the trade is executed at that price regardless of market impact or market conditions in general. As in a traditional OTC trade, the "broker-dealer" (stakers) then takes on the cost and risk of hedging any exposure.
The primary beneficiaries of this structure are widely recognized to be arbitrageurs who are able to capitalize on the plentiful liquidity provided by Synthetix.
Hedging debt pool exposure is nontrivial, and the protocol claims to be properly incentivizing stakers for this. This is unclear to us as we were unable to source the relevant historical data. It may be that "mostly adequate" risk management is what is being priced in by incentives, and tail risks are not accounted for. For example, many stakers use solutions such as dhedge's debt mirror token, which provide approximate hedges by periodic rebalancing. These solutions do not provide full protection under extreme scenarios.
If Curve synth pools were to change suddenly in a manner that significantly altered the volume or direction of trades going through Synthetix, this would cause a corresponding change in debt pool composition, leading to unanticipated hedging costs and increasing overall risk.
Conclusions
Arbitraging being the predominant use-case of atomic swaps makes volume very sensitive to tweaks in parameters. When the parameters are not optimal for arbitrageurs, volume can drop off precipitously.
Stakers, as the counterparty to trades, hold greater risk when arb flow is large and uni-directional. They need to hedge the corresponding change in the debt pool; the less active their hedging strategy is, the more likely they will be unhedged.
The “right” ecosystem parameters, such as Curve synth pool settings, can help slow one-sided flow by encouraging arbs in the other direction. When Curve synth pools depeg, for example, this encourages arbitrageurs to re-peg the pools, driving Synthetix volume the other way. From this viewpoint, slippage is a good thing, acting as a natural brake on the protocol. SIP-268 acknowledges this by proposing a direct Curve integration with lower Synthetix fees to offset slippage costs. The aim of the integration is to have aggregators route volume through Curve pools to create the braking effect.
Given the symbiosis between Synthetix and adjacent protocols, such as Curve, we recommend continued cooperation between protocols, especially for simulations and worst-case scenario analyses of parameter changes.
Synthetix has played an important role in the DeFi revolution, and the Synthetix-Curve relationship has been crucial since the beginning. We think with proper risk management Synthetix will continue this role as an essential building block and produce tangible benefits for Curve stakeholders.