pyserum icon indicating copy to clipboard operation
pyserum copied to clipboard

Does this work with Serum v3?

Open jaimindp opened this issue 3 years ago • 4 comments
trafficstars

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

jaimindp avatar Dec 23 '21 01:12 jaimindp

Does Pyserum work with Serum v3?

Yes, it does.

quazzuk avatar Dec 24 '21 11:12 quazzuk

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)

jaimindp avatar Dec 24 '21 14:12 jaimindp

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

a742377190 avatar Jan 26 '22 03:01 a742377190

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.

xloem avatar Apr 27 '22 21:04 xloem