-
Notifications
You must be signed in to change notification settings - Fork 2
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
Post audit changes Part 1 #23
Conversation
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.
LGTM but let's give the honours to the people that found the bugs :)
Co-authored-by: deuszx <95355183+deuszx@users.noreply.github.com>
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.
very nice 👍
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.
LGTM
amm/contracts/stable_pool/lib.rs
Outdated
@@ -718,7 +723,7 @@ pub mod stable_pool { | |||
let current_time = self.env().block_timestamp(); | |||
let mut rate_changed = false; | |||
for rate in self.pool.token_rates.iter_mut() { | |||
rate_changed = rate_changed || rate.update_rate_no_cache(current_time); | |||
rate_changed = rate.update_rate_no_cache(current_time) || rate_changed; |
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.
I'd prefer |
there anyway, as (1) Using ||
in expressions used in assignments is usually asking for troubles (someone might fork the repo and add some new condition after rate_changed
, which would be bad), and (2) I'm not sure if the gas cost of ||
wouldn't be greater, because of conditional jumps (probably in nanoscale, but still).
But it's correct and contracts are non-upgradeable, so up to you :P
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.
I personally like ||
more than bitwise |
- It's more clear
- When using
|
,rate_changed
would have to have a number type (|
shouldn't be applicable tobool
) and this is weird - Optimization of
|
sounds negligible
I can also propose an alternative which is 100% clear 😛
if rate.update_rate_no_cache(current_time) {
rate_changed = true;
}
The first part of the changes recommended in #22 and #18
D
calculationPrecision
error whenD
calculation takes more thanMAX_ITERATIONS
||
used inupdate_rates(...)