SWAP mode

A profitable Swap with minimal fees and no risks? Easy!

The Swap mode in a Selenium bot provides the opportunity for instant token exchange without the need to visit centralized exchanges. Simply enter the amount of tokens you want to swap, and the Swap mode will automatically find the best price and execute the exchange operation for you. This is a fast, convenient, and secure way to exchange cryptocurrencies directly from your wallet

  1. swapExactTokensForTokens: This function will allow the user to swap a specific amount of tokens for another token. The function will take the following arguments:

    amountIn: The amount of tokens to swap. amountOutMin: The minimum amount of tokens to receive. path: The path of the swap. to: The address of the recipient. deadline: The deadline for the swap.

  2. swapTokensForExactTokens: This function will allow the user to swap a specific amount of tokens for a specific amount of another token. The function will take the following arguments:

    amountOut: The amount of tokens to receive. amountInMax: The maximum amount of tokens to swap. path: The path of the swap. to: The address of the recipient. deadline: The deadline for the swap.

  3. swapExactETHForTokens: This function will allow the user to swap a specific amount of ETH for another token. The function will take the following arguments:

    amountOutMin: The minimum amount of tokens to receive. path: The path of the swap. to: The address of the recipient. deadline: The deadline for the swap.

  4. swapTokensForExactETH: This function will allow the user to swap a specific amount of tokens for a specific amount of ETH. The function will take the following arguments:

    amountOut: The amount of ETH to receive. amountInMax: The maximum amount of tokens to swap. path: The path of the swap. to: The address of the recipient. deadline: The deadline for the swap.

  5. swapExactTokensForETH: This function will allow the user to swap a specific amount of tokens for ETH. The function will take the following arguments:

    amountIn: The amount of tokens to swap. amountOutMin: The minimum amount of ETH to receive. path: The path of the swap. to: The address of the recipient. deadline: The deadline for the swap.async def swap( tokenA: str, tokenB: str, dex: str, amount: float, slippage: float = 0.5, max_gas_price: int = 100, gas_price: int = None, gas_limit: int = None, ): """ Performs a swap between two tokens on a DEX.

Args:
    tokenA (str): The first token to swap.
    tokenB (str): The second token to swap.
    dex (str): The DEX to use.
    amount (float): The amount of tokenA to swap.
    slippage (float): The slippage tolerance.
    max_gas_price (int): The maximum gas price to use.
    gas_price (int): The gas price to use.
    gas_limit (int): The gas limit to use.
"""

# Get the contract for the DEX
contract = await get_contract(dex)

# Get the path for the swap
path = [tokenA, tokenB]

# Get the amount out minimum
amount_out_min = await contract.functions.getAmountsOut(amount, path).call()
amount_out_min = amount_out_min[-1] * (1 - slippage / 100)

# Get the gas price
if gas_price is None:
    gas_price = await get_gas_price(max_gas_price)

# Get the gas limit
if gas_limit is None:
    gas_limit = await get_gas_limit(contract)

# Perform the swap
await contract.functions.swapExactTokensForTokens(
    amount,
    amount_out_min,
    path,
    msg.sender,
    (int(time.time()) + 600),
).call(gas_price=gas_price, gas=gas_limit)

Last updated