-
Notifications
You must be signed in to change notification settings - Fork 63
feat/transfer hook support #192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
bangyro
wants to merge
10
commits into
release_0.1.11
Choose a base branch
from
feat/transfer_hook_support2
base: release_0.1.11
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2a44572
feat: add transfer_hook_support
bangyro 1329f89
feat: fully isolated events
bangyro b2deba9
feat: error if transfer hook not revoked
bangyro 41d18ae
feat: update changelog
bangyro 6c1a1b1
fix: remove unused
bangyro ac548d8
fix: remove unused events
bangyro 43b658b
fix: explicitly reject in deprecated method
bangyro 7967b61
fix: revert zap_protocol_fee and claim_protocol_fee lifecycles changes
bangyro 91dc6f0
docs: add comment
bangyro 2538702
docs: add comment
bangyro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| { | ||
| "address": "EBZDYx7599krFc4m2govwBdZcicr4GgepqC78m71nsHS", | ||
| "metadata": { | ||
| "name": "transfer_hook_counter", | ||
| "version": "0.1.0", | ||
| "spec": "0.1.0" | ||
| }, | ||
| "instructions": [ | ||
| { | ||
| "name": "initialize_extra_account_meta_list", | ||
| "discriminator": [92, 197, 174, 197, 41, 124, 19, 3], | ||
| "accounts": [ | ||
| { | ||
| "name": "payer", | ||
| "writable": true, | ||
| "signer": true | ||
| }, | ||
| { | ||
| "name": "extra_account_meta_list", | ||
| "writable": true | ||
| }, | ||
| { | ||
| "name": "mint" | ||
| }, | ||
| { | ||
| "name": "counter_account", | ||
| "writable": true | ||
| }, | ||
| { | ||
| "name": "token_program" | ||
| }, | ||
| { | ||
| "name": "associated_token_program" | ||
| }, | ||
| { | ||
| "name": "system_program" | ||
| } | ||
| ], | ||
| "args": [] | ||
| }, | ||
| { | ||
| "name": "transfer_hook", | ||
| "discriminator": [220, 57, 220, 152, 126, 125, 97, 168], | ||
| "accounts": [ | ||
| { | ||
| "name": "source_token" | ||
| }, | ||
| { | ||
| "name": "mint" | ||
| }, | ||
| { | ||
| "name": "destination_token" | ||
| }, | ||
| { | ||
| "name": "owner" | ||
| }, | ||
| { | ||
| "name": "extra_account_meta_list" | ||
| }, | ||
| { | ||
| "name": "counter_account", | ||
| "writable": true | ||
| } | ||
| ], | ||
| "args": [ | ||
| { | ||
| "name": "amount", | ||
| "type": "u64" | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "accounts": [ | ||
| { | ||
| "name": "CounterAccount", | ||
| "discriminator": [164, 8, 153, 71, 8, 44, 93, 22] | ||
| } | ||
| ], | ||
| "errors": [ | ||
| { | ||
| "code": 6000, | ||
| "name": "AmountTooBig", | ||
| "msg": "The amount is too big" | ||
| } | ||
| ], | ||
| "types": [ | ||
| { | ||
| "name": "CounterAccount", | ||
| "type": { | ||
| "kind": "struct", | ||
| "fields": [ | ||
| { | ||
| "name": "counter", | ||
| "type": "u32" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
programs/dynamic-bonding-curve/src/event/transfer_hook.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| use anchor_lang::prelude::*; | ||
|
|
||
| use crate::{state::SwapResult2, SwapParameters2}; | ||
|
|
||
| #[event] | ||
| pub struct EvtInitializePoolWithTransferHook { | ||
| pub pool: Pubkey, | ||
| pub config: Pubkey, | ||
| pub creator: Pubkey, | ||
| pub base_mint: Pubkey, | ||
| pub pool_type: u8, | ||
| pub activation_point: u64, | ||
| } | ||
|
|
||
| #[event] | ||
| pub struct EvtVirtualPoolMetadataWithTransferHook { | ||
| pub virtual_pool_metadata: Pubkey, | ||
| pub virtual_pool: Pubkey, | ||
| } | ||
|
|
||
| #[event] | ||
| pub struct EvtSwap2WithTransferHook { | ||
| pub pool: Pubkey, | ||
| pub config: Pubkey, | ||
| pub trade_direction: u8, | ||
| pub has_referral: bool, | ||
| pub swap_parameters: SwapParameters2, | ||
| pub swap_result: SwapResult2, | ||
| pub quote_reserve_amount: u64, | ||
| pub migration_threshold: u64, | ||
| pub current_timestamp: u64, | ||
| } | ||
|
|
||
| #[event] | ||
| pub struct EvtCurveCompleteWithTransferHook { | ||
| pub pool: Pubkey, | ||
| pub config: Pubkey, | ||
| pub base_reserve: u64, | ||
| pub quote_reserve: u64, | ||
| } | ||
|
|
||
| #[event] | ||
| pub struct EvtClaimProtocolFee2WithTransferHook { | ||
| pub pool: Pubkey, | ||
| pub receiver_token_account: Pubkey, | ||
| pub token_mint: Pubkey, | ||
| pub amount: u64, | ||
| } | ||
|
|
||
| #[event] | ||
| pub struct EvtClaimTradingFeeWithTransferHook { | ||
| pub pool: Pubkey, | ||
| pub token_base_amount: u64, | ||
| pub token_quote_amount: u64, | ||
| } | ||
|
|
||
| #[event] | ||
| pub struct EvtClaimCreatorTradingFeeWithTransferHook { | ||
| pub pool: Pubkey, | ||
| pub token_base_amount: u64, | ||
| pub token_quote_amount: u64, | ||
| } | ||
|
|
||
| #[event] | ||
| pub struct EvtPartnerWithdrawSurplusWithTransferHook { | ||
| pub pool: Pubkey, | ||
| pub surplus_amount: u64, | ||
| } | ||
|
|
||
| #[event] | ||
| pub struct EvtCreatorWithdrawSurplusWithTransferHook { | ||
| pub pool: Pubkey, | ||
| pub surplus_amount: u64, | ||
| } | ||
|
|
||
| #[event] | ||
| pub struct EvtWithdrawLeftoverWithTransferHook { | ||
| pub pool: Pubkey, | ||
| pub leftover_receiver: Pubkey, | ||
| pub leftover_amount: u64, | ||
| } | ||
|
|
||
| #[event] | ||
| pub struct EvtUpdatePoolCreatorWithTransferHook { | ||
| pub pool: Pubkey, | ||
| pub creator: Pubkey, | ||
| pub new_creator: Pubkey, | ||
| } | ||
|
|
||
| #[event] | ||
| pub struct EvtWithdrawMigrationFeeWithTransferHook { | ||
| pub pool: Pubkey, | ||
| pub fee: u64, | ||
| pub flag: u8, | ||
| } | ||
|
|
||
| #[event] | ||
| pub struct EvtClaimPoolCreationFeeWithTransferHook { | ||
| pub pool: Pubkey, | ||
| pub receiver: Pubkey, | ||
| pub creation_fee: u64, | ||
| } | ||
|
|
||
| #[event] | ||
| pub struct EvtPartnerClaimPoolCreationFeeWithTransferHook { | ||
| pub pool: Pubkey, | ||
| pub partner: Pubkey, | ||
| pub creation_fee: u64, | ||
| pub fee_receiver: Pubkey, | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The transfer hook events have the same properties but different name to isolate them from the non-transfer hook events