Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/meteora integration #7

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

bginsber
Copy link

@bginsber bginsber commented Jan 11, 2025

Meteora DEX Integration

This PR integrates the Meteora DEX, allowing users to swap tokens, manage liquidity, and claim fees using Meteora's concentrated liquidity pools.

Changes

  • Added src/meteora.rs module with Meteora DEX functionality:
    • Swap tokens
    • Add liquidity
    • Remove liquidity
    • Claim fees
  • Added Meteora program ID constant
  • Added official Meteora SDK dependency via commons crate
  • Added comprehensive tests with minimal token amounts

Implementation Notes

  • Uses the official Meteora repository: MeteoraAg/dlmm-sdk
  • Minimized direct Solana dependencies, relying on commons interfaces where possible
  • Follows similar patterns to existing DEX integrations
  • Includes error handling and transaction confirmation
  • Supports interactive confirmation for swaps
  • Tests use real mainnet interactions with minimal amounts (~0.0006 SOL total)
    • Basic swap: 0.0001 SOL
    • Liquidity operations: 0.0001 SOL / 0.001 USDC
    • Fee testing: 0.0005 SOL / 0.005 USDC
  • Tests include balance verification, error handling, and cleanup

Raydium Integration

Due to Solana version compatibility issues, dependency conflicts, and the fact that Jupiter can route through Raydium, a separate issue will be created to plan the deprecation of the direct Raydium integration. This PR will focus solely on the Meteora integration. Raydium changes will be handled in a future PR.

Known Issues

  • Solana version compatibility with Raydium needs to be addressed. A plan for Raydium deprecation will be created in a separate issue.

Testing

  • The implementation has been thoroughly tested locally with:
    • Basic swap operations
    • Liquidity management
    • Error handling
    • Transaction confirmation
    • Added realistic mainnet tests with minimal amounts

Future Work

  1. Decide if we deprecate direct Raydium integration (tracked in a separate issue)
  2. Add documentation for Meteora-specific features
  3. Consider optimizing pool selection for better swap rates

Questions for Reviewers

  1. Is the error handling approach appropriate?
  2. Should we add more logging or metrics?
  3. Are there any security considerations we should address?
  4. Should we handle slippage differently?
  5. What is the best approach for notifying users about the potential direct Raydium lib deprecation?

Copy link
Owner

@piotrostr piotrostr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the PR @bginsber!

left some comments

one more thing - could we have some "realist" tests that run swaps by grabbing the env("FUND_KEYPAIR_PATH") with dust amounts? something like in

#[tokio::test]

should be okay to run it with 100_000 lamports

Cargo.toml Outdated
@@ -66,3 +52,10 @@ borsh = "0.10.3"
indicatif = "0.17"
rig-core = "0.6.0"
thiserror = "2.0.9"
commons = { git = "https://github.com/bginsber/dlmm-sdk.git", package = "commons", version = "0.3.0", branch = "update-tokio" }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we swap this to the https://github.com/MeteoraAg/dlmm-sdk root repo?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

totally

spl-token-2022 = { version = "0.9.0", features = ["no-entrypoint"] }
spl-token = { version = "4.0.0", features = ["no-entrypoint"] }
tokio = { version = "1.37.0", features = ["full"] }
solana-account-decoder = "=2.0.3"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill have to check out this branch and see if 2.0.3 is not going to cause shenanigans

the solana >=2 sdks were not compatible with the searcher client iirc, will lyk

Copy link
Owner

@piotrostr piotrostr Jan 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup
image
honestly i might be dropping the direct raydium lib dependency since it sucks big time, it takes like 4 account calls to do the swap, comes with a lot of peer deps and jupiter can easily allows swapping most raydium tokens with better slipapge prot

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

easier to monitor prices & pool events by using direct raydium though, yeh?

@piotrostr
Copy link
Owner

#16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants