Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
50946fb
feat: add univ4 dependency
0xPilou Mar 18, 2025
61600c6
draft: init LP feature from Lockers
0xPilou Mar 24, 2025
c112255
fix: added uniswapV3 submodules
0xPilou Mar 25, 2025
b16a60a
chore: remove uniV4 dependencies
0xPilou Mar 26, 2025
fcc5d49
chore: update sf protocol dep
0xPilou Mar 26, 2025
df5f782
feat: init draft v3 LP feature
0xPilou Mar 26, 2025
77c984a
feat: updated constructor
0xPilou Mar 26, 2025
d37edf5
feat: update test and deploy (add uni v3 required interfaces)
0xPilou Mar 27, 2025
e129919
chore: add uniswap-swap-router contracts dependency
0xPilou Mar 27, 2025
8526f27
refactor: use IV3SwapRouter interface instead of ISwapRouter
0xPilou Mar 27, 2025
b5c2db1
test: add some assertions
0xPilou Mar 27, 2025
5f4de4c
feat: add increase liquidity function and collect fee function
0xPilou Mar 31, 2025
791dc86
feat: added withdraw liquidity functions
0xPilou Mar 31, 2025
a8b2472
feat: enhance FluidLocker tests with new withdraw liquidity scenarios…
0xPilou Mar 31, 2025
5b61ef6
refactor: change tick constants from private to internal visibility i…
0xPilou Mar 31, 2025
2cc74c6
chore: format/refactor/simplify immutables
0xPilou Mar 31, 2025
618423b
design: SUP in Locker state machine
0xPilou Apr 7, 2025
4a73287
feat: added LP debt logic
0xPilou Apr 7, 2025
d5398ee
test: added test cases
0xPilou Apr 7, 2025
dd51cbf
feat: add liquidity pool controller contract
0xPilou Apr 8, 2025
621b1f5
feat: contract scalability - allow for multiple pools
0xPilou Apr 8, 2025
fa48b3b
fix: updated deploy script - add LiquidityPoolController deployment
0xPilou Apr 8, 2025
0a8fc01
test: refactor tests per new feature
0xPilou Apr 8, 2025
2b3baf2
test: added tests
0xPilou Apr 9, 2025
8deb324
feat: add check on withdraw
0xPilou Apr 9, 2025
f1678fb
feat: handle ETH native asset in case of SUP/WETH pool
0xPilou Apr 10, 2025
747cf8e
fix: added amount parameters to `stake` and `unstake` functions
0xPilou Apr 10, 2025
1961bb0
test: updated per changes
0xPilou Apr 10, 2025
8beaf87
fix: remove interconnection between staking and LPing
0xPilou Apr 10, 2025
7baf9eb
fix: added amount parameters to `unlock` functions
0xPilou Apr 10, 2025
6258b2b
fix: review instant unlock transfer
0xPilou Apr 11, 2025
e7a5dbb
test: updated instant unlock tests per new update
0xPilou Apr 11, 2025
da9f485
design: propose new state machine
0xPilou Apr 11, 2025
5cf733b
feat: added tax free liquidity withdraw feature
0xPilou Apr 22, 2025
0c28b2f
feat: remove multipool support
0xPilou Apr 23, 2025
7b922d6
feat: updated test and deploy script
0xPilou Apr 23, 2025
6198694
feat: added provider pool and tax allocation in `StakingRewardControl…
0xPilou Apr 24, 2025
39413b2
feat: updated locker to support LP Distribution Pool
0xPilou Apr 24, 2025
26b4c54
feat: updated deploy script and test per latest update
0xPilou Apr 24, 2025
58115b2
refator: delete unused contract and associated files
0xPilou Apr 25, 2025
f1e47a2
refator: delete unused contract and associated files
0xPilou Apr 25, 2025
fb71276
feat: WIP refactor SRC initializer
0xPilou Apr 25, 2025
a695f96
feat: added unit distributions in LP op
0xPilou Apr 28, 2025
37bba97
feat: updated locker tests
0xPilou Apr 28, 2025
def3477
feat: updated Fontaine contract / test and deploy scripts
0xPilou Apr 28, 2025
dac1bf9
feat: update Fontaine contract
0xPilou Apr 28, 2025
dcfc5ae
feat: review `_vestUnlock` logic per Fontaine update
0xPilou Apr 28, 2025
edd67af
chore: refactor tests files
0xPilou Apr 28, 2025
d2c9e69
feat: refactor `Fontaine::initialize` test
0xPilou Apr 28, 2025
12c21ef
test: updated Fontaine tests per new design
0xPilou Apr 28, 2025
95b7c8f
feat: update LP GDA pool scaling factor
0xPilou Apr 30, 2025
dcb87f9
tests: updated FluidLocker test cases
0xPilou Apr 30, 2025
02e6704
fix: updated storage layout
0xPilou May 5, 2025
7aca3e6
feat: square root price convertion script
0xPilou May 5, 2025
0a15674
test: improve Fontaine storage layout test
0xPilou May 5, 2025
6382dc2
chore: formatting
0xPilou May 5, 2025
0bdb02f
fix: updated `StakingRewardController` initializer
0xPilou May 5, 2025
1af3e32
chore: re-arrange `IFluidLocker` interface
0xPilou May 14, 2025
ff1d958
fix: added review comments / updated provideLiquidity function and as…
0xPilou May 14, 2025
64e26bc
chore: rename positionExitTimestamp state
0xPilou May 15, 2025
e79ff25
feat: review fee collection and withdraw functions
0xPilou May 16, 2025
881dc40
fix: updated Staking Unit Downscaler from `1e16` to `1e18`
0xPilou May 16, 2025
1150691
chore: rename `providerDistributionPool` into `lpDistributionPool`
0xPilou May 16, 2025
734e3d2
test: added case coverage for terminate unlock
0xPilou May 16, 2025
554921a
test: added testing helper function
0xPilou May 16, 2025
f2c75e2
feat: added convenience getters
0xPilou May 16, 2025
00ee7de
chore: rename taxAllocation components
0xPilou May 16, 2025
1871a2e
feat: update withdrawLiquidity method - user now receives ETH back in…
0xPilou May 16, 2025
bf9d6b4
feat: added `withdrawDustETH` function to locker
0xPilou May 16, 2025
0d89bcf
chore: update subproject commit reference in superfluid-protocol-mono…
0xPilou May 16, 2025
8d42ab3
Merge branch 'dev' into feat/liquidity
0xPilou May 16, 2025
bfe420d
test: added Fuzz Params
0xPilou May 19, 2025
c6d75c1
feat: add minimum unlock amount
0xPilou May 19, 2025
8d5cde1
chore: remove FluidLocker storage layout tests
0xPilou May 26, 2025
fb078d9
fix: updated .gitmodules
0xPilou Jun 4, 2025
6cb9f19
fix: updated submodule configuration
0xPilou Jun 4, 2025
5e22364
feat: update tax distribution mechanism
0xPilou Jun 19, 2025
9b2d4b4
fix: updated Deploy script
0xPilou Jun 19, 2025
87f2b13
fix: updated Fontaine tests
0xPilou Jun 19, 2025
035b9d9
fix: use mulDiv in `_instantUnlock` calculation
0xPilou Jun 19, 2025
d758ccd
fix: updated `FluidLocker` tests per latest design change
0xPilou Jun 19, 2025
2005180
chore: updated comment + adding event
0xPilou Jun 20, 2025
e7669b4
Merge pull request #25 from superfluid-finance/audit/fix-119
0xPilou Jun 20, 2025
84862e1
fix: added `getAvailableBalance` check before providing liquidity
0xPilou Jun 20, 2025
ff8a4f5
Merge pull request #26 from superfluid-finance/audit/fix-177
0xPilou Jun 20, 2025
9d86b36
fix: use `msg.value` instead of the total weth balance when providing…
0xPilou Jun 20, 2025
9b0ef9c
fix: review fuzz param
0xPilou Jun 20, 2025
358737f
Merge pull request #27 from superfluid-finance/audit/fix-44
0xPilou Jun 20, 2025
1f2234a
fix: added tax allocation condition on `FluidLocker::unlock`
0xPilou Jun 20, 2025
e02c67f
Merge pull request #28 from superfluid-finance/audit/fix-50
0xPilou Jun 20, 2025
42b22ef
chore: updated documentation
0xPilou Jun 30, 2025
a98828c
fix: add unlockAvailable modifier to liquidity functions in FluidLocker
0xPilou Jun 30, 2025
f8604a3
Merge pull request #30 from superfluid-finance/audit/fix-207
0xPilou Jun 30, 2025
1c07e10
feat: update cooldown periods for staking and liquidity withdrawal
0xPilou Jun 30, 2025
2a59fa6
refactor: reworded and update user guide for SPR SUP Reserve System
0xPilou Jul 2, 2025
4c02c9e
feat: add Superfluid Sherlock Audit Contest Report
0xPilou Jul 7, 2025
abe505c
Merge pull request #29 from superfluid-finance/audit/fix-review
0xPilou Jul 29, 2025
55c4c7f
feat: added TTE deploy script
0xPilou Sep 3, 2025
34311e2
feat: added python helpers
0xPilou Sep 3, 2025
295f0cf
Merge branch 'dev' into feat/liquidity
0xPilou Sep 3, 2025
90ff2c6
fix: merge conflict typo
0xPilou Sep 3, 2025
9f4405a
chore: remove outdated deploy script
0xPilou Sep 4, 2025
94619b4
feat: added ABI's + script to generate them
0xPilou Sep 4, 2025
379bba3
chore: updated user guide
0xPilou Sep 5, 2025
3c72452
feat: added LP events in Locker contract
0xPilou Sep 5, 2025
3dfe5de
feat: updated `FluidUnstake` event
0xPilou Sep 15, 2025
e3c649a
chore: updated abis
0xPilou Sep 15, 2025
43d164c
[LOCKER] Staking to LPing conversion mechanism (#39)
0xPilou Sep 24, 2025
d6eda53
Merge branch 'dev' into feat/liquidity
0xPilou Sep 24, 2025
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
14 changes: 13 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
[submodule "packages/contracts/lib/openzeppelin-contracts-v4"]
path = packages/contracts/lib/openzeppelin-contracts-v4
url = https://github.com/OpenZeppelin/openzeppelin-contracts

[submodule "packages/contracts/lib/superfluid-protocol-monorepo"]
path = packages/contracts/lib/superfluid-protocol-monorepo
url = https://github.com/superfluid-finance/protocol-monorepo
Expand All @@ -17,3 +16,16 @@
[submodule "packages/contracts/lib/openzeppelin-contracts-upgradeable"]
path = packages/contracts/lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "packages/contracts/lib/swap-router-contracts"]
path = packages/contracts/lib/swap-router-contracts
url = https://github.com/Uniswap/swap-router-contracts
[submodule "packages/contracts/lib/uniswap-v3-periphery"]
path = packages/contracts/lib/uniswap-v3-periphery
url = https://github.com/Uniswap/v3-periphery
[submodule "lib/uniswap-v3-periphery"]
branch = 0.8
[submodule "packages/contracts/lib/uniswap-v3-core"]
path = packages/contracts/lib/uniswap-v3-core
url = https://github.com/Uniswap/v3-core
[submodule "lib/uniswap-v3-core"]
branch = 0.8
Binary file not shown.
151 changes: 151 additions & 0 deletions docs/OPERATIONAL_GUIDELINES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# SPR SUP Locker System - Operational Guidelines

## Overview

This document provides operational guidelines for governance and system administrators of the SPR SUP Locker System. It focuses on the core operational processes for managing ecosystem partner programs, funding campaigns, and maintaining system parameters.

## System Governance Structure

### Contract Ownership

| Contract | Owner | Purpose |
| ----------------------- | ------------------- | -------------------------------------- |
| FluidLockerFactory | Governance Multisig | Locker creation and factory management |
| StakingRewardController | Governance Multisig | Staking rewards and tax distribution |
| FluidEPProgramManager | Governance Multisig | Ecosystem partner programs |
| SupVestingFactory | Governance Multisig | SUP token vesting management |

### Governance Process

- **Program Creation**: Requires governance vote and approval
- **Funding Allocation**: Governance determines funding amounts
- **Parameter Updates**: Governance approval for critical parameters

## Program Management Operations

### 1. Creating New Programs

#### Program Creation & Funding Procedure

**Required Parameters:**

- Program ID: Unique identifier assigned by governance
- Program Admin: Authorized to modify Stack signer & attribute GDA pool units
- Stack Signer: Address authorized to sign reward claims
- Pool Name: Descriptive name for the program
- Pool Symbol: Descriptive symbol for the program
- Funding Amount: Governance-approved SUP allocation
- Duration: Program duration in seconds (typically 90 days)

#### Program Creation & Funding Pre-requisites

- [ ] Governance proposal approved
- [ ] Funding amount defined by governance
- [ ] Duration defined (typically 90 days)

#### Program Creation & Funding Checklist

- [ ] Create Stack Program
- [ ] Execute transaction `FluidEPProgramManager::createProgram`
- [ ] Bootstrap GDA Pool units for the created program
- [ ] Allocate 1 Stack point unit to the Foundation Locker
- [ ] Claim units for the created program on behalf of the Foundation Locker
- [ ] Execute transaction `MacroForwarder::runMacro`
- Params: `FluidEPProgramManager.paramsGivePermission`
- [ ] Execute transaction `FluidEPProgramManager::startFunding`

### 2. Stopping Program Funding (Nominal Scenarios)

#### When to Stop Funding

- **Program Completion**: Starting from 4 days before the set duration

#### Normal Stop Procedure

**Important Consideration:**

Anyone can stop the funding flow to the program pool once the program completion date is reached.

**Stop Program Actions:**

- Stop the funding flow to the program pool
- Calculate compensation for remaining duration

#### Stop Program Checklist

- [ ] Execute transaction `FluidEPProgramManager::stopFunding`

### 4. Canceling Campaign Funding (Degraded Scenarios)

#### When to Cancel Funding

- **Security Issues**: Suspected vulnerability or attack
- **Program Malfunction**: Technical issues affecting users
- **Compliance Issues**: Regulatory or legal concerns
- **Emergency Situations**: Critical system issues
- **Program Setting Mistake**: Program was created with incorrect parameters

#### Emergency Cancel Procedure

**Emergency Cancel Actions:**

- Immediately stop the given program funding
- Return remaining funds to treasury

#### Emergency Cancel Checklist

- [ ] Governance approval for emergency cancellation
- [ ] Execute transaction `FluidEPProgramManager::cancelFunding`

## Parameter Management

### 1. Setting Locker Factory Fee

#### Fee Setting Process

**Governance Approval Required:**

- Fee changes require governance vote
- No minimum fee applies

#### Fee Update Procedure

**Fee Update Steps:**

1. Submit governance proposal
2. Allow community discussion period
3. Execute governance vote
4. Update fee parameter

#### Fee Update Checklist

- [ ] Governance vote completed
- [ ] Execute transaction `FluidLockerFactory::setLockerCreationFee`

### 2. Setting Tax Allocation Split

#### Tax Allocation Overview

The tax allocation determines how penalty fees from token unlocks are distributed:

- **Staker Allocation**: Percentage of penalties distributed to SUP token stakers
- **LP Allocation**: Percentage of penalties distributed to liquidity providers
- **Total**: Must equal 100% (10,000 basis points)

#### Allocation Update Procedure

**Allocation Update Steps:**

1. Submit allocation change proposal
2. Allow community discussion period
3. Execute governance vote
4. Update allocation parameters

#### Allocation Update Checklist

- [ ] Governance vote completed
- [ ] Execute transaction `StakingRewardController::setTaxAllocation`

---

_These operational guidelines provide a structured approach to managing the SPR SUP Locker System with governance-driven decision making and clear procedures for all critical operations._
208 changes: 208 additions & 0 deletions docs/USER_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
# SPR SUP Reserve System - User Guide

## Overview

This document provides a technical overview of the Reserve mechanism.

## Definitions

- [SUP Token](https://forum.superfluid.org/t/superfluid-dao-governance-and-tokenomics/69)
- [SPR](https://forum.superfluid.org/t/superfluid-dao-governance-and-tokenomics/69)
- [Reserves](https://forum.superfluid.org/t/superfluid-dao-governance-and-tokenomics/69)
- [Community Charge](https://forum.superfluid.org/t/superfluid-dao-governance-and-tokenomics/69)

## System Architecture

The SPR SUP Reserve System consists of several key components:

### Core Contracts

1. **FluidLockerFactory** - Creates individual reserve contracts for users
2. **FluidLocker** - Personal reserve where users store and manage their SUP tokens
3. **StakingRewardController** - Manages staking rewards and Community Charge distribution
4. **FluidEPProgramManager** - Administers ecosystem partner reward programs
5. **Fontaine** - Handles gradual token withdrawal through streaming

### Key Features

- **Reward Programs**: Participate in ecosystem partner programs
- **Liquidity Provision**: Provide liquidity to earn rewards & trading fees
- **Staking**: Earn rewards by staking SUP tokens
- **Streaming**: Withdraw tokens over time with reduced community charge
- **Draining**: Withdraw tokens instantly with high community charge
- **Token Locking**: Get yield from your SUP tokens

## Getting Started

### Step 1: Create Your Reserve

Before you can use the SPR SUP Reserve System, you need to create your personal reserve.

**Cost**: A small fee is required to create a reserve (set by governance)

**Result**: You get a unique reserve contract address that only you can control

### Step 2: Participate in Reward Programs

You can participate in reward programs to earn SUP tokens. Use the ecosystem partner apps and claim your SUP flow rate daily.

### Step 3: Lock Your SUP Tokens (optional)

Once you have a reserve, you can lock additional SUP tokens to earn additional rewards

**Benefits of Locking**:

- You can stake them to earn rewards
- You can provide liquidity

## Core Functions

### Reward Programs

The system supports ecosystem partner programs where you can earn SUP tokens.
You can participate in the currently live campaigns on [Superfluid Claim App](https://claim.superfluid.org).
As your participation in the campaigns increases, you are entitled to claim a higher SUP flow rate by claiming it daily.

### Withdrawing SUP Tokens from the Reserve

You can withdraw your SUP tokens in two ways:

#### 1. Drain (High Community Charge)

You can withdraw your SUP tokens instantly. Chosing this option will allow you to get your SUP tokens instantly to your wallet, however you will have to pay a high community charge.

**Community Charge**: 80% of the withdrawn amount goes to stakers and liquidity providers

#### 2. Stream (No Community Charge)

You can withdraw your SUP tokens gradually. Chosing this option will allow you to get your SUP tokens streamed to your wallet over 12 months.

### Staking

Staking allows you to earn rewards from the community charges collected when other users withdraw their tokens.

#### How to Stake

**Requirements**:

- You must have available SUP tokens in your Reserve

**Note**: After staking, there's a 30-days Minimum Staking Period before you can unstake
**Note**: The 30-days Minimum Staking Period is reset at every staking event
**Note**: As staked SUP remain in your Reserve, delegation power is unchanged

#### How to Unstake

**Requirements**:

- 30-day cooldown period must have elapsed

#### How to Claim Staking Rewards

Staking rewards are accrued directly to your Reserve. You do not have to claim them, however, you may have to stake them to increase your share of the rewards.

### Liquidity Provision

You can provide liquidity to the ETH/SUP Uniswap V3 pool to earn trading fees and a share of the community charge collected when other users withdraw their tokens.

#### How to Provide Liquidity

You can provide liquidity by sending ETH to your Reserve and calling the provide liquidity function.
Every time you provide liquidity a new Uniswap V3 position is created. The corresponding NFT is stored in your Reserve.

**Requirements**:

- Send the required ETH amount along with the transaction
- Have enough SUP tokens in your Reserve

**Note**: After providing liquidity, there's a 7-day cooldown before you can withdraw your liquidity
**Note**: The 7-days cooldown is position specific (i.e. different positions may have different cooldown end dates)

#### How to Collect Fees

You can collect fees from your liquidity positions at any time. The fees generated from your liquidity position are instantly transferred to your wallet.

#### How to Withdraw Liquidity

You can withdraw your Reserve's Uniswap V3 position either partially or fully.

**Requirements**:

- 7-day cooldown period must have elapsed

##### Community Charge-Free Withdrawals (Liquidity Provision)

After providing liquidity for 180 days, you can withdraw your position and get both your SUP and ETH tokens directly to your wallet without paying the Reserve Community Charge.

###### How Community Charge-Free Withdrawals Work

When you provide liquidity to the ETH/SUP Uniswap V3 pool through your Reserve, a timestamp is recorded for that position. After 180 days (6 months) from the initial liquidity provision, you become eligible for Community Charge-free withdrawals.

**Key Benefits:**

- **No Community Charge**: Withdraw your SUP tokens without paying the usual Community Charge
- **Full Value**: Get the complete value of your position without deductions
- **Reward Retention**: Keep all accumulated trading fees and rewards

**Requirements:**

- Position must have been created at least 180 days ago
- You must be the owner of the Reserve that created the position
- Position must still exist and be active

**Important Notes:**

- The 180-day timer starts from when you first provide liquidity to a position
- Each position has its own independent 180-day timer
- Community Charge-free withdrawal only applies to the SUP tokens in your liquidity position, not to staked tokens
- You can still collect trading fees at any time without affecting the Community Charge-free withdrawal eligibility

**Example Timeline:**

1. **Day 0**: Provide liquidity to ETH/SUP pool
2. **Day 1-179**: Collect trading fees, position not eligible for Community Charge-free withdrawal
3. **Day 180+**: Position becomes eligible for Community Charge-free withdrawal
4. **Any time after Day 180**: Withdraw your SUP tokens directly to your wallet without paying the Community Charge

## Token Management

### Available Balance

Your available balance is the amount of SUP tokens you can use for:

- Staking
- Providing liquidity
- Withdrawing from the reserve (Drain or Stream)

### Staked Balance

Your staked balance represents tokens that are earning staking rewards but cannot be used for other purposes until unstaked.

### Liquidity Balance

Your liquidity balance represents the size of all your Reserves' liquidity positions in the ETH/SUP pool.

## Important Considerations

### Security

- Only you can control your Reserve
- All operations on your Reserve require your signature

### Fees and Community Charge

- **Reserve Creation**: One-time fee set by governance
- **Draining**: 80% community charge
- **Streaming**: Variable community charge based on duration

### Limitations

- **Minimum Withdraw Amount**: 10 SUP tokens
- **Stream Period**: 365 days
- **Minimum Staking Period**: 30 days after last staking event
- **Liquidity Provision Cooldown**: 7 days after providing liquidity
- **Liquidity Provision Community Charge-free withdrawal**: 180 days after providing liquidity

---

_This guide covers the main user interactions with the SPR SUP Reserve System. For technical details and contract specifications, refer to the contract source code and interfaces._
Loading