Balmy
DCA
DCA
  • Introduction to the protocol
  • FAQ
  • Concepts
    • Positions
      • Actions
      • NFT/Permissions
      • Swap Intervals
    • Fees
    • Swaps
    • Token Integration
    • Yield Sources
  • Architecture
    • Core
      • Hub
      • Permission Manager
      • NFT Descriptor
    • Periphery
      • Companion
      • Libraries
  • Tech Guides
    • Interacting with the protocol
    • Smart Contract Registry
    • Swaps
      • Next Swap
      • Executing a Flash Swap
    • Position Management
      • Creating a Position
      • Modifying a Position
      • Withdrawing from a Position
      • Terminating a Position
    • Permission Management
    • Subgraphs
      • Playground
      • Fetch all pairs
      • Fetch all tokens
      • Fetch all active intervals
      • Fetch positions by address
    • Github
  • Mean explained by friends
    • By Perpetual Protocol
    • By Ceazor's Snack Sandwich
  • Other
    • Bug Reports
Powered by GitBook
On this page
  • Introduction
  • Responsibilities

Was this helpful?

  1. Architecture
  2. Core

Hub

PreviousCoreNextPermission Manager

Last updated 2 years ago

Was this helpful?

Introduction

In v1, we followed a Factory/Pairs approach in terms of architecture. Each pair would be a different contract and there was a factory contract that would deploy new pairs, while also keeping track of the existing ones.

Even though the approach worked, it was really expensive to deploy new contracts for each new pair, specially on Ethereum Mainnet. Another problem with this approach, was that it was very difficult to take advantage of the between different pairs when swapping.

So, for v2, we came up with "The Hub". The hub is a single contract that handles all pairs, therefore eliminating the need for deploying a new contracts. At the same time, it also makes it easier and cheaper to execute swaps for many pairs in one transaction.

Responsibilities

Since we unified all pairs in one place, the hub became the most important contract in the protocol. It is responsible for:

  • Positions

    • Creation / modification / termination

    • Withdraws

  • Swaps

    • Calculating potential swaps

    • Executing swaps

  • Config

    • Config changes

    • Pause / unpause

Coincidence of Wants
The Hub