# Ranked curve model

Code4rena's ranked curve is used to calculate rank-based award distributions, including:

* [QA reports](/awarding.md#ranks-for-qa-and-gas-reports)
* Historically, [Gas reports](/awarding/historical-info.md#gas-optimization-reports) and [Dark Horse bonuses](/awarding/historical-info.md#dark-horse-bonus-pool)

## If there are tied ranks

If two or more wardens (or teams) have tied ranks, they split the *total* awards for the ranks they would otherwise occupy — i.e. if two wardens tie for 2nd place, they split the total awards for 2nd and 3rd place. Or if three wardens tie for 3rd, they split the total awards for 3rd place.

## QA reports: ranked curve awarding

QA reports are [ranked and graded as described here](/awarding.md#ranks-for-qa-reports):

* 1st place (score: 5)
* 2nd place (score: 4)
* 3rd place (score: 3)
* `grade-a` and `grade-b` (score: 0, except in rare cases -- see below)
* `grade-c` (score: 0)

In most cases, only 1st, 2nd, and 3rd place reports are eligible for awards. See "If there are no valid HM findings" below for an exception.

* Reports (referred to as `findings` in the code) are sorted in descending order based on their scores. Findings without a score are treated as having a score of 0.
* For each report, a point value is calculated using the formula `qaAndGasConstant^(2 - idx)`, where `qaAndGasConstant` is defined in the `qaAndGasRanking` code (see example below), and `idx` is the index of the report in the sorted array. This means the highest-scored report gets the highest point value, decreasing exponentially for subsequent reports.
* **Pie** - The total value of the pie is the sum of all point values.
* **Mapping score to points** - unique score is mapped to an array of point values associated with findings that have that score.
* **Slice for each score** - sum the points for each score to determine the slice size for each score.
* **Split** - number of reports sharing the same score

### Sample output

| issueID | reportID | risk | score       | award              |
| ------- | -------- | ---- | ----------- | ------------------ |
| 13      | `Q-01`   | Q    | "1st place" | 3552.6315789473683 |
| 207     | `Q-02`   | Q    | "2nd place" | 2368.4210526315787 |
| 42      | `Q-03`   | Q    | "3rd place" | 1578.9473684210525 |

#### Sample input with ties for 1st place

```
  {
    number: 4,
    risk: 'q',
    labels: '["QA (Quality Assurance)","Q-08","3rd place"]'
  },
  {
    number: 28,
    risk: 'q',
    labels: '["QA (Quality Assurance)","Q-16","1st place"]'
  },
  {
    number: 113,
    risk: 'q',
    labels: '["QA (Quality Assurance)","Q-19","1st place"]'
  }
```

#### Sample output with ties for 1st place

| issueID | reportID | risk | pie  | split | slice | score | award              |
| ------- | -------- | ---- | ---- | ----- | ----- | ----- | ------------------ |
| 4       | `Q-08`   | Q    | 4.75 | 1     | 1     | 3     | 1578.9473684210525 |
| 28      | `Q-16`   | Q    | 4.75 | 2     | 3.75  | 5     | 2960.5263157894738 |
| 113     | `Q-19`   | Q    | 4.75 | 2     | 3.75  | 5     | 2960.5263157894738 |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.code4rena.com/awarding/curve-logic.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
