# Trade model: MMSettlement

This page describes the FX Integration API's **MMSettlement** trade model, as defined in the file `config/TradingAdapter/Blade/DataSource/etc/trademodels.xml` in the FX Integration API Kit.

This documentation is for the FX Integration API 12.10.0.

Trade models are XML-defined state machines used by the [Java Trading API](https://docs.caplin.com/developer/api/trading_java/latest/) and Caplin Trader's [Trading API](../caplin-trader/4/trading-api/index.md) to manage trading workflows. For more information on trade model XML definitions, see the [Trade model XML schema](../caplin-platform/cis/cis-trade-model-schema.md) reference.

## State model

The MMSettlement trade model's state model in Mermaid JS format:

```mermaid
%% State diagram for the MMSettlement trade model
stateDiagram-v2
    [*] --> Initial
    Initial --> Requested : Request (client)
    Requested --> Completed : Complete (server)
    Requested --> Error : Error (server)
    Completed --> [*] 
    Error --> [*] 
```

The MMSettlement trade model's state model in a flat state-transition matrix:

| Source state | Event trigger | Origin | Target state |
| ------------ | ------------- | ------ | ------------ |
| [*] | - | - | Initial |
| Initial | Request | client | Requested |
| Requested | Complete | server | Completed |
| Requested | Error | server | Error |
| Completed | - | - | [*] |
| Error | - | - | [*] |

## Event message specifications

This section describes the messages sent between client and server when a state-model event occurs. The origin of an event (the client or the server) is specified in brackets after the name of the event.

The specification of some events depends on the type of financial product being traded, and when this applies, the variant specifications are detailed under level-4 headings.

Back-end developers build server events by using classes in the Caplin's FX Integration API, a Java library that makes it easy to provide data to Caplin's web applications. Where appropriate, the specifications below include references to JavaDoc documentation and code examples.

### Event: Request (client)

Message specification:

```json
{
  "trade_model_name": "MMSettlement",
  "trade_model_trigger": "Request",
  "message_origin": "client",
  "parts": [
    {
      "part_name": "SettlementAction",
      "fields": [
        {
          "name": "Action",
          "type": "string",
          "flags": "",
          "definition": "Withdraw or deposit for Call Deposit.",
          "example_value": "",
          "deprecated": false
        },
        {
          "name": "TradeID",
          "type": "string",
          "flags": "",
          "definition": "The unique id identifying the trade.",
          "example_value": "",
          "deprecated": false
        }
      ]
    },
    {
      "part_name": "SettlementInstructions",
      "parts": [
        {
          "part_name": "SettlementLeg",
          "fields": [
            {
              "name": "Un_PaySettlementId",
              "type": "",
              "flags": "",
              "definition": "The Id corresponding to the payee's settlement details.",
              "example_value": "",
              "deprecated": false
            },
            {
              "name": "Un_PaySettlementRemarks",
              "type": "",
              "flags": "",
              "definition": "The remarks corresponding to the payee's settlement details.",
              "example_value": "",
              "deprecated": false
            },
            {
              "name": "Un_PaySettlementInstructionType",
              "type": "",
              "flags": "",
              "definition": "The type of settlement instruction on the pay side.",
              "example_value": "",
              "deprecated": false
            },
            {
              "name": "Un_ReceiveSettlementId",
              "type": "",
              "flags": "",
              "definition": "The Id corresponding to the recipient's settlement details.",
              "example_value": "",
              "deprecated": false
            },
            {
              "name": "Un_ReceiveSettlementRemarks",
              "type": "",
              "flags": "",
              "definition": "The remarks corresponding to the recipient's settlement details.",
              "example_value": "",
              "deprecated": false
            },
            {
              "name": "Un_ReceiveSettlementInstructionType",
              "type": "",
              "flags": "",
              "definition": "The type of settlement instruction on the receive side.",
              "example_value": "",
              "deprecated": false
            },
            {
              "name": "Un_ReceiveSettlementType",
              "type": "",
              "flags": "",
              "definition": "The type of settlement attached to a trade. Supported types are [PRINCIPAL, INTEREST].",
              "example_value": "",
              "deprecated": false
            }
          ]
        }
      ],
      "fields": [
        {
          "name": "IsInterestSplit",
          "type": "",
          "flags": "",
          "definition": "Whether the receive instruction is split into separate principal and interest instructions",
          "example_value": "",
          "deprecated": false
        }
      ]
    }
  ],
  "fields": [
    {
      "name": "MsgType",
      "type": "String",
      "flags": "",
      "definition": "Name of the transition",
      "example_value": "Request",
      "deprecated": false
    },
    {
      "name": "RequestID",
      "type": "String",
      "flags": "",
      "definition": "The RequestID. A Unique identifier, must remain the same for each event in the trade model",
      "example_value": "",
      "deprecated": false
    }
  ]
}
```

### Event: Complete (server)

Message specification:

```json
{
  "trade_model_name": "MMSettlement",
  "trade_model_trigger": "Complete",
  "message_origin": "server"
}
```

### Event: Error (server)

Message specification:

```json
{
  "trade_model_name": "MMSettlement",
  "trade_model_trigger": "Error",
  "message_origin": "server"
}
```