> For the complete documentation index, see [llms.txt](https://docs.covenant.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.covenant.finance/deprecated/user-app/guild-swaps.md).

# Guild Swaps

In addition to swapping debt tokens (zTokens) and money tokens in Uniswap v3 pools, users can also swap between these pairs using the Guild’s `swapMoneyForZTokens` and `swapZTokensForMoney` functions. The Guild has infinite zToken liquidity, meaning users can always `swapMoneyForZTokens` at the zToken *facePrice*. This is useful if there are not enough zTokens in the Uniswap v3 pool to pay off a user’s debt, if the user needs zTokens for liquidations, or if zToken *marketPrices* are too high (more details on this below). The Guild does not have infinite money tokens, however, so `swapZTokensForMoney` can only be used after users have already executed `swapMoneyForZTokens` and the Guild has a remaining money balance.

Guild money <> zToken swaps will always occur at the debt token *facePrice* (see details [here](https://docs.covenant.finance/getting-started/litepaper#interest-rates)). As a result, users can **potentially** take advantage of arbitrage opportunities if, for instance, the zToken *marketPrice* > *facePrice* or if zToken *facePrice* < *marketPrice* and there is Guild money to be claimed.

**Note: The following is meant for advanced defi users. Proceed with extreme caution and follow these steps at your own risk.**

***

## How to `swapMoneyForZTokens` :

1. Approve Money Token Transfers:
   1. Navigate to the top of the Market Details page in [https://alpha.covenant.finance/ ](https://alpha.covenant.finance/), and click on the link out from the money token in the right metrics panel

      <figure><img src="/files/0OC5h5DDvdBo1qpAvcgB" alt=""><figcaption></figcaption></figure>
   2. This will take you to the block explorer page for the money token. Navigate to the `Contracts` > `Write Contract` (or `Write as Proxy` if available) tab and click the `Connect to Web3` button to connect your wallet to the site.

      <figure><img src="/files/j0NWHYxhHlCdDwhVTSUd" alt=""><figcaption></figcaption></figure>
   3. After connecting your wallet, click the `approve` dropdown. Executing this function will enable the Guild to transfer an amount of money tokens on your behalf, which is required to execute `swapMoneyForZTokens`.

      <figure><img src="/files/8uiALqCpNjeKVlh2qzIN" alt=""><figcaption></figcaption></figure>
   4. You can find Guild address by navigating back to the Market Details page and clicking on the address button next to the market name at the top of the page.

      <figure><img src="/files/vaRuIQEii02g2NtuO4cw" alt=""><figcaption></figcaption></figure>
   5. Input the guild address into the `spender` input field and add the money token amount you want to swap in the `value` field. **Note**: the money token value should be in money token units (i.e. 1 sUSD = 1000000000000000000) - **ALWAYS** confirm the decimal value of the money token you intend to swap.

      <figure><img src="/files/OxHzZf2HYXotRqEnTDct" alt=""><figcaption></figcaption></figure>
   6. Click on the `Write` button & sign the transactions in your wallet to execute the `approve` function.
2. Swap money for zTokens
   1. Navigate back to the Market Details page and click on the link out to the Guild address on the block explorer.

      <figure><img src="/files/F8c5IatiyYbBEKkMrb7c" alt=""><figcaption></figcaption></figure>
   2. This will take you to the block explorer page for the money token. Navigate to the `Contracts` > `Write Contract` (or `Write as Proxy` if available) tab and click the `Connect to Web3` button to connect your wallet to the site.

      <figure><img src="/files/a58dCtc2kMIuY5eHL2qa" alt=""><figcaption></figcaption></figure>
   3. Navigate to the bottom of the page, click on the `swapMoneyForZTokens` function, and enter the amount of money you want to swap with the Guild (note: this cannot exceed the amount of money you approved in the previous step).

      <figure><img src="/files/ivaq0vd4RE7RJBXAgPLK" alt=""><figcaption></figcaption></figure>
   4. Click the `Write` button & approve transactions in your wallet to execute the Guild swap.

## How to `swapZTokensForMoney` :

1. Navigate to the bottom of the Market Details page to check if the Guild has money to swap (i.e. the `Guild Balance` is greater than 0):

   <figure><img src="/files/pDfroi6Ix6Xam7fgySYq" alt=""><figcaption></figcaption></figure>
2. Approve zToken Transfers:
   1. Navigate to the top of the Market Details page in <https://alpha.covenant.finance/>, and click on the link out from the zToken in the right metrics panel

      <figure><img src="/files/nTMO7S0EutIY9pz0LVIP" alt=""><figcaption></figcaption></figure>
   2. This will take you to the block explorer page for the Guild contract. Navigate to the `Contracts` > `Write Contract` (or `Write as Proxy` if available) tab and click the `Connect to Web3` button to connect your wallet to the site.

      <figure><img src="/files/VUt8u7t0tvmML3OUfNY0" alt=""><figcaption></figcaption></figure>
   3. After connecting your wallet, click the `approve` dropdown. Executing this function will enable the Guild to transfer an amount of zTokens on your behalf, which is required to execute `swapZTokensForMoney`.

      <figure><img src="/files/zlpZuFA84Ze211QDVzZM" alt=""><figcaption></figcaption></figure>
   4. You can find Guild address by navigating back to the Market Details page and clicking on the address button next to the market name at the top of the page.

      <figure><img src="/files/vaRuIQEii02g2NtuO4cw" alt=""><figcaption></figcaption></figure>
   5. Input the guild address into the `spender` input field and add the zToken amount you want to swap in the `value` field. **Note**: the money token value should be in zToken units (i.e. 1 zTazzDebtTest = 1000000000000000000) - **ALWAYS** confirm the decimal value of the zToken you intend to swap.

      <figure><img src="/files/1QXHlxrJRgrjycW7iluk" alt=""><figcaption></figcaption></figure>
   6. Click on the `Write` button & sign the transactions in your wallet to execute the `approve` function.
3. Swap zTokens for money
   1. Navigate back to the Market Details page and click on the link out to the Guild address on the block explorer.

      <figure><img src="/files/T4z8OBnZRWOssDF8kII6" alt=""><figcaption></figcaption></figure>
   2. This will take you to the block explorer page for the Guild contract. Navigate to the `Contracts` > `Write Contract` (or `Write as Proxy` if available) tab and click the `Connect to Web3` button to connect your wallet to the site.

      <figure><img src="/files/Kum7dNzJnaPXGBcPvZ15" alt=""><figcaption></figcaption></figure>
   3. Navigate to the bottom of the page, click on the `swapZTokenForMoney` function, and enter the amount of zToken you want to swap with the Guild (note: this cannot exceed the amount of zToken you approved in the previous step).

      <figure><img src="/files/ESx1cjAawT6qVnlexEs7" alt=""><figcaption></figcaption></figure>
   4. Click the `Write` button & approve transactions in your wallet to execute the Guild swap.
