⚔️ SIONG@sssionggg
The day after Christmas, we shipped one of our biggest upgrades on the Jupiter aggregator program. The project started around March with steady improvements and ended with a final rewrite on our Jupiter aggregator program. To developers and integrators on top of the program, they probably won’t notice anything, everything is backward compatible (other than the logging change, error codes remain the same). With these improvements and the rewrite, you can see the improvements yourself here:
*Dune only could return the last 240 days*
The graph shows the amount of CUs a Jupiter swap takes (most of it is being used by the underlying swap of any AMM, Meteora/Raydium/etc) over the course of the last year. We started steadily at around 180k CUs per swap and now we are around 100k CUs per swap. Do note that this is just an approximation since there can be many factors that are affecting the CUs being consumed per swap (single-hop vs dual hop, light CU AMM vs heavy CU AMM, etc).
Any on-chain “find_program_address” is bad for CU consumption, that was the first thing we tried to remove. Around late April, we stopped using the ATA program to create the temporary wSOL account. That removed one on-chain “find_program address” call. So, any swap that is with SOL as input or output, it uses less CUs.
Then, instead of using the nice macros conveniently provided by Anchor for event logging, we wrote our custom method that is backward compatible with the Anchor event logging but without the on-chain “find_program_address” call. This helped quite a lot since there could be multiple event calls per swap. This improvement was shipped around early August.
In late August, we went on to improve our Solana version from 1.16 to 1.18 and our Anchor version from the very old 0.27.0 to the latest 0.30.1. Version upgrade was always painful especially when it came to Solana and how our program could be tightly coupled with other programs. We had to upgrade other programs to be on the latest version and went on to upgrade ours. There were some major changes from Anchor 0.27.0 to the latest 0.30.1 but eventually it was worth while for the effort after looking at the CU usage improvement that came with it.
The final improvement was the one that took the longest time since it involved replacing Anchor from the main program with “solana-nostd-entrypoint” (github.com/cavemanloverbo…). This was an entire new rewrite with close to 100% backward compatibility (we dropped a few inactive integrations, no more on-chain transactions). We first had to have the “no-std-entry-point” framework audited (thanks to @cavemanloverboy and @Offside_Labs). Then after the rewrite of the program, we had the aggregator program audited as well. With this upgrade, CPI is a lot cheaper with a lot less CUs. This is important because our aggregator program is basically just a program that CPIs into different programs by our AMM partners. This was shipped the day after Christmas.
Along the way, there were some minor improvements here and there. With the new “solana-nostd-entrypoint” upgrade, it also sets us up for more improvements down the road as well. All in all, CU improvement is important to help our users to land transactions faster and cheaper. Since the Jupiter aggregator program is also used by other products in the Jupiverse (LO/DCA/VA/Perps/Ape.Pro/etc), all these products are also benefited by these improvements as well.
Obviously, this is a team effort. Thanks @PierreArowana and @beeceeman!