Skip to content

Commit

Permalink
fix query_exchange_rate x2
Browse files Browse the repository at this point in the history
  • Loading branch information
faust403 committed Nov 26, 2024
1 parent 3eaf9a5 commit c0529b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 6 additions & 4 deletions contracts/lazy-staking/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ fn query_exchange_rate(deps: Deps, env: Env) -> StdResult<Decimal> {
))?;
let lazy_denom: String = DENOM.load(deps.storage)?;
let lazy_total_supply = deps.querier.query_supply(lazy_denom)?;
let exchange_rate = asset_contract_balance.checked_mul(Decimal::from_ratio(
lazy_total_supply.amount,
Uint128::one(),
))?;
let exchange_rate = asset_contract_balance
.checked_div(Decimal::from_ratio(
lazy_total_supply.amount,
Uint128::one(),
))
.unwrap();
Ok(exchange_rate)
}

Expand Down
4 changes: 3 additions & 1 deletion contracts/lazy-staking/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{CheckedFromRatioError, OverflowError, StdError};
use cosmwasm_std::{CheckedFromRatioError, DivideByZeroError, OverflowError, StdError};
use cw_ownable::OwnershipError;
use cw_utils::PaymentError;
use neutron_sdk::NeutronError;
Expand Down Expand Up @@ -28,6 +28,8 @@ pub enum ContractError {
PaymentError(#[from] PaymentError),
#[error("{0}")]
CheckedFromRatioError(#[from] CheckedFromRatioError),
#[error("{0}")]
DivideByZeroError(#[from] DivideByZeroError),
}

impl From<semver::Error> for ContractError {
Expand Down

0 comments on commit c0529b2

Please sign in to comment.