-
Notifications
You must be signed in to change notification settings - Fork 110
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
refactor: move upd_twap from upd_aggregate to rust upd_price #398
Conversation
let agg_diff = { | ||
(clock.slot as i64) | ||
- load_checked::<PriceAccount>(price_account, cmd_args.header.version)?.last_slot_ | ||
as i64 | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
taken from upd_aggregate.h
@@ -100,8 +100,6 @@ fn test_upd_aggregate() { | |||
|
|||
assert_eq!(price_data.agg_.price_, 100); | |||
assert_eq!(price_data.agg_.conf_, 10); | |||
assert_eq!(price_data.twap_.val_, 100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better to keep the asserts and run c_upd_twap
after c_upd_aggregate
above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm we already have a test_ema.rs
which runs c_upd_twap
do we need it here again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would like to see other reviews
let agg_diff = { | ||
(clock.slot as i64) | ||
- load_checked::<PriceAccount>(price_account, cmd_args.header.version)? | ||
.prev_slot_ as i64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the prev_slot
after c_upd_aggregate
will remain the same as last_slot
before calling c_upd_aggregate
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup since both prev_slot
and last_slot
is only updated in c_upd_aggregate
if ptr->agg_.status_ == PC_STATUS_TRADING
|
||
// get number of slots from last published valid price | ||
int64_t agg_diff = ( int64_t )slot - ( int64_t )( ptr->last_slot_ ); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something to watch out for going forward is the if statement below this comment which updates the previous price. There's a chance that we introduce a bug that updates this multiple times on a single slot, which would make prev_slot == agg_.pub_slot_
this is the first refactor in part of the same slot agg changes, intentionally keeping it small and limited to
upd_twap
so that it's easier to review