diff --git a/contracts/lsm-share-bond-provider/src/contract.rs b/contracts/lsm-share-bond-provider/src/contract.rs index faae0f93..fe116fd9 100644 --- a/contracts/lsm-share-bond-provider/src/contract.rs +++ b/contracts/lsm-share-bond-provider/src/contract.rs @@ -163,11 +163,7 @@ fn query_can_process_on_idle(deps: Deps, env: &Env) -> ContractRes let config = CONFIG.load(deps.storage)?; - let pending_lsm_shares_count = PENDING_LSM_SHARES - .keys(deps.storage, None, None, cosmwasm_std::Order::Ascending) - .count(); - - if pending_lsm_shares_count > 0 { + if !PENDING_LSM_SHARES.is_empty(deps.storage) { return Ok(true); } @@ -406,6 +402,8 @@ fn execute_puppeteer_hook( } TOTAL_LSM_SHARES_REAL_AMOUNT.update(deps.storage, |one| StdResult::Ok(one - sum))?; LAST_LSM_REDEEM.save(deps.storage, &env.block.time.seconds())?; + + TX_STATE.save(deps.storage, &TxState::default())?; } } @@ -431,22 +429,24 @@ pub fn get_pending_redeem_msg( env: &Env, ) -> ContractResult>> { let addrs = get_contracts!(deps, config.factory_contract, puppeteer_contract); - let pending_lsm_shares_count = LSM_SHARES_TO_REDEEM - .keys(deps.storage, None, None, cosmwasm_std::Order::Ascending) - .count(); - let last_lsm_redeem = LAST_LSM_REDEEM.load(deps.storage)?; + let lsm_redeem_threshold = config.lsm_redeem_threshold as usize; + let shares_to_redeeem = LSM_SHARES_TO_REDEEM + .range(deps.storage, None, None, cosmwasm_std::Order::Ascending) + .take(lsm_redeem_threshold) + .collect::>>()?; + + let pending_lsm_shares_count = shares_to_redeeem.len(); + + let last_lsm_redeem = LAST_LSM_REDEEM.load(deps.storage)?; + if pending_lsm_shares_count == 0 || ((pending_lsm_shares_count < lsm_redeem_threshold) && (last_lsm_redeem + config.lsm_redeem_maximum_interval > env.block.time.seconds())) { return Ok(None); } - let shares_to_redeeem = LSM_SHARES_TO_REDEEM - .range(deps.storage, None, None, cosmwasm_std::Order::Ascending) - .take(lsm_redeem_threshold) - .collect::>>()?; let items: Vec = shares_to_redeeem .iter() diff --git a/ts-client/lib/contractLib/dropFactory.d.ts b/ts-client/lib/contractLib/dropFactory.d.ts index 1a92e22f..ea2f37ae 100644 --- a/ts-client/lib/contractLib/dropFactory.d.ts +++ b/ts-client/lib/contractLib/dropFactory.d.ts @@ -708,7 +708,7 @@ export interface ConfigOptional2 { val_ref_contract?: string | null; } export interface ValidatorData { - on_top: Uint128; + on_top?: Uint128 | null; valoper_address: string; weight: number; } diff --git a/ts-client/lib/contractLib/dropValidatorsSet.d.ts b/ts-client/lib/contractLib/dropValidatorsSet.d.ts index e884cddc..77cb1793 100644 --- a/ts-client/lib/contractLib/dropValidatorsSet.d.ts +++ b/ts-client/lib/contractLib/dropValidatorsSet.d.ts @@ -71,7 +71,7 @@ export type OnTopEditOperation = { validator_address: string; }; } | { - subtract: { + set: { amount: Uint128; validator_address: string; }; @@ -147,7 +147,7 @@ export interface UpdateValidatorsArgs { validators: ValidatorData[]; } export interface ValidatorData { - on_top: Uint128; + on_top?: Uint128 | null; valoper_address: string; weight: number; } diff --git a/ts-client/src/contractLib/dropFactory.ts b/ts-client/src/contractLib/dropFactory.ts index b0e63b80..8db347cc 100644 --- a/ts-client/src/contractLib/dropFactory.ts +++ b/ts-client/src/contractLib/dropFactory.ts @@ -776,7 +776,7 @@ export interface ConfigOptional2 { val_ref_contract?: string | null; } export interface ValidatorData { - on_top: Uint128; + on_top?: Uint128 | null; valoper_address: string; weight: number; } diff --git a/ts-client/src/contractLib/dropValidatorsSet.ts b/ts-client/src/contractLib/dropValidatorsSet.ts index ee8dcbb7..8baaf445 100644 --- a/ts-client/src/contractLib/dropValidatorsSet.ts +++ b/ts-client/src/contractLib/dropValidatorsSet.ts @@ -76,7 +76,7 @@ export type OnTopEditOperation = }; } | { - subtract: { + set: { amount: Uint128; validator_address: string; }; @@ -162,7 +162,7 @@ export interface UpdateValidatorsArgs { validators: ValidatorData[]; } export interface ValidatorData { - on_top: Uint128; + on_top?: Uint128 | null; valoper_address: string; weight: number; }