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,251 to 2,300 of 5,700
  1. The closable amount is not initialised to the previous position magnitude before the pending position loop.

    Seen in 1 report
  2. The close assessment enforces bounds once before commitment carry is folded in, so the first revert reports pre-carry values and a later constraint.

    Seen in 1 report
  3. The close delay can be reset by adding to the position, and stop-loss updates have no delay check.

    Seen in 1 report
  4. The close fee is applied only to the pod token amount returned, while borrowed tokens are transferred without any fee deduction.

    Seen in 1 report
  5. The close function did not check that the supplied credit ID existed before decrementing the count.

    Seen in 1 report
  6. The close logic refunded margin based on original size and leverage without checking whether it had already been withdrawn.

    Seen in 1 report
  7. The close path caps the recorded execution fee to the withheld action charge, which is zero when the close nets to a rebate, so the treasury top-up is also zero.

    Seen in 1 report
  8. The close path nets the rebate against the execution fee and caps the treasury fee at that net figure.

    Seen in 1 report
  9. The close path only skips the fresh charge when net depth is exactly zero, so a tiny positive depth makes the skew-squared-over-depth division produce a charge far larger than the position.

    Seen in 1 report
  10. The close path treated the count of lazily created per-borrower trackers as proof no rewards were owed.

    Seen in 1 report
  11. The close planner adds the signed VPI rebate into the same net charge as the execution fee and caps the protocol fee to what was actually withheld.

    Seen in 1 report
  12. The close planner conflates 'trader could not pay the fee' with 'trader paid via a reduced rebate', capping the treasury credit to zero whenever the net is a rebate.

    Seen in 1 report
  13. The close planner nets the fee into the signed rebate amount and then caps it to what was withheld, so a fee absorbed by the rebate becomes zero.

    Seen in 1 report
  14. The close planner reads pool depth after adding the closer's own realised carry, so the zero-depth exemption guard never triggers and the VPI curve divides by a near-zero depth.

    Seen in 1 report
  15. The close preview copies the capped and netted execution fee value instead of the assessed fee, so the documented meaning does not match the implementation.

    Seen in 1 report
  16. The close settlement calculates the execution fee from the action charge after the rebate has already reduced it, instead of assessing the full fee before netting the rebate.

    Seen in 1 report
  17. The close settlement clamps the execution fee to the non-rebated charge before computing the pool-cash top-up, so the top-up cannot restore the rebated portion.

    Seen in 1 report
  18. The close-loan routine ignores the collateral recipient parameter and always pays the lender.

    Seen in 1 report
  19. The close-trade function does not send all remaining collateral when the short amount reaches zero.

    Seen in 1 report
  20. The closeLoan function applies the minimum opening margin check even when only repaying debt.

    Seen in 1 report
  21. The closeTickets function limited the number of tickets closed per call to maxRedeemedTickets, so a fragmented queue of many small tickets forced multiple calls to transfer a large amount.

    Seen in 1 report
  22. The club contract calls _mint instead of _safeMint, omitting the receiver capability check.

    Seen in 1 report
  23. The club contract was not designed to implement the EIP2981 royalty standard, unlike the player contract.

    Seen in 1 report
  24. The code added the position's profit and loss (PnL) to the remaining collateral when checking if collateral was sufficient, instead of using only the actual collateral amount.

    Seen in 1 report
  25. The code applied the fee receiver factor to the total borrowing fees and added that amount to the pool value, instead of adding the pool's share (total fees minus the fee receiver's share).

    Seen in 1 report
  26. The code applies the bond market rate cap to leveraged token redemptions even though the market rate is only relevant for bonds.

    Seen in 1 report
  27. The code approves a non-zero amount without first setting the allowance to zero.

    Seen in 1 report
  28. The code assigned to a memory variable instead of the storage mapping entry, so the cancellation was lost.

    Seen in 1 report
  29. The code assumed all external money market calls would revert on error and did not check the returned success value.

    Seen in 1 report
  30. The code assumed errors came in the second return value, but the SDK returned them in the first, so retries never triggered.

    Seen in 1 report
  31. The code assumed the Aave pool contract holds the underlying liquidity, but in real deployments the aToken contract holds it.

    Seen in 1 report
  32. The code assumed the same Convex Booster function signature on all chains.

    Seen in 1 report
  33. The code assumed the vault currency and provider underlying token always had the same price.

    Seen in 1 report
  34. The code assumed Uniswap v3 pool token balance proportion corresponds to price.

    Seen in 1 report
  35. The code assumes a constant block time and includes an unnecessary modifier on an empty constructor.

    Seen in 1 report
  36. The code assumes every settlement token uses 18 decimals and passes the initial ask to Seaport without scaling to the asset's decimals.

    Seen in 1 report
  37. The code assumes reserves from getReserves are in the same order as the input token addresses, but they are sorted by token address.

    Seen in 1 report
  38. The code assumes share value is always at least the recorded allocation, so a loss causes an underflow.

    Seen in 1 report
  39. The code assumes the full transferred amount arrives without measuring the actual balance received, so a fee-on-transfer token leaves the pod short.

    Seen in 1 report
  40. The code assumes the index in the money markets array also applies to the withdraw sequence array, but the two arrays have independent orderings.

    Seen in 1 report
  41. The code assumes the last holder is always eligible and lacks an else branch for the undistributed remainder.

    Seen in 1 report
  42. The code assumes the settlement rate's supply factor is zero after maturity but before settlement and does not handle that state safely.

    Seen in 1 report
  43. The code assumes the swap path always has exactly two tokens.

    Seen in 1 report
  44. The code assumes the value returned by Etherfi's deposit function is the eETH amount, but it actually returns the number of shares, which differs due to the conversion rate.

    Seen in 1 report
  45. The code assumes token decimals are at most eighteen and performs an unsigned subtraction that underflows for larger values.

    Seen in 1 report
  46. The code both took the actual input and refunded the difference from the original amount, duplicating the refund.

    Seen in 1 report
  47. The code burns only the amount received after transfer fees even though the initial conversion already accounted for fees, applying fees twice.

    Seen in 1 report
  48. The code called raw approve instead of a safe helper that zeroes the allowance and checks the return value.

    Seen in 1 report
  49. The code called the YieldBox deposit without first approving YieldBox to spend the singularity token.

    Seen in 1 report