<!-- Source: https://docs.paxeer.app/modules/mint/ -->

# Mint Module

Scheduled native token inflation, daily distribution, and governance-controlled minting policy.

**Source:** `paxeer-network/modules/mint/`

## Overview

The mint module creates new PAX tokens according to a predefined schedule. It enables scheduled token release structures that distribute tokens over time. The goal is to reach a deflationary state where no more inflation occurs and the network relies solely on transaction fees.

Minting occurs daily (UTC), incentivizing users to stake tokens for longer durations to earn rewards.

## Minting Mechanism

The mint module operates on a daily distribution model:

1. A `total_mint_amount` is defined for a period between `start_date` and `end_date`
2. Each day, the module calculates `daily_mint_amount = remaining_mint_amount / days_remaining`
3. Tokens are minted and sent to the `fee_collector` account
4. The distribution module distributes collected fees to stakers

### Example

If `total_mint_amount = 1,000,000` tokens and the period is 100 days:

- Initial daily mint: `1,000,000 / 100 = 10,000` tokens/day

- After 50 days: `500,000 remaining / 50 days = 10,000` tokens/day (unchanged if no downtime)

- If the chain was down for 1 day at day 50: `500,000 remaining / 49 days = 10,204` tokens/day (adjusted)

Network outages automatically adjust the daily rate to meet the total mint amount by the end date.

## State

### Minter

The minter stores current inflation state:

```
type Minter struct {
    StartDate           string  // The day where the mint begins
    EndDate             string  // The day where the mint ends
    Denom               string  // Denom for the coins minted (default uhpx)
    TotalMintAmount     uint64  // Total amount to be minted
    RemainingMintAmount uint64  // Remaining amount to be minted
    LastMintAmount      uint64  // Last amount minted (usually from the day before)
    LastMintDate        string  // Last day minted
    LastMintHeight      uint64  // The height of the last mint
}
```

Query the current minter:

```
paxd q mint minter
```

### Params

Parameters define the minting schedule:

```
type Params struct {
    MintDenom            string                   // Type of coin to mint
    TokenReleaseSchedule []ScheduledTokenRelease  // List of token release schedules
}

type ScheduledTokenRelease struct {
    StartDate          string  // The day where the mint begins
    EndDate            string  // The day where the mint ends
    TokenReleaseAmount uint64  // Total amount to be minted
}
```

Multiple release schedules can be defined, allowing sequential minting periods.

## Begin-Block

At the end of each epoch (default 60s), the mint module:

1. Checks if it's the minting start date
2. Calculates the daily mint amount
3. Mints tokens to the `fee_collector` account
4. Updates `LastMintAmount`, `LastMintDate`, and `RemainingMintAmount`

Epoch hooks trigger the minting check. See [Epoch module](https://docs.paxeer.app/modules/epoch) for how epochs work.

## Governance

### Update Minter Proposal

The minter can be updated via governance to change the mint schedule:

```
{
  "title": "Update Minter",
  "description": "Adjust mint schedule",
  "minter": {
    "start_date": "2023-10-05",
    "end_date": "2023-11-22",
    "denom": "uhpx",
    "total_mint_amount": 100000
  }
}
```

Submit the proposal:

```
paxd tx gov submit-proposal update-minter ./minter_prop.json \
  --deposit 20pax --from admin -b block -y \
  --gas 200000 --fees 2000uhpx
```

Before the proposal:

```
> paxd q mint minter
denom: uhpx
end_date: "2023-04-30"
last_mint_amount: "333333333333"
last_mint_date: "2023-04-27"
last_mint_height: "0"
remaining_mint_amount: "666666666666"
start_date: "2023-04-27"
total_mint_amount: "999999999999"
```

After the proposal passes:

```
> paxd q mint minter
denom: uhpx
end_date: "2023-11-22"
last_mint_amount: "0"
last_mint_date: ""
last_mint_height: "0"
remaining_mint_amount: "0"
start_date: "2023-10-05"
total_mint_amount: "100000"
```

### Update Params Proposal

Parameters can be updated to define new token release schedules:

```
{
  "title": "Param Change Proposal",
  "description": "Update token release schedule",
  "changes": [
    {
      "subspace": "mint",
      "key": "MintDenom",
      "value": "uhpx"
    },
    {
      "subspace": "mint",
      "key": "TokenReleaseSchedule",
      "value": [
        {
          "token_release_amount": 500,
          "start_date": "2023-10-01",
          "end_date": "2023-10-30"
        },
        {
          "token_release_amount": 1000,
          "start_date": "2023-11-01",
          "end_date": "2023-11-30"
        }
      ]
    }
  ]
}
```

Submit:

```
paxd tx gov submit-proposal param-change ./param_change_prop.json \
  --from admin -b block -y --gas 200000 --fees 200000uhpx
```

**Note:** Changes to `total_mint_amount` or `remaining_mint_amount` after the start date do not affect tokens already minted.

## Events

### Mint Event

Emitted on each successful mint:

- **mint_date:** Date of the mint

- **mint_epoch:** Epoch number when the mint occurred

- **amount:** Amount minted

## Metrics

The mint module emits a `pax_mint_coins&#123;denom&#125;` Prometheus metric on each successful mint event.

## Next Steps

- [Understand epoch coordination](https://docs.paxeer.app/modules/epoch)

- [Learn about the oracle module](https://docs.paxeer.app/modules/oracle)
