Pisa web socket API

There is currently single deployment running for preprod network. Web socket API’s are available on the following addresses:

Balancer web socket protocol

Protocol messages examples.

Notes:

Balance CBOR request

{
  "requestId": "6fb8473d-807c-40b6-b4ca-478664b96ef4", // UUID; to match response with request during web socket communication
  "requestType": "balanceCbor",
  "payload": {
    "positionRef": "42085b8b6635404bc2ac13e65c5a5c729deb3fa689c3eb841c28685b25bd67c8#0",
    "swapAssets": [
      "919d4c2c9455016289341b1a14dedf697687af31751170d56a31466e.37343433346334313532343935343539"
    ],
    "unbalancedTxCbor": "84a300d90102818258200ce4a7e0ef6a9fb7223c09eb344f793e5676eb0a50edea42903e639bbf9784f900018182581d601305ac45084f0739a45351ffbd064acf188b74b8b67f5dd0d01cd2a31a00b71b000200a0f5f6",
    "userAddresses": [
      "addr_test1vz9zp8mp6js68755gx8y5spgszm43n6j25h38l3p922tgdsnvkqsc"
    ],
    "userChangeAddress": "addr_test1vz9zp8mp6js68755gx8y5spgszm43n6j25h38l3p922tgdsnvkqsc",
    "userCollateral": "84918cbd651d1b37a52f7708b80833c0ea293aec0ec78e0fd84d79cda99fd7a2#0" // optional (can be null)
  }
}

Balance adjusted/partially-pre-balanced CBOR request (lucid-evolution integration)

{
  "requestId": "6fb8473d-807c-40b6-b4ca-478664b96ef4", // UUID; to match response with request during web socket communication
  "requestType": "balanceAdjustedCbor",
  "payload": {
    "positionRef": "42085b8b6635404bc2ac13e65c5a5c729deb3fa689c3eb841c28685b25bd67c8#0",
    "swapAssets": [
      "919d4c2c9455016289341b1a14dedf697687af31751170d56a31466e.37343433346334313532343935343539"
    ],
    "unbalancedTxCbor": "84a300d90102818258200ce4a7e0ef6a9fb7223c09eb344f793e5676eb0a50edea42903e639bbf9784f900018182581d601305ac45084f0739a45351ffbd064acf188b74b8b67f5dd0d01cd2a31a00b71b000200a0f5f6",
    "userAddresses": [
      "addr_test1vz9zp8mp6js68755gx8y5spgszm43n6j25h38l3p922tgdsnvkqsc"
    ],
    "userChangeAddress": "addr_test1vz9zp8mp6js68755gx8y5spgszm43n6j25h38l3p922tgdsnvkqsc",
    "userCollateral": "84918cbd651d1b37a52f7708b80833c0ea293aec0ec78e0fd84d79cda99fd7a2#0" // optional (can be null)
  }
}

Balance response - Success

{
  "status": "success",
  "data": {
    "balancedCbor": "[cbor hex]",
    "requestId": "6fb8473d-807c-40b6-b4ca-478664b96ef4" // UUID; to match response with request during web socket communication
  }
}

Balance response - Failure parsing request

{
  "status": "fail",
  "data": {
    "error": "Some error happened during balancing",
    "requestId": "6fb8473d-807c-40b6-b4ca-478664b96ef4" // UUID; to match response with request during web socket communication
  }
}

Balance response - Failure while balancing

{
  "status": "fail",
  "data": {
    "error": "Some error while parsing request",
    "failedRequest": "Raw string representation of received request"
  }
}

Balance response - Server error

{
  "status": "error",
  "data": {
    "error": "Internal server error",
    "requestId": "6fb8473d-807c-40b6-b4ca-478664b96ef4" // UUID; to match response with request during web socket communication
  }
}

Indexer web socket protocol

Protocol messages examples.

Notes:

Get all positions

Get all positions - Request

{
  "requestId": "6fb8473d-807c-40b6-b4ca-478664b96ef4", // UUID; to match response with request during web socket communication
  "queryType": "getAllPositions",
  "payload": null
}

Get all positions - Response

{
  "status": "success",
  "data": {
    "requestId": "6fb8473d-807c-40b6-b4ca-478664b96ef4",
    "response": {
      "allPositions": [
        {
          "owner": "a989a5ddd49a85d9d23509037cf5b1d6eacfdf8e3518b52b29c5edc6",
          "positionRef": "42085b8b6635404bc2ac13e65c5a5c729deb3fa689c3eb841c28685b25bd67c8#0",
          "rates": [
            {
              "assetClass": "9f30db07c6ae78fe003eee54cac942401a0f0e5fd4eef3b7d5bf9ba0.3432",
              "rate": {
                "denominator": 10,
                "numerator": 1
              }
            }
          ]
        }
      ]
    }
  }
}

Get position by Out ref

Get position by Out ref - Request

{
  "requestId": "6fb8473d-807c-40b6-b4ca-478664b96ef4",
  "queryType": "getPosition",
  "payload": "42085b8b6635404bc2ac13e65c5a5c729deb3fa689c3eb841c28685b25bd67c8#0"
}

Get position by Out ref - Response - Found

{
  "status": "success",
  "data": {
    "requestId": "6fb8473d-807c-40b6-b4ca-478664b96ef4",
    "response": {
      "position": {
        "owner": "a989a5ddd49a85d9d23509037cf5b1d6eacfdf8e3518b52b29c5edc6",
        "positionRef": "42085b8b6635404bc2ac13e65c5a5c729deb3fa689c3eb841c28685b25bd67c8#0",
        "rates": [
          {
            "assetClass": "9f30db07c6ae78fe003eee54cac942401a0f0e5fd4eef3b7d5bf9ba0.3432",
            "rate": {
              "denominator": 10,
              "numerator": 1
            }
          }
        ]
      }
    }
  }
}

Get position by Out ref - Response - Not Found

{
  "status": "success",
  "data": {
    "requestId": "6fb8473d-807c-40b6-b4ca-478664b96ef4",
    "response": {
      "unknownPosition": "42085b8b6635404bc2ac13e65c5a5c729deb3fa689c3eb841c28685b25bd67c8#0"
    }
  }
}

Indexer query errors

Indexer response - Failure parsing query

{
  "status": "fail",
  "data": {
    "error": "Some error while parsing request",
    "failedRequest": "Raw string representation of received request"
  }
}

Indexer response - Failure during query execution

{
  "status": "fail",
  "data": {
    "error": "Failure reason",
    "requestId": "6fb8473d-807c-40b6-b4ca-478664b96ef4"
  }
}

Indexer response - Server error

{
  "status": "fail",
  "data": {
    "error": "Some error while parsing request",
    "failedRequest": "Raw string representation of received request"
  }
}

Web socket broadcast events

Event messages examples.

Notes:

Positions changed

{
  "eventType": "positionsChanged",
  "pisaEvents": {
    "blockHash": "65b0a360018531d9268711a3c262fa247dfddcfddb7f59be85d3442a7eb77c14",
    "newPositions": [
      {
        "owner": "c3a76bd6bfb4a4d965d92e6a579aa994edfc9219e2b1dc12fba222e0",
        "positionRef": "97f158bf405a0361754b8982d8da56166d7b20c5ddb28eef073a088aee3b922d#1",
        "rates": [
          {
            "assetClass": "1b650ba85f6590eebebe138cce94d96c62fcc332bbcfb3d9b3a11f33.53776170546f6b656e4f6e65",
            "rate": {
              "denominator": 1,
              "numerator": 100000
            }
          }
        ]
      }
    ],
    "slot": 86872779,
    "spentPositions": [
      "fe90646b03f616354da4795cc8c0f1d6e44a180c389608bcd3cf0fdea21ddf24#1"
    ]
  }
}

Rollback

{
  "eventType": "rollBack",
  "slot": 1
}