import { getAction } from "./getAction";
import { parseAbiItem } from "viem";
import { walletClient } from "./config";
const actionRequest: ActionRequest = {
actionType: "swap-action",
sender: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045", // generally the user's connected wallet address
srcToken: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", // USDC on Base
dstToken: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9", // USDT on Arbitrum
srcChainId: 8453, // Base Chain ID
dstChainId: 42161, // Arbitrum Chain ID
slippage: 100, // bps
swapDirection: "exact-amount-in",
amount: 10000000n, // denominated in srcToken decimals
recipient: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
};
const tx = await getAction({ actionRequest });
export async function sendBatchedTx() {
const { id } = await walletClient.sendCalls([
calls: [
{
to: actionRequest.srcToken,
abi: parseAbiItem('function approve(address, uint256) returns (bool)'),
functionName: 'approve',
args: [
tx.to,
amount
]
},
{
to: tx.to,
value: tx.value,
data: tx.data
},
]
]);
return id;
}