Skip to content

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

License

Notifications You must be signed in to change notification settings

primitivefinance/portfolio

Repository files navigation

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.