This repository is for the core contracts of the Primitive Protocol's Automated Market Maker named "RMM-01".
These are low-level contracts which are designed to be interacted through higher-level smart contracts.
The low-level contracts are missing important checks that should be implemented by smart contracts. Keep this in mind when interacting with them.
This repository has a $250,000 bug bounty through Immunefi. Details are on their website https://immunefi.com/bounty/primitive.
The contract documentation is hosted here: Primitive Docs
The math and smart contract specification is detailed in this paper: RMM-01
This repository has two contracts: PrimitiveFactory and PrimitiveEngine
The Factory contract is responsible for deploying new Engine contracts.
The Engine contract contains two tokens in immutable state called risky and stable. Pools can be created for these tokens within the Engine contract.
Running tests using the default yarn test
will run it through hardhat, it takes approximately 10 minutes on a good CPU.
The testing environment is unique. Make sure that yarn typechain
has been run first, or else there could be typescript compilation issues.
The test:fast
script makes use of the parallel
tag, which will take up a considerable amount of CPU power. It makes the tests run faster.
In the /test/shared/poolConfigs.ts
file is an array of different curve parameters. Each of these pools will go through the entire test suite.
Note: When running tests with parallel, the swap
tests will not be logged. If the tests are frozen, it means the swap tests are the last tests to be run.
yarn compile
yarn typechain
yarn test
yarn test:fast
yarn compile:all
All audits are located in the audits/
folder.
The core contracts are audited by three teams: Chainsecurity, ABDK Consulting, Sherlock, and Dedaub.
To be deployed...
The Engine contract holds funds and has no access control.
The Factory contract has an owner variable, but there are no functions on the factory which only the owner can call. All the factory's public functions can be called by anyone.