# Feed 'N' - Settlement transactions

**Requests**

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

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

For detailed settlement transactions description

{% content-ref url="../rest-api/settlements/settlementtransactions" %}
[settlementtransactions](https://faq.finerymarkets.com/api-reference/rest-api/settlements/settlementtransactions)
{% 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="../rest-api/settlements/settlementtransactions" %}
[settlementtransactions](https://faq.finerymarkets.com/api-reference/rest-api/settlements/settlementtransactions)
{% 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 %}
