Skip to content

In-depth lesson · Business logic

Root causes

Every point the Business logic reports back under this heading, best-backed first, each with the reports it is seen in.

Back to the lesson 2,301 to 2,350 of 5,700
  1. The code calls safe approve to change a non-zero allowance to another non-zero value, which the library disallows.

    Seen in 1 report
  2. The code calls the owner lookup with the loop index rather than the value at that index, so the wrong owner is checked and totals are misrecorded.

    Seen in 1 report
  3. The code calls the public share conversion function using the external vault rate instead of the internal function using the pool's one-to-one rate.

    Seen in 1 report
  4. The code calls the token transfer unconditionally without checking whether the computed amount is zero.

    Seen in 1 report
  5. The code caps the intermediate token amount but does not handle the leftover balance, which remains stuck.

    Seen in 1 report
  6. The code checked whether the receiver is the market token to decide whether to transfer, instead of checking whether the current iteration is the last in the swap path.

    Seen in 1 report
  7. The code checked who a user is but not what they are allowed to do, and ORMs returned every column by default.

    Seen in 1 report
  8. The code checks for a previous batch's validator tree unconditionally, so the first batch has no previous tree and validators skip signing.

    Seen in 1 report
  9. The code checks msg.value is at least the price instead of requiring exact payment or refunding the difference.

    Seen in 1 report
  10. The code checks only whether the file descriptor is a regular file and truncates it, without checking the flag that marks the stream as a curl-owned ETag output file.

    Seen in 1 report
  11. The code checks queuedShares[address(this)] instead of queuedShares[address(token)], so the condition is always true and queued shares are never added to the balance.

    Seen in 1 report
  12. The code checks the sell slippage parameter but does not use it to constrain the swap.

    Seen in 1 report
  13. The code checks the wrong variable (assets instead of entitled shares) and subtracts the fee from the wrong value.

    Seen in 1 report
  14. The code checks whether the username is a valid address before checking whether it is a registered username.

    Seen in 1 report
  15. The code compared raw stored principal without accrued interest against the new borrow amount.

    Seen in 1 report
  16. The code compared the market's long/short token to WNT instead of the user-supplied initialLongToken/initialShortToken, so the execution fee was deducted from the wrong token amount.

    Seen in 1 report
  17. The code compares principal token and underlying amounts directly without scaling for decimal differences.

    Seen in 1 report
  18. The code compares share balances against asset-denominated tier thresholds instead of converting shares to assets.

    Seen in 1 report
  19. The code compares share counts directly with reward amounts instead of converting shares to value.

    Seen in 1 report
  20. The code compares the full action value instead of the extracted action code when checking for the pull-token command.

    Seen in 1 report
  21. The code credited the full output as a deposit after already using it to repay debt.

    Seen in 1 report
  22. The code did not check the boolean return value from the external booster deposit call.

    Seen in 1 report
  23. The code did not separate the phase identifier from the aggregator round counter before doing arithmetic on the round identifier.

    Seen in 1 report
  24. The code divided by a fixed 1e18 instead of the vault's actual decimal precision.

    Seen in 1 report
  25. The code divided by N instead of N-1, giving a biased estimator.

    Seen in 1 report
  26. The code divided by the token's decimal precision instead of the oracle's precision when chaining feeds.

    Seen in 1 report
  27. The code divided by the underlying token's decimals instead of 1e18, leaving results in LP token decimals.

    Seen in 1 report
  28. The code divided by the wrong power of ten instead of 1e18 when converting the Compound exchange rate.

    Seen in 1 report
  29. The code divides by the tax cut value instead of multiplying by a percentage.

    Seen in 1 report
  30. The code does not check that the delegate is a transcoder before subtracting the delegate's weight from the tally.

    Seen in 1 report
  31. The code does not check whether the remaining amount after filling the withdrawal buffer is greater than zero before calling the operator delegator's deposit function, which reverts on zero input.

    Seen in 1 report
  32. The code does not distinguish between a transaction-not-found error and other RPC errors when deciding whether to resend.

    Seen in 1 report
  33. The code does not properly handle the case where a buy offer crosses existing sell offers but cannot be fully filled because the buyer's trustline limit is reached, leaving a partially filled crossing offer in the orderbook.

    Seen in 1 report
  34. The code enforced proportional deposits via _checkPrimarySecondaryRatio, which is suboptimal for imbalanced Curve pools that reward balancing deposits.

    Seen in 1 report
  35. The code fetches safe data using the destination handler rather than the source address.

    Seen in 1 report
  36. The code hardcoded 18 decimals and subtracted the token's decimals without checking for more than 18.

    Seen in 1 report
  37. The code hardcodes a specific pool fee and a fixed mainnet router address and returns a zero fee on other chains instead of using the provided fee parameter.

    Seen in 1 report
  38. The code ignored the actual amount returned by the lending pool's withdraw function.

    Seen in 1 report
  39. The code intentionally relies on integer overflow, which newer compiler versions make revert.

    Seen in 1 report
  40. The code logs the requested transfer amount instead of measuring the vault's balance change.

    Seen in 1 report
  41. The code manually increments the owned count after a mint that already increments it, causing double counting.

    Seen in 1 report
  42. The code mapped Curve's native ETH sentinel to the zero address but compared token addresses against the vault's WETH asset, so native ETH was never recognised as the primary asset.

    Seen in 1 report
  43. The code measured the starting gas before an external call, but EIP-150 requires that only 63/64 of the remaining gas is forwarded, so the gas used was overstated.

    Seen in 1 report
  44. The code minted an amount that included the protocol fee but only swapped the gas fee portion, leaving the fee in the module with no withdrawal function.

    Seen in 1 report
  45. The code mistakenly uses block.timestamp instead of the deadline value from the input struct when calling the swap function.

    Seen in 1 report
  46. The code negated an unsigned integer before converting it to a signed integer, making the resulting value always non-positive.

    Seen in 1 report
  47. The code only checked that a log came from the built-in address and assumed a non-zero call value meant ETH was sent, but delegatecall inherits the value without transferring funds.

    Seen in 1 report
  48. The code passed a YieldBox share amount to a function expecting a fraction of total assets without converting between the two.

    Seen in 1 report
  49. The code passed the caller address to the reward-sending function instead of the recipient field from the liquidation parameters.

    Seen in 1 report
  50. The code passed the caller as the owner argument to the ERC721 transfer, but the token contract requires the actual owner.

    Seen in 1 report