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

https://github.com/vitwit/cw-otc-dex


https://github.com/vitwit/cw-otc-dex

Last synced: 6 months ago
JSON representation

Awesome Lists containing this project

README

          

# cosmos-otc-platform ๐ŸŒŸ

A decentralized Over-The-Counter (OTC) trading platform built with CosmWasm. This smart contract enables secure, transparent, and efficient OTC trading of tokens with customizable discount rates and bidding mechanisms.

## Features ๐Ÿš€

- **Flexible Deal Creation**: Sellers can create OTC deals with:
- Custom token selection
- Configurable discount percentages
- Minimum price protection
- Minimum cap requirements
- Customizable bidding timeframes

- **Advanced Bidding System**:
- Buyers can place bids with desired quantities
- Maximum price protection for buyers
- Real-time bid updates and withdrawals
- Automatic bid sorting by discount rates

- **Secure Deal Settlement**:
- Automatic deal conclusion at specified time
- Fair distribution prioritizing lowest discount bids
- Automatic refunds for unsuccessful bids
- Platform fee management

## Prerequisites ๐Ÿ“‹

- Rust 1.63.0+
- [wasmd](https://github.com/CosmWasm/wasmd) 0.30.0+
- [cargo-generate](https://github.com/cargo-generate/cargo-generate)

## Installation ๐Ÿ› ๏ธ

```bash
# Clone the repository
git clone https://github.com/yourusername/cosmos-otc-platform
cd cosmos-otc-platform

# Compile the contract
cargo build

# Run tests
cargo test

# Generate Wasm binary
cargo wasm
```

## Usage ๐Ÿ“

### Creating an OTC Deal

```rust
let msg = ExecuteMsg::CreateDeal {
sell_token: "token_address",
total_amount: Uint128::new(1000000),
min_price: Uint128::new(100),
discount_percentage: 10,
min_cap: Uint128::new(500000),
bid_start_time: 1234567890,
bid_end_time: 1234657890,
conclude_time: 1234747890,
};
```

### Placing a Bid

```rust
let msg = ExecuteMsg::PlaceBid {
deal_id: 1,
amount: Uint128::new(100000),
discount_percentage: 5,
max_price: Some(Uint128::new(110)),
};
```

## Contract Architecture ๐Ÿ—๏ธ

```
src/
โ”œโ”€โ”€ lib.rs # Entry point
โ”œโ”€โ”€ contract.rs # Core contract logic
โ”œโ”€โ”€ msg.rs # Message definitions
โ”œโ”€โ”€ state.rs # State management
โ”œโ”€โ”€ error.rs # Error handling
โ””โ”€โ”€ helpers.rs # Utility functions
```

## Testing ๐Ÿงช

```bash
# Run all tests
cargo test

# Run specific test
cargo test test_create_deal
```

## Security Considerations ๐Ÿ”’

- All monetary operations are atomic
- Time-based validations prevent premature or late actions
- Minimum price protection for sellers
- Maximum price protection for buyers
- Automatic refund mechanism
- Platform fee validation

## Contributing ๐Ÿค

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

## Contact ๐Ÿ“ง

Anil - [@anilcse](https://twitter.com/anilcse_)

Project Link: [https://github.com/vitwit/cw-otc-dex](https://github.com/vitwit/cw-otc-dex)

## Acknowledgments ๐Ÿ™

- CosmWasm team for the amazing smart contract platform

---
Made with โค๏ธ for the Cosmos ecosystem