Skip to content

Commit

Permalink
Fix Crytic warnings (#73)
Browse files Browse the repository at this point in the history
* Fix compiler warning on doc strings

* Ignore require message too long warning

* Fix Syntic report: Local variables shadowing - (10)

* Add slither config to ignore oz packages

* Exclude more files

* Simplify slither config
  • Loading branch information
antoncoding committed Aug 18, 2020
1 parent 189b763 commit 94b6085
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 31 deletions.
3 changes: 2 additions & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"compiler-version":["error", "0.6.10"],
"not-rely-on-time": "off",
"no-complex-fallback": "off",
"no-inline-assembly": "off"
"no-inline-assembly": "off",
"reason-string": "off"
}
}
26 changes: 13 additions & 13 deletions contracts/Otoken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ contract Otoken is ERC20Initializable {
strikePrice = _strikePrice;
expiry = _expiry;
isPut = _isPut;
(string memory name, string memory symbol) = _getNameAndSymbol();
__ERC20_init_unchained(name, symbol);
(string memory tokenName, string memory tokenSymbol) = _getNameAndSymbol();
__ERC20_init_unchained(tokenName, tokenSymbol);
}

/**
Expand All @@ -92,10 +92,10 @@ contract Otoken is ERC20Initializable {

/**
* @notice generate name and symbol for an option
* @return name ETHUSDC 05-September-2020 200 Put USDC Collateral
* @return symbol oETHUSDC-05SEP20-200P
* @return tokenName ETHUSDC 05-September-2020 200 Put USDC Collateral
* @return tokenSymbol oETHUSDC-05SEP20-200P
*/
function _getNameAndSymbol() internal view returns (string memory name, string memory symbol) {
function _getNameAndSymbol() internal view returns (string memory tokenName, string memory tokenSymbol) {
string memory underlying = _getTokenSymbol(underlyingAsset);
string memory strike = _getTokenSymbol(strikeAsset);
string memory collateral = _getTokenSymbol(collateralAsset);
Expand All @@ -109,7 +109,7 @@ contract Otoken is ERC20Initializable {
(string memory monthSymbol, string memory monthFull) = _getMonth(month);

// concat name string: ETHUSDC 05-September-2020 200 Put USDC Collateral
name = string(
tokenName = string(
abi.encodePacked(
underlying,
strike,
Expand All @@ -129,7 +129,7 @@ contract Otoken is ERC20Initializable {
);

// concat symbol string: oETHUSDC-05SEP20-200P
symbol = string(
tokenSymbol = string(
abi.encodePacked(
"o",
underlying,
Expand Down Expand Up @@ -170,10 +170,10 @@ contract Otoken is ERC20Initializable {

/**
* @dev return string of option type
* @return symbol P or C
* @return full Put or Call
* @return shortString P or C
* @return longString Put or Call
*/
function _getOptionType(bool _isPut) internal pure returns (string memory symbol, string memory full) {
function _getOptionType(bool _isPut) internal pure returns (string memory shortString, string memory longString) {
if (_isPut) {
return ("P", "Put");
} else {
Expand All @@ -183,10 +183,10 @@ contract Otoken is ERC20Initializable {

/**
* @dev return string of month.
* @return symbol SEP, DEC ...etc
* @return full September, December ...etc
* @return shortString SEP, DEC ...etc
* @return longString September, December ...etc
*/
function _getMonth(uint256 _month) internal pure returns (string memory symbol, string memory full) {
function _getMonth(uint256 _month) internal pure returns (string memory shortString, string memory longString) {
if (_month == 1) {
return ("JAN", "January");
} else if (_month == 2) {
Expand Down
19 changes: 9 additions & 10 deletions contracts/libs/Actions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,19 @@ library Actions {
}

struct WithdrawArgs {
/// @notice The address of the account owner
//The address of the account owner
address owner;
/// @notice The index of the vault from which the asset will be withdrawn
// The index of the vault from which the asset will be withdrawn
uint256 vaultId;
/// @notice The address to which we transfer the asset
// The address to which we transfer the asset
address to;
/// @notice The asset that is to be withdrawn
// The asset that is to be withdrawn
address asset;
/**
* @notice Each vault can hold multiple short / long / collateral assets. In this version, we are restricting the scope to only 1 of each.
* In future versions this would be the index of the short / long / collateral asset that needs to be modified.
*/
// Each vault can hold multiple short / long / collateral assets.
// In this version, we are restricting the scope to only 1 of each.
// In future versions this would be the index of the short / long / collateral asset that needs to be modified.
uint256 index;
/// @notice The amount of asset that is to be transfered
// The amount of asset that is to be transfered
uint256 amount;
}

Expand Down Expand Up @@ -143,7 +142,7 @@ library Actions {
* @param _args The general action arguments structure
* @return The arguments for a withdraw action
*/
function _parseWithdrawArgs(ActionArgs memory _args) internal returns (WithdrawArgs memory) {
function _parseWithdrawArgs(ActionArgs memory _args) internal pure returns (WithdrawArgs memory) {
require(
(_args.actionType == ActionType.WithdrawLongOption) || (_args.actionType == ActionType.WithdrawCollateral),
"Actions: can only parse arguments for withdraw actions"
Expand Down
4 changes: 2 additions & 2 deletions contracts/mocks/MockERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ pragma solidity 0.6.10;
import {ERC20Initializable} from "../packages/oz/upgradeability/ERC20Initializable.sol";

contract MockERC20 is ERC20Initializable {
constructor(string memory name, string memory symbol) public {
__ERC20_init_unchained(name, symbol);
constructor(string memory _name, string memory _symbol) public {
__ERC20_init_unchained(_name, _symbol);
}

function mint(address account, uint256 amount) public {
Expand Down
6 changes: 3 additions & 3 deletions contracts/mocks/MockOtoken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ contract MockOtoken is ERC20Initializable {
strikePrice = _strikePrice;
expiry = _expiry;
isPut = _isPut;
string memory name = "ETHUSDC/1597511955/200P/USDC";
string memory symbol = "oETHUSDCP";
__ERC20_init_unchained(name, symbol);
string memory tokenName = "ETHUSDC/1597511955/200P/USDC";
string memory tokenSymbol = "oETHUSDCP";
__ERC20_init_unchained(tokenName, tokenSymbol);
}
}
2 changes: 1 addition & 1 deletion contracts/tests/UpgradeableContractV1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract UpgradeableContractV1 is VersionedInitializable {
* AddressBook.
* @param _addressBook the address of the AddressBook
**/
function initialize(address _addressBook) public initializer {
function initialize(address _addressBook) external initializer {
addressBook = _addressBook;
}
}
2 changes: 1 addition & 1 deletion contracts/tests/UpgradeableContractV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract UpgradeableContractV2 is VersionedInitializable {
* AddressBook.
* @param _addressBook the address of the AddressBook
**/
function initialize(address _addressBook) public initializer {
function initialize(address _addressBook) external initializer {
addressBook = _addressBook;
}
}
3 changes: 3 additions & 0 deletions slither.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"filter_paths": "packages|mocks|tests"
}

0 comments on commit 94b6085

Please sign in to comment.