A simple implementation of a root finding algorithm RMM-01 using the Newton-Raphson method. This was done to test out the Solstat library.
Modern CFMMs like RMM-01 implement more complicated trading functions that have variables that dynamically change such as volatility and time to expiry.
Since RMM-01 is a non-linear function that must equal 0. We can quickly solve for liquidity L
, the denominator that normalizes the reserves to ensure F(L) = 0.
A more through explanation of how Newton's method works can be found in my tweet.
$ forge build
$ forge test
$ forge fmt
$ forge snapshot
$ anvil
$ forge script script/deployRootFinder.s.sol:DeployRootFinder --rpc-url <YOUR_RPC_URL> --broadcast --private-key $PRIVATE_KEY
$ cast <subcommand>