Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
2659fdf
Support Delayed Token Update (#40)
riccardo-ssvlabs Apr 23, 2025
cbef692
Feature deactivation on demand (#42)
mtabasco Apr 23, 2025
fe6da4e
feat: update adjust percentage formula and optimizations
riccardo-ssvlabs Apr 23, 2025
cd8b1b2
feat: update adjust percentage formula and optimizations
riccardo-ssvlabs Apr 23, 2025
01dd57f
fix: <- test case
riccardo-ssvlabs Apr 24, 2025
6cc6ad0
Merge pull request #44 from ssvlabs/chore/optimize-storage
riccardo-ssvlabs Apr 24, 2025
1c20380
Updated deployment scripts (#45)
mtabasco Apr 24, 2025
dddaa6f
Release/v0.1.0 (#46)
mtabasco May 2, 2025
7fb4417
fix(strategy-manager): change slashing and obligationUpdate event order
riccardo-ssvlabs May 12, 2025
f3efb28
Merge pull request #47 from ssvlabs/fix/event-order-slashing
riccardo-ssvlabs May 14, 2025
1a21e65
fix(strategy): revert slashing if strategy not opted in
riccardo-ssvlabs May 27, 2025
a023070
test(strategy): revert slash not opted in strategy
riccardo-ssvlabs May 27, 2025
5b2de18
chore: <- update solhint
riccardo-ssvlabs May 27, 2025
90ede9d
Add Security Checks for Config (#49)
riccardo-ssvlabs May 28, 2025
1c86fe4
Enrich SSVBasedApps interface (#51)
riccardo-ssvlabs May 28, 2025
58dae6b
Remove IERC165 Interface Check (#52)
riccardo-ssvlabs May 28, 2025
5c94bda
feat: check bApp registered during OptIn (#53)
riccardo-ssvlabs May 28, 2025
8555ef4
Use `ICore.TokenConfig` for `registerBApp()` (#50)
riccardo-ssvlabs May 28, 2025
7767ca6
chore: update prettier dependency (#62)
mtabasco May 28, 2025
900166e
chore(deps): update dependency solhint to ^5.1.0 (#56)
renovate[bot] May 28, 2025
892568c
chore(deps): update dependency node to v22 (#59)
renovate[bot] May 28, 2025
c9464a8
chore(deps): update dependency lint-staged to v16 (#58)
renovate[bot] May 28, 2025
9ee223c
chore(deps): update dependency node to v22 (#64)
renovate[bot] May 28, 2025
3ee95af
chore(deps): update dependency solhint to ^5.1.0 (#63)
renovate[bot] May 28, 2025
572d843
chore: update docs + add release notes
mtabasco May 28, 2025
c4b0aa3
Merge pull request #68 from ssvlabs/chore/update-docs
riccardo-ssvlabs May 29, 2025
b48bc58
feat: support opt-out WIP
riccardo-ssvlabs May 30, 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
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=
5 changes: 5 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"github>ssvlabs/shared-configs//renovate/renovate.json"
]
}
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '22'
cache: 'npm'
cache-dependency-path: package-lock.json

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
84 changes: 24 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,94 +61,58 @@ __`❍ forge test`__

&nbsp;

## 🔨 _Slashing Mechanism_
## 🔨 _Slashing & Withdrawals Mechanisms_

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:
[Slashing & Withdrawals](./guides/slashing-and-withdrawals.md)

**1)** The bApp is a compliant smart contract;
[Generation pattern](./guides/generations.md)

**2)** The bApp is a non-compliant smart contract or an EOA.
## :gear: _Feature Activation_

### 🧠 Compliant BApp
[Feature Activation](./guides/feature-activation.md)

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.

### 🔐 Non-compliant bApp (EOA or Non-compliant Contract)

If the bApp is an EOA or does not comply with the required interface:

* Only the bApp itself can invoke slashing;

* The receiver of slashed funds is forcibly set to the bApp itself;

* The strategy is always exited (no obligation adjustment);

* Funds are added to the bApp’s slashing fund.

### ⏳ Post Slashing
## :page_facing_up: _Whitepaper_

⚠️ 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.
[Whitepaper](https://ssv.network/wp-content/uploads/2025/01/SSV2.0-Based-Applications-Protocol-1.pdf)

This acts as a safeguard to prevent immediate re-entry and encourages more deliberate strategy participation.

### 💸 Slashing Fund
## :books: _More Resources_

Slashed tokens are not immediately transferred. They are deposited into an internal slashing fund.
[Based Apps Onboarding Guide](./guides/bApp-onboarding.md)

The `receiver` (set during slashing) can later withdraw them using:

```
function withdrawSlashingFund(address token, uint256 amount) external
function withdrawETHSlashingFund(uint256 amount) external
```
## :rocket: _Deployments_

These functions verify balances and authorize the caller to retrieve their accumulated slashed tokens.
### How to Deploy

&nbsp;
**2)** Set the environment variables in the `.env` file.

## :page_facing_up: _Whitepaper_
**1)** Run the deployment script `DeployAllHoodi.s.sol` defined in `script/`:

[Whitepaper](https://ssv.network/wp-content/uploads/2025/01/SSV2.0-Based-Applications-Protocol-1.pdf)
__`❍ npm run deploy:hoodi-stage`__: verification is done automatically.

&nbsp;
### How to Update Module Contracts

## :books: _More Resources_
It is possible to update each one of the three modules: `StrategyManager`, `BasedAppsManager` and `ProtocolManager`.

[Based Apps Onboarding Guide](./doc/bAppOnBoarding.md)
It is possible to update multiple modules at the same time.

&nbsp;
**1)** Go on the Proxy Contract on Etherscan, under "Write as Proxy" call the function:

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

### 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
27 changes: 27 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Release Notes

## [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": "0xe5a75122b158D405518C6752aEE5D40b8FB1C364",
"SSVBasedAppsProxy": "0xc7fCFeEc5FB9962bDC2234A7a25dCec739e27f9f",
"StrategyModule": "0x0B81DcaF34f4455221A7d446eA41A70B8Baf91FF"
},
"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": "0xfCD7243D8fBb441497fEd67e19B7681C27BB20aD",
"SSVBasedAppsProxy": "0x40d959B95e7c56962D6d388d87921c03734b9C2C",
"StrategyModule": "0x7cF08Af55c6939BB748D4c4D2d219791EDe9dBC1"
},
"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
74 changes: 74 additions & 0 deletions docs/solidity.min.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
hljs.registerLanguage("solidity",(()=>{"use strict";function e(){try{return!0
}catch(e){return!1}}
var a=/-?(\b0[xX]([a-fA-F0-9]_?)*[a-fA-F0-9]|(\b[1-9](_?\d)*(\.((\d_?)*\d)?)?|\.\d(_?\d)*)([eE][-+]?\d(_?\d)*)?|\b0)(?!\w|\$)/
;e()&&(a=a.source.replace(/\\b/g,"(?<!\\$)\\b"));var s={className:"number",
begin:a,relevance:0},n={
keyword:"assembly let function if switch case default for leave break continue u256 jump jumpi stop return revert selfdestruct invalid",
built_in:"add sub mul div sdiv mod smod exp not lt gt slt sgt eq iszero and or xor byte shl shr sar addmod mulmod signextend keccak256 pc pop dup1 dup2 dup3 dup4 dup5 dup6 dup7 dup8 dup9 dup10 dup11 dup12 dup13 dup14 dup15 dup16 swap1 swap2 swap3 swap4 swap5 swap6 swap7 swap8 swap9 swap10 swap11 swap12 swap13 swap14 swap15 swap16 mload mstore mstore8 sload sstore msize gas address balance selfbalance caller callvalue calldataload calldatasize calldatacopy codesize codecopy extcodesize extcodecopy returndatasize returndatacopy extcodehash create create2 call callcode delegatecall staticcall log0 log1 log2 log3 log4 chainid origin gasprice basefee blockhash coinbase timestamp number difficulty gaslimit",
literal:"true false"},i={className:"string",
begin:/\bhex'(([0-9a-fA-F]{2}_?)*[0-9a-fA-F]{2})?'/},t={className:"string",
begin:/\bhex"(([0-9a-fA-F]{2}_?)*[0-9a-fA-F]{2})?"/};function r(e){
return e.inherit(e.APOS_STRING_MODE,{begin:/(\bunicode)?'/})}function l(e){
return e.inherit(e.QUOTE_STRING_MODE,{begin:/(\bunicode)?"/})}var o={
SOL_ASSEMBLY_KEYWORDS:n,baseAssembly:e=>{
var a=r(e),o=l(e),c=/[A-Za-z_$][A-Za-z_$0-9.]*/,d=e.inherit(e.TITLE_MODE,{
begin:/[A-Za-z$_][0-9A-Za-z$_]*/,lexemes:c,keywords:n}),u={className:"params",
begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,lexemes:c,keywords:n,
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,o,s]},_={
className:"operator",begin:/:=|->/};return{keywords:n,lexemes:c,
contains:[a,o,i,t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,s,_,{
className:"function",lexemes:c,beginKeywords:"function",end:"{",excludeEnd:!0,
contains:[d,u,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,_]}]}},
solAposStringMode:r,solQuoteStringMode:l,HEX_APOS_STRING_MODE:i,
HEX_QUOTE_STRING_MODE:t,SOL_NUMBER:s,isNegativeLookbehindAvailable:e}
;const{baseAssembly:c,solAposStringMode:d,solQuoteStringMode:u,HEX_APOS_STRING_MODE:_,HEX_QUOTE_STRING_MODE:m,SOL_NUMBER:b,isNegativeLookbehindAvailable:E}=o
;return e=>{for(var a=d(e),s=u(e),n=[],i=0;i<32;i++)n[i]=i+1
;var t=n.map((e=>8*e)),r=[];for(i=0;i<=80;i++)r[i]=i
;var l=n.map((e=>"bytes"+e)).join(" ")+" ",o=t.map((e=>"uint"+e)).join(" ")+" ",g=t.map((e=>"int"+e)).join(" ")+" ",M=[].concat.apply([],t.map((e=>r.map((a=>e+"x"+a))))),p={
keyword:"var bool string int uint "+g+o+"byte bytes "+l+"fixed ufixed "+M.map((e=>"fixed"+e)).join(" ")+" "+M.map((e=>"ufixed"+e)).join(" ")+" enum struct mapping address new delete if else for while continue break return throw emit try catch revert unchecked _ function modifier event constructor fallback receive error virtual override constant immutable anonymous indexed storage memory calldata external public internal payable pure view private returns import from as using pragma contract interface library is abstract type assembly",
literal:"true false wei gwei szabo finney ether seconds minutes hours days weeks years",
built_in:"self this super selfdestruct suicide now msg block tx abi blockhash gasleft assert require Error Panic sha3 sha256 keccak256 ripemd160 ecrecover addmod mulmod log0 log1 log2 log3 log4"
},O={className:"operator",begin:/[+\-!~*\/%<>&^|=]/
},C=/[A-Za-z_$][A-Za-z_$0-9]*/,N={className:"params",begin:/\(/,end:/\)/,
excludeBegin:!0,excludeEnd:!0,lexemes:C,keywords:p,
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,s,b,"self"]},f={
begin:/\.\s*/,end:/[^A-Za-z0-9$_\.]/,excludeBegin:!0,excludeEnd:!0,keywords:{
built_in:"gas value selector address length push pop send transfer call callcode delegatecall staticcall balance code codehash wrap unwrap name creationCode runtimeCode interfaceId min max"
},relevance:2},y=e.inherit(e.TITLE_MODE,{begin:/[A-Za-z$_][0-9A-Za-z$_]*/,
lexemes:C,keywords:p}),w={className:"built_in",
begin:(E()?"(?<!\\$)\\b":"\\b")+"(gas|value|salt)(?=:)"};function x(e,a){return{
begin:(E()?"(?<!\\$)\\b":"\\b")+e+"\\.\\s*",end:/[^A-Za-z0-9$_\.]/,
excludeBegin:!1,excludeEnd:!0,lexemes:C,keywords:{built_in:e+" "+a},
contains:[f],relevance:10}}var h=c(e),v=e.inherit(h,{
contains:h.contains.concat([{begin:/\./,end:/[^A-Za-z0-9$.]/,excludeBegin:!0,
excludeEnd:!0,keywords:{built_in:"slot offset length address selector"},
relevance:2},{begin:/_/,end:/[^A-Za-z0-9$.]/,excludeBegin:!0,excludeEnd:!0,
keywords:{built_in:"slot offset"},relevance:2}])});return{aliases:["sol"],
keywords:p,lexemes:C,
contains:[a,s,_,m,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,b,w,O,{
className:"function",lexemes:C,
beginKeywords:"function modifier event constructor fallback receive error",
end:/[{;]/,excludeEnd:!0,
contains:[y,N,w,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:/%/
},x("msg","gas value data sender sig"),x("block","blockhash coinbase difficulty gaslimit basefee number timestamp chainid"),x("tx","gasprice origin"),x("abi","decode encode encodePacked encodeWithSelector encodeWithSignature encodeCall"),x("bytes","concat"),f,{
className:"class",lexemes:C,beginKeywords:"contract interface library",end:"{",
excludeEnd:!0,illegal:/[:"\[\]]/,contains:[{beginKeywords:"is",lexemes:C
},y,N,w,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{lexemes:C,
beginKeywords:"struct enum",end:"{",excludeEnd:!0,illegal:/[:"\[\]]/,
contains:[y,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{
beginKeywords:"import",end:";",lexemes:C,keywords:"import from as",
contains:[y,a,s,_,m,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,O]},{
beginKeywords:"using",end:";",lexemes:C,keywords:"using for",
contains:[y,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,O]},{className:"meta",
beginKeywords:"pragma",end:";",lexemes:C,keywords:{
keyword:"pragma solidity experimental abicoder",
built_in:"ABIEncoderV2 SMTChecker v1 v2"},
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.inherit(a,{
className:"meta-string"}),e.inherit(s,{className:"meta-string"})]},{
beginKeywords:"assembly",end:/\b\B/,
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.inherit(v,{begin:"{",
end:"}",endsParent:!0,contains:v.contains.concat([e.inherit(v,{begin:"{",
end:"}",contains:v.contains.concat(["self"])})])})]}],illegal:/#/}}})());

// Ugly hack to reload HLJS
hljs.initHighlightingOnLoad();
Loading