# Loot

Contract hosting the Loot reward logic. A Loot is a struct holding the data for PAL & extra rewards allocated to an user based on distribution, user voting rewards from Quest and boosting power from their hPAL locks. The PAL rewards in the Loot are vested for a given duration, and can be claimed beforehand but are slashed based on the remaining duration of the vesting. The extra rewards are not vested and not slashed.

#### LootData

Loot Data strcut

```solidity
struct LootData {
  uint256 id;
  uint256 palAmount;
  uint256 extraAmount;
  uint256 startTs;
  uint256 endTs;
  bool claimed;
}
```

#### pal

```solidity
contract IERC20 pal
```

PAL token

#### extraToken

```solidity
contract IERC20 extraToken
```

Extra reward token

#### tokenReserve

```solidity
address tokenReserve
```

Address of the Reserve contract holding token to be distributed

#### lootCreator

```solidity
contract ILootCreator lootCreator
```

Loot Creator contract

#### vestingDuration

```solidity
uint256 vestingDuration
```

Duration of vesting for Loots

#### userLoots

```solidity
mapping(address => struct Loot.LootData[]) userLoots
```

List of Loot for each user

#### LootCreated

```solidity
event LootCreated(address user, uint256 id, uint256 palAmount, uint256 extraAmount, uint256 startTs)
```

Event emitted when a Loot is created

#### LootClaimed

```solidity
event LootClaimed(address user, uint256 id, uint256 palAmount, uint256 extraAmount)
```

Event emitted when a Loot is claimed

#### VestingDurationUpdated

```solidity
event VestingDurationUpdated(uint256 oldDuration, uint256 newDuration)
```

Event emitted when the vesting duration is updated

#### LootCreatorUpdated

```solidity
event LootCreatorUpdated(address oldCreator, address newCreator)
```

Event emitted when the Loot Creator address is updated

#### setInitialLootCreator

```solidity
function setInitialLootCreator(address _lootCreator) external
```

Sets the Loot Creator contract address

**Parameters**

| Name          | Type    | Description                          |
| ------------- | ------- | ------------------------------------ |
| \_lootCreator | address | Address of the Loot Creator contract |

#### getLootData

```solidity
function getLootData(address user, uint256 id) external view returns (uint256 palAmount, uint256 extraAmount, uint256 startTs, uint256 endTs, bool claimed)
```

Returns the data of a Loot for a user & an id

**Parameters**

| Name | Type    | Description         |
| ---- | ------- | ------------------- |
| user | address | Address of the user |
| id   | uint256 | ID of the Loot      |

**Return Values**

| Name        | Type    | Description                                       |
| ----------- | ------- | ------------------------------------------------- |
| palAmount   | uint256 | (uint256) : Amount of PAL                         |
| extraAmount | uint256 | (uint256) : Amount of extra token                 |
| startTs     | uint256 | (uint256) : Timestamp at which the vesting starts |
| endTs       | uint256 | (uint256) : Timestamp at which the vesting ends   |
| claimed     | bool    | (uint256) : Is Loot already claimed               |

#### getAllUserLootIds

```solidity
function getAllUserLootIds(address user) external view returns (uint256[])
```

Returns all the user Loot IDs

**Parameters**

| Name | Type    | Description         |
| ---- | ------- | ------------------- |
| user | address | Address of the user |

**Return Values**

| Name | Type       | Description                   |
| ---- | ---------- | ----------------------------- |
| \[0] | uint256\[] | uint256\[] : List of Loot IDs |

#### getAllActiveUserLootIds

```solidity
function getAllActiveUserLootIds(address user) external view returns (uint256[])
```

Returns all the user active Loot IDs

**Parameters**

| Name | Type    | Description         |
| ---- | ------- | ------------------- |
| user | address | Address of the user |

**Return Values**

| Name | Type       | Description                          |
| ---- | ---------- | ------------------------------------ |
| \[0] | uint256\[] | uint256\[] : List of active Loot IDs |

#### getAllUserLoot

```solidity
function getAllUserLoot(address user) external view returns (struct Loot.LootData[])
```

Returns all the user Loots

**Parameters**

| Name | Type    | Description         |
| ---- | ------- | ------------------- |
| user | address | Address of the user |

**Return Values**

| Name | Type                    | Description                 |
| ---- | ----------------------- | --------------------------- |
| \[0] | struct Loot.LootData\[] | LootData\[] : List of Loots |

#### getAllActiveUserLoot

```solidity
function getAllActiveUserLoot(address user) external view returns (struct Loot.LootData[])
```

Returns all the user active Loots

**Parameters**

| Name | Type    | Description         |
| ---- | ------- | ------------------- |
| user | address | Address of the user |

**Return Values**

| Name | Type                    | Description                        |
| ---- | ----------------------- | ---------------------------------- |
| \[0] | struct Loot.LootData\[] | LootData\[] : List of active Loots |

#### createLoot

```solidity
function createLoot(address user, uint256 startTs, uint256 palAmount, uint256 extraAmount) external returns (int256)
```

Creates a new Loot for a user

**Parameters**

| Name        | Type    | Description                           |
| ----------- | ------- | ------------------------------------- |
| user        | address | Address of the user                   |
| startTs     | uint256 | Timestamp at which the vesting starts |
| palAmount   | uint256 | Amount of PAL                         |
| extraAmount | uint256 | Amount of extra token                 |

#### claimLoot

```solidity
function claimLoot(uint256 id, address receiver) external
```

Claims a Loot for a user

**Parameters**

| Name     | Type    | Description                              |
| -------- | ------- | ---------------------------------------- |
| id       | uint256 | ID of the Loot                           |
| receiver | address | Address to receive the PAL & extra token |

#### claimMultipleLoot

```solidity
function claimMultipleLoot(uint256[] ids, address receiver) external
```

Claims multiple Loots for a user

**Parameters**

| Name     | Type       | Description                              |
| -------- | ---------- | ---------------------------------------- |
| ids      | uint256\[] | List of Loot IDs                         |
| receiver | address    | Address to receive the PAL & extra token |


---

# 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.paladin.vote/vote-flywheel/smart-contracts/loot.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.
