Derify Protocol v2

CertiKFiles named in the report

CertiK reviewed Derify protocol (Derify Protocol v2) on 7 Dec 2023: 18 findings, 0 critical; 3 marked fixed, 6 acknowledged, 9 open.

No open critical findings
Open the reportOpen Derify protocol’s security record

Report hosted on skynet.certik.com.

Trustblock does not review code.

Findings18

Statuses are the security firm’s own, from its report.

SeverityOpenAcknowledgedFixed
Critical000
High031
Medium032
Low900
LowAddress Not Initialized but UsedOpen

In the above-mentioned contract, the address is used, however, this address is never set up which will lead to call failure as a result.

LowFunction Calls User-Provided Addresses With No AcOpen

Calling a user provided address is dangerous, especially in a public function with no access control restriction. An attacker could deploy a malicious contract and use the vulnerable function to trigger a call to the malicious contract, potentially stealing user funds or causing other serious damages.

LowLack of access controlOpen

The withdraw function can be call by anyone to drain the WETH of the contract and send to any address. However, the funds were stored in the main contract. If this contract is deployed by itself, this is an issue.

LowLack of Input ValidationOpen

The below functions do not perform any checks to ensure that the amount parameter is greater than zero. If a user calls the functions with an amount of zero, it will add unnecessary data to the storage. - function `stakingDrf()` - function `depositBondToBank()`

LowOut of Scope DependenciesOpen

The `template` is serving as the underlying entity to interact with out-of-scope smart contracts. And the project relies on the correctness of swapping tokens to cover the cost of the gas used by the executor. The scope of the audit treats those out-of-scope contracts, programs as black boxes and assumes their functional correctness. However, in the real world, they can be compromised and may lead to lost or stolen assets. ```solidity address template = IDerifyExchangeModule(exchangeModule).getMarginTokenPriceFeedTemplate(protocol, marginToken); (bool success, bytes memory d) = template.delegatecall( abi.encodeWithSignature( "swapGas(uint256,address,address,address,address)", _adjustMarginTokenAmount(gasFeeAmount), protocol, marginToken, tokenWBNB, _msgSender() ) ```

LowPotential Divide by zeroOpen

--- ```solidity=80 uint256 amountVestedPerDay = amount / vestingDurationInDays; ``` The expression `amount / vestingDurationInDays` may divide by zero. Its divisor has has estimated interval [0, 9125]. --- ```solidity=299 uint256 amountVestedPerDay = grant.amount / uint256(grant.vestingDuration); ``` The expression `grant.amount / uint256(grant.vestingDuration)` may divide by zero. Its divisor has has estimated interval [0, 65535]. --- ```solidity=237 uint256 newAddedPeriodBlocks = amount / brokerValidUnitNumber; ``` The expression `amount / brokerValidUnitNumber` may divide by zero. Its divisor has has estimated interval [0, 115792089237316195423570985008687907853269984665640564039457584007913129639935]. --- ```solidity=17 margin = size * spotPrice / SPOT_PRICE_DECIMAL * CONTRACT_DECIMAL / leverage; ``` The expression `size * spotPrice / SPOT_PRICE_DECIMAL` may divide by zero. Its divisor has has estimated interval [0, 115792089237316195423570985008687907853269984665640564039457584007913129639935].

LowRedundant code componentsOpen

The `index` parameter in the `deleteOrderedLimitPositions()` function is redundant. The salt in the `createDerivative()` function is redundant.

LowUser information is not cleared when the user isOpen

When the user positions reaches the liquidation threshold, the user positions is liquidated and the order information is cleared, but the user information is not, which is not consistent with the logic of line 378. ```solidity=377 // remove trader IDerifyExchange(exchange).removeTrader(liquidateTraders[j]); ```

LowVariables That Could Be Declared as ImmutableOpen

The linked variables assigned in the constructor can be declared as `immutable`. Immutable state variables can be assigned during contract creation but will remain constant throughout the lifetime of a deployed contract. A big advantage of immutable variables is that reading them is significantly cheaper than reading from regular state variables since they will not be stored in storage.

Contracts in scope

No deployed address is recorded for this audit.

The report names a repository or files. Open the report to see its scope.

Repository and files the report names (17)

  • contracts/DerifyPmr.sol
  • contracts/DerifyRewards.sol
  • contracts/DerifyDerivative.sol
  • contracts/DerifyClearing.sol
  • contracts/DerifyRank.sol
  • contracts/DeployDerifyFactory.sol
  • contracts/DeployDerifyDerivative.sol
  • contracts/DerifyDerivativeModule.sol
  • contracts/DeployDerifyClearing.sol
  • contracts/DeployDerifyExchange.sol
  • contracts/DeployDerifyRewards.sol
  • contracts/DerifyExchange.sol
  • contracts/DerifyFactory.sol
  • contracts/DerifyProtocol.sol
  • contracts/DeployBMarginToken.sol
  • contracts/DerifyExchangeModule.sol
  • contracts/DerifyClearingModule.sol

Part of Derify protocol’s security record

Derify protocol
Audits3 audits by 1 firmLast audit Dec 2023, by CertiK.
Critical findingsNo open critical findingsAcross 3 reports.
Open Derify protocol’s security record

Security firm

CertiK

1,044 projects reviewed · 1,375 reports · latest May 2025

See CertiK’s audits

Something wrong on this page? A missing report, a wrong date, a finding that was fixed since. Tell us and we check it against its source.

Tell us