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
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
74 changes: 8 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,82 +61,25 @@ __`❍ forge test`__

 

## 🔨 _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

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

⚠️ 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.

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

### 💸 Slashing Fund

Slashed tokens are not immediately transferred. They are deposited into an internal slashing fund.

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

```
function withdrawSlashingFund(address token, uint256 amount) external
function withdrawETHSlashingFund(uint256 amount) external
```

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

 

## :gear: _Feature activation_

[Feature activation](./specs/feature_activation.md)
[Feature Activation](./guides/feature-activation.md)

## :page_facing_up: _Whitepaper_

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

 

## :books: _More Resources_

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

 

## :rocket: _Deployments_

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

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

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

### Public Testnet Holesky
### 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) |
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we will update the entry with the addresses of the deployed contracts on stage and prod


&nbsp;

Expand Down
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
}
}
24 changes: 18 additions & 6 deletions artifacts/deploy-hoodi-stage.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
{
"addresses": {
"BAppsModule": "0xF2b0c91b5256aD75585438C2722d5E7119666288",
"ProtocolModule": "0x5C08fb73Ba1E8Fd2894e0A3706C1e4CfBEA3F833",
"SSVBasedAppsImpl": "0x7E438E9264B431Fb62fbE2BFa350b9860cf7E8AA",
"SSVBasedAppsProxy": "0x1F3d4e4aEeA5406e3A7119d8daa31C67Ed3B13de",
"StrategyModule": "0x4b4638B067946c395C32CD0DFE5399E0899C7542"
"BAppsModule": "0xdC97f7935Ed6FDcA407dDdE95EB26f7807E52Dc9",
"ProtocolModule": "0x7AadaE0f159eECCe6a4Faad78FFF94e1eab4C540",
"SSVBasedAppsImpl": "0xfCD7243D8fBb441497fEd67e19B7681C27BB20aD",
"SSVBasedAppsProxy": "0x40d959B95e7c56962D6d388d87921c03734b9C2C",
"StrategyModule": "0x7cF08Af55c6939BB748D4c4D2d219791EDe9dBC1"
},
"chainInfo": {
"chainId": 560048,
"deploymentBlock": 253405
"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
Loading