Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking β€œSign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Vaults #874

Draft
wants to merge 552 commits into
base: develop
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
552 commits
Select commit Hold shift + click to select a range
75fa209
return types of vault storage
loga4 Nov 7, 2024
007794d
reduce size for locked and inOutDelta vars
loga4 Nov 7, 2024
852d82c
vaultStafffRoomParams refactoring
loga4 Nov 7, 2024
b4955c5
add notes for initialization _params var
loga4 Nov 7, 2024
9652868
fix: solhint
tamtamchik Nov 7, 2024
aa3efdd
chore: apply IStakingVault to StakingVault
tamtamchik Nov 7, 2024
34b654a
test: small refactoring
tamtamchik Nov 7, 2024
5973c00
fix: ci warnings
tamtamchik Nov 8, 2024
fae1537
chore: update deps
tamtamchik Nov 8, 2024
c83edc3
move report storage values to Report struct
loga4 Nov 8, 2024
c8d19e6
move report storage values to Report struct
loga4 Nov 8, 2024
4c2ae7c
Merge pull request #19 from lidofinance/feat/factory
folkyatina Nov 8, 2024
94f1d18
Merge pull request #25 from lidofinance/dependabot/npm_and_yarn/secp2…
folkyatina Nov 8, 2024
c7bbf23
fix: return value and stuff
folkyatina Nov 8, 2024
9cfe04e
unify events
loga4 Nov 8, 2024
c384a2c
Merge pull request #35 from lidofinance/factory/minor_fixes
loga4 Nov 8, 2024
8206704
chore: fixes for vaults reporting
tamtamchik Nov 9, 2024
7987794
Update contracts/0.8.25/vaults/StakingVault.sol
tamtamchik Nov 9, 2024
58e5b83
test(integration): restore partially happy path
tamtamchik Nov 9, 2024
0757a90
fix: solhint
tamtamchik Nov 9, 2024
97f330b
test(integration): finish happy path
tamtamchik Nov 10, 2024
b6e4f82
Merge pull request #36 from lidofinance/feat/fixes
tamtamchik Nov 11, 2024
c26f793
Merge branch 'main' into minting
tamtamchik Nov 13, 2024
8e0c17f
chore: update scratch deploy
tamtamchik Nov 13, 2024
ba2c2aa
Merge pull request #37 from lidofinance/feat/update-scratch
folkyatina Nov 14, 2024
20770b3
chore: mekong deploy
tamtamchik Nov 18, 2024
c0bd5c2
chore: enable gas reporter
mymphe Nov 26, 2024
e85791b
feat: delegation layer with committee actions
mymphe Nov 26, 2024
ab52647
fix: remove misleading comments
mymphe Nov 26, 2024
eb9195f
Merge branch 'develop' into feat/vaults
tamtamchik Nov 26, 2024
97612ee
test(integration): update second opinion integration test
tamtamchik Nov 26, 2024
7943917
fix: typecheck
tamtamchik Nov 26, 2024
1eafcbe
test(integration): fix scratch deploy
tamtamchik Nov 26, 2024
599806a
test: fix locator issue
tamtamchik Nov 26, 2024
6f8c01c
test: fix sanity checker issue
tamtamchik Nov 26, 2024
528dae7
ci: enable workflows
tamtamchik Nov 27, 2024
ce34c54
chore: update dependencies
tamtamchik Nov 27, 2024
1e57a1b
chore: exclude OZ contracts from the coverage
tamtamchik Nov 27, 2024
803199c
chore: apply suggestions from code review
tamtamchik Nov 27, 2024
d56c26f
feat: add proper upgrade to version 3 in Lido
folkyatina Nov 27, 2024
bf83fcd
chore: update deps
tamtamchik Nov 27, 2024
d376ee3
chore: bump node to 22.11
tamtamchik Nov 27, 2024
f560380
chore: apply suggestions from code review
tamtamchik Nov 27, 2024
6286561
test: fix getMaxExternalEther in tests
tamtamchik Nov 27, 2024
e14f443
Merge branch 'feat/vaults' into feat/vaults-develop-sync
tamtamchik Nov 27, 2024
f9ca4a4
feat: role and erc7201 storage
loga4 Nov 27, 2024
043b26e
feat: update owner contracts
mymphe Nov 28, 2024
1102123
feat: reanme del owner
mymphe Nov 28, 2024
29cde40
fix: clean up
mymphe Nov 28, 2024
137ced5
test: update tests
mymphe Nov 28, 2024
ae0f7f1
fix: renames
mymphe Nov 28, 2024
06b3c39
Merge branch 'feat/vaults' of https://github.com/lidofinance/core int…
mymphe Nov 28, 2024
038e2bd
fix(Lido): remove excessive initialize
folkyatina Nov 28, 2024
b2b413e
Merge pull request #882 from lidofinance/fix/lido-upgrade-version
folkyatina Nov 28, 2024
41ed2c7
feat: add accounting initializer
loga4 Nov 29, 2024
9b59268
feat: refactor StakingVault initialization
loga4 Nov 29, 2024
fa8e84c
fix: extract mint/burning to Lido
folkyatina Nov 28, 2024
728d828
fix: accouting scratch deploy fixed
loga4 Nov 29, 2024
481979d
fix: rename long name to Dashboard
mymphe Nov 29, 2024
ce82205
fix: rename long name to Delegation
mymphe Nov 29, 2024
d2c8008
fix: file renaming
mymphe Nov 29, 2024
7166610
fix: minor fixes
loga4 Nov 29, 2024
a0ed62c
Merge pull request #886 from lidofinance/feat/staking-vault-init
folkyatina Nov 29, 2024
ebbad1a
fix: disable warning for unused report values
mymphe Nov 29, 2024
c376856
Merge branch 'feat/vaults' of https://github.com/lidofinance/core int…
mymphe Nov 29, 2024
b2ef4fe
fix: grant NO role to set fee
mymphe Nov 29, 2024
a4b15fd
Merge branch 'develop' into feat/vaults-develop-sync
tamtamchik Nov 29, 2024
2a0233d
Merge branch 'feat/vaults' into feat/vaults-develop-sync
tamtamchik Nov 29, 2024
f5cadef
test: disable suspicious test
tamtamchik Nov 30, 2024
d607895
fix: clean up imports
mymphe Dec 2, 2024
41bbc8e
fix: rebalanace should not be payable
mymphe Dec 2, 2024
b75c742
feat: add a comment for clarity on contract duplication
mymphe Dec 2, 2024
1cc1ded
fix: remove unused import
mymphe Dec 2, 2024
a8f95a9
feat: add detailed explainers
mymphe Dec 2, 2024
dd485cd
fix: make eslint happy
mymphe Dec 2, 2024
fc5b704
fix: make eslint even happier
mymphe Dec 2, 2024
580a703
fix: use array instead of bitmap
mymphe Dec 2, 2024
847c9ab
chore: missed new line
folkyatina Dec 2, 2024
a18c2f0
Merge pull request #880 from lidofinance/vaults/fix-no
folkyatina Dec 2, 2024
6d8426f
Merge pull request #885 from lidofinance/fix/lido-mintburning
folkyatina Dec 2, 2024
f0d14ce
feat: add a detailed comment on voting
mymphe Dec 2, 2024
417d433
feat: exact gas saved
mymphe Dec 2, 2024
d534778
Merge pull request #888 from lidofinance/committee-replace-bitmap
mymphe Dec 2, 2024
fe2b426
Merge branch 'feat/vaults' into feat/vaults-develop-sync
tamtamchik Dec 2, 2024
eb9c29e
fix: integration tests UnknownError
tamtamchik Dec 2, 2024
e7b546e
chore: decrease coverage threshold
tamtamchik Dec 2, 2024
5de258b
fix: remove checkExtraDataItemsCountPerTransaction from second phase
tamtamchik Dec 2, 2024
e83f05f
Merge pull request #881 from lidofinance/feat/vaults-develop-sync
tamtamchik Dec 2, 2024
7e7edee
fix: update stvault interface
mymphe Dec 3, 2024
2de4da5
fix: check balance before unlocked
mymphe Dec 3, 2024
733740a
chore: apply review recommendations
tamtamchik Dec 3, 2024
0aadf9f
chore: refactoring
tamtamchik Dec 3, 2024
d9f1f14
test: lido external balance
tamtamchik Dec 3, 2024
28fedbd
chore: refactoring
tamtamchik Dec 3, 2024
2e1c3c0
chore: update naming and tests
tamtamchik Dec 3, 2024
2e20710
chore: update comments
tamtamchik Dec 3, 2024
aee1294
test: lido external balance with minting and burning
tamtamchik Dec 3, 2024
1bcd4fd
fix: eoa owner should not revert
mymphe Dec 4, 2024
6a88a0e
chore: cleanup
tamtamchik Dec 4, 2024
9f4ddcc
chore: holesky devnet 1
tamtamchik Dec 4, 2024
fa53eb4
chore: verified deployed contracts
tamtamchik Dec 4, 2024
fb2aa93
Merge pull request #889 from lidofinance/feat/review
folkyatina Dec 5, 2024
9030b5c
fix: check before sstore
mymphe Dec 5, 2024
03a84a8
fix: use precise error for locking
mymphe Dec 5, 2024
681c122
fix: various vaultHub fixes after the review
folkyatina Dec 4, 2024
1395555
fix: set withdraw recipient to vaulthub on rebalance
mymphe Dec 6, 2024
751c77e
fix: update action name for error
mymphe Dec 6, 2024
17b88bf
fix: handle report hook for different account types
mymphe Dec 6, 2024
a50851f
chore: bump hh
mymphe Dec 6, 2024
91d432e
test: staking vault full coverage*
mymphe Dec 6, 2024
e88a7de
test: broken test for precision loss
folkyatina Dec 5, 2024
0cdfaf8
fix: external shares in Lido
folkyatina Dec 6, 2024
8d6b255
feat: suggestions for additional methods to improve the UX of interac…
DiRaiks Dec 6, 2024
d4250c1
fix: weth call withdraw
DiRaiks Dec 6, 2024
3725cea
feat: add burn for wstETH (with permit)
DiRaiks Dec 6, 2024
8af0dc0
Update contracts/0.8.25/vaults/Dashboard.sol
DiRaiks Dec 6, 2024
e539ece
Update contracts/0.8.25/vaults/Dashboard.sol
DiRaiks Dec 6, 2024
94509bc
fix: accounting and unit tests
folkyatina Dec 7, 2024
212ec13
fix: remove safecast
mymphe Dec 9, 2024
50b04f6
fix: some vault renaming and cleanup
mymphe Dec 9, 2024
1205e6e
feat: update interfaces, update methods for work with weth/wsteth
DiRaiks Dec 9, 2024
4d3b8ea
Merge branch 'feat/vaults-suggestions' of github.com:lidofinance/core…
DiRaiks Dec 9, 2024
b3a50f5
feat: delete vaultsByOwner from VaultHub
DiRaiks Dec 9, 2024
bca1ddc
Merge pull request #894 from lidofinance/develop
tamtamchik Dec 9, 2024
9faf18a
chore: add q about recovery
mymphe Dec 10, 2024
1b7ca1e
feat: mint shares for vaults
folkyatina Dec 10, 2024
d040e12
fix: don't try to decrease the locked amount
folkyatina Dec 10, 2024
06340ca
test: dashboard
mymphe Dec 10, 2024
6f14ec7
fix: fix resorting on vaults' report
folkyatina Dec 10, 2024
20d7db8
fix: consistent naming
mymphe Dec 10, 2024
2c31ba1
feat: add wstETH to locator
tamtamchik Dec 10, 2024
e94cd96
chore: fix tests and types
tamtamchik Dec 10, 2024
1fad723
chore: updated devnet setup
tamtamchik Dec 10, 2024
ef39ef1
docs: update readme status badges
tamtamchik Dec 11, 2024
1a843a9
fix: remove only
mymphe Dec 11, 2024
7a7e622
test: delegation tests (wip)
mymphe Dec 11, 2024
953f5e6
fix: various accounting bugs on migration to shares
folkyatina Dec 11, 2024
4875492
chore: names and formatting
folkyatina Dec 11, 2024
e137105
fix: rename beacon chain depositor to logistics
mymphe Dec 12, 2024
a4e4ad1
chore: formatting and comments
folkyatina Dec 12, 2024
8b023e5
fix: add event for externalShares change
folkyatina Dec 12, 2024
7ca3cdc
chore: comments
folkyatina Dec 12, 2024
f229b7a
test: fix tests
folkyatina Dec 12, 2024
5c40f69
Merge pull request #891 from lidofinance/precision-loss
folkyatina Dec 12, 2024
cfc013b
feat: fix operator in the vault
mymphe Dec 13, 2024
2427c02
feat: add LDO holder for staking interface needs
tamtamchik Dec 13, 2024
11c74e7
build(deps): bump cross-spawn from 7.0.3 to 7.0.6
dependabot[bot] Dec 13, 2024
2114611
chore: add BeaconProxy to deploy for verification purposes
tamtamchik Dec 13, 2024
5185b04
fix: catch run out of gas error in report hook
mymphe Dec 16, 2024
ca89ffc
Merge pull request #898 from lidofinance/feat/locator-wsteth
folkyatina Dec 16, 2024
446c36d
Merge pull request #895 from lidofinance/feat/readme-update
tamtamchik Dec 16, 2024
76ec271
featL add permit modifier, fix errors, update Delegation constructor
DiRaiks Dec 16, 2024
a4febe8
Merge branch 'feat-immutable-operator-in-vault' of github.com:lidofin…
DiRaiks Dec 16, 2024
2963755
Merge pull request #890 from lidofinance/feat/vaults-devnet
tamtamchik Dec 16, 2024
31d419b
feat: update dashboard consts and methods, add tests
DiRaiks Dec 17, 2024
204260e
Merge branch 'develop' into feat/vaults
tamtamchik Dec 17, 2024
7d3047d
feat: rebalance shortcut in Lido
folkyatina Dec 17, 2024
4daff2d
test: improve external share tests
folkyatina Dec 17, 2024
168d025
chore: improve comments and some bits
folkyatina Dec 17, 2024
cb6ed42
fix: revert mintburning if paused
folkyatina Dec 17, 2024
ce7ccb8
Merge branch 'feat/vaults' into feat-immutable-operator-in-vault
tamtamchik Dec 17, 2024
496e6f2
test: fix .only in tests
tamtamchik Dec 17, 2024
d4b170c
Merge branch 'feat-immutable-operator-in-vault' into feat/vaults-sugg…
tamtamchik Dec 17, 2024
79653dd
ci: use hardhat 2.22.17
tamtamchik Dec 17, 2024
bb43b2e
fix: ensure rebalance amount doesn't exceed valuation
mymphe Dec 18, 2024
afcb7d3
Merge branch 'feat-immutable-operator-in-vault' of https://github.com…
mymphe Dec 18, 2024
1463ad3
fix: update eip7201 location
mymphe Dec 18, 2024
611ce3a
fix: simplify external shares accounting
folkyatina Dec 18, 2024
0099af6
fix: dashboard naming & tests
Jeday Dec 18, 2024
7045ec3
test: add tests for mintWstETH, burnWstETH
DiRaiks Dec 18, 2024
705bb31
fix: burnWstETHWithPermit method
DiRaiks Dec 18, 2024
5ba2431
Merge branch 'feat/vaults-suggestions' of github.com:lidofinance/core…
DiRaiks Dec 18, 2024
f3b4ed9
fix: canMint lower bound
Jeday Dec 18, 2024
aaf6ee6
Merge branch 'feat/vaults-suggestions' of github.com:lidofinance/core…
Jeday Dec 18, 2024
7c8eb29
test: canMint bound by shareLimit
Jeday Dec 18, 2024
8e0e547
tests: fix burnWstETH
DiRaiks Dec 18, 2024
1eb5e62
fix: dashboard naming
Jeday Dec 18, 2024
776f3c5
Merge branch 'feat/vaults-suggestions' of github.com:lidofinance/core…
Jeday Dec 18, 2024
39c155f
Merge pull request #892 from lidofinance/vaulthub-after-review
TheDZhon Dec 18, 2024
8669b43
fix: merge canMintShares
Jeday Dec 18, 2024
77fccb4
chore: fix pragma for test contracts
tamtamchik Dec 18, 2024
d1a3e7e
chore: fix scratch deploy
tamtamchik Dec 18, 2024
b8028c7
test(integration): stabilize vaults happy path
tamtamchik Dec 18, 2024
b4e1e35
test: fix tests
tamtamchik Dec 18, 2024
17669d6
test(integration): skip negative rebase tests for now
tamtamchik Dec 18, 2024
c89ac39
test: can withdraw test
Jeday Dec 19, 2024
732dbf4
feat: update comments
mymphe Dec 19, 2024
6256c16
fix: revert report if onReport ran out of gas
mymphe Dec 19, 2024
6616579
chore: extract some vaults helpers to library
tamtamchik Dec 19, 2024
04100c0
chore: update StETH harness contract for dashboard tests
tamtamchik Dec 19, 2024
65ec051
tests: start burn permit tests
DiRaiks Dec 19, 2024
6065f91
chore: simplify constructor
tamtamchik Dec 19, 2024
00223f4
fix: constructor
tamtamchik Dec 19, 2024
7d6da64
tests: fix steth events
DiRaiks Dec 19, 2024
7b58f62
Merge branch 'feat/steth-permit' of github.com:lidofinance/core into …
DiRaiks Dec 19, 2024
85baf12
Merge pull request #903 from lidofinance/feat/steth-permit
tamtamchik Dec 19, 2024
dd9157e
Merge branch 'feat-immutable-operator-in-vault' into feat/vaults-sugg…
tamtamchik Dec 19, 2024
856e6ef
fix: comments and tests
tamtamchik Dec 19, 2024
14e6273
fix: integration tests
tamtamchik Dec 19, 2024
c56493e
Merge branch 'feat/vaults-suggestions' of github.com:lidofinance/core…
DiRaiks Dec 19, 2024
3d5fbb8
tests: add tests for burnWstETHWithPermit and burnWithPermit, fix bur…
DiRaiks Dec 19, 2024
34261a9
Merge branch 'feat/vaults' of https://github.com/lidofinance/core int…
mymphe Dec 20, 2024
bc86331
feat: use Ownable interface for owner()
mymphe Dec 20, 2024
21425d0
fix: dashboard tests
mymphe Dec 20, 2024
7899756
fix: use consistent naming for bp
mymphe Dec 20, 2024
8d7a6af
fix: sort imports
mymphe Dec 20, 2024
2f0ec60
fix: add comment for codesize check
mymphe Dec 20, 2024
d9888f0
fix: take operator from vault
mymphe Dec 20, 2024
dcc5203
Merge pull request #902 from lidofinance/feat/vaults-actions
Jeday Dec 20, 2024
e9e105d
fix: dashboard naming
Jeday Dec 20, 2024
02c78b9
Merge branch 'feat-immutable-operator-in-vault' of github.com:lidofin…
Jeday Dec 20, 2024
592f06f
fix: add ERC20 token to lido interface
Jeday Dec 20, 2024
fe033da
test: fix vault hub mock
Jeday Dec 20, 2024
777d6ce
fix: interfaces&imports
Jeday Dec 20, 2024
13a0464
fix: ILido
Jeday Dec 20, 2024
14fe2d8
test(integration): fix and update vaults happy path
tamtamchik Dec 20, 2024
c34ebe1
test(integration): fix and update vaults happy path
tamtamchik Dec 20, 2024
0739501
Merge branch 'feat-immutable-operator-in-vault' into feat/vaults-sugg…
tamtamchik Dec 20, 2024
4897271
test: disable negative rebase integration test
tamtamchik Dec 20, 2024
49ba3fd
Merge branch 'feat-immutable-operator-in-vault' into feat/vaults-sugg…
tamtamchik Dec 20, 2024
d0b1d4c
fix: remove onReport hook πŸ‘
mymphe Dec 20, 2024
f7086b5
Merge branch 'feat-immutable-operator-in-vault' of https://github.com…
mymphe Dec 20, 2024
972b84c
fix: delegation tests
tamtamchik Dec 20, 2024
887fec3
fix: enable all the tests
tamtamchik Dec 20, 2024
6d4bd11
Merge branch 'feat-immutable-operator-in-vault' into feat/vaults-sugg…
tamtamchik Dec 20, 2024
c808b26
chore: updates after review
tamtamchik Dec 20, 2024
10897a0
fix: contract compilation
tamtamchik Dec 20, 2024
e2c380f
chore: restore some formating
tamtamchik Dec 20, 2024
0408978
feat: rework delegation
mymphe Dec 23, 2024
61163ae
tests: fix getMintableShares test
DiRaiks Dec 24, 2024
9099c27
fix: comments and formatting
folkyatina Dec 24, 2024
b3e53b5
feat(Delegation): add comments
mymphe Dec 24, 2024
dbabb36
test(integration): update for new delegation
mymphe Dec 24, 2024
a936b19
fix: wrong checks in external share limit
folkyatina Dec 24, 2024
b2cc291
test: remove only
mymphe Dec 24, 2024
e4f8595
Merge branch 'feat-immutable-operator-in-vault' into feat/vaults-sugg…
tamtamchik Dec 24, 2024
2168c79
Merge pull request #893 from lidofinance/feat/vaults-suggestions
tamtamchik Dec 24, 2024
b9ffdf6
Merge pull request #897 from lidofinance/feat-immutable-operator-in-v…
tamtamchik Dec 24, 2024
a9154a7
chore: fix slither
tamtamchik Dec 24, 2024
5ae82dd
Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/cross-sp…
tamtamchik Dec 24, 2024
01a41e4
build(deps-dev): bump aiohttp from 3.10.5 to 3.10.11
dependabot[bot] Dec 24, 2024
9f2d151
build(deps): bump @eslint/plugin-kit from 0.2.0 to 0.2.4
dependabot[bot] Dec 24, 2024
7c2d498
Merge remote-tracking branch 'origin/dependabot/pip/aiohttp-3.10.11' …
tamtamchik Dec 24, 2024
1659803
Merge remote-tracking branch 'origin/dependabot/npm_and_yarn/eslint/p…
tamtamchik Dec 24, 2024
3cb1d76
fix: bump hardhat version
tamtamchik Dec 24, 2024
901c0e1
Merge pull request #906 from lidofinance/feat/dependabot-updates
TheDZhon Dec 24, 2024
ab1db80
Merge remote-tracking branch 'origin/master' into feat/vaults
tamtamchik Dec 25, 2024
eafd3bc
chore: deploy devnet 2
tamtamchik Dec 25, 2024
978ff1e
Merge pull request #907 from lidofinance/feat/vaults-devnet-2
tamtamchik Dec 27, 2024
df8400f
chore: ignore only contracts in prettier
tamtamchik Dec 30, 2024
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
refactor: rename Vault->StakingVault
mymphe committed Oct 24, 2024

Verified

This commit was signed with the committer’s verified signature.
commit 24c741057484186479f491580c24b7e3d08b30b4
10 changes: 5 additions & 5 deletions contracts/0.8.25/vaults/DelegatorAlligator.sol
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
pragma solidity 0.8.25;

import {AccessControlEnumerable} from "@openzeppelin/contracts-v5.0.2/access/extensions/AccessControlEnumerable.sol";
import {IVault} from "./interfaces/IVault.sol";
import {IStakingVault} from "./interfaces/IStakingVault.sol";

// DelegatorAlligator: Vault Delegated Owner
// 3-Party Role Setup: Manager, Depositor, Operator
@@ -32,9 +32,9 @@ contract DelegatorAlligator is AccessControlEnumerable {
bytes32 public constant DEPOSITOR_ROLE = keccak256("Vault.DelegatorAlligator.DepositorRole");
bytes32 public constant OPERATOR_ROLE = keccak256("Vault.DelegatorAlligator.OperatorRole");

IVault public immutable vault;
IStakingVault public immutable vault;

IVault.Report public lastClaimedReport;
IStakingVault.Report public lastClaimedReport;

uint256 public managementFee;
uint256 public performanceFee;
@@ -45,7 +45,7 @@ contract DelegatorAlligator is AccessControlEnumerable {
if (_vault == address(0)) revert ZeroArgument("_vault");
if (_defaultAdmin == address(0)) revert ZeroArgument("_defaultAdmin");

vault = IVault(_vault);
vault = IStakingVault(_vault);
_grantRole(DEFAULT_ADMIN_ROLE, _defaultAdmin);
}

@@ -62,7 +62,7 @@ contract DelegatorAlligator is AccessControlEnumerable {
}

function getPerformanceDue() public view returns (uint256) {
IVault.Report memory latestReport = vault.latestReport();
IStakingVault.Report memory latestReport = vault.latestReport();

int128 _performanceDue = int128(latestReport.valuation - lastClaimedReport.valuation) -
int128(latestReport.inOutDelta - lastClaimedReport.inOutDelta);
Original file line number Diff line number Diff line change
@@ -6,11 +6,11 @@ pragma solidity 0.8.25;

import {OwnableUpgradeable} from "contracts/openzeppelin/5.0.2/upgradeable/access/OwnableUpgradeable.sol";
import {VaultBeaconChainDepositor} from "./VaultBeaconChainDepositor.sol";
import {IHub} from "./interfaces/IHub.sol";
import {IVaultHub} from "./interfaces/IVaultHub.sol";
import {IReportValuationReceiver} from "./interfaces/IReportValuationReceiver.sol";
import {SafeCast} from "@openzeppelin/contracts-v5.0.2/utils/math/SafeCast.sol";

contract Vault is VaultBeaconChainDepositor, OwnableUpgradeable {
contract StakingVault is VaultBeaconChainDepositor, OwnableUpgradeable {
event Funded(address indexed sender, uint256 amount);
event Withdrawn(address indexed sender, address indexed recipient, uint256 amount);
event DepositedToBeaconChain(address indexed sender, uint256 numberOfDeposits, uint256 amount);
@@ -33,7 +33,7 @@ contract Vault is VaultBeaconChainDepositor, OwnableUpgradeable {

uint256 private constant MAX_FEE = 100_00;

IHub public immutable hub;
IVaultHub public immutable vaultHub;
Report public latestReport;
uint256 public locked;
int256 public inOutDelta;
@@ -46,7 +46,7 @@ contract Vault is VaultBeaconChainDepositor, OwnableUpgradeable {
if (_owner == address(0)) revert ZeroArgument("_owner");
if (_hub == address(0)) revert ZeroArgument("_hub");

hub = IHub(_hub);
vaultHub = IVaultHub(_hub);
_transferOwnership(_owner);
}

@@ -122,7 +122,7 @@ contract Vault is VaultBeaconChainDepositor, OwnableUpgradeable {
if (_recipient == address(0)) revert ZeroArgument("_recipient");
if (_tokens == 0) revert ZeroArgument("_tokens");

uint256 newlyLocked = hub.mintStethBackedByVault(_recipient, _tokens);
uint256 newlyLocked = vaultHub.mintStethBackedByVault(_recipient, _tokens);

if (newlyLocked > locked) {
locked = newlyLocked;
@@ -134,28 +134,28 @@ contract Vault is VaultBeaconChainDepositor, OwnableUpgradeable {
function burn(uint256 _tokens) external onlyOwner {
if (_tokens == 0) revert ZeroArgument("_tokens");

hub.burnStethBackedByVault(_tokens);
vaultHub.burnStethBackedByVault(_tokens);
}

function rebalance(uint256 _ether) external payable {
if (_ether == 0) revert ZeroArgument("_ether");
if (_ether > address(this).balance) revert InsufficientBalance(address(this).balance);

if (owner() == msg.sender || (!isHealthy() && msg.sender == address(hub))) {
if (owner() == msg.sender || (!isHealthy() && msg.sender == address(vaultHub))) {
// force rebalance
// TODO: check rounding here
// mint some stETH in Lido v2 and burn it on the vault
inOutDelta -= int256(_ether);
emit Withdrawn(msg.sender, msg.sender, _ether);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
emit Withdrawn(msg.sender, msg.sender, _ether);
emit Withdrawn(msg.sender, VAULT_HUB, _ether);

Copy link
Contributor

Choose a reason for hiding this comment

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

or maybe 'Rebalanced'


hub.rebalance{value: _ether}();
vaultHub.rebalance{value: _ether}();
} else {
revert NotAuthorized("rebalance", msg.sender);
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should have two different revert options based on the branching above

}
}

function report(uint256 _valuation, int256 _inOutDelta, uint256 _locked) external {
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ We have an interesting issue:

  • feeRecipient (or other source of rewards) can be set aside from the vault address
  • reported valuation can be lower than its real value (concerning the external reward sources)
  • imbalanced state can be flagged prematurely as a consequence

Copy link
Contributor

Choose a reason for hiding this comment

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

naive mitigation approach: pre-report hook to withdraw rewards and put them on the vault address

if (msg.sender != address(hub)) revert NotAuthorized("update", msg.sender);
if (msg.sender != address(vaultHub)) revert NotAuthorized("update", msg.sender);

latestReport = Report(SafeCast.toUint128(_valuation), SafeCast.toInt128(_inOutDelta));
locked = _locked;
30 changes: 15 additions & 15 deletions contracts/0.8.25/vaults/VaultHub.sol
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
pragma solidity 0.8.25;

import {AccessControlEnumerableUpgradeable} from "contracts/openzeppelin/5.0.2/upgradeable/access/extensions/AccessControlEnumerableUpgradeable.sol";
import {IVault} from "./interfaces/IVault.sol";
import {IStakingVault} from "./interfaces/IStakingVault.sol";

interface StETH {
function mintExternalShares(address, uint256) external;
@@ -43,7 +43,7 @@ abstract contract VaultHub is AccessControlEnumerableUpgradeable {

struct VaultSocket {
/// @notice vault address
IVault vault;
IStakingVault vault;
/// @notice maximum number of stETH shares that can be minted by vault owner
uint96 capShares;
/// @notice total number of stETH shares minted by the vault
@@ -58,13 +58,13 @@ abstract contract VaultHub is AccessControlEnumerableUpgradeable {
VaultSocket[] private sockets;
/// @notice mapping from vault address to its socket
/// @dev if vault is not connected to the hub, it's index is zero
mapping(IVault => uint256) private vaultIndex;
mapping(IStakingVault => uint256) private vaultIndex;

constructor(address _admin, address _stETH, address _treasury) {
STETH = StETH(_stETH);
treasury = _treasury;

sockets.push(VaultSocket(IVault(address(0)), 0, 0, 0, 0)); // stone in the elevator
sockets.push(VaultSocket(IStakingVault(address(0)), 0, 0, 0, 0)); // stone in the elevator

_grantRole(DEFAULT_ADMIN_ROLE, _admin);
}
@@ -74,15 +74,15 @@ abstract contract VaultHub is AccessControlEnumerableUpgradeable {
return sockets.length - 1;
}

function vault(uint256 _index) public view returns (IVault) {
function vault(uint256 _index) public view returns (IStakingVault) {
return sockets[_index + 1].vault;
}

function vaultSocket(uint256 _index) external view returns (VaultSocket memory) {
return sockets[_index + 1];
}

function vaultSocket(IVault _vault) public view returns (VaultSocket memory) {
function vaultSocket(IStakingVault _vault) public view returns (VaultSocket memory) {
return sockets[vaultIndex[_vault]];
}

@@ -91,7 +91,7 @@ abstract contract VaultHub is AccessControlEnumerableUpgradeable {
/// @param _capShares maximum number of stETH shares that can be minted by the vault
/// @param _minBondRateBP minimum bond rate in basis points
function connectVault(
Copy link
Contributor

Choose a reason for hiding this comment

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

for permissionless addition:

  • there could be a scenario when we adding a vault under slashing

IVault _vault,
IStakingVault _vault,
uint256 _capShares,
uint256 _minBondRateBP,
uint256 _treasuryFeeBP
@@ -110,7 +110,7 @@ abstract contract VaultHub is AccessControlEnumerableUpgradeable {
if (_treasuryFeeBP > BPS_BASE) revert TreasuryFeeTooHigh(address(_vault), _treasuryFeeBP, BPS_BASE);

VaultSocket memory vr = VaultSocket(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
VaultSocket memory vr = VaultSocket(
VaultSocket memory vsocket = VaultSocket(

IVault(_vault),
IStakingVault(_vault),
uint96(_capShares),
0,
uint16(_minBondRateBP),
@@ -124,8 +124,8 @@ abstract contract VaultHub is AccessControlEnumerableUpgradeable {

/// @notice disconnects a vault from the hub
/// @param _vault vault address
function disconnectVault(IVault _vault) external onlyRole(VAULT_MASTER_ROLE) {
if (_vault == IVault(address(0))) revert ZeroArgument("vault");
function disconnectVault(IStakingVault _vault) external onlyRole(VAULT_MASTER_ROLE) {
if (_vault == IStakingVault(address(0))) revert ZeroArgument("vault");

uint256 index = vaultIndex[_vault];
if (index == 0) revert NotConnectedToHub(address(_vault));
@@ -164,7 +164,7 @@ abstract contract VaultHub is AccessControlEnumerableUpgradeable {
if (_amountOfTokens == 0) revert ZeroArgument("amountOfTokens");
if (_receiver == address(0)) revert ZeroArgument("receivers");

IVault vault_ = IVault(msg.sender);
IStakingVault vault_ = IStakingVault(msg.sender);
uint256 index = vaultIndex[vault_];
if (index == 0) revert NotConnectedToHub(msg.sender);
VaultSocket memory socket = sockets[index];
@@ -190,7 +190,7 @@ abstract contract VaultHub is AccessControlEnumerableUpgradeable {
function burnStethBackedByVault(uint256 _amountOfTokens) external {
if (_amountOfTokens == 0) revert ZeroArgument("amountOfTokens");

uint256 index = vaultIndex[IVault(msg.sender)];
uint256 index = vaultIndex[IStakingVault(msg.sender)];
if (index == 0) revert NotConnectedToHub(msg.sender);
VaultSocket memory socket = sockets[index];

@@ -203,7 +203,7 @@ abstract contract VaultHub is AccessControlEnumerableUpgradeable {
emit BurnedStETHOnVault(msg.sender, _amountOfTokens);
}

function forceRebalance(IVault _vault) external {
function forceRebalance(IStakingVault _vault) external {
uint256 index = vaultIndex[_vault];
if (index == 0) revert NotConnectedToHub(msg.sender);
VaultSocket memory socket = sockets[index];
@@ -231,7 +231,7 @@ abstract contract VaultHub is AccessControlEnumerableUpgradeable {
function rebalance() external payable {
if (msg.value == 0) revert ZeroArgument("msg.value");

uint256 index = vaultIndex[IVault(msg.sender)];
uint256 index = vaultIndex[IStakingVault(msg.sender)];
if (index == 0) revert NotConnectedToHub(msg.sender);
VaultSocket memory socket = sockets[index];

@@ -303,7 +303,7 @@ abstract contract VaultHub is AccessControlEnumerableUpgradeable {
uint256 preTotalShares,
uint256 preTotalPooledEther
) internal view returns (uint256 treasuryFeeShares) {
IVault vault_ = _socket.vault;
IStakingVault vault_ = _socket.vault;

uint256 chargeableValue = _min(vault_.valuation(), (_socket.capShares * preTotalPooledEther) / preTotalShares);

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.25;

interface IVault {
interface IStakingVault {
struct Report {
uint128 valuation;
int128 inOutDelta;
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.25;

import {IVault} from "./IVault.sol";
import {IStakingVault} from "./IStakingVault.sol";

interface IHub {
interface IVaultHub {
struct VaultSocket {
IVault vault;
IStakingVault vault;
uint96 capShares;
uint96 mintedShares;
uint16 minBondRateBP;
@@ -20,15 +20,20 @@ interface IHub {

function vaultsCount() external view returns (uint256);

function vault(uint256 _index) external view returns (IVault);
function vault(uint256 _index) external view returns (IStakingVault);

function vaultSocket(uint256 _index) external view returns (VaultSocket memory);

function vaultSocket(IVault _vault) external view returns (VaultSocket memory);
function vaultSocket(IStakingVault _vault) external view returns (VaultSocket memory);

function connectVault(IVault _vault, uint256 _capShares, uint256 _minBondRateBP, uint256 _treasuryFeeBP) external;
function connectVault(
IStakingVault _vault,
uint256 _capShares,
uint256 _minBondRateBP,
uint256 _treasuryFeeBP
) external;

function disconnectVault(IVault _vault) external;
function disconnectVault(IStakingVault _vault) external;

function mintStethBackedByVault(
address _receiver,
@@ -37,7 +42,7 @@ interface IHub {

function burnStethBackedByVault(uint256 _amountOfTokens) external;

function forceRebalance(IVault _vault) external;
function forceRebalance(IStakingVault _vault) external;

function rebalance() external payable;