In-depth lesson · Business logic
Typical fixes
Every point the Business logic reports back under this heading, best-backed first, each with the reports it is seen in.
-
Apply ENSIP-15 normalisation once and use the same canonical name for display, reads, pricing and calldata.
Seen in 23 reports
-
Take the balance snapshot before the vault withdrawal and compare it with the post-withdrawal balance.
Seen in 22 reports
-
Decrement the deposited-shares ledger on every path that transfers shares out, including forced repay and liquidation.
Seen in 17 reports
-
Cap the returned fee to the amount actually deducted from the account's collateral.
Seen in 12 reports
-
Do not set the terminal claimed marker on periods that are still open, and clear it when zeroing the slot.
Seen in 12 reports
-
Pin the period-start exposure at commitment time instead of reading a mutable timestamp-keyed checkpoint.
Seen in 12 reports
-
Reserve refundable VPI as a liability and include the VPI rebate reserve in the NAV used to price Junior deposits and redemptions.
Seen in 11 reports
-
Carry refundable charges as a liability in NAV until the position closes.
Seen in 10 reports
-
Decrement the global deposited-shares and earmarked counters in the forced-repayment and liquidation paths exactly as the normal repay and burn paths do.
Seen in 10 reports
-
Cap the pending recapitalisation against genuinely new unassigned backing and persist the original intent across reconciles.
Seen in 9 reports
-
Let the owner amend a protection regardless of whether a permissionless retry has moved it to Triggered, or restrict retry to the owner.
Seen in 9 reports
-
Clear the per-period claimed flag on unblock, or use a separate flag for relocated withdrawals, and have the withdrawal request reject a period already marked claimed.
Seen in 8 reports
-
Measure the actual balance change after a transfer instead of assuming the transferred amount is received.
Seen in 8 reports
-
Pay the liquidator fee based on the amount actually deducted from the borrower, not on the post-seizure remaining balance.
Seen in 8 reports
-
Require the named controller to consent before a redemption request is enqueued into their private queue, and do not let a request from another owner become the controller's head.
Seen in 8 reports
-
Restrict the retry to the position owner or require consent, and let the owner amend limits regardless of pending retry orders.
Seen in 8 reports
-
Send rewards to a recipient that can actually manage them, or add a recovery function to the vault and strategy.
Seen in 8 reports
-
Track tokens locked in vesting separately and exclude them from the distributable reward surplus calculation.
Seen in 8 reports
-
Carry a signed liability term for refundable positive VPI in the NAV used for LP entry and exit.
Seen in 7 reports
-
Check the incoming code against all applied promotions and cap the cumulative discount at the subtotal.
Seen in 7 reports
-
Compare each stored feed against its own accepted timestamp, or against the oldest component time, when reusing a cached basket.
Seen in 7 reports
-
Pass the original user as the refund receiver through the zapper call chain and add a recovery path for any leftovers.
Seen in 7 reports
-
Store the period-open snapshot at a dedicated key that ordinary flows cannot overwrite, or use an exclusive lookup that excludes the boundary second.
Seen in 7 reports
-
Authorise the retry entry point through the owner-checked protection lookup rather than the unchecked one, so only the owner can consume the Latched state.
Seen in 6 reports
-
Decrement the deposited-shares counter on every path where tokens leave the contract.
Seen in 6 reports
-
Implement the reward-claiming hook in each strategy and add a sweep or swap path for external reward tokens.
Seen in 6 reports
-
Preserve the larger surviving high-water mark and release the pending residual when its cash is paid out.
Seen in 6 reports
-
Reserve or vest positive VPI until the paying position closes, and book the contingent rebate as a liability in LP share pricing.
Seen in 6 reports
-
Restrict retry to the owner or add a retry limit or cooldown, and require amended close limits before re-enqueueing.
Seen in 6 reports
-
Restrict the retry function or give the owner a guaranteed window to amend limits.
Seen in 6 reports
-
Store the recapitalization target separately and keep the larger of the stored and new high-water marks.
Seen in 6 reports
-
Subtract the refundable VPI amount from LP net asset value until the position closes, so exits are not priced on money the pool may have to pay back.
Seen in 6 reports
-
Treat the ownerless reserve as a fixed reservation clamped only by mark-independent cash, and record any written-down amount for reversal.
Seen in 6 reports
-
Validate on the server that quantity is a positive whole number before using it in price calculations, and recalculate totals from stored prices before payment.
Seen in 6 reports
-
Apply the frozen-close spread to liquidations during the freeze, or prevent self-triggered liquidation from being a cheaper exit than a voluntary close.
Seen in 5 reports
-
Check stored feed coverage against the oldest component publish time.
Seen in 5 reports
-
Credit the treasury the assessed execution fee on rebate closes instead of netting it into the rebate.
Seen in 5 reports
-
Hold a liability reserve for the potential close-side rebate and exclude it from redemption NAV.
Seen in 5 reports
-
Include the signed lifetime impact term and secured rebate reserves in the LP net asset value snapshot.
Seen in 5 reports
-
Preserve the original recapitalisation target and high-water mark across partial settlements instead of using the residual bucket as the bootstrap target.
Seen in 5 reports
-
Re-evaluate solvency automatically when positions close or unwind, or net offsetting hedged exposure, instead of relying on an owner-only clear.
Seen in 5 reports
-
Reserve refundable price impact as a liability in LP NAV and withdrawal calculations.
Seen in 5 reports
-
Authorise the named controller on request creation and apply the minimum size check even to full-balance requests.
Seen in 4 reports
-
Bind the migration plan to a canonical snapshot and re-check freshness before wallet submission.
Seen in 4 reports
-
Clear the locker address, loan status and dirty flag whenever a position is liquidated, redeemed or moved.
Seen in 4 reports
-
Compute the maximum views from the remaining asset capacity and apply the same rounding and zero-share checks the deposit and mint paths use.
Seen in 4 reports
-
Freeze the margin used for post-trade bounds at commitment time rather than reading live margin at execution.
Seen in 4 reports
-
Give the owner a priority window or cooldown before permissionless retries can consume the latched state.
Seen in 4 reports
-
Include the guaranteed rebate reserve in the NAV used to price deposits.
Seen in 4 reports
-
Keep the larger of the existing Senior high-water mark and the recapitalisation target, and exclude seed-owned principal from covenant exposure.
Seen in 4 reports