Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/shapella-upgrade-followu…
Browse files Browse the repository at this point in the history
…ps' into refactor/nft_renaming
  • Loading branch information
TheDZhon committed Feb 18, 2023
2 parents 5e35d35 + 2b5b9a9 commit fabb410
Show file tree
Hide file tree
Showing 47 changed files with 2,064 additions and 941 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@ cli/vendor

# OS relative
.DS_Store

# foundry artifacts
foundry/cache
foundry/out
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "foundry/lib/forge-std"]
path = foundry/lib/forge-std
url = https://github.com/foundry-rs/forge-std
branch = v1.3.0
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ The contract also works as a wrapper that accepts stETH tokens and mints wstETH
* docker
* node.js v12
* (optional) Lerna
* (optional) Foundry

### Installing Aragon & other deps

Expand Down Expand Up @@ -239,6 +240,14 @@ so full branch coverage will never be reported until

[solidity-coverage#219]: https://github.com/sc-forks/solidity-coverage/issues/269

Run fuzzing tests with foundry:

```bash
curl -L https://foundry.paradigm.xyz | bash
foundryup
forge test
```

## Deploying

We have several ways to deploy lido smart-contracts and run DAO locally, you can find documents here:
Expand Down
5 changes: 5 additions & 0 deletions contracts/0.4.24/Lido.sol
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,9 @@ contract Lido is Versioned, StETHPermit, AragonApp {
/**
* @dev As AragonApp, Lido contract must be initialized with following variables:
* NB: by default, staking and the whole Lido pool are in paused state
*
* The contract's balance must be non-zero to allow initial holder bootstrap.
*
* @param _lidoLocator lido locator contract
* @param _eip712StETH eip712 helper contract for StETH
*/
Expand Down Expand Up @@ -291,6 +294,8 @@ contract Lido is Versioned, StETHPermit, AragonApp {
* @notice A function to finalize upgrade to v2 (from v1). Can be called only once
* @dev Value "1" in CONTRACT_VERSION_POSITION is skipped due to change in numbering
*
* The initial protocol token holder must exist.
*
* For more details see https://github.com/lidofinance/lido-improvement-proposals/blob/develop/LIPS/lip-10.md
*/
function finalizeUpgrade_v2(address _lidoLocator, address _eip712StETH) external {
Expand Down
14 changes: 9 additions & 5 deletions contracts/0.4.24/StETH.sol
Original file line number Diff line number Diff line change
Expand Up @@ -503,17 +503,21 @@ contract StETH is IERC20, Pausable {
}

/**
* @notice Mints amount of shares equal to contract balance to 0xdead address
* It allows to get rid of zero checks and corner cases
* @dev should be invoked before using the token
* @notice Mints shares on behalf of 0xdead address,
* the shares amount is equal to the contract's balance. *
*
* Allows to get rid of zero checks for `totalShares` and `totalPooledEther`
* and overcome corner cases.
*
* @dev must be invoked before using the token
*/
function _bootstrapInitialHolder() internal returns (uint256) {
uint256 balance = address(this).balance;
require(balance != 0, "EMPTY_INIT_BALANCE");

if (_getTotalShares() == 0) {
// if protocol is empty bootstrap it with the contract's balance
// 0xdead is a holder for initial shares
// if protocol is empty bootstrap it with the contract's balance
// address(0xdead) is a holder for initial shares
_mintShares(INITIAL_TOKEN_HOLDER, balance);

emit Transfer(0x0, INITIAL_TOKEN_HOLDER, balance);
Expand Down
8 changes: 4 additions & 4 deletions contracts/0.4.24/StETHPermit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ contract StETHPermit is IERC2612, StETH {
abi.encode(PERMIT_TYPEHASH, _owner, _spender, _value, _useNonce(_owner), _deadline)
);

bytes32 hash = IEIP712(_getEIP712StETH()).hashTypedDataV4(structHash);
bytes32 hash = IEIP712(getEIP712StETH()).hashTypedDataV4(structHash);

address signer = ECDSA.recover(hash, _v, _r, _s);
require(signer == _owner, "ERC20Permit: invalid signature");
Expand All @@ -124,7 +124,7 @@ contract StETHPermit is IERC2612, StETH {
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32) {
return IEIP712(_getEIP712StETH()).domainSeparatorV4();
return IEIP712(getEIP712StETH()).domainSeparatorV4();
}

/**
Expand All @@ -140,7 +140,7 @@ contract StETHPermit is IERC2612, StETH {
*/
function _initializeEIP712StETH(address _eip712StETH) internal {
require(_eip712StETH != address(0), "StETHPermit: zero eip712StETH");
require(_getEIP712StETH() == address(0), "StETHPermit: eip712StETH already set");
require(getEIP712StETH() == address(0), "StETHPermit: eip712StETH already set");

EIP712_STETH_POSITION.setStorageAddress(_eip712StETH);

Expand All @@ -150,7 +150,7 @@ contract StETHPermit is IERC2612, StETH {
/**
* @dev Get EIP712 message utils contract
*/
function _getEIP712StETH() internal view returns (address) {
function getEIP712StETH() public view returns (address) {
return EIP712_STETH_POSITION.getStorageAddress();
}
}
Loading

0 comments on commit fabb410

Please sign in to comment.