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.
-
The code calls safe approve to change a non-zero allowance to another non-zero value, which the library disallows.
Seen in 1 report
-
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
-
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
-
The code calls the token transfer unconditionally without checking whether the computed amount is zero.
Seen in 1 report
-
The code caps the intermediate token amount but does not handle the leftover balance, which remains stuck.
Seen in 1 report
-
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
-
The code checked who a user is but not what they are allowed to do, and ORMs returned every column by default.
-
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
-
The code checks msg.value is at least the price instead of requiring exact payment or refunding the difference.
Seen in 1 report
-
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
-
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
-
The code checks the sell slippage parameter but does not use it to constrain the swap.
Seen in 1 report
-
The code checks the wrong variable (assets instead of entitled shares) and subtracts the fee from the wrong value.
Seen in 1 report
-
The code checks whether the username is a valid address before checking whether it is a registered username.
Seen in 1 report
-
The code compared raw stored principal without accrued interest against the new borrow amount.
Seen in 1 report
-
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.
-
The code compares principal token and underlying amounts directly without scaling for decimal differences.
-
The code compares share balances against asset-denominated tier thresholds instead of converting shares to assets.
-
The code compares share counts directly with reward amounts instead of converting shares to value.
Seen in 1 report
-
The code compares the full action value instead of the extracted action code when checking for the pull-token command.
Seen in 1 report
-
The code credited the full output as a deposit after already using it to repay debt.
Seen in 1 report
-
The code did not check the boolean return value from the external booster deposit call.
-
The code did not separate the phase identifier from the aggregator round counter before doing arithmetic on the round identifier.
-
The code divided by a fixed 1e18 instead of the vault's actual decimal precision.
Seen in 1 report
-
The code divided by N instead of N-1, giving a biased estimator.
Seen in 1 report
-
The code divided by the token's decimal precision instead of the oracle's precision when chaining feeds.
Seen in 1 report
-
The code divided by the underlying token's decimals instead of 1e18, leaving results in LP token decimals.
Seen in 1 report
-
The code divided by the wrong power of ten instead of 1e18 when converting the Compound exchange rate.
Seen in 1 report
-
The code divides by the tax cut value instead of multiplying by a percentage.
-
The code does not check that the delegate is a transcoder before subtracting the delegate's weight from the tally.
-
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
-
The code does not distinguish between a transaction-not-found error and other RPC errors when deciding whether to resend.
Seen in 1 report
-
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.
-
The code enforced proportional deposits via _checkPrimarySecondaryRatio, which is suboptimal for imbalanced Curve pools that reward balancing deposits.
Seen in 1 report
-
The code fetches safe data using the destination handler rather than the source address.
Seen in 1 report
-
The code hardcoded 18 decimals and subtracted the token's decimals without checking for more than 18.
Seen in 1 report
-
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
-
The code ignored the actual amount returned by the lending pool's withdraw function.
Seen in 1 report
-
The code intentionally relies on integer overflow, which newer compiler versions make revert.
Seen in 1 report
-
The code logs the requested transfer amount instead of measuring the vault's balance change.
Seen in 1 report
-
The code manually increments the owned count after a mint that already increments it, causing double counting.
Seen in 1 report
-
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.
-
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
-
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
-
The code mistakenly uses block.timestamp instead of the deadline value from the input struct when calling the swap function.
Seen in 1 report
-
Medium
-
-
The code negated an unsigned integer before converting it to a signed integer, making the resulting value always non-positive.
Seen in 1 report
-
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
-
The code passed a YieldBox share amount to a function expecting a fraction of total assets without converting between the two.
-
The code passed the caller address to the reward-sending function instead of the recipient field from the liquidation parameters.
Seen in 1 report
-
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