0

I'm using anchor, and would like a handler call to error if there are other instructions within the same transaction. How can I accomplish this?

The use-case here is a liquidation call in a perp market, in an attempt to deter liquidation hunting.

i.e.

  1. manipulate price
  2. force liquidation
  3. unwind + profit

all within the same transaction

3

1 Answer 1

1

You will have to use the solana instructions sysvar. You need to ensure that there is only one instruction and that that instruction is an invocation to your program, otherwise a user could create a program that calls your instruction and others in a single instruction.

This is usually not great to do though because it limits your program's composability. There are very few attacks that are stopped by running this check, the attack you listed is not one of them.

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.