> ## Documentation Index
> Fetch the complete documentation index at: https://docs.enso.build/llms.txt
> Use this file to discover all available pages before exploring further.

# Withdraw & Swap

> Redeem asssets and swap them directly to an arbitrary token in a single transaction

Enso [GET `route`](/pages/build/get-started/route) API allows withdrawing (redeeming) from a curated vault position to an arbitrary DeFi or base asset.

## Withdraw PT and swap to USDC

This route redeems ezETH PT into USDC, performing any necessary withdrawals and swaps.

[Try this route →](https://happypath.enso.build/?tokenIn=0xeEE8aED1957ca1545a0508AfB51b53cCA7e3c0d1\&outChainId=1\&chainId=1\&tokenOut=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\&amountIn=10000000000000000000)

**Route mechanics:**

* Redeem from `PT_ezETH` to get `SY_ezETH`
* Redeem from `SY_ezETH` to obtain the deposited `ezETH`
* Swap `ezETH` to desired `USDC`

```mermaid theme={null}
flowchart LR
    PT((PT_Token)) -->|pendle-pt<br/>redeem| SY((SY_Token))
    SY -->|pendle-sy<br/>redeem| ezETH((ezETH))
    ezETH -->|barter<br/>swap| USDC((USDC))
```

```ts lines theme={null}
const PT_ezETH_25APR2024 = "0xeEE8aED1957ca1545a0508AfB51b53cCA7e3c0d1";
const USDC: Address = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
const amountIn = parseUnits("10", 18).toString();
const chainId = 1;

const fromAddress = "0xd8da6bf26964af9d7eed9e03e53415d37aa96045";

const routeParams: RouteParams = {
  chainId,
  amountIn: [amountIn],
  fromAddress,
  tokenIn: [PT_ezETH_25APR2024],
  tokenOut: [USDC],
  routingStrategy: "router",
  receiver: fromAddress,
  slippage: "500",
};



const route = await client.getRouteData(routeParams);
console.log(JSON.stringify(route, null, 2));

const approvalData = await client.getApprovalData({
  chainId,
  fromAddress,
  amount: amountIn,
  tokenAddress: PT_ezETH_25APR2024,
});
await sendEoa(approvalData.tx, approvalData.gas);
// sending the actual transaction
await sendEoa(route.tx, route.gas);
```

## Withdraw ADAI to USDC

This sample withdraws `ADAI` and swaps it to USDC in a single transaction.

[Try this route →](https://happypath.enso.build/?tokenIn=0xeEE8aED1957ca1545a0508AfB51b53cCA7e3c0d1\&outChainId=1\&chainId=1\&tokenOut=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\&amountIn=10000000000000000000)

**Route mechanics:**

* Withdraw deposited `ADAI` to the underlying `DAI`
* Swaps `DAI` to `USDC`
* The `receiver` gets the resulting funds

```mermaid theme={null}
flowchart LR
    aDAI((aDAI)) -->|aave-v3<br/>redeem| DAI((DAI))
    DAI -->|odos<br/>swap| USDC((USDC))
```

```ts lines theme={null}
const ADAI_ADDRESS = "0x018008bfb33d285247A21d44E50697654f754e63";
const USDC: Address = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
const amountIn = parseUnits("100", 18).toString();
const chainId = 1;

const fromAddress = "0xd8da6bf26964af9d7eed9e03e53415d37aa96045";

const routeParams: RouteParams = {
  chainId,
  destinationChainId: chainId,
  amountIn: [amountIn],
  fromAddress,
  tokenIn: [ADAI_ADDRESS],
  tokenOut: [USDC],
  routingStrategy: "router",
  receiver: fromAddress,
  slippage: "500",
};

const route = await client.getRouteData(routeParams);

console.log(JSON.stringify(route, null, 2));

const approvalData = await client.getApprovalData({
  chainId,
  fromAddress,
  amount: amountIn,
  tokenAddress: ADAI_ADDRESS,
});

await sendEoa(approvalData.tx, approvalData.gas);

// sending the actual transaction
await sendEoa(route.tx, route.gas);
```
