# Tetu Zap Solution

### Zapping

Zap solution converts a token to another using a defined route and can be used to deposit or withdraw from a vault.

![](/files/UaFJcUfftmCVN8Ltvc0D)

Through the Zapping Function users can enjoy the efficiency of participating in a yield farming vault with just one transaction, in general with zapping users can perform only one transaction to enter and exit a yield farming vault. Without using zapping the user would have to perform between 6 \~ 8 transactions to deposit to a yield farming vault.

Withdraw and converting to the token is also possible.

{% hint style="info" %}
The zapping function can cause slippage, when using it it is better to prioritize small amounts of deposits and withdrawals.
{% endhint %}

### Contracts

This solution included three contracts

* PriceCalculator
* MultiSwap
* ZapContract

### PriceCalculator  <a href="#pricecalculator" id="pricecalculator"></a>

In this solution Price Calculator will find the best liquidity pool across predefined Swap Platforms.

`getLargestPool(address token, address[] memory usedLps)`

For calculation price for any LiquidityPool pair using

`getPriceFromLp(address lpAddress, address token)`

### MultiSwap  <a href="#multiswap" id="multiswap"></a>

This contract has two purposes:

Find the best route for swap two tokens. The result will contain swap pairs.

&#x20; `findLpsForSwaps(address _tokenIn, address _tokenOut)`

The function should be called as a view from UI before the swap

Multi-swap will execute swaps for a given route. Used inside ZapContract but also can be used as a dedicated solution.

`multiSwap(address[] memory lps, address tokenIn, address tokenOut, uint256 amount, uint256 slippageTolerance)`

### ZapContract  <a href="#zapcontract" id="zapcontract"></a>

This contract implements all required steps for deposit/withdraw to the vault.

### Resources

Zap Feature article on [Medium](https://medium.com/@tetu.finance/zap-feature-bc43dba8b0f8).


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tetu.io/tetu-io/tetu-v1/yield-farm/tetu-zap-solution.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
