-
Notifications
You must be signed in to change notification settings - Fork 26
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
feat: add swap-baby swap adapter #143
base: main
Are you sure you want to change the base?
Conversation
let mut hops = vec![first_hop]; | ||
// we omit the last swap operation | ||
// since that is already the coin_out | ||
operations.pop(); | ||
// if it is not empty, we fill the other left operations. | ||
if !operations.is_empty() { | ||
hops.extend(operations.into_iter().map(|op| Hop { | ||
pool: op.pool, | ||
denom: op.denom_out, | ||
})); | ||
} | ||
|
||
let query_msg = swap_baby::QueryMsg::SimulateSwapExactAmountOutWithHops { | ||
want_out: coin_out, | ||
hops, | ||
}; |
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.
Isn't the first_hop here added twice? since only the last element is popped and then the rest of operations extend the vec (which still has the first hop)
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.
Or is this intended?
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.
this is intended and it's more of a forward compatibility thing.
fundamentally swap baby does not route based on pools but routes based on assets (although it has a notion of pool)
example:
swap op is BTC->USDT->ETH (so I put BTC and want ETH out)
then the swap ops are two:
- BTC for USDT
- USDT for ETH
but the swap baby hops are actually three: BTC -> USDT -> ETH (the asset out) that's why the first pool is used twice, because it contains the initial input.
use cosmwasm_std::{to_json_binary, Coin, CosmosMsg, Decimal, StdResult, Uint128, WasmMsg}; | ||
|
||
#[cw_serde] | ||
pub enum ExecuteMsg { |
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.
Question to learn: Does swap baby plan to be open sourced / in a GH repo we can link to instead of copying over the types, or is this the best way forward (no plans to release the code)
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.
Soon to be open sourced!
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.
left some comments, feel free to request a re-review once answered/addressed, great work!
No description provided.