Primex Finance

QuantstampFiles named in the report

Quantstamp reviewed Primex Finance on 18 Aug 2023: 38 findings, 0 critical; 28 marked fixed, 10 acknowledged; 8 more marked mitigated.

No open critical findings
Open the reportOpen Primex Finance’s security record

Report hosted on certificate.quantstamp.com.

Trustblock does not review code.

Findings59

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

SeverityOpenAcknowledgedFixedMitigated
Critical0000
High0030
Medium04102
Low06156

Marked Informational or Undetermined by the firm. Not counted as findings.

InformationalDifferent Solidity Compiler Used For Proxy and Implementation ContractsAcknowledged

The proxy contracts used in the Transparent Upgradeable Proxy pattern are compiled using solidity 0.8.10, but the implementation contracts are compiled using solidity 0.8.18.

InformationalIncompatibility with Non-Standard TokensAcknowledged

In general, the protocol has some limits on what the token can be supported to interact: 1. The protocol only supports tokens with at most 18 decimals: the protocol aligns the "multiplier" on the decimals to 18 in several places: `BatchManager`, `LimitPriceCOM`, `TakeProfitStopLossCCM`, `BestDexLens`, and `PositionLibrary` contracts. The 18 decimals are also how the `WadRayMath` library handles the WAD precision. 2. The protocol does not support token charging fees on transfers: despite that the `TokenTransfersLibrary.doTransferFromTo()` function returns the balance difference as the output, all places calling the function do not use the output. In other words, all places calling the function assume to get the full amount on transfer. 3. The protocol does not support rebaseable tokens: the contract `TraderBalanceVault` maintains the accounting of token balances in `balances`. Tokens with elastic supply (also known as rebasing tokens) and tokens with dishonest implementation would not be compatible with the logic intended by this contract.

InformationalMissing DNS AddressAcknowledged

The `SpotTradingRewardDistributorStorage` contract declares the `dns` variable, but the `SpotTradingRewardDistributor.initialized()` function does not set its value. The `dns` variable is not used in `SpotTradingRewardDistributor`, but if there is a function that requires the use of `dns`, the variable should be initialized during a contract upgrade.

UndeterminedReferral Program Susceptible to Sybil AttackAcknowledged

Any user can register a referrer by calling the `ReferralProgram.register()` function. This could potentially be dangerous as there is no way to verify that a single account belongs to a single human. Thus, if a reward was associated with referrals, a user would be incentivized to create and refer fake accounts to amass rewards. Since the reward mechanism for the referral program is unclear to us, we consider the severity to be undetermined.

InformationalUpgradabilityAcknowledged

While upgradability is not a vulnerability in itself, token holders should be aware that the token contract can be upgraded at any given time. This audit does not guarantee the behavior of future contracts that the token may be upgraded to. Here is the list of upgradable contracts: ```sh ▶ grep -rl --exclude="I*" --exclude-dir="mocks" "function initialize" contracts contracts/SpotTradingRewardDistributor/SpotTradingRewardDistributor.sol contracts/TraderBalanceVault/TraderBalanceVault.sol contracts/PMXBonusNFT/PMXBonusNFT.sol contracts/ActivityRewardDistributor/ActivityRewardDistributor.sol contracts/PToken/PToken.sol contracts/PriceOracle/PriceOracle.sol contracts/WhiteBlackList/WhiteBlackListReferral/WhiteBlackListReferral.sol contracts/WhiteBlackList/WhiteBlackList/WhiteBlackList.sol contracts/LimitOrderManager/LimitOrderManager.sol contracts/KeeperRewardDistributor/KeeperRewardDistributor.sol contracts/Bucket/Bucket.sol contracts/LiquidityMiningRewardDistributor/LiquidityMiningRewardDistributor.sol contracts/DebtToken/DebtToken.sol contracts/Reserve/Reserve.sol contracts/ReferralProgram/ReferralProgram.sol contracts/PrimexDNS/PrimexDNS.sol contracts/BonusExecutor/FeeExecutor.sol contracts/BonusExecutor/FeeDecreaser.sol contracts/Treasury/Treasury.sol contracts/PositionManager/PositionManager.sol ```

Informational`depositAndLock()` Not Directly Tied to a DepositFixed

The `TraderBalanceVault.depositAndLock()` function allows the `VAULT_ACCESS_ROLE` to add any amount of any asset to any trader's locked balance. However, this function does not actually require that a deposit takes place, contrary to what the function name suggests.

Informational`increaseDeposit()` May Revert if No Swap Is PerformedFixed

When increasing the deposit of a position through `PositionLibrary.increaseDeposit()`, the following check is performed: ``` _require(depositedAmountInBorrowed >= params.amountOutMin, ...) ``` However, this check will also be performed in case `params.asset == borrowedAsset`, meaning that no swap is executed. Therefore, this swap may revert if the user has provided `_amountOutMin` in `increaseDeposit(..)` of `PositionManager.sol` anyway.

InformationalApplication Monitoring Can Be Improved by Emitting More EventsFixed

In order to validate the proper deployment and initialization of the contracts, it is a good practice to emit events. Also, any important state transitions can be logged, which is beneficial for monitoring the contract, and also tracking eventual bugs or hacks. Below we present a non-exhaustive list of events that could be emitted to improve application management: 1. `Bucket.setReserveRate()` 1. `Bucket.setWithdrawalFee()` 1. `Bucket.setInterestRateStrategy()` 1. `PositionManager.setKeeperRewardDistributor()` 1. `PositionManager.setMinPositionSize()` 1. `PositionManager.setOracleTolerableLimitMultiplier()` 1. `Reserve.setTransferRestrictions()` 1. `PrimexDNS.setConditionalManager()` 1. `PrimexDNS.setPMX()` 1. `PrimexDNS.setProtocolRate` 1. `PrimexDNS.setProtocolRateInPMX` 1. `PrimexDNS.setAavePool()` 1. `PrimexDNS.activateBucket()` 1. `PrimexDNS.freezeBucket()` 1. `PrimexDNS.setDexAdapter()` 1. `PrimexDNS.activateDEX()` 1. `PrimexDNS.freezeDEX()` 1. `PriceOracle.updatePriceFeed()` 1. `PriceOracle.updateVolatilityFeed()` 1. `PriceOracle.setGasPriceFeed()` 1. `KeeperRewardDistributor.setDefaultMaxGasPrice()` 1. `KeeperRewardDistributor.setOracleGasPriceTolerance()` 1. `KeeperRewardDistributor.setMaxGasAmount` 1. `KeeperRewardDistributor.setPmxPartInReward()` 1. `KeeperRewardDistributor.setNativePartInReward()` 1. `KeeperRewardDistributor.setPositionSizeCoefficients()` 1. `KeeperRewardDistributor.setAdditionalGas()` 1. `SpotTradingRewardDistributor.decreaseRewardPerPeriod()` 1. `SpotTradingRewardDistributor.setRewardPerPeriod()` 1. `SpotTradingRewardDistributor.topUpAvailablePmxBalance()` 1. `SpotTradingRewardDistributor.withdrawPmx()` 1. `Treasury.setMaxSpendingLimit()` 1. `Treasury.decreaseLimits()` 1. `ReferralProgram.setReferrals()` 1. `DexAdapter.setQuoter()` 1. `DexAdapter.setDexType()` 1. `Redeemer.changeRate()` 1. `Redeemer.adminClaimEarlyTokens()` 1. `Redeemer.adminClaimRegularTokens()` 1. `SwapManager.setSwapRate()` 1. `SwapManager.setSwapRateInPmx()` 1. `PMXBonusNFT.setExecutor()` 1. `PMXBonusNFT.blockNFT()` 1. `PMXBonusNFT.unblockNFT()`

InformationalInfinite Token ApprovalFixed

Several contracts approves token infinitely for another contract. While we do not find any exploit from this, and the risk is mitigated as it is only approved to another contract within the protocol, it increase the risk surface as a vulnerability can cause the token on the approved contracts to be all taken away. We found the pattern in the following places: 1. `ActivityRewardDistributor.initialize()` 2. `Bucket.initialize()` 3. `LiquidityMiningRewardDistributor.initialize()` 4. `SpotTradingRewardDistributor.initialize()`

InformationalUnclear Whether Native Currency Should Be Supported for SwappingFixed

When swapping from the wallet through the `swap()` function, the input token `params.tokenA` can be `NATIVE_CURRENCY`. The current implementation does not accept `NATIVE_CURRENCY` when swapping directly from the wallet through the `TokenTransfersLibrary.doTransferFromTo()` function. However, the implementation accepts `NATIVE_CURRENCY` when using funds from the `traderBalanceVault.lockAsset()`. Nonetheless, the call to `PrimexPricingLibrary.multiSwap()` will eventually fail. However, it might be great to clarify whether native token should be supported or not and add the corresponding validation.

Show 3 more
InformationalUninitialized Implementation ContractFixed

Leaving an implementation contract uninitialized poses a security risk. An uninitialized implementation contract can be exploited by attackers, potentially compromising the associated proxy. To mitigate this risk, it is recommended to invoke the `_disableInitializers()` function in the constructor during deployment (see: [OpenZeppelin doc](https://docs.openzeppelin.com/upgrades-plugins/1.x/writing-upgradeable#initializing_the_implementation_contract)). This action will automatically lock the implementation contract, preventing any unauthorized usage. The following is the list of impacted contracts found with the `grep` command: ```sh ▶ grep -rl --include="*.sol" --exclude="I*.sol" --exclude-dir="mocks" "initializer" . ./SpotTradingRewardDistributor/SpotTradingRewardDistributor.sol ./TraderBalanceVault/TraderBalanceVault.sol ./PMXBonusNFT/PMXBonusNFT.sol ./ActivityRewardDistributor/ActivityRewardDistributor.sol ./PToken/PToken.sol ./PriceOracle/PriceOracle.sol ./WhiteBlackList/WhiteBlackListReferral/WhiteBlackListReferral.sol ./WhiteBlackList/WhiteBlackList/WhiteBlackList.sol ./LimitOrderManager/LimitOrderManager.sol ./KeeperRewardDistributor/KeeperRewardDistributor.sol ./Bucket/Bucket.sol ./LiquidityMiningRewardDistributor/LiquidityMiningRewardDistributor.sol ./DebtToken/DebtToken.sol ./Reserve/Reserve.sol ./ReferralProgram/ReferralProgram.sol ./PrimexDNS/PrimexDNS.sol ./BonusExecutor/FeeDecreaser.sol ./Treasury/Treasury.sol ./PositionManager/PositionManager.sol ```

InformationalUnresolved `TODO`Fixed

The `PrimexPricingLibrary.getLiquidiationPriceByOrder()` function has an unresolved `TODO` stating: "This function is only used in tests. Maybe it can be removed."

InformationalUsing Deprecated FunctionFixed

The function `AccessControl._setupRole()` has been [deprecated](https://docs.openzeppelin.com/contracts/4.x/api/access#AccessControl-_setupRole-bytes32-address-) in favor of `AccessControl._grantRole()`, which performs the same operations.

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 (13)

  • src/contracts/SwapManager.sol
  • src/contracts/InterestRateStrategy.sol
  • src/contracts/PrimexTimelock.sol
  • src/contracts/EPMXToken.sol
  • src/contracts/PMXToken.sol
  • src/contracts/BatchManager.sol
  • src/contracts/PrimexProxyAdmin.sol
  • src/contracts/PrimexUpkeep.sol
  • src/contracts/PrimexRegistry.sol
  • src/contracts/Redeemer.sol
  • src/contracts/PMXPriceFeed.sol
  • src/contracts/Constants.sol
  • src/contracts/DexAdapter.sol

Part of Primex Finance’s security record

Primex Finance
Audits9 audits by 2 firmsLast audit Oct 2024, by Resonance Security.
Critical findingsNo open critical findingsAcross the 9 reports, 4 critical findings were reported. Each is marked fixed by the firm that reported it.
Open Primex Finance’s security record

Security firm

Quantstamp

240 projects reviewed · 338 reports · latest Nov 2026

See Quantstamp’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