Perp88 Has Adopted The Diamond Standard (EIP-2535)

Rockman Perp88
Perp88
Published in
4 min readFeb 7, 2023

Perp88 is the first Decentralized Perpetual Exchange to have implemented the “Diamond Standard” on its smart contract on Polygon. Today, we will explain what this state-of-the-art architecture is and how it benefits the protocol!

What is Diamond Standard (EIP-2535)?

The Diamond Standard is a new, state-of-the-art smart contract architecture for upgradeable contracts. Previously, the DeFi space has widely used the Upgradeable Proxy pattern to enable the ability to upgrade smart contracts after deployment, allowing DeFi projects to add new requirements and features to adapt to the fast-changing DeFi landscape.

However, the Upgradeable Proxy pattern has a few limitations. One of which is the size limit. The Upgradeable Proxy pattern places a limit on the maximum contract size, which is currently set at 24.576 kb. Therefore, if the size of the original contract has reached the limit, new features cannot be added to the smart contract.

That is where the Diamond Pattern comes in. The Diamond Pattern solves this problem by introducing a new architecture that separates the contract storage from the contract logic. This allows for virtually unlimited contract size, enabling DeFi projects to innovate repeatedly on their protocols without the need for tedious and risky migrations for users.

Example Diagram of the Diamond Pattern Architecture from EIP-2535

How does Diamond Pattern work?

The Diamond Pattern consists of a single smart contract, which acts as the contract storage or database for the protocol. In the case of Perp88, this contract is called the “Pool Diamond” contract and can be found on PolygonScan here.

The Pool Diamond contract only contains minimal code and business logic. The actual business logic and code reside in smart contracts called “facets.” The Pool Diamond contract only functions as the execution layer, executing transactions of the protocol by leveraging codes from the selected “facet” relevant for that particular transaction.

Is the Diamond Pattern safe and secure?

The Diamond Pattern has been assigned EIP-2535 in the Ethereum Improvement Proposal and has received a “Final” status, which means that it has been reviewed and approved by the developers and community of Ethereum. This ensures that, by design, the Diamond Pattern is secure and ready for production use.

However, there are still risks associated with upgradeable smart contracts. Since these smart contracts can be upgraded, malicious DeFi protocols can modify their smart contracts with malicious codes. To enhance the security for user’s funds and add credibility to the protocol, Perp88 implements a “Timelock” contract with a delay of 24 hours.

The Timelock contract, which can be found here, will be the owner and governance of all Perp88’s smart contracts. Any updates to the parameters and contracts will need to go through the Timelock contract, which means that there will be a delay of 24 hours before the updates take effect.

With this adjustment, the community will have enough time to verify the validity of changes made to the contract. If the updates are questionable, the community will have enough time to react to the update and withdraw funds from the protocol before the update takes effect.

Why am I not able to see the public functions of Perp88’s smart contract?

PolygonScan currently does not support the Diamond pattern yet. Therefore, users will not be able to see the public functions and interact with them via PolygonScan.

If PolygonScan does not support the Diamond pattern, how can you interact with the Perp88’s smart contract directly?

If you would like to interact directly with the Perp88’s smart contracts, there is a tool called “Laika” which is a smart contract explorer.

Our Docs contains a step-by-step guide on how to interact with our smart contracts directly using Laika as well as the set up process. The guide can be found here.

Where can I find the code of Perp88 on PolygonScan? Are they verified contracts

The actual logic and code of Perp88 will reside in the smart contracts called “facets” as previously mentioned. You can view them on our Github repository here.

To validate that these smart contracts match the actual contracts deployed on the blockchain, you can check them by going to the contract addresses of all facets found here. Browse these contracts on Polygonscan to see the smart contract codes. For example, this is the link for the “PerpTradeFacet,” which contains logic for perpetual trading.

Official Perp88 Links:

Below are the official links for Perp88:

Website DocsTwitter TelegramTelegram Announcement Medium Discord Github

--

--

Rockman Perp88
Perp88
Editor for

Strategy @ Perp88 — The premier decentralized perpetual exchange with the best economics on Polygon