Skip to content

Commit

Permalink
chore: make fee aggregation permissionless
Browse files Browse the repository at this point in the history
  • Loading branch information
kerber0x committed Dec 5, 2023
1 parent b64cc7e commit 5dbc3e7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 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.

2 changes: 1 addition & 1 deletion contracts/liquidity_hub/fee_collector/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fee_collector"
version = "1.1.2"
version = "1.1.3"
authors = ["Kerber0x <[email protected]>"]
edition.workspace = true
description = "Contract to collect the fees accrued by the pools and vaults in the liquidity hub"
Expand Down
17 changes: 11 additions & 6 deletions contracts/liquidity_hub/fee_collector/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,22 @@ pub fn update_config(
/// Aggregates the fees collected into the given asset_info.
pub fn aggregate_fees(
mut deps: DepsMut,
info: MessageInfo,
env: Env,
ask_asset_info: AssetInfo,
mut ask_asset_info: AssetInfo,
aggregate_fees_for: FeesFor,
) -> Result<Response, ContractError> {
let config: Config = CONFIG.load(deps.storage)?;

// only the owner or the contract itself can aggregate the fees
if info.sender != config.owner && info.sender != env.contract.address {
return Err(ContractError::Unauthorized {});
}
// query fee collector
let fee_distributor_config: white_whale::fee_distributor::Config =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: config.fee_distributor.to_string(),
msg: to_binary(&white_whale::fee_distributor::QueryMsg::Config {})?,
}))?;

// This was done in order to make this function permissionless so anyone can trigger the fee aggregation
// The signature for `ExecuteMsg::AggregateFees` was kept the same to avoid migrating multiple contracts
ask_asset_info = fee_distributor_config.distribution_asset;

let mut aggregate_fees_messages: Vec<CosmosMsg> = Vec::new();

Expand Down
2 changes: 1 addition & 1 deletion contracts/liquidity_hub/fee_collector/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub fn execute(
ExecuteMsg::AggregateFees {
asset_info,
aggregate_fees_for,
} => commands::aggregate_fees(deps, info, env, asset_info, aggregate_fees_for),
} => commands::aggregate_fees(deps, env, asset_info, aggregate_fees_for),
ExecuteMsg::ForwardFees {
epoch,
forward_fees_as,
Expand Down

0 comments on commit 5dbc3e7

Please sign in to comment.