An In-Depth Analysis of SynthSwap

Synthswap
8 min readJan 11, 2021

SynthSwap is a set of synthetic protocols on the Ethereum network allowing users to trade cryptocurrencies with margin and trade stable coins against assets such as AAPL and TSLA on the stock market. The assets supported by the exchange are dependent on the community, and can be easily added in a process that will be described further into this article.

SYNTH is the native token of the SynthSwap ecosystem, it represents a share of the liquidity pool, and can be used to vote on different parameters of the protocol. SYNTH holders are entitled to liquidations of traders suffered on the exchange, as well as a share of the SynthSwap liquidity pool that backs all trades made.

When a user opens a trade, funds are sent to the SynthSwap liquidity pool (also known as the treasury). This pool holds all deposits of traders, and the assets bought by governance. Deposits are distinguished from funds available for use by governance.

There are six key contracts that play a key role in the ecosystem, and the source code will be released around the same time as beta. These contracts consist of:

  • Assets
  • Governance
  • Treasury
  • Oracle
  • Trading
  • Queue

These contracts and their individual functions will be described below, so investors have a better idea of how the trust-less synthetic trading protocol of SynthSwap will work.

Assets Contract

This contract is used to keep track of assets available for trade on the decentralized exchange. Once new assets are added through governance proposals, this solidity contract can be used to manage the maximum leverage supported on the specific asset, spread, and other factors like the funding rate which can be fit accordingly to needs.

Every addition of an asset will have to go through a governance proposal that is voted on and confirmed by the community. If changes need to be made to the contract, it can be upgraded by anyone through the executeProposal method of the Governance contact.

Initially supported assets for trade on beta will be BTC, ETH, TSLA, and AAPL, afterwards new additions can be made by the community as they please.

Proposals are written in JSON format, cryptocurrencies can easily be submitted via their symbol (i.e. BTC), and assets like AAPL will have to be added via their OpenFigi ID (i.e. BBG000B9XRY4).

The Financial Instrument Global Identifier is an open standard, unique identifier of financial instruments that can be assigned to instruments including common stock, options, derivatives, futures, corporate and government bonds, municipals, currencies, and mortgage products. Any of the previously listed categories of assets can be added for support on the decentralized exchange, if approved by governance.

Governance Contract

Arguably one of the most important aspects of the protocol is the governance contact of SynthSwap. This contract is used for a multitude of possibilities, essentially having outright control over the entire ecosystem. The governance contract receives staked tokens for voting along with proposals that are submitted by the community.

Once proposals are voted on and the default consensus period is over, anyone can execute the proposal via the executeProposal method on etherscan.

Proposals can make up of up to 10 transactions in code, with a discover-ability period of 40320 blocks (about a week). This gives SYNTH holders enough time to think about a vote on a proposal before an ultimatum is made too early or without enough input. Voters will be required to stake SYNTH to vote on the proposal, and these tokens are locked until the voting period ends.

If a proposal reaches 4% of the total supply of SYNTH and support for the proposal is stronger than opposing votes, the proposal can then be executed immediately after the voting period is over.

These proposals can be written manually using the Governance contract’s ABI, or users can use the hardhat examples provided in our repository (coming soon) to submit proposals. In the near future, we hope to release a governance dashboard to make this process a lot easier for everyone who wants to use it.

JSON Proposal Format:

{
"title": "proposal title",
"description": "proposal description",
"discoverabilityPeriod": "1",
"transactions": [
{
"type": "method",
"contract": "0x1111111111111111111111111111111111111111",
"method": "methodName",
"params": [
{ "name": "name", "type": "address", "value": "0x2222222222222222222222222222222222222222"}
]
}
]
}

These files can also be written in JavaScript, making it easier to relay certain values to the proposal.

JavaScript Proposal Format:

module.exports = {
title: 'proposal title',
description: 'proposal description',
discoverabilityPeriod: '1',
transactions: [
{
type: 'method',
contract: '0x1111111111111111111111111111111111111111',
method: 'methodName',
params: [
{ name: 'name', type: 'address', value: '0x2222222222222222222222222222222222222222'}
]
}
]
}

Example Register Assets Proposal Format:

// this proposal allows registering new products for tradingconst ethers = require('ethers');
const toBytes32 = (symbol) => ethers.utils.formatBytes32String(symbol).padEnd(66, '0')
const to8Decimals = (value) => ethers.utils.parseUnits(`${value}`, 8).toString();
module.exports = {
title: 'Register BTC, AAPL',
description: 'reasons: X, Y, Z...',
discoverabilityPeriod: '1',
transactions: [
{
type: 'method',
contract: process.env.PRODUCTS_CONTRACT_ADDRESS,
method: 'register',
params: [
{
name: 'symbols',
type: 'bytes32[]',
value: [
'BTC', // for crypto, you can directly use the symbol
'BBG000B9XRY4' // for non-crypto, use openfigi e.g. AAPL's FIGI symbol https://www.openfigi.com/id/BBG000B9XRY4
].map(toBytes32) // converts values to bytes32
},
{
name: 'maxLeverages',
type: 'uint256[]',
value: [
'100', // max leverage 100 for BTC
'20' // max leverage 20 for AAPL
].map(to8Decimals) // converts values to 8 decimals
},
{
// values are in basis points. 1 UNIT = 100%
name: 'spreads',
type: 'uint256[]',
value: [
'0.001',
'0.001'
].map(to8Decimals) // converts values to 8 decimals
},
{
// values are in basis points (per block). 1 UNIT = 100%. 5760 blocks in a day for 15s blocks
name: 'fundingRates',
type: 'uint256[]',
value: [
'2',
'2'
]
}
]
}
]
}

Users who wish to submit a proposal will have to stake at least 10 SYNTH tokens to be eligible to do so. Using hardhat, you can view proposals and their specific ID’s while voting.

SynthSwap is inherently decentralized, so it is up to the community to propose things that are in their best interest. Once released, the code can only be changed via a governance proposal that passes through a vote from holders of the token. Everything including how fees are managed, to the funds of different pools, to the status of trading, to who can trade on the exchange, and which assets are supported for trade is up to the community and token holders.

Treasury Contract

The treasury smart contract holds all assets of traders and governance in the system. This is backed by a large liquidity of stable coins managed on CURV behind the scenes, with a hot pool and cold pool to separate important functionalities of the protocol.

Hot Pool — used for withdraws and deposits of users, as well as pay outs to liquidity providers

Cold Pool — holds excess funds obtained by the liquidity pool, buys back SYNTH and burns it, controlled by a multi signature contract

Funds in the treasury available to governance are separate from assets deposited by users on the exchange.

Oracle Contract

SynthSwap utilizes access to a dark feed oracle price network. Traders submit orders which are then priced by this oracle network after being managed by the Queue.

Initially supported assets for trade on the ecosystem should consist of only highly liquid assets, to prevent the oracle network from being at risk of price manipulation on certain undesirable assets.

Synthetic trades on SynthSwap are settled instantly, and do not require a transaction to be confirmed, avoiding any potential front runners on the exchange.

The oracle is responsible for providing high quality price feeds to the contracts used for trading on the decentralized exchange.

Trading Contract

The trading smart contract receives incoming orders from users on the exchange. These may range from new positions, to additions of margin, to closing positions.

This is where real transactions are conducted behind the scenes, once a trade is submitted it is directed to the oracle network, where the queue then grabs the price provided by the oracle and sends it back to the trading contract for execution.

The first time submitting a trade involves inputting several parameters so the protocol knows what to do (on the back-end).

Trading.submitOrder(true, bytes32('BTC'), 500 * 10^8, 20 * 10^8);

These parameters consist of:

  • bool isBuy
  • bytes32 symbol
  • unit256 margin
  • unit256 leverage

Once a user wishes to adjust a trade, they will be able to make another transaction to close or add to their position.

Trading.submitOrderUpdate(1, 200 * 10^8);
  • unit256 positionID
  • unit256 margin

NOTE: These processes described above are done fully in the back end and can only be done on a hardhat environment. The team will provide dashboards for submitting proposals with ease later, and the exchanges user interface is as simple as making a few clicks.

Queue Contract

As described previously, the purpose of the queue contract is to receive and relay a specific price from the oracle feed network and send them to the trading contract to finalize trades.

The queue is updated every 30 seconds, sending orders back to the trading contract to be executed once received.

Conclusion

SynthSwap is comparable to something like Robinhood on the app store. Our goal is to provide universal access across thousands of markets in a decentralized and community governed manner. Users can trade the markets supported with their favorite cryptocurrencies by depositing funds into the liquidity pool. The SYNTH token represents a share in this pool, serving as both a liquidity provider token and governance token. Traders who are using the platform are generating revenue for the protocol, with the funds being sent to the SynthSwap liquidity pool, that is is represented by shares in the SYNTH token.

Rather than succumb to strict regulations from authorities in such a complex protocol, SynthSwap was built particularly on IPFS with decentralization and incorruptibility in mind. There are no owners of SynthSwap but the token holders themselves.

When investing in SynthSwap you are investing in a fund and the success of the protocol.

All of the markets across the exchange are backed by a single pool. Users who wish to trade the markets supported by SynthSwap can send DAI to the liquidity pool and receive SYNTH that tracks the individuals share in the pool. When you buy shares in the pool (the SYNTH token), you are exposed to revenue generated by SynthSwap.

For example: Let’s assume the total supply of SYNTH is 1,000, and I purchase 10% of the supply, or 100 tokens with $10, while there is $100 total in the pool. After more traders use the protocol, the amount in the pool is now worth $110, and I can now redeem my 10% share of SYNTH for $11, that I originally bought for $10.

This means that holders of the SYNTH token receive ALL liquidations or losses of traders suffered on the exchange in an amount proportional to their holdings of the pool.

More advanced users who wish to maximize earnings from the options offered by SynthSwap can stake their SYNTH tokens to lend out their tokens to borrowers (margin traders). Profits can then be accumulated from spread, interest, AND trader losses on the protocol. This yield can be calculated as shown in the formula below:

y = (a x b) + c + d
  • y = yield
  • a = spread
  • b = volume
  • c = interest
  • d = trader losses

Combined, the economically drafted concepts of the SynthSwap exchange help to facilitate an immutable protocol immune to potential censorship from authorities with universal market access.

It is imperative that the community is aware of what is in the best interest of the protocol, in addition to how exactly it functions throughout these next few years. The team is excited to join you all on this journey! We will have some exciting things to announce for you soon!

WEBSITE: COMING VERY SOON

GITHUB: COMING VERY SOON

TELEGRAM: https://t.me/SynthSwap

TWITTER: https://twitter.com/SynthSwap

--

--

Synthswap

A decentralized protocol for synthetics and trading with margin on the Ethereum network, backed by the SYNTH token.