> For the complete documentation index, see [llms.txt](https://fxprotocol.gitbook.io/fx-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fxprotocol.gitbook.io/fx-docs/developers/integrating-fxsave.md).

# Integrating fxSAVE

To facilitate the integration of fxSAVE from any chain, [Enso](https://www.enso.build/) routed it.\
You'll find more information here.

* <https://docs.enso.build/pages/build/get-started/route>
* <https://docs.enso.build/pages/build/examples/shortcuts>

Note that since fxSAVE withdrawal is a two-step process, Enso only routed the atomic withdrawal that charges a withdrawal fee.\
\
To avoid that fee, you can wait for the cooldown period instead.\
\ <br>

### Method 1: Direct Redemption via Router

* Contract Addresses
  * RouterManagementFacet:[ 0x33636D49FbefBE798e15e7F356E8DBef543CC708](https://etherscan.io/address/0x33636D49FbefBE798e15e7F356E8DBef543CC708)
  * SavingFxUSDFacet: [0x56afB443dE36340c32f1a461605171992480059D](https://etherscan.io/address/0x56afB443dE36340c32f1a461605171992480059D)
* Function Call
  * Function:&#x20;

    ```
    instantRedeemFromFxSave (0x6d701088)
    ```

  * Description: Burns fxSave shares and instantly converts them into the target token(s) (such as fxUSD, USDC, or a combination of fxUSD + USDC).<br>
* Function Signature

```solidity
function instantRedeemFromFxSave(
    LibRouter.ConvertOutParams memory fxusdParams,
    LibRouter.ConvertOutParams memory usdcParams,
    uint256 shares,
    address receiver
)
```

* Parameter Struct Description (ConvertOutParams)<br>

```solidity
struct ConvertOutParams {
    address tokenOut;    // Address of the output token
    address converter;   // Address of the converter contract
    uint256 encodings;   // Encoding parameters for MultiPathConverter
    uint256[] routes;    // Route encodings for conversion
    uint256 minOut;      // Minimum expected amount of output token
    bytes signature;     // Optional data for future use
}
```

## ConvertOutParams Example

ConvertOutParams defines how assets redeemed from fxSave are converted (swapped) into the target token, such as USDC, fxUSD, or USDC+fxUSD. Below are three typical usage scenarios:

***

### ✅ Scenario 1: Redeeming USDC

In this case:

* fxUSD needs to be swapped into USDC via the converter.<br>
* USDC is redeemed directly without swap.<br>

#### fxusdParams (Swap fxUSD → USDC)

```json

{
  tokenOut: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC address
  converter: "0x12AF4529129303D7FbD2563E242C4a2890525912",
  encodings: 2097151n, // Encoding flags for routing
  routes: [13937444672719263997463500976868002028738657667021836n], // Swap path: fxUSD → USDC
  minOut: tokenXMinOut, // Minimum acceptable output for USDC (should be queried from converter)
  signature: '0x'
}
```

#### usdcParams (Direct Redemption of USDC)

<pre class="language-json"><code class="lang-json">{
<strong>  tokenOut: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC address
</strong>  converter: "0x12AF4529129303D7FbD2563E242C4a2890525912",
  encodings: 0n, // No conversion
  routes: [],
  minOut: tokenYMinOut, // Minimum expected output for direct USDC
  signature: '0x'
}
</code></pre>

***

### ✅ Scenario 2: Redeeming fxUSD

In this case:

* fxUSD is redeemed directly without swap.<br>
* USDC needs to be swapped into fxUSD via the converter.<br>

#### fxusdParams (Direct Redemption of fxUSD)

```json
{
  tokenOut: "0x085780639CC2cACd35E474e71f4d000e2405d8f6", // fxUSD address
  converter: "0x12AF4529129303D7FbD2563E242C4a2890525912",
  encodings: 0n,
  routes: [],
  minOut: tokenYMinOut,
  signature: '0x'
}
```

#### usdcParams (Swap USDC → fxUSD)

```json
{
  tokenOut: "0x085780639CC2cACd35E474e71f4d000e2405d8f6", // fxUSD address
  converter: "0x12AF4529129303D7FbD2563E242C4a2890525912",
  encodings: 2097151n,
  routes: [97745794563822560938935604024150535507888453411437580n], // Swap path: USDC → fxUSD
  minOut: tokenXMinOut, // Should be obtained by querying the converter
  signature: '0x'
}
```

### ✅ Scenario 3: Redeeming USDC + fxUSD(No Swap)

In this case:

* fxUSD is redeemed directly without any swap.<br>
* USDC is redeemed directly without any swap.<br>

#### fxusdParams (Direct Redemption of fxUSD)

```json
{
  tokenOut: "0x085780639CC2cACd35E474e71f4d000e2405d8f6", // fxUSD address
  converter: "0x12AF4529129303D7FbD2563E242C4a2890525912",
  encodings: 0n,
  routes: [],
  minOut: fxusdMinOut, // Minimum expected fxUSD output
  signature: '0x'
}
```

#### usdcParams (Direct Redemption of USDC)

```json
{
  tokenOut: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", // USDC address
  converter: "0x12AF4529129303D7FbD2563E242C4a2890525912",
  encodings: 0n,
  routes: [],
  minOut: usdcMinOut, // Minimum expected USDC output
  signature: '0x'
}
```

&#x20;&#x20;

***

### Method 2: Two-Step Redemption Process to Get fxUSD + USDC

#### Step 1: Redeem fxSP Tokens from fxSave

* Contract Address
  * SavingFxUSD:[ `0x7743e50F534a7f9F1791DdE7dCD89F7783Eefc39`<br>](https://etherscan.io/address/0x7743e50F534a7f9F1791DdE7dCD89F7783Eefc39)
* Function Call
  * Function:&#x20;

    ```
    redeem (0xba087652)
    ```
* After redeeming, you will receive the corresponding amount of fxSP tokens.<br>

***

#### Step 2: Instantly Redeem fxSP Tokens to Obtain fxUSD and USDC

* Contract Address
  * fxSP: [`0x65C9A641afCEB9C0E6034e558A319488FA0FA3be`<br>](https://etherscan.io/address/0x65C9A641afCEB9C0E6034e558A319488FA0FA3be)

* Function Call
  * Function:&#x20;

    ```
    instantRedeem (0x9f56f9f0)
    ```

* Return Values<br>
  * `amountStableOut`: Amount of stable token (fxUSD and USDC) received
  * `amountYieldOut`: Amount of yield token received<br>

***

## Summary

| Method   | Description                                                         | Features                                                                     |
| -------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
| Method 1 | Direct redemption of fxUSD, USDC, or both via Router                | Single-step process; suitable for flexible and immediate conversion          |
| Method 2 | Two-step redemption: first redeem fxSP, then extract fxUSD and USDC | Fine-grained control over redemption; suitable for detailed asset management |

***

\ <br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://fxprotocol.gitbook.io/fx-docs/developers/integrating-fxsave.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
