Skip to content

Commit

Permalink
Merge branch 'main' into feat/archway_deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
kerber0x authored Sep 2, 2024
2 parents f48673a + 0e8c174 commit 3ae418f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 25 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.6"
version = "1.1.7"
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
68 changes: 45 additions & 23 deletions contracts/liquidity_hub/fee_collector/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,35 +273,57 @@ pub fn aggregate_fees(
Ok(operations) => {
let execute_swap_operations_msg =
to_json_binary(&router::ExecuteMsg::ExecuteSwapOperations {
operations,
operations: operations.clone(),
minimum_receive: None,
to: None,
max_spread: Some(Decimal::percent(50u64)),
})?;

match offer_asset_info.clone() {
AssetInfo::Token { contract_addr } => {
aggregate_fees_messages.push(CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr,
funds: vec![],
msg: to_json_binary(&Cw20ExecuteMsg::Send {
contract: config.pool_router.to_string(),
amount: balance,
msg: execute_swap_operations_msg,
})?,
}));
let operations_simulation: StdResult<router::SimulateSwapOperationsResponse> =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: config.pool_router.to_string(),
msg: to_json_binary(&router::QueryMsg::SimulateSwapOperations {
offer_amount: balance,
operations: operations.clone(),
})?,
}));

match operations_simulation {
Ok(_) => {
if balance < MINIMUM_AGGREGABLE_BALANCE {
continue;
}
match offer_asset_info.clone() {
AssetInfo::Token { contract_addr } => {
aggregate_fees_messages.push(CosmosMsg::Wasm(
WasmMsg::Execute {
contract_addr,
funds: vec![],
msg: to_json_binary(&Cw20ExecuteMsg::Send {
contract: config.pool_router.to_string(),
amount: balance,
msg: execute_swap_operations_msg,
})?,
},
));
}
AssetInfo::NativeToken { denom } => {
aggregate_fees_messages.push(CosmosMsg::Wasm(
WasmMsg::Execute {
contract_addr: config.pool_router.to_string(),
funds: vec![Coin {
denom,
amount: balance,
}],
msg: execute_swap_operations_msg,
},
));
}
};
}
AssetInfo::NativeToken { denom } => {
aggregate_fees_messages.push(CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: config.pool_router.to_string(),
funds: vec![Coin {
denom,
amount: balance,
}],
msg: execute_swap_operations_msg,
}));
Err(_) => {
continue;
}
};
}
}
Err(_) => {
// if there is no swap route, skip swap and keep the asset in contract
Expand Down

0 comments on commit 3ae418f

Please sign in to comment.