How to Use the Privacy-Preserving AMM SecretSwap (Guide)

Secret Network
10 min readApr 6, 2022

SecretSwap is the first privacy-preserving AMM (Automated Market Maker) to be launched on Secret Network and offers 100% protection from front-running and MEV bots. This guide walks through everything you need to know to successfully use SecretSwap, including:

  • Connecting your wallet
  • Swapping tokens
  • Staking secret tokens
  • liquidity providing (LP)
  • withdrawing liquidity

SecretSwap is the first AMM (Automated Market Maker) to be launched on Secret Network and a one-of-a-kind product for the blockchain space, since it is 100% front-running and MEV protected. This is achieved because smart contracts on Secret Network have encrypted inputs, outputs, and state. As such, miners are not able to front-run any orders submitted to the AMM. This is a critical piece of Secret DeFi, unlocking new liquidity for various Ethereum, BSC and Cosmos ecosystem assets on Secret Network!

SecretSwap allows users to trade any secret token for any other. It works like Uniswap or SushiSwap, but with lower costs and higher user security.

Tokens that users buy on SecretSwap can be transferred with privacy on Secret Network, used in other Secret Apps, or sent over bridges back to native chains (including Ethereum).

Like other AMMs, SecretSwap also allows users to provide liquidity on specific pairs while earning high yields paid in SEFI.

SEFI is the governance token for SecretSwap built on top of the Secret Network SNIP-20 standard which means that every SEFI transaction(including governance voting) is private by default.

View and interact with the SecretSwap : https://secretswap.net

Learn more about Secret Network: https://scrt.network

Purpose?

This guide is intended to educate users on how to trade secret tokens on SecretSwap, withdraw rewards, bridge tokens in & out of Secret Network and liquidity provide while taking advantage of the high yields after having understood all the risks involved with it.

Pre-requisites?

  • Install Keplr wallet, an open-source browser extension wallet for the Cosmos interchain ecosystem by following this guide
  • Own some SCRT to be used as gas fees (1 SCRT should be more than enough)
  • Own Secret Tokens (sSCRT, sETH/ERC-20s, sBNB/BEP20s, sXMR, SHD etc.) by swapping on SecretSwap, wrapping them here or migrating them across Secret Bridges( follow [this guide] to learn how to use bridges)

Connecting Your Wallet

In order to interact with the platform you first need to connect your Keplr wallet in two simple steps:

  1. Navigate to the SecretSwap application at https://app.secretswap.net
  2. Connect your Keplr wallet to allow SecretSwap to access the secret tokens in your wallet accounts

Making a Swap

You can exchange Secret Tokens by making a swap on the SecretSwap interface following these six simple steps:

  1. Navigate to the Swap tab using the banner menu.
  2. Select the Secret Token pairing that you would like to swap. (NOTE: If you don’t already own a secret token, you can wrap it at wrap.scrt.network)

3. Input the amount of Secret Token you would like to trade. Use the double sided arrows to flip between the two Secret Tokens (The top token is the one you are selling and the bottom token is the one you are exchanging for)

4. Since Secret Tokens are private by default, users will require a viewing key to see their token’s balance. If you are trading for a new Secret Token that you have not previously owned and you don’t have the viewing key for it then you will have to unlock it.

Click View Balance next to the 🔍 icon on the swap menu. (NOTE: you might need to refresh the page or delete browser cookies if you see the “wrong viewing key”).

Regenerating the viewing key (resubmitting the transaction) will remove the previous one, find more about viewing keys and permits at [viewing keys vs permits article])

5. Once you have confirmed the Secret Token amount you want to trade and the price ratio, click Swap.

Due to slippage there could be a minor difference between the expected trade ratio and the actual price at which the trade is executed. Generally, pairs with more liquidity are less affected by this problem(you can check the underlying liquidity of specific pairs at secretanalytics.xyz)

Sometimes there is no pool for the 2 assets you are swapping and Secretswap will therefore Route your swap through a different pool. In general more routing steps will increase the fee and slippage you have, playing around with the amount you are swapping might change the routing.

6. You have now successfully traded on SecretSwap. You can view your secret token balance on the Secret network tab of your Keplr extension wallet

Stake Secret Tokens:

In SecretSwap you can earn generous staking rewards on your SEFI(SecretSwap’s governance token) and ALTER(NOTE: you can buy SEFI and ALTER directly from the Swap tab).

Staking yields come from the protocol’s revenue generated from fees and from the treasury which distributes 90% of the total SEFI supply(more details here).

In some staking pools you can find a multiplier indication which represents the proportion of SEFI rewards each pool gets from the total supply every time a block is produced(NOTE: this multiplier is already included in the % APR calculation).

To stake your tokens follow these four easy steps:

  1. Navigate to the Earn tab using the banner menu
  2. Click on the token that you would like to stake. (NOTE: the infinity pool let’s you earn multiple tokens just by staking SEFI)

4. Enter the amount of tokens you would like to stake in the left box and click Earn

4. You have now successfully staked your tokens on SecretSwap. You can view your staked balance with a viewing key by clicking View Balance next to the 🔍 icon on the staking menu.

If you then want to unstake some tokens or claim the rewards you can do so by clicking the respective buttons(NOTE: every time you deposit, withdraw or claim the contract will automatically claim your rewards for you). This will execute a transaction on the blockchain which will require some SCRT for gas. The contract interaction will be visible on a block explorer like Secretnodes)

Provide Liquidity for Secret Tokens:

The liquidity available on SecretSwap comes from the so-called liquidity providers. A liquidity provider earns a percentage of the swap fees on a respective pool and a part of the SEFI protocol inflation rewards.

To provide liquidity users have to choose a specific trading pair and exchange an equal amount of the two tokens for a LP token which they can trade, stake or convert back into a 50:50 amount of the two tokens provided at any time.

However before moving on to try it yourself it’s really important that you understand the risks involved with providing liquidity.

The biggest risk to factor in is Impermanent Loss(IL) which is caused by the price fluctuation of the two assets that make up your pair(i.e. SEFI / sETH). Because of the nature of AMMs your LP token will always represent an equal 50:50 dollar amount of the respective provided tokens. When you withdraw your liquidity you wont receive the same amount of tokens back, unless both assets increased or decreased just as much in value. You can record how much of each token you put in the pool to track your impermanent loss (you can find this information using cryptoclerk.xyz)

Once you’re ready follow these steps:

  1. Navigate to the Pool tab using the banner menu on the top
  2. Select the two Secret Tokens that you would like to provide liquidity for. (NOTE: Not all Secret Token pools have high liquidity, which may increase your risk exposure for impermanent loss. You can view pools with higher liquidity at secretanalytics.xyz.)

3. Input the amount of each Secret Token you would like to provide. The Secret Token balances will automatically adjust the amounts to an even 50:50 split between the pair, based on the most current ratio for the Liquidity Pool.

4. Once you have confirmed that the Secret Token amounts you want to provide for each side of the liquidity pair, click Approve for each Secret Token (NOTE: this action is only required once per token meaning you never have to approve again when adding more to this pool). This will execute a transaction on the blockchain which will require some SCRT for gas. The contract interaction will be visible on a block explorer like Secretnodes)

5. Click Provide to confirm and add liquidity to the Secret Token pool. This will execute a transaction on the blockchain which will require some SCRT for gas. The contract interaction will be visible on a block explorer like Secretnodes)

You have successfully added liquidity on SecretSwap and you now own a share of the liquidity pool, represented as an LP Token. Like every other Secret Token you will need to unlock the viewing key in order to view your LP balance in your secret wallet:

  1. Navigate to the Earn tab using the banner menu.
  2. Select your Secret Token liquidity pool. (NOTE: If you provided liquidity to a pool which is no longer receiving rewards or is part of the “old” pool set and you’re having problems withdrawing your LP consider reaching out to the SecretSwap support team on discord)

3. Click View Balance next to the 🔍 icon on the Left side (available)

This will execute a transaction on the blockchain which will require some SCRT for gas. The contract interaction will be visible on a block explorer like Secretnodes)

4. You will now be able to view our LP Token balance in your Keplr wallet (i.e. SWAP-LP). LP Tokens will differ based on the liquidity pool you have selected

By owning a share of the liquidity pool, you automatically earn fees when the pool is used for SecretSwap trades. However, you can earn additional yield reward by staking your LP Tokens on select incentivized pairs(NOTE: rewards are paid in SEFI on a block by block basis approximately every 6 seconds and need to be claimed for them to be liquid).

  1. Navigate back to the Earn tab using the banner menu and select your Secret Token liquidity pool

2. Input the amount of LP Tokens you would like to stake and click Earn. There is no lock up time for staking LP Tokens for yield rewards so you can withdraw them whenever you want. This will execute a transaction on the blockchain which will require some SCRT for gas. The contract interaction will be visible on a block explorer like Secretnodes) (NOTE: If you are trying to input 100% and receiving an error, try putting a little less 99.99% as you may be encountering a rounding issue)

3. Now that you have staked into the rewards contract for your LP Token, you will have to add another viewing key for the LP Reward Token. Click on View Balance next to the 🔍 icon on the right side (staked).

This will execute a transaction on the blockchain which will require some SCRT for gas. The contract interaction will be visible on a block explorer like Secretnodes)

4. You are now successfully earning yield rewards in SEFI token. Click Claim to receive your SEFI rewards. This will execute a transaction on the blockchain which will require some SCRT for gas.

Withdraw Liquidity from SecretSwap pools:

To withdraw liquidity from a SecretSwap liquidity pool, you will first need to unstake from any LP rewards contracts. Then you will exchange the LP tokens back for the corresponding Secret Tokens based on the most current 50:50 balance of the liquidity pool(This is when you’ll experience Impermanent Loss)

  1. If you staked your LP Tokens for additional yield rewards, navigate to the Earn tab and click Withdraw. This will remove your staked LP Tokens from the rewards contract. You will be prompted to make a SCRT transaction to execute the secret contract.
  2. Navigate to the Pool tab, click Withdraw in the liquidity pool window, and select your LP Pool.

If you are trying to withdraw from a non-existing pool or if the balance of the pool you have delegated to states 0 please contact the Secret support team. Your pool might be deprecated and they will help with locating your funds.

3. Input the amount of liquidity you would like to withdraw. Be sure to check the price to see the current Secret Token ratio for your liquidity pair. This will indicate the ratio that you will receive when you withdraw.

4. Click Withdraw to remove liquidity from the pool. You will be prompted to make a SCRT transaction to execute the secret contract.

What’s Next?

Now have a better understanding on how to swap, stake and provide liquidity on SecretSwap.

One of the main advantages of using SecretSwap is that everything is 100% front-running resistant so that users can benefit from the higher security of trading Secret Tokens, which are private-by-default.

Trading on SecretSwap requires low fees and there are many opportunities to earn high yield rewards for participating in Secret DeFi.

Stay in touch with Secret Network and SecretSwap to be informed on new developments for participating in the growth of Secret DeFi — a universe where applications are front-running resistant and private by design!

Learn more about the Secret Network ecosystem: https://scrt.network

--

--

Secret Network

The Data Privacy Platform For Web3 — build and use blockchain applications that are both permissionless and privacy-preserving.