Code Monkey home page Code Monkey logo

soldexpy's Introduction

Solana Raydium Experiment

This is an experimental Python toolkit to work with Raydium Liquidity Pool V4 by using only Solana RPC. You can swap tokens, get price and even get the lp locked ratio by simulating transaction.

Disclaimer

This is written just for research purpose and it may contain old or unsafe way. Keep this code here as a reference only.

Features

  • RaydiumPool
    • get_price: You can get price based on the pool status. It supports simulating slippage.
      • *Only supports basic and network fee is not considered.
  • Swap
    • update_local_price_on_changes: Uses websocket to watch price changes and reflect price on object immediately.
    • buy: Use SOL to buy token.
    • sell: Use token to buy SOL.
    • get_pool_lp_locked_ratio: Retrieve locked ratio of liquidity pool.
  • Wallet
    • get_balance: Get specified token balance of the user.
    • get_sol_balance: Get SOL balance of the user.

*Only supports the pool that has SOL as the base or quote token.

Example

# load private key
keypair = Keypair.from_bytes(base58.b58decode(PRIVATE_KEY))
# configure rpc client
client = Client("https://api.mainnet-beta.solana.com")

# get pool
pool = RaydiumPool(client, "AVs9TA4nWDzfPJE9gGVNJMVhcQy3V9PGazuz33BfG2RA")
# initialize Swap
swap = Swap(client, pool)

# buy
swap.buy(1.0, 0.1, keypair)

Development

Testing

pytest

soldexpy's People

Contributors

leq6c avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.