import { privateKeyToAccount } from "viem/accounts";
import {
createPublicClient,
Chain,
http,
createWalletClient,
WalletClient,
Account,
defineChain,
} from "viem";
import { peripheryPoolAdapter } from "@skate-org/skate-app-amm";
const account = privateKeyToAccount(PRIVATE_KEY as `0x${string}`);
const wallet = createWalletClient({
chain,
account,
transport: http(RPC_URL),
});
const recipient = RECIPIENT_ADDRESS; // in bytes32 format
const swapData: `0x${string}` = peripheryPoolAdapter.getSwapCalldata({
recipient: evmContext!.account!.address as `0x${string}`,
destChainId: chainId,
destVmType: 1,
amount: amount,
zeroForOne: zeroForOne,
sqrtPriceLimitX96: sqrtPriceLimitX96,
minAmountOut: minAmountOut,
});
const executableRequest = await wallet.prepareTransactionRequest({
account: account,
chain: wallet.chain,
data: swapData,
to: poolAddress,
});
const signedTx = await wallet.signTransaction(executableRequest);
const tx = await wallet.sendRawTransaction({
serializedTransaction: signedTx,
});
return tx;