• Stars
    star
    113
  • Rank 310,115 (Top 7 %)
  • Language
    Solidity
  • License
    GNU Affero Genera...
  • Created over 2 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Portfolio is an automated market making protocol for implementing custom strategies at the lowest cost possible.

Beta: Portfolio is experimental software. Use at your own risk.

Portfolio by Primitive

PRs Welcome Twitter Badge

Portfolio is an automated market making protocol for implementing custom liquidity distribution strategies at the lowest cost possible.

Table of Contents

Overview

Portfolio is an automated market making protocol for creating custom liquidity distribution strategies at the lowest cost possible. Each pool in Portfolio can be created with a default strategy or custom strategy that defines a trading function, determining the available prices offered by the provider's liquidity. These pools all exist within the single Portfolio smart contract resulting in significantly lower gas costs for liquidity providers and swappers.

Read the local docs, hosted docs docs.primitive.xyz, or the formal specification for more information.

Deployments

Canonical Cross-chain Deployment Addresses

Contract Canonical cross-chain address
Portfolio 1.3.0-beta 0x82360b9a2076a09ea8abe2b3e11aed89de3a02d1
Portfolio 1.4.0-beta n/a
Portfolio 1.5.0-beta 0x0000a37Fd680Ab248119b448545eF72C51Bf7530

Deployments by Chain

Network Portfolio 1.3.0-beta Portfolio v1.4.0-beta Portfolio v1.5.0-beta
Ethereum 0x82360b9a2076a09ea8abe2b3e11aed89de3a02d1 n/a 0x0000a37Fd680Ab248119b448545eF72C51Bf7530
Base n/a n/a n/a
Sepolia 0x82360b9a2076a09ea8abe2b3e11aed89de3a02d1 n/a n/a
Network PortfolioRegistry v1.5.0-beta
Ethereum 0x42776F58b6BC63492E0b7A7a937D1138DF716670
Network PositionRenderer v1.5.0-beta
Ethereum 0xdDA01E1d7684Cc35e6a3A5803736D32d012B8C99

Security

Visit Primitive Security to view a comprehensive overview of the security initiatives of Portfolio.

Audits

Security Firm Date Review Time Status Final Commit w/ Fixes
ChainSecurity 2022-05-31 8-weeks Completed c6f692f41c1d20ac09acb832923bd46500fd8e06
Trail of Bits 2023-01-31 8-weeks Completed n/a
Spearbit #1 2023-03-31 5-weeks Completed tag/v1.1.0-beta
Spearbit #1 Extension 2023-05-12 2-weeks Competed 36e9efa28332fa03f6d5910edda2fec2f5937190
Spearbit #2 2023-07-78 2-weeks Completed tag/v1.4.0-beta-spearbit-2023-08-complete

Install

To install locally and compile contracts:

[Required] Foundry. Source.

If not installed, run the following:

# First install foundryup
curl -L https://foundry.paradigm.xyz | bash

# Restart terminal or reload `PATH`, then run foundryup
foundryup

[Required] Install Deps

forge install

Usage

Testing
FOUNDRY_PROFILE=test forge test
Building
FOUNDRY_PROFILE=optimized forge build --skip test
Coverage

[Optional] Install coverage gutters vs code extension.

Then run this to generate a coverage report:

forge coverage --report lcov

Install Artifacts via NPM

To install the artifacts to use in your own project:

npm install @primitivexyz/portfolio

Documentation

Hosted

Visit Primitive Documentation to view the hosted documentation for Portfolio.

Local

Autogenerated documentation:

Generated from the natspc of the contracts.

FOUNDRY_PROFILE=default forge doc --build --serve --port 4000

Written documentation:

[Required] Rust & Cargo

If not installed, follow the rust installation instructions.

[Required] Mdbook

If not installed, run the following:

cargo install mdbook

Build and serve

cd docs
mdbook serve --open

Resources

Contributing

Important:

  • This codebase uses the FORGE formatter. This is not prettier. If you have not already, make sure if you use vs code that the formatOnSaveconfig variable uses forge fmt instead of prettier.
  • Setup the proper settings using this guide: forge fmt for formatOnSave vscode.

When making a pull request:

  • All tests pass.
  • Code coverage does not change.
  • Code follows the style guide:
    • Follows Primitive styling rules.
    • Run forge fmt.
    • Code is thoroughly commented with natspec where relevant.
  • If making a change to the contracts:
    • Gas snapshots are provided and demonstrate an improvement (or an acceptable deficit given other improvements).
    • New tests for all new features or code paths.
  • If making a modification to third-party dependencies, yarn audit passes.
  • A descriptive summary of the PR has been provided.

Copyright

AGPL-3.0 © 2023 Primitive Bits, Inc.

More Repositories

1

arbiter

A blazing-fast Ethereum sandbox that lets developers orchestrate event-driven simulations.
Rust
669
star
2

hardhat-marmite

🥘 Hassle-free Hardhat plugin to compare gas cost among different Solidity code snippets.
TypeScript
196
star
3

primitive-dodoc

☄️ Zero-config Hardhat plugin to generate documentation for all your Solidity contracts.
TypeScript
135
star
4

rmm-core

Primitive Replicating Market Maker smart contracts
Solidity
131
star
5

solstat

Math library written in solidity for statistical function approximations like the Normal Cumulative Distribution Function.
Solidity
118
star
6

hardhat-foundry

Forkable hardhat & foundry template for thorough evm development.
Solidity
87
star
7

soulbound

Implementation of a non-transferrable NFT using non-financial incentivization.
Solidity
85
star
8

rmms-py

Python simulator to test implementation of the RMMS paper results.
Python
55
star
9

RMM01-Simulations

RMM-01 Simulations
Python
50
star
10

arbiter-template

Minimal template for simulating contracts with arbiter.
Rust
45
star
11

v1-contracts

Primitive protocol solidity contracts.
Solidity
43
star
12

rmm-manager

Manager and Routing smart contracts for Primitive RMM
Solidity
34
star
13

univ3-kit

An open simulation for Uniswap V3 contracts
Rust
34
star
14

sybil-detection

Python
31
star
15

open-research-questions

This is a collection of open research questions in the DeFi mechanism design space pertinent to the Primitive R&D Team. This serves as a public forum and is open to discussion and changes amongst the broader DeFi research and development community.
26
star
16

excalibur

Excalibur
Rust
21
star
17

rmm-math

Typescript math library for cumulative distributions, black-scholes, and the RMM trading function.
TypeScript
21
star
18

proto-sim-portfolio

Prototype risk modeling simulation for Portfolio using Arbiter.
Rust
20
star
19

DFMM

Smart contracts of the DFMM protocol
Rust
18
star
20

rmm-ethers

Library for interacting with RMM protocol through ethers.js.
TypeScript
15
star
21

aika

Discrete event simulator built in Rust 🦀
Rust
13
star
22

Topological-Data-Analysis

This repository is for topologic and geometric data analysis.
Python
13
star
23

m3-rs

Simple rust interface to get derived analytical information of algorithmic market making models (M3).
Rust
12
star
24

portfolio_simulations

Moving to the new Arbiter framework to test Portfolio.
Rust
10
star
25

rmm-sdk

Typescript based entity classes and transaction builders for the rmm-core and rmm-periphery smart contracts.
TypeScript
10
star
26

rmm-examples

Solidity
10
star
27

portfolio-rs

SDK for the Portfolio protocol written in rust.
Rust
9
star
28

DisputeGameSimulations

Rust
9
star
29

v1-connectors

Smart contracts that connect Primitive V1 to other Ethereum protocols and standards.
Solidity
9
star
30

CFMMRouter.py

Python implementation of CFMMRouter.jl
Python
9
star
31

visualization-rs

This is a collection of math and plotting tools for us to use for visualizing data.
Rust
8
star
32

rmm-docs

Primitive and RMM Protocol Documentation - Crypto Derivatives without Counterparties
JavaScript
7
star
33

fvm.ts

TypeScript
4
star
34

pool-analytics

Jupyter Notebook
4
star
35

v1-interface

An open-source interface for the Primitive protocol.
TypeScript
4
star
36

dagger

A lightweight interface for the DFMM smart contracts
TypeScript
4
star
37

Research

Research papers and repository directory
3
star
38

v1-sdk

An SDK for the Primitive Protocol.
TypeScript
3
star
39

portfolio-ts

Minimal toolkit for building TypeScript based applications for Portfolio by Primitive.
TypeScript
3
star
40

Arbitrum-Transaction-Data-Analysis

This repository is for transaction data analysis on the the Arbitrum Network
3
star
41

amm-auction

Solidity
3
star
42

portfolio-examples-solidity

Solidity
3
star
43

arbmod

git submodule for arbiter
Solidity
3
star
44

v1-subgraph

A graph for the Primitive Protocol.
TypeScript
3
star
45

dfmm-indexer

Indexer for the DFMM protocol
TypeScript
3
star
46

security

All security reports for Primitive products and protocols.
2
star
47

discord-bot

TypeScript
2
star
48

rmm-core-dapptools

Rmm protocol core contracts in dapptools testing environment.
Solidity
2
star
49

arbiter-dispute-game

TeX
2
star
50

brand

Primitive's brand assets.
2
star
51

v1-amm-spec

Derivative focused AMM for the Primitive Protocol.
Solidity
2
star
52

arbiter-portfolio-sim

Migration from old middleware to new.
Solidity
1
star
53

rmm

Solidity
1
star
54

nugu

Solidity
1
star
55

fee-generation-py

Python
1
star