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
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