Protocol Integration
You can integrate with most of the protocols with 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 back to Veilnyx. The interaction basically converts from one asset to another. Some examples:
When
WETHwithUSDCon Uniswap you're converting yourWETH(input) toUSDC(ouput).When staking
WETHon Lido you convert yourWETH(input) towstETH(output).When lending
USDTon Aave, you convert it toaUSDT.
Adaptor Contracts
These are the smart contacts that implement the IAdaptorinterface:
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.
inAssetIdsis the list of asset ids of the assets given to this contract.inValuesis the corresponding value of the specified asset ids in that order.payloadis an arbitrary data passed on that might be required as, for example, user input for the necessary operation.
Note that handleAssets function is delegatecalled by the Veilnyx's AdaptorHandler contract. At the time of call, the AdaptorHandler holds exactly the amount of assets that were specified by the inAssetIds and inValues. So, you don't need to do any ERC-20 operation like transferFrom(...) or anything to get the assets - you already have it.
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 exactly have those assets (outAssetIds) and exactly those amount of the assets (outValues).
Examples
UniswapV3 integration with Veilnyx
Last updated