# Lockup Account

The `x/lockup` module provides functionality for managing token lockups and delegations. This module supports operations such as creating lockup accounts, non-voting delegation, reward claiming, and token transfers.

## Key Features

1. **Lockup Account Management**:
   * Creation and management of lockup accounts
   * Setting lockup periods (start and end times)
   * Tracking of locked tokens
2. **Non-Voting Delegation**:
   * Delegation of locked tokens to validators
   * Undelegation functionality
   * Delegation reward claiming
3. **Token Management**:
   * Transfer of locked tokens
   * Querying spendable amounts
   * Tracking lockup status

## Core Concepts

### Lockup Account

> **Note:** The following section covers advanced topics intended for experienced users or developers.

A lockup account is defined by the following parameters:

* **`address`**: The lockup account address
* **`owner`**: The account owner's address
* **`id`**: Unique identifier for the lockup account
* **`start_time`**: Lockup start time (Unix timestamp)
* **`end_time`**: Lockup end time (Unix timestamp)
* **`original_locking`**: Original locked amount
* **`delegated_free`**: Amount of delegated transfers available
* **`delegated_locking`**: Delegated amount of locking amount
* **`unbond_entries`**: List of unbonding entries
* **`additional_locking`**: Additional locked amount

### Unbonding Entry

An unbonding entry is defined by the following parameters:

* **`creation_height`**: Block height when the entry was created
* **`end_time`**: End time of the entry
* **`amount`**: Unbonding amount
* **`validator_address`**: Validator's address

## Workflow

### 1. Lockup Account Initialization

* User creates a lockup account
* Sets lockup period and amount
* Specifies account owner

### 2. Non-Voting Delegation

* Delegates locked tokens to validators
* Executes undelegation
* Claims delegation rewards

### 3. Token Transfer

* Transfers tokens from lockup account
* Verifies spendable amount
* Executes transfer

## Sequence Diagram: Lockup Operations

{% @mermaid/diagram content="sequenceDiagram
participant User as User
participant LockupModule as x/lockup Module
participant Validator as Validator
participant Bank as x/bank Module

```
User->>LockupModule: Create Lockup Account
LockupModule->>Bank: Lock Tokens
User->>LockupModule: Non-Voting Delegate
LockupModule->>Validator: Delegate Tokens
Validator->>LockupModule: Generate Rewards
User->>LockupModule: Claim Rewards
LockupModule->>User: Send Rewards" %}
```

## Messages

The module provides various message types:

* MsgUpdateParams: Update module parameters (governance operation)
* MsgInitLockupAccount: Initialize a new lockup account with specified parameters
* MsgNonVotingDelegate: Delegate tokens from a lockup account without voting rights
* MsgNonVotingUndelegate: Undelegate tokens from a non-voting delegation
* MsgClaimRewards: Claim delegation rewards for a lockup account
* MsgSend: Send tokens from a lockup account to another address

## Queries

The module provides various query endpoints:

* Params: Query module parameters
* LockupAccounts: List all lockup accounts for a given owner
* LockupAccount: Get details of a specific lockup account
* SpendableAmount: Get the spendable amount for a specific lockup account

See [Github](https://github.com/sunriselayer/sunrise/tree/main/x/lockup) for details.


---

# 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.sunriselayer.io/learn/sunrise/lockup.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.
