A Developer’s Guide to Payment Engine System Design

The RippleX engineering team has published a new whitepaper that provides an overview of the Payment Engine (PE) system, including design concepts and examples. The PE system is a subsystem within the rippled software that is responsible for executing payments, offer crossings, and cash checks in the XRPL network, and is also used as part of the XRP Ledger’s path finding algorithm. The full whitepaper demonstrates key concepts of the PE system with several examples.

Synopsis (Super Summary)

The document provides an overview of the design concepts and examples related to the Payment Engine (PE) system, which is a subsystem within the XRPL’s rippled software. Here is a summary of the main points covered:

Payment Engine Overview

  • Payment Engine is responsible for executing payments, offer crossings, and cash checks in the XRPL network.
  • It converts payment paths into a sequence of specific steps and executes them sequentially.
  • The steps can involve different types, such as XRPEndpointStep, BookStep, and DirectStep, depending on the nature of the payment.

Design Concepts By Example

  • Several examples are provided to illustrate different design concepts and scenarios.
  • Examples include executing steps in reverse and forward directions, re-executing steps based on limitations, consuming offers at the same quality, iterative payment execution, and multi-path payment execution.
  • The examples showcase how payments are executed, how offers and liquidity are consumed, and how the system handles various scenarios.

Payments via Automated Market Maker (AMM)

  • The document discusses the integration of Automated Market Maker (AMM) functionality into the BookStep process.
  • AMM allows tokens to be traded in both directions based on mathematical formulas.
  • AMM offers are handled within BookStep and can be chosen based on spot price quality (SPQ).
  • The document explains how AMM offers are generated and resized during payment execution.

Multi-Path Payment Execution

  • The document explores the execution of payments involving multiple paths, where liquidity can be consumed from different sources.
  • Paths are sorted based on their quality, and the best quality path is executed first.
  • The document introduces a Fibonacci sequence-based approach to generating synthetic AMM offers in multi-path payments.
  • The iterative approach is used to execute multi-path payments until the requested output or input amounts are fulfilled.

The document provides conceptual understanding of the Payment Engine subsystem and helps developers delve into the coding implementation details. It demonstrates various payment scenarios, the interaction between different steps, and the considerations involved in executing payments within the XRPL network.

Read the full whitepaper here.