Skip to content

Commit

Permalink
Merge pull request #208 from hadronlabs-org/feat/fix-integration-tests
Browse files Browse the repository at this point in the history
Fix. Lsm Shares Bond provider
  • Loading branch information
oldremez authored Dec 4, 2024
2 parents 31f7b90 + d72f5fb commit 97b87a5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
26 changes: 13 additions & 13 deletions contracts/lsm-share-bond-provider/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,7 @@ fn query_can_process_on_idle(deps: Deps<NeutronQuery>, 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);
}

Expand Down Expand Up @@ -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())?;
}
}

Expand All @@ -431,22 +429,24 @@ pub fn get_pending_redeem_msg(
env: &Env,
) -> ContractResult<Option<SubMsg<NeutronMsg>>> {
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::<StdResult<Vec<_>>>()?;

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::<StdResult<Vec<_>>>()?;

let items: Vec<RedeemShareItem> = shares_to_redeeem
.iter()
Expand Down
2 changes: 1 addition & 1 deletion ts-client/lib/contractLib/dropFactory.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions ts-client/lib/contractLib/dropValidatorsSet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export type OnTopEditOperation = {
validator_address: string;
};
} | {
subtract: {
set: {
amount: Uint128;
validator_address: string;
};
Expand Down Expand Up @@ -147,7 +147,7 @@ export interface UpdateValidatorsArgs {
validators: ValidatorData[];
}
export interface ValidatorData {
on_top: Uint128;
on_top?: Uint128 | null;
valoper_address: string;
weight: number;
}
Expand Down
2 changes: 1 addition & 1 deletion ts-client/src/contractLib/dropFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions ts-client/src/contractLib/dropValidatorsSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export type OnTopEditOperation =
};
}
| {
subtract: {
set: {
amount: Uint128;
validator_address: string;
};
Expand Down Expand Up @@ -162,7 +162,7 @@ export interface UpdateValidatorsArgs {
validators: ValidatorData[];
}
export interface ValidatorData {
on_top: Uint128;
on_top?: Uint128 | null;
valoper_address: string;
weight: number;
}
Expand Down

0 comments on commit 97b87a5

Please sign in to comment.