Skip to content

Commit

Permalink
feat: dust-collector package
Browse files Browse the repository at this point in the history
  • Loading branch information
PFC-developer committed Oct 27, 2023
1 parent e5f6576 commit 59458a5
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"packages/pfc-astroport_reward_holder",
"packages/pfc-fee-split",
"packages/pfc-vault",
"packages/pfc-dust-collector",
"packages/pfc-dust-collector-kujira",
"contracts/pfc-astroport-generator",
"contracts/pfc-fee-splitter",
Expand Down
11 changes: 11 additions & 0 deletions packages/pfc-dust-collector/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.rs]
indent_size = 4
23 changes: 23 additions & 0 deletions packages/pfc-dust-collector/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "pfc-dust-collector"
version = "0.1.0"
authors = ["PFC"]
edition = "2021"
description = "Common helpers for other contracts to use pfc-fee-split"
license = "Apache-2.0"
repository = "https://github.com/PFC-Validator/pfc-fee-split"
keywords = ["cosmos", "cosmwasm"]
[features]
backtraces = ["cosmwasm-std/backtraces"]

[dependencies]
cosmwasm-std = "1.0.0"
schemars = "0.8.10"
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
pfc-dust-collector-derive = {version ="0.1.0"}
pfc-whitelist-derive = {version ="0.1.0"}
pfc-whitelist={version="0.1.0"}

cosmwasm-schema = "1.2.1"
cw-ownable = "0.5.0"
cw-ownable-derive = "0.5.0"
60 changes: 60 additions & 0 deletions packages/pfc-dust-collector/src/dust_collector.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
use cosmwasm_schema::{cw_serde, QueryResponses};
use cosmwasm_std::Uint128;
use cw_ownable_derive::{cw_ownable_execute, cw_ownable_query};

use pfc_dust_collector_derive::pfc_dust_collect;

use pfc_whitelist_derive::{pfc_whitelist_exec, pfc_whitelist_query};
#[cw_serde]
pub struct CollectorResponse<T> {
pub entries: Vec<T>,
}

#[pfc_dust_collect]
#[pfc_whitelist_exec]
#[cw_ownable_execute]
#[cw_serde]
pub enum ExecuteMsg {
/// get some dust
SetTokenRouter { contract: String },
/// Set Base denom
SetBaseDenom { denom: String },
/// minimum of zero
SetAssetMinimum { denom: String, minimum: Uint128 },
/// passing this asset moving forward will just hold it, and not attempt to convert it. a 'Flush' will send it back (to avoid loops)
ClearAsset { denom: String },
}

#[cw_ownable_query]
#[pfc_whitelist_query]
#[cw_serde]
#[derive(QueryResponses)]
pub enum QueryMsg {
#[returns(CollectorResponse<AssetHolding>)]
Assets {
start_after: Option<String>,
limit: Option<u32>,
},
#[returns(AssetHolding)]
Asset { denom: String },
#[returns(ConfigResponse)]
Config {},
}

#[cw_serde]
pub struct ConfigResponse {
pub token_router: String,
pub base_denom: String,
pub return_contract: String,
}
#[cw_serde]
pub struct AssetMinimum {
pub denom: String,
pub minimum: Uint128,
}
#[cw_serde]
pub struct AssetHolding {
pub denom: String,
pub minimum: Uint128, // only send $ after we have this amount in this coin
pub balance: Uint128,
}
1 change: 1 addition & 0 deletions packages/pfc-dust-collector/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod dust_collector;

0 comments on commit 59458a5

Please sign in to comment.