Propose change to the comment
Closed this issue · 2 comments
sujine2 commented
It seems that the notice about the tokenOracleReverse
is wrong.
struct OracleHelperConfig {
...
/// @notice 'true' if price is dollars-per-token (or ether-per-token), 'false' if price is tokens-per-dollar
bool tokenOracleReverse;
/// @notice 'false' if price is dollars-per-ether, 'true' if price is ether-per-dollar
bool nativeOracleReverse;
...
}
function calculatePrice(
uint256 tokenPrice,
uint256 nativeAssetPrice,
bool tokenOracleReverse,
bool nativeOracleReverse
) private view returns (uint256){
if (tokenOracleReverse) {
tokenPrice = PRICE_DENOMINATOR * tokenOracleDecimalPower / tokenPrice;
else {
tokenPrice = PRICE_DENOMINATOR * tokenPrice / tokenOracleDecimalPower;
}
if (nativeOracleReverse) {
return nativeAssetPrice * tokenPrice / nativeOracleDecimalPower;
} else {
return tokenPrice * nativeOracleDecimalPower / nativeAssetPrice;
}
}
Parameter tokenPrice
is the return value of oracle (dollars-per-token)
When the token price is 200000000 USD and decimal is 8 and tokenOracleReverse
is true, the tokenPrice
is PRICE_DENOMINATOR / 2, which is tokens-per-dollar.
When tokenOracleReverse is false, the tokenPrice
is PRICE_DENOMINATOR * 2, which is dollars-per-token
Below is the proposed change to the comment:
@notice 'false' if price is dollars-per-token (or ether-per-token), 'ture' if price is tokens-per-dollar
drortirosh commented
please submit fixes as PRs (and if needed, update tests too).
drortirosh commented