# User Data

This guide explains how to fetch detailed user position data, including liquidity shares and profit/loss metrics.

### Contract IDs

* **Mainnet**: `000080350ca5ef204bc29b3232bb197e12bec6b473f5e6bdb749a6921197e83c`
* **Testnet**: `00000eecf6a990576c12bfa9e12ee089a5b1ea65e6de1456687ba1f4dc7fd463`

***

### 1. Get All User Positions

Fetch all liquidity positions for a specific user address across all pools.

**Method**: `get_user_positions(address)`\
**Args**: `address` (string) - The user's wallet address (or Caller ID).

#### Example Request

```bash
USER_ADDRESS="H..." # Replace with actual address

curl -s -G "https://node1.mainnet.hathor.network/v1a/nano_contract/state" \
  --data-urlencode "id=000080350ca5ef204bc29b3232bb197e12bec6b473f5e6bdb749a6921197e83c" \
  --data-urlencode "calls[]=get_user_positions(\"$USER_ADDRESS\")" \
  | jq
```

#### Response Structure

Returns a dictionary where keys are Pool Keys and values are `UserPosition` objects.

```json
{
  "return": {
    "POOL_KEY_STRING": [
      1000,    // liquidity (Amount)
      500,     // token0Amount (Amount)
      500,     // token1Amount (Amount)
      1000,    // share (Amount, basis points e.g. 1000 = 10%)
      0,       // balance_a (Amount)
      0,       // balance_b (Amount)
      "00",    // token_a (UID)
      "UID..." // token_b (UID)
    ]
  }
}
```

***

### 2. Get User Profit Info

Get the profit and loss (PnL) analysis for a user's position in a specific pool.

**Method**: `get_user_profit_info(address, pool_key)`\
**Args**:

* `address`: User's wallet address
* `pool_key`: The unique pool identifier

#### Example Request

```bash
USER_ADDRESS="H..."
POOL_KEY="00/UID.../80"

curl -s -G "https://node1.mainnet.hathor.network/v1a/nano_contract/state" \
  --data-urlencode "id=000080350ca5ef204bc29b3232bb197e12bec6b473f5e6bdb749a6921197e83c" \
  --data-urlencode "calls[]=get_user_profit_info(\"$USER_ADDRESS\", \"$POOL_KEY\")" \
  | jq
```

#### Response Structure

Returns a `UserProfitInfo` object.

```json
{
  "return": [
    2000,        // current_value_usd (Amount)
    1500,        // initial_value_usd (Amount)
    500,         // profit_amount_usd (Amount)
    3333,        // profit_percentage (Amount, 3333 = 33.33%)
    1700000000   // last_action_timestamp (Integer)
  ]
}
```
