# ZKSwap 2.0 Markdown version of https://l2beat.com/layer2s/projects/zkswap2 ## Summary **Warning:** This project is archived and no longer maintained. - Total Value Secured: $165.31 K (-0.91% compared to seven days ago; canonically bridged $165.31 K, natively minted $0.00, externally bridged $0.00; 0.00% with additional trust assumptions compared to the tokens involved and the Stage assigned to the project's canonical messaging bridge) - Type: ZK Rollup - Purposes: Payments, Exchange - Host chain: Ethereum ### Risks - Sequencer failure: Force via L1 (sentiment: good) - State validation: Validity proofs (SN) (sentiment: good) - Data availability: Onchain (sentiment: good) - Exit window: Unknown (sentiment: bad) - Proposer failure: Use escape hatch (sentiment: good) ### About ZKSwap 2.0 is a fork of ZKsync with added AMM functionality. Based on ZK Rollup technology, ZKSwap aims to execute the full functionality of Uniswap on Layer 2, but increase the TPS, and make transaction processing cheaper. ## Value Secured Shown as an interactive chart or widget on [the HTML page](https://l2beat.com/layer2s/projects/zkswap2#tvs). - [TVS chart (JSON)](https://l2beat.com/api/scaling/tvs/zkswap2) - [TVS breakdown by token (JSON)](https://l2beat.com/api/scaling/tvs/zkswap2/breakdown) ## Risk summary **Warning:** 3 addresses have unverified source code (CRITICAL). - ZkSyncExit: 0xC0221a4Dfb792AA71CE84C2687b1D2b1E7D3eea0 - VerifierExit: 0xb56878d21F6b101f48bb55f1AA9D3F624f04E513 - UpgradeGatekeeper: 0x0DCCe462ddEA102D3ecf84A991d3ecFC251e02C7 **Warning:** Version 3 of the protocol called ZkSpace is available and users are encouraged to move their assets there. ### Funds can be stolen if 1. a contract receives a malicious code upgrade. There is a 8 days delay on code upgrades, 2. the source code of unverified contracts contains malicious code (CRITICAL). ### Funds can be lost if 3. the user is unable to generate the non-trivial ZK proof for exodus withdraw. ### Users can be censored if 4. the operator refuses to include their transactions. However, there exists a mechanism to independently exit the system. ### MEV can be extracted if 5. the operator exploits their centralized position and frontruns user transactions. ## Risk analysis **Warning:** Version 3 of the protocol called ZkSpace is available and users are encouraged to move their assets there. ### Sequencer failure Force via L1 (sentiment: good) Users can force the sequencer to include a transaction by submitting a request through L1. If the sequencer censors or is down for , users can use the exit hatch to withdraw their funds. ### State validation Validity proofs (SN) (sentiment: good) SNARKs are succinct zero knowledge proofs that ensure state correctness, but require trusted setup. ### Data availability Onchain (sentiment: good) All of the data needed for proof construction is published on Ethereum L1. ### Exit window Unknown (sentiment: bad) Some contracts are not verified, so there is no way to assess the exit window. ### Proposer failure Use escape hatch (sentiment: good) Users are able to trustlessly exit by submitting a zero knowledge proof of funds. ## Data availability ### All data required for proofs is published onchain All the data that is used to construct the system state is published onchain in the form of cheap calldata. This ensures that it will always be available when needed. **References** - [ZKSwap Introduces Practical ZK Rollups - Medium blog](https://medium.com/zkswap/zkswap-introduces-practical-zk-rollups-zkspeed-achieving-high-tps-and-low-gas-fees-in-real-6effe4e789e0) ## State validation ### Validity proofs Each update to the system state must be accompanied by a ZK proof that ensures that the new state was derived by correctly applying a series of valid user transactions to the previous state. These proofs are then verified on Ethereum by a smart contract. **References** - [ZKSwap Introduces Practical ZK Rollups - Medium blog](https://medium.com/zkswap/zkswap-introduces-practical-zk-rollups-zkspeed-achieving-high-tps-and-low-gas-fees-in-real-6effe4e789e0) ## Updates Shown as an interactive chart or widget on [the HTML page](https://l2beat.com/layer2s/projects/zkswap2#updates). ## Operator ### The system has a centralized operator The operator is the only entity that can propose blocks. A live and trustworthy operator is vital to the health of the system. **Risks** - MEV can be extracted if the operator exploits their centralized position and frontruns user transactions. **References** - [ZKSwap Validator - ZKSwap wiki](https://en.wiki.zks.org/techonology#3-validator) ### Users can force exit the system Force exit allows the users to escape censorship by withdrawing their funds. The system allows users to force the withdrawal of funds by submitting a request directly to the contract onchain. The request must be served within a defined time period. If this does not happen, the system will halt regular operation and permit trustless withdrawal of funds. **Risks** - Users can be censored if the operator refuses to include their transactions. However, there exists a mechanism to independently exit the system. **References** - [ZkSync.sol#L404 - ZKSwap source code](https://github.com/l2labs/zkswap-contracts-v2/blob/master/contracts/ZkSync.sol#L404) ## Withdrawals ### Regular exit The user initiates the withdrawal by submitting a regular transaction on this chain. When the block containing that transaction is settled the funds become available for withdrawal on L1. ZK proofs are required to settle blocks. Finally the user submits an L1 transaction to claim the funds. **References** - [Make Transaction](https://en.wiki.zks.org/interact-with-zkswap/make-transaction#withdraw) ### Forced exit If the user experiences censorship from the operator with regular exit they can submit their withdrawal requests directly on L1. The system is then obliged to service this request. Once the force operation is submitted and if the request is serviced, the operation follows the flow of a regular exit. **References** - [ZkSync.sol#L404 - ZKSwap source code](https://github.com/l2labs/zkswap-contracts-v2/blob/master/contracts/ZkSync.sol#L404) ### Emergency exit If the enough time deadline passes and the forced exit is still ignored the user can put the system into Exodus Mode, disallowing further state updates. In that case everybody can withdraw by submitting a zero knowledge proof of their funds with their L1 transaction. **Risks** - Funds can be lost if the user is unable to generate the non-trivial ZK proof for exodus withdraw. **References** - [ZkSyncCommitBlock.sol#L230-L246 - ZKSwap source code](https://github.com/l2labs/zkswap-contracts-v2/blob/3f650d28a266a56d49a3b3d2049cde34112efb14/contracts/ZkSyncCommitBlock.sol#L230-L246) ## Permissions ### Ethereum #### Actors ##### zkSwap 2.0 Admin Addresses: [0x9D7397204F32e0Ee919Ea3475630cdf131086255](https://etherscan.io/address/0x9D7397204F32e0Ee919Ea3475630cdf131086255) This address is the master of Upgrade Gatekeeper contract, which is allowed to perform upgrades for Governance, Verifier, VerifierExit, PairManager and ZkSync contracts. ##### Active validator Addresses: [0x38101ae98196C8BCf7dF1835Bf3983B384272ae4](https://etherscan.io/address/0x38101ae98196C8BCf7dF1835Bf3983B384272ae4) This actor is allowed to propose, revert and execute L2 blocks on L1. A list of active validators is kept inside Governance contract and can be updated by zkSwap 2.0 Admin. ## Smart contracts ### Ethereum #### ZkSync Addresses: [0x6dE5bDC580f55Bc9dAcaFCB67b91674040A247e3](https://etherscan.io/address/0x6dE5bDC580f55Bc9dAcaFCB67b91674040A247e3#code), [0xf2c351f22b148A9fF583a0F81701471a74E7338e](https://etherscan.io/address/0xf2c351f22b148A9fF583a0F81701471a74E7338e#code) (Implementation (Upgradable)), [0x0DCCe462ddEA102D3ecf84A991d3ecFC251e02C7](https://etherscan.io/address/0x0DCCe462ddEA102D3ecf84A991d3ecFC251e02C7#code) (Admin) The main Rollup contract. Operator commits blocks, provides ZK proof which is validated by the Verifier contract and process withdrawals (executes blocks). Users deposit ETH and ERC20 tokens. This contract defines the upgrade delay in the UPGRADE_NOTICE_PERIOD constant that is currently set to 8 days. #### ZkSyncCommitBlock Addresses: [0xE26Ebb18144CD2d8DCB14cE87fdCfbEb81baCAD4](https://etherscan.io/address/0xE26Ebb18144CD2d8DCB14cE87fdCfbEb81baCAD4#code) Additional contract to store implementation details of the main ZkSync contract. #### ZkSyncExit Addresses: [0xC0221a4Dfb792AA71CE84C2687b1D2b1E7D3eea0](https://etherscan.io/address/0xC0221a4Dfb792AA71CE84C2687b1D2b1E7D3eea0#code) (unverified) The source code of this contract is not verified on Etherscan. #### Governance Addresses: [0x86E527BC3C43E6Ba3eFf3A8CAd54A7Ed09cD8E8B](https://etherscan.io/address/0x86E527BC3C43E6Ba3eFf3A8CAd54A7Ed09cD8E8B#code), [0x95269f9E76540459c797089034dc74b48dF780a2](https://etherscan.io/address/0x95269f9E76540459c797089034dc74b48dF780a2#code) (Implementation (Upgradable)), [0x0DCCe462ddEA102D3ecf84A991d3ecFC251e02C7](https://etherscan.io/address/0x0DCCe462ddEA102D3ecf84A991d3ecFC251e02C7#code) (Admin) Keeps a list of block producers and whitelisted tokens. #### UniswapV2Factory Addresses: [0xD2cbDcd7C6b3152BdFf6549C208052E4DBcd575D](https://etherscan.io/address/0xD2cbDcd7C6b3152BdFf6549C208052E4DBcd575D#code), [0xB2639bA16c7A5b0C55cA22D77CdA3D7ED88A5c89](https://etherscan.io/address/0xB2639bA16c7A5b0C55cA22D77CdA3D7ED88A5c89#code) (Implementation (Upgradable)), [0x0DCCe462ddEA102D3ecf84A991d3ecFC251e02C7](https://etherscan.io/address/0x0DCCe462ddEA102D3ecf84A991d3ecFC251e02C7#code) (Admin) Manages trading pairs. #### Verifier Addresses: [0x42F15EFE22993C88441EF3467f2E6Fa8FFA9ADef](https://etherscan.io/address/0x42F15EFE22993C88441EF3467f2E6Fa8FFA9ADef#code), [0x94b9401945a9bc06CE5B69e6dB3c6B671aABc829](https://etherscan.io/address/0x94b9401945a9bc06CE5B69e6dB3c6B671aABc829#code) (Implementation (Upgradable)), [0x0DCCe462ddEA102D3ecf84A991d3ecFC251e02C7](https://etherscan.io/address/0x0DCCe462ddEA102D3ecf84A991d3ecFC251e02C7#code) (Admin) zkSNARK Plonk Verifier. #### VerifierExit Addresses: [0xb56878d21F6b101f48bb55f1AA9D3F624f04E513](https://etherscan.io/address/0xb56878d21F6b101f48bb55f1AA9D3F624f04E513#code) (unverified), [0x17e51B3659884d70a306906B5BDD73D1c64a3892](https://etherscan.io/address/0x17e51B3659884d70a306906B5BDD73D1c64a3892#code) (Implementation (Upgradable), unverified), [0x0DCCe462ddEA102D3ecf84A991d3ecFC251e02C7](https://etherscan.io/address/0x0DCCe462ddEA102D3ecf84A991d3ecFC251e02C7#code) (Admin, unverified) The source code of this contract is not verified on Etherscan. #### UpgradeGatekeeper Addresses: [0x0DCCe462ddEA102D3ecf84A991d3ecFC251e02C7](https://etherscan.io/address/0x0DCCe462ddEA102D3ecf84A991d3ecFC251e02C7#code) (unverified) The source code of this contract is not verified on Etherscan. The current deployment carries some associated risks: - Funds can be stolen if a contract receives a malicious code upgrade. There is a 8 days delay on code upgrades. - Funds can be stolen if the source code of unverified contracts contains malicious code (CRITICAL).