Skip to content
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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

v1 program #175

wants to merge 10 commits into from

Conversation

anihamde
Copy link
Contributor

@anihamde anihamde commented Oct 17, 2024

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.

@anihamde anihamde marked this pull request as draft October 17, 2024 13:26
token::authority = trader,
token::token_program = token_program_input
)]
pub ta_input_trader: InterfaceAccount<'info, TokenAccount>,
Copy link
Contributor

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>,
Copy link
Contributor

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?

Copy link
Contributor Author

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)

Copy link
Contributor

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)
Copy link
Contributor

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,
Copy link
Contributor

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"
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants