From eda668fb5cdd3bf33252e26ac47dd6317c2f1f7f Mon Sep 17 00:00:00 2001 From: Hrik Bhowal Date: Mon, 5 Feb 2024 12:20:58 -0500 Subject: [PATCH] fmt: run forge fmt --- .github/workflows/checks.yml | 33 +++++- .prettierignore | 1 + README.md | 100 ++++++++++-------- bun.lockb | Bin 58336 -> 58712 bytes certora/README.md | 36 ++++--- offchain/scrapePastExchangeRates.ts | 6 +- package.json | 2 + test/fork/concrete/WstEthHandlerFork.t.sol | 10 +- .../BalancerFlashloanDirectMintHandler.t.sol | 5 +- 9 files changed, 122 insertions(+), 71 deletions(-) create mode 100644 .prettierignore diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index cce60288..e7ab5383 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -1,4 +1,4 @@ -on: [push, pull_request, workflow_dispatch] +on: [pull_request, workflow_dispatch] concurrency: group: ${{github.workflow}}-${{github.ref}} @@ -26,8 +26,35 @@ jobs: - name: Run Prettier run: npx prettier -c '**/*.{md,yml,yaml}' - - name: Format Solidity code - run: forge fmt + - name: Install Foundry + uses: foundry-rs/foundry-toolchain@v1 + with: + version: nightly + + - name: Check Solidity formatting with forge fmt + run: | + # Stash changes from the checkout step to ignore in the formatting check + git stash -u + + # Remember the current HEAD commit + BEFORE_FMT=$(git rev-parse HEAD) + + # Run forge fmt to format Solidity files + forge fmt + + # Check if there are any changes by comparing the current HEAD to the tree after running forge fmt + if [ -n "$(git diff $BEFORE_FMT)" ]; then + echo "Solidity files are not formatted correctly. Please run 'forge fmt' locally and commit the changes." + git diff $BEFORE_FMT + exit 1 + else + echo "All Solidity files are formatted correctly." + fi + + # Optional: Revert changes made by forge fmt to leave the working directory clean + - name: Revert formatting changes + if: failure() + run: git reset --hard $BEFORE_FMT codespell: runs-on: ${{ matrix.os }} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..c3af8579 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +lib/ diff --git a/README.md b/README.md index 846cc113..9f6de0db 100644 --- a/README.md +++ b/README.md @@ -1,64 +1,71 @@ ``` -,-. .---. .-. .-. ,---. ,---. .---. _______ .---. ,--, .---. ,-. -|(|/ .-. ) | \| | | .-.\ | .-.\ / .-. )|__ __|/ .-. ) .' .') / .-. ) | | -(_)| | |(_)| | | | |-' )| `-'/ | | |(_) )| | | | |(_)| |(_)| | |(_)| | -| || | | | | |\ | | |--' | ( | | | | (_) | | | | | \ \ | | | | | | -| |\ `-' / | | |)| | | | |\ \ \ `-' / | | \ `-' / \ `-.\ `-' / | `--. -`-' )---' /( (_) /( |_| \)\ )---' `-' )---' \____\)---' |( __.' - (_) (__) (__) (__)(_) (_) (_) (_) +,-. .---. .-. .-. ,---. ,---. .---. _______ .---. ,--, .---. ,-. +|(|/ .-. ) | \| | | .-.\ | .-.\ / .-. )|__ __|/ .-. ) .' .') / .-. ) | | +(_)| | |(_)| | | | |-' )| `-'/ | | |(_) )| | | | |(_)| |(_)| | |(_)| | +| || | | | | |\ | | |--' | ( | | | | (_) | | | | | \ \ | | | | | | +| |\ `-' / | | |)| | | | |\ \ \ `-' / | | \ `-' / \ `-.\ `-' / | `--. +`-' )---' /( (_) /( |_| \)\ )---' `-' )---' \____\)---' |( __.' + (_) (__) (__) (__)(_) (_) (_) (_) ``` # Ion Protocol -Ion Protocol is a decentralized money market purpose-built for all types of staked and restaked assets. Ion protocol unlocks capital efficiency for yield-bearing staking collaterals using reactive interest rates, collateral-specific utilization, and price-agnostic liquidations. Borrowers can collateralize their yield-bearing staking assets to borrow WETH, and lenders can gain exposure to the boosted staking yield generated by borrower collateral. -## Documentation +Ion Protocol is a decentralized money market purpose-built for all types of staked and restaked assets. Ion protocol unlocks capital efficiency for yield-bearing staking collaterals using reactive interest rates, collateral-specific utilization, and price-agnostic liquidations. Borrowers can collateralize their yield-bearing staking assets to borrow WETH, and lenders can gain exposure to the boosted staking yield generated by borrower collateral. + +## Documentation To learn more about Ion Protocol without code, please visit: + - [Our website](https://ionprotocol.io) - [User Docs](https://docs.ionprotocol.io) To learn more about the protocol's technical details, please visit: + - [Audit Docs for Security Researchers](https://ionprotocol.notion.site/Ion-Protocol-Audit-Docs-c871ff178bf54447bd28018cd5a88f75?pvs=74) -## Audits +## Audits + > Please report any white hat findings for potential vulnerabilities to security@molecularlabs.io - OpenZeppelin Audit December 2023 - - [Report to be released soon] -- [Hats Finance January 2024](https://app.hats.finance/audit-competitions) - - Regular Audit and Formal Verification Competition with Certora - - [Competition Ongoing] + - [Report to be released soon] +- [Hats Finance January 2024](https://app.hats.finance/audit-competitions) + - Regular Audit and Formal Verification Competition with Certora + - [Competition Ongoing] ## Community -To engage in conversations around Ion Protocol and the staking/restaking ecosystem, please join the [Discord](https://t.co/6np4WvIx70) channel or follow [@ionprotocol](https://twitter.com/ionprotocol) on X. +To engage in conversations around Ion Protocol and the staking/restaking ecosystem, please join the [Discord](https://t.co/6np4WvIx70) channel or follow [@ionprotocol](https://twitter.com/ionprotocol) on X. ## Usage -### Installing Dependencies +### Installing Dependencies + +Install Bun -Install Bun ```shell -curl -fsSL https://bun.sh/install | bash +curl -fsSL https://bun.sh/install | bash ``` Run Bun install for javascript dependencies + ```shell bun install ``` -Install jq +Install jq + ```shell -brew install jq +brew install jq ``` -### Environmental Variables +### Environmental Variables -Copy .env.example to .env and add environmental variables. +Copy .env.example to .env and add environmental variables. ```bash MAINNET_RPC_URL=https://mainnet.infura.io/v3/ -MAINNET_ARCHIVE_RPC_URL= # Archive node used for creating fork environments +MAINNET_ARCHIVE_RPC_URL= # Archive node used for creating fork environments MAINNET_ETHERSCAN_URL=https://api.etherscan.io/api ETHERSCAN_API_KEY= RPC_URL= # RPC of the desired testnet used in deployment scripts @@ -66,31 +73,36 @@ RPC_URL= # RPC of the desired testnet used in deployment scripts ### Test -1. The test suite includes fork tests that require foundry ffi. -2. Add RPC_URLs to the .env and run forge test with the --ffi flag. +1. The test suite includes fork tests that require foundry ffi. +2. Add RPC_URLs to the .env and run forge test with the --ffi flag. + ```shell -forge test --ffi +forge test --ffi ``` + ### Testnet Setup -1. Set up anvil as a mainnet fork. - - For the contracts using mainnet contract addresses as constants to work properly, the testnet needs to be a fork of a mainnet environment. - ```bash - anvil --fork-url $MAINNET_ARCHIVE_RPC_URL --chain-id 31337 - ``` + +1. Set up anvil as a mainnet fork. + - For the contracts using mainnet contract addresses as constants to work properly, the testnet needs to be a fork of a mainnet environment. + ```bash + anvil --fork-url $MAINNET_ARCHIVE_RPC_URL --chain-id 31337 + ``` 2. Set anvil as the target RPC for the deployment script in `.env` - ```bash - # ...other environmental variables - RPC_URL=http://localhost:8545 - - ``` -3. Run the testnet deployment script - ```bash - bash node.sh - ``` -4. Run the foundry script to verify that the contracts are working properly. - ```bash - forge script script/__TestFlashLeverage.s.sol --rpc-url $RPC_URL - ``` + + ```bash + # ...other environmental variables + RPC_URL=http://localhost:8545 + + ``` + +3. Run the testnet deployment script + ```bash + bash node.sh + ``` +4. Run the foundry script to verify that the contracts are working properly. + ```bash + forge script script/__TestFlashLeverage.s.sol --rpc-url $RPC_URL + ``` ### Format diff --git a/bun.lockb b/bun.lockb index d7ca1124f3f14ffa77294cba99aff0f175e3ce96..adb1b988fead3f2e538e17da054c88898575984a 100755 GIT binary patch delta 6306 zcmeI0YfzL`7{}jTc6E1!SX&$sNst&3)C~ax6I~KR&2+SxBukyV;4F6m9qog@OogKs zA{}6$pxc;JUP|4@kjk-U8Vz)0MpG;=i(y_SCrOjk!2bW`Z1XxX_90z9=)aGb@G8W z#bZ_F>0$c46+2ft4W^}q8OxSsW)upyA=c6{Tu~lUl;YHASBNpsU^+QJ_Ssz{_LPdX z=9$8287|yrld(9Y%%F1xSehaNRz@jG68igLTD@o;HbPh}CgTox6U3>(jB=RQ!8Zmzt7x?(>h_93c8A^=Encus(9IS#c8Bgmal$@s zju`=n6$}DKFa*%FszW^tusu?0G?e}rK%=rg0vN=ogn=pwN-UsvG%GMFZz};90B+OM zJ{C%UGN4g8ZoJe9P(4Tiv=q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