diff --git a/Cargo.lock b/Cargo.lock index 9eba221..ffe02d4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -654,7 +654,7 @@ dependencies = [ [[package]] name = "terraswap" -version = "2.4.0" +version = "2.4.1" dependencies = [ "cosmwasm-schema", "cosmwasm-std", diff --git a/contracts/terraswap_factory/Cargo.toml b/contracts/terraswap_factory/Cargo.toml index f35344a..484c86b 100644 --- a/contracts/terraswap_factory/Cargo.toml +++ b/contracts/terraswap_factory/Cargo.toml @@ -34,7 +34,7 @@ overflow-checks = true backtraces = ["cosmwasm-std/backtraces"] [dependencies] -terraswap = { path = "../../packages/terraswap", default-features = false, version = "2.4.0"} +terraswap = { path = "../../packages/terraswap", default-features = false, version = "2.4.1"} cosmwasm-std = { version = "0.16.0" } cw-storage-plus = { version = "0.8.0" } schemars = "0.8.1" diff --git a/contracts/terraswap_pair/Cargo.toml b/contracts/terraswap_pair/Cargo.toml index 120548c..11f0703 100644 --- a/contracts/terraswap_pair/Cargo.toml +++ b/contracts/terraswap_pair/Cargo.toml @@ -44,7 +44,7 @@ serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.20" } protobuf = { version = "2", features = ["with-bytes"] } cosmwasm-bignumber = "2.2.0" -terraswap = { path = "../../packages/terraswap", default-features = false, version = "2.4.0"} +terraswap = { path = "../../packages/terraswap", default-features = false, version = "2.4.1"} [dev-dependencies] cosmwasm-schema = "0.16.0" diff --git a/contracts/terraswap_pair/src/contract.rs b/contracts/terraswap_pair/src/contract.rs index 9a8fcd1..35909e4 100644 --- a/contracts/terraswap_pair/src/contract.rs +++ b/contracts/terraswap_pair/src/contract.rs @@ -269,14 +269,20 @@ pub fn provide_liquidity( ) }; + // prevent providing free token + if share.is_zero() { + return Err(ContractError::InvalidZeroAmount{}); + } + // mint LP token to sender + let receiver = receiver.unwrap_or_else(|| info.sender.to_string()); messages.push(CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: deps .api .addr_humanize(&pair_info.liquidity_token)? .to_string(), msg: to_binary(&Cw20ExecuteMsg::Mint { - recipient: receiver.unwrap_or_else(|| info.sender.to_string()), + recipient: receiver.to_string(), amount: share, })?, funds: vec![], @@ -284,6 +290,8 @@ pub fn provide_liquidity( Ok(Response::new().add_messages(messages).add_attributes(vec![ ("action", "provide_liquidity"), + ("sender", info.sender.as_str()), + ("receiver", receiver.as_str()), ("assets", &format!("{}, {}", assets[0], assets[1])), ("share", &share.to_string()), ])) @@ -317,7 +325,9 @@ pub fn withdraw_liquidity( refund_assets[0] .clone() .into_msg(&deps.querier, sender.clone())?, - refund_assets[1].clone().into_msg(&deps.querier, sender)?, + refund_assets[1] + .clone() + .into_msg(&deps.querier, sender.clone())?, // burn liquidity token CosmosMsg::Wasm(WasmMsg::Execute { contract_addr: deps @@ -330,6 +340,7 @@ pub fn withdraw_liquidity( ]) .add_attributes(vec![ ("action", "withdraw_liquidity"), + ("sender", sender.as_str()), ("withdrawn_share", &amount.to_string()), ( "refund_assets", @@ -397,13 +408,16 @@ pub fn swap( }; let tax_amount = return_asset.compute_tax(&deps.querier)?; + let receiver = to.unwrap_or(sender.clone()); // 1. send collateral token from the contract to a user // 2. send inactive commission to collector Ok(Response::new() - .add_message(return_asset.into_msg(&deps.querier, to.unwrap_or(sender))?) + .add_message(return_asset.into_msg(&deps.querier, receiver.clone())?) .add_attributes(vec![ ("action", "swap"), + ("sender", sender.as_str()), + ("receiver", receiver.as_str()), ("offer_asset", &offer_asset.info.to_string()), ("ask_asset", &ask_pool.info.to_string()), ("offer_amount", &offer_amount.to_string()), diff --git a/contracts/terraswap_router/Cargo.toml b/contracts/terraswap_router/Cargo.toml index 95f2aab..b74565e 100644 --- a/contracts/terraswap_router/Cargo.toml +++ b/contracts/terraswap_router/Cargo.toml @@ -36,7 +36,7 @@ backtraces = ["cosmwasm-std/backtraces"] [dependencies] cw20 = { version = "0.8.0" } cosmwasm-std = { version = "0.16.0" } -terraswap = { path = "../../packages/terraswap", version = "2.4.0" } +terraswap = { path = "../../packages/terraswap", version = "2.4.1" } terra-cosmwasm = "2.2.0" cw-storage-plus = { version = "0.8.0"} integer-sqrt = "0.1.5" diff --git a/contracts/terraswap_token/Cargo.toml b/contracts/terraswap_token/Cargo.toml index 17b679b..5144143 100644 --- a/contracts/terraswap_token/Cargo.toml +++ b/contracts/terraswap_token/Cargo.toml @@ -27,7 +27,7 @@ cosmwasm-std = { version = "0.16.0" } schemars = "0.8.1" serde = { version = "1.0.103", default-features = false, features = ["derive"] } thiserror = { version = "1.0.20" } -terraswap = { path = "../../packages/terraswap", version = "2.4.0" } +terraswap = { path = "../../packages/terraswap", version = "2.4.1" } [dev-dependencies] # we only need to enable this if we use integration tests diff --git a/packages/terraswap/Cargo.toml b/packages/terraswap/Cargo.toml index 1805588..907af90 100644 --- a/packages/terraswap/Cargo.toml +++ b/packages/terraswap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "terraswap" -version = "2.4.0" +version = "2.4.1" authors = ["Terraform Labs, PTE."] edition = "2018" description = "Common terraswap types"