diff --git a/Cargo.lock b/Cargo.lock index 045cf0f..b8b37bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,9 +82,9 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "cosmwasm-crypto" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6b4c3f9c4616d6413d4b5fc4c270a4cc32a374b9be08671e80e1a019f805d8f" +checksum = "dd50718a2b6830ce9eb5d465de5a018a12e71729d66b70807ce97e6dd14f931d" dependencies = [ "digest 0.10.7", "ecdsa", @@ -96,9 +96,9 @@ dependencies = [ [[package]] name = "cosmwasm-derive" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c586ced10c3b00e809ee664a895025a024f60d65d34fe4c09daed4a4db68a3f3" +checksum = "242e98e7a231c122e08f300d9db3262d1007b51758a8732cd6210b3e9faa4f3a" dependencies = [ "syn 1.0.109", ] @@ -129,9 +129,9 @@ dependencies = [ [[package]] name = "cosmwasm-std" -version = "1.5.4" +version = "1.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712fe58f39d55c812f7b2c84e097cdede3a39d520f89b6dc3153837e31741927" +checksum = "78c1556156fdf892a55cced6115968b961eaaadd6f724a2c2cb7d1e168e32dd3" dependencies = [ "base64", "bech32", @@ -683,6 +683,19 @@ dependencies = [ "serde", ] +[[package]] +name = "pfc-steak-dao" +version = "3.0.18" +dependencies = [ + "cosmwasm-schema", + "cosmwasm-std", + "cw20 1.1.2", + "cw20-base 1.1.2", + "pfc-steak", + "schemars", + "serde", +] + [[package]] name = "pfc-steak-hub" version = "3.0.16" @@ -700,7 +713,7 @@ dependencies = [ [[package]] name = "pfc-steak-hub-tf" -version = "3.0.17" +version = "3.0.19" dependencies = [ "cosmwasm-std", "cw-item-set", diff --git a/Cargo.toml b/Cargo.toml index 1f043b0..30c7359 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,6 @@ [workspace] -members = ["contracts/token", "contracts/hub", "contracts/hub-tf", "packages/*"] +members = ["contracts/token", "contracts/hub", "contracts/hub-tf", + "packages/*"] resolver = '1' [profile.release.package.pfc-steak] diff --git a/contracts/hub-tf/Cargo.toml b/contracts/hub-tf/Cargo.toml index 22764cc..ca5049c 100644 --- a/contracts/hub-tf/Cargo.toml +++ b/contracts/hub-tf/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pfc-steak-hub-tf" -version = "3.0.18" +version = "3.0.19" authors = ["larry ", "PFC "] edition = "2018" license = "GPL-3.0-or-later" diff --git a/contracts/hub-tf/src/contract.rs b/contracts/hub-tf/src/contract.rs index 96c3f13..18aff93 100644 --- a/contracts/hub-tf/src/contract.rs +++ b/contracts/hub-tf/src/contract.rs @@ -181,6 +181,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { start_after, limit, } => to_json_binary(&queries::unbond_requests_by_user(deps, user, start_after, limit)?), + QueryMsg::Unreconciled {} => to_json_binary(&queries::previous_batches_unreconciled(deps)?), } } diff --git a/contracts/hub-tf/src/execute.rs b/contracts/hub-tf/src/execute.rs index 2c1553b..1eb1f9b 100644 --- a/contracts/hub-tf/src/execute.rs +++ b/contracts/hub-tf/src/execute.rs @@ -353,11 +353,10 @@ pub fn harvest(deps: DepsMut, env: Env) -> StdResult { /// NOTE: /// 1. When delegation Native denom here, we don't need to use a `SubMsg` to handle the received -/// coins, -/// because we have already withdrawn all claimable staking rewards previously in the same atomic -/// execution. +/// coins, because we have already withdrawn all claimable staking rewards previously in the same +/// atomic execution. /// 2. Same as with `bond`, in the latest implementation we only delegate staking rewards with the -/// validator that has the smallest delegation amount. +/// validator that has the smallest delegation amount. pub fn reinvest(deps: DepsMut, env: Env) -> StdResult { let state = State::default(); let denom = state.denom.load(deps.storage)?; @@ -720,7 +719,7 @@ pub fn reconcile(deps: DepsMut, env: Env) -> StdResult { let all_batches = previous_batches() .idx .reconciled - .prefix("false".into()) + .prefix("false".to_string()) .range(deps.storage, None, None, Order::Ascending) .map(|item| { let (_, v) = item?; diff --git a/contracts/hub-tf/src/queries.rs b/contracts/hub-tf/src/queries.rs index 55b7212..4705912 100644 --- a/contracts/hub-tf/src/queries.rs +++ b/contracts/hub-tf/src/queries.rs @@ -113,6 +113,18 @@ pub fn previous_batches( }) .collect() } +pub fn previous_batches_unreconciled(deps: Deps) -> StdResult> { + state::previous_batches() + .idx + .reconciled + .prefix("false".into()) + .range(deps.storage, None, None, Order::Ascending) + .map(|item| { + let (_, v) = item?; + Ok(v) + }) + .collect() +} pub fn unbond_requests_by_batch( deps: Deps, diff --git a/contracts/hub-tf/src/state.rs b/contracts/hub-tf/src/state.rs index 70b95f0..714f88b 100644 --- a/contracts/hub-tf/src/state.rs +++ b/contracts/hub-tf/src/state.rs @@ -144,7 +144,7 @@ pub fn unbond_requests<'a>() pub struct PreviousBatchesIndexes<'a> { // pk goes to second tuple element - pub reconciled: MultiIndex<'a, String, Batch, String>, + pub reconciled: MultiIndex<'a, String, Batch, u64>, } impl<'a> IndexList for PreviousBatchesIndexes<'a> { diff --git a/contracts/hub/src/contract.rs b/contracts/hub/src/contract.rs index dae22e5..895f098 100644 --- a/contracts/hub/src/contract.rs +++ b/contracts/hub/src/contract.rs @@ -212,6 +212,7 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult { start_after, limit, } => to_json_binary(&queries::unbond_requests_by_user(deps, user, start_after, limit)?), + QueryMsg::Unreconciled {} => to_json_binary(&queries::previous_batches_unreconciled(deps)?), } } diff --git a/contracts/hub/src/execute.rs b/contracts/hub/src/execute.rs index e15c125..969d7a1 100644 --- a/contracts/hub/src/execute.rs +++ b/contracts/hub/src/execute.rs @@ -307,11 +307,10 @@ pub fn harvest(deps: DepsMut, env: Env) -> StdResult { /// NOTE: /// 1. When delegation Native denom here, we don't need to use a `SubMsg` to handle the received -/// coins, -/// because we have already withdrawn all claimable staking rewards previously in the same atomic -/// execution. +/// coins, because we have already withdrawn all claimable staking rewards previously in the same +/// atomic execution. /// 2. Same as with `bond`, in the latest implementation we only delegate staking rewards with the -/// validator that has the smallest delegation amount. +/// validator that has the smallest delegation amount. pub fn reinvest(deps: DepsMut, env: Env) -> StdResult { let state = State::default(); let denom = state.denom.load(deps.storage)?; diff --git a/contracts/hub/src/queries.rs b/contracts/hub/src/queries.rs index d308d76..14e8d9f 100644 --- a/contracts/hub/src/queries.rs +++ b/contracts/hub/src/queries.rs @@ -13,6 +13,7 @@ use pfc_steak::hub::{ use crate::{ helpers::{query_cw20_total_supply, query_delegations}, state::State, + types::BooleanKey, }; const MAX_LIMIT: u32 = 30; @@ -110,7 +111,21 @@ pub fn previous_batches( }) .collect() } +pub fn previous_batches_unreconciled(deps: Deps) -> StdResult> { + let state = State::default(); + state + .previous_batches + .idx + .reconciled + .prefix(BooleanKey::new(false)) + .range(deps.storage, None, None, Order::Ascending) + .map(|item| { + let (_, v) = item?; + Ok(v) + }) + .collect() +} pub fn unbond_requests_by_batch( deps: Deps, id: u64, diff --git a/justfile b/justfile index 6753226..16aa04d 100644 --- a/justfile +++ b/justfile @@ -2,7 +2,7 @@ check: cargo check --target wasm32-unknown-unknown --lib clippy: - cargo clippy --tests + cargo +nightly clippy --tests format: cargo +nightly fmt @@ -20,11 +20,11 @@ optimize-arm: --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ --platform linux/arm64 \ - cosmwasm/workspace-optimizer-arm64:0.15.1 + cosmwasm/optimizer-arm64:0.16.0 optimize-x86: docker run --rm -v "$(pwd)":/code \ --mount type=volume,source="$(basename "$(pwd)")_cache",target=/target \ --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ --platform linux/amd64 \ - cosmwasm/workspace-optimizer:0.15.1 + cosmwasm/optimizer:0.16.0 diff --git a/packages/steak/src/hub.rs b/packages/steak/src/hub.rs index 438d70d..9201669 100644 --- a/packages/steak/src/hub.rs +++ b/packages/steak/src/hub.rs @@ -188,6 +188,8 @@ pub enum QueryMsg { State {}, /// The current batch on unbonding requests pending submission. Response: `PendingBatch` PendingBatch {}, + /// list of batches with reconciled == false + Unreconciled {}, /// Query an individual batch that has previously been submitted for unbonding but have not yet /// fully withdrawn. Response: `Batch` PreviousBatch(u64),