Skip to content

Commit

Permalink
Merge pull request #2 from PFC-Validator/dusty-2023-11-23
Browse files Browse the repository at this point in the history
Dusty 2023 11 23
  • Loading branch information
PFC-developer authored Jan 13, 2024
2 parents fa93861 + 014ccd6 commit e2a152d
Show file tree
Hide file tree
Showing 24 changed files with 925 additions and 156 deletions.
2 changes: 1 addition & 1 deletion artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
3d74986751e5ffaee368e2fef48600a2cec7475cf34180bf4416f0bf38f7511b pfc_astroport_generator.wasm
882eaf36e8f8377e6da7d38338a5f6f1abf1e2c2d4c3201dde34ec62de63faaf pfc_dust_collector_kujira_contract.wasm
9ddaa3af8899c013ce4efaf78dde32124304b624f20ba869cc407a951fafc2e8 pfc_dust_collector_kujira_contract.wasm
f4301d89b55b0f1f18279c6b3b3931a5a5db3efc2d58875000d1768a27d27f1a pfc_fee_splitter.wasm
866668e836b01245abc173e2a7669f53eb2adcbc7ba266627d5651f07b7ca580 pfc_vault_contract.wasm
Binary file modified artifacts/pfc_dust_collector_kujira_contract.wasm
Binary file not shown.
3 changes: 1 addition & 2 deletions contracts/pfc-dust-collector-kujira/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "pfc-dust-collector-kujira-contract"
version = "0.0.1"
version = "1.1.0"
authors = ["PFC <[email protected]>"]
edition = "2018"
license = "Apache-2.0"
Expand Down Expand Up @@ -38,7 +38,6 @@ pfc-steak= "3.0.8"
cw-ownable = "0.5.0"
pfc-dust-collector-kujira={ path="../../packages/pfc-dust-collector-kujira"}
pfc-whitelist={ version="0.1.0", path="../../packages/pfc-whitelist"}
#pool-network= {version="2.8.1", path="../../../white-whale-core/packages/pool-network"}

[build-dependencies]
protoc-rust = "2"
Expand Down
49 changes: 34 additions & 15 deletions contracts/pfc-dust-collector-kujira/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ use cosmwasm_std::{
use cw2::{get_contract_version, set_contract_version};
use kujira::Denom;

use pfc_dust_collector_kujira::dust_collector::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};
use pfc_dust_collector_kujira::dust_collector::{
ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, SellStrategy,
};

use crate::error::ContractError;
use crate::handler::exec as ExecHandler;
use crate::handler::exec::{
execute_clear_asset, execute_set_asset_minimum, execute_set_asset_stages,
execute_set_base_denom, execute_set_max_swaps, execute_set_return_contract,
execute_set_token_router,
execute_clear_asset, execute_set_asset_maximum, execute_set_asset_minimum,
execute_set_asset_strategy, execute_set_base_denom, execute_set_calc_token_router,
execute_set_manta_token_router, execute_set_max_swaps, execute_set_return_contract,
};
use crate::handler::query as QueryHandler;
use crate::state;
Expand All @@ -41,7 +43,8 @@ pub fn instantiate(
deps.storage,
&state::Config {
//this: deps.api.addr_validate(env.contract.address.as_str())?,
token_router: deps.api.addr_validate(&msg.token_router)?,
manta_token_router: deps.api.addr_validate(&msg.manta_token_router)?,
calc_token_router: deps.api.addr_validate(&msg.calc_token_router)?,
base_denom: msg.base_denom.clone(),
return_contract: deps.api.addr_validate(&msg.return_contract)?,
max_swaps: msg.max_swaps,
Expand All @@ -58,7 +61,11 @@ pub fn instantiate(
// }

ASSET_HOLDINGS.save(deps.storage, row.denom.to_string(), &row.minimum)?;
ASSET_STAGES.save(deps.storage, row.denom.to_string(), &Vec::new())?;
ASSET_STAGES.save(
deps.storage,
row.denom.to_string(),
&SellStrategy::default(),
)?;
}

let mut res = Response::new();
Expand Down Expand Up @@ -115,9 +122,13 @@ pub fn execute(
cw_ownable::assert_owner(deps.storage, &info.sender)?;
execute_set_return_contract(deps, &info.sender, &contract)
}
ExecuteMsg::SetTokenRouter { contract } => {
ExecuteMsg::SetMantaTokenRouter { contract } => {
cw_ownable::assert_owner(deps.storage, &info.sender)?;
execute_set_manta_token_router(deps, &info.sender, &contract)
}
ExecuteMsg::SetCalcTokenRouter { contract } => {
cw_ownable::assert_owner(deps.storage, &info.sender)?;
execute_set_token_router(deps, &info.sender, &contract)
execute_set_calc_token_router(deps, &info.sender, &contract)
}
ExecuteMsg::SetBaseDenom { denom } => {
cw_ownable::assert_owner(deps.storage, &info.sender)?;
Expand All @@ -127,6 +138,10 @@ pub fn execute(
cw_ownable::assert_owner(deps.storage, &info.sender)?;
execute_set_asset_minimum(deps, &info.sender, denom, minimum)
}
ExecuteMsg::SetAssetMaximum { denom, maximum } => {
cw_ownable::assert_owner(deps.storage, &info.sender)?;
execute_set_asset_maximum(deps, &info.sender, denom, maximum)
}
ExecuteMsg::ClearAsset { denom } => {
cw_ownable::assert_owner(deps.storage, &info.sender)?;
execute_clear_asset(deps, &info.sender, denom)
Expand All @@ -142,8 +157,8 @@ pub fn execute(
pfc_whitelist::remove_entry(deps.storage, deps.api, address)?;
Ok(Response::default())
}
ExecuteMsg::SetAssetStages { denom, stages } => {
execute_set_asset_stages(deps, &info.sender, &denom, &stages)
ExecuteMsg::SetAssetStrategy { denom, strategy } => {
execute_set_asset_strategy(deps, &info.sender, &denom, &strategy)
}
ExecuteMsg::SetMaxSwaps { max_swaps } => {
cw_ownable::assert_owner(deps.storage, &info.sender)?;
Expand Down Expand Up @@ -214,6 +229,7 @@ mod tests {

use pfc_dust_collector_kujira::dust_collector::{
AssetHolding, AssetMinimum, CollectorResponse, InitHook, InstantiateMsg, QueryMsg,
SellStrategy,
};
use pfc_whitelist::Whitelist;

Expand All @@ -230,7 +246,8 @@ mod tests {
let hook_msg = Binary::from(r#"{"some": 123}"#.as_bytes());
let instantiate_msg = InstantiateMsg {
owner: "owner".to_string(),
token_router: "swap".to_string(),
manta_token_router: "swap".to_string(),
calc_token_router: "calc".to_string(),
return_contract: "jim".to_string(),
base_denom: Denom::from(DENOM_3),
assets: vec![
Expand Down Expand Up @@ -295,7 +312,7 @@ mod tests {
assert!(false, "{} not expected", entry.denom)
}
}
assert_eq!(entry.stages.is_empty(), true);
assert_eq!(entry.strategy, SellStrategy::Hold);
assert_eq!(entry.balance, Uint128::zero());
}
assert_eq!(seen_denom_1, 1, "wantred to see DENOM_1 once");
Expand All @@ -307,7 +324,7 @@ mod tests {
.iter()
.find(|p| p.denom.to_string() == DENOM_2)
.unwrap();
assert_eq!(denom_2.stages.is_empty(), true, "should be empty");
assert_eq!(denom_2.strategy, SellStrategy::Hold, "should be hold");
assert_eq!(
denom_2.minimum,
Uint128::from(20u128),
Expand All @@ -316,7 +333,8 @@ mod tests {

let instantiate_msg_fail = InstantiateMsg {
owner: "owner".to_string(),
token_router: "swap".to_string(),
manta_token_router: "swap".to_string(),
calc_token_router: "calc".to_string(),
return_contract: "jim".to_string(),
base_denom: Denom::from(DENOM_3),
assets: vec![
Expand Down Expand Up @@ -355,7 +373,8 @@ mod tests {
}
let instantiate_msg_2 = InstantiateMsg {
owner: "owner".to_string(),
token_router: "swap".to_string(),
manta_token_router: "swap".to_string(),
calc_token_router: "calc".to_string(),
return_contract: "jim".to_string(),
base_denom: Denom::from(DENOM_MAIN),
assets: vec![
Expand Down
4 changes: 3 additions & 1 deletion contracts/pfc-dust-collector-kujira/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{OverflowError, StdError};
use cosmwasm_std::{OverflowError, StdError, Uint128};
use cw_ownable::OwnershipError;
use kujira::Denom;
use thiserror::Error;
Expand Down Expand Up @@ -42,6 +42,8 @@ pub enum ContractError {
DenomNotUnique {},
#[error("PFC-Dust-Kujira: Don't send funds here")]
NoFundsRequired {},
#[error("PFC-Dust-Kujira: Min {min:?} > Max {max:?} ?")]
MinMax { min: Uint128, max: Uint128 },

#[error("PFC-Dust-Kujira: Contract can't be migrated! {current_name:?} {current_version:?}")]
MigrationError {
Expand Down
Loading

0 comments on commit e2a152d

Please sign in to comment.