A simple yet powerfull open source transaction explorer for EVM dexes.
Currently working for:
Uniswapv2 / Uniswapv3 / Sushiswap / 1inch.
Details
It includes mempool (pendingTxs) transactions so you can be aware of incoming movements, **that for example**, may impact in a token price.
We take the mempool input data for every new pending transaction, we decode it to get the target DEX router (univ2 univ3 sushiswap), the tokens and pools involved in the swap, the swap route, the swap method, the swap inputs and outputs amounts. With this data we classify txs and store them in a backend database connected to websocket server that monitor and publish every new pending transaction and their failed/confirmed/dropped/replaced changes.
Details
The mempool interface run with real time updates, so you can be aware of some kind of "extendend network state"... like watching the future transactions to be included (or not) in the confirmed netwrok state.
In terms of a DEX Swap over a token pair/pool this mean a new impact on it, changing the price (in some cases) of a token in the exosystem.
Just by watching the UI u are able to realize if a token its being traded like really fast (HOT), or if a token its not beign traded at all.
This give the user (a defi trader) a better idea of what its really happening in the network, protocol, dex or token.
Look at the difference between the following tokens, and get your own idea.
-
An always HOT token (really fast updates), all TXs involving WETH: https://trojan.finance/#/explorer?inputCurrency=0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
-
A not so HOT token (not so fast updates) , all TXs involving DAI: https://trojan.finance/#/explorer?inputCurrency=0x6B175474E89094C44Da98b954EedeAC495271d0F
-
A not so HOT token (not so fast updates) , all TXs involving USDC: https://trojan.finance/#/explorer?inputCurrency=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
-
A NOT_HOT token, TXs involving LINK: https://trojan.finance/#/explorer?inputCurrency=0x514910771AF9Ca656af840dff83E8264EcF986CA
Among other use cases, you can get advantage of real time swaps information to.
-
Jump in a new TOKEN recently added to uniswap or sushiswap.
-
Know the real status of a token of your interest and wake up (take action) if the token become HOT from one moment to another.
-
Check whales movements and realize how much they are trading or how much token balances they got available to DROP/PUMP a token.
-
Check users trading at the same time from different wallets, connect them and think about what they are doing.... yeah, just like a real trading bot does .... you can actually extend this code and hook an implementation to feed you trading bot with usefull data ... just sayin ....
The interface uses the Uniswap SDK to get the prices of all tokens listed in the explorer.
We query gas now and blocknative API to get latest and next block information.
The interface generate a couple of usefull links for the selected token and the showed transactions, so you can easily see the transaction details in etherscan and validate it.
The interface shows a TAG in the transaction header of the explorer, in case a known whale address is involved in the transaction. We use sibil list to import some public / verified users from https://raw.githubusercontent.com/Uniswap/sybil-list/master/verified.json.
We are looking for a way to import more whales addresses from other sources.
Details
There are some usefull things trojan does in the backend... hope you can discover them but just to start i can post the first one.
-
Tokens. after the app start runing, listening all the swap trades, some times they got new tokens related, and we dont have the token data, so we go and get the token information from the network and we add it to our database, you can realize that this happends usually when a new token its created in the network (recetly added or deployed on main net) so you can actually be aware of all new tokens beign swapped in uniswap and get an opportunity to jump in a good project ... =)
-
In a similar way for every tx , trojan inspect the addresses related , from, receiver, to, etc, and tag them if they are knows, so you can actually be aware to, for example, when a whale wake up ...
-
etc .....
Clone the reposity and install dependencies.
git clone https://github.com/we-commit/in-dex-explorer.git
Use nodejs v14.16.1+ and run with yarn.
- Nodejs v14.16.1+: Recomend https://github.com/nvm-sh/nvm
- Yarn: https://classic.yarnpkg.com/en/docs/install
Gget the connection information to later set the ATLAS_STRING .env variable and connect to the database.
-
MongoDB Cluster: https://www.mongodb.com/cloud/atlas/register
-
You can use you own mongo instance, but need replica set oplog for mongo listeners.
.env In the root folder.
# serverUser pass _ID1_ _DB_NAME_ _ID2_
ATLAS_STRING=mongodb://serverUser:pass@cluster0-shard-00-00._ID1_.mongodb.net:27017,cluster0-shard-00-01._ID1_.mongodb.net:27017,cluster0-shard-00-02._ID1_.mongodb.net:27017/_DB_NAME_?ssl=true&replicaSet=atlas-_ID2_-shard-0&authSource=admin&retryWrites=true&w=majority
# must be the same that replaced _DB_NAME_
DB_NAME=TROJAN-DB-ETH
# a collection prefix when tables are created.
COLLECTION_PREFIX=_ETH_
# ws CORS url
CORS_ORIGIN=*
GAS_STATION_API_URL=https://ethgasstation.info/api/ethgasAPI.json?
BLOCKNATIVE_API_URL=https://api.blocknative.com/gasprices/blockprices
# Get a key in blocknative.
BLOCKNATIVE_API_KEY=9999999999999999999999999999999999999999999999999999
# this is the main websocket provider FULL URL, used to listen to the events of the network.
URL=wss://mainnet.infura.io/ws/v3/99999999999999
# a list of several providers key used to get transaction data, tokens, pools, etc.
# as we run listener in separated server origins (MEMPOOL LISTENER, BLOCK LISTENER AND CONFIRMATION LISTENER)
BLOCKS_URL=wss://emerald-emerald-emerald.quiknode.pro/99999999999999999999999999999/
MEMPOOL_URL=wss://emerald-emerald-emerald.quiknode.pro/99999999999999999999999999999/
CONFIRMED_URL=wss://emerald-emerald-emerald.quiknode.pro/99999999999999999999999999999/
INFURA_URL=wss://mainnet.infura.io/ws/v3/99999999999999999999999999999
ALCHEMY_URL=wss://eth-mainnet.g.alchemy.com/v2/99999999999999999999999999999
# !!! IMPORTANT !!! DEX router address, used to check if a new transaction is a DEX transaction.
UNIV2=0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
UNIV3=0xE592427A0AEce92De3Edee1F18E0157C05861564
SUSHIV2=0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F
# used just to import tokens from the network, and init the database with a token information Cache,
# this saves a lot of calls to the network as we need token data like **decimals** to decode and parse swaps amounts correctly.
WRAPPED=https://wrapped.tokensoft.eth.link/
ROLL=https://app.tryroll.com/tokens.json
SUSHISWAP=https://raw.githubusercontent.com/sushiswapclassic/token-list/master/sushiswap.tokenlist.json
ONE_INCH=https://tokens.1inch.eth.link
COINGECKO=https://tokens.coingecko.com/uniswap/all.json
COMPOUND=https://raw.githubusercontent.com/compound-finance/token-list/master/compound.tokenlist.json
DEFIPRIME=https://defiprime.com/defiprime.tokenlist.json
MESSARI=https://messari.io/tokenlist/messari-verified
OPYN=https://raw.githubusercontent.com/opynfinance/opyn-tokenlist/master/opyn-v1.tokenlist.json
SNX=https://synths.snx.eth.link/
SET=https://raw.githubusercontent.com/SetProtocol/uniswap-tokenlist/main/set.tokenlist.json
AVE=https://tokenlist.aave.eth.link
AGORA=https://datafi.theagora.eth.link
CMCDEFI=https://defi.cmc.eth.link
CMCSTABLECOIN=https://stablecoin.cmc.eth.link
CMC200ERC20=https://erc20.cmc.eth.link
KLEROS=https://t2crtokens.eth.link
FURUCOMBO=https://cdn.furucombo.app/furucombo.tokenlist.json
KYBER=https://api.kyber.network/tokenlist
MYCRYPTOAPI=https://uniswap.mycryptoapi.com/
ZAPPER=https://zapper.fi/api/token-list
UMA=https://umaproject.org/uma.tokenlist.json
BAZAR=https://raw.githubusercontent.com/EthereansOS/Organizations-Interface/master/bazar-tokens-list/dist/decentralizedFlexibleOrganizations.json
ZERION=https://tokenlist.zerion.eth.link
# used to build the front on heroku, this env vars are used in set-heroku script
# at the moment heroku build the client.
# infura key, google analitycs ID, and the heroku app url where the websocket server will be exposed
REACT_APP_CHAIN_ID=1
REACT_APP_GOOGLE_ANALYTICS_ID=UA-999999999999999-1
REACT_APP_NETWORK_URL=https://mainnet.infura.io/v3/999999999999999
REACT_APP_WS_URL_TROJAN=https://localhost:3001/ # or https://mysuperwebsocket.herokuapp.com/ # ensure it ends on /
REACT_APP_APP_IS_OFFLINE=false
SKIP_PREFLIGHT_CHECK=true
./client/.env In the client folder.
REACT_APP_CHAIN_ID=1
REACT_APP_GOOGLE_ANALYTICS_ID=UA-999999999999999-1
REACT_APP_NETWORK_URL=https://mainnet.infura.io/v3/999999999999999
REACT_APP_WS_URL_TROJAN=http://localhost:3001/
REACT_APP_APP_IS_OFFLINE=false
SKIP_PREFLIGHT_CHECK=true
-
In the root folder:
yarn install
-
Go to the client folder:
cd client yarn install
-
In the root folder again. Connect to mongodb, create DB, create collections and indexes as required.
yarn create-indexes "create-indexes": "ts-node ./src/utils/initServer/create-indexes.ts",
-
Import some known tokens and pools. To get a database with the initial data.
yarn init-pools && yarn init-tokens "init-tokens": "ts-node ./src/utils/initServer/init-tokens.ts", "init-pools": "ts-node ./src/utils/initServer/init-pools.ts",
-
Import known addres, to get a sample data base to tag transactions with a known user tag.
yarn init-whales "init-whales": "ts-node ./src/utils/initServer/init-whales.ts",
All these steps are required to start the app. This can take some time, specially on tokens and pools, for pools we scan factories from creation block up to the latest, so pretty much lot of blocks, but if you need a fast way to get and validate pools addresses and information this is really usefull. And same for token decimals and data.
Having the ./.env file created, go to the repo root folder and run:
yarn build-all
- Block Listener:
Start some common but not less important tasks. As blocks information and clear cache tables. Start and wait to get a couple of blocks information.
yarn blocks
- Mempool Listener:
Start a pending mempool listener. Used to get the new txs, filter by dex swap, and decode their input data as needed. This is like the most expensive task, as it must get all the network incoming transactions hashes, get the transactionResponse (details), and classify it.
yarn mempool
- Confirmation Listener.
Start an event listener, filtering by router address and swap event topic. Getting for each confirmed block, all the confirmation events and transaction related, updating the pending transaction status as correpond.
yarn confirmed
- Start Websocket and App Client server.
Connected to the mongo cluster oplog and uses socket.io rooms pattern to serve live data over a token in a dex. Every time a tx its writen or modified in mongo, the oplog will inform that action so we can send updates to the websocket clients subscribed to a token room.
It also expose the client_build app to the public.
yarn websocket
Cheers! 🐶
Jump in...