Download audit report
This document outlines the security review conducted by Nethermind Security for the Chi protocol contracts. Chi Protocol issued its first stablecoin, USC, using a dual stability mechanism to maintain its price at 1 USD. Users interact with the ArbitrageV5 contract to mint and burn their USC tokens. This contract manages various scenarios, including fluctuations in USC price and the status of reserves, executing necessary actions to uphold the stability of USC’s price, and ensuring adequate reserves that back the token. The protocol also includes mechanisms for rebalancing reserves within the ReserveHolderV2 contract. It introduces specific adapter contracts like WeEthAdapter and StEthAdapter to manage the reserves of each supported LST.
The audited code comprises 1016 lines of code in Solidity. The Chi Protocol team has provided documentation that explains the purpose and functionality behind audited contracts.
At the time of our review, the code in the final commit hash reviewed by our team matches the code found in commit 3a4da8c4bc59a577a56fb551ed4bb7d657f235c7 of Chi Protocol’s public repository. This note exclusively concerns the files within the defined scope, as listed in Section 2.
The audit was performed using: (a) manual analysis of the codebase, (b) simulation of the smart contracts.
| Audit assessment | |
| Audit Type | Security Review |
| Initial Report | Jul 05, 2024 |
| Final Report | Jul 22,2024 |
| Methods | Manual Review, Automated analysis |
| Repository | chi-contracts |
| Commit Hash | 5751cffb37 |
| Final Commit Hash | 550c318d28 |
| Documentation | Chi protocol documentation |
| Documentation Assessment | High |
| Test Suite Assessment | Medium |
Findings by severity
| # | Contract | LoC | Comments | Ratio | Blank | Total |
| 01 | contracts/ArbitrageV5.sol | 531 | 43 | 8.1% | 134 | 708 |
| 02 | contracts/Treasury.sol | 26 | 4 | 15.4% | 8 | 38 |
| 03 | contracts/library/ExternalContractAddresses.sol | 15 | 2 | 13.3% | 1 | 18 |
| 04 | contracts/library/UniswapV3SwapLibrary.sol | 52 | 1 | 1.9% | 7 | 60 |
| 05 | contracts/library/UniswapV2SwapLibrary.sol | 47 | 1 | 2.1% | 8 | 56 |
| 06 | contracts/reserve/Adapter.sol | 39 | 3 | 7.7% | 8 | 50 |
| 07 | contracts/reserve/ReserveHolderV2.sol | 166 | 21 | 12.7% | 43 | 230 |
| 08 | contracts/reserve/StEthAdapter.sol | 62 | 6 | 9.7% | 16 | 84 |
| 09 | contracts/reserve/WeEthAdapter.sol | 78 | 6 | 7.7% | 22 | 106 |
| Total | 1016 | 87 | 8.56% | 247 | 1350 |
Chi protocol introduces their first stablecoin, USC, employing a dual stability mechanism designed to peg its value to 1 USD. This token is backed by reserves that include Liquid Staking Tokens (LSTs) and WETH.
The key contracts of the codebase include:
In subsequent sections, we delve into the detailed mechanics of Chi protocol’s arbitrage mechanism and their approach to reserve management.
The ArbitrageV5 contract manages the arbitrage operations, minting, and burning of USC tokens based on different scenarios.
We classify 6 distinct scenarios based on whether the USC price is above, below, or at the peg. Each scenario may result in either an excess or deficit of reserves. The executeArbitrage(...) function manages the logic for each scenario.
function executeArbitrage(uint256 maxChiSpotPrice) public override nonReentrant onlyArbitrager returns (uint256)When USC is valued at 1 USD, the contract evaluates the balance of reserves versus the circulating USC tokens:
_arbitrageAtPegExcessOfReserves() function is executed, minting a USC amount that is equivalent to the reserveDiff.function _arbitrageAtPegExcessOfReserves(uint256 reserveDiff, uint256 discount, uint256 ethPrice) private returns (uint256)The discount is calculated using the value of total USC in circulation to determine the portion of newly minted USC allocated to rewards.
discount = (reserveDiff * 1 ether) / uscTotalSupplyValue;_arbitrageAtPegDeficitOfReserves() function is executed. USC tokens are burned up to the reserve shortfall.function _arbitrageAtPegDeficitOfReserves(uint256 reserveDiff, uint256 discount, uint256 ethPrice) private returns (uint256)CHI tokens are minted and exchanged for WETH to augment reserves, with the minted USC including rewards based on the discount percentage.
discount = (reserveDiff * 1 ether) / reserveValue;When USC trades above 1 USD, the contract mints USC tokens to restore the peg:
_arbitrageAbovePegExcessOfReserves() function verifies if the reserveDiff is sufficient to back the delta. In that case, the deltaUSD is swapped for CHI. Otherwise, the reserveDiff is swapped, with the remaining WETH amount (deltaInETH - ethAmountToSwap) sent to the reserves holder contract. The received CHI tokens are burned.function _arbitrageAbovePegExcessOfReserves(uint256 reserveDiff, uint256 ethPrice) private returns (uint256)function _arbitrageAbovePegDeficitOfReserves(uint256 reserveDiff, uint256 ethPrice) private returns (uint256)When USC is priced below 1 USD, the contract executes buyback operations using ETH:
_arbitrageBelowPegExcessOfReserves() function where surplus reserves cover the buyback of USC tokens, with excess USC burned.function _arbitrageBelowPegExcessOfReserves(uint256 reserveDiff, uint256 ethPrice) private returns (uint256)_arbitrageBelowPegDeficitOfReserves() function mints CHI tokens, swaps them for ETH, and subsequently for USC tokens. The purchased USC tokens are then burned to reduce the circulating supply.function _arbitrageBelowPegDeficitOfReserves(uint256 reserveDiff, uint256 ethPrice) private returns (uint256)The ReserveHolderV2 contract serves as the central repository for the Chi protocol’s reserves, including WETH and various Liquid Staking Tokens (LSTs) managed through specific adapters.
Users can deposit WETH or any supported LST into the reserves using the deposit(...) function. The deposited tokens are transferred from the caller to the contract and forwarded to the respective adapter.
function deposit(address reserveAsset, uint256 amount) externalThe contract allows the Arbitrager contract to redeem WETH from the reserves using the redeem(...) function.
function redeem(uint256 amount) external onlyArbitrager returns (uint256)Actors with the claimer role can claim rewards from all supported tokens using the claimRewards(...) function. This function iterates through each adapter, claims rewards, and then transfers them to the specified account.
function claimRewards(address account) external onlyClaimerThe contract implements a rebalancing mechanism through the rebalance(...) function, which adjusts reserves according to predefined percentages. It sells excessive tokens for LSTs with higher reserves than target and buys tokens with reserves lower than target.
function rebalance(uint256[] calldata protectionParams) external onlyRebalancerCurrently, Chi protocol supports two adapters: WeEthAdapter for managing WeETH and StEthAdapter for managing StETH tokens. Each adapter contract provides the following main functionalities:
rescueReserves(...) function.function rescueReserves() external onlyOwnerswapAmountToEth(...) function allows the exchange of a specific amount of tokens for ETH, and the received WETH is transferred to the specified receiver.function swapAmountToEth(uint256 amountIn, uint256 minAmountOut, address receiver) external override returns (uint256)swapAmountFromEth(...) function allows the exchange of an ETH amount for the adapter token; the WETH is transferred from the caller while the received tokens remain in the contract.function swapAmountFromEth(uint256 amountIn) external returns (uint256)Users interact with the ArbitrageV5 contract to mint or burn USC tokens based on their needs.
Users can mint USC tokens by depositing a specified token and amount using the mint(...) function. The equivalent amount of USC tokens is minted and transferred to the user.
function mint(address token, uint256 amount) external whenMintNotPaused nonReentrant onlyWhenMintableOrBurnable returns (uint256)Users can burn USC tokens to redeem the equivalent ETH amount from the reserves using the burn(...) function. The redeemed ETH is transferred back to the user.
function burn(uint256 amount) external whenBurnNotPaused nonReentrant onlyWhenMintableOrBurnable returns (uint256)The risk rating methodology used by Nethermind Security follows the principles established by the OWASP Foundation. The severity of each finding is determined by two factors: Likelihood and Impact.
Likelihood measures how likely the finding is to be uncovered and exploited by an attacker. This factor will be one of the following values:
When defining the likelihood of a finding, other factors are also considered. These can include but are not limited to motive, opportunity, exploit accessibility, ease of discovery, and ease of exploit.
Impact is a measure of the damage that may be caused if an attacker exploits the finding. This factor will be one of the following values:
When defining the impact of a finding, other factors are also considered. These can include but are not limited to data and state integrity, loss of availability, financial loss, and reputation damage. After defining the likelihood and impact of an issue, the severity is determined according to the table below.
| Impact / Likelihood | Low | Medium | High |
| High | Medium | High | Critical |
| Medium | Low | Medium | High |
| Low | Info / Best Practices | Low | Medium |
| Undetermined | Undetermined | Undetermined | Undetermined |
To address issues that do not fit a High, Medium or Low severity, Nethermind Security also uses three more finding severities: Informational, Best Practices, and Undetermined.
swapAmountToEth(...) function| File | Fix commit | Type | Status |
StEthAdapter.solWeEthAdapter.sol | 19222ab | Critical | Fixed |
The swapAmountToEth(...) function facilitates the exchange of the Adapter’s asset to WETH, currently utilized by the ReserveHolderV2 contract during its rebalancing process. This function swaps a specified amountIn of the asset and transfers the resulting WETH to the designated receiver address.
However, the current implementation lacks access control, allowing anyone to invoke the function, perform the swap, and transfer WETH to themselves, potentially depleting the contract’s funds.
function swapAmountToEth(...) external override returns (uint256) {
//@audit Lack of access control exposes the function to unauthorized use
IERC20(stETH).approve(address(curvePool), amountIn);
//@audit Tokens are swapped directly from the contract's balance
uint256 ethReceived = curvePool.exchange(1, 0, amountIn, minAmountOut);
totalDeposited -= amountIn;
WETH.deposit{value: ethReceived}();
//@audit Received WETH is transferred to the specified receiver
IERC20(WETH).safeTransfer(receiver, ethReceived);
return ethReceived;
}Recommendation
Implement an access control mechanism to restrict the invocation of this function exclusively to the ReserveHolderV2 contract.
Resolution
19222ab796faa6a3605fdc4dea92c636625efd18
| File | Fix commit | Type | Status |
Adapter.solStEthAdapter.solWeEthAdapter.sol | f7a0e72 | Medium | Fixed |
The Adapter provides rescueReserves(...) functionality for the owner to withdraw the LST assets in the reserves to the owner’s address.
function rescueReserves() external onlyOwner {
IERC20(asset).safeTransfer(msg.sender, IERC20(asset).balanceOf(address(this)));
emit RescueReserves();
}However, as the assets are withdrawn but the totalDeposited will continue to hold the total deposits, calling the claimRewards(...) function will revert as the reward calculation will result in an underflow. Consequently, claiming rewards for all the LSTs reverts.
function claimRewards(address receiver) external onlyReserveHolder returns (uint256) {
uint256 balance = IERC20(asset).balanceOf(address(this));
uint256 reward = balance - totalDeposited;
IERC20(asset).safeTransfer(receiver, reward);
emit ClaimRewards(receiver, reward);
return reward;
}Similarly, the rebalance(...) function will revert once the swapAmountToEth(...) function is called in the adapter.
Recommendation
Consider skipping the adapter where funds are rescued when performing the rewards claiming or rebalancing process. This can be done by integrating a boolean flag that indicates if funds are rescued.
Resolution
f7a0e724bbfc742ce32b9ffcb7291ab6b21c17ec
This function will be used in urgencies where we need to rescue reserves that are backing USC stablecoin in case of exploit or migration to new version of reserve holder. This means that funds will be moved in safe place and that arbitrage mechanism will also be changed manually in that case.
discount computation in the case of an excess of reserves| File | Fix commit | Type | Status |
ArbitrageV5.sol | e250fcc | Medium | Fixed |
When the USC trades at peg (1 USD), there’s an arbitrage opportunity through the excess or deficit of reserves. In that case, the discount is computed to represent the difference between the USC supply and reserves. The discount computation depends on the reserves status, as shown in the documentation :
if (isExcessOfReserves) {
discount = (reserveDiff * 1 ether) / uscTotalSupplyValue;
} else{
discount = (reserveDiff * 1 ether) / reserveValue;
}However, the current implementation erroneously computes the discount in the case of an excess of reserves, as it divides the reserveDiff by the reserveValue instead of the uscTotalSupplyValue.
if (_almostEqualAbs(uscPrice, USC_TARGET_PRICE, pegPriceToleranceAbs)) {
discount = Math.mulDiv(reserveDiff, BASE_PRICE, reserveValue);
}Recommendation
Compute the discount based on the excess or deficit of reserves cases by dividing the reserveDiff by uscTotalSupplyValue or reserveValue, respectively.
Resolution
e250fcc0f20d22aec0461f6b553e09378114b88a
reserveAssets array lead to double accounting of reserves| File | Fix commit | Type | Status |
ReserveHolderV2.sol | e7e87a1 | Low | Fixed |
The reserveAssets array stores the list of current reserve tokens; each token has its own adapter where funds are kept.
The contract owner can add a new reserve asset to the system using the addReserveAsset(...) function. However, this function currently lacks a check to prevent adding the same token multiple times.
function addReserveAsset(address reserveAsset) external onlyOwner {
// @audit Possible duplicate asset in the array
reserveAssets.push(reserveAsset);
emit AddReserveAsset(reserveAsset);
}When calculating the total reserves in the system, the getReserveValue() function iterates through the array of assets and sums their reserves. This results in duplicated token reserves being counted twice, which impacts the protocol’s arbitrage functionality and breaks the system invariants.
function getReserveValue() public view returns (uint256) {
// ...
for (uint256 i = 0; i < reserveAssets.length; i++) {
// @audit Reserve value is counted twice for duplicated tokens
totalReserveValue += reserveAdapters[reserveAssets[i]].getReserveValue();
}
return totalReserveValue;
}Recommendation
Ensure that the added token does not already exist in the array. This can be achieved by setting up the adapter with the same function and ensuring no previous adapter is set. Additionally, prevent setting the adapter address to address(0) in the setReserveAssetAdapter(...) function.
Resolution
e7e87a14392da815e8d2719ac5526a8737f91527
swapTolerance functionality for rebalancing| File | Fix commit | Type | Status |
ReserveHolderV2.sol | 731d464 | Low | Fixed |
swapTolerance is a configurable value that defines the tolerance window for performing sales and buys during the rebalancing process.
However, this variable is never initialized, and the contract does not provide any function to update its value. Consequently, swapTolerance will always default to 0 and does not impact the maxReserveAssetValueForSell and minReserveAssetValueForBuy computation.
function rebalance(...) external onlyRebalancer {
// ...
for (uint256 i = 0; i < reserveAssets.length; i++) {
// ...
uint256 reserveAssetTargetValue = Math.mulDiv(totalReserveValue, reserveAssetPercentage, MAX_PERCENTAGE);
uint256 reserveAssetValue = reserveAdapters[reserveAsset].getReserveValue();
uint256 maxReserveAssetValueForSell = Math.mulDiv(
reserveAssetTargetValue,
// @audit swapTolerance is always 0
MAX_PERCENTAGE - swapTolerance,
MAX_PERCENTAGE
);
// ...
uint256 minReserveAssetValueForBuy = Math.mulDiv(
reserveAssetTargetValue,
// @audit swapTolerance is always 0
MAX_PERCENTAGE + swapTolerance,
MAX_PERCENTAGE
);
}
// ...
}Recommendation
Add an owner function to update the swapTolerance value.
Resolution
731d4649211dd22eeae33bfc9375c2e9eaef839b
stETH deposits will inflate the value of the reserves| File | Fix commit | Type | Status |
StEthAdapter.sol | c23ef6b | Low | Fixed |
There is a known issue with Lido’s stETH token called the 1-2 wei corner case, which can be found in the official docs here. When a user transfers stETH to another user (this applies to deposit transactions, too), under the hood, the stETH balance gets converted to shares, integer division happens, and rounding down applies. This means the actual balance transferred is often off by 1-2 wei. You can read more about the math behind the issue here.
The totalDeposited will be off by 1-2 weis after each deposit, meaning that if a user deposits 1e18 stEth, the actual amount deposited will be 0.99e18.
This means that the calculation of the ReserveHolderV2::getReserveValue will be wrong and slightly inflated because the StEthAdapter::getReserveValue function uses totalDeposited when calculating the value of the reserves.
The ArbitrageV5 contract relies on the precision of the reserves in the _getReservesData function, which will set the context for executing the arbitrage. In some cases, if the value of the reserveValue is very close to the value of uscTotalSupplyValue, the contract may assign the wrong value to the isExcessOfReserves boolean, and do wrong calculations.
Recommendation
Calculate the actual amount the user deposited, and update totalDeposited based on that, similarly to the flow of the StEthAdapter::swapAmountFromEth function.
Resolution
c23ef6b45a870f7c51440c838de1b89bae14ce05
| File | Fix commit | Type | Status |
ReserveHolderV2.sol | e7e87a1 | Info | Acknowledged |
The ReserveHolderV2 allows the Owner to add and support new LST tokens as reserves. However, the exposed functions to add support for new assets are segmented and could result in misconfigurations.
In order to support a new reserve asset, the owner will have to configure the below 3 steps.
1. Add a new Reserve Asset addReserveAsset() adds a new reserveAsset support in the ReserveHolderV2 2. Configure an adaptor for the asset setReserveAssetAdapter() adds an adapter for the new reserve asset 3. Add a percentage for the asset setReserveAssetPercentage() adds the percentage for the new reserve assets
If a new asset is added without configuring its adapter, the getReserveValue(...) function will revert, breaking any flow where it is used.
Similarly, if an asset’s adapter is set but was not added to the array, deposits from the ArbitrageV5 contract will go through ( i.e calls to mint(...)) and funds are added to the right adapter. However, since the asset is not in the list, these reserves are not accounted for when calling the getReserveValue() function. Consequently, the collateral invariant is broken, as USC is minted, but the corresponding reserves are not accounted.
Recommendation
To avoid possible misconfigurations, we recommend setting up the asset and its adapter within the same function.
Resolution
Partially resolved e7e87a14392da815e8d2719ac5526a8737f91527
Update from Nethermind Security
The provided commit does not full fix the issue. It is still possible to set the adapter for an inexistent asset. Consider ensuring that the token exists before setting the adapter within the setReserveAssetAdapter() function. This can be achieved by either iterating through the tokens array within the function, or using the reserveAdapters mapping.
ArbitrageV5::mint and ReserveHolderV2::deposit| File | Fix commit | Type | Status |
ArbitrageV5.solReserveHolderV2PriceFeedAggregator.sol | c23ef6b | Best Practices | Fixed |
The current ArbitrageV5::mint function lacks validation for the token input parameter, allowing anyone to call mint with an arbitrary address. During execution, the contract invokes safeTransferFrom on the specified token address, enabling external calls and potentially allowing users to execute arbitrary logic. Similarly, the deposit function in ReserveHolderV2 behaves similarly, accepting an address reserveAsset parameter and invoking safeTransferFrom.
While these arbitrary calls do not currently pose significant issues in the existing implementation, they could potentially impact external components interacting with the ArbitrageV5 contract.
Furthermore, if a new Chainlink price feed is integrated into the price feed aggregator, a user could mint USC by providing the address of the corresponding token as an input parameter to the mint function. In this scenario, USC would be minted without the collateral being deposited into the adapters, thereby violating the protocol’s 100% collateral invariant.
Recommendation
Revert the ReserveHolderV2::deposit transaction if a user attempts to deposit a token that is not supported and add input validation checks on the token address that the users pass inside the ArbitrageV5::mint function.
Resolution
c23ef6b45a870f7c51440c838de1b89bae14ce05
updatedAt parameter| File | Fix commit | Type | Status |
ReserveHolderV2.sol | — | Best Practices | Acknowledged |
During rebalance, the asset prices are read from the priceFeeAggregator which is used to compute the swap amount for the asset. The price is read from the aggregator using peek() function which sources the data from underlying oracles.
Below is a reference of how reserveAssetAmountToSwap is being computed using asset price.
uint256 reserveAssetAmountToSwap = Math.mulDiv(
reserveAssetValueToSwap,
10 ** IERC20Metadata(reserveAsset).decimals(),
_peek(reserveAsset)
);The peek call is routed to the underlying oracle to fetch the price of the asset.
function peek() external view returns (uint256 price) {
(, int256 priceInUSD, , , ) = chainlinkFeed.latestRoundData();
assert(priceInUSD > 0); // prices for assets from chainlink should always be grater than 0
return uint256(priceInUSD);
}Chainlink provides the updatedAt parameter to track the last time the price was updated. This field allows the consumer protocol to recognise a stale price. Accurate price feed is critical to ensure USC holds the peg and does not depeg, as using stale prices without noticing will impact the valuation of USC stable coin.
Recommendation
Use the updatedAt value returned by the oracle. If the price is older than a configured threshold, a notification should be emitted for corrective action.
asset variable in adapter contracts| File | Fix commit | Type | Status |
StEthAdapter.solWeEthAdapter.sol | c2f6097 | Best Practices | Fixed |
The StEthAdapter and WeEthAdapter contracts utilize the asset variable alongside constants that store asset addresses: stETH and weETH. The current implementation does not enforce initializing asset to the specific constant, potentially leading to errors and complicating the code review process.
Recommendation
Consider initializing the asset variable with the appropriate token constant and consistently use it throughout the logic.
Resolution
| File | Fix commit | Type | Status |
StEthAdapter.solWeEthAdapter.sol | — | Best Practices | Acknowledged |
The StEthAdapter contract implements a receive() function, allowing it to receive native Ether within the swap operations.
Within the swapAmountToEth(...) function, the contract receives native Ether when swapping the stETH, wrapping it into WETH. Likewise, within the swapAmountFromEth(...) function, transferred WETH to be swapped is unwrapped and received as native Ether in the contract.
However, any Ether that is received outside of these specific flows becomes locked within the contract, as there is no mechanism to withdraw it. Note that this applies to the WeEthAdapter contract as well.
Recommendation
In order to prevent locked Ether in the adapter contracts, restrict receiving Ether only from the necessary contracts.
| File | Fix commit | Type | Status |
ReserveHolderV2.sol | c326f8e | Best Practices | Fixed |
The upgrade of ReserveHolder implementation contract resulted in the following variables not being used in the new implementation ReserveHolderV2. Their declaration is kept to retain the storage layout. However, the current code lacks comments or indicators that these variables are deprecated.
uint256 public totalClaimed;
uint256 public swapEthTolerance;
uint256 public ethThreshold;
uint256 public totalStEthDeposited;
uint256 public curveStEthSafeGuardPercentage;Recommendation
Add a comment against each of these variables as deprecated or rename them as deprecated.
Resolution
New reserve holder contract will be deployed and funds will be migrated from old reserve holder. c326f8e6720b4caf409a474afeba000e613ea48a
Update from Nethermind Security
The commit fixes the issue under the assumption that the contract will be re-deployed and not upgraded. Otherwise, removing the variable will break the existent storage layout of the contract.
ReserveHolderV2| File | Fix commit | Type | Status |
ReserveHolderV2.sol | 550c318 | Best Practices | Fixed |
When a new adapter is assigned to a specific asset using the setReserveAssetAdapter(...) function, it receives unlimited approval for both the reserve asset and WETH. This setup facilitates the execution of deposit and swap functionalities.
However, if the asset adapter is updated to a new address, the unlimited approval granted to the previous address persists. While this does not pose a significant risk currently, it could potentially be exploited in future implementations of the ReserveHolderV2 contract.
function setReserveAssetAdapter(address reserveAsset, address adapter) external onlyOwner {
//@audit Approval for the previous adapter persists
reserveAdapters[reserveAsset] = IAdapter(adapter);
IERC20(reserveAsset).approve(adapter, type(uint256).max);
IERC20(WETH).approve(adapter, type(uint256).max);
emit SetReserveAssetAdapter(reserveAsset, adapter);
}Recommendation
When updating to a new adapter address, consider resetting the approval for the previous adapter to 0.
Resolution
Software documentation refers to the written or visual information that describes the functionality, architecture, design, and implementation of software. It provides a comprehensive overview of the software system and helps users, developers, and stakeholders understand how the software works, how to use it, and how to maintain it. Software documentation can take different forms, such as user manuals, system manuals, technical specifications, requirements documents, design documents, and code comments. Software documentation is critical in software development, enabling effective communication between developers, testers, users, and other stakeholders. It helps to ensure that everyone involved in the development process has a shared understanding of the software system and its functionality. Moreover, software documentation can improve software maintenance by providing a clear and complete understanding of the software system, making it easier for developers to maintain, modify, and update the software over time. Smart contracts can use various types of software documentation. Some of the most common types include:
These types of documentation are essential for smart contract development and maintenance. They help ensure that the contract is properly designed, implemented, and tested, and they provide a reference for developers who need to modify or maintain the contract in the future.
The Chi Protocol team has provided documentation about their protocol through their official documentation which includes a general overview of the protocol as well as a detailed description of the arbitrage process and its different flows. The information in the documentation is concise and technical, with well-written explanations. Additionally, the Chi Protocol team was available to address any questions or concerns from the Nethermind Security team.
Remarks about Chi Protocol’s test suite
The development team behind Chi Protocol has a comprehensive fuzz testing suite that checks the main functionalities of the protocol such as the different arbitrage scenarios, the mint and burn flows. However, note that the test suite is based on the ArbitrageV3 contract instead of ArbitrageV5. Furthermore, the testForkFuzzRebalance test fails because of the 1-2 wei corner case issue with stETH. To ensure robust testing coverage, we recommend updating the test suite to align with the V5 version of the Arbitrage contract and addressing the specific issues to ensure all tests pass successfully. This will help maintain the integrity and reliability of the protocol’s functionalities under various scenarios.
| 221Tests passed | 8Failed |
The complete test output is in the full report.
As auditors, we recommend that any changes or updates made to the audited codebase undergo a re-audit or security review to address potential vulnerabilities or risks introduced by the modifications. By conducting a re-audit or security review of the modified codebase, you can significantly enhance the overall security of your system and reduce the likelihood of exploitation. However, we do not possess the authority or right to impose obligations or restrictions on our clients regarding codebase updates, modifications, or subsequent audits. Accordingly, the decision to seek a re-audit or security review lies solely with you.
This report is based on the scope of materials and documentation provided by you to Nethermind in order that Nethermind could conduct the security review outlined in 1. Executive Summary and 2. Audited Files. The results set out in this report may not be complete nor inclusive of all vulnerabilities. Nethermind has provided the review and this report on an as-is, where-is, and as-available basis. You agree that your access and/or use, including but not limited to any associated services, products, protocols, platforms, content, and materials, will be at your sole risk. Blockchain technology remains under development and is subject to unknown risks and flaws. The review does not extend to the compiler layer, or any other areas beyond the programming language, or other programming aspects that could present security risks. This report does not indicate the endorsement of any particular project or team, nor guarantee its security. No third party should rely on this report in any way, including for the purpose of making any decisions to buy or sell a product, service or any other asset. To the fullest extent permitted by law, Nethermind disclaims any liability in connection with this report, its content, and any related services and products and your use thereof, including, without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement. Nethermind does not warrant, endorse, guarantee, or assume responsibility for any product or service advertised or offered by a third party through the product, any open source or third-party software, code, libraries, materials, or information linked to, called by, referenced by or accessible through the report, its content, and the related services and products, any hyperlinked websites, any websites or mobile applications appearing on any advertising, and Nethermind will not be a party to or in any way be responsible for monitoring any transaction between you and any third-party providers of products or services. As with the purchase or use of a product or service through any medium or in any environment, you should use your best judgment and exercise caution where appropriate. FOR AVOIDANCE OF DOUBT, THE REPORT, ITS CONTENT, ACCESS, AND/OR USAGE THEREOF, INCLUDING ANY ASSOCIATED SERVICES OR MATERIALS, SHALL NOT BE CONSIDERED OR RELIED UPON AS ANY FORM OF FINANCIAL, INVESTMENT, TAX, LEGAL, REGULATORY, OR OTHER ADVICE.
The Leading Engineers of Blockchain Infrastructure