Skip to content

Commit dddaa6f

Browse files
authored
Release/v0.1.0 (#46)
* docs: slashing & withdrawal mechanics * chore: stage & prod deployment
1 parent 1c20380 commit dddaa6f

File tree

58 files changed

+3622
-95
lines changed

Some content is hidden

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

58 files changed

+3622
-95
lines changed

.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

README.md

Lines changed: 8 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -61,82 +61,25 @@ __`❍ forge test`__
6161

6262
 
6363

64-
## 🔨 _Slashing Mechanism_
64+
## 🔨 _Slashing & Withdrawals Mechanisms_
6565

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

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

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

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.
91-
92-
### 🔐 Non-compliant bApp (EOA or Non-compliant Contract)
93-
94-
If the bApp is an EOA or does not comply with the required interface:
95-
96-
* Only the bApp itself can invoke slashing;
97-
98-
* The receiver of slashed funds is forcibly set to the bApp itself;
99-
100-
* The strategy is always exited (no obligation adjustment);
101-
102-
* Funds are added to the bApp’s slashing fund.
103-
104-
### ⏳ Post Slashing
105-
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.
107-
108-
This acts as a safeguard to prevent immediate re-entry and encourages more deliberate strategy participation.
109-
110-
### 💸 Slashing Fund
111-
112-
Slashed tokens are not immediately transferred. They are deposited into an internal slashing fund.
113-
114-
The `receiver` (set during slashing) can later withdraw them using:
115-
116-
```
117-
function withdrawSlashingFund(address token, uint256 amount) external
118-
function withdrawETHSlashingFund(uint256 amount) external
119-
```
120-
121-
These functions verify balances and authorize the caller to retrieve their accumulated slashed tokens.
122-
123-
 
124-
125-
## :gear: _Feature activation_
126-
127-
[Feature activation](./specs/feature_activation.md)
72+
[Feature Activation](./guides/feature-activation.md)
12873

12974
## :page_facing_up: _Whitepaper_
13075

13176
[Whitepaper](https://ssv.network/wp-content/uploads/2025/01/SSV2.0-Based-Applications-Protocol-1.pdf)
13277

133-
 
13478

13579
## :books: _More Resources_
13680

137-
[Based Apps Onboarding Guide](./doc/bAppOnBoarding.md)
81+
[Based Apps Onboarding Guide](./guides/bApp-onboarding.md)
13882

139-
 
14083

14184
## :rocket: _Deployments_
14285

@@ -164,13 +107,12 @@ __`❍ updateModules`__: specifying the correct module id and the new module add
164107

165108
__`❍ upgradeToAndCall`__: specifying the new implementation address. The data field can be left empty in this case.
166109

167-
There is also the `UpgradeProxy.s.sol` script file that can be run easily from the CLI.
168110

169-
### Public Testnet Holesky
111+
### Public Testnet Hoodi
170112

171113
| Name | Proxy | Implementation | Notes |
172114
| -------- | -------- | -------- | -------- |
173-
| [`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) |
115+
| [`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) |
174116

175117
&nbsp;
176118

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": "0xe5a75122b158D405518C6752aEE5D40b8FB1C364",
6+
"SSVBasedAppsProxy": "0xc7fCFeEc5FB9962bDC2234A7a25dCec739e27f9f",
7+
"StrategyModule": "0x0B81DcaF34f4455221A7d446eA41A70B8Baf91FF"
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: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
{
22
"addresses": {
3-
"BAppsModule": "0xF2b0c91b5256aD75585438C2722d5E7119666288",
4-
"ProtocolModule": "0x5C08fb73Ba1E8Fd2894e0A3706C1e4CfBEA3F833",
5-
"SSVBasedAppsImpl": "0x7E438E9264B431Fb62fbE2BFa350b9860cf7E8AA",
6-
"SSVBasedAppsProxy": "0x1F3d4e4aEeA5406e3A7119d8daa31C67Ed3B13de",
7-
"StrategyModule": "0x4b4638B067946c395C32CD0DFE5399E0899C7542"
3+
"BAppsModule": "0xdC97f7935Ed6FDcA407dDdE95EB26f7807E52Dc9",
4+
"ProtocolModule": "0x7AadaE0f159eECCe6a4Faad78FFF94e1eab4C540",
5+
"SSVBasedAppsImpl": "0xfCD7243D8fBb441497fEd67e19B7681C27BB20aD",
6+
"SSVBasedAppsProxy": "0x40d959B95e7c56962D6d388d87921c03734b9C2C",
7+
"StrategyModule": "0x7cF08Af55c6939BB748D4c4D2d219791EDe9dBC1"
88
},
99
"chainInfo": {
1010
"chainId": 560048,
11-
"deploymentBlock": 253405
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
1224
}
1325
}

docs/.gitignore

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

docs/book.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
table {
2+
margin: 0 auto;
3+
border-collapse: collapse;
4+
width: 100%;
5+
}
6+
7+
table td:first-child {
8+
width: 15%;
9+
}
10+
11+
table td:nth-child(2) {
12+
width: 25%;
13+
}

docs/book.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[book]
2+
src = "src"
3+
title = ""
4+
5+
[output.html]
6+
no-section-label = true
7+
additional-js = ["solidity.min.js"]
8+
additional-css = ["book.css"]
9+
mathjax-support = true
10+
git-repository-url = "https://github.com/ssvlabs/based-applications"
11+
12+
[output.html.fold]
13+
enable = true

docs/solidity.min.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
hljs.registerLanguage("solidity",(()=>{"use strict";function e(){try{return!0
2+
}catch(e){return!1}}
3+
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|\$)/
4+
;e()&&(a=a.source.replace(/\\b/g,"(?<!\\$)\\b"));var s={className:"number",
5+
begin:a,relevance:0},n={
6+
keyword:"assembly let function if switch case default for leave break continue u256 jump jumpi stop return revert selfdestruct invalid",
7+
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",
8+
literal:"true false"},i={className:"string",
9+
begin:/\bhex'(([0-9a-fA-F]{2}_?)*[0-9a-fA-F]{2})?'/},t={className:"string",
10+
begin:/\bhex"(([0-9a-fA-F]{2}_?)*[0-9a-fA-F]{2})?"/};function r(e){
11+
return e.inherit(e.APOS_STRING_MODE,{begin:/(\bunicode)?'/})}function l(e){
12+
return e.inherit(e.QUOTE_STRING_MODE,{begin:/(\bunicode)?"/})}var o={
13+
SOL_ASSEMBLY_KEYWORDS:n,baseAssembly:e=>{
14+
var a=r(e),o=l(e),c=/[A-Za-z_$][A-Za-z_$0-9.]*/,d=e.inherit(e.TITLE_MODE,{
15+
begin:/[A-Za-z$_][0-9A-Za-z$_]*/,lexemes:c,keywords:n}),u={className:"params",
16+
begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,lexemes:c,keywords:n,
17+
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,o,s]},_={
18+
className:"operator",begin:/:=|->/};return{keywords:n,lexemes:c,
19+
contains:[a,o,i,t,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,s,_,{
20+
className:"function",lexemes:c,beginKeywords:"function",end:"{",excludeEnd:!0,
21+
contains:[d,u,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,_]}]}},
22+
solAposStringMode:r,solQuoteStringMode:l,HEX_APOS_STRING_MODE:i,
23+
HEX_QUOTE_STRING_MODE:t,SOL_NUMBER:s,isNegativeLookbehindAvailable:e}
24+
;const{baseAssembly:c,solAposStringMode:d,solQuoteStringMode:u,HEX_APOS_STRING_MODE:_,HEX_QUOTE_STRING_MODE:m,SOL_NUMBER:b,isNegativeLookbehindAvailable:E}=o
25+
;return e=>{for(var a=d(e),s=u(e),n=[],i=0;i<32;i++)n[i]=i+1
26+
;var t=n.map((e=>8*e)),r=[];for(i=0;i<=80;i++)r[i]=i
27+
;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={
28+
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",
29+
literal:"true false wei gwei szabo finney ether seconds minutes hours days weeks years",
30+
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"
31+
},O={className:"operator",begin:/[+\-!~*\/%<>&^|=]/
32+
},C=/[A-Za-z_$][A-Za-z_$0-9]*/,N={className:"params",begin:/\(/,end:/\)/,
33+
excludeBegin:!0,excludeEnd:!0,lexemes:C,keywords:p,
34+
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,a,s,b,"self"]},f={
35+
begin:/\.\s*/,end:/[^A-Za-z0-9$_\.]/,excludeBegin:!0,excludeEnd:!0,keywords:{
36+
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"
37+
},relevance:2},y=e.inherit(e.TITLE_MODE,{begin:/[A-Za-z$_][0-9A-Za-z$_]*/,
38+
lexemes:C,keywords:p}),w={className:"built_in",
39+
begin:(E()?"(?<!\\$)\\b":"\\b")+"(gas|value|salt)(?=:)"};function x(e,a){return{
40+
begin:(E()?"(?<!\\$)\\b":"\\b")+e+"\\.\\s*",end:/[^A-Za-z0-9$_\.]/,
41+
excludeBegin:!1,excludeEnd:!0,lexemes:C,keywords:{built_in:e+" "+a},
42+
contains:[f],relevance:10}}var h=c(e),v=e.inherit(h,{
43+
contains:h.contains.concat([{begin:/\./,end:/[^A-Za-z0-9$.]/,excludeBegin:!0,
44+
excludeEnd:!0,keywords:{built_in:"slot offset length address selector"},
45+
relevance:2},{begin:/_/,end:/[^A-Za-z0-9$.]/,excludeBegin:!0,excludeEnd:!0,
46+
keywords:{built_in:"slot offset"},relevance:2}])});return{aliases:["sol"],
47+
keywords:p,lexemes:C,
48+
contains:[a,s,_,m,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,b,w,O,{
49+
className:"function",lexemes:C,
50+
beginKeywords:"function modifier event constructor fallback receive error",
51+
end:/[{;]/,excludeEnd:!0,
52+
contains:[y,N,w,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE],illegal:/%/
53+
},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,{
54+
className:"class",lexemes:C,beginKeywords:"contract interface library",end:"{",
55+
excludeEnd:!0,illegal:/[:"\[\]]/,contains:[{beginKeywords:"is",lexemes:C
56+
},y,N,w,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{lexemes:C,
57+
beginKeywords:"struct enum",end:"{",excludeEnd:!0,illegal:/[:"\[\]]/,
58+
contains:[y,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{
59+
beginKeywords:"import",end:";",lexemes:C,keywords:"import from as",
60+
contains:[y,a,s,_,m,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,O]},{
61+
beginKeywords:"using",end:";",lexemes:C,keywords:"using for",
62+
contains:[y,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,O]},{className:"meta",
63+
beginKeywords:"pragma",end:";",lexemes:C,keywords:{
64+
keyword:"pragma solidity experimental abicoder",
65+
built_in:"ABIEncoderV2 SMTChecker v1 v2"},
66+
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.inherit(a,{
67+
className:"meta-string"}),e.inherit(s,{className:"meta-string"})]},{
68+
beginKeywords:"assembly",end:/\b\B/,
69+
contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.inherit(v,{begin:"{",
70+
end:"}",endsParent:!0,contains:v.contains.concat([e.inherit(v,{begin:"{",
71+
end:"}",contains:v.contains.concat(["self"])})])})]}],illegal:/#/}}})());
72+
73+
// Ugly hack to reload HLJS
74+
hljs.initHighlightingOnLoad();

0 commit comments

Comments
 (0)