Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
HOODI_RPC_URL=
MAINNET_RPC_URL=
ETHERSCAN_API_KEY=
DEPLOYER_PRIVATE_KEY=
8 changes: 4 additions & 4 deletions .github/workflows/foundry-gas-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
compare_gas_reports:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
uses: foundry-rs/foundry-toolchain@82dee4ba654bd2146511f85f0d013af94670c4de # v1
with:
version: nightly

Expand All @@ -28,7 +28,7 @@ jobs:
FOUNDRY_FUZZ_SEED: 0x${{ github.event.pull_request.base.sha || github.sha }}

- name: Compare gas reports
uses: Rubilmax/foundry-gas-diff@v3
uses: Rubilmax/foundry-gas-diff@60e763d02526ee3299bd04278cb178d1547b134b # v3
with:
summaryQuantile: 0.9 # only display the 10% most significant gas diffs in the summary (defaults to 20%)
sortCriteria: avg,max # sort diff rows by criteria
Expand All @@ -38,7 +38,7 @@ jobs:

- name: Add gas diff to sticky comment
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
uses: marocchino/sticky-pull-request-comment@v2
uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2
with:
# delete the comment in case changes no longer impact gas costs
delete: ${{ !steps.gas_diff.outputs.markdown }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
submodules: recursive

- name: Install Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '18'
cache: 'npm'
Expand All @@ -32,7 +32,7 @@ jobs:
npm install

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
uses: foundry-rs/foundry-toolchain@82dee4ba654bd2146511f85f0d013af94670c4de # v1

- name: Show Forge version
run: |
Expand Down
7 changes: 1 addition & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ out/
/broadcast/**/dry-run/
/broadcast

# Docs
docs/

# Dotenv file
.env

Expand All @@ -21,6 +18,4 @@ coverage/
report/
lcov.info

.gas-snapshot

test.txt
.gas-snapshot
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
"files": "*.sol",
"options": {
"parser": "solidity-parse",
"parser": "slang",
"printWidth": 80,
"tabWidth": 4,
"useTabs": false,
Expand Down
88 changes: 28 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

:construction: CAUTION: This repo is currently under **heavy development!** :construction:

We strongly advise you to work with **releases tags**. Please, check what version the SSVBasedApp.sol is using by calling `getVersion()`.

 

[![CI Tests](https://github.com/ssvlabs/based-applications/actions/workflows/tests.yml/badge.svg)](https://github.com/ssvlabs/based-applications/actions/workflows/tests.yml)
[![License: GPL-3.0](https://img.shields.io/badge/license-GPL--3.0-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.html)

Expand Down Expand Up @@ -61,94 +65,58 @@ __`❍ forge test`__

 

## 🔨 _Slashing Mechanism_

The `slash` function allows for the reduction of a strategy’s token balance under specific conditions, either as a penalty or to enforce protocol-defined behavior. Slashing can happen in two distinct modes, depending on whether:

**1)** The bApp is a compliant smart contract;

**2)** The bApp is a non-compliant smart contract or an EOA.

### 🧠 Compliant BApp

If the bApp is a compliant contract implementing the required interface `IBasedApp`,

The slash function of the bApp is called: `(success, receiver, exit) = IBasedApp(bApp).slash(...)`

* `data` parameter is forwarded and may act as a proof or auxiliary input.

* The bApp decides:

* Who receives the slashed funds by setting the `receiver` fund, it can burn by setting the receiver as `address(0)`;

* Whether to exit the strategy or adjust obligations;

* If `exit == true`, the strategy is exited and the obligation value is set to 0;

* Otherwise, obligations are adjusted proportionally based on remaining balances, the new obligated amount is set to the previous one less the slashed amount;

* Funds are credited to the receiver in the slashing fund.
## 🔨 _Slashing & Withdrawals Mechanisms_

### 🔐 Non-compliant bApp (EOA or Non-compliant Contract)
[Slashing & Withdrawals](./guides/slashing-and-withdrawals.md)

If the bApp is an EOA or does not comply with the required interface:
[Generation pattern](./guides/generations.md)

* Only the bApp itself can invoke slashing;
## :gear: _Feature Activation_

* The receiver of slashed funds is forcibly set to the bApp itself;
[Feature Activation](./guides/feature-activation.md)

* The strategy is always exited (no obligation adjustment);
## :page_facing_up: _Whitepaper_

* Funds are added to the bApp’s slashing fund.
[Whitepaper](https://ssv.network/wp-content/uploads/2025/01/SSV2.0-Based-Applications-Protocol-1.pdf)

### ⏳ Post Slashing

⚠️ Important: After an obligation has been exited, it can be updated again to a value greater than 0, but only after a 14-day obligation timelock.
## :books: _More Resources_

This acts as a safeguard to prevent immediate re-entry and encourages more deliberate strategy participation.
[Based Apps Onboarding Guide](./guides/bApp-onboarding.md)

### 💸 Slashing Fund

Slashed tokens are not immediately transferred. They are deposited into an internal slashing fund.
## :rocket: _Deployments_

The `receiver` (set during slashing) can later withdraw them using:
### How to Deploy

```
function withdrawSlashingFund(address token, uint256 amount) external
function withdrawETHSlashingFund(uint256 amount) external
```
**2)** Set the environment variables in the `.env` file.

These functions verify balances and authorize the caller to retrieve their accumulated slashed tokens.
**1)** Run the deployment script `DeployAllHoodi.s.sol` defined in `script/`:

 
__`❍ npm run deploy:hoodi-stage`__: verification is done automatically.

## :page_facing_up: _Whitepaper_
### How to Update Module Contracts

[Whitepaper](https://ssv.network/wp-content/uploads/2025/01/SSV2.0-Based-Applications-Protocol-1.pdf)
It is possible to update each one of the three modules: `StrategyManager`, `BasedAppsManager` and `ProtocolManager`.

 

## :books: _More Resources_
It is possible to update multiple modules at the same time.

[Based Apps Onboarding Guide](./doc/bAppOnBoarding.md)
**1)** Go on the Proxy Contract on Etherscan, under "Write as Proxy" call the function:

 
__`❍ updateModules`__: specifying the correct module id and the new module address.

## :rocket: _Deployments_

### How to Deploy
### How to Upgrade the Implementation Contract

**1)** Run the deployment script defined in `scripts/`:
**1)** Go on the Proxy Contract on Etherscan, under "Write as Proxy" call the function:

__`❍ npm run deploy:holesky`__: verification is done automatically.
__`❍ upgradeToAndCall`__: specifying the new implementation address. The data field can be left empty in this case.

__`❍ npm run deploy:hoodi`__: verification needs to be done manually for now.

### Public Testnet
### Public Testnet Hoodi

| Name | Proxy | Implementation | Notes |
| -------- | -------- | -------- | -------- |
| [`BasedApplications`](https://github.com/ssvlabs/based-applications/blob/main/src/BasedAppManager.sol) | [`0x1Bd6ceB98Daf7FfEB590236b720F81b65213836A`](https://holesky.etherscan.io/address/0x1Bd6ceB98Daf7FfEB590236b720F81b65213836A) | [`0x9a09A49870353867b0ce9901B44E84C32B2A47AC`](https://holesky.etherscan.io/address/0x9a09A49870353867b0ce9901B44E84C32B2A47AC) | Proxy: [`[email protected]`](https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/v5.1.0/contracts/proxy/utils/UUPSUpgradeable.sol) |
| [`SSVBasedApps`](https://github.com/ssvlabs/based-applications/blob/main/src/BasedAppManager.sol) | [`<pending>`](https://holesky.etherscan.io/address/0x1Bd6ceB98Daf7FfEB590236b720F81b65213836A) | [`<pending>`](https://holesky.etherscan.io/address/0x9a09A49870353867b0ce9901B44E84C32B2A47AC) | Proxy: [`[email protected]`](https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/v5.1.0/contracts/proxy/utils/UUPSUpgradeable.sol) |

&nbsp;

Expand Down
33 changes: 33 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Release Notes

## [v0.1.1 - fix] 2024-06-17
### Description
- Fix to update the storage references when proposing an obligation
- Bump solidity version
- Create module deployment scripts

## [v0.1.1] 2024-06-xx

### Functions

#### Modified
- `function registerBApp(ICore.TokenConfig[] calldata tokenConfigs, string calldata metadataURI) external`
- `function updateDisabledFeatures(uint32 value) external onlyOwner`

### Errors

#### New
- `error InvalidDisabledFeatures();`
- `error InvalidFeeExpireTime();`
- `error InvalidFeeTimelockPeriod();`
- `error InvalidMaxShares();`
- `error InvalidObligationExpireTime();`
- `error InvalidObligationTimelockPeriod();`
- `error InvalidTokenUpdateTimelockPeriod();`
- `error InvalidWithdrawalExpireTime();`
- `error InvalidWithdrawalTimelockPeriod();`

### Events

#### Modified
- `event BAppRegistered(address indexed bApp, ICore.TokenConfig[] tokenConfigs, string metadataURI);`
25 changes: 25 additions & 0 deletions artifacts/deploy-hoodi-prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"addresses": {
"BAppsModule": "0xCf9894B93C34E9Af8E912EcE7089DCE879740141",
"ProtocolModule": "0xA11022BB79cE25F9bAdfDB426746A4a47a1FD768",
"SSVBasedAppsImpl": "0xba84542de120aa2e94ccb5334a6f21a6a9e78999",
"SSVBasedAppsProxy": "0xc7fCFeEc5FB9962bDC2234A7a25dCec739e27f9f",
"StrategyModule": "0xe9C3AD47E13f5902F97E8ab6f8C63D2414732e8e"
},
"chainInfo": {
"chainId": 560048,
"deploymentBlock": 260728
},
"parameters": {
"disabledFeatures": 0,
"feeExpireTime": 3600,
"feeTimelockPeriod": 86400,
"maxFeeIncrement": 500,
"maxShares": 100000000000000000000000000000000000000000000000000,
"obligationExpireTime": 86400,
"obligationTimelockPeriod": 172800,
"tokenUpdateTimelockPeriod": 3600,
"withdrawalExpireTime": 86400,
"withdrawalTimelockPeriod": 172800
}
}
25 changes: 25 additions & 0 deletions artifacts/deploy-hoodi-stage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"addresses": {
"BAppsModule": "0xdC97f7935Ed6FDcA407dDdE95EB26f7807E52Dc9",
"ProtocolModule": "0x7AadaE0f159eECCe6a4Faad78FFF94e1eab4C540",
"SSVBasedAppsImpl": "0xba84542de120aa2e94ccb5334a6f21a6a9e78999",
"SSVBasedAppsProxy": "0x40d959B95e7c56962D6d388d87921c03734b9C2C",
"StrategyModule": "0xe9C3AD47E13f5902F97E8ab6f8C63D2414732e8e"
},
"chainInfo": {
"chainId": 560048,
"deploymentBlock": 259312
},
"parameters": {
"disabledFeatures": 0,
"feeExpireTime": 3600,
"feeTimelockPeriod": 300,
"maxFeeIncrement": 500,
"maxShares": 100000000000000000000000000000000000000000000000000,
"obligationExpireTime": 3600,
"obligationTimelockPeriod": 300,
"tokenUpdateTimelockPeriod": 300,
"withdrawalExpireTime": 3600,
"withdrawalTimelockPeriod": 300
}
}
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
book/
13 changes: 13 additions & 0 deletions docs/book.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
table {
margin: 0 auto;
border-collapse: collapse;
width: 100%;
}

table td:first-child {
width: 15%;
}

table td:nth-child(2) {
width: 25%;
}
13 changes: 13 additions & 0 deletions docs/book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[book]
src = "src"
title = ""

[output.html]
no-section-label = true
additional-js = ["solidity.min.js"]
additional-css = ["book.css"]
mathjax-support = true
git-repository-url = "https://github.com/ssvlabs/based-applications"

[output.html.fold]
enable = true
Loading