# Contract

<figure><img src="https://2519306540-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FV1ORJT16Dy4SeGDI9BkP%2Fuploads%2FDyo38fouEkaWA3DuKkMh%2FScreen%20Shot%202024-01-30%20at%203.37.09%20PM.png?alt=media&#x26;token=5cc2eb33-fd62-4584-89d2-b99e30e0ab64" alt=""><figcaption><p>Main</p></figcaption></figure>

[Github](https://github.com/currentxchange/loot)

### Loot Contract Actions

#### 📝 User Registration (`regnewuser`)

* **Purpose**: Registers a user on the contract, enabling participation in NFT staking and rewards.
* **Parameters**:
  * `user`: Account name to be registered.
  * `referrer`: (Optional) Account name of the referrer, if any.

#### 💰 Claiming Rewards (`claim`)

* **Purpose**: Allows users to claim accumulated rewards from staked NFTs.
* **Parameters**:
  * `user`: Account name claiming the rewards.
  * `collection`: Name of the NFT collection from which to claim rewards.

#### 🔄 Unstaking NFTs (`unstake`)

* **Purpose**: Enables users to remove their NFTs from staking, halting reward accumulation.
* **Parameters**:
  * `user`: Account name performing the unstake action.
  * `asset_ids`: List of NFT asset IDs to be unstaked.

#### 🔄 Resetting User Data (`resetuser`)

* **Purpose**: Clears a user's staking data and returns any staked NFTs.
* **Parameters**:
  * `user`: Account name whose data is to be reset.

#### 💸 Refunding Tokens (`refund`)

* **Purpose**: Issues a refund of tokens to a user under specific conditions.
* **Parameters**:
  * `user`: Recipient of the refund.
  * `collection`: Collection associated with the refund.
  * `refund_amount`: Amount of tokens to be refunded.

#### 🌐 Registering NFT Collection (`setnftcolrew`)

* **Purpose**: Sets up a new NFT collection for staking with specific reward parameters.
* **Parameters**:
  * `user`: Account initiating the registration.
  * `collection`: Collection name.
  * `token_symbol`: Token symbol for rewards.
  * `token_contract`: Contract managing the reward tokens.
  * `time_unit_length`: Length of time units for reward calculation.
  * `unstake_period`: Minimum staking period before NFTs can be unstaked.
  * `reward_series_referral`: Series for calculating referral rewards.
  * `reward_coefficient_referral`: Coefficient for referral reward calculation.
  * `reward_series_hodl`: Series for calculating holding rewards.
  * `reward_coefficient_hodl`: Coefficient for holding reward calculation.

#### ➕ Adding Eligible NFT Templates (`addtemplates`)

* **Purpose**: Includes NFT templates in the staking program of a collection.
* **Parameters**:
  * `user`: Account adding the templates.
  * `template_id`: ID of the template to be added.
  * `collection`: Collection to which the template belongs.
  * `timeunit_rate`: Reward rate per time unit for the template.

#### ➖ Removing NFT Templates (`rmtemplates`)

* **Purpose**: Excludes NFT templates from the staking program of a collection.
* **Parameters**:
  * `user`: Account removing the templates.
  * `template_id`: ID of the template to be removed.
  * `collection`: Collection from which the template is removed.

#### 🔔 Receiving NFTs (`receiveassets`)

* **Purpose**: Automatically stakes NFTs sent to the contract and updates user staking data.
* **Parameters**:
  * Handled through `atomicassets::transfer` notifications; no direct user parameters.

#### 📈 Handling Token Transfers (`on_transfer`)

* **Purpose**: Manages incoming token transfers to fund the contract's reward pool.
* **Parameters**:
  * Handled through token `transfer` notifications; the memo should contain the collection name.

<br>
