{"id":42235351,"url":"https://github.com/clober-dex/futures-market","last_synced_at":"2026-01-27T03:17:28.040Z","repository":{"id":280922635,"uuid":"938271398","full_name":"clober-dex/futures-market","owner":"clober-dex","description":"NDF Futures Market Solidity Contracts","archived":false,"fork":false,"pushed_at":"2025-07-23T06:32:40.000Z","size":372,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-23T08:28:30.626Z","etag":null,"topics":["blockchain","dapp","defi","evm","futures","ndf","solidity"],"latest_commit_sha":null,"homepage":"https://futures.clober.io","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clober-dex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-24T17:31:16.000Z","updated_at":"2025-05-13T13:55:21.000Z","dependencies_parsed_at":"2025-03-06T03:26:30.289Z","dependency_job_id":"544914ff-88b6-4832-8e9d-481daef7985c","html_url":"https://github.com/clober-dex/futures-market","commit_stats":null,"previous_names":["clober-dex/futures-market"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/clober-dex/futures-market","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clober-dex%2Ffutures-market","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clober-dex%2Ffutures-market/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clober-dex%2Ffutures-market/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clober-dex%2Ffutures-market/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clober-dex","download_url":"https://codeload.github.com/clober-dex/futures-market/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clober-dex%2Ffutures-market/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28798790,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T01:07:07.743Z","status":"online","status_checked_at":"2026-01-27T02:00:07.755Z","response_time":168,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","dapp","defi","evm","futures","ndf","solidity"],"created_at":"2026-01-27T03:17:27.335Z","updated_at":"2026-01-27T03:17:28.034Z","avatar_url":"https://github.com/clober-dex.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Clober Futures Market\n\n[![CI Status](https://github.com/clober-dex/futures-market/actions/workflows/test.yml/badge.svg)](https://github.com/clober-dex/futures-market/actions/workflows/test.yml)\n[![Website](https://img.shields.io/badge/website-futures.clober.io-blue)](https://futures.clober.io/future)\n\n## Overview\n\n**Clober Futures Market** is a decentralized protocol designed to facilitate **Non-Deliverable Forward (NDF)** contracts on EVM-compatible blockchains.  \nIn traditional finance, an NDF is a type of forward contract where there is **no physical delivery of the underlying asset**—instead, profits and losses are settled in a widely accepted currency (e.g., USD). This project recreates that mechanism on-chain, allowing users to hedge or speculate on various assets using a **cash-settled** approach.\n\n---\n\n## Install\n\n### Prerequisites\n- We use [Forge Foundry](https://github.com/foundry-rs/foundry) for **testing**. Follow the [Foundry installation guide](https://github.com/foundry-rs/foundry#installation).\n- **Node.js** and **npm** (Node Package Manager) are required. You can download and install them from the [official Node.js website](https://nodejs.org/).\n\n### Installing from source\n\n```bash\ngit clone https://github.com/clober-dex/futures-market \u0026\u0026 cd futures-market\nforge install\nnpm install\n```\n\n## Usage\n\n### Build\n```bash\nforge build\n```\n\n### Tests\n```bash\nforge test\n```\n\n### Linting\n\n```bash\nforge fmt\n```\n\n## Deployments\n\nFor the most up-to-date deployment addresses, please check the [`deployments/`](./deployments/) directory.\n\n### Monad Testnet (Chain ID: 10143)\n| Contract | Address | Explorer Link |\n|----------|---------|---------------|\n| FuturesMarket | `0x86Add33C407dB62b44E08BC326b4F5CD1eBA575f` | [View on Monad Explorer](https://testnet.monadexplorer.com/address/0x86Add33C407dB62b44E08BC326b4F5CD1eBA575f) |\n| PythOracle | `0x51b7bf333aa6425B951da4C42105d94F68F6e80E` | [View on Monad Explorer](https://testnet.monadexplorer.com/address/0x51b7bf333aa6425B951da4C42105d94F68F6e80E) |\n\n## Project Structure\n\n```\nfutures-market/\n├── src/             # Smart contract source files\n├── test/            # Test files\n├── script/          # Deployment and other scripts\n├── deployments/     # Deployed contract addresses\n└── lib/             # Dependencies and external libraries\n```\n\nThe project follows a standard Foundry project structure:\n- `src/`: Contains the core smart contract implementations\n- `test/`: Contains the test suite for the contracts\n- `script/`: Contains deployment scripts and other utilities\n- `deployments/`: Contains deployed contract addresses for different networks\n- `lib/`: Contains project dependencies managed by Forge\n\n## Architecture \u0026 Technical Implementation\n\n### Overview\nFutures Market is a decentralized futures trading protocol running on EVM-compatible chains. It adopts a modularized structure using the Diamond Proxy pattern and utilizes Pyth Network's Pull Oracle for secure and efficient oracle data processing.\n\n### Technologies Used\n1. **Diamond Proxy ([EIP-2535](https://eips.ethereum.org/EIPS/eip-2535))**\n   - Modularized smart contract structure\n   - Upgradeable contract design\n   - Gas-optimized function execution\n\n2. **[CreateX](https://github.com/pcaversaccio/createx)**\n   - Optimized contract deployment\n   - Deterministic address generation\n\n3. **[IERC3156 Flashloan](https://eips.ethereum.org/EIPS/eip-3156)**\n   - Liquidity utilization optimization\n   - Complex trading strategy support\n\n4. **[Permit](https://eips.ethereum.org/EIPS/eip-2612)**\n   - Gasless approvals\n   - Enhanced user experience\n\n5. **Multicall**\n   - Execute multiple operations in a single transaction\n   - Gas cost reduction\n\n### External Dependencies\n\n#### Pyth Network\nWe integrate [Pyth Network](https://pyth.network/) for reliable price feeds using their pull oracle mechanism. For detailed implementation, check out the [Pyth documentation](https://docs.pyth.network/price-feeds/pull-updates).\n\n### Design Choices\n\n#### Diamond Proxy Pattern (EIP-2535)\n- Enhanced maintainability through modularized contract structure\n- Selective feature upgradeability\n- Prevention of storage collisions\n- Gas-efficient function calls\n\n#### Pull Oracle vs Push Oracle\nReasons for choosing Pull Oracle:\n- On-demand data updates\n- Gas cost optimization\n- Reduced network load\n- High reliability and accuracy\n- Usage-based cost structure\n\n## How It Works\n\n### Basic Workflow\n\n1. **Market Creation**\n   - Markets are created with specific parameters:\n     - Asset ID and Collateral token\n     - Expiration date\n     - LTV (Loan-to-Value) ratio\n     - Liquidation threshold\n     - Minimum debt amount\n\n2. **Position Management**\n   - **Opening a Position**:\n     1. Deposit collateral into the market\n     2. Mint debt tokens to create leverage\n     3. Monitor position's health ratio\n   \n   - **Trading Hours Restriction**:\n     - For stock futures, position minting, withdrawal, and liquidation are only available during stock market trading hours\n     - This restriction ensures alignment with traditional stock market operations\n     - Other operations remain available 24/7\n\n   - **Managing Risk**:\n     - Add more collateral to avoid liquidation\n     - Burn debt tokens to reduce exposure\n     - Monitor oracle price feeds\n\n3. **Settlement \u0026 Position Closing**\n   - **Settlement**: \n     - At expiry, market is settled at the oracle price\n     - Settlement price determines the final PnL for all positions\n   \n   - **Closing Options**:\n     - **Close**: Receive PnL in settlement currency (profit or loss based on position)\n     - **Redeem**: Exchange debt tokens for collateral at settlement price\n   \n   - **Liquidation**: \n     - Positions below liquidation threshold can be liquidated before settlement\n     - Liquidators can cover debt and receive collateral at a discount\n\n## Risks \u0026 Disclaimers\n\n### Trading Risks\n- **Liquidation Risk**: Positions are liquidated if they fall below the liquidation threshold\n- **Oracle Risk**: \n  - Price feed delays or failures could affect position management\n  - Pyth Network oracle reliability is critical for settlement\n- **Market Risk**:\n  - Volatile market conditions may cause significant losses\n- **Smart Contract Risk**: \n  - Despite audits, smart contract vulnerabilities may exist\n  - Interaction with multiple protocols increases complexity\n\n### Important Notes\n- This protocol is designed for experienced traders familiar with futures trading\n- Understand the liquidation mechanism\n- Monitor position health ratio regularly\n- Test with small amounts first to understand the system\n- Past performance does not guarantee future results\n\n## License\n\nThe source code in `src/` is licensed under GPL-2.0-or-later.\n\n## Contributing\n\nWe welcome contributions from the community! Please follow these steps:\n\n1. Fork the repository\n2. Create a new branch for your feature\n3. Submit a Pull Request with a clear description\n4. Follow our code style and include tests\n\nFor bug reports or feature requests, please open an issue on GitHub.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclober-dex%2Ffutures-market","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclober-dex%2Ffutures-market","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclober-dex%2Ffutures-market/lists"}