# ERC20 Swaps

ERC20 Swaps were designed by the developers in the Frictionless protocol to risk off permissionless stablecoins such as USDC or USDT.&#x20;

Permissionless are a great innovation from the crypto markets which were designed for permissionless crypto referencing to US Dollars, however handling stablecoins for traditional institutional partners is still a risky proposition.

{% hint style="success" %}
Using the ERC20 Converter contracts, FrictionlessFundDepositTokens can be converted to/from stablecoins using the Frictionless protocol to help Managers accept stablecoins whilst off-loading their associated risks, such as de-peg events, underlying community bank reliance and liquidity risks.
{% endhint %}

{% hint style="info" %}
The PROTOCOL\_TREASURY manages the on/off ramp of the ERC20 stablecoin, such as USDC/USDT within its fund structures of FRICTIONLESS MARKETS SECURITIES FT. &#x20;
{% endhint %}

{% hint style="success" %}
The availability of a valid configured ERC20 token for conversion to/from FrictionlessFundDepositToken along with the associated fees is transparent, any market participant may query the smart contract.
{% endhint %}

The principle of an ERC20 Swap is simple.

<figure><img src="https://257329724-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fn1p8Xj3fTDixdW6ELAVY%2Fuploads%2FYGOiYkoDFznVajOnBGwz%2Ffrictionless-protocol-img-src-Frictionless-ERC20-Swap.drawio%20(1).png?alt=media&#x26;token=994dd5e8-c10b-4e7a-a10a-d457c65fa418" alt=""><figcaption><p>Schematic of a Frictionless ERC20 (USDC stablecoin) Swap</p></figcaption></figure>

1. The PROTOCOL\_ADMIN defines the valid token pairs which are convertible on a 1:1 basis.
2. Fees can be optionally defined for the conversion to/from the ERC20 token.
3. The holder (Investor) of ERC20 tokens invokes the `convertFromERC20`function of the smart contract, the ERC20 tokens are sent to the PROTOCOL\_TREASURY and a matching amount of FrictionlessFundDepositToken is minted and sent to the holder (Investor).
4. If the Investor wishes to convert their FrictionlessFundDepositToken to a valid configured ERC20 token, such as USDC/USDT, then they can invoke the `convertToERC20`function of the smart contract. In this case, the PROTOCOL\_TREASURY will receive the FrictionlessFundDepositToken and burn it, transferring the matching amount of ERC20 (less any fees) to the Investor.

An example of two live ERC20 swaps on the Avalanche C-Chain are;

* [USDC swapped for fsUSD ](https://snowtrace.io/tx/0x3cac0554cbf7b75d347bca14c9e7531147ba75d32b30d0923233c45fd1aa49c7?chainId=43114)
* [fsUSD swapped for USDC ](https://snowtrace.io/tx/0x7dc46fbadd478d8d9c723ce43a913f8e666b17675f394aee2957df93a87c16b2)

In these swaps, you can observe the collection of optional fees and the atomic settlement of the swap of the fsUSD tokens with USDC into the PROTOCOL\_TREASURY.

<figure><img src="https://257329724-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fn1p8Xj3fTDixdW6ELAVY%2Fuploads%2F33g66iAMNS8CKi8lmPP3%2FScreenshot%202023-12-28%20at%2019.07.10.png?alt=media&#x26;token=cbf1954c-73fd-4316-bee1-43eb640e7994" alt=""><figcaption><p>Frictionless ERC20 Swap - USDC for fsUSD with automatic fee collection</p></figcaption></figure>

<figure><img src="https://257329724-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fn1p8Xj3fTDixdW6ELAVY%2Fuploads%2FlBiZGmd6REaVYtYbtjNH%2FScreenshot%202023-12-28%20at%2019.04.46.png?alt=media&#x26;token=d6ea2234-7755-429c-98b4-6914ef52b8c9" alt=""><figcaption><p>Frictionless ERC20 Swap - fsUSDC for USDC with no fee collection</p></figcaption></figure>
