BIA: 3rd Fastest on a Raydium Pool
· solana, jito, mev, typescript, redis
I put a call to getNextScheduledLeader() in BIA because I wanted to send a transaction at the right moment. The first time I measured it, the answer took about 2.1 seconds. A Solana slot was roughly four-tenths of a second. While the bot was asking whose turn it was, about five turns went by.
I built BIA in TypeScript over six weeks in early 2024. She watched new Raydium pools and tried to buy as they opened. In the pools I watched she was usually somewhere around the tenth to fifteenth buyer. The best position I saw was third. That was a place in line. I didn’t collect a network-wide benchmark.
Minutes to get ready
Some Raydium pool-creation transactions announced an opening time minutes in advance. BIA could read the creation log, check the pair and prepare the pool accounts while she waited. I kept a set of transaction signatures she’d already seen after duplicated notifications started producing duplicated work. Raydium AMM
The early version fetched more data than it needed. Many of those accounts had addresses I could derive locally from the market ID. That left three network reads for the market and the two mints. I also moved the scheduler from whole seconds to milliseconds. A whole second of rounding was a substantial part of the wait I was trying to remove.
February 14, crossing out the loop
My first sender asked a block engine about the next leader and waited until the leader was near. Checking all four regions took about eight seconds in an early measurement. After the process had warmed up the single lookup was closer to 200 milliseconds, still a noticeable fraction of a slot.
On February 14 I removed the wait and sent the same signed bundle to four regional engines. The important word there is same. Four copies of one signed transaction can produce one confirmed purchase. Four workers signing independently are a different design.
That evening’s notes put buys at roughly one to three seconds and sells at three to four seconds after opening. I made several changes that week. I could time the whole build, but I couldn’t assign the improvement to one change.
February 15, one listener
At first each running copy watched the chain, parsed the same creation and derived the same keys. I moved that work into one listener and published the pool keys and opening time to workers over Redis. A second channel handled pools that were open by the time we found them. Redis Pub/Sub
The exit loop had a smaller timing bug. It checked the balance every half-second and was supposed to give up after ten tries. I’d forgotten to clear the interval on failure. A pool could be long over and the bot would still be waking up for it.
The branch that stayed in the repo
In March I had an experimental branch that listened for pending pool creations. It never shipped. Jito shut down its mempool service on March 8, and I parked the branch.
When I read those six weeks of notes now, the number I remember is 2.1 seconds. It was an ordinary network call, placed at the one point in the program where I had no time to spare.