# ClaimManager

The ClaimManager contract manages the lifecycle of claims from initiation to resolution. It coordinates interactions between users, the Liquidity Manager, and arbitration courts. This contracts ensures a fair and transparent system for cover holders to submit claims and receive compensation when eligible.

***

## Enums info

### ClaimStatus

```solidity
enum ClaimStatus {
  Initiated,
  Accepted,
  Compensated,
  Disputed,
  RejectedByOverrule,
  RejectedByRefusalToArbitrate,
  RejectedByCourtDecision,
  AcceptedByCourtDecision,
  CompensatedAfterDispute
}
```

### RulingOptions

```solidity
enum RulingOptions {
  RefusedToArbitrate,
  PayClaimant,
  RejectClaim
}
```

The neutral "refuse to arbitrate" option IS ALWAYS 0

***

## Structs info

### ClaimRead

```solidity
struct ClaimRead {
 uint256 claimId;
 address claimant;
 string[] evidence;
 string[] counterEvidence;
 uint256[] relatedClaimIds;
 uint64 poolId;
 uint256 coverAmount;
 bool isCoverActive;
 uint64 createdAt;
 uint64 rulingTimestamp;
 uint64 challengedTimestamp;
 ClaimManager.ClaimStatus status;
 uint256 coverId;
 uint256 disputeId;
 string metaEvidenceURI;
 uint256 amount;
 address prosecutor;
 uint256 deposit;
}
```

### Claim

```solidity
struct Claim {
 uint64 createdAt;
 uint64 rulingTimestamp;
 uint64 challengedTimestamp;
 ClaimManager.ClaimStatus status;
 uint256 coverId;
 uint256 disputeId;
 uint256 amount;
 address claimant;
 address prosecutor;
 uint256 deposit;
}
```

***

## State variables info

### baseMetaEvidenceURI

```solidity
string baseMetaEvidenceURI
```

### coverToken

```solidity
contract IAthenaCoverToken coverToken
```

### liquidityManager

```solidity
contract ILiquidityManager liquidityManager
```

### arbitrator

```solidity
contract IArbitrator arbitrator
```

### evidenceGuardian

```solidity
address evidenceGuardian
```

### overruleGuardian

```solidity
address overruleGuardian
```

### nextClaimId

```solidity
uint256 nextClaimId
```

### claims

```solidity
mapping(uint256 => struct ClaimManager.Claim) claims
```

### disputeIdToClaimId

```solidity
mapping(uint256 => uint256) disputeIdToClaimId
```

### claimIdToEvidence

```solidity
mapping(uint256 => string[]) claimIdToEvidence
```

### claimIdToCounterEvidence

```solidity
mapping(uint256 => string[]) claimIdToCounterEvidence
```

### claimCollateral

```solidity
uint256 claimCollateral
```

### klerosExtraData

```solidity
bytes klerosExtraData
```

### challengePeriod

```solidity
uint64 challengePeriod
```

### overrulePeriod

```solidity
uint64 overrulePeriod
```

### evidenceUploadPeriod

```solidity
uint64 evidenceUploadPeriod
```

### numberOfRulingOptions

```solidity
uint64 immutable numberOfRulingOptions = 2
```

### courtClosed

```solidity
bool courtClosed
```

## Modifiers info

### onlyArbitrator

```solidity
modifier onlyArbitrator()
```

Check that the caller is the arbitrator contract

### coverExists

```solidity
modifier coverExists(uint256 coverId_)
```

Check that the cover exists

Parameters:

| Name      | Type    | Description  |
| --------- | ------- | ------------ |
| coverId\_ | uint256 | The cover ID |

### claimsExists

```solidity
modifier claimsExists(uint256 claimId_)
```

Check that the claim exists

Parameters:

| Name      | Type    | Description  |
| --------- | ------- | ------------ |
| claimId\_ | uint256 | The claim ID |

***

## Read Functions info

### arbitrationCost

```solidity
function arbitrationCost() public view returns (uint256)
```

Returns the cost of arbitration for a Kleros dispute.

Return values:

| Name | Type    | Description          |
| ---- | ------- | -------------------- |
| --   | uint256 | The arbitration cost |

### metaEvidenceURI

```solidity
function metaEvidenceURI(uint256 claimId) public view returns (string memory)
```

Returns the URI of the meta-evidence for a claim

Parameters:

| Name    | Type    | Description  |
| ------- | ------- | ------------ |
| claimId | uint256 | The claim ID |

Return values:

| Name | Type   | Description                  |
| ---- | ------ | ---------------------------- |
| --   | string | The URI of the meta-evidence |

### coverIdToClaimIds

```solidity
function coverIdToClaimIds(
    uint256 coverId_
) external view coverExists(coverId_) returns (uint256[] memory)
```

Returns all claim IDs associated with a cover.

Parameters:

| Name      | Type    | Description  |
| --------- | ------- | ------------ |
| coverId\_ | uint256 | The cover ID |

Return values:

| Name | Type       | Description                                 |
| ---- | ---------- | ------------------------------------------- |
| --   | uint256\[] | All the claim IDs associated with the cover |

### claimInfo

```solidity
function claimInfo(
    uint256 claimId_
) external view returns (ClaimManager.ClaimRead memory)
```

Get a claim by its ID.

Parameters:

| Name      | Type    | Description  |
| --------- | ------- | ------------ |
| claimId\_ | uint256 | The claim ID |

Return values:

| Name | Type                          | Description      |
| ---- | ----------------------------- | ---------------- |
| --   | struct ClaimManager.ClaimRead | The claim's data |

### claimInfos

```solidity
function claimInfos(
    uint256[] memory claimIds_
) public view returns (ClaimManager.ClaimRead[] memory result)
```

Returns multiple claims by their IDs.

Parameters:

| Name       | Type       | Description   |
| ---------- | ---------- | ------------- |
| claimIds\_ | uint256\[] | The claim IDs |

Return values:

| Name   | Type                             | Description          |
| ------ | -------------------------------- | -------------------- |
| result | struct ClaimManager.ClaimRead\[] | All the claims' data |

### claimsByCoverId

```solidity
function claimsByCoverId(
    uint256 coverId_
) public view returns (ClaimManager.ClaimRead[] memory)
```

Returns all the claims associated with a cover.

Parameters:

| Name      | Type    | Description  |
| --------- | ------- | ------------ |
| coverId\_ | uint256 | The cover ID |

Return values:

| Name | Type                             | Description            |
| ---- | -------------------------------- | ---------------------- |
| --   | struct ClaimManager.ClaimRead\[] | All the cover's claims |

### claimsByAccount

```solidity
function claimsByAccount(
    address account_
) external view returns (ClaimManager.ClaimRead[] memory result)
```

Returns all the claims of a user.

Parameters:

| Name      | Type    | Description        |
| --------- | ------- | ------------------ |
| account\_ | address | The user's address |

Return values:

| Name   | Type                             | Description           |
| ------ | -------------------------------- | --------------------- |
| result | struct ClaimManager.ClaimRead\[] | All the user's claims |

### getClaimEvidence

```solidity
function getClaimEvidence(
    uint256 claimId_
) external view claimsExists(claimId_) returns (string[] memory)
```

Returns the evidence submitted by claimant for a claim.

Parameters:

| Name      | Type    | Description  |
| --------- | ------- | ------------ |
| claimId\_ | uint256 | The claim ID |

Return values:

| Name | Type      | Description       |
| ---- | --------- | ----------------- |
| --   | string\[] | The evidence CIDs |

### getClaimCounterEvidence

```solidity
function getClaimCounterEvidence(
    uint256 claimId_
) external view claimsExists(claimId_) returns (string[] memory)
```

Returns the counter-evidence submitted by prosecutor or Athena for a claim.

Parameters:

| Name      | Type    | Description  |
| --------- | ------- | ------------ |
| claimId\_ | uint256 | The claim ID |

Return values:

| Name | Type      | Description               |
| ---- | --------- | ------------------------- |
| --   | string\[] | The counter-evidence CIDs |

***

## Write Functions info

### submitEvidenceForClaim

```solidity
function submitEvidenceForClaim(
    uint256 claimId_,
    string[] calldata ipfsEvidenceCids_
) external claimsExists(claimId_)
```

Adds evidence IPFS CIDs for a claim.

Parameters:

| Name               | Type      | Description                   |
| ------------------ | --------- | ----------------------------- |
| claimId\_          | uint256   | The claim ID                  |
| ipfsEvidenceCids\_ | string\[] | The IPFS CIDs of the evidence |

### initiateClaim

```solidity
function initiateClaim(
    uint256 coverId_,
    uint256 amountClaimed_
) external payable nonReentrant
```

Initiates a payment claim to Kleros by a cover holder.

Parameters:

| Name            | Type    | Description                            |
| --------------- | ------- | -------------------------------------- |
| coverId\_       | uint256 | The cover ID                           |
| amountClaimed\_ | uint256 | The amount claimed by the cover holder |

### disputeClaim

```solidity
function disputeClaim(
    uint256 claimId_
) external payable claimsExists(claimId_) nonReentrant
```

Allows a user to challenge a pending claim by creating a dispute in Kleros.

Parameters:

| Name      | Type    | Description  |
| --------- | ------- | ------------ |
| claimId\_ | uint256 | The claim ID |

### withdrawCompensation

```solidity
function withdrawCompensation(
    uint256 claimId_
) external claimsExists(claimId_) nonReentrant
```

Allows the claimant to withdraw the compensation after a dispute has been resolved in their favor or the challenge period has elapsed.

Intentionally public to prevent claimant from indefinitely blocking withdrawals from a pool by not executing the claims ruling.

Parameters:

| Name      | Type    | Description  |
| --------- | ------- | ------------ |
| claimId\_ | uint256 | The claim ID |

***

## Events info

### ClaimCreated

```solidity
event ClaimCreated(address indexed claimant, uint256 indexed coverId, uint256 claimId)
```

### DisputeResolved

```solidity
event DisputeResolved(uint256 claimId, uint256 disputeId, uint256 ruling)
```

### MetaEvidence

```solidity
event MetaEvidence(uint256 indexedmetaEvidenceID_, stringevidence_)
```

To be emitted when meta-evidence is submitted.

Parameters:

| Name             | Type    | Description                                                                                                  |
| ---------------- | ------- | ------------------------------------------------------------------------------------------------------------ |
| metaEvidenceID\_ | uint256 | Unique identifier of meta-evidence.                                                                          |
| evidence\_       | string  | IPFS path to metaevidence, example: '/ipfs/Qmarwkf7C9RuzDEJNnarT3WZ7kem5bk8DZAzx78acJjMFH/metaevidence.json' |

### Evidence

```solidity
event Evidence(IArbitrator indexedarbitrator_, uint256 indexedevidenceGroupID_, address indexedparty_, stringevidence_)
```

To be raised when evidence is submitted. Should point to the resource (evidences are not to be stored on chain due to gas considerations).

Parameters:

| Name              | Type                 | Description                                                                                                   |
| ----------------- | -------------------- | ------------------------------------------------------------------------------------------------------------- |
| arbitrator\_      | contract IArbitrator | The arbitrator of the contract.                                                                               |
| evidenceGroupID\_ | uint256              | Unique identifier of the evidence group the evidence belongs to.                                              |
| party\_           | address              | The address of the party submiting the evidence. Note that 0x0 refers to evidence not submitted by any party. |
| evidence\_        | string               | IPFS path to evidence, example: '/ipfs/Qmarwkf7C9RuzDEJNnarT3WZ7kem5bk8DZAzx78acJjMFH/evidence.json'          |

### Dispute

```solidity
event Dispute(IArbitrator indexedarbitrator_, uint256 indexeddisputeID_, uint256metaEvidenceID_, uint256evidenceGroupID_)
```

To be emitted when a dispute is created to link the correct meta-evidence to the disputeID.

Parameters:

| Name              | Type                 | Description                                                             |
| ----------------- | -------------------- | ----------------------------------------------------------------------- |
| arbitrator\_      | contract IArbitrator | The arbitrator of the contract.                                         |
| disputeID\_       | uint256              | ID of the dispute in the Arbitrator contract.                           |
| metaEvidenceID\_  | uint256              | Unique identifier of meta-evidence.                                     |
| evidenceGroupID\_ | uint256              | Unique identifier of the evidence group that is linked to this dispute. |


---

# 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://doc.athenains.io/smart-contracts/claimmanager.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.
