Skip to content

Commit

Permalink
chore: make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
kerber0x committed Jan 15, 2024
1 parent b598a17 commit 0ddce6c
Show file tree
Hide file tree
Showing 87 changed files with 612 additions and 619 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ thiserror = "1.0.43"
osmosis-std-derive = "0.15.3"
prost = {version = "0.11.9", default-features = false, features = ["prost-derive"]}
prost-types = {version = "0.11.9", default-features = false}
white-whale = { path = "./packages/white-whale", features = [] }
white-whale = { path = "./packages/white-whale", features = ["osmosis"] }
white-whale-testing = { path = "./packages/white-whale-testing" }
cw-multi-test = { version = "0.16.5" }
uint = "0.9.5"
Expand Down
8 changes: 4 additions & 4 deletions contracts/liquidity_hub/epoch-manager/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{entry_point, to_binary, StdError};
use cosmwasm_std::{entry_point, to_json_binary, StdError};
use cosmwasm_std::{Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult};
use cw2::{get_contract_version, set_contract_version};
use semver::Version;
Expand Down Expand Up @@ -79,9 +79,9 @@ pub fn execute(
#[entry_point]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Config {} => Ok(to_binary(&queries::query_config(deps)?)?),
QueryMsg::CurrentEpoch {} => Ok(to_binary(&queries::query_current_epoch(deps)?)?),
QueryMsg::Epoch { id } => Ok(to_binary(&queries::query_epoch(deps, id)?)?),
QueryMsg::Config {} => Ok(to_json_binary(&queries::query_config(deps)?)?),
QueryMsg::CurrentEpoch {} => Ok(to_json_binary(&queries::query_current_epoch(deps)?)?),
QueryMsg::Epoch { id } => Ok(to_json_binary(&queries::query_epoch(deps, id)?)?),
}
}

Expand Down
6 changes: 3 additions & 3 deletions contracts/liquidity_hub/fee-distributor-mock/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, Uint64,
to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, Uint64,
};

use white_whale::fee_distributor::EpochResponse;
Expand Down Expand Up @@ -71,7 +71,7 @@ pub fn query(
match msg {
white_whale::fee_distributor::QueryMsg::Config {} => {}
white_whale::fee_distributor::QueryMsg::CurrentEpoch {} => {
return to_binary(&EpochResponse {
return to_json_binary(&EpochResponse {
epoch: CURRENT_EPOCH.load(deps.storage)?,
});
}
Expand All @@ -80,5 +80,5 @@ pub fn query(
white_whale::fee_distributor::QueryMsg::Claimable { .. } => {}
}

to_binary(&"")
to_json_binary(&"")
}
32 changes: 16 additions & 16 deletions contracts/liquidity_hub/fee_collector/src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_std::{
to_binary, Addr, BalanceResponse, BankQuery, Coin, CosmosMsg, Decimal, DepsMut, Env,
to_json_binary, Addr, BalanceResponse, BankQuery, Coin, CosmosMsg, Decimal, DepsMut, Env,
MessageInfo, QueryRequest, ReplyOn, Response, StdResult, SubMsg, Uint128, WasmMsg, WasmQuery,
};
use cw20::{Cw20ExecuteMsg, Cw20QueryMsg};
Expand Down Expand Up @@ -49,10 +49,10 @@ pub fn collect_fees(deps: DepsMut, collect_fees_for: FeesFor) -> Result<Response
fn collect_fees_for_contract(contract: Addr, contract_type: ContractType) -> StdResult<CosmosMsg> {
let collect_protocol_fees_msg = match contract_type {
ContractType::Vault {} => {
to_binary(&white_whale::vault_network::vault::ExecuteMsg::CollectProtocolFees {})?
to_json_binary(&white_whale::vault_network::vault::ExecuteMsg::CollectProtocolFees {})?
}
ContractType::Pool {} => {
to_binary(&white_whale::pool_network::pair::ExecuteMsg::CollectProtocolFees {})?
to_json_binary(&white_whale::pool_network::pair::ExecuteMsg::CollectProtocolFees {})?
}
};

Expand All @@ -76,7 +76,7 @@ fn collect_fees_for_factory(
let response: VaultsResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: factory.to_string(),
msg: to_binary(
msg: to_json_binary(
&white_whale::vault_network::vault_factory::QueryMsg::Vaults {
start_after,
limit,
Expand All @@ -95,7 +95,7 @@ fn collect_fees_for_factory(
let response: PairsResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: factory.to_string(),
msg: to_binary(&QueryMsg::Pairs { start_after, limit })?,
msg: to_json_binary(&QueryMsg::Pairs { start_after, limit })?,
}))?;

for pair in response.pairs {
Expand Down Expand Up @@ -182,7 +182,7 @@ pub fn aggregate_fees(
let response: VaultsResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: factory.to_string(),
msg: to_binary(
msg: to_json_binary(
&white_whale::vault_network::vault_factory::QueryMsg::Vaults {
start_after,
limit,
Expand All @@ -198,7 +198,7 @@ pub fn aggregate_fees(
let response: PairsResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: factory.to_string(),
msg: to_binary(&QueryMsg::Pairs { start_after, limit })?,
msg: to_json_binary(&QueryMsg::Pairs { start_after, limit })?,
}))?;

for pair in response.pairs {
Expand All @@ -224,7 +224,7 @@ pub fn aggregate_fees(
let balance_response: cw20::BalanceResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: contract_addr.to_string(),
msg: to_binary(&Cw20QueryMsg::Balance {
msg: to_json_binary(&Cw20QueryMsg::Balance {
address: env.contract.address.to_string(),
})?,
}))?;
Expand All @@ -234,7 +234,7 @@ pub fn aggregate_fees(
// Increase the allowance for the cw20 token so the router can perform the swap
aggregate_fees_messages.push(CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: contract_addr.to_string(),
msg: to_binary(&Cw20ExecuteMsg::IncreaseAllowance {
msg: to_json_binary(&Cw20ExecuteMsg::IncreaseAllowance {
spender: config.pool_router.to_string(),
amount: balance_response.balance,
expires: None,
Expand All @@ -261,7 +261,7 @@ pub fn aggregate_fees(
let operations_res: StdResult<Vec<SwapOperation>> =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: config.pool_router.to_string(),
msg: to_binary(&router::QueryMsg::SwapRoute {
msg: to_json_binary(&router::QueryMsg::SwapRoute {
offer_asset_info: offer_asset_info.clone(),
ask_asset_info: ask_asset_info.clone(),
})?,
Expand All @@ -270,7 +270,7 @@ pub fn aggregate_fees(
match operations_res {
Ok(operations) => {
let execute_swap_operations_msg =
to_binary(&router::ExecuteMsg::ExecuteSwapOperations {
to_json_binary(&router::ExecuteMsg::ExecuteSwapOperations {
operations,
minimum_receive: None,
to: None,
Expand All @@ -282,7 +282,7 @@ pub fn aggregate_fees(
aggregate_fees_messages.push(CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr,
funds: vec![],
msg: to_binary(&Cw20ExecuteMsg::Send {
msg: to_json_binary(&Cw20ExecuteMsg::Send {
contract: config.pool_router.to_string(),
amount: balance,
msg: execute_swap_operations_msg,
Expand Down Expand Up @@ -336,7 +336,7 @@ pub fn forward_fees(
msg: CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: env.contract.address.to_string(),
funds: vec![],
msg: to_binary(&ExecuteMsg::CollectFees {
msg: to_json_binary(&ExecuteMsg::CollectFees {
collect_fees_for: FeesFor::Factory {
factory_addr: config.vault_factory.to_string(),
factory_type: FactoryType::Vault {
Expand All @@ -355,7 +355,7 @@ pub fn forward_fees(
msg: CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: env.contract.address.to_string(),
funds: vec![],
msg: to_binary(&ExecuteMsg::CollectFees {
msg: to_json_binary(&ExecuteMsg::CollectFees {
collect_fees_for: FeesFor::Factory {
factory_addr: config.pool_factory.to_string(),
factory_type: FactoryType::Pool {
Expand All @@ -375,7 +375,7 @@ pub fn forward_fees(
msg: CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: env.contract.address.to_string(),
funds: vec![],
msg: to_binary(&ExecuteMsg::AggregateFees {
msg: to_json_binary(&ExecuteMsg::AggregateFees {
aggregate_fees_for: FeesFor::Factory {
factory_addr: config.vault_factory.to_string(),
factory_type: FactoryType::Vault {
Expand All @@ -394,7 +394,7 @@ pub fn forward_fees(
msg: CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: env.contract.address.to_string(),
funds: vec![],
msg: to_binary(&ExecuteMsg::AggregateFees {
msg: to_json_binary(&ExecuteMsg::AggregateFees {
aggregate_fees_for: FeesFor::Factory {
factory_addr: config.pool_factory.to_string(),
factory_type: FactoryType::Pool {
Expand Down
10 changes: 5 additions & 5 deletions contracts/liquidity_hub/fee_collector/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_binary, Addr, BalanceResponse, BankMsg, BankQuery, Binary, CosmosMsg, Deps, DepsMut, Env,
MessageInfo, QueryRequest, Reply, Response, StdResult, Uint128,
to_json_binary, Addr, BalanceResponse, BankMsg, BankQuery, Binary, CosmosMsg, Deps, DepsMut,
Env, MessageInfo, QueryRequest, Reply, Response, StdResult, Uint128,
};
use cw2::{get_contract_version, set_contract_version};
use semver::Version;
Expand Down Expand Up @@ -96,7 +96,7 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result<Response, ContractEr
.add_attribute("action", "reply")
.add_attribute("new_epoch", epoch.to_string())
.add_messages(messages)
.set_data(to_binary(&ForwardFeesResponse { epoch })?))
.set_data(to_json_binary(&ForwardFeesResponse { epoch })?))
} else {
Err(ContractError::UnknownReplyId(msg.id))
}
Expand Down Expand Up @@ -138,11 +138,11 @@ pub fn execute(
#[entry_point]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Config {} => to_binary(&queries::query_config(deps)?),
QueryMsg::Config {} => to_json_binary(&queries::query_config(deps)?),
QueryMsg::Fees {
query_fees_for,
all_time,
} => to_binary(&queries::query_fees(
} => to_json_binary(&queries::query_fees(
deps,
query_fees_for,
all_time.unwrap_or(false),
Expand Down
15 changes: 9 additions & 6 deletions contracts/liquidity_hub/fee_collector/src/queries.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{to_binary, Addr, Deps, QueryRequest, StdResult, WasmQuery};
use cosmwasm_std::{to_json_binary, Addr, Deps, QueryRequest, StdResult, WasmQuery};

use white_whale::fee_collector::{Config, ContractType, FactoryType, FeesFor};
use white_whale::pool_network;
Expand Down Expand Up @@ -75,7 +75,7 @@ fn query_fees_for_vault(deps: &Deps, vault: String, all_time: bool) -> StdResult
.querier
.query::<ProtocolVaultFeesResponse>(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: vault,
msg: to_binary(&white_whale::vault_network::vault::QueryMsg::ProtocolFees {
msg: to_json_binary(&white_whale::vault_network::vault::QueryMsg::ProtocolFees {
all_time,
})?,
}))?
Expand All @@ -90,7 +90,7 @@ fn query_fees_for_pair(deps: &Deps, pair: String, all_time: bool) -> StdResult<V
.querier
.query::<ProtocolPairFeesResponse>(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: pair,
msg: to_binary(&pool_network::pair::QueryMsg::ProtocolFees {
msg: to_json_binary(&pool_network::pair::QueryMsg::ProtocolFees {
all_time: Some(all_time),
asset_id: None,
})?,
Expand All @@ -114,7 +114,7 @@ fn query_fees_for_factory(
let response: VaultsResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: factory.to_string(),
msg: to_binary(
msg: to_json_binary(
&white_whale::vault_network::vault_factory::QueryMsg::Vaults {
start_after,
limit,
Expand All @@ -131,7 +131,10 @@ fn query_fees_for_factory(
let response: PairsResponse =
deps.querier.query(&QueryRequest::Wasm(WasmQuery::Smart {
contract_addr: factory.to_string(),
msg: to_binary(&pool_network::factory::QueryMsg::Pairs { start_after, limit })?,
msg: to_json_binary(&pool_network::factory::QueryMsg::Pairs {
start_after,
limit,
})?,
}))?;

for pair in response.pairs {
Expand All @@ -151,7 +154,7 @@ pub(crate) fn query_distribution_asset(deps: Deps) -> StdResult<AssetInfo> {
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 {})?,
msg: to_json_binary(&white_whale::fee_distributor::QueryMsg::Config {})?,
}))?;

Ok(fee_distributor_config.distribution_asset)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{to_binary, Addr, BankMsg, Coin, Response};
use cosmwasm_std::{to_json_binary, Addr, BankMsg, Coin, Response};
use cw_multi_test::ContractWrapper;
use serde::{Deserialize, Serialize};
use thiserror::Error;
Expand Down Expand Up @@ -28,6 +28,6 @@ pub fn create_dummy_flash_loan_contract(
}
},
|_deps, _env, _info, _msg| Ok(Response::new()),
|_deps, _env, _query| Ok(to_binary::<Vec<Coin>>(&vec![]).unwrap()),
|_deps, _env, _query| Ok(to_json_binary::<Vec<Coin>>(&vec![]).unwrap()),
)
}
20 changes: 10 additions & 10 deletions contracts/liquidity_hub/fee_collector/src/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::collections::HashMap;

use cosmwasm_std::{
coin, coins, to_binary, Addr, BankMsg, BlockInfo, Coin, Decimal, Timestamp, Uint128, Uint256,
Uint64,
coin, coins, to_json_binary, Addr, BankMsg, BlockInfo, Coin, Decimal, Timestamp, Uint128,
Uint256, Uint64,
};
use cw20::{BalanceResponse, Cw20Coin, Cw20ExecuteMsg, MinterResponse};
use cw_multi_test::Executor;
Expand Down Expand Up @@ -299,7 +299,7 @@ fn collect_all_factories_cw20_fees_successfully() {
&Cw20ExecuteMsg::Send {
contract: pair_tokens[i as usize - 1].to_string(),
amount: Uint128::new(100_000_000u128),
msg: to_binary(&pool_network::pair::Cw20HookMsg::Swap {
msg: to_json_binary(&pool_network::pair::Cw20HookMsg::Swap {
belief_price: None,
max_spread: None,
to: None,
Expand All @@ -316,7 +316,7 @@ fn collect_all_factories_cw20_fees_successfully() {
&Cw20ExecuteMsg::Send {
contract: pair_tokens[i as usize].to_string(),
amount: Uint128::new(200_000_000_000u128),
msg: to_binary(&pool_network::pair::Cw20HookMsg::Swap {
msg: to_json_binary(&pool_network::pair::Cw20HookMsg::Swap {
belief_price: None,
max_spread: Some(Decimal::percent(20u64)),
to: None,
Expand Down Expand Up @@ -817,7 +817,7 @@ fn collect_cw20_fees_for_specific_contracts_successfully() {
&Cw20ExecuteMsg::Send {
contract: pair_tokens[i - 1].to_string(),
amount: Uint128::new(100_000u128),
msg: to_binary(&pool_network::pair::Cw20HookMsg::Swap {
msg: to_json_binary(&pool_network::pair::Cw20HookMsg::Swap {
belief_price: None,
max_spread: Some(Decimal::percent(30u64)),
to: None,
Expand All @@ -834,7 +834,7 @@ fn collect_cw20_fees_for_specific_contracts_successfully() {
&Cw20ExecuteMsg::Send {
contract: pair_tokens[i].to_string(),
amount: Uint128::new(200_000u128),
msg: to_binary(&pool_network::pair::Cw20HookMsg::Swap {
msg: to_json_binary(&pool_network::pair::Cw20HookMsg::Swap {
belief_price: None,
max_spread: Some(Decimal::percent(30u64)),
to: None,
Expand Down Expand Up @@ -1321,7 +1321,7 @@ fn collect_pools_native_fees_successfully() {
&Cw20ExecuteMsg::Send {
contract: pair_tokens[i].to_string(),
amount: Uint128::new(200_000_000u128),
msg: to_binary(&pool_network::pair::Cw20HookMsg::Swap {
msg: to_json_binary(&pool_network::pair::Cw20HookMsg::Swap {
belief_price: None,
max_spread: None,
to: None,
Expand Down Expand Up @@ -1884,7 +1884,7 @@ fn collect_fees_with_pagination_successfully() {
&Cw20ExecuteMsg::Send {
contract: pair_tokens[i].to_string(),
amount: Uint128::new(200_000u128),
msg: to_binary(&pool_network::pair::Cw20HookMsg::Swap {
msg: to_json_binary(&pool_network::pair::Cw20HookMsg::Swap {
belief_price: None,
max_spread: Some(Decimal::percent(40u64)),
to: None,
Expand Down Expand Up @@ -2204,7 +2204,7 @@ fn collect_fees_for_vault() {
vaults[i].clone(),
&white_whale::vault_network::vault::ExecuteMsg::FlashLoan {
amount: Uint128::new(flash_loan_value),
msg: to_binary(&BankMsg::Send {
msg: to_json_binary(&BankMsg::Send {
to_address: vaults[i].to_string(),
// return a higher amount than the flashloan + fees
amount: coins(return_flash_loan_value, coin.denom.clone()),
Expand Down Expand Up @@ -2632,7 +2632,7 @@ fn aggregate_fees_for_vault() {
vaults[i].clone(),
&white_whale::vault_network::vault::ExecuteMsg::FlashLoan {
amount: Uint128::new(flash_loan_value),
msg: to_binary(&BankMsg::Send {
msg: to_json_binary(&BankMsg::Send {
to_address: vaults[i].to_string(),
// return a higher amount than the flashloan + fees
amount: coins(return_flash_loan_value, coin.denom.clone()),
Expand Down
Loading

0 comments on commit 0ddce6c

Please sign in to comment.