Skip to content

A graph pathfinding approach to FX liquidity challenges

Anthony Butler
2 min read

In blockchain networks that are focused on enabling PvP cross-border payments, such as the BIS Innovation Hub’s mBridge, addressing the FX conversion requirement is important.

There may be a challenge with these multi-currency payment networks around the liquidity of certain currency pairs.  This can, of course, be solved by using an external market maker or a commonly traded currency such as the USD as a vehicle currency – but this may diminish one of the core value propositions of these types of networks.  Further, we can conceive of a future where, with increasing amounts of non-cash assets being tokenized, a more diverse set of assets may be used to effect cross-border trades.

In thinking about possible approaches, a graph theoretic mechanism to identify optimal currency conversion paths, even in scenarios where direct conversions face liquidity challenges, could be useful.  It would, in essence, find a set of paths through one or more conversions that, taken in aggregate, optimize for the lowest total cost of conversion whilst adhering to liquidity constraints in the network.

The idea would be as follows:

Step 1: Build a Graph Representation:

Build a graph representing the market:

1.     Each currency (or asset) is a node on the graph.

2.     Every edge is directional reflecting the conversion between two currencies (nodes).

Step 2: Edge Weight Calculation:

Each edge is assigned two distinct weights:

a)     The inverse of the FX rate, ensuring that stronger currencies are more favorable. This weight essentially captures the cost of conversion.

b)    The available liquidity for that conversion. This weight indicates the maximum volume that can be converted directly between the two currencies without exhausting available resources.

c)     These both values could be constantly updated to reflect real-time pricing via an Oracle or some other mechanism.

Step 3: Pathfinding with liquidity constraints

Find all paths between the source and target currency nodes:

1.     Using a variation of the Bellman Ford algorithm, the system identifies potential conversion paths from a source currency to a destination currency.

2.     The algorithm is tailored to not only look for the most cost-effective path but to also explore multiple viable paths. This multi-path exploration ensures redundancy and provides flexibility in addressing liquidity constraints.

Step 4: Transaction allocation across multiple paths:

1.     After identifying multiple potential paths, they are ranked based on their associated conversion costs.

2.     For each path, the "bottleneck liquidity" is noted — this is the smallest liquidity value among all the edges in that path.

3.     Starting with the most cost-effective path, the system checks if the desired transaction amount can be handled by the path's bottleneck liquidity. If the transaction amount exceeds this liquidity, the maximum possible amount is converted using this path, and the remaining amount is allocated to the next best path. This process continues iteratively, ensuring that liquidity constraints are always respected while achieving the most favorable conversion rate.

Step 5: Execution:

1.     The conversion instructions, based on the final allocation across multiple paths, are executed. This ensures that each individual conversion stays within the liquidity constraints of its respective path, while collectively achieving the best possible rate for the entire transaction.

In essence, this approach ensures that conversions in the multicurrency blockchain network are executed at optimal rates while always respecting liquidity constraints. It provides a balanced and flexible solution, especially beneficial for currency pairs that are less commonly traded.

Anthony Butler Twitter

Anthony is a currently Chief Architect for a Saudi government entity focused on establishing the Kingdom's leadership in AI globally. He previously held senior roles with Saudi Central Bank and IBM.