Skip to content

A simple root finding algorithm for RMM-01 in Solidity.

Notifications You must be signed in to change notification settings

robertleifke/root-finder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Root Finder

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.

Build

$ forge build

Test

$ forge test

Format

$ forge fmt

Gas Snapshots

$ forge snapshot

Anvil

$ anvil

Deploy

$ forge script script/deployRootFinder.s.sol:DeployRootFinder --rpc-url <YOUR_RPC_URL> --broadcast --private-key $PRIVATE_KEY

Cast

$ cast <subcommand>

About

A simple root finding algorithm for RMM-01 in Solidity.

Resources

Stars

Watchers

Forks

Packages

No packages published