Monorepo for Silo protocol. v2
see:
# from root dir
git clone <repo>
git hf init
nvm install 18
nvm use 18
# this is for ode 18, for other versions please check https://yarnpkg.com/getting-started/install
corepack enable
corepack prepare yarn@stable --activate
npm i -g yarn
yarn install
git config core.hooksPath .githooks/
git submodule add --name foundry https://github.com/foundry-rs/forge-std gitmodules/forge-std
git submodule add --name silo-foundry-utils https://github.com/silo-finance/silo-foundry-utils gitmodules/silo-foundry-utils
forge install OpenZeppelin/openzeppelin-contracts --no-commit
forge install OpenZeppelin/openzeppelin-contracts-upgradeable --no-commit
git submodule add --name gitmodules/uniswap/v3-periphery https://github.com/Uniswap/v3-periphery gitmodules/uniswap/v3-periphery
git submodule add --name gitmodules/chainlink https://github.com/smartcontractkit/chainlink gitmodules/chainlink
git submodule add --name lz_gauges https://github.com/LayerZero-Labs/lz_gauges gitmodules/lz_gauges
git submodule add --name layer-zero-examples https://github.com/LayerZero-Labs/solidity-examples gitmodules/layer-zero-examples
git submodule add --name chainlink-ccip https://github.com/smartcontractkit/ccip gitmodules/chainlink-ccip
git submodule add --name openzeppelin5 https://github.com/OpenZeppelin/[email protected] gitmodules/openzeppelin-contracts-5
git submodule add --name openzeppelin-contracts-upgradeable-5 https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable gitmodules/openzeppelin-contracts-upgradeable-5
git submodule add --name morpho-blue https://github.com/morpho-org/morpho-blue/ gitmodules/morpho-blue
git submodule update --init --recursive
git submodule
create .remappings.txt
in main directory
forge-std/=gitmodules/forge-std/src/
this will make forge visible for imports eg: import "forge-std/Test.sol"
.
cd gitmodules/silo-foundry-utils
cargo build --release
cp target/release/silo-foundry-utils ../../silo-foundry-utils
More about silo foundry utils here.
example:
# Remove the submodule entry from .git/config
git submodule deinit -f gitmodules/silo-foundry-utils
# Remove the submodule directory from the super project's .git/modules directory
rm -rf .git/modules/gitmodules/silo-foundry-utils
# Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule
rm -rf .git/modules/gitmodules/silo-foundry-utils
git submodule update --remote gitmodules/<submodule>
If you want to update to specific commit:
- cd
gitmodules/<module>
git checkout <commit>
- commit changes (optionally update
branch
section in.gitmodules
, however this make no difference)
- create new workflow in
.github/workflows
- create new directory
mkdir new-dir
with content - create new profile in
.foundry.toml
- add new workspace in
package.json
workspaces
section - run
yarn reinstall
- In
external/
create subdirectory for cloned code eguniswap-v3-core/
- clone git repo into that directory
NOTICE: do not run yarn install
directly from workspace directory. It will create separate yarn.lock
and it will
act like separate repo, not part of monorepo. It will cause issues when trying to access other workspaces eg as
dependency.
- you need to remove
./git
directories in order to commit cloned code - update
external/package.json#workspaces
with this newuniswap-v3-core
- update
external/uniswap-v3-core/package.json#name
to match dir name, in our exampleuniswap-v3-core
Run yarn install
, enter your new cloned workspace, and you should be able to execute commands for this new workspace.
example of running scripts for workspace:
yarn workspace <workspaceName> <commandName> ...
brew install lcov
rm lcov.info
mkdir coverage
FOUNDRY_PROFILE=core-with-test forge coverage --report summary --report lcov --gas-price 1 --ffi --gas-limit 40000000000 --no-match-test "_skip_|_gas_|_anvil_" > coverage/silo-core.log
cat coverage/silo-core.log | grep -i 'silo-core/contracts/' > coverage/silo-core.txt
genhtml --ignore-errors inconsistent -ignore-errors range -o coverage/silo-core/ lcov.info
rm lcov.info
FOUNDRY_PROFILE=oracles forge coverage --report summary --report lcov | grep -i 'silo-oracles/contracts/' > coverage/silo-oracles.log
cat coverage/silo-oracles-report.log | grep -i 'silo-oracles/contracts/' > coverage/silo-oracles.txt
genhtml -o coverage/silo-oracles/ lcov.info
Check Rounding.sol
for rounding policy.
brew install echidna
git submodule add --name crytic-properties https://github.com/crytic/properties gitmodules/crytic/properties
# before you can run any echidna tests, run the script:
./silo-core/scripts/echidnaBefore.sh
# after you done run this to revert changes:
./silo-core/scripts/echidnaAfter.sh
# generate snapshot file
FOUNDRY_PROFILE=core-test forge snapshot --desc --no-match-test "_skip_" --no-match-contract "SiloIntegrationTest" --ffi
# check gas difference
FOUNDRY_PROFILE=core-test forge snapshot --desc --check --no-match-test "_skip_" --no-match-contract "SiloIntegrationTest" --ffi
# better view, with % change
FOUNDRY_PROFILE=core-test forge snapshot --diff --desc --no-match-test "_skip_" --no-match-contract "SiloIntegrationTest" --ffi
set env variable PRIVATE_KEY
then run
FOUNDRY_PROFILE=core \
forge script silo-core/deploy/MainnetDeploy.s.sol \
--ffi --broadcast --rpc-url https://arbitrum-mainnet.infura.io/v3/<key>
In case you deploying without ve-silo, go to SiloFactoryDeploy
and SiloDeployWithGaugeHookReceiver
and set
daoFeeReceiver
and timelock
addresses manually to eg. deployer address.