Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
168 commits
Select commit Hold shift + click to select a range
2260247
test: <- propose and finalize update/removal
riccardo-ssvlabs Mar 3, 2025
b49de04
feat: <- support verification at deploy and more tests
riccardo-ssvlabs Mar 4, 2025
4f82724
feat: <- use strategy whitelisting methods
riccardo-ssvlabs Mar 4, 2025
c125f10
test: <- finish test coverage
riccardo-ssvlabs Mar 5, 2025
9ce8ef5
test: <- move from upgradeable to not
riccardo-ssvlabs Mar 5, 2025
423998f
test: <- achieve 100% total coverage
riccardo-ssvlabs Mar 6, 2025
d7d68ff
chore: <- improve style
riccardo-ssvlabs Mar 7, 2025
0307c6c
fix(ownable-based-app): <- var shadowing
riccardo-ssvlabs Mar 7, 2025
ce8f177
fix: <- more shadowing
riccardo-ssvlabs Mar 7, 2025
084bdd6
chore: <- remove sligther obscuring gas reports
riccardo-ssvlabs Mar 7, 2025
5a46d19
chore: <- restore
riccardo-ssvlabs Mar 7, 2025
81d6c01
gas: saving 30/50 gas
riccardo-ssvlabs Mar 7, 2025
8d6bc43
gas(proposeBAppTokensUpdate: optmize
riccardo-ssvlabs Mar 7, 2025
4cbfc47
gas(proposeBAppTokensRemoval): <- optmize
riccardo-ssvlabs Mar 7, 2025
67bb77e
optimize: <- add new tokens
riccardo-ssvlabs Mar 7, 2025
f2d9ef4
optimize: <- use unchecked block for delegateBalance
riccardo-ssvlabs Mar 7, 2025
313ea91
optimize: <- use unchecked block for delegateBalance - format
riccardo-ssvlabs Mar 7, 2025
d9e173f
optimize: <- use unchecked block for more balance operations
riccardo-ssvlabs Mar 7, 2025
c1aa8e5
optimize: <- uint256 is more optimized for loops
riccardo-ssvlabs Mar 7, 2025
cf24b73
optimize: <- restore previous obligation
riccardo-ssvlabs Mar 7, 2025
ccbdaae
test: <- advanced tests
riccardo-ssvlabs Mar 10, 2025
0116505
chore: <- format
riccardo-ssvlabs Mar 10, 2025
ebd3e31
test: <- multiple updates of obligations and used tokens
riccardo-ssvlabs Mar 11, 2025
339903f
test: <- advanced withdrawal flow
riccardo-ssvlabs Mar 11, 2025
b7bad6e
test: <- advanced add tokens then remove, with obl. implications
riccardo-ssvlabs Mar 11, 2025
d9582b7
chore: <- format
riccardo-ssvlabs Mar 11, 2025
d8994ff
test: <- test more events
riccardo-ssvlabs Mar 11, 2025
945a5b8
test: <- test more events and add check strategy util
riccardo-ssvlabs Mar 11, 2025
7574701
feat: <- remove old fee from events
riccardo-ssvlabs Mar 12, 2025
6c03771
test: <- continue test refactor
riccardo-ssvlabs Mar 12, 2025
0b73d02
test: <- refactor correct number of used tokens
riccardo-ssvlabs Mar 12, 2025
4a9b67b
test: <- refactor delegated balance
riccardo-ssvlabs Mar 13, 2025
34952c0
test: <- refactor strategy
riccardo-ssvlabs Mar 14, 2025
0579b6c
test: <- refactor strategy complete
riccardo-ssvlabs Mar 14, 2025
6b4860a
feat: <- add hoodi deployment
riccardo-ssvlabs Mar 17, 2025
f3919e5
feat: <- add script to verify on hoodi
riccardo-ssvlabs Mar 18, 2025
67e36be
fix(exploit): double check the amount on finalize withdrawal
riccardo-ssvlabs Mar 18, 2025
613f3cf
feat: <- isFast field to fee update event
riccardo-ssvlabs Mar 19, 2025
d2fee0d
test: <- reject exploit withdrawal ERC20 and ETH
riccardo-ssvlabs Mar 19, 2025
f2ad651
feat: <- support non interface compatible bApps and EOA bBapps
riccardo-ssvlabs Mar 19, 2025
24357cb
feat: <- slashing wip
riccardo-ssvlabs Mar 17, 2025
408bebd
feat: <- slashing wip 2
riccardo-ssvlabs Mar 18, 2025
3ddeaab
feat: <- slashing wip 2
riccardo-ssvlabs Mar 18, 2025
5ef1b1d
feat: <- support open slashing from SSVBasedApp contract
riccardo-ssvlabs Mar 19, 2025
3825be5
chore: <- format
riccardo-ssvlabs Mar 19, 2025
e24a395
feat: <- optimize for loops
riccardo-ssvlabs Mar 19, 2025
afbe286
feat: <- basic slash + testing
riccardo-ssvlabs Mar 20, 2025
eaaa47f
feat: <- adjusting slashing and tests after share refactor
riccardo-ssvlabs Mar 21, 2025
e25a005
chore: <- describe new shares mappings
riccardo-ssvlabs Mar 21, 2025
4a1e9f1
chore: <- clear shares code
riccardo-ssvlabs Mar 21, 2025
8a44738
chore: <- format
riccardo-ssvlabs Mar 21, 2025
cc8e1f3
chore: <- add comments to explictly handle return values in based app…
riccardo-ssvlabs Mar 21, 2025
6262406
test: <- finish test update for shares
riccardo-ssvlabs Mar 21, 2025
92026cc
Merge branch 'main' into feat/slashing-basics
riccardo-ssvlabs Mar 21, 2025
3a57e89
chore: <- format
riccardo-ssvlabs Mar 21, 2025
e0bbd3d
feat: <- remove fastUpdateObligation and achieve test coverage
riccardo-ssvlabs Mar 24, 2025
6df04b6
test: achieve 100% coverage
riccardo-ssvlabs Mar 24, 2025
cdfbbe2
feat: <- slashing does not burn but send funds in the slashing fund
riccardo-ssvlabs Mar 25, 2025
6326832
feat: <- create storage contract
riccardo-ssvlabs Mar 25, 2025
a8f18d6
test: <- test setters
riccardo-ssvlabs Mar 25, 2025
db7e655
chore: <- format
riccardo-ssvlabs Mar 25, 2025
d844fa4
feat: <- remove emit obligation created event during opt in
riccardo-ssvlabs Mar 26, 2025
5b6bea5
fix(ci): <- remove nightly version
riccardo-ssvlabs Mar 26, 2025
162975f
feat: <- support and test withdraw from slashing fund, convert var to…
riccardo-ssvlabs Mar 26, 2025
a0c2711
feat: <- add reentrancy
riccardo-ssvlabs Mar 26, 2025
cb5a108
fix: typo
riccardo-ssvlabs Mar 27, 2025
d4a2a88
feat: support new architecture wip
riccardo-ssvlabs Mar 31, 2025
0fd88d6
feat: support new format
riccardo-ssvlabs Mar 31, 2025
369bde7
test: <- compliant format
riccardo-ssvlabs Mar 31, 2025
49f0150
chore: <- explicit imports
riccardo-ssvlabs Apr 1, 2025
58cf219
chore: <- prepare style for audit
riccardo-ssvlabs Apr 1, 2025
b8564bf
test: <- update modules
riccardo-ssvlabs Apr 1, 2025
826f494
test: <- clean testing and reach coverage
riccardo-ssvlabs Apr 1, 2025
236bb97
feat: <- support slashing total balance
riccardo-ssvlabs Apr 1, 2025
e435004
chore: <- polish strategy module
riccardo-ssvlabs Apr 1, 2025
0992db5
feat: <- support full slashing
riccardo-ssvlabs Apr 2, 2025
b4a7ab1
feat: <- add new view for current generation value
riccardo-ssvlabs Apr 2, 2025
fc220ad
fix: <- change owner to account because of shadowning
riccardo-ssvlabs Apr 2, 2025
07c5ad4
feat: <- test adjusted finalize withdrawal
riccardo-ssvlabs Apr 2, 2025
9a17606
test: <- achieve complete coverage
riccardo-ssvlabs Apr 2, 2025
d37db33
test: <- propose withdrawal overwrites correctly
riccardo-ssvlabs Apr 2, 2025
402f901
chore: <- polish comments
riccardo-ssvlabs Apr 2, 2025
680114a
feat: <- remove receiver from slash function
riccardo-ssvlabs Apr 3, 2025
aa20cf0
test: <- cover withdrawSlashingFund from BAppCore
riccardo-ssvlabs Apr 3, 2025
5b1fc24
chore: <- polish comments
riccardo-ssvlabs Apr 3, 2025
98d3ad7
feat: <- split strategy manager into more modules
riccardo-ssvlabs Apr 3, 2025
9723301
chore: <- add comment for review
riccardo-ssvlabs Apr 3, 2025
aa5495b
Merge pull request #34 from ssvlabs/test/split-half
riccardo-ssvlabs Apr 3, 2025
3c07a4a
feat: <- restructure repo
riccardo-ssvlabs Apr 4, 2025
88414ff
feat: <- add only owner for ssvdao methods
riccardo-ssvlabs Apr 6, 2025
5bc6de5
feat: <- add ownership test
riccardo-ssvlabs Apr 7, 2025
635d437
feat: <- update freezing implementation
riccardo-ssvlabs Apr 7, 2025
f3971e2
fix: <- use correct name for freeze timelock
riccardo-ssvlabs Apr 7, 2025
a44b072
feat: <- support slashing and obligation ajustment
riccardo-ssvlabs Apr 7, 2025
ba445bb
chore: <- remove unused var
riccardo-ssvlabs Apr 7, 2025
5162a52
feat: <- set 14 days withdrawal and obligation time
riccardo-ssvlabs Apr 7, 2025
32370fd
feat: <- update global values
riccardo-ssvlabs Apr 8, 2025
e59166b
test: <- 100% slashing coverage
riccardo-ssvlabs Apr 8, 2025
2452cc9
test: <- unify slash tests
riccardo-ssvlabs Apr 8, 2025
110beab
chore: <- format test imports
riccardo-ssvlabs Apr 8, 2025
78b74fc
feat: <- support new structure
riccardo-ssvlabs Apr 8, 2025
c66baba
feat: <- support initial var configuration
riccardo-ssvlabs Apr 9, 2025
4e82ec0
chore: <- format and remove commets
riccardo-ssvlabs Apr 11, 2025
ff6884c
feat: <- move ssvDao to ProtocolManager
riccardo-ssvlabs Apr 11, 2025
f4712f4
chore: <- fmt
riccardo-ssvlabs Apr 11, 2025
6a0b29c
feat: <- shrink in 3 modules
riccardo-ssvlabs Apr 14, 2025
afeda25
chore: <- fmt
riccardo-ssvlabs Apr 14, 2025
73b1f37
feat: <- set MAX_PERCENTAGE and ETH_ADDRESS as constants
riccardo-ssvlabs Apr 14, 2025
d0d58bc
feat: <- remove proxy and add delegateTo inside the core
riccardo-ssvlabs Apr 14, 2025
715b9de
feat: <- move errors from ICore to interfaces
riccardo-ssvlabs Apr 14, 2025
f5f93e9
chore: <- remove unused proxy
riccardo-ssvlabs Apr 14, 2025
996aa8a
feat: <- support multiple module update
riccardo-ssvlabs Apr 14, 2025
4a516aa
fix: <- remove unused updates
riccardo-ssvlabs Apr 14, 2025
2af170d
chore: <- update package.json scripts
riccardo-ssvlabs Apr 14, 2025
fe943ae
feat: <- restrict isBApp to internal
riccardo-ssvlabs Apr 14, 2025
9cf337e
feat: <- restrict isBApp to private view
riccardo-ssvlabs Apr 14, 2025
fdee33a
feat: <- add obligation updated event for slashing readjustment
riccardo-ssvlabs Apr 14, 2025
bae67af
chore: <- remove unused events and sort
riccardo-ssvlabs Apr 14, 2025
2d09b81
feat: <- add getModuleAddress in interface
riccardo-ssvlabs Apr 14, 2025
f23101d
chore: <- remove commented code
riccardo-ssvlabs Apr 14, 2025
742d133
feat: <- support pre-commit or repo
riccardo-ssvlabs Apr 15, 2025
7cc36b1
chore: <- update readme
riccardo-ssvlabs Apr 15, 2025
b1afcc1
chore: <- update readme 2
riccardo-ssvlabs Apr 15, 2025
5c4800f
chore: <- test husky
riccardo-ssvlabs Apr 15, 2025
8fe21f9
feat: <- general pre-commit w/ solhint
riccardo-ssvlabs Apr 15, 2025
3477d4d
feat: <- support lint-staged in pre-commit
riccardo-ssvlabs Apr 15, 2025
94a0270
feat: <- support new prettier
riccardo-ssvlabs Apr 15, 2025
512e2b5
feat: <- support pre-commit right order
riccardo-ssvlabs Apr 15, 2025
948ff80
feat: <- support pre-commit right order 2
riccardo-ssvlabs Apr 15, 2025
3dd7818
feat: <- update CI with new prettier
riccardo-ssvlabs Apr 15, 2025
dfb0f06
feat: <- update CI with npm instsall
riccardo-ssvlabs Apr 15, 2025
8b52564
feat: <- slashing section in README
riccardo-ssvlabs Apr 15, 2025
44580b5
chore: <- adjust ci and more readme info
riccardo-ssvlabs Apr 15, 2025
7b2b6e9
fix: <- use bound instead of assume after CI failing
riccardo-ssvlabs Apr 15, 2025
33e7187
fix: <- test
riccardo-ssvlabs Apr 15, 2025
cc5c0bb
feat: <- remove modifier and use function for _onlyStrategyOwner
riccardo-ssvlabs Apr 15, 2025
74eb236
chore: <- format
riccardo-ssvlabs Apr 15, 2025
7b87687
chore: <- format
riccardo-ssvlabs Apr 15, 2025
2848bcc
feat: <- use call to trasfer eth
riccardo-ssvlabs Apr 15, 2025
9a0a20e
chore: <- reduce fuzzer value
riccardo-ssvlabs Apr 15, 2025
ffc1de7
test: <- bApp rejects ETH transfer
riccardo-ssvlabs Apr 16, 2025
2d832f0
chore: <- remove slither from the CI
riccardo-ssvlabs Apr 16, 2025
6f05639
chore: <- remove empty test
riccardo-ssvlabs Apr 16, 2025
eb50397
fix: <- remove freezing data from struc
riccardo-ssvlabs Apr 16, 2025
585b674
chore: <- format
riccardo-ssvlabs Apr 16, 2025
c525957
chore: <- remove comments
riccardo-ssvlabs Apr 16, 2025
cc90955
feat: support one step token update WIP
riccardo-ssvlabs Apr 17, 2025
e9c2335
chore: <- remove internal method to avoid reading again from storage
riccardo-ssvlabs Apr 17, 2025
a2d5c51
chore: <- format
riccardo-ssvlabs Apr 17, 2025
8f3f96d
chore: <- remove unused vars
riccardo-ssvlabs Apr 17, 2025
75f5484
feat: test strategy owners
riccardo-ssvlabs Apr 17, 2025
350a809
feat: update readmes with more info
riccardo-ssvlabs Apr 18, 2025
a668e41
chore: <- format readme
riccardo-ssvlabs Apr 18, 2025
9583b53
chore: <- format readme 2
riccardo-ssvlabs Apr 18, 2025
3dbf4e6
feat(readme): <- add deploy instructions
riccardo-ssvlabs Apr 18, 2025
20fb611
feat(readme): <- add deploy instructions
riccardo-ssvlabs Apr 18, 2025
0db1968
Merge branch 'feat/slashing' into feat/othentic
riccardo-ssvlabs Apr 18, 2025
42f298e
feat: removed usedTokens var
riccardo-ssvlabs Apr 18, 2025
4b62a8d
feat: update module info
riccardo-ssvlabs Apr 18, 2025
e6ba580
chore: ref to deploy script
riccardo-ssvlabs Apr 18, 2025
5abbfa2
chore: <- resolve conflicts
riccardo-ssvlabs Apr 22, 2025
e72a5b5
chore: <- remove unused var
riccardo-ssvlabs Apr 22, 2025
282443b
test: <- support slashing percentage
riccardo-ssvlabs Apr 22, 2025
f77d6a2
chore: <- remove unused var
riccardo-ssvlabs Apr 22, 2025
5cb489c
chore: <- remove unused var
riccardo-ssvlabs Apr 22, 2025
502f9d8
chore: <- remove unused test
riccardo-ssvlabs Apr 22, 2025
d7eb5e2
chore: adjustments
mtabasco Apr 23, 2025
63baf0b
chore: rename functions
mtabasco Apr 23, 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
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,31 @@ These functions verify balances and authorize the caller to retrieve their accum

### How to Deploy

**1)** Run the deployment script defined in `scripts/`:
**1)** Run the deployment script `DeployProxy.s.sol` defined in `scripts/`:

__`❍ npm run deploy:holesky`__: verification is done automatically.

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

### Public Testnet
### How to Update Module Contracts

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

It is possible to update multiple modules at the same time.

**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.

### How to Upgrade the Implementation Contract

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

__`❍ 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

| Name | Proxy | Implementation | Notes |
| -------- | -------- | -------- | -------- |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "based-applications",
"version": "0.0.0",
"version": "0.0.1",
"description": "SSV Based Applications",
"author": "SSV.Network",
"repository": {
Expand Down
5 changes: 5 additions & 0 deletions scripts/DeployProxy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ contract DeployProxy is Script {
withdrawalExpireTime: 3 days,
obligationTimelockPeriod: 14 days,
obligationExpireTime: 3 days,
tokenUpdateTimelockPeriod: 14 days,
maxFeeIncrement: 500
});

Expand Down Expand Up @@ -76,6 +77,10 @@ contract DeployProxy is Script {
config.obligationTimelockPeriod
);
console.log("Obligation Expire Time:", config.obligationExpireTime);
console.log(
"Token Update Timelock Period:",
config.tokenUpdateTimelockPeriod
);
console.log("Max Shares:", config.maxShares);
console.log("Max Fee Increment:", config.maxFeeIncrement);
vm.stopBroadcast();
Expand Down
53 changes: 39 additions & 14 deletions src/core/SSVBasedApps.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ contract SSVBasedApps is
IBasedAppManager ssvBasedAppManger_,
IStrategyManager ssvStrategyManager_,
IProtocolManager protocolManager_,
ProtocolStorageLib.Data memory config
ProtocolStorageLib.Data calldata config
) external override initializer onlyProxy {
__UUPSUpgradeable_init();
__Ownable_init_unchained(owner_);
Expand All @@ -89,7 +89,7 @@ contract SSVBasedApps is
IBasedAppManager ssvBasedAppManger_,
IStrategyManager ssvStrategyManager_,
IProtocolManager protocolManager_,
ProtocolStorageLib.Data memory config
ProtocolStorageLib.Data calldata config
) internal onlyInitializing {
CoreStorageLib.Data storage s = CoreStorageLib.load();
ProtocolStorageLib.Data storage sp = ProtocolStorageLib.load();
Expand All @@ -114,6 +114,7 @@ contract SSVBasedApps is
sp.withdrawalExpireTime = config.withdrawalExpireTime;
sp.obligationTimelockPeriod = config.obligationTimelockPeriod;
sp.obligationExpireTime = config.obligationExpireTime;
sp.tokenUpdateTimelockPeriod = config.tokenUpdateTimelockPeriod;
sp.maxShares = config.maxShares;

emit MaxFeeIncrementSet(sp.maxFeeIncrement);
Expand Down Expand Up @@ -147,6 +148,12 @@ contract SSVBasedApps is
_delegateTo(SSVCoreModules.SSV_BAPPS_MANAGER);
}

function updateBAppsTokens(
ICore.TokenConfig[] calldata tokenConfigs
) external {
_delegateTo(SSVCoreModules.SSV_BAPPS_MANAGER);
}

function createObligation(
uint32 strategyId,
address bApp,
Expand Down Expand Up @@ -271,7 +278,7 @@ contract SSVBasedApps is
uint32 strategyId,
address bApp,
address token,
uint256 amount,
uint32 percentage,

Choose a reason for hiding this comment

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

Maybe you should consider working with wads instead of percentage

bytes calldata data
) external {
_delegateTo(SSVCoreModules.SSV_STRATEGY_MANAGER);
Expand Down Expand Up @@ -323,6 +330,10 @@ contract SSVBasedApps is
_delegateTo(SSVCoreModules.SSV_PROTOCOL_MANAGER);
}

function updateTokenUpdateTimelockPeriod(uint32 value) external onlyOwner {
_delegateTo(SSVCoreModules.SSV_PROTOCOL_MANAGER);
}

function updateMaxShares(uint256 value) external onlyOwner {
_delegateTo(SSVCoreModules.SSV_PROTOCOL_MANAGER);
}
Expand Down Expand Up @@ -364,6 +375,13 @@ contract SSVBasedApps is
return (s.strategies[strategyId].owner, s.strategies[strategyId].fee);
}

function ownedStrategies(
address owner
) external view returns (uint32[] memory strategyIds) {
CoreStorageLib.Data storage s = CoreStorageLib.load();
return s.strategyOwners[owner];
}

function strategyAccountShares(
uint32 strategyId,
address account,
Expand Down Expand Up @@ -420,22 +438,25 @@ contract SSVBasedApps is
);
}

function usedTokens(
uint32 strategyId,
address token
) external view returns (uint32) {
CoreStorageLib.Data storage s = CoreStorageLib.load();
return s.usedTokens[strategyId][token];
}

function bAppTokens(
address bApp,
address token
) external view returns (uint32 value, bool isSet) {
)
external
view
returns (
uint32 currentValue,
bool isSet,
uint32 pendingValue,
uint32 effectTime
)
{
CoreStorageLib.Data storage s = CoreStorageLib.load();
return (
s.bAppTokens[bApp][token].value,
s.bAppTokens[bApp][token].isSet
s.bAppTokens[bApp][token].currentValue,
s.bAppTokens[bApp][token].isSet,
s.bAppTokens[bApp][token].pendingValue,
s.bAppTokens[bApp][token].effectTime
);
}

Expand Down Expand Up @@ -533,6 +554,10 @@ contract SSVBasedApps is
return ProtocolStorageLib.load().obligationExpireTime;
}

function tokenUpdateTimelockPeriod() external view returns (uint32) {
return ProtocolStorageLib.load().tokenUpdateTimelockPeriod;
}

function getVersion() external pure returns (string memory) {
return "0.0.1";
}
Expand Down
16 changes: 11 additions & 5 deletions src/core/interfaces/IBasedAppManager.sol
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.29;

import { ICore } from "@ssv/src/core/interfaces/ICore.sol";

interface IBasedAppManager {
event BAppMetadataURIUpdated(
address indexed bAppAddress,
string metadataURI
);
event BAppMetadataURIUpdated(address indexed bApp, string metadataURI);
event BAppRegistered(
address indexed bAppAddress,
address indexed bApp,
address[] tokens,
uint32[] sharedRiskLevel,
string metadataURI
);
event BAppTokensUpdated(
address indexed bApp,
ICore.TokenConfig[] tokenConfigs
);

function registerBApp(
address[] calldata tokens,
uint32[] calldata sharedRiskLevels,
string calldata metadataURI
) external;
function updateBAppMetadataURI(string calldata metadataURI) external;
function updateBAppsTokens(
ICore.TokenConfig[] calldata tokenConfigs
) external;

error BAppAlreadyRegistered();
error BAppDoesNotSupportInterface();
Expand Down
16 changes: 15 additions & 1 deletion src/core/interfaces/ICore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ interface ICore {
/// @dev The shared risk level
/// Encoding: The value is stored as a uint32. However, it represents a real (float) value.
/// To get the actual real value (decode), divide by 10^6.
uint32 value;
uint32 currentValue;
/// @dev if the shared risk level is set
bool isSet;
/// @dev The value to be updated
uint32 pendingValue;
/// @dev The block time when the update request was sent
uint32 effectTime;
}

/// @notice Represents an Obligation
Expand Down Expand Up @@ -67,4 +71,14 @@ interface ICore {
/// @dev The account latest generation
mapping(address => uint256) accountGeneration;
}

struct TokenUpdateRequest {
TokenConfig[] tokens;
uint32 requestTime;
}

struct TokenConfig {
address token;
uint32 sharedRiskLevel;
}
}
2 changes: 2 additions & 0 deletions src/core/interfaces/IProtocolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ interface IProtocolManager {
event FeeTimelockPeriodUpdated(uint32 feeTimelockPeriod);
event ObligationExpireTimeUpdated(uint32 obligationExpireTime);
event ObligationTimelockPeriodUpdated(uint32 obligationTimelockPeriod);
event TokenUpdateTimelockPeriodUpdated(uint32 tokenUpdateTimelockPeriod);
event StrategyMaxFeeIncrementUpdated(uint32 maxFeeIncrement);
event StrategyMaxSharesUpdated(uint256 maxShares);
event WithdrawalExpireTimeUpdated(uint32 withdrawalExpireTime);
Expand All @@ -17,6 +18,7 @@ interface IProtocolManager {
function updateMaxShares(uint256 value) external;
function updateObligationExpireTime(uint32 value) external;
function updateObligationTimelockPeriod(uint32 value) external;
function updateTokenUpdateTimelockPeriod(uint32 value) external;
function updateWithdrawalExpireTime(uint32 value) external;
function updateWithdrawalTimelockPeriod(uint32 value) external;
}
4 changes: 2 additions & 2 deletions src/core/interfaces/IStrategyManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ interface IStrategyManager {
uint32 indexed strategyId,
address indexed bApp,
address token,
uint256 amount,
uint32 percentage,
address receiver
);

Expand Down Expand Up @@ -148,7 +148,7 @@ interface IStrategyManager {
uint32 strategyId,
address bApp,
address token,
uint256 amount,
uint32 percentage,
bytes calldata data
) external;
function updateAccountMetadataURI(string calldata metadataURI) external;
Expand Down
17 changes: 11 additions & 6 deletions src/core/libraries/CoreStorageLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ library CoreStorageLib {
* @dev The strategy ID is incremental and unique
*/
mapping(uint32 strategyId => ICore.Strategy) strategies;
/**
* @notice Tracks the owners of the strategies
* @dev The strategy ID is incremental and unique
*/
mapping(address owner => uint32[] strategyId) strategyOwners;
/**
* @notice Links an account to a single strategy for a specific bApp
* @dev Guarantees that an account cannot have more than one strategy for a given bApp
Expand All @@ -47,12 +52,6 @@ library CoreStorageLib {
* @dev Uses a hash of the bApp and token to map the obligation percentage for the strategy.
*/
mapping(uint32 strategyId => mapping(address bApp => mapping(address token => ICore.Obligation))) obligations;
/**
* @notice Tracks unallocated tokens in a strategy.
* @dev Count the number of bApps that have one obligation set for the token.
* If the counter is 0, the token is unused and we can allow fast withdrawal.
*/
mapping(uint32 strategyId => mapping(address token => uint32 bAppsCounter)) usedTokens;
/**
* @notice Tracks all the withdrawal requests divided by token per strategy.
* @dev User can have only one pending withdrawal request per token.
Expand Down Expand Up @@ -87,6 +86,12 @@ library CoreStorageLib {
* @dev The bApp is identified with its address
*/
mapping(address bApp => mapping(address token => ICore.SharedRiskLevel)) bAppTokens;
/**
* @notice Tracks the token update requests for a bApp
* @dev Only the bApp owner can submit one.
* Submitting a new request will overwrite the previous one and reset the timer.
*/
mapping(address bApp => ICore.TokenUpdateRequest) tokenUpdateRequests;
}

uint256 private constant SSV_BASED_APPS_STORAGE_POSITION =
Expand Down
1 change: 1 addition & 0 deletions src/core/libraries/ProtocolStorageLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ library ProtocolStorageLib {
uint32 withdrawalExpireTime;
uint32 obligationTimelockPeriod;
uint32 obligationExpireTime;
uint32 tokenUpdateTimelockPeriod;
uint32 maxFeeIncrement;
uint256 maxShares;
}
Expand Down
Loading
Loading