Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve readme #4

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 56 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,68 @@
# Double Zero Swap
<h3 align="center"> ⛓️ 🔐 👀</h3>
<h1 align="center">Double Zero Swap</h1>

## Summary
<p align="center">A private blockchain solution with access control features that leverage the ZKsync Elastic Chain ecosystem's development tools and interoperability.</p>

Double zero swap is a simple constant product AMM build to be used on top of [Double Zero](https://github.com/Moonsong-Labs/double-zero).
![Double-Zero](assets/architecture.png)_High-level architecture design for a "Double-Zero" implementation using a Validium
Chain with access control features and scoped data access._

It was built using standard technologies like:
> [!NOTE]
> By combining **_Zero-Knowledge with Zero-Access_**, it offers a unique **value** proposition for organizations seeking to
> maintain **_privacy and access management_** while harnessing the benefits of EVM-compatible technologies.

- 🏗 Scaffold-ETH 2: https://scaffoldeth.io/
- Foundry: https://foundry-book.zksync.io/
- wagmi: https://wagmi.sh/
- viem: https://viem.sh/
- react: https://react.dev/
- nextjs: https://nextjs.org/
- rainbowkit: https://www.rainbowkit.com/
## 📒 Summary

## How to start
Double Zero Swap is a simple dapp built to be used on top of [Double Zero](https://github.com/Moonsong-Labs/double-zero). It resembles a constant product AMM, but with private data access and access control features, brought by the Double Zero architecture.

Even when this was developed with a private validium chain in mind, you can use
this app with any zksync compatible chain following these steps:
### Built With

- [Next.js](https://nextjs.org/)
- [Foundry ZKSync](https://foundry-book.zksync.io/)
- [Wagmi](https://wagmi.sh/)
- [Viem](https://viem.sh/)
- [RainbowKit](https://www.rainbowkit.com/)

## ⚙️ Quickstart

### 0. Prepare your environment

Clone the [Double Zero](https://github.com/Moonsong-Labs/double-zero) repository and follow the instructions to start the local network.

> [!TIP]
> This step is only required if you want to deploy the contracts using Double Zero. This app can be used with any EVM compatible chain, but you will need to change the RPC URL in the webapp config.

### 1. Deploy contracts

In your terminal run:
In the `contracts` folder, you can find the contracts to be deployed and the deploy script. Run the following command to deploy the contracts:

```bash
PRIVATE_KEY=<deployer_private_key> \
RPC_URL="http://localhost:3050" \
scripts/deploy.sh
```
cd contracts
export PRIVATE_KEY=<deployer_private_keyt> # space at start to avoid sending pk to shell history
env RPC_URL="http://localhost:3050" scripts/deploy.sh
```

This script does several things:
- Deploys 2 ERC20 tokens
- Deploys the AMM contract
- Links everything together
- Mint some of both tokens and send them to the deploy address.
Take into account that the `RPC_URL` should be the one of the local network you have running. If attempting to run this using Double Zero, you should put the Private RPC address.

The script does several things:

At the end is going to log something like this:
- Deploys 2 ERC20 tokens
- Deploys the AMM contract
- Links everything together
- Mint some of both tokens and send them to the deploy address

At the end it will log the addresses of the deployed contracts:

```
DAI: <dai_address>
WBTC: <wbtc_address>
CPAMM: <cpamm_address>
```

These addresses are going to be used in the next step

### 2. Webapp config

The easiest way to configure the webapp is using a dotenv file
The easiest way to configure the webapp is using a dotenv file:

``` bash
```bash
cp web/.env.example web/.env
```

Expand All @@ -59,17 +72,27 @@ Now you can edit that file and put your data:
NEXT_PUBLIC_CHAIN_ID="<your_chain_id>"
NEXT_PUBLIC_CPAMM_ADDRESS="<cpamm_address>"
NEXT_PUBLIC_DAI_ADDRESS="<dai_address>"
NEXT_PUBLIC_WBTC_ADDRESS="<weth_address>"
NEXT_PUBLIC_WBTC_ADDRESS="<wbtc_address>"
NEXT_PUBLIC_CHAIN_NAME="Local Chain"
NEXT_PUBLIC_BLOCK_EXPLORER_URL="<double_zero_explorer_url>"
```

### 3. Install dependencies and run

Now the app can be launched
In the `web` folder, run the following command to install the dependencies and start the app:

``` bash
cd web
```bash
pnpm install
pnpm dev
```

## 🎯 **Conclusion**

Double Zero Swap demonstrates the practical application of **_private DeFi_** through:

1. **Private AMM**: A constant product market maker that maintains transaction privacy while enabling efficient token swaps.
2. **Access Control**: Leverages Double Zero's architecture to manage who can view and interact with the protocol.
3. **User Experience**: Simple interface built with modern web3 tools for seamless interaction.
4. **Composability**: Built on Double Zero's infrastructure, showing how private DeFi protocols can be constructed.

By implementing a basic DeFi primitive with privacy features, Double Zero Swap serves as a blueprint for building confidential decentralized applications that maintain the benefits of public blockchain technology while protecting sensitive transaction data.
Binary file added assets/architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading