Download audit report
This document presents the security review performed by Nethermind Security for the smart contracts of MetaPool. MetaPool protocol is a multi-chain liquidity-staking ecosystem that allows users to stake tokens and earn yield. Staking users will also get voting rights for the DAO of the protocol. This audit scope comprises smart contracts related to integration of MetaPool with Story Protocol.
Anyone can deposit either native IP tokens or wrapped IP tokens in the protocol. Only the entitled operator role will be able to stake the deposited tokens with the validator. Users can initiate withdrawal of their tokens any time with a waiting period of 14 days. The yield earned is given to the user at the time of withdrawal along with their deposited tokens.
The operator is responsible for provisioning tokens for withdrawal request either by un-staking funds from the validator or routing the funds from new deposits. Operators can choose to restake the accrued rewards for compounding.
This security review focuses exclusively on the smart contracts listed in Section 2 (Audited Files).
The audited code comprises of 703 lines of code written in the Solidity language, and the audit was performed using (a) manual analysis of the codebase and (b) creation of test cases.
| Audit assessment | |
| Audit Type | Security Review |
| Initial Report | Feb 07, 2025 |
| Response from Client | Regular responses during audit engagement |
| Final Report | Feb 10, 2025 |
| Repository | MetaPool-Story Protocol |
| Commit (Audit) | 24806b73c4 |
| Commit (Final) | cdd68063ff |
| Documentation Assessment | Low |
| Test Suite Assessment | Medium |
Findings by severity
| # | Contract | LoC | Comments | Ratio | Blank | Total |
| 1 | StakedIP.sol | 391 | 86 | 22.0% | 113 | 590 |
| 2 | RewardsManager.sol | 61 | 6 | 9.8% | 16 | 83 |
| 3 | Withdrawal.sol | 99 | 17 | 17.2% | 32 | 148 |
| 4 | interfaces/IStakedIP.sol | 6 | 3 | 50.0% | 4 | 13 |
| 5 | interfaces/IWIP.sol | 10 | 1 | 10.0% | 7 | 18 |
| 6 | interfaces/IRewardsManager.sol | 5 | 1 | 20.0% | 2 | 8 |
| 7 | interfaces/IWithdrawal.sol | 5 | 1 | 20.0% | 2 | 8 |
| 8 | interfaces/IStakedIPVaultOperations.sol | 5 | 1 | 20.0% | 2 | 8 |
| 9 | interfaces/story/IIPTokenStakingFull.sol | 6 | 1 | 16.7% | 3 | 10 |
| 10 | interfaces/story/IIPTokenStaking.sol | 115 | 157 | 136.5% | 30 | 302 |
| Total | 703 | 274 | 39.0% | 211 | 1188 |
| # | Finding | Severity | Update |
| 1 | Incorrect implementation of StakedIP::mint | Critical | Fixed |
| 2 | Users cannot deposit with WIP | Critical | Fixed |
| 3 | Excessive IP tokens in Withdrawal contract cannot be restaked to StakedIP | High | Fixed |
| 4 | Remove validator operation is buggy, creates duplicate entry in the array | High | Fixed |
| 5 | RewardsManager cannot accept Native tokens | High | Fixed |
| 6 | User staked tokens could be locked in Withdraw contract | Medium | Fixed |
| 7 | Use of transfer when sending native tokens | Low | Fixed |
| 8 | Emit event only when rewards are disbursed | Info | Fixed |
| 9 | IStakedIPVaultOperations interface is not used | Info | Fixed |
| 10 | Unused imports/Error in Withdrawal contract | Info | Fixed |
| 11 | StakedIP is not fully ERC4626-compatible | Info | Fixed |
| 12 | getValidatorIndex should iterate over validatorsLength | Info | Fixed |
| 13 | injectRewards should be callable only from RewardManager contract | Info | Fixed |
| 14 | Ownership is more secure with two-step transfers | Best Practices | Fixed |
| 15 | Unlocked and multiple solidity versions | Best Practices | Fixed |
MetaPool is a multi-chain liquidity stake ecosystem. The current scope of smart contracts are related to integration with the Story protocol. StakedIP is the main interfacing contract that extends the ERC4626 specification. StakedIP is upgradeable. The Story Protocol expects a RewardManager contract and a Withdrawal contract to be configured.
The tokens deposited by the users are staked and allocated to the validators. Any withdrawal request from the user will undergo a waiting period. The Story Protocol sends the yield to the RewardManager contract. Staker will get their yield at the time of withdrawal along with their deposited tokens.

Anyone can deposit native or wrapped tokens to MetaPool in return for a yield. The deposited liquidity is managed by an operator role. The operator chooses the amount, the period for staking, and the validator to stake the available funds.
Users can initiate a request to withdraw the deposited funds anytime. As the deposited funds are staked in the Story Protocol, there is a waiting period of 14 days for the request to be processed. The operator can cover the funds required for withdrawal from new deposits or by un-staking funds from the validator. The earned yield for the user is computed at the time of withdrawal request, which is sent along with deposited funds on completion of the request.
Story Protocol sends the rewards to the configured Reward Manager contract. The operator can choose to re-stake the earned rewards into the story protocol for compounding.
The owner of the protocol can perform admin functions to configure the values in the protocol.
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.
StakedIP::mint| File | Fix commit | Type | Status |
StakedIP.sol | d91cdae | Critical | Fixed |
The mint function is intended to accept shares as its first argument and return the required number of assets. Its purpose is to mint the exact number of shares for the receiver by depositing the corresponding amount of underlying assets. However, the function is incorrectly overridden:
function mint(uint256 _assets, address _receiver) public override returns (uint256) {
_transferAndUnwrap(msg.sender, _assets);
uint256 shares = previewMint(_assets);
_deposit(msg.sender, _receiver, _assets, shares);
return shares;
}The implementation contains several critical issues:
1. The function incorrectly accepts assets instead of shares as input, contradicting its intended behavior; 2. It transfers the received _assets(which are the shares) instead of calculating and transferring the required assets for minting the specified shares; 3. It incorrectly computes shares using previewMint, whereas previewMint actually returns the amount of assets needed to mint the exact number of shares;
Recommendation
Update the mint function to correctly accept shares as input and ensure it transfers the required assets from the user:
function mint(uint256 shares, address receiver) public override returns (uint256) {
uint256 assets = previewMint(shares);
_transferAndUnwrap(msg.sender, assets);
_deposit(msg.sender, receiver, assets, shares);
return assets;
}Resolution
Fixed in commit d91cdae
| File | Fix commit | Type | Status |
StakedIP.sol | b9fc12d | Critical | Fixed |
The StakedIP contract allows users to deposit into the vault using WIP. The deposit function is designed to transfer WIP to the contract and subsequently unwrap it into IP:
function depositIP(address _receiver) public payable returns (uint256) {
uint256 shares = previewDeposit(msg.value);
_deposit(address(this), _receiver, msg.value, shares);
return shares;
}
function _transferAndUnwrap(address _from, uint256 _amount) private {
address asset = asset();
IERC20(asset).safeTransferFrom(_from, address(this), _amount);
==> IWIP(asset).withdraw(_amount);
}However, the StakedIP contract incorrectly prevents the WIP contract from sending native tokens due to a restrictive condition in the receive fallback function:
receive() external payable {
==> require(msg.sender != asset()
&& msg.sender != withdrawal, InvalidDepositSender(msg.sender));
depositIP(msg.sender);
}Since WIP must send native tokens when unwrapping, this restriction causes the withdraw function to fail, leading to a permanent failure of deposits using WIP. As a result, users cannot deposit through WIP
Recommendation
Revise the revert condition in the receive fallback function to allow the WIP contract to send native tokens to StakedIP.
Resolution
Fixed in commit b9fc12d
Withdrawal contract cannot be restaked to StakedIP| File | Fix commit | Type | Status |
StakedIP.solWithdrawal.sol | 13e6f70 | High | Fixed |
When withdrawal requests are made, the operator can cover withdrawals by calling coverWithdrawals, which transfers IP tokens to the Withdrawal contract. The Withdrawal contract may hold more IP tokens than required for withdrawals. In such cases, these excess tokens should be restaked back into the StakedIP vault, hence the utility of sendIPToRestake function. There are two key implementation issues that prevent this from happening:
1. The sendIPToRestake function is restricted to being called only by the StakedIP contract:
function sendIPToRestake(uint256 _amount) external onlyStaking {
if (address(this).balance <= totalPendingWithdrawals) revert NotEnoughIPtoStake(_amount, 0);
uint256 ipRemaining = address(this).balance - totalPendingWithdrawals;
if (_amount > ipRemaining) revert NotEnoughIPtoStake(_amount, ipRemaining);
stIP.sendValue(_amount);
}This restriction is problematic because the StakedIP contract cannot directly call the Withdrawal contract to retrieve excess tokens. Instead, the Withdrawal contract should be responsible for transferring these tokens back to StakedIP. 2. The receive fallback function in StakedIP incorrectly blocks the Withdrawal contract from sending IP tokens:
receive() external payable {
require(msg.sender != asset() && msg.sender != withdrawal, InvalidDepositSender(msg.sender));
depositIP(msg.sender);
}This restriction prevents the Withdrawal contract from restaking its excess IP tokens by calling sendIPToRestake.
Due to these implementation flaws, any excess IP tokens held by the Withdrawal contract are stuck and cannot be restaked.
Recommendation
Revisit the revert condition of receive fallback in StakedIP. Also, remove the onlyStaking modifier from sendIPToRestake.
Resolution
Fixed in commit 13e6f70
| File | Fix commit | Type | Status |
StakedIP.sol | 16ab74e | High | Fixed |
_removeValidator function in StakedIPVaultOperations does not correctly delete the item from the validators array. As a result, the same item could result in duplicate entries for the same validator.
function _removeValidator(bytes memory _validatorCmpPubkey) private {
uint256 _validatorsLength = validatorsLength;
require(_validatorsLength > 1, ValidatorsEmptyList());
uint256 _index = getValidatorIndex(_validatorCmpPubkey);
Validator memory validator = _validators[_index];
require(validator.targetStakePercent == 0, ValidatorHasTargetPercent(validator));
if (_index != _validatorsLength - 1) {
==> _validators[_index] = _validators[_validatorsLength - 1];
} else {
delete _validators[_index];
}
//...
}In the case where, the element being deleted is not the last element of the array, the last element of the array is copied into the index of the element being deleted. But, as the last element is not popped from the array, this will result in two instances of the same validator.
Example:
validators[
{index:0,pubkey:"A"},
{index:1,pubkey:"B"},
{index:2,pubkey:"C"}
];
// Remove pubkey=="B" would result as below
validators[
{index:0,pubkey:"A"},
{index:2,pubkey:"C"},
{index:2,pubkey:"C"}
];This will impact how the validators array is used in the contract. For example, redistribute function will return incorrect results.
Recommendation
Pop the last element of the validators array.
Resolution
Fixed in commit 16ab74e
| File | Fix commit | Type | Status |
RewardsManager.sol | 0be2869 | High | Fixed |
RewardsManager contract tracks the accrued rewards which are then restaked as part of compounding. A treasury fee is deducted from the rewards which is sent to the treasury address.
function sendRewardsAndFees() external {
(uint rewards, uint treasuryFee) = getManagerAccrued();
IStakedIP(stakedIP).injectRewards{ value: rewards }();
payable(treasury).sendValue(treasuryFee);
emit SendRewards(msg.sender, rewards);
emit SendFees(msg.sender, treasuryFee);
}
function getManagerAccrued() public view returns (uint rewards, uint treasuryFee) {
uint balance = address(this).balance;
treasuryFee = (balance * rewardsFeeBp) / ONE_HUNDRED;
rewards = balance - treasuryFee;
}The issue arises from how the accrued amount is computed in the contract. As the RewardsManager contract does not have a receive or payable functions, there seems no way in how the balance of native tokens in the contract will accrue for distribution.
This issue impacts the working of reward accruals for the protocol.
Recommendation
Add receive function so that rewards can be received into the contract from story protocol.
Resolution
Fixed in commit 0be2869
| File | Fix commit | Type | Status |
StakedIP.sol | d700889 | Medium | Fixed |
StakedIP contract overrides the _withdraw function of ERC4626 library contract and implements a withdrawal queue that has a waiting period before the request can be completed. On _withdraw call, the accounting for shares and assets are updated and a request is submitted to the Withdrawal contract. As a result, the withdrawal will not be completed in a single transaction.
function _withdraw(
address _caller,
address _receiver,
address _owner,
uint256 _assets,
uint256 _shares
) internal override onlyFullyOperational {
if (_shares == 0) revert InvalidZeroAmount();
if (_caller != _owner) _spendAllowance(_owner, _caller, _shares);
_burn(_owner, _shares);
totalUnderlying -= _assets;
IWithdrawal(withdrawal).requestWithdraw(_assets, _caller, _receiver);
emit Withdraw(msg.sender, _receiver, _owner, _shares, _assets);
}When the user tries to process the pending withdrawal request, the issues arises if the _receiver setup in the request is a smart contract that does not accept native tokens. In that case, the completeWithdraw will revert and the funds will remain locked in the Withdrawal contract.
function completeWithdraw(uint256 _request_id) external {
WithdrawRequest memory _pendingUserWithdraw = _userPendingWithdrawals[msg.sender][_request_id];
//...
payable(_pendingUserWithdraw.receiver).sendValue(_pendingUserWithdraw.amount);
//...
}Recommendation
Add an option for the request owner to send WIP instead of IP tokens.
Resolution
Fixed in commit d700889
transfer when sending native tokens| File | Fix commit | Type | Status |
StakedIP.sol | 735a14f | Low | Fixed |
In order to transfer native tokens, the StakedIP contract is currently using the transfer function. This is not a recommended function to move native tokens due to the fixed gas limit of 2300. As the gas cost is subject to change as part of infra upgrades.
Also, if the recipient is a smart contract like a multi-sign wallet, 2300 gas will not cover the gas required to complete the transfer leading to revert.
function mintIP(uint256 _shares, address _receiver) external payable returns (uint256) {
//...
uint256 change = msg.value - assets;
if (change > 0) {
payable(msg.sender).transfer(change);
}
//...
}Recommendation
Use .sendValue function to move native tokens like in other places in the contract.
Resolution
Fixed in commit 735a14f
| File | Fix commit | Type | Status |
RewardsManager.sol | 0eed09c | Info | Fixed |
In RewardsManager contact, sendRewardsAndFees function can be called by anyone to process the accrued rewards. Rewards are injected to the StakedIP contract and the applicable fee is transferred to the treasury address.
function sendRewardsAndFees() external nonReentrant {
(uint256 rewards, uint256 treasuryFee) = getManagerAccrued();
if (rewards > 0) IStakedIP(stakedIP).injectRewards{ value: rewards }();
if (treasuryFee > 0) payable(treasury).sendValue(treasuryFee);
==> emit SendRewardsAndFees(msg.sender, rewards, treasuryFee);
}The event SendRewardsAndFees should be emitted only when accrued rewards are processed. In the current implementation, the event is emitted even when there are no accrued rewards.
Recommendation
emit SendRewardsAndFees event only when rewards > 0.
Resolution
Fixed in commit 0eed09c
| File | Fix commit | Type | Status |
IStakedIPVaultOperations.sol | — | Info | Fixed |
Functions of IStakedIPVaultOperations interface are migrated from dedicated operations contract to StakedIP contract, but the contract does not derive from IStakedIPVaultOperations.
interface IStakedIPVaultOperations {
function getValidatorIndex(bytes memory _validatorUncmpPubkey) external view returns (uint256);
function isValidatorListed(bytes memory _validatorUncmpPubkey) external view returns (bool);
}Recommendation
StakedIP contract should inherit from IStakedIPVaultOperations interface.
Resolution
Removed the interface
| File | Fix commit | Type | Status |
Withdrawal.sol | edf0024 | Info | Fixed |
The Withdrawal contract has imports from other files, but they were never used in the contract.
Like wise, the below error was also not used in the contract.
Recommendation
Remove redundant imports or objects from the contract.
Resolution
Fixed in commit edf0024
StakedIP is not fully ERC4626-compatible| File | Fix commit | Type | Status |
StakedIP.sol | cdd6806 | Info | Fixed |
In the _deposit function, the first parameter is the caller of the function. But, in the case of depositIP and mintIP, the address of the contract is being passed as a caller instead of msg.sender.
function depositIP(address _receiver) public payable returns (uint256) {
uint256 shares = previewDeposit(msg.value);
_deposit(address(this), _receiver, msg.value, shares);
return shares;
}While the contract can indeed deposit IP in the staking setup via setupStaking, users can still call the function to deposit IP and in such cases, the depositor will be logged as the contract’s address instead of the caller.
In addition, the first parameter of the Withdraw event in _withdraw is emitted with the msg.sender directly, while the function already accepts the caller in its first argument and that argument should be used instead.
Recommendation
Consider:
1. Passing msg.sender as caller for _deposit in the depositIP function. 2. Updating the first argument of the Withdraw event emitted in _withdraw from msg.sender to _caller.
Resolution
Fixed in commit cdd6806
getValidatorIndex should iterate over validatorsLength| File | Fix commit | Type | Status |
StakedIP.sol | 55916ab | Info | Fixed |
The StakedIP contract tracks the current number of validators using validatorsLength. While the max number of validators is 10, In the case where the current number is smaller, the getValidatorIndex function is still iterating over the full length of the array. Instead, while searching for validator index, the logic can iterate up to validatorsLength instead of validators.length.
function getValidatorIndex(bytes memory _validatorCmpPubkey) public view returns (uint256) {
Validator[MAX_VALIDATORS] memory validators = _validators;
bytes32 _validatorPubkeyHash = keccak256(_validatorCmpPubkey);
for (uint256 i = 0; i < validators.length; ++i) {
if (keccak256(validators[i].cmpPubkey) == _validatorPubkeyHash) {
return i;
}
}
revert ValidatorNotFount(_validatorCmpPubkey);
}Recommendation
Update for loop to iterate on validatorsLength value instead of validators.length.
Resolution
Fixed in commit 55916ab
| File | Fix commit | Type | Status |
StakedIP.solRewardsManager.sol | 090f129 | Info | Fixed |
When sendRewardsAndFees function is called on the RewardManager contract, the reward funds are sent from the RewardManager contract to the StakedIP contract.
function sendRewardsAndFees() external nonReentrant {
(uint256 rewards, uint256 treasuryFee) = getManagerAccrued();
if (rewards > 0) IStakedIP(stakedIP).injectRewards{ value: rewards }();
//...
}But, in the StakedIP contract, there is no access control assigned to the injectRewards function. As a result any one can call the function.
function injectRewards() external payable {
require(msg.value >= minDepositAmount, LessThanMinDeposit());
totalUnderlying += msg.value;
}Recommendation
Assign a modifier that will restrict the access for injectRewards to RewardManager contract only.
Resolution
Fixed in commit 090f129
| File | Fix commit | Type | Status |
RewardsManager.sol | cfb9d4d | Best Practices | Fixed |
As owner is a critical role in managing admin functions of the protocol, it is recommended to implement a two step transfer process. In the first step, the current owner initiates the process for the new account to take over the ownership. As a second step, the new account will claim the ownership. This ensures that the caller of the claiming function has control on the new account.
contract RewardsManager is IRewardsManager, Ownable, ReentrancyGuard {Recommendation
Consider using the Ownable2Step library contract of openzeppelin instead of Ownable. Likewise for StakedIP and Withdrawal contracts, consider using the Ownable2StepUpgradeable library contract.
Resolution
Fixed in commit cfb9d4d
| File | Fix commit | Type | Status |
IWIP.solIIPTokenStaking.sol | 41c0b29 | Best Practices | Fixed |
It is recommended to use locked and single solidity versions in the project. The below two interface files are using an unlocked and older version of Solidity.
pragma solidity ^0.8.23;Recommendation
It is recommended to use a single and locked version of Solidity.
Resolution
Fixed in commit 41c0b29
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 MetaPool team was actively present in regular calls, effectively addressing concerns and questions raised by the Nethermind Security team. However, the code contained only minimal NatSpec documentation, and there was no comprehensive project documentation. The team could improve this by providing a well-structured written overview of the system and detailing the different design choices to enhance clarity and accessibility.
| 21Tests passed | 0Failed |
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