> For the complete documentation index, see [llms.txt](https://docs.veilnyx.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.veilnyx.com/veilnyx-sdk/quickstart/protocol-integration.md). Agents can also search and read this documentation through its [MCP server](https://docs.veilnyx.com/~gitbook/mcp).

# Protocol Integration

You can integrate with most of the protocols with the Veilnyx protocol, to allow anonymous transactions for the users. Your users will be using their shielded account instead of a public account to interact with your protocol.

For this, you'll have to write and deploy a stateless contract that acts as a logic layer between the Veilnyx core and the target protocol that you're integrating. We call these contracts **Adaptors**. The reason is that these contracts take input assets from the user's shielded account, convert those assets to some other (output) assets, and return these output assets to Veilnyx. The interaction basically converts from one asset to another. Some examples:

* When `WETH` with `USDC` On Uniswap, you're converting your `WETH` (input) to `USDC` (output).
* When staking `WETH` On Lido, you convert your `WETH` (input) to `wstETH` (output).
* When lending `USDT` On Aave, you convert it to `aUSDT`.

### Adaptor Contracts

These are the smart contacts that implement the `IAdaptor`interface:

```solidity
interface IAdaptor {
    function handleAssets(
        uint24[] calldata inAssetIds,
        uint256[] calldata inValues,
        bytes calldata payload
    )
        external
        payable
        virtual
        returns (uint24[] memory outAssetIds, uint256[] memory outValues);
}
```

The interface only requires the implementation of the `convert` method as seen above.&#x20;

* `inAssetIds` is the list of asset IDs of the assets given to this contract.
* `inValues` is the corresponding value of the specified asset IDs in that order.
* `payload` is an arbitrary data passed on that might be required, for example, user input for the necessary operation.

Note that `handleAssets` the function is `delegatecall`ed by the Veilnyx's `AdaptorHandler` contract. At the time of the call, the `AdaptorHandler` holder holds exactly the amount of assets that were specified by the `inAssetIds` holder and `inValues`. So, you don't need to do any ERC-20 operation like `transferFrom(...)` or anything to get the assets - you already have them.

Simply do any necessary operation within the `handleAssets(...)` method and return any output assets by returning `outAssetIds` and `outValues`. Please make sure that after performing your `convert` operation, you only have those assets (`outAssetIds`) and exactly that amount of the assets (`outValues`).

### Examples

[*UniswapV3 integration with* ](https://docs.veilnyx.com/veilnyx-sdk/integrating-with-defi-protocols.md)Veilnyx


---

# 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://docs.veilnyx.com/veilnyx-sdk/quickstart/protocol-integration.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.
