From 916e6514598e2f649e7177a04c5e8821431db38d Mon Sep 17 00:00:00 2001 From: Kerber0x Date: Tue, 6 Feb 2024 12:09:29 +0000 Subject: [PATCH] fix: prevents sending very small balances when collecting fees from pools --- Cargo.lock | 2 +- .../liquidity_hub/pool-network/terraswap_pair/Cargo.toml | 2 +- .../liquidity_hub/pool-network/terraswap_pair/src/commands.rs | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 52698974..9c6fbd35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1597,7 +1597,7 @@ dependencies = [ [[package]] name = "terraswap-pair" -version = "1.3.4" +version = "1.3.5" dependencies = [ "anybuf", "classic-bindings", diff --git a/contracts/liquidity_hub/pool-network/terraswap_pair/Cargo.toml b/contracts/liquidity_hub/pool-network/terraswap_pair/Cargo.toml index cc949f2b..3aca9064 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_pair/Cargo.toml +++ b/contracts/liquidity_hub/pool-network/terraswap_pair/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "terraswap-pair" -version = "1.3.4" +version = "1.3.5" authors = [ "Terraform Labs, PTE.", "DELIGHT LABS", diff --git a/contracts/liquidity_hub/pool-network/terraswap_pair/src/commands.rs b/contracts/liquidity_hub/pool-network/terraswap_pair/src/commands.rs index 41105767..0c0d747a 100644 --- a/contracts/liquidity_hub/pool-network/terraswap_pair/src/commands.rs +++ b/contracts/liquidity_hub/pool-network/terraswap_pair/src/commands.rs @@ -586,6 +586,8 @@ pub fn update_config( Ok(Response::new().add_attribute("action", "update_config")) } +const MINIMUM_COLLECTABLE_BALANCE: Uint128 = Uint128::new(1_000u128); + /// Collects all protocol fees accrued by the pool pub fn collect_protocol_fees(deps: DepsMut) -> Result { let config = CONFIG.load(deps.storage)?; @@ -610,7 +612,7 @@ pub fn collect_protocol_fees(deps: DepsMut) -> Result = Vec::new(); for protocol_fee in protocol_fees { // prevents trying to send 0 coins, which errors - if protocol_fee.amount != Uint128::zero() { + if protocol_fee.amount > MINIMUM_COLLECTABLE_BALANCE { messages.push(protocol_fee.into_msg(&deps.querier, config.fee_collector_addr.clone())?); } }