-
Notifications
You must be signed in to change notification settings - Fork 17
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
fix: Error on too few snapshots and too short #223
Conversation
window size
d866079
to
364a08e
Compare
@@ -174,6 +174,12 @@ impl PriceSourceUnchecked<WasmPriceSourceChecked, Empty> for WasmPriceSourceUnch | |||
&route_assets, | |||
)?; | |||
|
|||
if window_size <= 1 { |
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.
set this either as const MIN_WINDOW_SIZE
or config item?
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.
Could set it as a const if you prefer, but it shouldn't be changeable. Its just that the logic breaks (subtraction underflow) if you set it to 1 or less.
@@ -307,6 +313,10 @@ fn query_astroport_twap_price( | |||
.may_load(deps.storage, denom)? | |||
.ok_or(ContractError::NoSnapshots {})?; | |||
|
|||
if snapshots.len() < 2 { |
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.
set as either const MIN_NUM_OF_SNAPSHOTS
or config item?
window size