Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2 update #38

Merged
merged 50 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
c3b5c72
fist commit - setup echidna
beirao Feb 17, 2024
32e4bfa
Making forge tests easily configurable in terms of number of levels.
beirao Feb 17, 2024
15a1677
added gas snapshots for 8, 100 and 300 levels
beirao Feb 17, 2024
dd39b84
gas 8 levels snapshot updated
beirao Feb 17, 2024
bb7d50d
Reliquary.levelOnUpdate() is now dichotomous + test
beirao Feb 17, 2024
bb1eec4
Gas snapshot scalable version
beirao Feb 17, 2024
98f6d2c
Scalable _poolBalance() implemented + test passing
beirao Feb 17, 2024
e8436c0
fix shadowing var
beirao Feb 18, 2024
62dfaae
Removed gamified logic
beirao Feb 18, 2024
62f1e95
Initial curve logic removed and replaced with constant emission rate
beirao Feb 18, 2024
fb3c517
Great cleanup
beirao Feb 18, 2024
ad70e19
Curve logic implemented
beirao Feb 19, 2024
237c7dc
Fully continuous curve + typing uniformity
beirao Feb 20, 2024
ecb6241
Curve implementation simplified
beirao Feb 20, 2024
e214c29
Prettier run + readme update
beirao Feb 20, 2024
123cbd5
✅ Rolling reward adapted to the Reliquary Curve version.
beirao Mar 7, 2024
145a591
some test done + withdrawAndHarvest fixed
beirao Mar 8, 2024
9f140b1
update deploy script
Zokunei Mar 9, 2024
d4ee81a
upgrade to 0.8.23, Created ReliquaryLogic, Clean up, Main develpment …
beirao Mar 11, 2024
f5a0a27
Code clean-up and simplification
beirao Mar 16, 2024
fb75798
Some natspecs added.
beirao Mar 18, 2024
61416b8
Small changes
beirao Mar 28, 2024
5389da9
Merging the deployment script into the working branch.
beirao Mar 28, 2024
d588c99
oz V5 update
beirao Mar 30, 2024
7b5c961
soft gas optimizations
beirao Mar 30, 2024
e157ed0
PolynomialPlateauCurve added and partially tested
beirao Mar 31, 2024
f99980e
PolynomialPlateauCurve simplification
beirao Apr 1, 2024
7e87f32
harvest gas optimization
beirao Apr 1, 2024
cc5a127
poolId uint8
beirao Apr 1, 2024
76ec84c
small refactor
beirao Apr 1, 2024
d209274
fully gas optimized
beirao Apr 1, 2024
a3f686e
small refactor
beirao Apr 1, 2024
158ee9e
small gas optimization on onReward
beirao Apr 4, 2024
bdbcc13
Cergyk audit - H1 fix
beirao Apr 10, 2024
f8767e5
Cergyk audit - M2 fix
beirao Apr 10, 2024
f2de3f7
Cergyk audit - M3 fix
beirao Apr 10, 2024
5477f2a
Cergyk audit - infos fix
beirao Apr 10, 2024
0566e40
Cergyk audit - gas fix
beirao Apr 10, 2024
c11766a
H1 poc test added
beirao Apr 10, 2024
77cfe9a
totalRewardsSent removed
beirao Apr 11, 2024
45fff8b
Cergyk audit - M1 & L2 fix
beirao Apr 11, 2024
fea3e4c
clean up
beirao Apr 13, 2024
b79a45e
readme V2 update
beirao Apr 15, 2024
1ff395e
readme V2 update bis
beirao Apr 15, 2024
3de1684
cleaner curve overflow check
beirao Apr 15, 2024
653e991
totalIssue removed => replaced by events
beirao Apr 15, 2024
f262a1e
Cergyk audit - L3 fix
beirao Apr 16, 2024
faedaae
fmt
beirao Apr 16, 2024
6b18415
audit added
beirao Apr 16, 2024
68f411c
remove image from NFTDescriptor contract
Zokunei May 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
ETHERSCAN_API_KEY=
ALCHEMY_API_KEY=abc
ETHERSCAN_API_KEY=
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ types
forge-cache
out
broadcast

# Echidna
corpus/
**/crytic-compile
**/crytic-export
**/corpus
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
branch = release-v4.8
branch = v5.0.2
[submodule "lib/v2-core"]
path = lib/v2-core
url = https://github.com/uniswap/v2-core
Expand Down
90 changes: 83 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# Reliquary
# Reliquary V2

![Reliquary](header.png "Reliquary")

> Designed and written by [Justin Bebis](https://twitter.com/0xBebis_) and Zokunei, with help from [Goober](https://twitter.com/0xGoober) and the rest of the [Byte Masons](https://twitter.com/ByteMasons) crew.
> Designed and written by [Justin Bebis](https://twitter.com/0xBebis_), Zokunei and [Beirao](https://twitter.com/0xBeirao), with help from [Goober](https://twitter.com/0xGoober) and the rest of the [Byte Masons](https://twitter.com/ByteMasons) crew.

---

Reliquary is a smart contract system that is designed to improve outcomes of incentive distribution by giving users and developers fine grained control over their investments and rewards. It accomplishes this with the following features:
1) Emits tokens based on the maturity of a user's investment, separated in tranches.
2) Binds variable emission rates to a base emission curve designed by the developer for predictable emissions.
3) Supports deposits and withdrawals along with these variable rates, which has historically been impossible.
4) Issues a 'financial NFT' to users which represents their underlying positions, able to be traded and leveraged without removing the underlying liquidity.
5) Can emit multiple types of rewards for each investment as well as handle complex reward mechanisms based on deposit and withdrawal.

1. Emits tokens based on the maturity of a user's investment, separated in tranches.
2. Binds variable emission rates to a base emission curve designed by the developer for predictable emissions.
3. Supports deposits and withdrawals along with these variable rates, which has historically been impossible.
4. Issues a 'financial NFT' to users which represents their underlying positions, able to be traded and leveraged without removing the underlying liquidity.
5. Can emit multiple types of rewards for each investment as well as handle complex reward mechanisms based on deposit and withdrawal.

By binding tokens to a base emission rate you not only gain the advantage of a predictable emission curve, but you're able
to get extremely creative with the Curve contracts you write. Whether this be a sigmoid curve, a square root curve, or a
Expand All @@ -18,12 +21,85 @@ random curve, you can codify the user behaviors you'd like to promote.
Please reach out to [email protected] to report bugs or other funky behavior. We will proceed with various stages of production
testing in the coming weeks.

## V2 update notes

1. **Maturity Evolution Curves**: We have replaced the previous level evolution mechanism with curves to provide more flexibility and precision. The available curve options are:
- Linear
- Linear Plateau
- Polynomial Plateau

2. **Scalable 'Level' Number**: The 'Level' number now scales with an O(1) complexity, ensuring consistent performance as the system grows.

3. **Multi-Rewards with Rolling Rewarders**: The V2 update now enables the possibility of multiple rewards with the rolling rewarders.

4. **ABI Simplification**: We have simplified ABI to streamline the interaction between the smart contracts and the user interface.

5. **Gas Optimization**: The V2 update brings a 20% reduction in gas consumption, resulting in lower transaction fees and improved efficiency.

6. **Bug Fixes**: We have addressed bugs identified in the previous version (see audit/ for more details).

7. **Code Clean-up, Formatting, and Normalization**: The codebase has undergone a thorough clean-up, formatting, and normalization process to improve readability and maintainability.

## Installation

This is a Foundry project. Get Foundry from [here](https://github.com/foundry-rs/foundry).

Please run the following command in this project's root directory to enable pre-commit testing:

```bash
ln -s ../../pre-commit .git/hooks/pre-commit
```

## Quick start

### Env setup
```bash
mv .env.example .env
```
Fill your `ETHERSCAN_API_KEY` in the `.env`.

### Foundry
```bash
forge install
forge test
```

### Echidna
```bash
echidna test/echidna/ReliquaryProperties.sol --contract ReliquaryProperties --config test/echidna/config1_fast.yaml
```

## Typing conventions

### Variables

- storage: `x`
- memory/stack: `x_`
- function params: `_x`
- contracts/events/structs: `MyContract`
- errors: `MyContract__ERROR_DESCRIPTION`
- public/external functions: `myFunction()`
- internal/private functions: `_myFunction()`
- comments: "This is a comment to describe the variable `amount`."

### Nat Specs

```js
/**
* @dev Internal function called whenever a position's state needs to be modified.
* @param _amount Amount of poolToken to deposit/withdraw.
* @param _relicId The NFT ID of the position being updated.
* @param _kind Indicates whether tokens are being added to, or removed from, a pool.
* @param _harvestTo Address to send rewards to (zero address if harvest should not be performed).
* @return poolId_ Pool ID of the given position.
* @return received_ Amount of reward token dispensed to `_harvestTo` on harvest.
*/
```

### Formating

Please use `forge fmt` before commiting.

## TODOs

- NFT Desccriptor needs to be ajusted to curve
Loading
Loading