Skip to content

Commit 86f8eec

Browse files
authored
Merge pull request #379 from primitivefinance/v1.2.0-beta
V1.2.0 beta
2 parents f6b761a + 2cc5425 commit 86f8eec

48 files changed

Lines changed: 1113 additions & 2637 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,4 @@ jobs:
1717
version: nightly
1818

1919
- name: Run tests RMM01Portfolio
20-
run: FOUNDRY_PROFILE=test forge test --gas-report --match-contract RMM01Portfolio
21-
22-
- name: Run tests RMM02Portfolio
23-
run: FOUNDRY_PROFILE=test forge test --gas-report --match-contract RMM02Portfolio
20+
run: FOUNDRY_PROFILE=test forge test --gas-report --match-contract TestRMM01

.github/workflows/default.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,4 @@ jobs:
2020
run: FOUNDRY_PROFILE=default forge build --skip test
2121

2222
- name: Run tests RMM01Portfolio
23-
run: FOUNDRY_PROFILE=default forge test --gas-report --match-contract TestRMM01Portfolio -vvv
24-
25-
- name: Run tests RMM02Portfolio
26-
run: FOUNDRY_PROFILE=default forge test --match-contract TestRMM02Portfolio
23+
run: FOUNDRY_PROFILE=default forge test --gas-report --match-contract TestRMM01 -vvv

.github/workflows/optimized.yaml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ jobs:
2020
run: FOUNDRY_PROFILE=optimized forge build --sizes --skip test
2121

2222
- name: Run tests RMM01Portfolio
23-
run: FOUNDRY_PROFILE=optimized forge test --match-contract TestRMM01Portfolio
24-
25-
- name: Run tests RMM02Portfolio
26-
run: FOUNDRY_PROFILE=optimized forge test --match-contract TestRMM02Portfolio
23+
run: FOUNDRY_PROFILE=optimized forge test --match-contract TestRMM01
2724

2825
- name: Run invariant tests
2926
run: FOUNDRY_PROFILE=optimized forge test --gas-report --match-contract TestRMM01PortfolioInvariants -vvv

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@ On-chain portfolio management. Optimized for managing risk and liquidity.
66

77
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/primitivefinance/portfolio#contributing) [![](https://dcbadge.vercel.app/api/server/primitive?style=flat)](https://discord.gg/primitive) [![Twitter Badge](https://badgen.net/badge/icon/twitter?icon=twitter&label)](https://twitter.com/primitivefi)
88

9-
## Yellow Paper
109

11-
A technical summary of Portfolio is detailed in the [Yellow Paper](https://www.primitive.xyz/papers/yellow.pdf).
10+
# Portfolio Security
11+
12+
[Visit Primitive Security](https://www.primitive.xyz/security) to view a comprehensive overview of the security initiatives of Portfolio.
1213

1314
## System Invariants
1415

1516
The system is designed around a single invariant:
1617

1718
```
18-
Balance >= Reserve
19+
Actual balance of tokens in contract >= virtually tracked token balance in `__account__.reserves`.
1920
```
2021

2122
Exposed via: `Portfolio.getNetBalance(token)`
@@ -63,7 +64,7 @@ forge test --match-contract TestRMM01
6364

6465
## Resources
6566

66-
- [Portfolio Yellow Paper](https://www.primitive.xyz/papers/yellow.pdf)
67+
- [Portfolio Yellow Paper (Deprecated)](https://www.primitive.xyz/papers/yellow.pdf)
6768
- [RMM in desmos](https://www.desmos.com/calculator/8py0nzdgfp)
6869
- [Original codebase](https://github.com/primitivefinance/rmm-core)
6970
- [solstat](https://github.com/primitivefinance/solstat)
@@ -73,11 +74,12 @@ forge test --match-contract TestRMM01
7374

7475
## Audits
7576

76-
| Security Firm | Review Time | Status |
77-
| ------------- | ----------- | --------- |
78-
| ChainSecurity | 8-weeks | Completed |
79-
| Trail of Bits | 8-weeks | Completed |
80-
| Spearbit | 5-weeks | Completed |
77+
| Security Firm | Review Time | Status |
78+
| ------------------ | ----------- | --------- |
79+
| ChainSecurity | 8-weeks | Completed |
80+
| Trail of Bits | 8-weeks | Completed |
81+
| Spearbit | 5-weeks | Completed |
82+
| Spearbit Extension | 2-weeks | Pending |
8183

8284

8385
## Contributing

contracts/Objective.sol

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: AGPL-3.0-only
2-
pragma solidity 0.8.13;
2+
pragma solidity 0.8.19;
33

4-
import "./PortfolioLib.sol";
4+
import "./libraries/PortfolioLib.sol";
55
import "./interfaces/IERC20.sol";
66
import "./interfaces/IPortfolio.sol";
77
import "./interfaces/IPortfolioRegistry.sol";
@@ -23,17 +23,6 @@ abstract contract Objective is IPortfolio {
2323
bool sellAsset
2424
) internal virtual returns (bool success, int256 invariant);
2525

26-
/**
27-
* @dev Conditional check made before changing `pool.liquidity` and `position.freeLiquidity`.
28-
* @param delta Signed quantity of liquidity in WAD units to change liquidity by.
29-
* @return True if position liquidity can be changed by `delta` amount.
30-
*/
31-
function checkPosition(
32-
uint64 poolId,
33-
address owner,
34-
int256 delta
35-
) public view virtual returns (bool);
36-
3726
/**
3827
* @dev Conditional check before interacting with a pool.
3928
* @return True if pool exists and is ready to be interacted with.
@@ -74,14 +63,12 @@ abstract contract Objective is IPortfolio {
7463
uint256 price
7564
) public view virtual returns (uint256 reserveX, uint256 reserveY);
7665

77-
/**
78-
* @dev Computes an amount of tokens out given an amount in, units are in the token's decimals.
79-
* @param amountIn Quantity to swap in, in native decimals.
80-
*/
66+
/// @inheritdoc IPortfolioGetters
8167
function getAmountOut(
8268
uint64 poolId,
8369
bool sellAsset,
8470
uint256 amountIn,
71+
int256 liquidityDelta,
8572
address swapper
8673
)
8774
public
@@ -90,13 +77,8 @@ abstract contract Objective is IPortfolio {
9077
override(IPortfolioGetters)
9178
returns (uint256 output);
9279

93-
/**
94-
* @dev
95-
* WARNING! Do not rely on this price value. This CAN be manipulated. It is also an estimate that has error.
96-
* Estimates the `price` of a pool with `poolId` given the pool's reserves.
97-
* @return price Estimated quantity of "Quote" tokens per "Asset" tokens in WAD units.
98-
*/
99-
function getVirtualPrice(uint64 poolId)
80+
/// @inheritdoc IPortfolioGetters
81+
function getSpotPrice(uint64 poolId)
10082
public
10183
view
10284
virtual

0 commit comments

Comments
 (0)