The v2 Factory source code has been made public on Github. This suggests the launch of the factory is like soon. In some cases Curve makes the repository public concurrent with launch. Looking over their usual deployment addresses (lookin’ at you, 0xbabe) there’s no sign of any contract launches. Could be deployed from a new address to give more time to make sure it works, we’ll have to see.
For now, let’s review the code and see what we can expect from l'avenir de la France.
Right up top, we see Vyper 0.3.1 — chad Curve devs testing in prod! Vyper 0.3 was only released in November, with an explicit warning that you may want to test drive it a bit before launching. Fortunately, this implementation looks fairly anodyne — like the other registries and factories it’s not built to hold funds, and it could be upgraded easily enough in the registry if there was any error.
Otherwise, the most interesting thing here is the look at the CryptoPool interface. The CryptoPool is where the real magic happens. Here we see TriCrypto’s launch has been successful enough for its parameters to be codified — A, gamma, price oracles, half lives.
We also observe the exchange function contains a flag for using raw Ethereum. TriCrypto used wrapped Ethereum, but since then the ETH pools have been handling native ETH. I occasionally hope some devious genius will launch a wETH-ETH pool using the existing factory, for the sole purpose of tidying up a few lines of code here and there. However, it’s unlikely such a pool would be plausibly competitive in the Curve Wars, so there’s little real world use case for it.
Of note among the events is the coins[2] array — the crypto pool factory will support a pair of coins. Vyper’s new dynamic arrays could theoretically have allowed for more, but it makes sense to keep it simple for launch.
Also the event for LiquidityGaugeDeployed demonstrates the factory will be all-in-one for deployments, keeping gauges streamlined.
A lot of the constants are much of what we’ve seen. Like previous factories, Curve maintains the clever use of the bitwise_xor to provide the mappings for quick lookups. N_COINS constant here confirms pools of pairs of coins. WETH is hardcoded to enable ETH processing capabilities, mostly used to lookup the pool’s ETH index.
Here’s the other side of the bitwise_xor used for lookups. Notice the markets is a list, so it seems there’s no restriction on duplicate pools with the same coins in them if you so desire.
Following this is a bunch of getter functions we skip over, until we get to the robust deployment function.
The meat of the factory is the deployment capabilities. Mostly we observe a ton of checks on the various parameters within range. This higher level math is where Curve excels. Months of testing various pools has refined these functions. While they may seem opaque, our king has provided a wonderful tool to visualize how these interact.
Otherwise, there’s very few restrictions on anything. No decimals > 18 digits, exactly two ERC20 tokens, but otherwise anything goes. From prior pool launches I had thought the pool may require ETH as a pair (ie CRVETH, CVXETH, SPELLETH), but the conftest is run on a USD / EUR pair so it really is anything goes. You can look deeper into the CurveCryptoSwap2ETH.vy file if you want to get a better look at how it elegantly juggles WETH/ETH.
Gauge deployments, check.
Finally, the admin functions are those which get reserved to the DAO, which are transferring ownership and setting fee receivers and gauges.
All in all, looks sleek. The repo also contains extensive tests you can use to walk through the functionality. It runs nicely in a forked mainnet, with no issues launching the factory and interacting with it.
The CurveCryptoSwap2ETH.vy is where the real magic happens. I thought to do a similar walkthrough of this file, but it’s 1300 lines of dense math that couldn’t be knocked out in my self-imposed deadline to publish weekdays. Nonetheless, it’s beautiful and well worth a look if you enjoyed this factory tour.
As mentioned at the outset, the factory is lower stakes than the underlying CryptoPools it launches. The factory is easily comprehended by anybody, understanding the nuances of the underlying CryptoPool mathematics is the tough part. Fortunately CryptoPools now have months of battle testing, and have performed resiliently despite major crypto market fluctuations.
The ability for anybody to deploy a pool quickly and get it fast tracked into the Curve ecosystem is the start of an exciting new era for Curve. Nearly any transaction can be routed through the networks to be built. Much of the complexity in the next stage of Curve’s growth will come from optimizing routing among different pools, as the traveling salesperson problem remains a nuisance for mathematicians who hold P <> NP. Fortunately the Curve team has a history of making complex math look easy.