https://github.com/vitwit/cw-otc-dex
https://github.com/vitwit/cw-otc-dex
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/vitwit/cw-otc-dex
- Owner: vitwit
- Created: 2024-03-01T06:05:38.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-08T11:20:12.000Z (over 1 year ago)
- Last Synced: 2024-11-08T11:27:39.946Z (over 1 year ago)
- Size: 65.3 MB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
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