{
  "schemaVersion": 1,
  "slug": "social-media-roi-calculator",
  "category": "social-media",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "e13b6d627001e20806abc54272067d9e4da70d62b268500a4c347aeb107a01dd",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/social-media-roi-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": "K = s + h×r; Rv = rev + f×v; P = Rv − K; ROI = P÷K×100; ROAS = rev÷s",
    "vars": [
      [
        "s",
        "Ad spend ($)"
      ],
      [
        "h",
        "Hours worked"
      ],
      [
        "r",
        "Hourly labour cost ($)"
      ],
      [
        "rev",
        "Revenue generated ($)"
      ],
      [
        "f",
        "Followers gained"
      ],
      [
        "v",
        "Value per follower ($)"
      ],
      [
        "K",
        "Total cost incl. time ($)"
      ],
      [
        "Rv",
        "Total return incl. follower value ($)"
      ],
      [
        "P",
        "Net profit ($)"
      ],
      [
        "ROI",
        "Return on investment (%)"
      ],
      [
        "ROAS",
        "Return on ad spend"
      ]
    ],
    "note": "Total cost = spend + time cost; return = attributed revenue + follower count × assumed value; ROI = (return − cost) ÷ cost; ROAS = revenue ÷ ad spend. Zero denominators are undefined."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const timeCost = hoursSpent*hourlyCost; const totalCost = spend + timeCost; const followerValue = followersGained*valuePerFollower; const totalReturn = revenue + followerValue; const profit = totalReturn - totalCost; return { totalCost, returnValue: totalReturn, roi: totalCost > 0 ? profit/totalCost*100 : null, roas: spend > 0 ? revenue/spend : null, costPerFollower: followersGained > 0 ? totalCost/followersGained : null, profit };",
    "inputs": [
      {
        "name": "spend",
        "type": "number",
        "default": 5000,
        "min": 0,
        "max": 1000000000,
        "step": 1
      },
      {
        "name": "revenue",
        "type": "number",
        "default": 12000,
        "min": 0,
        "max": 10000000000,
        "step": 1
      },
      {
        "name": "hoursSpent",
        "type": "number",
        "default": 40,
        "min": 0,
        "max": 100000,
        "step": 1
      },
      {
        "name": "hourlyCost",
        "type": "number",
        "default": 30,
        "min": 0,
        "max": 10000,
        "step": 1
      },
      {
        "name": "followersGained",
        "type": "number",
        "default": 1500,
        "min": 0,
        "max": 100000000,
        "step": 1
      },
      {
        "name": "valuePerFollower",
        "type": "number",
        "default": 2,
        "min": 0,
        "max": 1000,
        "step": 0.01
      }
    ],
    "outputs": [
      {
        "name": "totalCost",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "returnValue",
        "precision": 2,
        "unit": "$"
      },
      {
        "name": "roi",
        "precision": 1,
        "unit": "%",
        "optional": true
      },
      {
        "name": "roas",
        "precision": 2,
        "unit": "x",
        "optional": true
      },
      {
        "name": "costPerFollower",
        "precision": 3,
        "unit": "$",
        "optional": true
      },
      {
        "name": "profit",
        "precision": 2,
        "unit": "$"
      }
    ],
    "interpret": null
  }
}
