0

raydium SDK or raydium rust API does not have any documentation, so its very difficult to understand.

def make_swap_instruction(self, amount_in: int, token_account_in: PublicKey, token_account_out: PublicKey,
                          accounts: dict) -> TransactionInstruction:
    keys = [
        AccountMeta(pubkey=TOKEN_PROGRAM_ID, is_signer=False, is_writable=False),
        AccountMeta(pubkey=accounts["amm_id"], is_signer=False, is_writable=True),
        AccountMeta(pubkey=accounts["authority"], is_signer=False, is_writable=False),
        AccountMeta(pubkey=accounts["open_orders"], is_signer=False, is_writable=True),
        AccountMeta(pubkey=accounts["target_orders"], is_signer=False, is_writable=True),
        AccountMeta(pubkey=accounts["base_vault"], is_signer=False, is_writable=True),
        AccountMeta(pubkey=accounts["quote_vault"], is_signer=False, is_writable=True),
        AccountMeta(pubkey=SERUM_PROGRAM_ID, is_signer=False, is_writable=False),
        AccountMeta(pubkey=accounts["market_id"], is_signer=False, is_writable=True),
        AccountMeta(pubkey=accounts["bids"], is_signer=False, is_writable=True),
        AccountMeta(pubkey=accounts["asks"], is_signer=False, is_writable=True),
        AccountMeta(pubkey=accounts["event_queue"], is_signer=False, is_writable=True),
        AccountMeta(pubkey=accounts["market_base_vault"], is_signer=False, is_writable=True),
        AccountMeta(pubkey=accounts["market_quote_vault"], is_signer=False, is_writable=True),
        AccountMeta(pubkey=accounts["market_authority"], is_signer=False, is_writable=False),
        AccountMeta(pubkey=token_account_in, is_signer=False, is_writable=True),
        AccountMeta(pubkey=token_account_out, is_signer=False, is_writable=True),
        AccountMeta(pubkey=self.owner.public_key, is_signer=True, is_writable=False)
    ]
    data = SWAP_LAYOUT.build(
        dict(
            instruction=9,
            amount_in=int(amount_in),
            min_amount_out=0
        )
    )
    return TransactionInstruction(keys, AMM_PROGRAM_ID, data)
  async def buy(self, amount):
        swap_tx = Transaction()
        signers = [self.owner]
        token_account_in = self.quote_token_account
        token_account_out = self.base_token_account
        amount_in = amount * 10 ** self.pool_keys['quote_decimals']
        swap_tx.add(
            self.make_create_associated_account_instruction(amount_in, token_account_in, token_account_out, self.pool_keys),
            self.make_swap_instruction(amount_in, token_account_in, token_account_out, self.pool_keys))
        swap_tx = swap_tx.sign(*signers)
        return await self.conn.send_raw_transaction(swap_tx)

I am getting following error

solders.SignerError: not enough signers

There is very little documentation available online and I am new to solana. Any help would be appreciated Thanks

3
  • Please fix formatting and add some more detail wrt to what you want your code to do.
    – Ahri
    Commented Dec 31, 2023 at 23:18
  • have you been able to resolve this issue? If possible, could publish here the code to do the swap on Raydium in Python. I cannot find a working example on the web. Tnx Commented Mar 15 at 7:54
  • This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From Review
    – Ahri
    Commented Mar 15 at 12:37

1 Answer 1

1

Review the https://github.com/raydium-io/raydium-sdk/blob/895abf5dfff8d83a1d42aa94ec278e18aad6f2a6/src/tradeV2/trade.ts#L734 and https://github.com/raydium-io/raydium-sdk/blob/895abf5dfff8d83a1d42aa94ec278e18aad6f2a6/src/common/web3.ts#L374 it may be you're working with dated information as it does appear that LUTs are being used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.