LibertyPie Core

Version 1.0

November 2020


This document describes a trustless, permissionless & autonomous P2P and DeFi protocol that will enable anyone to buy or sell selected cryptocurrencies instantly & securely.


In 2019, the P2P marketplace had a total volume of $2.9 billion on LocalBitcoins and $1.6 billion on Paxful with other regional and global exchanges accounting for over $5 billion.

2020 and beyond is expected to surpass all previous years in terms of trading volume with India’s P2P marketplace processing a trade volume of up to $4.4 million per week.

Global giants in the cryptocurrency exchange sector such as Binance &  Huobi have also tapped into the P2P market to bring more adoption to the masses.

Peer-to-Peer crypto-asset trading is a unique form of market where users trade directly within themselves without a middleman.


The revolution of cryptocurrencies has given birth to several innovative products such as centralized exchanges including P2P platforms with Paxful and Localbitcoin as few examples.

Recently, most people are not very happy with centralized P2P platforms.

By default, most P2P platforms limit users’ accounts thereby restricting transactions.

Most users have to go through a lot of stress to lift these limits which might seem impossible in emergency cases.

Since most centralized P2P exchanges hold custody of their users’ funds, these funds are always at risk because they are saved on the server’s hot wallet which is highly susceptible to hacking.

Other times, users are denied access to their assets by disabling withdrawal, this can cause frustrations on the side of the user. As the popular saying goes:

 Not your keys, not your coins”

Finally, most P2P platforms have been an avenue for fraudsters where innocent people are duped simply because they want to trade.


We believe all technologies should be accessible to anyone and at any place in full without restrictions or limits.

Moreover, the main reason for the invention of the blockchain & cryptocurrencies is to give people the advantage of becoming keepers of their own funds, like the slogan goes, be your own bank. So keeping custody of users' funds to use a platform is highly against the principle of blockchain and decentralization.

LibertyPie Protocol

LibertyPie v1 is the first version of the protocol, developed in 2020 on the Ethereum & Binance Smart Chain (BSC) which would later be deployed on other blockchain platforms.

The protocol was developed to be permissionless & autonomous, due to this nature, it will exist as long as the blockchain it was deployed on exists. It is a trustless, non-custodial & smart contract-based P2P exchange with cross-chain asset support & a fraud protection mechanism.

LibertyPie is not a company or firm, but rather a code, it is governed by the DAO (Decentralized Autonomous Organization) structure of governance, where no individual, entity, or corporation owns the network but rather decision making is based on codes (smart contracts) and by the efforts of the community.

Key Features

Design Principle

LibertyPie is built to be 100% decentralized, open-sourced, and deployable on most EVM based public blockchains.

Anyone can design their own user interface to interact with the protocol.  

Most features are built with modularity in mind, this way a module can be replaced using its contract address.

Price Feeds & Oracles

Price feeds  & oracles are one of the essential modules of the protocol, LibertyPie cannot work as required without an up to date price feed of supported assets.

Fortunately, the protocol natively supports different price feeds sources & oracles.

Cross-chain oracles such as ChainLink & Band Protocol are supported on both deployed versions on Binance Smart Chain and Ethereum.

On the other hand, PancakeSwap price feeds are supported on Binance Smart Chain while Uniswap & Compound’s open price feeds are supported on Ethereum.

Unisawp Based Price Feeds

Uniswap & PancakeSwap uses a Uniswap v2 based smart contract,  this has direct support for price feeds.

function getAmountsIn(uint amountOut, address[] memory path) internal view returns (uint[] memory amounts);

The above code demonstrates how to get the latest price between two assets using the Uniswap v2 smart contract.

Compound’s Open Price Feed

Compound’s open price feed is only supported on Ethereum, it adds an extra layer against vector attacks by combining Coinbase oracle with Uniswap price feeds.

UniswapAnchoredView view = UniswapAnchoredView(0xABCD...);

uint price = view.price("ETH");

Using open price feed to fetch the latest price for Ethereum


Offers are ads presented by traders to buy or sell a particular asset under their terms.

Users have the liberty to create a new offer, modify or disable an existing offer. All offers are saved on the blockchain, some metadata such as the offer description and terms are stored on decentralized file storage such as IPFS to avoid the additional gas cost.

To create a new offer from the contract, call the newOffer method as shown below.

function newOffer(

       address  _assetAddress,

        string  memory _offerType,

        uint256  _priceMargin,

        string   memory countryCode,

        uint256  paymentTypeId,

        uint256  expiry,

        string extraDataHash 

    ) external

_assetAddress: The contract address of the asset you wish to create the offer for, note that the offer creation will fail if the asset is not supported

_offerType: The offer type, it’s either  buy or sell

_priceMargin:  The profit or loss percent added to the asset price, this helps in the calculation of the final price for the asset.

countryCode:  A two-letter iso code of the offer  target country, for example, CA  for Canada

paymentTypeId: The targeted payment type for the offer,  this parameter is of the type uint256. Payment types & their ids can be fetched with the contract code below

function getAllPaymentTypes() external view returns( PaymentTypeStruct[] memory  )

expiry: set this parameter greater than 0 if you wish the offer to expire after some time. Expiry is implemented as

bool hasOfferExpired  = (OfferEntry.expiry > 0) && (OfferEntry.expiry < block.timestamp);

extraDataHash:  This is the hash of extra data such as trade terms and instructions stored on decentralized storage protocol IPFS.

Offer Pricing Mechanism

An offer price is calculated using the asset’s market price summed with the price margin percentage provided during the offer creation.



Starting a trade on LibertyPie initializes as a gasless operation,  the trade data is encrypted and temporally stored on IPFS until the asset to be traded has been deposited into the escrow contract.

As a  security measure, the escrow in a trade won’t be executed until both parties are online and ready to proceed with the trade.

The following pattern depicts  a trade on LibertyPie

Data Security & Privacy

During every trade, a unique asymmetric public-private keypair is generated for each participant of the trade including guardians.   The public keys from these keypairs are exchanged while keeping the private keys to only their owners.

Data exchanged during trades such as payment details & chat messages are very private and mostly restricted to the trade participants; this is where the exchanged public keys are used in encrypting data between the participants.

Data Encryption Algorithm

Data transfer between the participants is always done using a secure HTTPS connection but most of the content and documents stored on IPFS such as chat messages are encrypted before storage.

The encryption is done using the state of the art military grade level encryption algorithm AES-GCM (  Advanced Encryption Standard in Galois/Counter Mode) inside the user’s browser.

Client Side KeyPair Generation

 let key = window.crypto.subtle.generateKey(


      name: "AES-GCM",

      length: 256



    ["encrypt", "decrypt"]


Client Side Data Encryption

async function encrypt(string,key) {

  let encoded = new TextEncoder().encode(string);

  let iv = crypto.getRandomValues(new Uint8Array(12));

  let encrypted = await crypto.subtle.encrypt({"name":"AES-GCM","iv":iv}, key, encoded);

  return encrypted = {"encrypted":encrypted, "iv": iv};


Client Side Data  Decryption

async function decrypt(encrypted,iv, key) {

  let decrypted = await crypto.subtle.decrypt({"name":"AES-GCM","iv":iv}, key,encrypted);

  let decoded = new TextDecoder().decode(decrypted);

  return decoded;


User Rating

Every user on the network will be rated based on their trade and feedback from other traders. After every successful trade, both parties will have a +1 rating, moreover, a merchant or the initiator can decide to give feedback using the rating widget after the trading closes.

Guardians summoned to moderate a trade can also rate any of the parties based on their behavior. Users with the best rating will have their offers shown on top of the offer list always.

In rare cases, the community can vote on banning a merchant if any dubious activity is suspected.

Trading Fee  

Every successful trade on LibertyPie will attract a 0.25% fee, this fee will be taken automatically from the asset deposited into the escrow contract.

If the trade fails or is canceled, the fee will not be charged as no transaction took place.

Trade Rewards

As part of the token distribution plan, traders involved in every successful trade will receive an amount of XPIE tokens, this is to help boost user adoption and also to compensate the traders for the gas used.

XPIE Token rewards will be distributed to traders based on the amount traded. Both the buyer and seller will receive the reward once the trade is completed successfully.

Trade Moderation

When starting a trade, the user can optionally enable a guardian (mediator) involvement in the trade, the guardian will supervise the trade from start to finish, this will help spot fraud by any of the parties even before it happens.

During the trade, the initiator or merchant can summon a guardian immediately to moderate the trade if it was not done during the start of the trade.


A guardian is anyone willing to dedicate his or her time and effort to help protect the network against fraud and bad actors for a reward.

Guardians help in moderating a trade if optionally added to the trade, they must also respond to the summons of a trader any time during a trade.

Secondly, guardians help in dispute resolution on the network.

If any trader or merchant has a problem with a trade, they can seek a dispute resolution where a minimum of 3 guardians is tasked to solve the issue.

Guardians are rewarded from the fee vault collected from trades at the end of the month.

Becoming a Guardian

To become a  guardian, you need to stake at least 10,000 XPIE  tokens in the guardian contract.

After the staking, you will need to open a proposal on why the community should vote and accept you as a guardian.

If the majority of the votes approve your position as a guardian, you will be automatically approved on the guardian contract. If you are voted against as a guardian, You will need to unstake your XPIE  tokens from the guardian contract.

Guardians Rating

Guardians are rated based on the feedback from the traders and successful operations handled. This helps eliminate the bad from the good. If a  guardian misses more than 3 summons, 50 XPIE will be deducted from his staked account.

Also once a guardian’s staked tokens amount goes below 10,000 XPIE, the guardian will be disabled from being summoned and thus will not be rewarded on trades.

In extreme cases, guardians can be blacklisted, in rare situations like this, the guardian will lose all his staked XPIE tokens.

Guardians Rewards

Guardians will earn from two different sources:

  1. DeFi Vault: Staking in the guardian contract will mint a GPIE token which can be staked into the DeFi vault for yields.
  2. Every successful trade attracts a fee of 0.25%  which 0.1%  is distributed to the guardians either summoned or on standby.

Offline Mode

Guardians are free to set an offline mode if they wish to take a break, this way, they won’t be punished by the network for not responding to the summons of traders.

Note: Once you are on offline mode, rewards from fees will be cut off. DeFi vault’s earnings won’t be affected.

XPIE Governance Token

XPIE is the native governance token for the LibertyPie protocol.

Currently, it has a total supply of 990,000,000 XPIE.

The protocol’s decision making and future improvements depend on the community of XPIE token holders.

Holders can vote on proposals or start a new proposal to be voted on.

Any address with 9,900,000 XPIE (1% of current XPIE max supply)  or more delegated to it is eligible to start a new governance proposal which is an executable code.

All proposals have a maximum of 3days voting period.

If a proposal reaches 495,000,000 votes (5% of current XPIE max supply) or more, it will be considered as passed and will be queued in the TimeLock contract which will be executed after 3days.

Token Distribution

The tokens are distributed in a free and fair manner; the community is the first-class citizens on the network, so 50% of the total supply will be allocated to them.

Community Allocation:  50%

This will be distributed to the community through different events and mechanisms over a period of time. Below is the distribution table.


Distribution Treasury















Team Allocation: 20%

This allocation goes to the team members, co-founders & advisory board, there will be a  vesting period of 36 months where the tokens will be locked into a smart contract, after this period, 10% will be released for every 3 months interval.

Initial Fund Raising: 25%

This is the initial funds needed to run the project, listing on exchanges, providing liquidity, marketing and temporally paying the developers.

Ecosystem Fund: 5%

This fund will be used for strategic partnership & incentivization to grow the network.

LibertyPie DeFi

LibertyPie protocol is not only for P2P only but has DeFi features where token holders can benefit from staking selected assets into the DeFi vault. Rewards in the DeFi vault will be given in XPIE tokens.

Using multiple strategies that will be created by the team and community, the vault will select the best yields for users who stake their assets.


Bisq Network

Bisq is one of our closest competitors, Bisq is a decentralized bitcoin exchange network. Bisq has distributed its application for major platforms like Windows / macOS creating a decentralized network to allow users to trade.

LibertyPie on the other hand takes a stepwise approach to gain maximum volume/liquidity by providing access to an easy-to-use web interface to reduce the hustle of onboarding and allowing altcoins to pair with fiat directly.


LocalCryptos is a peer‐to‐peer custody‐less encrypted marketplace for buying and selling ether selected crypto assets. Though they boast of being a decentralized marketplace, much of their implementation relies heavily on centralized servers which they host and maintain.

Moreover, users must go through the hustle of creating accounts where personal data are collected which defeats the principle of decentralization.

LibertyPie unleashes the power of smart contracts to achieve 100% decentralization without compromising liberty & privacy.