Skip to content

Commit

Permalink
feat: add recipient to pool
Browse files Browse the repository at this point in the history
  • Loading branch information
ApolloGie committed Aug 15, 2024
1 parent 9d65db2 commit 46db747
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion cw-dex-astroport/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ impl Pool for AstroportPool {
env: &Env,
assets: AssetList,
min_out: Uint128,
recipient: Option<String>,
) -> Result<Response, CwDexError> {
let (funds, cw20s) = separate_natives_and_cw20s(&assets);

Expand Down Expand Up @@ -186,7 +187,7 @@ impl Pool for AstroportPool {
assets: assets_vec.iter().map(asset_to_astroport_v5_asset).collect(),
slippage_tolerance: Some(Decimal::from_str(MAX_ALLOWED_SLIPPAGE)?),
auto_stake: Some(false),
receiver: None,
receiver: recipient,
min_lp_to_receive: Some(min_out),
})?,
funds,
Expand Down
1 change: 1 addition & 0 deletions cw-dex-osmosis/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ impl Pool for OsmosisPool {
env: &Env,
assets: AssetList,
min_out: Uint128,
_recipient: Option<String>,
) -> Result<Response, CwDexError> {
let mut assets = assets;

Expand Down
3 changes: 2 additions & 1 deletion cw-dex/src/implementations/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ impl PoolTrait for Pool {
env: &Env,
assets: AssetList,
min_out: Uint128,
recipient: Option<String>,
) -> Result<Response, CwDexError> {
self.as_trait()
.provide_liquidity(deps, env, assets, min_out)
.provide_liquidity(deps, env, assets, min_out, recipient)
}

fn withdraw_liquidity(
Expand Down
1 change: 1 addition & 0 deletions cw-dex/src/traits/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub trait Pool {
env: &Env,
assets: AssetList,
min_out: Uint128,
recipient: Option<String>,
) -> Result<Response, CwDexError>;

/// Get the LP token for this pool
Expand Down
5 changes: 3 additions & 2 deletions test-contracts/astroport-test-contract/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn execute(
) -> Result<Response, ContractError> {
match msg {
ExecuteMsg::ProvideLiquidity { assets, min_out } => {
execute_provide_liquidity(deps, env, info, assets, min_out)
execute_provide_liquidity(deps, env, info, assets, min_out, None)
}
ExecuteMsg::WithdrawLiquidity { amount, min_out } => {
execute_withdraw_liquidity(deps, env, info, amount, min_out)
Expand All @@ -66,10 +66,11 @@ pub fn execute_provide_liquidity(
_info: MessageInfo,
assets: AssetList,
min_out: Uint128,
recipient: Option<String>,
) -> Result<Response, ContractError> {
let pool = POOL.load(deps.storage)?;

Ok(pool.provide_liquidity(deps.as_ref(), &env, assets, min_out)?)
Ok(pool.provide_liquidity(deps.as_ref(), &env, assets, min_out, recipient)?)
}

pub fn execute_withdraw_liquidity(
Expand Down
2 changes: 1 addition & 1 deletion test-contracts/osmosis-test-contract/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub fn execute_provide_liquidity(
) -> Result<Response, ContractError> {
let pool = POOL.load(deps.storage)?;

Ok(pool.provide_liquidity(deps.as_ref(), &env, assets, min_out)?)
Ok(pool.provide_liquidity(deps.as_ref(), &env, assets, min_out, None)?)
}

pub fn execute_withdraw_liquidity(
Expand Down

0 comments on commit 46db747

Please sign in to comment.