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

Does this work with Serum v3? #101

Open
jaimindp opened this issue Dec 23, 2021 · 4 comments
Open

Does this work with Serum v3? #101

jaimindp opened this issue Dec 23, 2021 · 4 comments

Comments

@jaimindp
Copy link

Does Pyserum work with Serum v3?

After following the test code for market.place_order() I am getting the error on the Solana Block Explorer:

Program returned error: invalid program argument
Runtime error: invalid program argument

@quazzuk
Copy link
Contributor

quazzuk commented Dec 24, 2021

Does Pyserum work with Serum v3?

Yes, it does.

@jaimindp
Copy link
Author

I am having this error when trying to place a limit order on the SOL/USDC order book and am wondering why?

The transaction goes through, (the quote wallet is created) however the order on the Solana explorer it fails with: invalid program argument

I am wondering how I can fix this?

from pyserum.connection import conn
from pyserum.enums import OrderType, Side
from pyserum.market import Market
from solana.account import Account
from solana.publickey import PublicKey
from solana.rpc.types import TxOpts
from spl.token.client import Token
from spl.token.constants import TOKEN_PROGRAM_ID

cc = conn("https://solana-api.projectserum.com")
payer = keypair

quote_token = Token(
    cc,
    pubkey=PublicKey("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"), # mint address of token USDC
    program_id=TOKEN_PROGRAM_ID,
    payer=payer,
)

quote_wallet = quote_token.create_account(
  payer.public_key,
  skip_confirmation=True)  # Make sure you send tokens to this address
print("quote wallet: ", str(quote_wallet))

market_address = PublicKey("9wFFyRfZBsuAha4YcuxcXLKwMxJR43S7fPfQLusDBzvT") # Address for SOL/USDC
market = Market.load(cc, market_address)

tx_sig = market.place_order(
    payer=quote_wallet,
    owner=payer,
    side=Side.BUY,
    order_type=OrderType.LIMIT,
    limit_price=179,
    max_quantity=0.01,
    opts = TxOpts(skip_preflight=True)
)
print(tx_sig)

@a742377190
Copy link

I also encountered this problem, could you give me a sample code?thanks

@xloem
Copy link

xloem commented Apr 27, 2022

For me this was because my max_quantity was zero. I believe it should be an integer in lamports, so 0.01 would get rounded to zero. Could be wrong, still trying to make it work.

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

No branches or pull requests

4 participants