-
Notifications
You must be signed in to change notification settings - Fork 2
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
v1 program #175
base: main
Are you sure you want to change the base?
v1 program #175
Conversation
token::authority = trader, | ||
token::token_program = token_program_input | ||
)] | ||
pub ta_input_trader: InterfaceAccount<'info, TokenAccount>, |
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.
Is it possible that the trader doesn't have an input account?
token::authority = searcher, | ||
token::token_program = token_program_output | ||
)] | ||
pub ta_output_searcher: InterfaceAccount<'info, TokenAccount>, |
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.
is it possible that the searcher doesn't have an output ata yet?
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.
possible, although initializing this would need to be added into the logic of the method. also this wouldn't be straightforward to initialize if we wanted to keep it generic to all token accounts (not just ATAs)
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.
mmmmmmmmmm, why is ok to have init_if_needed for the router token accounts but not here
fee_ppm: u64, | ||
) -> Result<u64> { | ||
// we do the computation in u128 to avoid overflow in case of large amounts | ||
let fee_u128 = (amount as u128) |
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.
It's more idomatic to use u128::from
and u64::try_from
#[account( | ||
init_if_needed, | ||
payer = searcher, | ||
mut, |
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.
I like init_if_needed more tbh, makes the sdk simpler
@@ -6,6 +6,9 @@ edition = "2021" | |||
|
|||
[dependencies] | |||
anchor-lang = ">=0.29.0" | |||
anchor-spl = ">=0.29.0" | |||
spl-token = ">=0.7.0" | |||
spl-associated-token-account = ">=0.6.0" |
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.
nitpick: can you make these dev dependencies instead of dependencies?
changes to program to support v1
This PR is still a draft. Some of the testing code needs to be refactored. However, the swap method is functional as of now and somewhat tested.