Recently, I came across bots doing arbitrage on Solana. Was reading about wormhole hack and how it created great opportunities for bots to make free money. Note that the wormhole hack was a long tail event. In general, arbitrage is a very competitive space and needs constant improvements in strategy.

Misaka wrote a detailed analysis on bots which made money in the “Golden 30 mins” just after the hacker dumped stolen ETH into Solana AMM pools. Quoting from the post

There was $13 million arbitrage profit in 30 mins.

In this post, we are going to look at a few bots that made money that day and try to figure out how they work.

Transaction fees on Solana => 0.000005 SOL, at time time of writing this post 1 SOL = 88$

Let’s look at some basic terminology which will be used in later analysis

Cyclic Arbitrage

Cyclic arbitrage is a trade combination in which you end up with the same currency with which you started. For example: you bought SOL with USDC from a pool and sold the same SOL in another pool for USDC such that you ended up with more USDC than you started with (This scenario is profitable cyclic arbitrage, you can also end up with same or less). Trade path => USDC -> SOL -> USDC.

AMM Pools

Automated Market Makers (AMM) allows digital assets to be traded in permissionless manner by using liquidity pools. Liquidity pool is a smart contract in which people lock their tokens and get LP fees in return. That LP pool is used to facilitate trade in Decentralized exchange. Most of the AMM pools follow the CPMM (Constant Product Market Maker) curve. CPMM curve is represented by function x*y = c, where x and y are assets in the pool and c is a constant. Refer formal specification of CPMM for more details.

Simple diagram that shows arbitrage between USDC->SOL->USDC

Arbitrage in Solana

Arbitrage in Solana

BOT 1

Program account - MEV1HDn99aybER3U3oa9MySSXqoEZNDEQ4miAimTjaW This is a program(Smart Contract) which is deployed on the Solana blockchain.

This program typically receives transactions from 2 accounts.

Account 1 - Gv7oiSP2784zpapUDEgsXUmMW8Z62q465FVAeS4DVifE Account 2 - FDzoKvsArP2LjPYFrP6KNTxn45trxwpu5WMQUYu3kboR

Account 1

Gv7oiSP2784zpapUDEgsXUmMW8Z62q465FVAeS4DVifE The arb trade arising from this account comprises the base token as USDC. We can assume that some bot would be monitoring profitable cyclic arb opportunities starting from USDC and whenever found, makes the transaction using this account. Sample trades:

Account 2

FDzoKvsArP2LjPYFrP6KNTxn45trxwpu5WMQUYu3kboR The arb trade arising from this account comprises the base token as SOL. Sample trades:

BOT 2

Program account - EwZxwieySEeMCCf5E2459CbQyEiAdMTH5ioz9F7VoZ7W This is similar to bot 1. A program deployed on blockchain does the arbitrage transaction. Sample trade:

BOT 3

Account - Gn35xm6fr3ByUJt9aC6ZSzSqzb15AyryhKQmZVoP56Z1 The transactions coming from this account interact with the Jupiter aggregator program with instructions. Instructions have route related info according to which the swap needs to be done. Refer Jupiter Core to understand how to use Jupiter to swap across pools. Sample trades:

BOT 4

Account - J3xKkSUowia5q483zwQmijSfnVocGsWg6duFzQYHL9Nn This bot is similar to Bot 3 and calls the Jupiter aggregator program with instructions to swap. Sample trades:

Other Bots

Attached below are the account addresses which Misaka pointed out in the analysis. These are in text format, so you can copy and search on explorer easily.

Gn35xm6fr3ByUJt9aC6ZSzSqzb15AyryhKQmZVoP56Z1 J3xKkSUowia5q483zwQmijSfnVocGsWg6duFzQYHL9Nn 7aMFk2CEo33Sb9R1a1W6q2HxZ1Z97hbLedDy3ZgHJ4i6 6tW8VxosufrSQBhADuGjjB45BKiMCFuYS63YR7LoizK7 EDMGEpKKGKS7nxpu1gjLmuHHWAmvLNy3BZWDxNC3nhAt 9uAxqcxgGSn9Sft9FmshVoM8CZjmtY5K8d2TSGb75bsn 44PJ3JyrkUvJPDrauYzNAyKV2CB4FHQLKdxf4xX9HyQu Ai5ZrhuwvDiLubv7gNpVS1v9qrKo5kxfARZGtKagkvH9 FDzoKvsArP2LjPYFrP6KNTxn45trxwpu5WMQUYu3kboR AasQTQH9oroodW5vi3uEoDuLyJDVfMz7GWehvisdGmDX J82JTFdFq1frsS7xmvMbN9d7B4t5DSrGSYQqvexMyaNa BFBvSCGA5i83oq9c2R4hGJ5DPcP1HLr8LiRVYvskhYRC FhuJfyiM3hH32qA3NYz1NADnZhu3GzSw4pL1pcfFNW5Y 3pfNpRNu31FBzx84TnefG6iBkSqQxGtuL5G5v9aaxyv8 6hyuGqKQyhAEipjtaquiNHfd1dVjrNT3FzzanXurbK4W Gv7oiSP2784zpapUDEgsXUmMW8Z62q465FVAeS4DVifE 4qfMyvVxAUMWLceyaiWrXxD9mXhZCZ32d16cArQ5MmfX FrJZ4DP12Tg7r8rpjMqknkpCbJihqbEhfEBBQkpFimaS EDEG8c7wqLkyvGVLzHmckZcUFUjxkcHCUvGo58CzH6QR Fsb16JMXAWLML5PTLKVh5Lg1xviVB6ah5p7YYcJEw3g2 3b3zfYBQ61sEicY4bhQMKUvRo9bAxPYAz32uyAP9Cj9u 3heTLmaYyWpQhvfYztMWBhzB9wqRqVgZofYtdw8778gf E6rRQBgWFxJZ1T6Rs66VwkArz6EeTqhX2ULEfCvSeb4o Lion6QppZ6x5VZaawuYUxdhJ7T8J8Hjf56v.7B4G2EGh A4gG7n7aFaBonYgggiF9Ubi4pNLwu4MCG8dWxSdwxUm5 BossNYX1ELRTYZmxb6h2086ktgrXTExdDymEDim65Nq3 CsBGFujsus6Q1K7Leu7tprZcVVMSRDCFH1L6mxGqME3k BFWgBMPyYVT8.71E3HLytUKF9KBgBwBFjni92AiixPC7t 4nHVM1NF5LRptEZWiQn888za51r38dFAsZKCHkuyq1Fx

Misc

Bots on solana do a lot of transactions and most of them fail as they don’t end up with profit. They can afford it due to transaction fees being very less i.e 0.000005 SOL. New folks can enter the arb scenario to test the waters as transaction fees are very less. For new folks with very little capital to spare, it is not possible on Ethereum due to very high tx fees. I did some fee calculation for a bot account (Gn35xm6fr3ByUJt9aC6ZSzSqzb15AyryhKQmZVoP56Z1) this bot spent ~4.8 SOL as transaction fees for ~961_400 transactions. Haven’t calculated the profit but it would easily be in millions. You can use fees.solar to find fee stats of any solana account.

Fees Solar stats

Fees Solar stats

FAQs

  • How to find the optimal input for arb trade? Refer the math explained in the README file of this repo amm-arbitrageur

References