All Projects β†’ nicholashc β†’ uniswap-skim

nicholashc / uniswap-skim

Licence: Unlicense license
scripts to scan all of the uniswapV2πŸ¦„ contracts on ethereum and search for skim opportunities

Programming Languages

javascript
184084 projects - #8 most used programming language
solidity
1140 projects

Projects that are alternatives of or similar to uniswap-skim

uniswap-python
πŸ¦„ The unofficial Python client for the Uniswap exchange.
Stars: ✭ 533 (+323.02%)
Mutual labels:  dex, defi, uniswap, uniswap-exchange
zeneth
🏡️ Let Your ETH Chill β€” Gasless Ethereum account abstraction with Flashbots
Stars: ✭ 112 (-11.11%)
Mutual labels:  smart-contracts, defi, uniswap
uniswap-arbitrage-flash-swap
Uniswap flash swap arbitrage solidity contracts
Stars: ✭ 341 (+170.63%)
Mutual labels:  smart-contracts, dex, uniswap
botdexdamar
πŸ€– multichain trading bot with sniper, frontrun, backrun, sandwich
Stars: ✭ 124 (-1.59%)
Mutual labels:  dex, defi, uniswap
quipuswap-core
πŸ§™β€β™‚οΈ Repository containing QuipuSwap liquidity protocol smart-contracts written in Ligo language
Stars: ✭ 48 (-61.9%)
Mutual labels:  smart-contracts, defi
idex-sdk-js
IDEX v3 SDK built with TypeScript, supporting both web and Node environments.
Stars: ✭ 35 (-72.22%)
Mutual labels:  smart-contracts, dex
mStable-contracts
πŸ“ƒ Smart Contracts that make up the core of the mStable protocol
Stars: ✭ 277 (+119.84%)
Mutual labels:  smart-contracts, defi
UpSideDai
⬆️ Take a HIGHLY leveraged position on the future price of DAI πŸ“ˆ.
Stars: ✭ 26 (-79.37%)
Mutual labels:  smart-contracts, defi
flow-protocol-ethereum
Flow Protocols powering synthetic asset and margin trading
Stars: ✭ 18 (-85.71%)
Mutual labels:  smart-contracts, defi
MultiDexArbBot
This is an arbitrage bot that uses existing price aggregators such as 1inch, Paraswap, dex.ag, matcha and more to get the best exchange rates across different decentralized exchanges on different blockchains and ecosystems.
Stars: ✭ 67 (-46.83%)
Mutual labels:  arbitrage, defi
mai-protocol
A Protocol for trading decentralized derivatives on Ethereum
Stars: ✭ 22 (-82.54%)
Mutual labels:  smart-contracts, defi
uniswap-sushiswap-arbitrage-bot
Two bots written in JS that uses flashswaps and normal swaps to arbitrage Uniswap. Includes an automated demostration.
Stars: ✭ 351 (+178.57%)
Mutual labels:  arbitrage, uniswap
defi
Tools for use in DeFi. Impermanent Loss calculations, staking and farming strategies, coingecko and pancakeswap API queries, liquidity pools and more
Stars: ✭ 464 (+268.25%)
Mutual labels:  dex, defi
squeeth-monorepo
Squeeth is a new financial primitive in DeFi that gives traders exposure to ETHΒ²
Stars: ✭ 156 (+23.81%)
Mutual labels:  defi, uniswap
wyvern-ethereum
Project Wyvern Ethereum Smart Contracts
Stars: ✭ 209 (+65.87%)
Mutual labels:  smart-contracts, dex
ape
The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
Stars: ✭ 339 (+169.05%)
Mutual labels:  smart-contracts, defi
prb-math
Solidity library for advanced fixed-point math
Stars: ✭ 404 (+220.63%)
Mutual labels:  smart-contracts, defi
alcor-ui
Alcor Exchange | First self-listing onchain DEX for eosio tokens;
Stars: ✭ 103 (-18.25%)
Mutual labels:  dex, defi
rainbow
DeFi options comparator to detect market opportunities with CLI (Go) and web (Vue3).
Stars: ✭ 40 (-68.25%)
Mutual labels:  dex, defi
core
SIREN Core Smart Contracts
Stars: ✭ 39 (-69.05%)
Mutual labels:  smart-contracts, defi

uniswap-skim

Scripts to scan all of the UniswapV2πŸ¦„ contracts on the Ethereum network and search for mismatched balances/reserves.

about

UniswapV2 has an interesting function called skim(address) that lets anyone claim a positive discrepancy between the actual token balance in the contract and the reserve number stored in the Pair contract.

These scripts scan all of the uniV2πŸ¦„ contracts to look for those opportunities. Usually there are only a handful, but tokens with changing supplies like aTokens or rebase tokens like AMPL can create some chaos. Most of the skim balances are so small that they aren't worth the gas to call. But sometimes they are profitable.

If you try to call skim from an EOA expect to be frontrun. There are an increasing number of bots searching for these opportunities. You may want to use something like the Forwarder.sol contract example or even something more sophisticated.

install

  1. clone the repo
  2. cd into the repo
  3. run npm i to install the dependencies (web3 and axios)

usage

  1. there are two main scripts:
  • uniMarkets.js scans for any newly deployed markets since the last known Pair and appends logs/events.js with any new markets
  • skim.js checks every market in log/events.js and looks for skim opportunities. It attempts to use the coingecko api to find a price for the value of the skim-able tokens
  1. from the root of the repo directory npm run update will run uniMarket.js and update the logs to the latest block
  2. from the root of the repo directory npm run skim will search for skim-able opportunities

usage notes

  1. the scripts are hardcoded to use a local node on port 8546 with a websockets connection. If you are using different ports or infura, change this in the code
  2. there is a "token blacklist" array that includes tokens that are self-destructed, not actually contracts, or totally non-standard ERC20. This reduces overall errors
  3. there is a "whitelist" that correctly names tokens who didn't follow the ERC-20 standard and return a byte32 for their name (looking at you MKR). there is probably a smarter way to deal with this edge case than hardcoding but Β―\(ツ)/Β―
  4. if you run into problems updating events.js try: A) hardcode the path directory in fs.writeFile() in uniMarkets.js B) define the block range for eth.getLogs more narrowly if updating a long time period
  5. skim.js defaults to return skim-able values that are greater than $0.01 so you can see some results. you can change this by altering the variable minDollarVal in skim.js. Skim-able values are also returned when coingecko does not have a price for the token (but they have most)
  6. events.js in this repo is current as of block 11057149 and there are 15,230 uniV2πŸ¦„ Pairs
  7. skim.js can take a few minutes to run as there are over 15,000 pairs to search!
  8. if uniMarkets.js returns no results it's possible that there were no new pairs were deployed since the last time you called the function
  9. the script ignores cases where the reserve is higher than the balance, since that is not skim-able (this happens with rebase coins sometimes)

example output

what your terminal should roughly look like after running npm run update

uniswap-skim npm run update

> [email protected] update /yourDirectory/uniswap-skim
> node ./scripts/uniMarkets.js

πŸ¦„ pair #: 9786 deployed in block: 10898080
πŸ¦„ pair #: 9787 deployed in block: 10898182
πŸ¦„ pair #: 9788 deployed in block: 10898201
πŸ¦„ pair #: 9789 deployed in block: 10898327
πŸ¦„ pair #: 9790 deployed in block: 10898366
πŸ¦„ pair #: 9791 deployed in block: 10898390

what your terminal should roughly look like after running npm run skim

uniswap-skim npm run skim

> [email protected] skim /yourDirectory/uniswap-skim
> node ./scripts/skim.js

{
  "pairAddress": "0x321d87e1757c8c9b57e7af5aa3fe13d2ae774445",
  "pairIndex": 9355,
  "token0": {
    "address": "0x29e240cfd7946ba20895a7a02edb25c210f9f324",
    "name": "yearn Aave Interest bearing LINK",
    "decimals": "18",
    "balance": "252,858.663596952206854028",
    "reserve": "252,858.663596952206854028",
    "imbalance": false
  },
  "token1": {
    "address": "0xa64bd6c70cb9051f6a9ba1f163fdc07e0dfb5f84",
    "name": "Aave Interest bearing LINK",
    "decimals": "18",
    "balance": "267,963.012522435165106136",
    "reserve": "267,962.996672942810947153",
    "imbalance": {
      "diff": "0.015849492360200192",
      "usdPrice": 10.35,
      "value": "$0.16πŸ¦„"
    }
  }
}

disclaimers

I take no responsibility for any use, misuse, mistakes, or funds lost or received related to the use of this code. Use, modify, ignore as you see fit. There is also a benevolent way to correct uniV2πŸ¦„ balance/reserve discrepancies by calling sync(). 😈 or πŸ˜‡: the choice is yours!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].