Skip to content

Commit

Permalink
fix: prevents sending very small balances when collecting fees from p…
Browse files Browse the repository at this point in the history
…ools
  • Loading branch information
kerber0x authored Feb 6, 2024
2 parents a91b39b + 916e651 commit b82b979
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "terraswap-pair"
version = "1.3.4"
version = "1.3.5"
authors = [
"Terraform Labs, PTE.",
"DELIGHT LABS",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TerraQuery>) -> Result<Response, ContractError> {
let config = CONFIG.load(deps.storage)?;
Expand All @@ -610,7 +612,7 @@ pub fn collect_protocol_fees(deps: DepsMut<TerraQuery>) -> Result<Response, Cont
let mut messages: Vec<CosmosMsg> = 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())?);
}
}
Expand Down

0 comments on commit b82b979

Please sign in to comment.