Skip to content

Commit

Permalink
fix(PCL): internal audit regarding a new oracle type
Browse files Browse the repository at this point in the history
  • Loading branch information
epanchee authored Sep 1, 2023
1 parent c032206 commit 1ee5ff2
Show file tree
Hide file tree
Showing 18 changed files with 552 additions and 299 deletions.
45 changes: 22 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/pair_concentrated/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "astroport-pair-concentrated"
version = "2.0.5"
version = "2.1.0"
authors = ["Astroport"]
edition = "2021"
description = "The Astroport concentrated liquidity pair"
Expand Down
12 changes: 8 additions & 4 deletions contracts/pair_concentrated/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use astroport::asset::{
use astroport::common::{claim_ownership, drop_ownership_proposal, propose_new_owner};
use astroport::cosmwasm_ext::{AbsDiff, DecimalToInteger, IntegerToDecimal};
use astroport::factory::PairType;
use astroport::observation::{MIN_TRADE_SIZE, OBSERVATIONS_SIZE};
use astroport::observation::{PrecommitObservation, MIN_TRADE_SIZE, OBSERVATIONS_SIZE};
use astroport::pair::{Cw20HookMsg, ExecuteMsg, InstantiateMsg};
use astroport::pair_concentrated::{
ConcentratedPoolParams, ConcentratedPoolUpdateParams, MigrateMsg, UpdatePoolParams,
Expand Down Expand Up @@ -785,15 +785,19 @@ fn swap(
}
}

// Store time series data.
// Skipping small unsafe values which can seriously mess oracle price due to rounding errors
// Store observation from precommit data
accumulate_swap_sizes(deps.storage, &env)?;

// Store time series data in precommit observation.
// Skipping small unsafe values which can seriously mess oracle price due to rounding errors.
// This data will be reflected in observations in the next action.
if offer_asset_dec.amount >= MIN_TRADE_SIZE && swap_result.dy >= MIN_TRADE_SIZE {
let (base_amount, quote_amount) = if offer_ind == 0 {
(offer_asset.amount, return_amount)
} else {
(return_amount, offer_asset.amount)
};
accumulate_swap_sizes(deps.storage, &env, base_amount, quote_amount)?;
PrecommitObservation::save(deps.storage, &env, base_amount, quote_amount)?;
}

CONFIG.save(deps.storage, &config)?;
Expand Down
Loading

0 comments on commit 1ee5ff2

Please sign in to comment.