diff --git a/CHANGELOG.md b/CHANGELOG.md index d1421392b9..a3cf6a74b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features +- program: increase stable coin oracle threshold ([#1526](https://github.com/drift-labs/protocol-v2/pull/1526)) + ### Fixes ### Breaking diff --git a/programs/drift/src/state/oracle.rs b/programs/drift/src/state/oracle.rs index b1b328dba7..218ac42d3c 100644 --- a/programs/drift/src/state/oracle.rs +++ b/programs/drift/src/state/oracle.rs @@ -321,9 +321,11 @@ pub fn get_pyth_stable_coin_price( let price = oracle_price_data.price; let confidence = oracle_price_data.confidence; - let five_bps = 500_i64; + let twenty_bps = 2000_i64; - if price.safe_sub(PRICE_PRECISION_I64)?.abs() <= five_bps.min(confidence.cast()?) { + if price.safe_sub(PRICE_PRECISION_I64)?.abs() + <= twenty_bps.min(confidence.cast::()?.saturating_mul(5)) + { oracle_price_data.price = PRICE_PRECISION_I64; } diff --git a/sdk/src/oracles/pythClient.ts b/sdk/src/oracles/pythClient.ts index 464b975e9a..011612464b 100644 --- a/sdk/src/oracles/pythClient.ts +++ b/sdk/src/oracles/pythClient.ts @@ -75,9 +75,14 @@ function convertPythPrice(price: number, exponent: number, multiple: BN): BN { .div(pythPrecision); } -const fiveBPS = new BN(500); +const twentyBPS = new BN(2000); function getStableCoinPrice(price: BN, confidence: BN): BN { - if (price.sub(QUOTE_PRECISION).abs().lt(BN.min(confidence, fiveBPS))) { + if ( + price + .sub(QUOTE_PRECISION) + .abs() + .lt(BN.min(confidence.muln(5), twentyBPS)) + ) { return QUOTE_PRECISION; } else { return price;