-
Notifications
You must be signed in to change notification settings - Fork 81
perf(oracle): store price onto stack #113
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
Conversation
Liquidate was the only function that implied 2 calls to the oracle anyway, am I right ? |
The gas diff may not be representative of the true cost savings because of the use of a very basic mock oracle. A real oracle may be much more expensive to call. |
Note that if you have custom oracles, they can also take into account that they are called twice (to consume much less gas the second time). |
Note also that when the opti of setting address zero as oracle for the quote asset (which I believe happens in a lot of markets) in order for it not to be called, it reduces the gas improvement of this PR. |
@MathisGD @QGarchery do you approve? |
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 agree that we want to optimize oracle calls: they can be more complicated, we don't want to add a constraint on them to return early when called twice, and we want to limit external calls (anyone create a market with custom oracles). This PR is a straightforward solution to that problem, but it introduces some duplication.
I'm wondering if there is a different approach, see #137 (not entirely convinced by it yet, it may need more work)
The base branch was changed.
…ho-labs/blue into refactor/oracle-prices
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.
Looks good, one small change to make
77834bc
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'm not a huge fan to be honest, but at the same time I don't have in mind any better implem to avoid calling oracle twice.
We can merge @Rubilmax since @QGarchery is not available |
Gas diff is not much per our tests...