Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bigz/improve-perp-match-get_fallback_price #797

Merged
merged 3 commits into from
Dec 29, 2023

Conversation

0xbigz
Copy link
Member

@0xbigz 0xbigz commented Dec 27, 2023

No description provided.

Copy link

codecov bot commented Dec 27, 2023

Codecov Report

Merging #797 (671b31d) into master (ec254da) will increase coverage by 0.02%.
Report is 21 commits behind head on master.
The diff coverage is 91.83%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #797      +/-   ##
==========================================
+ Coverage   74.52%   74.55%   +0.02%     
==========================================
  Files         126      126              
  Lines       29603    29643      +40     
==========================================
+ Hits        22062    22100      +38     
- Misses       7541     7543       +2     
Components Coverage Δ
drift 74.75% <91.83%> (+0.02%) ⬆️

programs/drift/src/state/user.rs Outdated Show resolved Hide resolved
amm_available_liquidity: u64,
oracle_price: i64,
seconds_til_order_expiry: i64,
) -> DriftResult<i64> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should return u64 probably

} else {
oracle_price.safe_add(self.last_bid_price_twap.cast::<i64>()?
.safe_sub(self.historical_oracle_data.last_oracle_price_twap)?
.min(0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think it'd be better to min 0 with (last bid price twap - last_oracle_price_twap) so this is never 0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

think thats what its doing already

@@ -771,6 +771,45 @@ impl Default for AMM {
}

impl AMM {
pub fn get_fallback_price(self,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs tests

@crispheaney crispheaney merged commit 71d7931 into master Dec 29, 2023
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants