Skip to content

The Open Source Hub for DeFi Options Protocols, Enabling Seamless Read and Write Actions Across Diverse Blockchain Platforms

Notifications You must be signed in to change notification settings

grixprotocol/derivatives-adapters

Repository files navigation

Grix Protocol Adapters

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.

Grix Protocol Integration Kit

This guide will help you integrate your DeFi options protocol with Grix, making it easy for Grix users to reach your protocol's options.

How Grix Works

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.

Quick Contribution Guide

  • 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

Please Note

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.

Protocols Integration Table

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

Implementing a New Protocol Adapter

Overview

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.

Required Methods

  1. fetchExpiryDates: Returns available expiry dates for options
  2. getLongOptionPremium: Calculates premium for buying an option
  3. getShortOptionPremium: Calculates premium for selling an option

Implementation Steps

  1. Create a new directory under src/adapters with your protocol name: src/adapters/your-protocol/

  2. 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
  3. 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", }, }

  4. 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
  5. Test your implementation:

    • Run npm test to verify your adapter
    • Ensure all test cases pass
    • Verify real API responses work as expected

Best Practices

  • 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

Example Implementation

For a complete example, see:

  • Moby adapter: src/adapters/moby/index.ts
  • Deribit adapter: src/adapters/deribit/index.ts

Need Help?

  • Check our example PRs in the repository
  • Join our community discussions
  • Review existing implementations for guidance
  • Reach out to our team for support

About

The Open Source Hub for DeFi Options Protocols, Enabling Seamless Read and Write Actions Across Diverse Blockchain Platforms

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 7