PaintSwaps - P2P Swap

PaintSwap
Paint Swap Finance
Published in
6 min readNov 10, 2022

Trustless Peer-to-Peer Swapping of NFTs on PaintSwap

Continuing in our standing mission of filling gaps both seen and unseen in our current market of Fantom Opera, PaintSwap has recently released the P2P (Peer-to-Peer) Swap. While this release was motivated by the needs of the Fantom community, the experience and technology are superior to that of similar offerings from other services and across other chains. This article will discuss the motivation for, use of, and technology behind the P2P Swap.

The Need

As we’re all aware, malevolent users are easy to encounter in crypto and NFT spaces, leaving users rightfully suspicious of offers that might otherwise be exciting and lucrative. Trading within or across NFT collections is one type of offer that often comes from these malevolent users. To empower our users to both take advantage of opportunities and avoid being taken advantage of, PaintSwap developed the non-custodial, trustless P2P Swap. By removing the risk of a single-sided send and the inconvenience of an escrow participant, we’ve put the power in the hands of the traders.

We filled this need on the Fantom Opera chain, but, in our research, found that these services were lacking on many chains. In accordance with our roadmap, which calls for our eventual expansion onto other chains, we developed a positive experience for all involved. User experience remains a top priority for PaintSwap. On-chain offer data, signing, and verified/non-verified indicators are a few ways that we’ve done this.

The Product

P2P Swap is easy by design and can be accessed from two locations on the site: the header and a user’s profile. If the swap originator is already aware of the target wallet for the trade, they simply click the Swap button on the top bar of the site, enter the address into the “Swap with User” field, and click the “Start Swapping” button just below the text field. If the originator knows the NFT for which they want to trade, the Swap can also be initiated by navigating to the owner of the NFT via the Info card on the asset page. From there, the “Swap” button is available at the top of the user profile. Both of these routes lead the originator to the two-sided Swap page. This interface does not have to be used in real-time with the Swap recipient

Once on the Swap page, clicking “Select My NFTs” or “Select Their NFTs” allows the originator to begin constructing their initial offer. Simply click on the items to be traded, and they will be bordered in yellow, indicating successful selection. When selection within the wallet is complete, you may click either the “✔” in the bottom right corner of the grid or anywhere outside of the modal to move on to selections in the other wallet. Note that all NFTs listed in the “Offering” wallet must be approved before the “Propose Swap” action will become available. There may be up to eight NFTs included on each side of the Swap.

Once these steps are completed, clicking the “Propose Swap button” will do two things. Firstly, the fixed fee of 5 FTM per swap will be assessed. Both the originator and the recipient will pay this fee (only if the recipient interacts with the swap). Secondly, the function setUpSwap is called from the Marketplace contract, writing the data of both offered and expected NFTs for both users on-chain. Both the fee and the on-chain metadata are functions designed to deter malevolent and spam offers. Additionally, there is a “Refresh On-Chain Data” button, which forces an update to the UI that then reflects the latest on-chain information. That is very important given the finality of the Swap. Before a Swap can be accepted, this refresh will be required if the on-chain data doesn’t match the displayed data. Swaps can be revised at any time by either party prior to Swap acceptance.

When the recipient is reviewing the Swap, they can “Accept Swap”, “Counter Offer”, or “Cancel Swap”. To counter an offer, the same steps described above for the initial offer must be followed. There are no restrictions on the counter offer, and the recipient may change any or all of the NFTs involved. Counter Offer also calls the setUpSwap function, overwriting the on-chain Swap data. Once the recipient has countered, the originator has the same opportunity. There is no maximum on counters. Either party may cancel the swap at any time prior to acceptance. The “Accept” button calls the acceptSwap function on the Marketplace contract, which completes the Swap.

Analytics

Swap history can be viewed in several places. When engaged with another account on the Swap page itself, the Swap history between those two accounts is displayed beneath the interface in an Activity area. Additionally, any account’s swap history may be viewed from its profile in the Swaps tab. The default view shows all Active and Accepted Swaps.

Use the Show All Events toggle to display more detailed history of Swap activity. Additional events shown by the toggle include New Swap, Counter Offer, and Revised Offer.

From the Activity area of our Stats page, Swaps is now a selectable tab. This will show all “Accepted”, “Ongoing…”, and “Cancelled” Swaps by default, but can also reveal the same level of granularity as the individual Swap history. This area may also be accessed by clicking “Global Swaps” in the upper right-hand corner of the Swaps interface.

Swapping Guide — (Available in Swap Interface)

Up to 16 NFTs (8 on both sides) can be swapped at once, with any user. A fee of 5.0 FTM is required to initiate a swap. The other party must also pay the same fee when accepting the swap, or making the first counter-offer. No extra fees are required, regardless of the number of counter offers made. The total fees for a successful swap are split 50–50 and are non-refundable.

  1. Select those you would like to offer from “My NFTs”, and then select what you expect to receive in return from “Their NFTs”.
  2. The other user will either accept, counter-offer with different NFTs or reject the swap.
  3. If counter-offered: Validate the NFTs and either accept the swap or start over with step 1.

Note: The other user can change the NFTs at any time. If accepting fails, click “Get Latest Onchain Data” and check the NFTs again and the latest history, and also note the number of unverified NFTs being offered. Users may be trying to scam you with fake NFTs with the same image, so if in doubt clear and select again from scratch. When accepting a swap, the contents of the offering & expected NFT tables are passed to the contract to validate the on-chain data to ensure there is no chance of being front-run when accepting.

--

--