Skip to content

Commit 2632bba

Browse files
authored
Merge b66645e into ed16ac0
2 parents ed16ac0 + b66645e commit 2632bba

File tree

107 files changed

+5496
-1250
lines changed

Some content is hidden

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

107 files changed

+5496
-1250
lines changed

.env.sample

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
HOODI_RPC_URL=
2+
MAINNET_RPC_URL=
3+
ETHERSCAN_API_KEY=
4+
DEPLOYER_PRIVATE_KEY=

.github/workflows/foundry-gas-diff.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ jobs:
1010
compare_gas_reports:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v4
13+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
1414
with:
1515
submodules: recursive
1616

1717
- name: Install Foundry
18-
uses: foundry-rs/foundry-toolchain@v1
18+
uses: foundry-rs/foundry-toolchain@82dee4ba654bd2146511f85f0d013af94670c4de # v1
1919
with:
2020
version: nightly
2121

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

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

3939
- name: Add gas diff to sticky comment
4040
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target'
41-
uses: marocchino/sticky-pull-request-comment@v2
41+
uses: marocchino/sticky-pull-request-comment@52423e01640425a022ef5fd42c6fb5f633a02728 # v2
4242
with:
4343
# delete the comment in case changes no longer impact gas costs
4444
delete: ${{ !steps.gas_diff.outputs.markdown }}

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ jobs:
1616
name: Foundry project
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
2020
with:
2121
submodules: recursive
2222

2323
- name: Install Node.js
24-
uses: actions/setup-node@v4
24+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
2525
with:
2626
node-version: '18'
2727
cache: 'npm'
@@ -32,7 +32,7 @@ jobs:
3232
npm install
3333
3434
- name: Install Foundry
35-
uses: foundry-rs/foundry-toolchain@v1
35+
uses: foundry-rs/foundry-toolchain@82dee4ba654bd2146511f85f0d013af94670c4de # v1
3636

3737
- name: Show Forge version
3838
run: |

.gitignore

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ out/
88
/broadcast/**/dry-run/
99
/broadcast
1010

11-
# Docs
12-
docs/
13-
1411
# Dotenv file
1512
.env
1613

@@ -21,6 +18,4 @@ coverage/
2118
report/
2219
lcov.info
2320

24-
.gas-snapshot
25-
26-
test.txt
21+
.gas-snapshot

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{
99
"files": "*.sol",
1010
"options": {
11-
"parser": "solidity-parse",
11+
"parser": "slang",
1212
"printWidth": 80,
1313
"tabWidth": 4,
1414
"useTabs": false,

README.md

Lines changed: 28 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

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

5+
We strongly advise you to work with **releases tags**. Please, check what version the SSVBasedApp.sol is using by calling `getVersion()`.
6+
7+
 
8+
59
[![CI Tests](https://github.com/ssvlabs/based-applications/actions/workflows/tests.yml/badge.svg)](https://github.com/ssvlabs/based-applications/actions/workflows/tests.yml)
610
[![License: GPL-3.0](https://img.shields.io/badge/license-GPL--3.0-blue.svg)](https://www.gnu.org/licenses/gpl-3.0.html)
711

@@ -61,94 +65,58 @@ __`❍ forge test`__
6165

6266
 
6367

64-
## 🔨 _Slashing Mechanism_
65-
66-
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:
67-
68-
**1)** The bApp is a compliant smart contract;
69-
70-
**2)** The bApp is a non-compliant smart contract or an EOA.
71-
72-
### 🧠 Compliant BApp
73-
74-
If the bApp is a compliant contract implementing the required interface `IBasedApp`,
75-
76-
The slash function of the bApp is called: `(success, receiver, exit) = IBasedApp(bApp).slash(...)`
77-
78-
* `data` parameter is forwarded and may act as a proof or auxiliary input.
79-
80-
* The bApp decides:
81-
82-
* Who receives the slashed funds by setting the `receiver` fund, it can burn by setting the receiver as `address(0)`;
83-
84-
* Whether to exit the strategy or adjust obligations;
85-
86-
* If `exit == true`, the strategy is exited and the obligation value is set to 0;
87-
88-
* Otherwise, obligations are adjusted proportionally based on remaining balances, the new obligated amount is set to the previous one less the slashed amount;
89-
90-
* Funds are credited to the receiver in the slashing fund.
68+
## 🔨 _Slashing & Withdrawals Mechanisms_
9169

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

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

96-
* Only the bApp itself can invoke slashing;
74+
## :gear: _Feature Activation_
9775

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

100-
* The strategy is always exited (no obligation adjustment);
78+
## :page_facing_up: _Whitepaper_
10179

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

104-
### ⏳ Post Slashing
10582

106-
⚠️ 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.
83+
## :books: _More Resources_
10784

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

110-
### 💸 Slashing Fund
11187

112-
Slashed tokens are not immediately transferred. They are deposited into an internal slashing fund.
88+
## :rocket: _Deployments_
11389

114-
The `receiver` (set during slashing) can later withdraw them using:
90+
### How to Deploy
11591

116-
```
117-
function withdrawSlashingFund(address token, uint256 amount) external
118-
function withdrawETHSlashingFund(uint256 amount) external
119-
```
92+
**2)** Set the environment variables in the `.env` file.
12093

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

123-
 
96+
__`❍ npm run deploy:hoodi-stage`__: verification is done automatically.
12497

125-
## :page_facing_up: _Whitepaper_
98+
### How to Update Module Contracts
12699

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

129-
 
130-
131-
## :books: _More Resources_
102+
It is possible to update multiple modules at the same time.
132103

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

135-
 
106+
__`❍ updateModules`__: specifying the correct module id and the new module address.
136107

137-
## :rocket: _Deployments_
138-
139-
### How to Deploy
108+
### How to Upgrade the Implementation Contract
140109

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

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

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

147-
### Public Testnet
115+
### Public Testnet Hoodi
148116

149117
| Name | Proxy | Implementation | Notes |
150118
| -------- | -------- | -------- | -------- |
151-
| [`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) |
119+
| [`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) |
152120

153121
&nbsp;
154122

RELEASE_NOTES.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Release Notes
2+
3+
## [v0.1.1 - fix] 2024-06-17
4+
### Description
5+
- Fix to update the storage references when proposing an obligation
6+
- Bump solidity version
7+
- Create module deployment scripts
8+
9+
## [v0.1.1] 2024-06-xx
10+
11+
### Functions
12+
13+
#### Modified
14+
- `function registerBApp(ICore.TokenConfig[] calldata tokenConfigs, string calldata metadataURI) external`
15+
- `function updateDisabledFeatures(uint32 value) external onlyOwner`
16+
17+
### Errors
18+
19+
#### New
20+
- `error InvalidDisabledFeatures();`
21+
- `error InvalidFeeExpireTime();`
22+
- `error InvalidFeeTimelockPeriod();`
23+
- `error InvalidMaxShares();`
24+
- `error InvalidObligationExpireTime();`
25+
- `error InvalidObligationTimelockPeriod();`
26+
- `error InvalidTokenUpdateTimelockPeriod();`
27+
- `error InvalidWithdrawalExpireTime();`
28+
- `error InvalidWithdrawalTimelockPeriod();`
29+
30+
### Events
31+
32+
#### Modified
33+
- `event BAppRegistered(address indexed bApp, ICore.TokenConfig[] tokenConfigs, string metadataURI);`

artifacts/deploy-hoodi-prod.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"addresses": {
3+
"BAppsModule": "0xCf9894B93C34E9Af8E912EcE7089DCE879740141",
4+
"ProtocolModule": "0xA11022BB79cE25F9bAdfDB426746A4a47a1FD768",
5+
"SSVBasedAppsImpl": "0xba84542de120aa2e94ccb5334a6f21a6a9e78999",
6+
"SSVBasedAppsProxy": "0xc7fCFeEc5FB9962bDC2234A7a25dCec739e27f9f",
7+
"StrategyModule": "0xe9C3AD47E13f5902F97E8ab6f8C63D2414732e8e"
8+
},
9+
"chainInfo": {
10+
"chainId": 560048,
11+
"deploymentBlock": 260728
12+
},
13+
"parameters": {
14+
"disabledFeatures": 0,
15+
"feeExpireTime": 3600,
16+
"feeTimelockPeriod": 86400,
17+
"maxFeeIncrement": 500,
18+
"maxShares": 100000000000000000000000000000000000000000000000000,
19+
"obligationExpireTime": 86400,
20+
"obligationTimelockPeriod": 172800,
21+
"tokenUpdateTimelockPeriod": 3600,
22+
"withdrawalExpireTime": 86400,
23+
"withdrawalTimelockPeriod": 172800
24+
}
25+
}

artifacts/deploy-hoodi-stage.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"addresses": {
3+
"BAppsModule": "0xdC97f7935Ed6FDcA407dDdE95EB26f7807E52Dc9",
4+
"ProtocolModule": "0x7AadaE0f159eECCe6a4Faad78FFF94e1eab4C540",
5+
"SSVBasedAppsImpl": "0xba84542de120aa2e94ccb5334a6f21a6a9e78999",
6+
"SSVBasedAppsProxy": "0x40d959B95e7c56962D6d388d87921c03734b9C2C",
7+
"StrategyModule": "0xe9C3AD47E13f5902F97E8ab6f8C63D2414732e8e"
8+
},
9+
"chainInfo": {
10+
"chainId": 560048,
11+
"deploymentBlock": 259312
12+
},
13+
"parameters": {
14+
"disabledFeatures": 0,
15+
"feeExpireTime": 3600,
16+
"feeTimelockPeriod": 300,
17+
"maxFeeIncrement": 500,
18+
"maxShares": 100000000000000000000000000000000000000000000000000,
19+
"obligationExpireTime": 3600,
20+
"obligationTimelockPeriod": 300,
21+
"tokenUpdateTimelockPeriod": 300,
22+
"withdrawalExpireTime": 3600,
23+
"withdrawalTimelockPeriod": 300
24+
}
25+
}

docs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
book/

0 commit comments

Comments
 (0)