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 closable amount is not initialised to the previous position magnitude before the pending position loop.
-
The close assessment enforces bounds once before commitment carry is folded in, so the first revert reports pre-carry values and a later constraint.
-
The close delay can be reset by adding to the position, and stop-loss updates have no delay check.
Seen in 1 report
-
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
-
The close function did not check that the supplied credit ID existed before decrementing the count.
Seen in 1 report
-
The close logic refunded margin based on original size and leverage without checking whether it had already been withdrawn.
Seen in 1 report
-
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.
-
The close path nets the rebate against the execution fee and caps the treasury fee at that net figure.
-
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.
-
The close path treated the count of lazily created per-borrower trackers as proof no rewards were owed.
-
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.
-
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.
-
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
-
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.
-
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.
-
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.
-
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
-
The close-loan routine ignores the collateral recipient parameter and always pays the lender.
Seen in 1 report
-
The close-trade function does not send all remaining collateral when the short amount reaches zero.
Seen in 1 report
-
The closeLoan function applies the minimum opening margin check even when only repaying debt.
-
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.
-
The club contract calls _mint instead of _safeMint, omitting the receiver capability check.
Seen in 1 report
-
The club contract was not designed to implement the EIP2981 royalty standard, unlike the player contract.
Seen in 1 report
-
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.
-
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
-
The code applies the bond market rate cap to leveraged token redemptions even though the market rate is only relevant for bonds.
-
The code approves a non-zero amount without first setting the allowance to zero.
Seen in 1 report
-
The code assigned to a memory variable instead of the storage mapping entry, so the cancellation was lost.
Seen in 1 report
-
The code assumed all external money market calls would revert on error and did not check the returned success value.
Seen in 1 report
-
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
-
The code assumed the Aave pool contract holds the underlying liquidity, but in real deployments the aToken contract holds it.
-
The code assumed the same Convex Booster function signature on all chains.
Seen in 1 report
-
The code assumed the vault currency and provider underlying token always had the same price.
-
The code assumed Uniswap v3 pool token balance proportion corresponds to price.
-
The code assumes a constant block time and includes an unnecessary modifier on an empty constructor.
Seen in 1 report
-
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
-
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
-
The code assumes share value is always at least the recorded allocation, so a loss causes an underflow.
-
The code assumes the full transferred amount arrives without measuring the actual balance received, so a fee-on-transfer token leaves the pod short.
-
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
-
The code assumes the last holder is always eligible and lacks an else branch for the undistributed remainder.
Seen in 1 report
-
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
-
The code assumes the swap path always has exactly two tokens.
Seen in 1 report
-
Medium
-
-
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
-
The code assumes token decimals are at most eighteen and performs an unsigned subtraction that underflows for larger values.
Seen in 1 report
-
The code both took the actual input and refunded the difference from the original amount, duplicating the refund.
Seen in 1 report
-
The code breaks out of the log loop after the first matching event.
-
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
-
The code called raw approve instead of a safe helper that zeroes the allowance and checks the return value.
Seen in 1 report
-
The code called the YieldBox deposit without first approving YieldBox to spend the singularity token.