3

I recently encountered an error while trying to withdraw stSOL from the Tulip Protocol's "Lending" section:

Program Error: "Instruction #3 Failed - null"

At first, I thought it was just an honest UI issue. I tried to reach the protocol's support via Discord and Telegram, but found only scammers trying to steal my private key everywhere. I also noticed significant inactivity from the protocol's official channels, including their X account, and came to the conclusion that there is no support, only scams 🫠

Given the situation, I decided to dive into Solana development to build a tool that can help withdraw the tokens. However, I need some guidance on where to start to understand how this particular programs to be able to construct a valid transaction.

Can anyone provide advice on the necessary steps to locate, inspect the Program, and build a valid transaction for it? Are there any resources, tutorials, or existing tools that can help with this process?

Any guidance or resources would be greatly appreciated. Thank you!

1 Answer 1

4

There's a few steps you'll need to take:

  1. Check if it's open-source. You may need to do some searching on their website, docs, and github for this. If it is, then your life has just got a whole lot easier. A public repo will let you easily inspect each instruction in the program and its required accounts + arguments. Additionally, if it's built with Anchor you can pull it down, build it, and get the IDL to start interacting with it from a frontend client.
  2. Check for a public IDL. If it isn't open-source, then they may have published an IDL on-chain for you to pull. You can run this command against their program ID to see if it is: anchor idl fetch -o <out-file.json> <program-id>. If this is successful, then you can import it into a frontend client and start calling instructions.
  3. If there's no public IDL, and it isn't open-source, you'll need to start reverse engineering (i.e reference explorers, start deducing what accounts do what, and attempting to call instructions via your own scripting). There's more than a few ways of going about this, depending on what you're comfortable with. I've linked a few resources at the bottom that might help.

EDIT: If inspecting binaries is your fancy, then the second answer on the question linked above gives a method of decompiling programs deployed on mainnet

2
  • First of all thanks a lot for the answer! So I checked and it seems that it's not open source and it doesn't have an IDL🙁 (Unless I am missing something) I tried to follow osec.io/blog/2022-08-27-reverse-engineering-solana blogpost but apparently only paid version of Binary Ninja supports plugins Isn't there any other way? From the failed transaction: explorer.solana.com/tx/… it seems like some oracle related issue, if that's the case than there is nothing to do about it? Commented Jun 16 at 15:33
  • It appears to be using pyth oracles, which narrows things down. From the simulation you sent, you can likely cross reference the accounts passed in with known pyth oracles on mainnet (pyth.network/price-feeds?cluster=solana-mainnet-beta), and narrow down which one it might be using. This seems to be a matter of the specific oracle not being updated in a timely manner, resulting in a stale price. If you can deduce which oracle is being used, you may be able to add a substitute, copy the ix data and accounts, and try to call the instruction via script with the new oracle
    – Joey Meere
    Commented Jun 16 at 15:43

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.