{
  "schemaVersion": 1,
  "slug": "crypto-profit-calculator",
  "category": "crypto",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "2a336f8f9f8101da24630aa4535b311d65ea9f56af4bade13add14ea63539818",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/crypto-profit-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "Pr = P_s × q × (1 − s ÷ 100) − w − P_b × q × (1 + b ÷ 100)",
    "vars": [
      [
        "P_b",
        "Buy price"
      ],
      [
        "P_s",
        "Sell price"
      ],
      [
        "q",
        "Quantity"
      ],
      [
        "b",
        "Buy fee (%)"
      ],
      [
        "s",
        "Sell fee (%)"
      ],
      [
        "w",
        "Withdrawal fee"
      ]
    ],
    "note": "Invested = P_b × q × (1 + b ÷ 100); ROI = Pr ÷ invested × 100; break-even sell price = (invested + w) ÷ (q × (1 − s ÷ 100))."
  },
  "externalEvidence": {
    "reviewedAt": "2026-10-12",
    "sources": [
      {
        "name": "Investor.gov — Investment fees and expenses",
        "url": "https://www.investor.gov/introduction-investing/general-resources/news-alerts/alerts-bulletins/investor-bulletins/updated"
      }
    ],
    "referenceRole": "context",
    "implementationHash": "2a336f8f9f8101da24630aa4535b311d65ea9f56af4bade13add14ea63539818",
    "basis": "Pr = P_s × q × (1 − s ÷ 100) − w − P_b × q × (1 + b ÷ 100)",
    "limitations": "The references provide context and limitations. They do not validate this page’s illustrative multipliers, lookup values or predictions."
  },
  "contract": {
    "compute": "const empty={invested:null,proceeds:null,feesPaid:null,profit:null,roiPercent:null,breakEvenPrice:null,profitPerCoin:null};const v=[buyPrice,sellPrice,quantity,buyFeePct,sellFeePct,withdrawalFee].map(Number);if(v.some(n=>!Number.isFinite(n))||buyPrice<=0||sellPrice<0||quantity<=0||buyFeePct<0||buyFeePct>20||sellFeePct<0||sellFeePct>20||withdrawalFee<0)return{...empty,__error:'inputError'};const gross=buyPrice*quantity,buyFee=gross*buyFeePct/100,invested=gross+buyFee,grossSell=sellPrice*quantity,sellFee=grossSell*sellFeePct/100,proceeds=grossSell-sellFee-withdrawalFee,profit=proceeds-invested,perCoinNet=sellPrice*(1-sellFeePct/100),breakEven=(invested+withdrawalFee)/(quantity*(1-sellFeePct/100)),feesPaid=buyFee+sellFee+withdrawalFee,roiPercent=profit/invested*100,profitPerCoin=profit/quantity;if(![gross,buyFee,invested,grossSell,sellFee,proceeds,profit,perCoinNet,breakEven,feesPaid,roiPercent,profitPerCoin].every(Number.isFinite))return{...empty,__error:'inputError'};return{invested,proceeds,feesPaid,profit,roiPercent,breakEvenPrice:breakEven,profitPerCoin};",
    "inputs": [
      {
        "name": "buyPrice",
        "type": "number",
        "default": 30000,
        "min": 0,
        "max": 100000000,
        "step": 0.01
      },
      {
        "name": "sellPrice",
        "type": "number",
        "default": 36000,
        "min": 1e-8,
        "max": 100000000,
        "step": 0.01
      },
      {
        "name": "quantity",
        "type": "number",
        "default": 0.5,
        "min": 0,
        "max": 1000000000,
        "step": 1e-8
      },
      {
        "name": "buyFeePct",
        "type": "number",
        "default": 0.1,
        "min": 0,
        "max": 20,
        "step": 0.01,
        "slider": true
      },
      {
        "name": "sellFeePct",
        "type": "number",
        "default": 0.1,
        "min": 0,
        "max": 20,
        "step": 0.01,
        "slider": true
      },
      {
        "name": "withdrawalFee",
        "type": "number",
        "default": 5,
        "min": 0,
        "max": 100000,
        "step": 0.01
      }
    ],
    "outputs": [
      {
        "name": "profit",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "roiPercent",
        "precision": 3,
        "unit": "%"
      },
      {
        "name": "invested",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "proceeds",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "feesPaid",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "breakEvenPrice",
        "precision": 4,
        "unit": "$"
      },
      {
        "name": "profitPerCoin",
        "precision": 4,
        "unit": "$"
      }
    ],
    "interpret": null
  }
}
