import { useAccount, useContract } from "@starknet-react/core";
import { getSwapCalldata } from "@/lib/avnu";
async function deposit(wbtcAmount: bigint) {
const { account } = useAccount();
// Get AVNU swap calldata for 50% wBTC → USDC
const swapCalldata = await getSwapCalldata(
WBTC_ADDRESS,
USDC_ADDRESS,
wbtcAmount / 2n, // Only 50% gets swapped
VAULT_ADDRESS,
1 // 1% slippage
);
// Approve wBTC transfer
const approveCall = {
contractAddress: WBTC_ADDRESS,
entrypoint: "approve",
calldata: [VAULT_ADDRESS, wbtcAmount, 0]
};
// Deposit call
const depositCall = {
contractAddress: VAULT_ADDRESS,
entrypoint: "deposit",
calldata: [wbtcAmount, 0, minShares, 0, ...swapCalldata]
};
return account.execute([approveCall, depositCall]);
}