Skip to content

Commit

Permalink
feat: add solhint to makefile
Browse files Browse the repository at this point in the history
feat: block funds by mev committee

feat: tests

feat: more tests

fix: required

fix: remarks

Update blocked bond retention and management
periods

Check onRewardsMinted call from the staking router

forge install: openzeppelin-contracts-v4.4

v4.4.1

build: import oracle contracts from lido-dao

feat: CSFeeOracle based on HashConsensus

refactor: deploy script

docs: udate READMEs

lint: add compiler-version solhint rule

fix: some remarks

refactor: integration tests addresses

[CS-93] locking bond funds by mev committee (#35)

* feat: add solhint to makefile

* feat: block funds by mev committee

* feat: tests

* feat: more tests

* fix: required

* fix: remarks

* Update blocked bond retention and management
periods

* fix: some remarks
  • Loading branch information
vgorkavenko committed Nov 8, 2023
1 parent 6c67389 commit 6622db3
Show file tree
Hide file tree
Showing 45 changed files with 4,041 additions and 1,161 deletions.
5 changes: 0 additions & 5 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
RPC_URL=
LIDO_LOCATOR_ADDRESS=
WSTETH_ADDRESS=
# For deployment
DEPLOYER_PRIVATE_KEY=
INITIALIZATION_EPOCH=
## mainnet
CL_GENESIS_TIME=1606824023
KEEP_ANVIL_AFTER_LOCAL_DEPLOY=false
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,3 @@ jobs:
forge test -vvv
env:
RPC_URL: ${{ secrets.RPC_URL }}
LIDO_LOCATOR_ADDRESS: "0xC1d0b3DE6792Bf6b4b37EccdcC24e45978Cfd2Eb"
WSTETH_ADDRESS: "0x7f39c581f595b53c5cb19bd0b3f8da6c935e2ca0"
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/openzeppelin-contracts-v4.4"]
path = lib/openzeppelin-contracts-v4.4
url = https://github.com/OpenZeppelin/openzeppelin-contracts
1 change: 1 addition & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "solhint:recommended",
"plugins": ["lido-csm"],
"rules": {
"compiler-version": ["error", "0.8.21"],
"no-inline-assembly": "off",
"no-unused-import": "error",
"func-named-parameters": "error",
Expand Down
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
include .env

.PHONY: artifacts clean test deploy-prod deploy-local anvil-fork anvil-kill
.PHONY: build clean test deploy-prod deploy-local anvil-fork anvil-kill

DEPLOY_SCRIPT_PATH := script/Deploy.s.sol:Deploy
CHAIN ?= mainnet

artifacts:
forge compile --force
DEPLOY_SCRIPT_PATH_mainnet := script/DeployMainnetish.s.sol:DeployMainnetish
DEPLOY_SCRIPT_PATH_holesky := script/DeployHolesky.s.sol:DeployHolesky
DEPLOY_SCRIPT_PATH_goerli := script/DeployGoerli.s.sol:DeployGoerli
DEPLOY_SCRIPT_PATH := ${DEPLOY_SCRIPT_PATH_${CHAIN}}

build:
forge build --force
clean:
forge clean
rm -rf cache broadcast out
lint-solhint:
yarn lint:solhint
lint-check:
yarn lint:check
lint-fix:
Expand Down Expand Up @@ -48,6 +55,7 @@ endif

# aliases
a: artifacts
ls: lint-solhint
lc: lint-check
lf: lint-fix
t: test
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ forge install
```

- Config environment variables

```bash
cp .env.example .env
cp .env.sample .env
```

Fill vars in the `.env` file with your own values

### Features
Expand All @@ -38,6 +40,12 @@ forge install rari-capital/solmate
make deploy-local
```

- Deploy to local fork of non-mainnet chain

```bash
CHAIN=holesky make deploy-local
```

### Notes

Whenever you install new libraries using Foundry, make sure to update your
Expand Down
3 changes: 3 additions & 0 deletions lib/base-oracle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is an extraction from [lidofinance/lido-dao@v2.0.0](https://github.com/lidofinance/lido-dao/releases/tag/v2.0.0) codebase.
Patched to use ^0.8.9 solidity compiler version.
@openzeppelin/contracts-v4.4 mapped to v4.4.1.
31 changes: 31 additions & 0 deletions lib/base-oracle/lib/Math.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-FileCopyrightText: 2023 Lido <info@lido.fi>
// SPDX-License-Identifier: MIT

// See contracts/COMPILERS.md
pragma solidity ^0.8.9;

library Math {
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a > b ? a : b;
}

function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}

/// @notice Tests if x ∈ [a, b) (mod n)
///
function pointInHalfOpenIntervalModN(uint256 x, uint256 a, uint256 b, uint256 n)
internal pure returns (bool)
{
return (x + n - a) % n < (b - a) % n;
}

/// @notice Tests if x ∈ [a, b] (mod n)
///
function pointInClosedIntervalModN(uint256 x, uint256 a, uint256 b, uint256 n)
internal pure returns (bool)
{
return (x + n - a) % n <= (b - a) % n;
}
}
43 changes: 43 additions & 0 deletions lib/base-oracle/lib/UnstructuredStorage.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* SPDX-License-Identifier: MIT
*/

pragma solidity ^0.8.9;


/**
* @notice Aragon Unstructured Storage library
*/
library UnstructuredStorage {
function getStorageBool(bytes32 position) internal view returns (bool data) {
assembly { data := sload(position) }
}

function getStorageAddress(bytes32 position) internal view returns (address data) {
assembly { data := sload(position) }
}

function getStorageBytes32(bytes32 position) internal view returns (bytes32 data) {
assembly { data := sload(position) }
}

function getStorageUint256(bytes32 position) internal view returns (uint256 data) {
assembly { data := sload(position) }
}

function setStorageBool(bytes32 position, bool data) internal {
assembly { sstore(position, data) }
}

function setStorageAddress(bytes32 position, address data) internal {
assembly { sstore(position, data) }
}

function setStorageBytes32(bytes32 position, bytes32 data) internal {
assembly { sstore(position, data) }
}

function setStorageUint256(bytes32 position, uint256 data) internal {
assembly { sstore(position, data) }
}
}
Loading

0 comments on commit 6622db3

Please sign in to comment.