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

Integrate Jupiter adapter #2

Merged
merged 9 commits into from
Jan 13, 2023
Merged

Integrate Jupiter adapter #2

merged 9 commits into from
Jan 13, 2023

Conversation

ghost
Copy link

@ghost ghost commented Oct 19, 2022

This update will support Jupiter protocol in Gateway program, so that all the state can be stored on chain and provide better user experience to check the asset flow in Activity pages. See more details below.

  • Handle swap config to pass through correct instruction data
  • Set swap_config to [u8; 30] for scalability as Jupiter's parameter SwapLeg might be longer in the future.

Will also update these repo to make all functions works:
gateway-programs
gateway

@ghost ghost force-pushed the jupiter-adapter branch from d5d4e37 to 80c1856 Compare November 17, 2022 06:16
@ghost ghost force-pushed the jupiter-adapter branch from 06833b0 to d371787 Compare December 28, 2022 03:10
@ghost ghost changed the title wip: integrate Jupiter adapter Integrate Jupiter adapter Jan 4, 2023
programs/adapter-jupiter/src/lib.rs Outdated Show resolved Hide resolved
let mut swap_data = vec![];
swap_data.append(&mut discriminator.try_to_vec()?);
swap_data.extend(
&mut input_struct.swap_config[start_index..=last_index]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wonder: what is start_index and last_index for

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For extracting swap config
Jupiter swap's ix data contain 5 props in this order:
a). SwapLeg: (uncertain length)
b) inAmount: u64
c) outAmount: u64
d) slippage: u16
e) platform fee: u8

since we can only set swap_config a fix u8 array size in SwapInwrapper,
we need to extract the subarray from this attribute to fit the payload format.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted

overflow-checks = true

[dependencies]
anchor-lang = "0.24.2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upgrade to v0.26.0

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to build with v0.26.0, however, all adapters should also update to v0.26.0 to proceed compile.
Shall I push all updates on Cargo.toml in this repo?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, plz

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OKay.

let mut swap_data = vec![];
swap_data.append(&mut discriminator.try_to_vec()?);
swap_data.extend(
&mut input_struct.swap_config[start_index..=last_index]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted

@ironaddicteddog ironaddicteddog merged commit ec4b7f7 into master Jan 13, 2023
@ironaddicteddog ironaddicteddog deleted the jupiter-adapter branch January 13, 2023 06:58
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