Serum markets

What a day. Last night I watched Free Guy with Elder, and showed her a bit of Ready Player One before I made her go to bed. I stayed up a bit too late. This morning I got up fairly early and finished up some things I was working on last night. I had been reconfiguring the exchange’s API/indexer. It runs behind Nginx’s Unit, and I wanted to have a process running on a test branch while I made sure the new configuration things were working like they were supposed to. I finished that up this morning in time to do my Sunday 9AM Perpetual accounting.

This week was pretty flat. BTC was negative, and I only made $150 on the ETH side. I rolled that into a 10x position. I usually don’t mind not making money on the funding rate if the price is going up. BTC was up 13% on the week, ETH was down less than five dollars.

I spent most of the day working on working through my exploration of Serum markets on Solana. It’s been quite the battle, trying to figure out how to run JavaScript or TypeScript and make it work with these other programs that I’ve been using. So basically I’m trying to look at how the Solana explorer works, how it’s able to parse certain transactions, and figure out how I can do the same. I was unable to just write a JS script that could import it, as it’s not a module, so it’s been a lot of trial and error. Most of it is TypeScript, so I’ve been trying to do that, which is an entirely different beast than I’ve been used to. I had a really hard time trying to get a script to run, so I was hoping to just start with the actual explorer React code and rip out everything that I didn’t need. I mean I will need to make this an app at some point, after all, but I couldn’t get it to compile.

The TypeScript page was helpful in that it led me to Gluegun, which allows one to write Javascript CLIs. I had a bit of trouble getting Yarn’s bins to work, but I fixed my path and was able to get my script to run through the CLI. Now it’s time to start digging really deep in the explorer’s code to figure out how it determines whether a transaction is a Serum one, hopefully from there I can figure out what the hell is happening with each instruction. Hopefully it will give me enough information that I can replay the history and actually see what trades occured.

I’m probably over optimizing already, but I’m guessing that I’ll need to log the transactions somewhere to keep from blowing up my RPC calls. The market I’m looking at has just over two thousand transactions, but basically I’d want to grab them, a thousand at a time, and start from the market init call, and then walk through all the order placement stuff. I just hope I don’t have to simulate the internal state of the orderbook. It would be a pain, but I have the Rust code for the market itself if I need to. My fear is that I’ll have to keep track of the orderbook myself and figure out when they’ve been matched, but I’m still too far from even knowing how to do that.

Still, if I can make something work, I might be able to sell this thing to Step.Finance or someone like that. It would probably be a lot easier to look for transactions for a single wallet and compute the cost basis just by looking at the token accounts associated with that pubkey. It’s probably actually a much easier problem to solve. Much smaller set of transactions that one would have to look at, hopefully. Now that I know how to get all the transactions associated with an addresses, we can parse those for the Serum ones, and figure out what went in and what came out.

So I’ve got another hour before bed. Tomorrow I have an update for SAIAdao, and Missus has a work holiday.

Leave a Reply

Your email address will not be published.