QX Explore - Getting started with Polymesh data
  • 💡ABOUT
    • About
    • License
    • How to Give Attribution For Usage of QX Explore - Polymesh
  • 🖥️Getting Started
    • Polymesh Network
    • Polymesh Data
    • Polymesh Metrics
  • 🔎Exploring Polymesh Data
    • Assets
    • Liquidity
    • Identities & Accounts
    • Settlements & Legs
  • 📊VIZUALIZING POLYMESH DATA
    • Assets
    • Liquidity
    • Identities & Accounts
    • Settlements & Legs
Powered by GitBook
On this page
  • Nb of settlements
  • Number of settlements by status
  • Settlements over time
  1. Exploring Polymesh Data

Settlements & Legs

Exploring Settlements and Legs

PreviousIdentities & AccountsNextAssets

Last updated 1 year ago

The settlements metrics aims to provide an understanding the dynamics of digital asset trades Polymesh network, covering key aspects of settlement activities.

Metric Category
Metric
Metric Description

Settlements

Nb of settlements

Total number of transactions settled on the network

Settlements

Number of settlements by status

Number of successful vs. failed vs rejected settlements.

Settlements

Settlements over time

Number of settlements by status by month.

Nb of settlements

This metric helps gauging the overall activity level within the Polymesh network in terms of trade settlements.

How many trades of assets have been settled on the Polymesh network?

SQL

SELECT COUNT(DISTINCT ID)
FROM 
    settlements

GraphQL

query {
  settlements {
    totalCount
  }
}

Number of settlements by status

This metric captures the operational efficiency and reliability of the settlement process on the network by differentiating between successful, failed, and rejected settlements.

How efficient and reliable is the settlement process on the Polymesh network, based on the outcomes of settlement attempts?

SQL

SELECT 
    s.result,
    COUNT(*) AS number_of_settlements
FROM 
    settlements s
JOIN 
    blocks b ON s.created_block_id::integer = b.block_id
GROUP BY 
   s.result
ORDER BY 
   s.result;

GraphQL

query {
  settlements {
    nodes {
      result
    }
  }
}

This query retrieves all the settlements and their corresponding result field. Since the provided schema doesn't support aggregation directly, you'll need to handle the grouping and counting of settlements by their result in the application code.

Possible improvement #13

To support the query for grouping and counting settlements by their result directly in GraphQL, one idea could be to modify the schema by introducing a new field in the Query type and defining a custom type for the aggregated result. Add the settlementResultCounts field to the Query type. Implement the resolver for the settlementResultCounts field in your GraphQL server.

Settlements over time

This metric provides an overview of the settlement process's outcomes on the Polymesh network, segmented into categories like successful, failed, and rejected settlements over each month.

SQL

SELECT 
    DATE_TRUNC('month', b.datetime) AS settlement_month,
    s.result as status,
    COUNT(*) AS number_of_settlements
FROM 
    settlements s
JOIN 
    blocks b ON s.created_block_id::integer = b.block_id
GROUP BY 
    settlement_month, s.result
ORDER BY 
    settlement_month ASC, s.result;

GraphQL

query {
  settlements {
    nodes {
      result
      createdBlock {
        datetime
      }
    }
  }
}

This query retrieves all the settlements along with their corresponding result and createdBlock.datetime fields. Since the provided schema doesn't support aggregation directly, you'll need to handle the grouping and counting of settlements by settlement month and result in the application code.

Possible improvement #14

To support the query for grouping and counting settlements by settlement month and result directly in GraphQL, one idea could be to modify the schema by introducing a new entity called SettlementAggregateByMonthAndResult . Add the SettlementAggregateByMonthAndResult entity theen Modify the Settlement entity to include a reference to the SettlementAggregateByMonthAndResult.

🔎
Nb of settlements
Number of settlements by status