Home

Awesome

🦣 RMM Examples

License

This repository contains examples showing how to interact with the RMM protocol.

Alternatively, you can use this repository as a base if you plan on building on top of the RMM protocol, as it contains all the necessary setup to run the whole protocol locally.

⚠️ These example contracts are written for educational purposes and were NOT AUDITED. Keep this in mind before using them in production.

🚀 Usage

Clone the repository on your computer:

git clone https://github.com/primitivefinance/rmm-examples.git

Then install the required dependencies:

# Using npm
npm install

# Using yarn
yarn

After that, you can try the other commands:

# Using npm and npx

# Compile the contracts
npm run compile

# Run a test
npx hardhat test ./path/to/the/test.ts

# Style the contracts using Prettier
npm run prettier


# Using yarn

# Compile the contracts
yarn compile

# Run a test
yarn hardhat test ./path/to/the/test.ts

# Style the contracts using Prettier
yarn prettier

📚 Example Contracts

💦 LiquidityManager

This simple example shows how a contract can manage liquidity pool tokens on the behalf of users, allowing them to allocate or remove into different pools. It's a very basic version of the PrimitiveManager contract.

The features of this example are quite basic:

See the code here.

🎁 LiquidityWrapper

The PrimitiveManager contract tokenizes liquidity pool tokens using the ERC1155 standard. This allows significant gas optimizations at a contract level, but adds a little bit of friction when it comes to integrating with other protocols, more used to deal with ERC20 tokens. Luckily, a straightforward solution to this problem is to use a "wrapper" contract.

The specifications of the LiquidityWrapper contract are extremely simple:

See the code here.

🧑‍🍳 PrimitiveChef

Based on the MasterChef created by SushiSwap, this contract is a reimplementation of the code with the support of ERC1155 tokens, the token standard used by the PrimitiveManager.

In a few words, the PrimitiveChef goals are to:

See the code here.

🏗 Building

As mentioned above, if you plan on building on top of the RMM protocol, this repository can be used as a base for your work, as it already contains:

Feel free to remove the examples or any files you don't want to keep to make yourself at home!