Snipe new tokens at listing
Basic
A trading bot can use multiple strategies to snip tokens when listing:
Monitoring of Announcements
The bot tracks announcements of new token listings on DEX exchanges. This can be done by monitoring official exchange announcements, news channels and social networks.
Quick Placement of Orders
When a new listing is announced, the bot instantly places limit orders to buy the token at or slightly above the listing price. The bot uses an optimized order placement process to ensure that orders are executed first.
Large Order Volumes
The bot places large buy orders to increase the probability of execution. This can be especially effective for new tokens with low liquidity.
Using Multiple Accounts
The bot can use multiple accounts on the exchange to place more buy orders, increasing the chances of getting tokens.
Example
Suppose a DEX exchange announces the listing of a new token called "XYZ". The bot detects this announcement and immediately places a limit buy order for 10 ETH at a listing price of 0.1 ETH. The bot also uses two additional accounts to place additional buy orders, increasing the total order volume by 30 ETH.
When a token is listed, the bot's orders are executed first, and it purchases XYZ tokens at the listing price. The bot can then sell the tokens at a profit, taking advantage of the price volatility immediately after the listing.
Basic Code
Token Sniping Function in Listing
import web3 import time
def snipe_token(w3, pair, amount, price): """Snipe token when listing.
Args: w3: Web3 object connected to the wallet. pair: Trade pair (e.g., "ETH/XYZ"). amount: Buy order amount. price: Buy order price. """ # Get the token listing information listing_info = get_listing_info(pair)
# Wait until listing time listing_time = listing_info["time"] while time.time() < listing_time: time.sleep(1)
# Place a buy order order = w3.eth.contract( address=listing_info["exchange_contract"], abi=listing_info["exchange_abi"] ).functions.functions.createOrder( pair, amount, price ).buildTransaction()
# Send order transaction_hash = w3.eth.sendTransaction(order)
# Wait for the order to be executed receipt = w3.eth.wait_for_transaction_receipt(transaction_hash)
# Check if the order has been executed if receipt["status"] == 1: print("Purchase order executed.") else: print("Failed to execute purchase order.")
# Function to get token listing information def get_listing_info(pair): """"Gets token listing information.
Args: pair: Trade pair (e.g. "ETH/XYZ"). """"
# Replace these variables with the actual listing information exchange_contract = "YOUR_EXCHANGE_CONTRACT_ADDRESS" exchange_abi = "YOUR_EXCHANGE_CONTRACT_ABI" listing_time = 1656844800 # Listing time in Unix timestamp format
return { "exchange_contract": exchange_contract, "exchange_abi": exchange_abi, "time": listing_time }
Using the Function
// # Replace these variables with the desired values pair = "ETH/XYZ" amount = 1 price = 0.1
# Connect to Web3 and wallet w3 = connect_to_wallet(private_key, network)
# Snipe the token snipe_token(w3, pair, amount, price)
Using the Function
// // # Replace these variables with the desired values pair = "ETH/XYZ" amount = 1 price = 0.1
# Connect to Web3 and wallet w3 = connect_to_wallet(private_key, network)
# Snipe the token snipe_token(w3, pair, amount, price)
Last updated