> For the complete documentation index, see [llms.txt](https://lendxyz.gitbook.io/lend/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lendxyz.gitbook.io/lend/reference/activity-events.md). Agents can also search and read this documentation through its [MCP server](https://lendxyz.gitbook.io/lend/~gitbook/mcp).

# Activity events

Activity is Lend's normalised event feed. Chain logs are noisy, chain-specific and addressed to contracts; activity events are deduplicated, addressed to **users** and **operations**, and identical in shape whether they originated on Ethereum, an L2 or Stellar.

This is what fills the activity tab of an operation and the history in your portfolio.

## How they are produced

```
Factory / opLend / Rewards / Restitution
                │  logs
                ▼
   EVM indexer   ·   Soroban indexer
                │  normalised rows
                ▼
          activity table
                │
                ▼
   GET /activity/op/{id}   ·   GET /users/activity
```

Two indexers write into the same table. Each reads finalised blocks, decodes the events it knows, resolves the on-chain `factory_op_id` to Lend's internal operation UUID, and inserts one row per *interested party*.

Soroban coverage is currently narrower than EVM: the Soroban indexer maps operation creation and opLend transfers. The remaining types are produced by the EVM indexer.

## The event object

```json
{
  "event_hash": "0xabc…#42#lend_invested",
  "chain_id": 1,
  "block_number": 21874312,
  "event_type": "invested",
  "op_id": "3f1c…",
  "factory_op_id": 12,
  "user_address": "0x…",
  "created_at": "2026-03-04T11:02:19Z",
  "data": {
    "tx_hash": "0xabc…#42",
    "usdc_amount": "1050000000",
    "shares_bought": "10000000"
  }
}
```

| Field           | Notes                                                                                             |
| --------------- | ------------------------------------------------------------------------------------------------- |
| `event_hash`    | Unique. `{txHash}#{logIndex}#{suffix}` — the dedup key that makes re-indexing a block idempotent. |
| `chain_id`      | Chain the event was observed on.                                                                  |
| `block_number`  | Block it was included in.                                                                         |
| `event_type`    | One of the types below.                                                                           |
| `op_id`         | Lend's internal operation UUID.                                                                   |
| `factory_op_id` | The operation id on the Factory contract.                                                         |
| `user_address`  | The party this row concerns. Absent for operation-level events that belong to no one.             |
| `data`          | Type-specific payload — the table below tells you which fields to expect.                         |
| `created_at`    | Block timestamp, not indexing time.                                                               |

{% hint style="info" %}
`data.tx_hash` is the transaction hash suffixed with the log index (`0xabc…#42`), not a bare hash. Strip the suffix before linking to a block explorer.
{% endhint %}

### One chain event, several rows

Some events concern two parties, and each gets their own row so that a per-user query never has to interpret direction:

* **`op_lend_transfered`** — one row for the sender, one for the receiver, distinguished by `user_is_sender`.
* **`order_filled`** — one row for the maker, one for the taker, distinguished by `is_maker`.

Amounts are always strings, in the token's base units. opLend and USDC both use 6 decimals on EVM.

***

## Event catalogue

### Investing

| `event_type`       | Emitted when                                                                                     | `data` fields                                |
| ------------------ | ------------------------------------------------------------------------------------------------ | -------------------------------------------- |
| `invested`         | A user buys shares — including via pre-deposit, gift or fiat, which all emit `Invested` on-chain | `tx_hash`, `usdc_amount`, `shares_bought`    |
| `invested_fiat`    | The investment was paid in fiat, opLend held in custody                                          | `tx_hash`, `op_lend_holder`, `shares_bought` |
| `claimed_op_token` | Pending shares from a pre-deposit or gift were minted                                            | `tx_hash`, `token_amount`                    |
| `refunded`         | An admin refunded a user, burning their opLend                                                   | `tx_hash`, `usdc_amount`, `shares_refunded`  |

### Operation lifecycle

These have no `user_address` — they describe the operation itself.

| `event_type`            | Emitted when                                           | `data` fields                                       |
| ----------------------- | ------------------------------------------------------ | --------------------------------------------------- |
| `op_created`            | The operation and its opLend token were deployed       | `tx_hash`, `op_token`, `total_shares`               |
| `op_predeposits_open`   | The pre-deposit window opened                          | `tx_hash`                                           |
| `op_predeposits_closed` | The pre-deposit window closed                          | `tx_hash`                                           |
| `op_started`            | Funding opened                                         | `tx_hash`                                           |
| `op_paused`             | Funding was paused                                     | `tx_hash`                                           |
| `op_resumed`            | Funding resumed                                        | `tx_hash`                                           |
| `op_finished`           | The funding goal was reached                           | `tx_hash`, `amount_raised`                          |
| `op_canceled`           | The operation was cancelled                            | `tx_hash`                                           |
| `op_lend_peer_added`    | The token was registered on another chain for bridging | `tx_hash`, `op_token`, `chain_id`, `lz_endpoint_id` |

### Token movements

| `event_type`         | Emitted when                        | `data` fields                                                             |
| -------------------- | ----------------------------------- | ------------------------------------------------------------------------- |
| `op_lend_transfered` | opLend moved between two users      | `tx_hash`, `from`, `to`, `amount`, `user_is_sender`                       |
| `op_lend_bridged`    | opLend was bridged to another chain | `tx_hash`, `src_chain_id`, `dst_chain_id`, `src_eid`, `dst_eid`, `amount` |

{% hint style="info" %}
A plain `op_lend_transfered` really means *a transfer between users*. Transfers that are the mechanical side of an investment, refund, claim, bridge or DEX fill are suppressed — the indexer inspects the transaction and drops the `Transfer` log when a richer event already describes what happened.
{% endhint %}

### Revenue and rewards

| `event_type`                  | Emitted when                                                       | `data` fields                                                   |
| ----------------------------- | ------------------------------------------------------------------ | --------------------------------------------------------------- |
| `rewards_distributed`         | An epoch's merkle root was published and funded                    | `tx_hash`, `op_id`, `epoch`, `usdc_amount`                      |
| `rewards_distributed_grouped` | The same distribution across several chains, folded into one entry | `txs: [{ tx_hash, chain_id }]`, `op_id`, `epoch`, `usdc_amount` |
| `claimed_rewards`             | A user claimed their revenue for an epoch                          | `tx_hash`, `usdc_amount`                                        |
| `ref_rewards_distributed`     | A referral epoch was funded                                        | `tx_hash`, `epoch`, `usdc_amount`                               |
| `claimed_ref_rewards`         | A user claimed referral rewards                                    | `tx_hash`, `usdc_amount`                                        |

An operation distributes on every chain it lives on, so a single epoch produces one `rewards_distributed` per chain. `rewards_distributed_grouped` is the collapsed view the app renders, so the feed shows one distribution rather than eight.

### Secondary market

| `event_type`      | Emitted when                                 | `data` fields                                                                                                                                                           |
| ----------------- | -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `order_filled`    | A limit order was filled, fully or partially | `tx_hash`, `order_hash`, `is_maker`, `maker_asset`, `taker_asset`, `making_amount_traded`, `taking_amount_traded`, `remaining_making_amount`, `remaining_taking_amount` |
| `order_cancelled` | An open order was cancelled                  | `tx_hash`, `order_hash`, `making_amount_canceled`, `taking_amount_canceled`                                                                                             |

`making_amount_traded` and `taking_amount_traded` are the *deltas* of this fill, not cumulative totals — a partially filled order produces one event per fill.

### Redemption

| `event_type`          | Emitted when                          | `data` fields                              |
| --------------------- | ------------------------------------- | ------------------------------------------ |
| `restitution_opened`  | The redemption was funded and opened  | `tx_hash`, `usdc_amount`, `usdc_per_token` |
| `restitution_claimed` | A holder redeemed opLend against USDC | `tx_hash`, `usdc_amount`, `oplend_amount`  |
| `restitution_closed`  | The redemption window closed          | `tx_hash`                                  |

***

## Reading the feed

| Endpoint                          | Scope                                                                                          |
| --------------------------------- | ---------------------------------------------------------------------------------------------- |
| `GET /activity/op/{id}` `/{page}` | Everything that happened on one operation                                                      |
| `GET /users/activity` `/{page}`   | Everything concerning the authenticated user, enriched with the operation's `slug` and `title` |

Both are paginated, newest first. See the [API reference](https://lendxyz.gitbook.io/lend/reference/api-reference.md).

For live updates rather than polling, the WebSocket `op_progress` channel pushes funding progress as investments land.
