Web3 · Smart Contract Audit

Velvet Capital Security Audit

softstack completed a smart contract audit of Velvet Capital's Core v3 Contracts in July 2024, reporting 50 findings (2 high, 4 medium, 21 low and 23 informational), of which 47 were resolved or mitigated before the final report. The full report is published in the softstack public audit archive.

Key facts

Client
Velvet Capital
Completed
Languages
Solidity
Commit
849629b1aacf
Market cap
$26M as of 2026-09-30

About the project

Velvet Capital runs an onchain trading terminal for spot trades, perpetual futures and yield strategies executed from a trader's own wallet. It routes through aggregated DEX liquidity on chains including Ethereum, Solana, Base, BNB Chain and Hyperliquid, with MEV protection. A social layer tracks wallets and an AI assistant supports token research. The company is backed by YZi Labs.

Case study

Scope

Source repositorygithub.com/Velvet-Capital/v3-contract

Components reviewed

1 module
  1. See the published report for the file list

Findings

0Critical
2High
4Medium
21Low
23Informational

47 of 50 findings resolved before the final report.

IDTitleSeverityStatus
6.2.1Incorrect Parameter Order in Function Call

In the call to the calculateProtocolAndManagementFeesToMint function, the parameters lastChargedProtocolFee and lastChargedManagementFee are swapped.

Highfixed
6.2.2Incorrect updatedAt Value Retrieval

In the latestRoundData function where the latest price data for a token pair is retrieved, the updatedAt value is expected to be the second to last value returned by the latestRoundData function from the AggregatorV2V3Interface.

Highfixed
6.2.3Division by Zero in PortfolioCalculations Contract

The PortolfioCalculations contract contains a function getUserAmountToDeposit that calculates the lowest amount possible to deposit to get the exact ratio of token amounts in a portfolio.

Mediumfixed
6.2.4Incorrect Calculation Due to Mismatched Array Lengths in PortfolioCalculations Contract

The PortfolioCalculations contract contains a function getUserAmountToDeposit that calculates the lowest amount possible to deposit to get the exact ratio of token amounts in a portfolio.

Mediumfixed
6.2.5Division Before Multiplication in FeeCalculations and PortfolioCalculations Contracts

The FeeCalculations and PortolfioCalculations contracts contain functions that perform a multiplication on the result of a division.

Mediumfixed
6.2.6Potential Issue with UUPSUpgradeable in _upgrade Function Due to Outdated OpenZeppelin Library

The _upgrade function in the PortfolioFactory contract uses the UUPSUpgradeable contract to upgrade proxies.

Mediumfixed
6.2.7Division by Zero in PortfolioCalculations Contract

The PortolfioCalculations contract contains a function getUserAmountToDeposit that calculates the lowest amount possible to deposit to get the exact ratio of token amounts in a portfolio.

Lowfixed
6.2.8Use Ownable2Step for Safer Ownership Transfer in VelvetSafeModule

The VelvetSafeModule contract currently uses the transferOwnership function from the Ownable contract, which transfers ownership in a single step.

Lowfixed
6.2.9Potential Denial of Service (DoS) in whitelistUser Function Due to Lack of User Limit

The whitelistUser function in the UserWhitelistManagement contract allows an arbitrary number of users to be whitelisted in a single transaction.

Lowfixed
6.2.10Missing Event Emission in PriceOracleAbstract.updateOracleExpirationThreshold Function

The PriceOracleAbstract contract contains a function updateOracleExpirationThreshold that updates the oracleExpirationThreshold state variable. However, this function does not emit an event when the state variable is updated.

Lowfixed
6.2.11Deprecated Library Function Usage in AccessController

The AccessController contract uses the deprecated _setupRole function from the OpenZeppelin AccessControl library.

Lowfixed
6.2.12Incompatibility with Solidity 0.8.20 Due to PUSH0 Opcode

The contracts are compiled with Solidity version 0.8.23, which defaults to targeting the Shanghai EVM version. This includes the new PUSH0 opcode introduced in Solidity 0.8.20. The PUSH0

Lowfixed
6.2.13Missing Storage Gap in TokenBalanceLibrary for Upgradeable Contracts

The TokenBalanceLibrary contract does not include a storage gap, which is essential for maintaining storage compatibility in upgradeable contracts.

Lowacknowledged
6.2.14Non-compliance with Solidity Function Order in TokenBalanceLibrary

The TokenBalanceLibrary contract does not follow the recommended function order as specified in the Solidity style guide.

Lowfixed
6.2.15Potential Division by Zero and Rounding Issues in calculateMintAmount and getDepositToVaultBalanceRatio Functions

The calculateMintAmount and getDepositToVaultBalanceRatio functions in the contract perform divisions without checking for zero values in the input parameters. This can lead to the functions reverting when zero is passed as an argument.

Lowfixed
6.2.16Inconsistent Handling of Deadlines in CooldownManager Contract

The CooldownManager contract uses a timestamp comparison to enforce cooldown periods. According to EIP-2612, signatures used on exactly the deadline timestamp should be allowed.

Lowfixed
6.2.17Public Functions Not Used Internally Should Be Marked as External

In the codebase, several functions are marked as public but are not used internally within their respective contracts. According to best practices, functions that are not called internally should be marked as external instead of public.

Lowfixed
6.2.18Events Missing indexed Fields in Multiple Contracts

Several events across multiple contracts are missing indexed fields. Indexing event fields makes them more quickly accessible to off-chain tools that parse events.

Lowfixed
6.2.19Empty Blocks in _authorizeUpgrade Functions

Several _authorizeUpgrade functions across multiple contracts contain empty blocks. Empty blocks do not contribute to the functionality of the contract and can be removed to improve code readability and maintainability.

Lowfixed
6.2.20Internal Functions Called Only Once Should Be Inlined

Several internal functions across multiple contracts are called only once. Instead of separating the logic into a separate function, consider inlining the logic into the calling function.

Lowfixed
6.2.21Unused Custom Errors in Multiple Contracts

Several custom errors are defined but not used in the codebase. It is recommended to remove these unused custom errors to improve code readability and maintainability. Unused code can lead to confusion and potential errors in the future.

Lowfixed
6.2.22Missing Event Emission in _updatePriceOracle Function OracleManagement contract

The _updatePriceOracle function in the contract updates the priceOracle address but does not emit an event to log this change.

Lowfixed
6.2.23Missing Check for Identical Protocol Fee in updateProtocolFee and updateProtocolStreamingFee Functions in ProtocolFeeManagement contract

The updateProtocolFee and updateProtocolStreamingFee functions in the contract update the protocol fee and protocol streaming fee, respectively. However, these functions do not check if the new fee is the same as the current fee.

Lowfixed
6.2.24Missing Check for Identical Treasury Address in updateVelvetTreasury Function in ProtocolTreasuryManagement contract

The updateVelvetTreasury function in the contract updates the velvetTreasury address but does not check if the new address is the same as the current address.

Lowfixed
6.2.25Missing Minimum Cooldown Period Check in setCoolDownPeriod Function

The setCoolDownPeriod function in the SystemSettings contract allows the protocol owner to set a new cooldown period. However, there is no check to ensure that the new cooldown period is above a minimum acceptable value.

Lowfixed
6.2.26Prevent Division by Zero in getDepositToVaultBalanceRatio function

In the getDepositToVaultBalanceRatio function, division by zero can occur if tokenBalance is zero, which could lead to unexpected reverts.

Lowfixed
6.2.27Missing Cooldown Period Check for Deposit

The multiTokenDeposit function lacks a cooldown period check, which is present in the multiTokenWithdrawal function.

Lowacknowledged
6.2.28Missing inheritance

Some contracts are missing inheritance from their respective interfaces or base contracts.

Informationalfixed
6.2.29Too Many Digits

The contract FeeConfig contains a literal with too many digits, making it difficult to read and review.

Informationalfixed
6.2.30Unused Imports

Importing files that are not used in the contract likely indicates a mistake. These unused imports should be removed to avoid confusion and improve code clarity.

Informationalfixed
6.2.31Non-compliance with Solidity Style Guide in AssetManagerCheck and OwnableCheck Contracts

The AssetManagerCheck and OwnableCheck contracts does not follow the recommended ordering of elements as specified in the Solidity style guide.

Informationalfixed
6.2.32Missing NatSpec Comments in enableSolverHandler Function

The enableSolverHandler function in the SolverManagement contract lacks NatSpec comments, which are essential for providing clear documentation for both developers and end users.

Informationalfixed
6.2.33Non-compliance with Solidity Naming Convention in MathUtils Library

The MathUtils library contains internal functions that do not follow the Solidity style guide

Informationalfixed
6.2.34Redundant Return Statement in getTokenBalancesOf Function

The getTokenBalancesOf function in the TokenBalanceLibrary contract defines a named return variable vaultBalances.

Informationalfixed
6.2.35Use Enums for Array Indices Instead of Numeric Literals in PortfolioCalculations Contract

The PortolfioCalculations contract uses numeric literals to reference array indices, which can lead to errors and reduce code readability.

Informationalacknowledged
6.2.36Potential Issues with abi.encodeWithSignature in GnosisDeployer Contract

The GnosisDeployer contract uses abi.encodeWithSignature to encode function calls. This approach is prone to errors such as typos in the function signature and incorrect parameter types.

Informationalfixed
6.2.37Use bytes.concat Instead of abi.encodePacked in GnosisDeployer Contract

The GnosisDeployer contract uses abi.encodePacked for concatenating bytes. Solidity version 0.8.4 introduces bytes.concat, which is a safer and more efficient method for concatenating bytes.

Informationalfixed
6.2.38Superfluous Initialization of Loop Variable in getTokenBalancesOf Function

The getTokenBalancesOf function in the TokenBalanceLibrary contract initializes the loop variable i to zero explicitly. In Solidity, the default value for uninitialized variables is zero, making this explicit initialization redundant.

Informationalfixed
6.2.39Optimization Opportunity in _disableInitializers Function

The _disableInitializers function in the contract uses an older version of the OpenZeppelin library.

Informationalfixed
6.2.40Typographical Error in Smart Contract File Name PortolfioCalculations.sol

The smart contract file intended to be named PortfolioCalculations.sol is mistakenly titled PortolfioCalculations.sol. This typographical error in the file name could lead to several potential issues in a project.

Informationalfixed
6.2.41Unnecessary Variable Usage in _updateWeights Function

In the _updateWeights function, the _sellTokens array is assigned to the sellToken variable within the loop. However, the _sellTokens array is accessed directly again in the subsequent line.

Informationalfixed
6.2.42Missing Function Parameters in NatSpec Documentation

There are multiple functions missing documentation for their parameters in the NatSpec comments. This lack of documentation can lead to confusion for users and developers about the purpose and usage of the parameters.

Informationalfixed
6.2.43Missing NatSpec Documentation for Interfaces

Several contracts are missing NatSpec documentation for their functions. NatSpec comments are essential for providing clear, standardized documentation for functions, making them easier to understand and use.

Informationalfixed
6.2.44Incorrect Documentation

In the claimRewardTokens function, the NatSpec documentation for the rewardTokenBalanceAfter variable incorrectly states "all Tokens", which is misleading as it only fetches the balance of a specific token.

Informationalfixed
6.2.45Inconsistent Implementation of updateTokens Function in IRebalancing and Rebalancing Contracts

The updateTokens function in the IRebalancing interface is documented and implemented differently compared to the updateTokens function in the Rebalancing contract.

Informationalfixed
6.2.46Duplicate NatSpec Documentation for getUserAmountToDeposit Function

The getUserAmountToDeposit function has duplicate NatSpec documentation comments. This redundancy can clutter the code and potentially confuse developers and users.

Informationalfixed
6.2.47Gas Optimization for setEmergencyPause Function

The setEmergencyPause function can be optimized for gas efficiency. The _state parameter is always passed as true when calling setProtocolPause(_state) initially, and always passed as false when calling setProtocolPause(_state)…

Informationalfixed
6.2.48Use of Constant ONE_ETH_IN_WEI for Gas Efficiency

In the calculateMintAmount function, the value 10 ** 18 is used, which can be replaced by the constant ONE_ETH_IN_WEI defined above. Using a constant can save gas and make the code more readable and maintainable.

Informationalfixed
6.2.49Unused Named Returns

The functions getVaultValueInUSD and _burnWithdraw have unused named returns. Named returns can improve readability and gas consumption, but if not used consistently throughout the function, they may introduce confusion and redundancy.

Informationalfixed
6.2.50Assignment of tokensLength Variable Earlier in initToken Function

The initToken function checks the length of _tokens multiple times. Assigning the length to the tokensLength variable earlier can improve readability and efficiency by using this variable consistently throughout the function.

Informationalfixed

About this engagement

A smart contract audit reviews on-chain code for flaws an attacker could exploit. Engineers trace how assets move through the contracts, check who can call privileged functions, and test the arithmetic, external calls and upgrade paths. Each finding is rated by severity, and fixes are re-checked before the final report.

How softstack runs smart contract audits

Methodology

Review process

  1. Scoping and threat modelling

    The commit hash is frozen and the attack surface is mapped: asset flows, trust assumptions, privileged roles and the external systems the code depends on.

  2. Automated analysis

    Static analysers sweep the full codebase to surface known weakness patterns, unreachable states and deviations from established conventions.

  3. Manual code review

    Independent engineers read the code line by line, concentrating on business logic, access control, arithmetic and the handling of external calls.

  4. Adversarial testing

    Property-based fuzzing and invariant tests attack the assumptions the protocol relies on, targeting states that ordinary unit tests never reach.

  5. Reporting

    Every finding is documented with a severity rating, its impact, the steps to reproduce it and a concrete remediation the team can act on.

  6. Remediation verification

    Submitted fixes are re-reviewed against the original finding, and the final report records the resolved state of each one.

Standards and references

  • SWC RegistrySmart Contract Weakness Classification
  • CWECommon Weakness Enumeration

FAQ

Velvet Capital was audited by softstack GmbH, a German Web3 security and software company based in Flensburg and certified to ISO/IEC 27001 by TÜV SÜD. softstack completed a smart contract audit for Velvet Capital in July 2024. The full report is linked on this page and published in the softstack public audit archive.

The review reported 50 findings: 2 high, 4 medium, 21 low and 23 informational. 47 of 50 were resolved or mitigated before the final report.

The review covered the code in github.com/Velvet-Capital/v3-contract at commit 849629b. The published report lists every file covered.

This report covers the code as reviewed in July 2024 at commit 849629b. Any code changed after that point is outside the reviewed scope.

Related audits

Browse all security audits

Disclaimer

This audit represents a point-in-time security assessment of the reviewed codebase and is intended for informational purposes only. While Softstack applies industry-standard security review methodologies, no audit can guarantee the absence of vulnerabilities, bugs, or other security risks. This report does not constitute financial, legal, regulatory, or investment advice, nor does it endorse the project, its business model, products, or services. Security is an ongoing process, and we strongly recommend conducting a new assessment following any material code changes or at least every 6 months to address newly emerging threats, vulnerabilities, and ecosystem developments.