A perpetual DEX with a price feed integrity proof using ZK-SNARK circuits.
Most of the perpetual DEXs are not operated transparently at some extent, as they somehow rely on the centralized services. As fully decentralized system is hard to support complicated exchange mechanisms, most of the leading DEXs or related services like DyDx, GMX, Chainlink, etc. try to mitigate such problems by making the structure semi-decentralized, in other words, they turn a certain portion of their system into centralized servers. As things get centralized, becomes harder to fully trust their service, even harder when it comes to trading real money. It comes to questions like βwas my liquidation really valid?β βwas my order executed at the proper price?β
Hence, we introduce a simple perpetual DEX with ZK-SNARK proof of the oracle price feed data integrity. We use ZK-SNARK (Groth16) circuits to provide validity proofs of that the price feed data was calculated properly, with no manipulation. Still not revealing the exact formula and weights for calculating the mark price from different data sources, Rise Finance is even more resistant to DeFi exploits like oracle price manipulation attacks. ZK conceals how the price data is exactly calculated, but still guarantees that it follows the rules of price aggregation which is defined in the circuit. This enables oracle-based perpetual DEX protocols to have an βauthenticβ price feed of their own.
A price feed of a oracle-based perpetual DEX is meant to be aggregated and then interpolated from many other external sources like Binance, Coinbase, and Bybit. In order to prove that the price feed for our DEX was properly interpolated among the sources we released in advance, we generate a validity proof of the operation using ZK-SNARK every time it is aggregated and then interpolated. However, we conceal the exact interpolation weights, in order to make it harder to track down the exact sources we are using; in other words, to make our price more 'authentic'. The SNARK proof always guarantees the actual execution price of a specific order(market order, liquidation, etc.) is equal to the properly interpolated values obtained previously. If nobody knows how it is forged, then it is original. It makes DEX immune to price manipulation attacks.
We have implemented a simple oracle & pool based perpetual DEX with Solidity so that it could run on any EVM compatible chains. Most of the exchange logics are operated fully on-chain, and the only data injected to the system from off-chain is the real-time price data aggregated from different price sources, proven its validity and calculation integrity with our SNARK circuits.