Decentralized perpetual trading platform with low fees, zero price impact, and up to 50x leverage.
- Overview
- Features
- Architecture
- Getting Started
- Installation
- Usage
- Testing
- Deployment
- Security
- Contributing
- License
- Contact
Gambit Protocol is a decentralized perpetual trading platform that enables users to trade perpetual futures with leverage up to 50x. The protocol features a unique AMM-based liquidity model that provides zero price impact trades and low fees.
- Vault: Core contract managing positions, collateral, and liquidity
- Position Manager: Handles position creation, modification, and liquidation
- Order Book: Manages limit orders and stop-loss orders
- Oracle System: Fast price feeds with Chainlink integration
- GMT Token: Native governance and utility token
- Staking & Rewards: Staking mechanisms for GMT and GLP tokens
- GLP Manager: Manages GLP (Gambit Liquidity Provider) token minting and burning
- π High Leverage: Trade with up to 50x leverage
- π° Low Fees: Competitive trading and funding fees
- π Zero Price Impact: AMM-based liquidity model
- π Multiple Markets: Support for various trading pairs
- π― Limit Orders: Advanced order types including stop-loss
- π Staking Rewards: Earn rewards by staking GMT and GLP
- π Multi-Chain: Deployable on multiple EVM-compatible chains
- π Security: Audited smart contracts with comprehensive test coverage
contracts/
βββ core/ # Core trading logic
β βββ Vault.sol # Main vault contract
β βββ PositionManager.sol
β βββ PositionRouter.sol
β βββ OrderBook.sol
β βββ Router.sol
βββ gambit-token/ # GMT token implementation
β βββ GMT.sol
β βββ Treasury.sol
βββ staking/ # Staking and rewards
β βββ RewardTracker.sol
β βββ RewardRouter.sol
β βββ Vester.sol
βββ oracle/ # Price feed system
β βββ PriceFeed.sol
β βββ FastPriceFeed.sol
βββ amm/ # AMM integrations
β βββ PancakeRouter.sol
β βββ UniRouter.sol
βββ libraries/ # Shared libraries
βββ math/
βββ token/
-
Clone the repository
git clone https://github.com/gambit-protocol/contracts.git cd contracts -
Install dependencies
npm install
-
Set up environment variables
Create an
env.jsonfile in the root directory (seeenv.json.examplefor reference):{ "BSC_URL": "https://bsc-dataseed.binance.org/", "BSC_DEPLOY_KEY": "your-private-key", "BSCSCAN_API_KEY": "your-api-key" }
npm run compilenpm testnpm run typechainnpm run sizenpm run cleanThe project includes comprehensive test suites covering:
- Vault operations (deposit, withdraw, swap)
- Position management (open, close, liquidate)
- Order book functionality
- Staking and rewards
- Token operations
Run all tests:
npm testRun specific test file:
npx hardhat test test/core/Vault/depositCollateral.js-
Start a local Hardhat node:
npx hardhat node
-
Deploy contracts to local network:
npx hardhat run scripts/core/deployVault.js --network localhost
Deploy to BSC Testnet:
npx hardhat run scripts/core/deployVault.js --network bscTestnetnpx hardhat run scripts/core/deployVault.js --network bscThis codebase has been audited by:
- ABDK Consulting (see
audits/directory)
- Always verify contracts on block explorers after deployment
- Use timelock contracts for critical parameter changes
- Implement multi-sig wallets for governance
- Regular security reviews and updates
- Solidity version 0.6.12 is used for compatibility
- Contracts use SafeMath for arithmetic operations
- ReentrancyGuard is implemented where necessary
The scripts/ directory contains deployment and management scripts:
- Core Contracts:
scripts/core/ - Token Deployment:
scripts/gambit-token/ - Staking Setup:
scripts/staking/ - Peripherals:
scripts/peripherals/
Example usage:
npx hardhat run scripts/core/deployVault.js --network bscTestnetContributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow Solidity style guide
- Write comprehensive tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting PR
This project is licensed under the MIT License - see the LICENSE file for details.
- Telegram: @moooncity
- Project: Gambit Protocol
- Built on the foundation of decentralized finance principles
- Inspired by innovative DeFi protocols in the ecosystem
- Community-driven development and feedback