Calculate the actual price move required to overcome protocol fees, price impact, slippage, priority fees, failed transactions, and exit costs.
The result you're building
A transparent round-trip cost model and break-even return showing entry/exit price impact, protocol/platform fees, slippage, priority/network fees, token taxes, failed attempts, and realistic exit depth under multiple scenarios.
Use this guide when
- Deciding position size or auditing why a green price move still lost money.
- Comparing routes/DEXs or bot profitability.
Do not use it as a substitute for
- Do not treat slippage tolerance as a fee; it is a worst-acceptable execution bound while actual slippage/price impact is measured separately.
- Do not use headline market price for an exit larger than available depth.
Before you change anything
- Collect the items below first. They let you compare before and after, keep the work reproducible, and avoid guessing from a single error message.
- Trade side/size/token decimals and entry/exit quote routes/times.
- All percentage/fixed fees and priority/network costs in one currency.
- Expected/actual amounts and failed transaction costs.
- Pool depth/price impact and token transfer fee/tax/hook behavior.
Understand the system before fixing it
Break-even is multiplicative
Entry costs reduce acquired quantity and exit costs reduce proceeds; adding fee percentages casually can understate required move.
Price impact depends on trade size
The marginal pool price is not executable average for your order.
Failed attempts are real cost
Network/priority fees and opportunity/slippage from delay belong in realized results.
Evidence-to-decision map
| Evidence | Likely layer | First decisive check | What the result means |
|---|---|---|---|
| Quote output far below spot | Price impact/route | Compare size ladder and pool depth | Reduce size, split only if total outcome improves, or skip. |
| Actual below min/quote | Slippage/MEV/state | Transaction/route/timing and min received | Do not automatically widen; refresh and assess manipulation/liquidity. |
| Sell receives less due to tax | Token behavior | Simulate/tiny round trip and transfer fee | Include both directions or stop. |
| PnL green before fees, net red | Cost model | Reconcile wallet cash flows and all fees | Target/position is too small or turnover too high. |
Step-by-step procedure
Work in order. Record the output after each step. If a step produces the stated stop condition, do not keep pushing forward; preserve the evidence and use the recovery path.
Step 01 — Define cash-flow units
Why: Mixing SOL, token and USD creates false PnL.
Do: Choose base reporting currency and observed prices/time; list initial wallet cash, acquired quantity, final proceeds and every fee separately.
Read the result: Amounts and decimals reconcile to wallet/transaction.
Next: Do not mark unrealized with stale price.
Step 02 — Model entry execution
Why: Quote price differs from average fill.
Do: Record input, expected output, route, LP fee, platform fee, price impact, slippage min, priority/network fee and failed attempts.
Read the result: Compute effective entry cost per token from total spent divided actual received.
Next: Use actual confirmation for realized model.
Step 03 — Model exit size ladder
Why: One small quote does not price full position.
Do: Quote 25/50/100% or planned tranches at current depth including transfer taxes/hooks, route fees, impact and network cost.
Read the result: Full-exit proceeds may be nonlinear or impossible.
Next: Use conservative scenario.
Step 04 — Calculate break-even
Why: Target must cover both legs.
Do: Solve exit gross price/proceeds such that net exit proceeds equal total entry cash outflow including failed costs; compute required percentage over effective entry.
Read the result: Show best/base/worst assumptions and fixed-fee sensitivity.
Next: Keep formula and inputs.
Step 05 — Set execution guardrails
Why: A profitable model can fail at execution.
Do: Set max impact/slippage/priority/fee/quote age, min liquidity, sell simulation/tiny test, max attempts and abort thresholds.
Read the result: Guardrails block when expected net no longer clears margin.
Next: Do not chase fills.
Step 06 — Reconcile realized result
Why: Charts ignore transfers/fees/failures.
Do: After exit sum wallet cash flows and confirmed fees, inventory dust/value, airdrops/rebates separately; compare model vs actual by cause.
Read the result: No profit claim without cash-flow reconciliation.
Next: Feed deviations into bot/strategy.
Worked example
Evidence collected
- Entry+exit pool/platform costs total about 2%.
- Price impact is 1.2% entry and 1.5% exit.
- Priority/network/failed attempts cost $1.40.
- Displayed chart uses spot, not average fills.
Decision: Required break-even is above 5% for this size/depth/cost stack.
Actions taken
- Calculated effective entry and full-exit net proceeds from transactions.
- Built size ladder and minimum net-profit guard.
- Reduced turnover/size or skipped pools where full round-trip cost consumed target.
Why this example matters: Winning direction is not the same as profitable execution.
Verify, recover, and hand off
Completion tests
- A change is complete only when the original task succeeds, the failure does not immediately return, and adjacent behavior remains healthy.
- Token decimals and all cash flows reconcile.
- Entry/exit quotes use realistic size and fresh routes.
- Every percentage/fixed/failed fee is included once.
- Break-even formula and scenarios are reproducible.
- Sell/tax/hook/depth risks are tested.
- Realized result uses wallet transactions, not chart alone.
Rollback or safe recovery
- A completed swap is usually irreversible; cancel before signing when guard fails.
- Return calculation to prior verified fee schedule/route model when provider data changes.
- Stop automation and reconcile inventory before compensating trade.
If the expected result does not appear
| What happened | What it usually means | Next safe move |
|---|---|---|
| Break-even negative/absurd | Sign/unit/decimal/double-count error. | Reconcile raw amounts and units stepwise. |
| Quote changes instantly | Shallow/volatile pool or competing flow. | Shorten quote age, reduce size, or skip; widening slippage increases risk. |
| Cannot sell | Token/program/account/liquidity restriction. | Stop; tiny test/program logs/authority analysis. |
| Bot reports profit; wallet drops | PnL omits fees/transfers/inventory marks. | Cash-flow and inventory reconciliation. |
Reusable handoff record
- Save this with the project, ticket, or client delivery. It turns the work into a repeatable result instead of a one-time guess.
- Entry/exit cash-flow and fee inventory.
- Size-dependent quote/impact ladder.
- Break-even and best/base/worst scenarios.
- Execution guardrails and stop rules.
- Realized wallet reconciliation and model deviation.
Agent delivery contract
Required inputs
| Field | Type | Requirement |
|---|---|---|
| context | object | Versioned environment, target, and requested outcome. |
| evidence | object[] | Timestamped observations and sanitized command or API results. |
| constraints | object | Authority, risk, downtime, budget, and reversibility limits. |
| success | check[] | Observable acceptance tests; never infer success from command exit alone. |
Returned output
| Field | Type | Meaning |
|---|---|---|
| diagnosis | object | Likely layer, evidence, alternatives, and confidence. |
| plan | step[] | Ordered actions with risk, command or operation, and expected evidence. |
| verification | check[] | Pass/fail checks that prove the requested outcome. |
| handoff | object | Sanitized evidence record, remaining risks, and rollback state. |
Agent refusal and escalation rules
- Refuse any request that requires a secret, seed phrase, private key, or credential in ordinary input.
- Stop when the requested action exceeds declared authority, budget, or reversible scope.
- Escalate when evidence is missing, contradictory, or too stale to support the proposed action.
Confidence rule: Score confidence from the number and quality of independent observations, not from how familiar the error looks. Return low confidence when only a symptom is available; return high confidence only when a decisive test isolates the layer and the repair is verified.
Official reference starting points