Skip to content

Commit

Permalink
fix(pcl): convert price scale based on base/quote denoms
Browse files Browse the repository at this point in the history
  • Loading branch information
epanchee committed Mar 13, 2024
1 parent ce7dad6 commit 136bd0e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion contracts/pair_concentrated/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,15 @@ pub fn query(deps: Deps, env: Env, msg: QueryMsg) -> StdResult<Binary> {
observation.price.inv().unwrap_or_default()
}
})
.or_else(|_| try_dec256_into_dec(config.pool_state.price_state.price_scale))?;
.or_else(|_| -> StdResult<_> {
let price_scale =
try_dec256_into_dec(config.pool_state.price_state.price_scale)?;
if pool_denoms[0] == quote_asset_denom && pool_denoms[1] == base_asset_denom {
Ok(price_scale)
} else {
Ok(price_scale.inv().unwrap_or_default())
}
})?;

to_json_binary(&SpotPriceResponse { spot_price })
}
Expand Down

0 comments on commit 136bd0e

Please sign in to comment.