An open API service indexing awesome lists of open source software.

https://github.com/berzanorg/xane

A zero knowledge order book decentralized exchange.
https://github.com/berzanorg/xane

astrojs decentralized-exchange dex mina mina-protocol o1js solidjs xane zk zkdex

Last synced: 3 months ago
JSON representation

A zero knowledge order book decentralized exchange.

Awesome Lists containing this project

README

          

# Xane 📈

**Xane** (IPA: /seɪn/) is a **zero knowledge order book decentralized exchange**.

**Xane** is live at [xane.berzan.org](https://xane.berzan.org/).

![Xane banner](/ui/public/xane.png)

> **Note**: Currently, the user interface is not functioning because there is no
backend server running on the web and there are issues with Mina nodes.

> However you can visit it and see how it looks like.

## Prerequirements

You need [o1js](https://docs.minaprotocol.com/zkapps/o1js) knowledge for smart contract development.


You need [~~Rust~~](https://www.rust-lang.org/), (currently) [TypeScript](https://www.typescriptlang.org/) knowledge for backend development.


You need [Astro.js](https://astro.build/) & [Solid.js](https://www.solidjs.com/) knowledge for user interface development.

## Resources

[o1js](https://docs.minaprotocol.com/zkapps/o1js) resource: [https://docs.minaprotocol.com/zkapps/o1js](https://docs.minaprotocol.com/zkapps/o1js)


[TypeScript](https://www.typescriptlang.org/) resource: [https://www.typescriptlang.org/docs/](https://www.typescriptlang.org/docs/)


[Astro.js](https://astro.build/) resource: [https://docs.astro.build/en/getting-started/](https://docs.astro.build/en/getting-started/)


[Solid.js](https://www.solidjs.com/) resource: [https://www.solidjs.com/guides/getting-started#learn-solid](https://www.solidjs.com/guides/getting-started#learn-solid)

## Setup A Development Environment

The easiest way to setup a development environment is to use [Dev Containers](https://containers.dev/).

You just need [Docker](https://www.docker.com/) and [VS Code](https://code.visualstudio.com/) installed to use [Dev Containers](https://containers.dev/).

When you open the project in [VS Code](https://code.visualstudio.com/), it will warn you to repeon it in a container.

It also contains six different [VS Code](https://code.visualstudio.com/) extensions that will help you during the development.

If you prefer a more traditional way to setup a development environment, you only need to install the latest version of [NodeJS](https://nodejs.org/).

## Project Structure

This repository is a monorepo for the smart contracts, the user interface, and the backend server of **Xane**.

## Smart Contracts

It currently contains [`Token`](contracts/src/Token.ts), [`Exchange`](contracts/src/Exchange.ts) and [`Vault`](contracts/src/Vault.ts) smart contracts.


All the smart contracts are working as expected even tho they are non-secure implementations.

[`Token`](contracts/src/Token.ts) contract is a simple token standard implementation for Mina.


It has all the basic methods a token needs such as `mint`, `burn`, `transfer`, `approveUpdate`, `approveCallbackAndTransfer`, `approveUpdateAndTransfer`, etc.


Its unit tests reside in [`Token.test.ts`](contracts/src/Token.test.ts) file.

[`Exchange`](contracts/src/Exchange.ts) contract is a decentralized exchange


that currently allows placing, cancelling and executing a single order at a time.


It has methods such as `createPair`, `placeBuyOrder`, `cancelSellOrder`, `executeBuyOrder`, etc.


Its unit tests reside in [`Exchange.test.ts`](contracts/src/Exchange.test.ts) file.

[`Vault`](contracts/src/Vault.ts) contract is a vault that holds a specific token on behalf of the exchange.


It is created to support unlimited kind of tokens on the exchange.


Its unit tests reside in [`Vault.test.ts`](contracts/src/Vault.test.ts) file.

Smart contracts of **Xane** reside in [`contracts/`](contracts) folder.


So you have to change the current working directory before working with them.

```sh
cd contracts/
```

You can run all the tests by running the command below.

```sh
npm run test
```

## User Interface

The user interface of **Xane** is built using [Astro.js](https://astro.build/) & [Solid.js](https://www.solidjs.com/).

It resides in [`ui/`](ui) folder.


So you have to change the current working directory before working with it.

```sh
cd ui/
```

You can start a development server by running the command below.

```sh
npm run dev # then visit localhost:4321 too see the preview
```

## Backend

The backend of **Xane** is built using [TypeScript](https://www.typescriptlang.org/) & [tinyhttp](https://tinyhttp.v1rtl.site/).

It acts like an authority that is responsible for storing data and generating proofs.

It resides in [`backend/`](backend) folder.


So you have to change the current working directory before working with it.

```sh
cd backend/
```

You can build the backend by running the command below.

```sh
npm run start # then the backend server will be live on localhost:3000
```

**Made with sweat 💦 and love ❤️ by [Berzan](https://berzan.org/).**