Swap
Swap parameters
/// Swap inputs are gathered in a single object (Anchor's conversion from the rust enum)
/// Every usual type of swap is supported:
// - buyExactIn: {amountIn: number, minAmountOut: number}
// - buyExactOut: {maxAmountIn: number, amountOut: number}
// - sellExactIn: {amountIn: number, minAmountOut: number}
// - sellExactOut: {maxAmountIn: number, amountOut: number}
const swapParameters = {
buyExactIn: [
new anchor.BN(10_000_000), // 0.01 SOL
new anchor.BN(1),
],
};SOL wrapping
const transferIx = anchor.web3.SystemProgram.transfer({
fromPubkey: wallet.publicKey,
toPubkey: userTokenAccount1.address,
lamports: swapParameters.buyExactIn[0].toNumber(),
});
const syncNativeIx = createSyncNativeInstruction(userTokenAccount1.address);
const tx = new anchor.web3.Transaction().add(transferIx, syncNativeIx);Fee addresses
Transaction
Last updated