Skip to main content

Transactions

Execute and manage transactions through your vault.

Single Transactions

const tx = await client.execute({
target: contractAddress,
value: ethers.parseEther('0.1'), // ETH value
data: calldata,
});

const receipt = await tx.wait();
console.log('Gas used:', receipt.gasUsed);

Batch Transactions

Execute multiple operations atomically:

const tx = await client.executeBatch({
targets: [uniswap, aave, compound],
values: [0n, 0n, 0n],
calldatas: [swapData, depositData, borrowData],
});

If any operation fails, the entire batch reverts.

Token Swaps

Use the swap intent helper:

import { buildSwapCalldata, calculateMinOutput } from '@zeroquant/sdk';

const minOutput = calculateMinOutput(expectedOutput, 100); // 1% slippage

const calldata = buildSwapCalldata({
amountIn: ethers.parseEther('1'),
amountOutMin: minOutput,
path: [WETH, USDC],
to: vaultAddress,
deadline: Math.floor(Date.now() / 1000) + 1200,
});

const tx = await client.execute({
target: uniswapRouter,
value: 0n,
data: calldata,
});