staratlasmeta / factory

Star Atlas Factory for constructing Transactions targeting Solana on-chain programs
https://www.npmjs.com/package/@staratlas/factory
Apache License 2.0
37 stars 15 forks source link

Cannot create order #112

Closed mindrunner closed 2 years ago

mindrunner commented 2 years ago

I am trying to use the GmClientService to interact with the Star Atlas Marcetplace. I am trying to create a Buy Order:

  const resource = new PublicKey('ammo.....') 
  const quoteMint = new PublicKey('ATLAS.....') 
  const market = new PublicKey('trader.....') 
  const amount = 10

    const orders = gmOrderbookService.getSellOrdersByCurrencyAndItem(
        quoteMint.toString(),
        resource.toString())
        .sort((a, b) => a.uiPrice - b.uiPrice)

 const orderTx = await gmClientService.getInitializeOrderTransaction(
        connection,
        keyPair.publicKey,
        resource,
        quoteMint,
        amount,
        orders[0].price,
        market,
        OrderSide.Buy
    )

    const txid = await connection.sendTransaction(orderTx.transaction, [...orderTx.signers, keyPair])

Resulting in an error: error: Error: failed to send transaction: Transaction simulation failed: Attempt to debit an account but found no record of a prior credit.

Ther keypair I am using has SOL/ATLAS and all fleet-resources in stock already and is able to trade on serum marketplace via serum-ts.

What am I missing here?

mindrunner commented 2 years ago

Stupid me: Wrong signers order

connection.sendTransaction(orderTx.transaction, [keyPair, ...orderTx.signers])