Skip to content

Commit 8de9f60

Browse files
committed
program: update-mark-twap-crank-use-5min-basis (#1769)
* program: update-mark-twap-crank-use-5min-basis * changelog
1 parent d1dcc96 commit 8de9f60

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- program: add new settle pnl invariants ([#1812](https://github.com/drift-labs/protocol-v2/pull/1812))
1313
- program: add update_perp_market_pnl_pool ([#1810](https://github.com/drift-labs/protocol-v2/pull/1810))
14+
- program: update mark twap crank use 5min basis for bid/ask ([#1769](https://github.com/drift-labs/protocol-v2/pull/1769))
1415

1516
### Fixes
1617

programs/drift/src/math/amm.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,13 @@ pub fn update_mark_twap_crank(
125125

126126
// handle crossing bid/ask
127127
if best_bid_price > best_ask_price {
128-
if best_bid_price >= oracle_price_data.price.cast()? {
128+
let market_basis = amm
129+
.last_mark_price_twap_5min
130+
.cast::<i64>()?
131+
.safe_sub(amm.historical_oracle_data.last_oracle_price_twap_5min)?
132+
.clamp(-oracle_price_data.price/100, oracle_price_data.price/100);
133+
134+
if best_bid_price >= oracle_price_data.price.safe_add(market_basis)?.cast()? {
129135
best_bid_price = best_ask_price;
130136
} else {
131137
best_ask_price = best_bid_price;

0 commit comments

Comments
 (0)