Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

159
Visualizações
Serum Error What is "Unable to simulate swap"?

I would like to swap using project-serum/serum-ts. I prepared the following while reading readme.MD.

  • Use the latest version of Yarn etc.
  • Install the dependent modules according to readme.MD
  • Prepare the id.json file containing the wallet secret in ./config/solana/id.json
  • Put 0.01 SOL in the wallet on mainnet-beta.

After that, I tried to run node ./package/swap/example/swap.js, which is prepared for the sample.

This file -> https://github.com/project-serum/serum-ts/blob/master/packages/swap/examples/swap.js

I confirmed that it worked until line 26 _srmSwapPairs.

However, at line 29, I get the following error

Error: Unable to simulate swap
at Swap.estimate (/mnt/c/Users/username/Desktop/solana_test/serum-ts/packages/swap/lib/index.js:401:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async main (/mnt/c/Users/username/Desktop/solana_test/serum-ts/packages/swap/examples/swap.js:29:25)

My OS is Windows 10, but I am using WSL.

What could be the cause?

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

This is most likely failing because you're trying to simulate a swap from SRM to USDC on your wallet, but your wallet doesn't have enough SRM to complete the trade, or doesn't have the accounts to conduct the trade.

To learn more about the issue, you can hack the code to print out more information about the failure:

    const resp = await this.program.provider.simulate(
      tx,
      signers,
      params.options,
    );
    if (resp === undefined || resp.value.err || !resp.value.logs) {
      console.error(resp); // get more information about the error
      throw new Error('Unable to simulate swap');
    }

You can make the changes at https://github.com/project-serum/serum-ts/blob/93946077cbacc4149a3372d9e6651bf4de18a255/packages/swap/src/index.ts#L535

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda