Allows sniping pool creation events for Uniswap V2-styled routers in under 250 LOC. Monitors UniswapV2Factory
for PairCreated
events, verifies that one of the tokens of pair matches your desired sniping tokens, and automatically submits a purchase transaction (with initial token for route === base chain token, eg. ETH or Matic).
This repo is a proof-of-concept implementation of sniping the Klima pool launch on Sushiswap Router V2 — Polygon. If you do not want to test on Polygon Mainnet, do not apply the postinstall patch and change src/sniper.ts:L73 to desired network.
Credits: @joshstevens19 for simple-uniswap-sdk
# Clone repo
git clone https://github.com/anish-agnihotri/pool-sniper
# Install dependencies
npm install
# Re-run post install (just in case, see issue #1)
npm run postinstall
# Update environment variables
cp .env.sample > .env
vim .env
# Run pool-sniper
npm run start
The Polygon mainnet is defined in the sniper code. You can use polygon testnet by turning IS_TESTNET
to true
in your .env
. Please note your RPC_ENDPOINT
to be a testnet node.
The easiest way to test locally is:
// SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol"; // OZ: ERC20
contract Tester is ERC20 {
constructor(string memory _name, string memory _symbol) ERC20(_name, _symbol) {
_mint(msg.sender, 1e18 * 1000);
}
}
.env
npm run start
)