> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trusset.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Pay Operator Fees

> Calldata that pays the vault's unattributed distributor slice to the vault owner

Builds `payOperatorFees()` on the vault. It pays the vault owner the part of the collected distributor slices that no distributor earned. That is what shares without a distributor earned, plus anything that accrued while no shares were in issue. `operator.claimable` on [Get Earnings](/endpoints/vaults/get-earnings) shows the amount.

Any wallet may sign, and the vault pays its owner, never the signer. The API builds the call only for the instance that operates the vault. Only fees already collected into the vault are payable: run [Collect Distributor Fees](/endpoints/vaults/collect-distributor-fees) for each market first.

Holders bound to your instance's own distributor wallet earn through [Pay Distributor](/endpoints/vaults/pay-distributor), like any other distributor's holders. This call pays only the unattributed part.

## Path Parameters

<ParamField path="vaultId" type="string" required>Vault ID.</ParamField>

## Body Parameters

<ParamField body="txHash" type="string">
  Hash of the mined payout, `0x` and 64 hex characters. Send it to confirm and record the result. Omit it to receive the calldata; no other field is needed to build.
</ParamField>

The route validates every field of the schema it shares with the other distributor actions, even where this action ignores it.

## Response Fields

The calldata response:

<ResponseField name="data" type="object">
  <Expandable>
    <ResponseField name="action" type="string">`SIGN_TRANSACTION`.</ResponseField>
    <ResponseField name="transaction" type="object">`to` (the vault), `data`, `value` (`"0"`) and `chainId`.</ResponseField>
    <ResponseField name="functionName" type="string">`payOperatorFees`.</ResponseField>
    <ResponseField name="permissionless" type="boolean">Always `true`: any wallet may sign.</ResponseField>
    <ResponseField name="recipient" type="string">The vault owner, which the vault pays.</ResponseField>
    <ResponseField name="amount" type="string">What the vault holds for its owner when the calldata was built, formatted at the vault's asset decimals.</ResponseField>
    <ResponseField name="amountRaw" type="string">The same amount in base units.</ResponseField>
    <ResponseField name="description" type="string">The transaction in words.</ResponseField>
    <ResponseField name="note" type="string">States that the vault pays its owner, never the signer.</ResponseField>
    <ResponseField name="confirmWith" type="object">`endpoint`, this route with the vault ID filled in, and `field`, always `txHash`.</ResponseField>
  </Expandable>
</ResponseField>

The confirmation response, after the backend has verified the receipt:

<ResponseField name="data" type="object">
  <Expandable>
    <ResponseField name="txHash" type="string">The verified hash.</ResponseField>
    <ResponseField name="action" type="string">`operator`.</ResponseField>
    <ResponseField name="signer" type="string">The wallet that signed.</ResponseField>
    <ResponseField name="amount" type="string">What the vault paid, from its `OperatorFeePaid` event.</ResponseField>
    <ResponseField name="amountRaw" type="string">The same amount in base units.</ResponseField>
    <ResponseField name="events" type="array">The distributor events the vault emitted in the transaction, here `OPERATOR_PAID`.</ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.trusset.org/lending-external-securities-v2/api/vaults/cmssh8t2u0003cghxkx1w1fwd/operator-fees/pay" \
    -H "X-API-Key: trusset_your_key_here" \
    -H "Content-Type: application/json" \
    -d '{}'
  ```

  ```typescript TypeScript theme={null}
  const url = `https://api.trusset.org/lending-external-securities-v2/api/vaults/${vaultId}/operator-fees/pay`;
  const headers = { 'X-API-Key': 'trusset_your_key_here', 'Content-Type': 'application/json' };

  const res = await fetch(url, { method: 'POST', headers, body: JSON.stringify({}) });
  const { data } = await res.json();

  const tx = await signer.sendTransaction(data.transaction);
  await tx.wait();

  await fetch(url, { method: 'POST', headers, body: JSON.stringify({ txHash: tx.hash }) });
  ```
</RequestExample>

<ResponseExample>
  ```json Calldata Response theme={null}
  {
    "success": true,
    "data": {
      "action": "SIGN_TRANSACTION",
      "transaction": {
        "to": "0x4d0cfe39a3431b145d1a1393d901a36d459a1b13",
        "data": "0x3799fd63",
        "value": "0",
        "chainId": 11155111
      },
      "functionName": "payOperatorFees",
      "permissionless": true,
      "recipient": "0x5ad87a0621175206b72d10e4b8577b192e7f40ab",
      "amount": "5.625",
      "amountRaw": "5625000",
      "description": "Pay the 5.625 USDC unattributed distributor slice to the vault owner 0x5ad87a0621175206b72d10e4b8577b192e7f40ab",
      "note": "Any wallet may sign this transaction. The vault pays its owner, never the signer.",
      "confirmWith": {
        "endpoint": "POST /lending-external-securities-v2/api/vaults/cmssh8t2u0003cghxkx1w1fwd/operator-fees/pay",
        "field": "txHash"
      }
    }
  }
  ```

  ```json Confirmed Response theme={null}
  {
    "success": true,
    "data": {
      "txHash": "0xa05ac2618cc57644ff005eaa0c358110f3949ba14a0fb0c732eda4f5f4bca5e5",
      "action": "operator",
      "signer": "0x5ad87a0621175206b72d10e4b8577b192e7f40ab",
      "amount": "5.625",
      "amountRaw": "5625000",
      "events": ["OPERATOR_PAID"]
    }
  }
  ```

  ```json Error - Nothing Accrued theme={null}
  {
    "success": false,
    "data": null,
    "error": {
      "code": "NOTHING_ACCRUED",
      "message": "No unattributed distributor fee is waiting for the operator in this vault."
    }
  }
  ```
</ResponseExample>

## Error Codes

| Code                              | HTTP  | Cause                                                                                                                              |
| --------------------------------- | ----- | ---------------------------------------------------------------------------------------------------------------------------------- |
| `VALIDATION_ERROR`                | `400` | A body field is malformed                                                                                                          |
| `NOT_VAULT_OPERATOR`              | `403` | Your instance does not operate this vault. The contract would still take the call from any signer                                  |
| `VAULT_NOT_FOUND`                 | `404` | No such vault, or it is not visible to your instance                                                                               |
| `VAULT_NOT_DEPLOYED`              | `409` | The vault has no on-chain address on record                                                                                        |
| `VAULT_UPGRADE_REQUIRED`          | `409` | The vault runs an implementation from before distributor attribution                                                               |
| `NOTHING_ACCRUED`                 | `409` | No unattributed distributor fee is waiting for the operator. Collect the vault's slice from its markets first                      |
| `VAULT_STATE_UNAVAILABLE`         | `503` | The vault implementation, its operator balance or owner, or your standing in an unpublished vault could not be read. Retry shortly |
| `CHAIN_UNAVAILABLE`               | `503` | The chain could not be read, so nothing was decided. Retry shortly                                                                 |
| `SERVICE_UNAVAILABLE`             | `503` | The vault records or your instance's verified wallets could not be read. Retry shortly                                             |
| `VAULT_DISTRIBUTOR_ACTION_FAILED` | `500` | Unexpected failure. Retry, or contact support with the request ID                                                                  |

Confirming with `txHash` can also return `TX_NOT_FOUND` (`404`), `TX_REVERTED`, `TX_WRONG_TARGET` or `TX_WRONG_FUNCTION` (`400`), and `TX_NOT_VERIFIED` (`400`) when the transaction carries no operator payout on this vault. See [transaction verification errors](/endpoints/introduction#confirm-a-transaction).
