Skip to content
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

Merged
merged 7 commits into from
Aug 14, 2020

Conversation

ayobuenavista
Copy link
Contributor

@ayobuenavista ayobuenavista commented Aug 5, 2020

also fixing
#168

Copy link
Contributor

@ilanDoron ilanDoron left a 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

contracts/sol6/SanityRatesMaxGasPrice.sol Outdated Show resolved Hide resolved
contracts/sol6/SanityRatesMaxGasPrice.sol Outdated Show resolved Hide resolved
contracts/sol6/SanityRatesMaxGasPrice.sol Outdated Show resolved Hide resolved
contracts/sol6/SanityRatesMaxGasPrice.sol Outdated Show resolved Hide resolved
@ayobuenavista ayobuenavista force-pushed the sanity/maxGasPrice branch 7 times, most recently from 70e7f57 to 887422a Compare August 10, 2020 11:20
Copy link
Contributor

@ilanDoron ilanDoron left a 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.

contracts/sol6/mock/MockReserveSanity.sol Outdated Show resolved Hide resolved
test/sol6/sanityRatesMaxPrice.js Outdated Show resolved Hide resolved
contracts/sol6/SanityRatesGasPrice.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@Anyhowclick Anyhowclick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor stuff

contracts/sol6/SanityRatesGasPrice.sol Outdated Show resolved Hide resolved
contracts/sol6/mock/MockReserveSanity.sol Outdated Show resolved Hide resolved
contracts/sol6/SanityRatesGasPrice.sol Outdated Show resolved Hide resolved
contracts/sol6/SanityRatesGasPrice.sol Outdated Show resolved Hide resolved
contracts/sol6/SanityRatesGasPrice.sol Outdated Show resolved Hide resolved
contracts/sol6/SanityRatesGasPrice.sol Outdated Show resolved Hide resolved
contracts/sol6/SanityRatesGasPrice.sol Outdated Show resolved Hide resolved
Copy link
Contributor

@ilanDoron ilanDoron left a 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
Copy link
Contributor

@ilanDoron ilanDoron Aug 13, 2020

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.

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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) {
Copy link
Contributor

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:

  1. we use this parameter which in on the stack anyway.
  2. the function is clearer when we say name of return value (in this case not a big diff, in other examples more important)
  3. it saves another extra line of declaring another parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

sanityRates = await SanityRates.new(admin, gasPrice);
await sanityRates.addOperator(operator);

await sanityRates.setReasonableDiff(tokens, reasonableDiffs);
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test.

});

it('should test setting sanity rates.', async function () {
await sanityRates.setSanityRates(tokens, rates, {from: operator});
Copy link
Contributor

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

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@ilanDoron ilanDoron merged commit ac3829b into master Aug 14, 2020
@ilanDoron ilanDoron deleted the sanity/maxGasPrice branch August 14, 2020 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants