Welcome to the Grix Protocol Adapters repository! This project is designed to facilitate the integration of various DeFi options protocols with the Grix platform, enabling easy and smooth quoting of options premium prices.
This guide will help you integrate your DeFi options protocol with Grix, making it easy for Grix users to reach your protocol's options.
Fetching Expiry Dates: Grix retrieves all available expiry dates for options, ensuring you have the latest data. Listing Strike Prices by Expiry: For each expiry date, Grix lists all possible strike prices, giving you a comprehensive view of the market. Calculating Option Premiums: Grix calculates both long and short option premiums, providing accurate pricing information for your users.
- Fork the Repository: Start by forking the Grix Protocol Adapters Repository.
- Develop Your Adapter: Implement the necessary functions for expiry dates, strike prices, and premiums.
- Submit Your Work: Create a pull request with your adapter and documentation.
- Engage with the Community: Join discussions and contribute to the ongoing development.
- For detailed guidelines, please refer to our Contribution Guidelines.
For contribution example, see this PR by Thetanuts or this PR by Arrow Market
While we value consistency and maintainability, we also aim to be flexible to maximize community involvement. Our coding standards are a guide, not a strict rulebook. We're open to different styles and approaches, especially if they lead to innovative solutions.
Thank you for contributing to Grix! Your efforts help us build a robust, community-driven DeFi options framework.
| Protocol Name | fetchExpiryDates | listStrikePricesByExpiry | getLongOptionPremium | getShortOptionPremium | buyOptionContract | addOptionToPosition | exerciseOptionContract | sellOptionBackToIssuer | transferOptionOwnership | getEstimatedClosedValue |
|---|---|---|---|---|---|---|---|---|---|---|
| Moby | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ⏳ | ✅ |
| Premia | ✅ | ✅ | ✅ | ⏳ | ✅ | ✅ | ✅ | ✅ | ⏳ | ✅ |
| Derive | ✅ | ✅ | ✅ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
| Stryke | ✅ | ✅ | ✅ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
| Aevo | ✅ | ✅ | ✅ | ✅ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
| Zomma | ✅ | ✅ | ✅ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
| Ithaca | ✅ | ✅ | ✅ | ✅ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
| Thetanuts | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
| Rysk Finance | ✅ | ✅ | ✅ | ⏳ | ✅ | ✅ | ⏳ | ⏳ | ⏳ | ⏳ |
| Hegic | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
| Gamma Swap | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
| Siren | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ | ⏳ |
To integrate a new protocol with Grix, you'll need to implement an adapter that follows our standardized interface. Each adapter must provide three core functions and include test parameters for validation.
- fetchExpiryDates: Returns available expiry dates for options
- getLongOptionPremium: Calculates premium for buying an option
- getShortOptionPremium: Calculates premium for selling an option
-
Create a new directory under src/adapters with your protocol name: src/adapters/your-protocol/
-
Create an index.ts file with the following structure:
src/adapters/your-protocol/index.ts
Required sections:
- Protocol Adapter Implementation Guide header
- Test parameters definition
- Adapter implementation with required methods
- Export of the adapter object
-
Define your test parameters:
Your test parameters must:
- Use real instrument names/assets from your protocol
- Return valid responses from your protocol's API
- Include all required fields for each method
Example structure: const testParams = { fetchExpiryDates: { asset: "ETH", // Base asset symbol }, getLongOptionPremium: { instrument_name: "ETH-30JUN24-3000-C", }, getShortOptionPremium: { instrument_name: "ETH-30JUN24-3000-C", }, }
-
Implement the required methods:
- fetchExpiryDates: Must return an array of timestamps
- getLongOptionPremium: Must return a number representing the premium
- getShortOptionPremium: Must return a number representing the premium
-
Test your implementation:
- Run npm test to verify your adapter
- Ensure all test cases pass
- Verify real API responses work as expected
- Keep your implementation clean and well-documented
- Handle errors gracefully
- Use TypeScript types for better code safety
- Follow existing adapter examples for consistency
- Test with real protocol data
For a complete example, see:
- Moby adapter: src/adapters/moby/index.ts
- Deribit adapter: src/adapters/deribit/index.ts
- Check our example PRs in the repository
- Join our community discussions
- Review existing implementations for guidance
- Reach out to our team for support