Skip to content

Commit

Permalink
grid trading and arbit updates
Browse files Browse the repository at this point in the history
  • Loading branch information
glasgowm148 committed Dec 23, 2024
1 parent c74ef4c commit 6316058
Show file tree
Hide file tree
Showing 6 changed files with 479 additions and 48 deletions.
56 changes: 33 additions & 23 deletions docs/dev/data-model/nizk.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,35 @@ NIZKs in Ergo are primarily implemented through **Sigma Protocols** (Σ-protocol
### Key Characteristics

- **Non-Interactive**: Proofs can be verified without direct communication
- Unlike traditional interactive zero-knowledge proofs, NIZKs can be verified asynchronously
- Reduces computational overhead and network complexity

- Unlike traditional interactive zero-knowledge proofs, NIZKs can be verified asynchronously
- Reduces computational overhead and network complexity

- **Zero-Knowledge**: No information about the secret is revealed
- Cryptographically guarantees that only the validity of a statement is proven
- Protects sensitive information while maintaining verifiability

- Cryptographically guarantees that only the validity of a statement is proven
- Protects sensitive information while maintaining verifiability

- **Composable**: Can be combined using logical operators like AND, OR, and THRESHOLD
- Enables creation of complex cryptographic conditions
- Supports advanced smart contract logic and privacy-preserving protocols

- Enables creation of complex cryptographic conditions
- Supports advanced smart contract logic and privacy-preserving protocols

## Cryptographic Primitives

Ergo supports several fundamental zero-knowledge proof types:

1. **Discrete Logarithm Proofs**
- Prove knowledge of a secret key without revealing it
- Fundamental to [Schnorr signature verification](schnorr.md)
- Implemented using `proveDlog()` predicate in [ErgoScript](ergoscript.md)

- Prove knowledge of a secret key without revealing it
- Fundamental to [Schnorr signature verification](schnorr.md)
- Implemented using `proveDlog()` predicate in [ErgoScript](ergoscript.md)

2. **Diffie-Hellman Tuple Proofs**
- Prove equality of discrete logarithms across different generators
- Enables privacy-preserving key exchange and contract designs
- Critical for advanced cryptographic protocols

- Prove equality of discrete logarithms across different generators
- Enables privacy-preserving key exchange and contract designs
- Critical for advanced cryptographic protocols

## Implementation Techniques

Expand All @@ -43,6 +48,7 @@ Ergo supports several fundamental zero-knowledge proof types:
Ergo makes proofs non-interactive using the Fiat-Shamir transformation, which converts interactive proofs into non-interactive ones by using a cryptographic hash function.

Key steps:

- Transform an interactive proof into a non-interactive version
- Use a cryptographic hash function to generate a challenge
- Eliminates the need for real-time communication between prover and verifier
Expand Down Expand Up @@ -72,19 +78,22 @@ val thresholdProof = prove {
### Privacy-Preserving Techniques

1. **Ring Signatures**
- Prove one of multiple possible signers without revealing the exact signer
- Enables anonymous transactions
- Detailed in [Ring Signatures](ring.md) documentation

- Prove one of multiple possible signers without revealing the exact signer
- Enables anonymous transactions
- Detailed in [Ring Signatures](ring.md) documentation

2. **Threshold Signatures**
- Require k-out-of-n participants to sign
- Supports multi-party computational scenarios
- Explored in [Threshold Signatures](threshold.md) documentation

- Require k-out-of-n participants to sign
- Supports multi-party computational scenarios
- Explored in [Threshold Signatures](threshold.md) documentation

3. **Stealth Addresses**
- Generate one-time addresses for enhanced transaction privacy
- Prevent linking of transactions to a specific public address
- Crucial for maintaining financial privacy

- Generate one-time addresses for enhanced transaction privacy
- Prevent linking of transactions to a specific public address
- Crucial for maintaining financial privacy

### Mixer Protocols

Expand Down Expand Up @@ -129,8 +138,9 @@ NIZKs in Ergo are designed with performance in mind:
- [Cryptographic Foundations](crypto.md)
- [Zero-Knowledge Proofs in Ergo](zkp.md)
- Academic Papers:
- [Sigma Protocols: A Survey](https://eprint.iacr.org/2021/1022)
- [Non-Interactive Zero-Knowledge Proofs](https://eprint.iacr.org/2016/263)

- [Sigma Protocols: A Survey](https://eprint.iacr.org/2021/1022)
- [Non-Interactive Zero-Knowledge Proofs](https://eprint.iacr.org/2016/263)

## Conclusion

Expand Down
178 changes: 178 additions & 0 deletions docs/uses/arbit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# Arbit Documentation

[Arbit](https://github.com/ConnecMent/arbit) is a simple and intuitive arbitrage platform designed for decentralized trading on the Ergo and Cardano blockchains. It aims to simplify the arbitrage process, enabling users to identify and execute profitable swaps with minimal setup.

/// details | WIP
{type: warning, open: true}
This project is a work in progress and is not yet ready for production use.
///


---

## Overview

**What is Arbit?**

Arbit streamlines the process of arbitrage trading by providing a clean and simple interface. The platform identifies opportunities where a user can buy and sell tokens across different decentralized exchanges to make a profit.

- **Supported Tokens:** ERG, ADA, and RSN.
- **Supported Exchanges:** Ergo Dex and Splash.
- **Core Features:**

- Predefined arbitrage strategies (called "Arbits").
- Focus on simplicity and usability.
- Execution of swaps with just a few clicks.

**What is an Arbit?**

An Arbit is a series of swaps that generate profit. For example:

1. Sell 100 X tokens on Exchange A for $100.
2. Buy 105 Y tokens on Exchange B for the same $100.
3. Profit from the additional 5 Y tokens.

---

## Key Features

### Simplicity and Usability

- Designed for users with basic blockchain knowledge.
- Clear interface with no distractions or unnecessary complexity.
- Profitability of swaps displayed prominently.

### Fixed Arbitrage Strategies

- Supports predefined arbitrage paths, such as:

- ERG ↔ ADA
- RSN ↔ ADA

- Profit calculations are based on fixed USD values ($50 and $100).

---

## How It Works

1. **Arbitrage Strategy Execution:**

- Predefined paths calculate profitability based on current market conditions.
- Fixed token values ($50 and $100) are used for calculations to avoid complexity.

2. **Supported Providers:**

- **Ergo Dex:** Facilitates ERG and ADA swaps.
- **Splash:** Enables swapping of RSN and ADA tokens.

3. **Profit Calculation:**

- Example for a $50 swap:
- Sell $50 worth of rsADA on Ergo Dex for ERG.
- Swap ERG for ADA on Splash.
- Compare the ADA received with the initial $50 equivalent.

---

## Deployment

### Local Setup

1. **Clone the Repository:**

```bash
git clone https://github.com/ConnecMent/arbit.git
cd arbit
```

2. **Set Up Environment Variables:**

Create a `.env` file in the root directory with the following variables:

- `SPLASH_API_URL`: API URL for Splash exchange.
- `ERGO_EXPLORER_API_URL`: API URL for Ergo Explorer.

Example:

```env
SPLASH_API_URL=https://api.splash.exchange
ERGO_EXPLORER_API_URL=https://api.ergoplatform.com
```

3. **Run the Development Server:**

Install dependencies and start the development server:

```bash
pnpm install
pnpm run dev
```

The application will be available at `http://localhost:3000`.

---

## Arbitrage Strategies

The following strategies are implemented in Arbit:

### ERG ↔ ADA Arbitrage

- Leverages Ergo Dex and Splash to identify profitable swaps between ERG and ADA.
- Calculations consider both direct and reverse swap paths for maximum opportunities.

### RSN ↔ ADA Arbitrage

- Utilizes Ergo Dex and Splash for swaps between RSN and ADA tokens.
- Similar profit calculation methods as the ERG ↔ ADA strategy.

---

## Technical Details

### Core Arbitrage Logic

The core logic for arbitrage is implemented in `src/arbitrategy.ts`. It defines a set of predefined strategies for swapping between supported tokens and providers.

### Provider Integrations

- **Ergo Dex (`src/providers/ergodex.ts`):**

- Interacts with the Ergo Dex SDK for swapping tokens.
- Supports `x2y` and `y2x` operations.

- **Splash (`src/providers/splash.ts`):**

- Uses the Splash API to fetch order book data.
- Supports bid/ask matching for liquidity and price calculations.

---

## Usage Guide

1. **Prepare Tokens:**

- Ensure you have supported tokens (ERG, ADA, RSN) on Ergo and Cardano chains.
- Use [Rosen Bridge](https://app.rosen.tech) to bridge assets if necessary.

2. **Visit the App:**

- Open the application and review the displayed arbitrage opportunities.

3. **Execute a Swap:**

- If a profitable Arbit is available, execute the swap by following the on-screen instructions.

---

## Contributing

The project is maintained by [ConnecMent](https://github.com/ConnecMent). Contributions are welcome via pull requests.

**Team:**

- Mentors: [@mkermani144](https://github.com/mkermani144), [@fatemeh-ra](https://github.com/fatemeh-ra)
- Mentee: [@SeyedMojtaba1](https://github.com/SeyedMojtaba1)

Special thanks to [@zargarzadehm](https://github.com/zargarzadehm) for Ergo Dex SDK insights.

26 changes: 3 additions & 23 deletions docs/uses/grid_trading.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,11 @@ Decentralized grid trading is a powerful concept implemented on the Ergo blockch
Learn more about grid trading on [Investopedia](https://www.investopedia.com/terms/g/grid-trading.asp).


## Off the Grid
## [Off the Grid](off_the_grid.md)

Off the Grid is a decentralized application (dApp) that builds on the grid trading contract proposed by kushti. It includes an execution bot/batcher for automating order matching without user interaction.

Explore the project [here](https://github.com/Telefragged/off-the-grid/)

## [Machina Finance](machina-finance.md)

### Features

Off the Grid provides the following features:

- Utilizes a contract that permits spending only if orders are correctly filled or with the order owner's signature. This contract can manage multiple orders simultaneously.
- Employs off-chain bots/batchers to monitor grid orders and match them against other liquidity sources.
- Currently, it matches orders against Spectrum Automated Market Makers (AMMs). However, it can be extended to other sources like the SigUSD bank.
- Supports trading of ERG against any token, with profits accumulated in ERGs.
- Enables grid orders to profit from repeated execution of the same orders, while bot operators benefit from arbitraging the price difference between the liquidity source and grid orders.

This concept was introduced by `@kushti` on [ergoforum](https://www.ergoforum.org/t/decentralized-grid-trading-on-ergo/).

> "We can do decentralized grid trading on Ergo (which is automatically compatible with existing DEXes, such as Spectrum LP pools and babel fees). Grid trading is a good way to make profits from volatility, and many CEXes offer it."
Check out the [first decentralized grid order transaction on Ergo](https://twitter.com/chepurnoy/status/1582657292834861057).

## Machina Finance

Machina Finance is another project on Ergo that is exploring the concept of grid trading. It is developing a decentralized exchange (DEX) that utilizes grid order contracts.

Explore the project [here](../eco/machina-finance.md)
Machina Finance is another project on Ergo that is exploring the concept of grid trading. It is developing a decentralized exchange (DEX) that utilizes grid order contracts.
21 changes: 21 additions & 0 deletions docs/uses/off_the_grid.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Off the Grid

Off the Grid is a decentralized application (dApp) that builds on the grid trading contract proposed by kushti. It includes an execution bot/batcher for automating order matching without user interaction.

Explore the project [here](https://github.com/Telefragged/off-the-grid/) and check out our [Getting Started Guide](off_the_grid_tut.md).

### Features

Off the Grid provides the following features:

- Utilizes a contract that permits spending only if orders are correctly filled or with the order owner's signature. This contract can manage multiple orders simultaneously.
- Employs off-chain bots/batchers to monitor grid orders and match them against other liquidity sources.
- Currently, it matches orders against Spectrum Automated Market Makers (AMMs). However, it can be extended to other sources like the SigUSD bank.
- Supports trading of ERG against any token, with profits accumulated in ERGs.
- Enables grid orders to profit from repeated execution of the same orders, while bot operators benefit from arbitraging the price difference between the liquidity source and grid orders.

This concept was introduced by `@kushti` on [ergoforum](https://www.ergoforum.org/t/decentralized-grid-trading-on-ergo/).

> "We can do decentralized grid trading on Ergo (which is automatically compatible with existing DEXes, such as Spectrum LP pools and babel fees). Grid trading is a good way to make profits from volatility, and many CEXes offer it."
Check out the [first decentralized grid order transaction on Ergo](https://twitter.com/chepurnoy/status/1582657292834861057).
Loading

0 comments on commit 6316058

Please sign in to comment.