Skip to content

Commit

Permalink
updated the simulate_pool_swap token in format
Browse files Browse the repository at this point in the history
  • Loading branch information
kakucodes committed Apr 1, 2024
1 parent 4437b87 commit b7b5250
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/osmosis-helpers/src/osmosis_lp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub fn join_osmosis_cl_pool_single_side(
querier,
user_addr,
&pool_id,
coin(
&coin(
offer_asset.amount.checked_div(2u128.into())?.u128(),
offer_asset.denom.clone(),
),
Expand Down
18 changes: 8 additions & 10 deletions packages/osmosis-helpers/src/osmosis_swap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,12 @@ pub fn generate_swap(
pub fn simulate_pool_swap(
querier: &QuerierWrapper,
pool_id: &u64,
offer_asset: &str,
offer_token: &CWCoin,
token_out_denom: &str,
) -> Result<EstimateSwapExactAmountInResponse, OsmosisHelperError> {
let simulation = EstimateSwapExactAmountInRequest {
pool_id: pool_id.clone(),
token_in: offer_asset.to_string(),
token_in: format!("{}{}", offer_token.amount, offer_token.denom),
routes: vec![SwapAmountInRoute {
pool_id: *pool_id,
token_out_denom: token_out_denom.to_string(),
Expand All @@ -460,19 +460,17 @@ pub fn pool_swap_with_sim(
querier: &QuerierWrapper,
user_addr: &Addr,
pool_id: &u64,
offer_asset: cosmwasm_std::Coin,
offer_asset: &CWCoin,
token_out_denom: &str,
token_out_min_amount: Uint128,
) -> Result<(Vec<CosmosProtoMsg>, Uint128), OsmosisHelperError> {
let offer_coin = Coin {
denom: offer_asset.denom.to_string(),
amount: offer_asset.amount.to_string(),
};

Ok((
vec![CosmosProtoMsg::OsmosisSwapExactAmountIn(
MsgSwapExactAmountIn {
token_in: Some(offer_coin.clone()),
token_in: Some(Coin {
denom: offer_asset.denom.to_string(),
amount: offer_asset.amount.to_string(),
}),
sender: user_addr.to_string(),
token_out_min_amount: token_out_min_amount.to_string(),
routes: vec![SwapAmountInRoute {
Expand All @@ -482,7 +480,7 @@ pub fn pool_swap_with_sim(
},
)],
Uint128::from_str(
simulate_pool_swap(querier, pool_id, &offer_coin.denom, token_out_denom)?
simulate_pool_swap(querier, pool_id, offer_asset, token_out_denom)?
.token_out_amount
.as_str(),
)?,
Expand Down

0 comments on commit b7b5250

Please sign in to comment.