Coder Social home page Coder Social logo

Comments (24)

1500256797 avatar 1500256797 commented on May 28, 2024 2

i met same error
const directionIn = poolKeys.quoteMint.toString() == toToken ^ TypeError: Cannot read properties of null (reading 'quoteMint')

from raydium-sdk-swap-example-typescript.

youngclaude avatar youngclaude commented on May 28, 2024 1

i met same error const directionIn = poolKeys.quoteMint.toString() == toToken ^ TypeError: Cannot read properties of null (reading 'quoteMint')

@soos3d Thanks for your help on this. Its clear the community will use it to trade the latest meme craze of the hour so the acceptance tests should be tight to that use case.

I was able to swap with your default example tokens with no issues using my mainnet Chainstack RPC.

However I am seeing the same issue as others after changing the 'tokenBAddress' address. Did you change anything to get it to work? Here is an example with the Raydium token RAY

image

from raydium-sdk-swap-example-typescript.

peonante avatar peonante commented on May 28, 2024 1

i met same error const directionIn = poolKeys.quoteMint.toString() == toToken ^ TypeError: Cannot read properties of null (reading 'quoteMint')

@soos3d Thanks for your help on this. Its clear the community will use it to trade the latest meme craze of the hour so the acceptance tests should be tight to that use case.
I was able to swap with your default example tokens with no issues using my mainnet Chainstack RPC.
However I am seeing the same issue as others after changing the 'tokenBAddress' address. Did you change anything to get it to work? Here is an example with the Raydium token RAY
image

Hi @youngclaude , quoteMint should be an issue with the slippage. You can edit it from here: slippage line

I tried changing the slippage but nothing changes, the error persists.

I believe the problem is due to the fact that new pairs are not immediately updated in the .. mainnet.json link

from raydium-sdk-swap-example-typescript.

kiknaio avatar kiknaio commented on May 28, 2024 1

Hey folks πŸ‘‹ I have same issue.
I'm trying to get pool information from here https://api.raydium.io/v2/sdk/liquidity/mainnet.json and seems Raydium is updating file not so frequently and one can't get latest deployed pool information from there.
Do you know any alternative services that provide that?

from raydium-sdk-swap-example-typescript.

Krshivam25 avatar Krshivam25 commented on May 28, 2024 1

I swapped the token A (HUMP). to token B (SOL) the terminal show no error and generate the transaction URL but TX-URL_SOLSCAN nothing is there

from raydium-sdk-swap-example-typescript.

Krshivam25 avatar Krshivam25 commented on May 28, 2024 1

even the user dont have the SOL balance on wallet the transaction getting executed and there is no check for this

true, this can be a good feature to add; feel free to contribute and open a PR if you want to implement it!

Sure, I am working on it , will update it here soon : )

from raydium-sdk-swap-example-typescript.

soos3d avatar soos3d commented on May 28, 2024

I have been noticing this error with new coins. Are you trying to swap newly created coins?

from raydium-sdk-swap-example-typescript.

0NighTWizard0 avatar 0NighTWizard0 commented on May 28, 2024

its BOME token (ukHH6c7mMyiWCf1b9pnWe25TSpkDDt3H5pQZgZ74J82)
it came about 6 days ago.

from raydium-sdk-swap-example-typescript.

soos3d avatar soos3d commented on May 28, 2024

just tried it now and the simulation worked fine!

Raydium swap initialized
Swapping 0.01 of So11111111111111111111111111111111111111112 for ukHH6c7mMyiWCf1b9pnWe25TSpkDDt3H5pQZgZ74J82...
Loaded pool keys
Found pool info
{
  minAmountOut: TokenAmount {
    numerator: <BN: 7c19b44>,
    denominator: <BN: f4240>,
    currency: Token {
      decimals: 6,
      symbol: 'UNKNOWN',
      name: 'UNKNOWN',
      programId: [PublicKey [PublicKey(TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA)]],
      mint: [PublicKey [PublicKey(ukHH6c7mMyiWCf1b9pnWe25TSpkDDt3H5pQZgZ74J82)]]
    },
    token: Token {
      decimals: 6,
      symbol: 'UNKNOWN',
      name: 'UNKNOWN',
      programId: [PublicKey [PublicKey(TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA)]],
      mint: [PublicKey [PublicKey(ukHH6c7mMyiWCf1b9pnWe25TSpkDDt3H5pQZgZ74J82)]]
    }
  },
  amountIn: TokenAmount {
    numerator: <BN: 989680>,
    denominator: <BN: 3b9aca00>,
    currency: Token {
      decimals: 9,
      symbol: 'UNKNOWN',
      name: 'UNKNOWN',
      programId: [PublicKey [PublicKey(TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA)]],
      mint: [PublicKey [PublicKey(So11111111111111111111111111111111111111112)]]
    },
    token: Token {
      decimals: 9,
      symbol: 'UNKNOWN',
      name: 'UNKNOWN',
      programId: [PublicKey [PublicKey(TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA)]],
      mint: [PublicKey [PublicKey(So11111111111111111111111111111111111111112)]]
    }
  }
}
{
  context: { apiVersion: '1.17.25', slot: 255567497 },
  value: {
    accounts: null,
    err: null,
    logs: [
      'Program ComputeBudget111111111111111111111111111111 invoke [1]',
      'Program ComputeBudget111111111111111111111111111111 success',
      'Program 11111111111111111111111111111111 invoke [1]',
      'Program 11111111111111111111111111111111 success',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]',
      'Program log: Instruction: InitializeAccount',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 3443 of 999700 compute units',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
      'Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL invoke [1]',
      'Program log: Create',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]',
      'Program log: Instruction: GetAccountDataSize',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1569 of 986390 compute units',
      'Program return: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA pQAAAAAAAAA=',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
      'Program 11111111111111111111111111111111 invoke [2]',
      'Program 11111111111111111111111111111111 success',
      'Program log: Initialize the associated token account',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]',
      'Program log: Instruction: InitializeImmutableOwner',
      'Program log: Please upgrade to SPL Token 2022 for immutable owner support',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1405 of 979803 compute units',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]',
      'Program log: Instruction: InitializeAccount3',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4188 of 975921 compute units',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
      'Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL consumed 24807 of 996257 compute units',
      'Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL success',
      'Program 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 invoke [1]',
      'Program log: ray_log: A4CWmAAAAAAARJvBBwAAAAABAAAAAAAAAICWmAAAAAAAeylzdg8AAACMAmQgAQAAAAjjJAgAAAAA',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]',
      'Program log: Instruction: Transfer',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4736 of 953333 compute units',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]',
      'Program log: Instruction: Transfer',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4645 of 945616 compute units',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
      'Program 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 consumed 31282 of 971450 compute units',
      'Program 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 success',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]',
      'Program log: Instruction: CloseAccount',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 2915 of 940168 compute units',
      'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success'
    ],
    returnData: null,
    unitsConsumed: 62747
  }
}
✨  Done in 21.39s.

from raydium-sdk-swap-example-typescript.

mulerm avatar mulerm commented on May 28, 2024

I have been noticing this error with new coins. Are you trying to swap newly created coins?

This is nice tool. Thanks! I'm trying this with newly created coins and I see the same error. Is this because it attempts to read the price of the token? Why not provide an option for the user to specify?

from raydium-sdk-swap-example-typescript.

peonante avatar peonante commented on May 28, 2024

I have the same problem, it would be interesting to have a solution for swapping new tokens too

from raydium-sdk-swap-example-typescript.

soos3d avatar soos3d commented on May 28, 2024

i met same error const directionIn = poolKeys.quoteMint.toString() == toToken ^ TypeError: Cannot read properties of null (reading 'quoteMint')

@soos3d Thanks for your help on this. Its clear the community will use it to trade the latest meme craze of the hour so the acceptance tests should be tight to that use case.

I was able to swap with your default example tokens with no issues using my mainnet Chainstack RPC.

However I am seeing the same issue as others after changing the 'tokenBAddress' address. Did you change anything to get it to work? Here is an example with the Raydium token RAY

image

Hi @youngclaude , quoteMint should be an issue with the slippage. You can edit it from here: slippage line

from raydium-sdk-swap-example-typescript.

soos3d avatar soos3d commented on May 28, 2024

I'm working on adding retries to re-fetch the pools when they fail. might not fix the issue at 100%, but it should help.

from raydium-sdk-swap-example-typescript.

soos3d avatar soos3d commented on May 28, 2024

Yes, I think that too. Adding retry logic to fetch the pairs should make it better. I'll work on it as soon as I have some time!

from raydium-sdk-swap-example-typescript.

peonante avatar peonante commented on May 28, 2024

must there be something already existing that does this job? I can't find any other repositories or code anywhere that solves this, yet there are swaps and bots that do it

from raydium-sdk-swap-example-typescript.

anisurrahman072 avatar anisurrahman072 commented on May 28, 2024

Guys thanks a lot for your helps. Is there any way to test it first on devnet ?

Why my change "https://api.raydium.io/v2/sdk/liquidity/devnet.json" not works ? @soos3d could you please let me know how can i make the code compatible for Devnet ?

Doing test by Devnet is important really.

from raydium-sdk-swap-example-typescript.

soos3d avatar soos3d commented on May 28, 2024

Guys thanks a lot for your helps. Is there any way to test it first on devnet ?

Why my change "https://api.raydium.io/v2/sdk/liquidity/devnet.json" not works ? @soos3d could you please let me know how can i make the code compatible for Devnet ?

Doing test by Devnet is important really.

Let me look into that!

from raydium-sdk-swap-example-typescript.

soos3d avatar soos3d commented on May 28, 2024

I swapped the token A (HUMP). to token B (SOL) the terminal show no error and generate the transaction URL but TX-URL_SOLSCAN nothing is there

yeah this happens when the chain is really congested; the transactions are simply dropped. Unfortunately, there is not too much we can do at the moment besides increasing priority fees and sens transactions continuously until one goes throughπŸ₯²

from raydium-sdk-swap-example-typescript.

Krshivam25 avatar Krshivam25 commented on May 28, 2024

@soos3d adding to this code need lot of more improvement as even the user dont have the SOL balance on wallet the transaction getting executed and there is no check for this. which is wrong.

from raydium-sdk-swap-example-typescript.

soos3d avatar soos3d commented on May 28, 2024

even the user dont have the SOL balance on wallet the transaction getting executed and there is no check for this

true, this can be a good feature to add; feel free to contribute and open a PR if you want to implement it!

from raydium-sdk-swap-example-typescript.

AMIYA8597 avatar AMIYA8597 commented on May 28, 2024

hello. I don't know why it gives me this error when I exceute the swap. this error related to the pool and it's like the code can't read the pool list.

Loaded pool keys C:\raydium-sdk-swap-example-typescript\src\RaydiumSwap.ts:59 const poolData = this.allPoolKeysJson.find( ^ TypeError: Cannot read properties of undefined (reading 'find') at RaydiumSwap.findPoolInfoForTokens (C:\raydium-sdk-swap-example-typescript\src\RaydiumSwap.ts:59:43) at C:\raydium-sdk-swap-example-typescript\src\index.ts:30:32 at Generator.next () at fulfilled (C:\raydium-sdk-swap-example-typescript\src\index.ts:5:58) at processTicksAndRejections (node:internal/process/task_queues:95:5) error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

here I am facing other error

throw new Error('Non-base' + BASE + ' character')
      ^

Error: Non-base58 character

from raydium-sdk-swap-example-typescript.

brianyeap avatar brianyeap commented on May 28, 2024

Guys thanks a lot for your helps. Is there any way to test it first on devnet ?
Why my change "https://api.raydium.io/v2/sdk/liquidity/devnet.json" not works ? @soos3d could you please let me know how can i make the code compatible for Devnet ?
Doing test by Devnet is important really.

Let me look into that!

i have this issue to, is it becasue raydium does not provide the poolkeys?

from raydium-sdk-swap-example-typescript.

alexandr-kazakov avatar alexandr-kazakov commented on May 28, 2024

The TypeError: Cannot read properties of null (reading 'quoteMint' appears if the app can't load any pools keys for your tokens pairs(for example pair: SOL and USDC).

So you can write instead of

 const poolInfo = raydiumSwap.findPoolInfoForTokens(swapConfig.tokenAAddress, swapConfig.tokenBAddress);
 console.log('Found pool info');

this:

  const poolInfo = raydiumSwap.findPoolInfoForTokens(swapConfig.tokenAAddress, swapConfig.tokenBAddress);
    if (!poolInfo) {
      console.error('Pool not found');
      return 'Pool not found';
    }
  

from raydium-sdk-swap-example-typescript.

alexandr-kazakov avatar alexandr-kazakov commented on May 28, 2024

I'm searching myself ho to make swap for newly created coins. Current this repo solution doesn't work for this.
I implemented this https://solana.stackexchange.com/a/10020/2840 by LIQUIDITY_STATE_LAYOUT_V4 solution too and it doesn't help. I'm thinking about yellowstone-grpc solution now.

Any ideas?

from raydium-sdk-swap-example-typescript.

Related Issues (10)

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.