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

Adding sails DEX #547

Merged
merged 7 commits into from
Jan 16, 2025
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
32 changes: 32 additions & 0 deletions contracts/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ members = [
"car-races/car-3",
"car-races",
"concert",
"dex",
"dynamic-nft",
"galactic-express",
"multisig-wallet",
Expand Down
2 changes: 2 additions & 0 deletions contracts/dex/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
.binpath
24 changes: 24 additions & 0 deletions contracts/dex/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "dex"
version.workspace = true
edition.workspace = true
license.workspace = true

[dependencies]
dex-app = { path = "app" }

[build-dependencies]
dex-app = { path = "app" }
sails-rs = { workspace = true, features = ["wasm-builder"] }
sails-idl-gen.workspace = true
extended-vft-client.workspace = true

[dev-dependencies]
dex = { path = ".", features = ["wasm-binary"] }
dex-client = { path = "client" }
sails-rs = { workspace = true, features = ["gtest"] }
tokio = { workspace = true, features = ["rt", "macros"] }
extended-vft-client.workspace = true

[features]
wasm-binary = []
31 changes: 31 additions & 0 deletions contracts/dex/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# DEX

This is a basic implementation of a Decentralized Exchange (DEX) contract designed to showcase fundamental functionality. It includes liquidity management, token swaps, and administrative controls. While simple, this example can serve as a foundation for more complex implementations.

### Opportunities for Extension

This basic DEX implementation can be enhanced with additional features:

- **Fees and Incentives**: Introduce a small fee on swaps (e.g., 0.3%) to reward liquidity providers and create a sustainable ecosystem.
- **Decimal Precision**: Replace integer-based calculations with decimal values to enable more precise token management and swaps.
- **Dynamic Fees**: Implement adaptive fees based on market conditions or pool activity to optimize user experience.
- **Governance Integration**: Add voting mechanisms for liquidity providers to influence key decisions, such as fee rates or token listings.
- **Multi-Token Pools**: Expand functionality to support more than two tokens in a liquidity pool, enabling advanced DeFi scenarios.

This example is intentionally simple to highlight the core mechanics of a DEX. It can be tailored to suit a wide range of DeFi use cases, making it a versatile starting point for blockchain developers. By extending its features, this contract could evolve into a powerful tool for decentralized finance.

A detailed description of the project can be found on the [wiki](https://wiki.vara.network/docs/examples/DeFi/dex).

⚙️ **Note**: The project code is developed using the [Sails](https://github.com/gear-tech/sails) framework.

### 🏗️ Building

```sh
cargo b -r -p "dex"
```

### ✅ Testing

```sh
cargo t -r -p "dex"
```
9 changes: 9 additions & 0 deletions contracts/dex/app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "dex-app"
version.workspace = true
edition.workspace = true
license.workspace = true

[dependencies]
sails-rs.workspace = true
extended-vft-client.workspace = true
Loading
Loading