-
Notifications
You must be signed in to change notification settings - Fork 341
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
Added maxGasPrice setting to SanityRates, and updated to solidity 6 #1053
Conversation
b6affb6
to
1cbd443
Compare
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.
please add revert message
and check them
also add unit to function / parameter name
we should use normal withdrawable
can find it in Quangs PR for uniswap V2
e706c9c
to
934782e
Compare
70e7f57
to
887422a
Compare
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 think there is no test for a token that rate wasn't set.
should test getting sanity rates both sides for a token that wasn't set.
887422a
to
5d16b31
Compare
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.
Some minor stuff
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.
see comments
two setter functions are never tested by calling with un authorised address.
setGasPrice(_maxGasPriceWei); | ||
} | ||
|
||
/// @dev set reasonableDiffInBps of a token to MAX_RATE if you want to ignore |
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 write:
set reasonableDiffInBps of a token to MAX_RATE to avoid handling the price feed for this token.
Hard to understand current sentence, "ignore sanity rate for it", seems the sentence is in reserve level perspective.
so better write it in this contract perspective.
easier to communicate it like this.
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.
Okay, changed it to this comment.
|
||
contract SanityRatesGasPrice is IKyberSanity, Withdrawable3, Utils5 { | ||
struct SanityData { | ||
uint168 tokenRate; |
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.
lets use here:
uint128
uint128
those numbers look a little weird.
especially when later used for casting in the file.
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.
Done.
} | ||
} | ||
|
||
function getSanityRate(IERC20 src, IERC20 dest) external override view returns (uint256) { |
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.
please use the return value to declare 'rate' parameter.
it has 3 advantages:
- we use this parameter which in on the stack anyway.
- the function is clearer when we say name of return value (in this case not a big diff, in other examples more important)
- it saves another extra line of declaring another parameter.
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.
Done.
test/sol6/sanityRatesGasPrice.js
Outdated
sanityRates = await SanityRates.new(admin, gasPrice); | ||
await sanityRates.addOperator(operator); | ||
|
||
await sanityRates.setReasonableDiff(tokens, reasonableDiffs); |
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.
this is never called by non admin address
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.
Added test.
test/sol6/sanityRatesGasPrice.js
Outdated
}); | ||
|
||
it('should test setting sanity rates.', async function () { | ||
await sanityRates.setSanityRates(tokens, rates, {from: operator}); |
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.
not this is never called by non operator address
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.
Added test.
|
||
|
||
contract MockReserveSanity is IKyberReserve, Utils5 { | ||
using SafeERC20 for IERC20; |
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 be better to just make this a mock reserve.
not only for sanity.
like mock reserve with fixed rates we use in Katalyst regression.
And the mock reserve can call sanity if address isn't 0.
but don't need to handle it now.
just name this mockReserve and add todo for trade function.
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.
There is already MockReserve.sol, but I forked it since I didn't know if modifying the existing one will affect the other existing tests. Anyway I can just use this instead. Just need to add more lines on sanity tests for reserve setup.
also fixing
#168