# Feed 'N' - Settlement transactions

**Requests**

{% tabs %}
{% tab title="Subscribe" %}

```json
{"event": "bind", "feed": "N"}
```

For detailed settlement transactions description

{% content-ref url="/pages/iImE6POOfq4lRQL38OMS" %}
[settlementTransactions](/api-reference/rest-api/settlements/settlementtransactions.md)
{% endcontent-ref %}
{% endtab %}

{% tab title="Unsubscribe" %}

```json
{"event": "unbind", "feed": "N"}
```

{% endtab %}
{% endtabs %}

**Feed handling**

{% tabs %}
{% tab title="Definitions" %}

```json
settlementTransaction = [
  0: counterpartyId (Efx::ClientId)
  1: currencyName (string)
  2: amount (Efx::Size)
  3: settlementOrderId (Efx::OrderId)
  4: comment (string)
  5: createdAt (Efx::Timestamp)
  6: txId (string)
  7: sentAt (Efx::Timestamp)
  8: transactionFlags (Efx::Flags)
  9: transactionMoment (Efx::Timestamp)
  10: transaction (Efx::DealId)
  11: networkFee (unsigned int64)
  12: network (string)
]
```

For detailed settlement transaction description

{% content-ref url="/pages/iImE6POOfq4lRQL38OMS" %}
[settlementTransactions](/api-reference/rest-api/settlements/settlementtransactions.md)
{% endcontent-ref %}
{% endtab %}

{% tab title="Possible updates" %}

```json
// snapshot
['N', 0, 'S', [
  0, // Reserved
  [incoming settlementTransactions],
  [outgoing settlementTransactions]
]]

// add settlement transactions
['N', 0, '+', [
  [new incoming settlementTransactions],
  [new outgoing settlementTransactions]
]]

// modify settlement transactions
['N', 0, 'M', [
  [received incoming settlementTransactions],
  [received outgoing settlementTransactions]
]]

//committed settlement transactions
['N', 0, 'D', [
  [committed incoming settlementTransactions],
  [committed outgoing settlementTransactions]
]]

// removed settlement transactions
['N', 0, '-', [
  [removed incoming settlementTransactions],
  [removed outgoing settlementTransactions]
]]

// failed to subscribe
['N', 0, 'Z', 2]

// unsubscribed
['N', 0, 'U', 0]
```

{% endtab %}

{% tab title="Feed update example" %}

```javascript
applyToSnapshot(prevSnapshot, feed, action, data) {
    switch (action) {
        case 'S' : {
            snapshot = [data[0], [...data[1]], [...data[2]]]
            break
        }
        case '+' : {
            for (let incoming of data[0]) {
                snapshot[1].push(incoming)
            }
            for (let outgoing of data[1]) {
                snapshot[2].push(outgoing)
            }
            break
        }
        case 'M' : {
            for (let incoming of data[0]) {
                for (var i in snapshot[1]) {
                    if (snapshot[1][i][3] == incoming[3]) {
                        snapshot[1][i] = incoming
                        break
                    }
                }
            }
            for (let outgoing of data[1]) {
                for (var i in snapshot[2]) {
                    if (snapshot[2][i][3] == outgoing[3]) {
                        snapshot[2][i] = outgoing
                        break
                    }
                }
            }
            break
        }
        case 'D' :
        case '-' : {
            for (let incoming of data[0]) {
                if (incoming[10]) {
                    snapshot[0] = incoming[10] + 1
                }
                for (var i in snapshot[1]) {
                    if (snapshot[1][i][3] == incoming[3]) {
                        snapshot[1].splice(i, 1)
                        break
                    }
                }
            }
            for (let outgoing of data[1]) {
                if (outgoing[10]) {
                    snapshot[0] = outgoing[10] + 1
                }
                for (var i in snapshot[2]) {
                    if (snapshot[2][i][3] == outgoing[3]) {
                        snapshot[2].splice(i, 1)
                        break
                    }
                }
            }
            break
        }
    }
    return prevSnapshot
}
```

{% endtab %}
{% endtabs %}


---

# 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://faq.finerymarkets.com/api-reference/websocket-api/feed-n-settlement-transactions.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.
