DEV Community

Cover image for How to Stand Up Your Own Participant Financial Institution (PFI)
Lymah
Lymah

Posted on • Edited on

How to Stand Up Your Own Participant Financial Institution (PFI)

Introduction

With decentralized finance (DeFi) becoming more mainstream, the need for decentralized exchanges and institutions is rising. The tbDEX protocol, developed by TBD, a subsidiary of Block (formerly Square), introduces a new way to think about financial institutions: Participant Financial Institutions (PFIs). PFIs are decentralized entities that interact with decentralized exchanges (DEXs) and serve as intermediaries in transactions.

Standing up a PFI allows an organization or individual to act as a bridge between the traditional financial system and the decentralized one. This blog will guide you through the basic steps and concepts of standing up your own PFI using the tbDEX protocol.

What is PFI?

A Participating Financial Institution (PFI) is a regulated entity that serves as a bridge between traditional financial systems and the TBDex protocol.
A PFI provides liquidity, performs identity verification, and ensures compliance with legal regulations such as anti-money laundering (AML) and know-your-customer (KYC) protocols.

PFIs are responsible for:

  • Providing liquidity
  • Managing compliance requirements
  • Processing exchanges between different forms of money
  • Maintaining proper regulatory standards

Technical Requirements

Before beginning the PFI setup process, ensure you have:

  • A robust backend infrastructure
  • Secure key management systems
  • Compliance monitoring tools
  • API integration capabilities
  • DID (Decentralized Identifier) management system

Step-by-Step Setup Process

Step 1: Understand TBDex Protocol

Before starting, it's essential to have a solid understanding of the TBDex protocol. The protocol is decentralized and operates on a peer-to-peer network, facilitating direct interactions between parties. TBDex is not an order book exchange but uses a unique approach where PFIs act as intermediaries to facilitate trades. These institutions provide liquidity, verification, and compliance services, ensuring that decentralized finance complies with regulatory requirements.

Start by reviewing the official tbDEX documentation to get an overview of the protocol and the role of PFIs.

Step 2: Establish Your DID Infrastructure

# Example of creating a DID using the TBDex CLI
tbDEX did create --method ion
Enter fullscreen mode Exit fullscreen mode

Your DID will serve as your unique identifier in the tbDEX network, enabling secure and verifiable interactions.

Step 3: Set Up Your Offering Service

Your offerings represent the exchange pairs you support. Here's a basic example structure:

{
  "offering": {
    "payinCurrency": "USD",
    "payoutCurrency": "BTC",
    "price": {
      "baseRate": "1",
      "fee": "0.01"
    },
    "payinMethods": [
      {
        "kind": "DEBIT_CARD",
        "requiredPayerData": {
          "name": "required",
          "address": "required"
        }
      }
    ]
  }
}
Enter fullscreen mode Exit fullscreen mode

Step 4: Implement Required APIs

Your PFI must implement several core APIs:

  • GET /offerings
  • POST /rfq (Request for Quote)
  • POST /orders
  • GET /orders/{id}

Step 5: Compliance Integration

Set up your compliance stack to handle:

  • KYC/AML checks
  • Transaction monitoring
  • Regulatory reporting
  • Risk assessment

Code Example: Basic PFI Server Setup

import { tbDEX, PFI } from '@tbdex/protocol';
import express from 'express';

class MyPFI extends PFI {
  async handleRfq(rfq: Rfq): Promise<Quote> {
    // Implement your quote generation logic
    return {
      id: generateId(),
      price: calculatePrice(rfq),
      expiresAt: new Date(Date.now() + 300000) // 5 minutes
    };
  }

  async handleOrder(order: Order): Promise<void> {
    // Implement order processing logic
    await processOrder(order);
  }
}

const app = express();
const pfi = new MyPFI();

app.post('/rfq', async (req, res) => {
  const quote = await pfi.handleRfq(req.body);
  res.json(quote);
});

app.post('/orders', async (req, res) => {
  await pfi.handleOrder(req.body);
  res.sendStatus(200);
});

app.listen(3000);
Enter fullscreen mode Exit fullscreen mode

Resources for Setting Up Your PFI

  • tbDEX YouTube Introduction: This YouTube video explains the basics of the tbDEX protocol, including how PFIs operate within the network.
  • tbDEX PFI Overview: The official tbDEX PFI documentation is the most comprehensive guide for understanding the protocol.
  • PFI Quickstart: Learn PFI on tbdex in 5 Minutes

Top comments (0)