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

Support split routes in entry point contract #101

Merged
merged 4 commits into from
Apr 30, 2024
Merged

Conversation

thal0x
Copy link
Member

@thal0x thal0x commented Apr 23, 2024

Updates the Entry Point contract to support multiple routes when calling SwapExactAssetIn.

SwapExactAssetOut will continue to be unsupported for the time being due to added complexity and no current integrators supporting this anyways.

@thal0x thal0x requested a review from NotJeremyLiu April 23, 2024 16:10
Copy link
Member

@NotJeremyLiu NotJeremyLiu left a comment

Choose a reason for hiding this comment

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

approving to unblock but left comments/considerations to address

.enumerate()
.max_by_key(|(_, route)| route.offer_asset.amount())
.map(|(idx, _)| idx)
.unwrap()
Copy link
Member

Choose a reason for hiding this comment

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

How does the handle routes with the same amount in? Is it first route or does it error be if there's a tie?

Also using unwrap in general is a practice that should be avoided / used in tests but not prod code if can be caught and given a useful error instead

@@ -646,3 +686,26 @@ fn query_swap_asset_in(

Ok(fee_swap_asset_in)
}

// fn get_largest_route_idx(routes: Vec<Route>) -> usize {
Copy link
Member

Choose a reason for hiding this comment

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

Delete commented out fn

&deps,
fee_swap,
&mut remaining_asset,
&ibc_fee_coin,
)?;

// Update the user swap to deduct the ibc fee amount from the route
// with the largest input amount
user_swap = match user_swap.clone() {
Copy link
Member

Choose a reason for hiding this comment

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

This logic makes sense to me, it just has to match with what the server does

@thal0x thal0x merged commit 94c3bbf into main Apr 30, 2024
5 checks passed
@thal0x thal0x deleted the jw/entry-point-split-route branch April 30, 2024 10:47
thal0x added a commit that referenced this pull request May 7, 2024
thal0x added a commit that referenced this pull request May 7, 2024
* Revert "Add split route support in all adapters (#103)"

This reverts commit 1fa4f21.

* Revert "Support multiple routes in astroport adapter (#99)"

This reverts commit a95f17d.

* Revert "Support split routes in entry point contract (#101)"

This reverts commit 94c3bbf.

* Revert "Update contract types to support route splitting (#98)"

This reverts commit ec1fd57.

* Revert "add interface field to SwapOperation (#96)"

This reverts commit eb37618.
thal0x added a commit that referenced this pull request May 8, 2024
* add SmartSwapExactAssetIn swap type

* Revert "Add split route support in all adapters (#103)"

This reverts commit 1fa4f21.

* Revert "Support multiple routes in astroport adapter (#99)"

This reverts commit a95f17d.

* Revert "Support split routes in entry point contract (#101)"

This reverts commit 94c3bbf.

* Revert "Update contract types to support route splitting (#98)"

This reverts commit ec1fd57.

* Revert "add interface field to SwapOperation (#96)"

This reverts commit eb37618.

* remove deployed test contracts

* fix fmt issue

* update schema

* since user_swap is mutatable, we can mutate in place

* swap excess funds

* update schema

* lint change

* fix test

* add optional interface field to SwapOperation (#108)

* return error for largest_route_index

---------

Co-authored-by: Jeremy Liu <[email protected]>
thal0x added a commit that referenced this pull request May 8, 2024
* add SmartSwapExactAssetIn swap type

* Revert "Add split route support in all adapters (#103)"

This reverts commit 1fa4f21.

* Revert "Support multiple routes in astroport adapter (#99)"

This reverts commit a95f17d.

* Revert "Support split routes in entry point contract (#101)"

This reverts commit 94c3bbf.

* Revert "Update contract types to support route splitting (#98)"

This reverts commit ec1fd57.

* Revert "add interface field to SwapOperation (#96)"

This reverts commit eb37618.

* remove deployed test contracts

* fix fmt issue

* update schema

* since user_swap is mutatable, we can mutate in place

* swap excess funds

* update schema

* lint change

* fix test

* add optional interface field to SwapOperation (#108)

* return error for largest_route_index

* [API-2792] Add hallswap adapter (#102)

* feat: add hallswap adapter

* chore: add readme

* pr fixes

* add optional interface field to SwapOperation

* update hallswap adapter to implement updated interface

* remove get_hallswap_routes_from_skip_routes

---------

Co-authored-by: thal0x <[email protected]>

---------

Co-authored-by: Jeremy Liu <[email protected]>
Co-authored-by: Yonggiee <[email protected]>
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