Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
javiersuweijie committed Jan 16, 2024
1 parent d611779 commit 715f42e
Show file tree
Hide file tree
Showing 9 changed files with 322 additions and 35 deletions.
35 changes: 16 additions & 19 deletions contracts/alliance-lp-hub/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ pub fn instantiate(
let config = Config {
governance: governance_address,
controller: controller_address,
fee_collector_address: fee_collector_address,
astro_incentives_addr: astro_incentives_address,
fee_collector: fee_collector_address,
astro_incentives: astro_incentives_address,
alliance_token_denom: "".to_string(),
alliance_token_supply: Uint128::zero(),
reward_denom: msg.reward_denom,
Expand Down Expand Up @@ -183,9 +183,9 @@ fn stake(
// from the asset info e.g. cw20:asset1 -> asset1 or native:uluna -> uluna
let lp_token = received_asset.info.to_string();
let astro_incentives: Vec<RewardInfo> = deps.querier.query_wasm_smart(
config.astro_incentives_addr.to_string(),
config.astro_incentives.to_string(),
&QueryAstroMsg::RewardInfo{
lp_token: lp_token.split(":").collect::<Vec<&str>>()[1].to_string(),
lp_token: lp_token.split(':').collect::<Vec<&str>>()[1].to_string(),
},
).unwrap_or_default();

Expand All @@ -201,38 +201,35 @@ fn stake(
AssetInfo::Native(native_asset) => {
// If the asset is native, we need to send it to the astro incentives contract
// using the ExecuteAstroMsg::Deposit message
let msg = CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: config.astro_incentives_addr.to_string(),
CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: config.astro_incentives.to_string(),
msg: to_json_binary(&ExecuteAstroMsg::Deposit {
recipient: None,
})?,
funds: vec![CwCoin {
denom: native_asset,
amount: received_asset.amount.clone(),
amount: received_asset.amount,
}],
});
msg
})
}
AssetInfo::Cw20(cw20_contract_addr) => {
// If the asset is a cw20 token, we need to send it to the astro incentives contract
// using the ExecuteAstroMsg::Receive message
let msg = CosmosMsg::Wasm(WasmMsg::Execute {
CosmosMsg::Wasm(WasmMsg::Execute {
contract_addr: cw20_contract_addr.to_string(),
msg: to_json_binary(&Cw20ExecuteMsg::Send {
contract: config.astro_incentives_addr.to_string(),
amount: received_asset.amount.clone(),
contract: config.astro_incentives.to_string(),
amount: received_asset.amount,
msg: to_json_binary(&Cw20ReceiveMsg {
sender: env.contract.address.to_string(),
amount: received_asset.amount.clone(),
amount: received_asset.amount,
msg: to_json_binary(&Cw20Msg::Deposit {
recipient: None,
})?,
})?,
})?,
funds: vec![],
});
msg

})
},
_ => {
return Err(ContractError::AssetNotWhitelisted(received_asset.info.to_string()));
Expand Down Expand Up @@ -573,7 +570,7 @@ fn update_reward_callback(
let unallocated_rewards = (Decimal::from_atomics(rewards_collected, 0)? * unallocated_distribution).to_uint_floor();
if !unallocated_rewards.is_zero() {
res = res.add_message(BankMsg::Send {
to_address: config.fee_collector_address.to_string(),
to_address: config.fee_collector.to_string(),
amount: vec![CwCoin::new(unallocated_rewards.u128(), config.reward_denom)]
})
}
Expand Down Expand Up @@ -660,9 +657,9 @@ fn rebalance_emissions_callback(
let asset_key = AssetInfoKey::from(asset_info.clone());
WHITELIST.update(deps.storage, asset_key, |current| -> Result<_, ContractError> {
if let Some(current) = current {
return Ok(current + distribution.distribution.to_decimal()?);
Ok(current + distribution.distribution.to_decimal()?)
} else {
return Err(ContractError::AssetNotWhitelisted(asset_info.to_string()));
Err(ContractError::AssetNotWhitelisted(asset_info.to_string()))
}
})?;
}
Expand Down
4 changes: 2 additions & 2 deletions contracts/alliance-lp-hub/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ pub type AssetDenom = String;
pub struct Config {
pub governance: Addr,
pub controller: Addr,
pub fee_collector_address: Addr,
pub astro_incentives_addr: Addr,
pub fee_collector: Addr,
pub astro_incentives: Addr,
pub alliance_token_denom: String,
pub alliance_token_supply: Uint128,
pub reward_denom: String,
Expand Down
2 changes: 1 addition & 1 deletion contracts/alliance-lp-hub/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn get_rewards_distribution(deps: Deps) -> StdResult<Binary> {
.map(|(asset_info, distribution) |
EmissionsDistribution {
denom: asset_info.check( deps.api, None).unwrap().to_string(),
distribution: SignedDecimal::from_decimal(distribution.clone(), Sign::Positive),
distribution: SignedDecimal::from_decimal(*distribution, Sign::Positive),
}
)
.collect();
Expand Down
Loading

0 comments on commit 715f42e

Please sign in to comment.