{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.hoodbuybutton.com/receipts/ledger.schema.json",
  "title": "Buy Button public fee ledger",
  "type": "object",
  "additionalProperties": false,
  "required": ["$schema", "schemaVersion", "recordType", "canonicalUri", "updatedAt", "chain", "assets", "activation", "labelRegistry", "scopeDefinitions", "summary", "snapshot", "routes", "venueSnapshot", "venueHistory", "latestRwaRun", "claims", "usesAndOutcomes", "evidenceBoundary"],
  "properties": {
    "$schema": {"type": "string", "format": "uri"},
    "schemaVersion": {"const": "1.1.0"},
    "recordType": {"const": "buy-button-public-fee-ledger"},
    "canonicalUri": {"type": "string", "format": "uri"},
    "updatedAt": {"type": "string", "format": "date-time"},
    "chain": {"$ref": "#/$defs/chain"},
    "assets": {"$ref": "#/$defs/assets"},
    "activation": {"$ref": "#/$defs/activation"},
    "labelRegistry": {"$ref": "#/$defs/labelRegistry"},
    "scopeDefinitions": {"$ref": "#/$defs/scopeDefinitions"},
    "summary": {"$ref": "#/$defs/summary"},
    "snapshot": {"$ref": "#/$defs/snapshot"},
    "routes": {"type": "array", "minItems": 5, "maxItems": 5, "items": {"$ref": "#/$defs/route"}},
    "venueSnapshot": {"$ref": "#/$defs/venueSnapshot"},
    "venueHistory": {"$ref": "#/$defs/venueHistory"},
    "latestRwaRun": {"$ref": "#/$defs/latestRwaRun"},
    "claims": {"type": "array", "minItems": 7, "maxItems": 7, "items": {"$ref": "#/$defs/claim"}},
    "usesAndOutcomes": {"type": "array", "items": {"$ref": "#/$defs/useOutcome"}},
    "evidenceBoundary": {"$ref": "#/$defs/evidenceBoundary"}
  },
  "$defs": {
    "decimal": {"type": "string", "pattern": "^(0|[1-9][0-9]*)\\.[0-9]+$"},
    "numericString": {"type": "string", "pattern": "^(0|[1-9][0-9]*)(\\.[0-9]+)?$"},
    "signedDecimal": {"type": "string", "pattern": "^-?(0|[1-9][0-9]*)\\.[0-9]+$"},
    "address": {"type": "string", "pattern": "^0x[0-9a-fA-F]{40}$"},
    "hash": {"type": "string", "pattern": "^0x[0-9a-fA-F]{64}$"},
    "sha256": {"type": "string", "pattern": "^[0-9a-f]{64}$"},
    "assetAmount": {
      "type": "object", "additionalProperties": false, "required": ["asset", "amount"],
      "properties": {"asset": {"enum": ["BUY", "WETH", "ETH", "USDC", "HOOD"]}, "amount": {"$ref": "#/$defs/decimal"}}
    },
    "chain": {
      "type": "object", "additionalProperties": false, "required": ["namespace", "name", "chainId", "explorer"],
      "properties": {"namespace": {"const": "eip155"}, "name": {"type": "string", "minLength": 1}, "chainId": {"const": 4663}, "explorer": {"type": "string", "format": "uri"}}
    },
    "assets": {
      "type": "object", "additionalProperties": false, "required": ["BUY", "WETH", "ETH"],
      "properties": {"BUY": {"$ref": "#/$defs/tokenAsset"}, "WETH": {"$ref": "#/$defs/tokenAsset"}, "ETH": {"$ref": "#/$defs/nativeAsset"}}
    },
    "tokenAsset": {
      "type": "object", "additionalProperties": false, "required": ["contract", "decimals"],
      "properties": {"contract": {"$ref": "#/$defs/address"}, "decimals": {"const": 18}}
    },
    "nativeAsset": {"type": "object", "additionalProperties": false, "required": ["decimals"], "properties": {"decimals": {"const": 18}}},
    "activation": {
      "type": "object", "additionalProperties": false,
      "required": ["status", "effectiveFrom", "firstIncludedBlock", "split", "signalEvidenceUrl", "wordingBoundary"],
      "properties": {
        "status": {"const": "eight-week-test-approved"}, "effectiveFrom": {"type": "string", "format": "date-time"},
        "firstIncludedBlock": {"type": "integer", "minimum": 1}, "split": {"const": "45/30/10/10/5"},
        "signalEvidenceUrl": {"type": "string", "format": "uri"}, "wordingBoundary": {"type": "string", "minLength": 1}
      }
    },
    "labelRegistry": {
      "type": "object", "additionalProperties": false, "required": ["version", "registryUrl", "signatureUrl", "authority", "limitation"],
      "properties": {
        "version": {"const": 1}, "registryUrl": {"type": "string", "pattern": "^/"}, "signatureUrl": {"type": "string", "pattern": "^/"},
        "authority": {"const": "signed-project-declaration"}, "limitation": {"type": "string", "minLength": 1}
      }
    },
    "scopeDefinitions": {
      "type": "object", "additionalProperties": false,
      "required": ["lifetimeDeadAddress", "postActivationClaimLinkedDead", "reserveAttributedBuy", "lighterPosition"],
      "properties": {
        "lifetimeDeadAddress": {"type": "string", "minLength": 1},
        "postActivationClaimLinkedDead": {"type": "string", "minLength": 1},
        "reserveAttributedBuy": {"type": "string", "minLength": 1},
        "lighterPosition": {"type": "string", "minLength": 1}
      }
    },
    "summary": {
      "type": "object", "additionalProperties": false,
      "required": ["confirmedCollectionCount", "lifetimeCollectorDeadTransferCount", "routedWeth", "buySentToDeadDuringIncludedCollections", "verifiedReserveAcquisitionCount", "verifiedReserveWethInput", "verifiedReserveBuyReceived", "unclassifiedOutflowCount", "correctionCount"],
      "properties": {
        "confirmedCollectionCount": {"const": 7}, "lifetimeCollectorDeadTransferCount": {"type": "integer", "minimum": 0},
        "routedWeth": {"$ref": "#/$defs/decimal"}, "buySentToDeadDuringIncludedCollections": {"$ref": "#/$defs/decimal"},
        "verifiedReserveAcquisitionCount": {"type": "integer", "minimum": 0}, "verifiedReserveWethInput": {"$ref": "#/$defs/decimal"},
        "verifiedReserveBuyReceived": {"$ref": "#/$defs/decimal"}, "unclassifiedOutflowCount": {"const": 2}, "correctionCount": {"type": "integer", "minimum": 0}
      }
    },
    "snapshot": {
      "type": "object", "additionalProperties": false, "required": ["blockNumber", "blockHash", "blockTimestamp", "observedAt", "rpc", "deadAddress"],
      "properties": {
        "blockNumber": {"type": "integer", "minimum": 1}, "blockHash": {"$ref": "#/$defs/hash"},
        "blockTimestamp": {"type": "string", "format": "date-time"}, "observedAt": {"type": "string", "format": "date-time"},
        "rpc": {"type": "string", "format": "uri"}, "deadAddress": {"$ref": "#/$defs/deadAddress"}
      }
    },
    "deadAddress": {
      "type": "object", "additionalProperties": false,
      "required": ["address", "buyBalance", "shareOfOriginalSupplyPercent", "erc20TotalSupply", "practicalCirculatingEstimate", "supplyAccountingBoundary", "explorerUrl", "marketValueEstimate"],
      "properties": {
        "address": {"$ref": "#/$defs/address"}, "buyBalance": {"$ref": "#/$defs/decimal"},
        "shareOfOriginalSupplyPercent": {"$ref": "#/$defs/decimal"}, "erc20TotalSupply": {"$ref": "#/$defs/decimal"},
        "practicalCirculatingEstimate": {"$ref": "#/$defs/decimal"}, "supplyAccountingBoundary": {"type": "string", "minLength": 1},
        "explorerUrl": {"type": "string", "format": "uri"},
        "marketValueEstimate": {"$ref": "#/$defs/marketValueEstimate"}
      }
    },
    "marketValueEstimate": {
      "type": "object", "additionalProperties": false,
      "required": ["classification", "quoteCurrency", "estimatedAmount", "unitPriceUsd", "priceObservedAt", "balanceConfirmedAtBlock", "balanceConfirmedAt", "source", "method", "limitation"],
      "properties": {
        "classification": {"const": "NOTIONAL_SPOT_ESTIMATE"}, "quoteCurrency": {"const": "USD"},
        "estimatedAmount": {"$ref": "#/$defs/decimal"}, "unitPriceUsd": {"$ref": "#/$defs/decimal"},
        "priceObservedAt": {"type": "string", "format": "date-time"}, "balanceConfirmedAtBlock": {"type": "integer", "minimum": 1},
        "balanceConfirmedAt": {"type": "string", "format": "date-time"}, "source": {"$ref": "#/$defs/marketValueSource"},
        "method": {"type": "string", "minLength": 1}, "limitation": {"type": "string", "minLength": 1}
      }
    },
    "marketValueSource": {
      "type": "object", "additionalProperties": false, "required": ["provider", "poolAddress", "marketUrl", "apiUrl"],
      "properties": {"provider": {"const": "GeckoTerminal"}, "poolAddress": {"$ref": "#/$defs/address"}, "marketUrl": {"type": "string", "format": "uri"}, "apiUrl": {"type": "string", "format": "uri"}}
    },
    "route": {
      "type": "object", "additionalProperties": false,
      "required": ["routeId", "label", "sharePercent", "recipient", "receivedSinceActivation", "observedBalances", "openingOrOtherNetWeth", "receiptedUse", "verifiedOutcome", "reconciliationStatus", "reconciliationNote"],
      "properties": {
        "routeId": {"enum": ["content-marketing", "public-buy-reserve", "products", "builder-operations", "hood-additions"]},
        "label": {"type": "string", "minLength": 1}, "sharePercent": {"type": "integer", "minimum": 0, "maximum": 100},
        "recipient": {"$ref": "#/$defs/address"}, "receivedSinceActivation": {"$ref": "#/$defs/assetAmount"},
        "observedBalances": {"type": "array", "minItems": 3, "maxItems": 3, "items": {"$ref": "#/$defs/assetAmount"}},
        "openingOrOtherNetWeth": {"anyOf": [{"$ref": "#/$defs/decimal"}, {"type": "null"}]},
        "receiptedUse": {"anyOf": [{"$ref": "#/$defs/reserveReceiptedUse"}, {"$ref": "#/$defs/rwaReceiptedUse"}, {"type": "null"}]},
        "verifiedOutcome": {"anyOf": [{"$ref": "#/$defs/verifiedOutcome"}, {"type": "null"}]},
        "reconciliationStatus": {"enum": ["RECONCILED", "PARTIAL", "UNAVAILABLE"]}, "reconciliationNote": {"type": "string", "minLength": 1}
      }
    },
    "reserveReceiptedUse": {
      "type": "object", "additionalProperties": false, "required": ["inputAsset", "inputAmount", "outputAsset", "outputAmount", "eventCount"],
      "properties": {
        "inputAsset": {"const": "WETH"}, "inputAmount": {"$ref": "#/$defs/decimal"}, "outputAsset": {"const": "BUY"},
        "outputAmount": {"$ref": "#/$defs/decimal"}, "eventCount": {"type": "integer", "minimum": 1}
      }
    },
    "rwaReceiptedUse": {
      "type": "object", "additionalProperties": false,
      "required": ["inputAsset", "inputAmount", "outputAsset", "outputAmount", "eventCount", "classification", "attributionBoundary"],
      "properties": {
        "inputAsset": {"const": "WETH"}, "inputAmount": {"$ref": "#/$defs/decimal"}, "outputAsset": {"const": "USDC"},
        "outputAmount": {"$ref": "#/$defs/decimal"}, "eventCount": {"type": "integer", "minimum": 1},
        "classification": {"const": "ACCUMULATED TREASURY BRIDGE"}, "attributionBoundary": {"type": "string", "minLength": 1}
      }
    },
    "verifiedOutcome": {
      "type": "object", "additionalProperties": false,
      "required": ["asset", "amount", "holder", "holderLabel", "holderPurpose", "publicProfileUrl", "labelAuthority", "registryStatus", "explorerUrl"],
      "properties": {
        "asset": {"const": "BUY"}, "amount": {"$ref": "#/$defs/decimal"}, "holder": {"$ref": "#/$defs/address"},
        "holderLabel": {"const": "DECLARED FOMO BUYBACK ACCOUNT"}, "holderPurpose": {"type": "string", "minLength": 1},
        "publicProfileUrl": {"type": "string", "format": "uri"}, "labelAuthority": {"const": "unsigned-project-declaration"},
        "registryStatus": {"const": "NOT COVERED BY SIGNED REGISTRY V1"}, "explorerUrl": {"type": "string", "format": "uri"}
      }
    },
    "claim": {
      "type": "object", "additionalProperties": false,
      "required": ["eventType", "transactionHash", "blockNumber", "timestamp", "wethRouted", "buySentToDead", "routeAmounts"],
      "properties": {
        "eventType": {"const": "CLAIM"}, "transactionHash": {"$ref": "#/$defs/hash"},
        "blockNumber": {"type": "integer", "minimum": 1}, "timestamp": {"type": "string", "format": "date-time"},
        "wethRouted": {"$ref": "#/$defs/decimal"}, "buySentToDead": {"$ref": "#/$defs/decimal"},
        "routeAmounts": {
          "type": "object", "additionalProperties": false,
          "required": ["content-marketing", "public-buy-reserve", "products", "builder-operations", "hood-additions"],
          "properties": {
            "content-marketing": {"$ref": "#/$defs/decimal"}, "public-buy-reserve": {"$ref": "#/$defs/decimal"},
            "products": {"$ref": "#/$defs/decimal"}, "builder-operations": {"$ref": "#/$defs/decimal"}, "hood-additions": {"$ref": "#/$defs/decimal"}
          }
        }
      }
    },
    "useOutcome": {
      "type": "object", "additionalProperties": false,
      "required": ["eventType", "classification", "routeId", "transactionHash", "blockNumber", "timestamp", "input", "output"],
      "properties": {
        "eventType": {"enum": ["USE", "OUTCOME", "UNCLASSIFIED", "CORRECTION"]}, "classification": {"type": "string", "minLength": 1},
        "routeId": {"enum": ["content-marketing", "public-buy-reserve", "products", "builder-operations", "hood-additions"]},
        "transactionHash": {"$ref": "#/$defs/hash"}, "linkedTransactionHashes": {"type": "array", "items": {"$ref": "#/$defs/hash"}},
        "blockNumber": {"type": "integer", "minimum": 1}, "timestamp": {"type": "string", "format": "date-time"},
        "input": {"$ref": "#/$defs/assetAmount"}, "output": {"anyOf": [{"$ref": "#/$defs/assetAmount"}, {"type": "null"}]},
        "claimTransactionHash": {"anyOf": [{"$ref": "#/$defs/hash"}, {"type": "null"}]}, "destination": {"$ref": "#/$defs/address"},
        "note": {"type": "string", "minLength": 1}
      }
    },
    "venueSnapshot": {
      "type": "object", "additionalProperties": false,
      "required": ["source", "marketSource", "observedAt", "accountResponseSha256", "marketResponseSha256", "accountIndex", "marketId", "symbol", "positionSide", "marginMode", "initialMarginFractionPercent", "positionSize", "averageEntryPrice", "positionValue", "unrealizedPnl", "realizedPnl", "liquidationPrice", "allocatedMargin", "totalAssetValue", "collateral", "totalFundingPaidOut", "markPrice", "indexPrice", "lastPrice", "openInterest", "positionSizeShareOfReportedOpenInterestPercent", "attributedToFivePercentRoute", "boundary"],
      "properties": {
        "source": {"type": "string", "format": "uri"}, "marketSource": {"type": "string", "format": "uri"},
        "observedAt": {"type": "string", "format": "date-time"}, "accountResponseSha256": {"$ref": "#/$defs/sha256"},
        "marketResponseSha256": {"$ref": "#/$defs/sha256"}, "accountIndex": {"const": 733049}, "marketId": {"const": 108},
        "symbol": {"const": "HOOD"}, "positionSide": {"const": "LONG"}, "marginMode": {"const": 1},
        "initialMarginFractionPercent": {"$ref": "#/$defs/numericString"}, "positionSize": {"$ref": "#/$defs/decimal"},
        "averageEntryPrice": {"$ref": "#/$defs/decimal"}, "positionValue": {"$ref": "#/$defs/decimal"},
        "unrealizedPnl": {"$ref": "#/$defs/decimal"}, "realizedPnl": {"$ref": "#/$defs/decimal"},
        "liquidationPrice": {"$ref": "#/$defs/decimal"}, "allocatedMargin": {"$ref": "#/$defs/decimal"},
        "totalAssetValue": {"$ref": "#/$defs/decimal"}, "collateral": {"$ref": "#/$defs/decimal"},
        "totalFundingPaidOut": {"$ref": "#/$defs/signedDecimal"}, "markPrice": {"$ref": "#/$defs/decimal"},
        "indexPrice": {"$ref": "#/$defs/decimal"}, "lastPrice": {"$ref": "#/$defs/decimal"},
        "openInterest": {"$ref": "#/$defs/decimal"}, "positionSizeShareOfReportedOpenInterestPercent": {"$ref": "#/$defs/decimal"},
        "attributedToFivePercentRoute": {"type": "null"}, "boundary": {"type": "string", "minLength": 1}
      }
    },
    "venueHistory": {
      "type": "object", "additionalProperties": false,
      "required": ["source", "observedAt", "responseSha256", "fillCount", "buyFillCount", "sellFillCount", "additionGroupCount", "firstFillAt", "latestFillAt", "reconstructedNetSize", "milestones"],
      "properties": {
        "source": {"type": "string", "format": "uri"}, "observedAt": {"type": "string", "format": "date-time"},
        "responseSha256": {"$ref": "#/$defs/sha256"}, "fillCount": {"type": "integer", "minimum": 0},
        "buyFillCount": {"type": "integer", "minimum": 0}, "sellFillCount": {"type": "integer", "minimum": 0},
        "additionGroupCount": {"type": "integer", "minimum": 0}, "firstFillAt": {"type": "string", "format": "date-time"},
        "latestFillAt": {"type": "string", "format": "date-time"}, "reconstructedNetSize": {"$ref": "#/$defs/decimal"},
        "milestones": {"type": "array", "minItems": 2, "items": {"$ref": "#/$defs/venueMilestone"}}
      }
    },
    "venueMilestone": {
      "type": "object", "additionalProperties": false, "required": ["timestamp", "positionSize"],
      "properties": {"timestamp": {"type": "string", "format": "date-time"}, "positionSize": {"$ref": "#/$defs/decimal"}}
    },
    "latestRwaRun": {
      "type": "object", "additionalProperties": false,
      "required": ["classification", "claimTransactionHash", "claimWethRouted", "fivePercentSliceWeth", "bridgeTransactionHash", "bridgeInputWeth", "depositTransactionHash", "depositOutputUsdc", "positionDeltaHood", "fillCount", "fillVwap", "fillHashes", "latestFillAt", "attributionBoundary"],
      "properties": {
        "classification": {"const": "ACCUMULATED_TREASURY_PATH"}, "claimTransactionHash": {"$ref": "#/$defs/hash"},
        "claimWethRouted": {"$ref": "#/$defs/decimal"}, "fivePercentSliceWeth": {"$ref": "#/$defs/decimal"},
        "bridgeTransactionHash": {"$ref": "#/$defs/hash"}, "bridgeInputWeth": {"$ref": "#/$defs/decimal"},
        "depositTransactionHash": {"$ref": "#/$defs/hash"}, "depositOutputUsdc": {"$ref": "#/$defs/decimal"},
        "positionDeltaHood": {"$ref": "#/$defs/decimal"}, "fillCount": {"type": "integer", "minimum": 1},
        "fillVwap": {"$ref": "#/$defs/decimal"}, "fillHashes": {"type": "array", "minItems": 1, "items": {"type": "string", "pattern": "^[0-9a-f]+$"}},
        "latestFillAt": {"type": "string", "format": "date-time"}, "attributionBoundary": {"type": "string", "minLength": 1}
      }
    },
    "evidenceBoundary": {
      "type": "object", "additionalProperties": false, "required": ["onchain", "projectDeclared", "accounting", "notClaimed"],
      "properties": {
        "onchain": {"type": "string", "minLength": 1}, "projectDeclared": {"type": "string", "minLength": 1},
        "accounting": {"type": "string", "minLength": 1}, "notClaimed": {"type": "string", "minLength": 1}
      }
    }
  }
}
