1

Is there a way to modify the transfer_hook in order to deduct tax fee in $SOL from swap transaction only? I know there is transfer-hook supported that, but dont know how I check program address of pair mint address when transfer to ensure that it's a swap transaction

1 Answer 1

3

This is up to your own design in the end, but if you want to detect that a particular transfer is being called from a swap program, there's a few options:

  • include the "instructions" sysvar in your transfer hook so that you can inspect who might have called into your transfer hook program. This is a bit brittle though, since someone might have a program that calls into a swap program, and you might not be able to detect it
  • add a list of "known swap addresses", PDAs that own token accounts for swap programs. You can check to see if either of the owners is one of those PDAs, and charge your fee if the address is found in that list
1
  • Thanks for your answer
    – Jade
    Commented Mar 15 at 1:27

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.