Skip to content

Commit

Permalink
chore: Clean solc warnings and fix test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
superduck35 committed Sep 29, 2021
1 parent b4fbb02 commit 0bd7c3e
Show file tree
Hide file tree
Showing 23 changed files with 156 additions and 390 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-shared.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
${{ runner.os }}-yarn-
- run: yarn
- run: yarn compile
- run: yarn test:file ./test/buy-and-make/*.spec.ts ./test/meta-token/*.spec.ts ./test/nexus/*.spec.ts ./test/shared/*.spec.ts
- run: yarn test:file ./test/buy-and-make/*.spec.ts ./test/nexus/*.spec.ts ./test/shared/*.spec.ts
39 changes: 0 additions & 39 deletions contracts/interfaces/IMetaToken.sol

This file was deleted.

10 changes: 5 additions & 5 deletions contracts/masset/MassetLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ library MassetLogic {
uint8 _i,
uint256 _rawInput,
InvariantConfig memory _config
) public view returns (uint256 mintAmount) {
) public pure returns (uint256 mintAmount) {
// 1. Get raw reserves
(uint256[] memory x, uint256 sum) = _getReserves(_bAssets);
// 2. Get value of reserves according to invariant
Expand Down Expand Up @@ -540,7 +540,7 @@ library MassetLogic {
uint8[] memory _indices,
uint256[] memory _rawInputs,
InvariantConfig memory _config
) public view returns (uint256 mintAmount) {
) public pure returns (uint256 mintAmount) {
// 1. Get raw reserves
(uint256[] memory x, uint256 sum) = _getReserves(_bAssets);
// 2. Get value of reserves according to invariant
Expand Down Expand Up @@ -580,7 +580,7 @@ library MassetLogic {
uint256 _rawInput,
uint256 _feeRate,
InvariantConfig memory _config
) public view returns (uint256 bAssetOutputQuantity, uint256 scaledSwapFee) {
) public pure returns (uint256 bAssetOutputQuantity, uint256 scaledSwapFee) {
// 1. Get raw reserves
(uint256[] memory x, uint256 sum) = _getReserves(_bAssets);
// 2. Get value of reserves according to invariant
Expand Down Expand Up @@ -637,7 +637,7 @@ library MassetLogic {
uint256 _grossMassetQuantity,
InvariantConfig memory _config,
uint256 _feeRate
) public view returns (uint256 rawOutputUnits, uint256 scaledFee) {
) public pure returns (uint256 rawOutputUnits, uint256 scaledFee) {
// 1. Get raw reserves
(uint256[] memory x, uint256 sum) = _getReserves(_bAssets);
// 2. Get value of reserves according to invariant
Expand Down Expand Up @@ -685,7 +685,7 @@ library MassetLogic {
uint256[] memory _rawOutputs,
InvariantConfig memory _config,
uint256 _feeRate
) public view returns (uint256 grossMasset, uint256 fee) {
) public pure returns (uint256 grossMasset, uint256 fee) {
// 1. Get raw reserves
(uint256[] memory x, uint256 sum) = _getReserves(_bAssets);
// 2. Get value of reserves according to invariant
Expand Down
4 changes: 2 additions & 2 deletions contracts/rewards/BoostDirector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ contract BoostDirector is IBoostDirector, ImmutableModule {
uint128 _bitmap,
uint8 _pos,
uint8 _id
) internal returns (uint128 newMap) {
) internal pure returns (uint128 newMap) {
// bitmap = ... 00000000 00000000 00000011 00001010
// pos = 1, id = 1 = 00000001
// step = ... 00000000 00000000 00000001 00000000
Expand All @@ -166,7 +166,7 @@ contract BoostDirector is IBoostDirector, ImmutableModule {
*/
function _indexExists(uint128 _bitmap, uint8 _target)
internal
view
pure
returns (
bool isWhitelisted,
uint8 count,
Expand Down
2 changes: 1 addition & 1 deletion contracts/rewards/RewardsDistributionRecipient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IRewardsDistributionRecipient } from "../interfaces/IRewardsDistributio
/**
* @title RewardsDistributionRecipient
* @author Originally: Synthetix (forked from /Synthetixio/synthetix/contracts/RewardsDistributionRecipient.sol)
* Changes by: Stability Labs Pty. Ltd.
* Changes by: mStable
* @notice RewardsDistributionRecipient gets notified of additional rewards by the rewardsDistributor
* @dev Changes: Addition of ImmutableModule and abstract `getRewardToken` func + cosmetic
*/
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,10 @@ import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { ERC20Burnable } from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";

/**
* @title MetaToken
* @author Stability Labs Pty. Ltd.
* @dev MetaToken is an ERC20 token, with mint privileges governed by mStable
* governors
* @title MintableToken
* @author mStable
*/
contract MetaToken is ERC20, GovernedMinterRole, ERC20Burnable {
/**
* @dev MetaToken simply implements a detailed ERC20 token,
* and a governed list of minters
*/
contract MintableToken is ERC20, GovernedMinterRole, ERC20Burnable {
constructor(address _nexus, address _initialRecipient)
ERC20("Meta", "MTA")
GovernedMinterRole(_nexus)
Expand All @@ -24,7 +18,6 @@ contract MetaToken is ERC20, GovernedMinterRole, ERC20Burnable {
_mint(_initialRecipient, 100000000 * (10**18));
}

// Forked from @openzeppelin
/**
* @dev See {ERC20-_mint}.
*
Expand Down
1 change: 1 addition & 0 deletions contracts/z_mocks/buy-and-make/MockBPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@ contract MockBPool is ERC20, IBPool {
tokenAmountOut = (tokenAmountIn * inputToOutputRatio) / 1e18;
require(tokenAmountOut > minAmountOut, "Invalid output amount");
IERC20(tokenOut).transfer(msg.sender, tokenAmountOut);
return (tokenAmountOut, 0);
}
}
10 changes: 5 additions & 5 deletions contracts/z_mocks/feeder/ExposedFeederLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contract ExposedFeederLogic {
uint8 _i,
uint256 _rawInput,
FeederConfig memory _config
) public view returns (uint256 mintAmount) {
) public pure returns (uint256 mintAmount) {
return FeederLogic.computeMint(_bAssets, _i, _rawInput, _config);
}

Expand All @@ -19,7 +19,7 @@ contract ExposedFeederLogic {
uint8[] memory _indices,
uint256[] memory _rawInputs,
FeederConfig memory _config
) public view returns (uint256 mintAmount) {
) public pure returns (uint256 mintAmount) {
return FeederLogic.computeMintMulti(_bAssets, _indices, _rawInputs, _config);
}

Expand All @@ -30,7 +30,7 @@ contract ExposedFeederLogic {
uint256 _rawInput,
uint256 _feeRate,
FeederConfig memory _config
) public view returns (uint256 bAssetOutputQuantity, uint256 scaledSwapFee) {
) public pure returns (uint256 bAssetOutputQuantity, uint256 scaledSwapFee) {
return FeederLogic.computeSwap(_bAssets, _i, _o, _rawInput, _feeRate, _config);
}

Expand All @@ -39,7 +39,7 @@ contract ExposedFeederLogic {
uint8 _o,
uint256 _netMassetQuantity,
FeederConfig memory _config
) public view returns (uint256 rawOutputUnits) {
) public pure returns (uint256 rawOutputUnits) {
return FeederLogic.computeRedeem(_bAssets, _o, _netMassetQuantity, _config);
}

Expand All @@ -48,7 +48,7 @@ contract ExposedFeederLogic {
uint8[] memory _indices,
uint256[] memory _rawOutputs,
FeederConfig memory _config
) public view returns (uint256 totalmAssets) {
) public pure returns (uint256 totalmAssets) {
return FeederLogic.computeRedeemExact(_bAssets, _indices, _rawOutputs, _config);
}
}
3 changes: 2 additions & 1 deletion contracts/z_mocks/governance/MockBVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ contract MockBVault is IBVault {
returns (
address[] memory tokens,
uint256[] memory balances,
uint256 /*lastChangeBlock*/
uint256 lastChangeBlock
)
{
lastChangeBlock = 0;
MockBPT pool = pools[poolId];
IERC20[] memory tokenDatas = tokenData[address(pool)];
uint256 len = tokenDatas.length;
Expand Down
12 changes: 6 additions & 6 deletions contracts/z_mocks/masset/ExposedMassetLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contract ExposedMassetLogic {
uint8 _i,
uint256 _rawInput,
InvariantConfig memory _config
) public view returns (uint256 mintAmount) {
) public pure returns (uint256 mintAmount) {
return MassetLogic.computeMint(_bAssets, _i, _rawInput, _config);
}

Expand All @@ -19,7 +19,7 @@ contract ExposedMassetLogic {
uint8[] memory _indices,
uint256[] memory _rawInputs,
InvariantConfig memory _config
) public view returns (uint256 mintAmount) {
) public pure returns (uint256 mintAmount) {
return MassetLogic.computeMintMulti(_bAssets, _indices, _rawInputs, _config);
}

Expand All @@ -30,7 +30,7 @@ contract ExposedMassetLogic {
uint256 _rawInput,
uint256 _feeRate,
InvariantConfig memory _config
) public view returns (uint256 bAssetOutputQuantity, uint256 scaledSwapFee) {
) public pure returns (uint256 bAssetOutputQuantity, uint256 scaledSwapFee) {
return MassetLogic.computeSwap(_bAssets, _i, _o, _rawInput, _feeRate, _config);
}

Expand All @@ -40,7 +40,7 @@ contract ExposedMassetLogic {
uint256 _netMassetQuantity,
InvariantConfig memory _config,
uint256 _feeRate
) public view returns (uint256 rawOutputUnits, uint256 scaledFee) {
) public pure returns (uint256 rawOutputUnits, uint256 scaledFee) {
return MassetLogic.computeRedeem(_bAssets, _o, _netMassetQuantity, _config, _feeRate);
}

Expand All @@ -50,13 +50,13 @@ contract ExposedMassetLogic {
uint256[] memory _rawOutputs,
InvariantConfig memory _config,
uint256 _feeRate
) public view returns (uint256 grossMasset, uint256 fee) {
) public pure returns (uint256 grossMasset, uint256 fee) {
return MassetLogic.computeRedeemExact(_bAssets, _indices, _rawOutputs, _config, _feeRate);
}

function getK(BassetData[] memory _bAssets, InvariantConfig memory _config)
external
view
pure
returns (uint256 k)
{
(, k) = MassetLogic.computePrice(_bAssets, _config);
Expand Down
2 changes: 1 addition & 1 deletion contracts/z_mocks/masset/MaliciousAaveIntegration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ contract MaliciousAaveIntegration is IPlatformIntegration, ImmutableModule {
* @param _bAsset Address of the bAsset
* @return balance Total value of the bAsset in the platform
*/
function checkBalance(address _bAsset) external override returns (uint256 balance) {
function checkBalance(address _bAsset) external view override returns (uint256 balance) {
// balance is always with token aToken decimals
IAaveATokenV2 aToken = _getATokenFor(_bAsset);
return _checkBalance(aToken) * 5;
Expand Down
2 changes: 1 addition & 1 deletion contracts/z_mocks/masset/MockPlatformIntegration.sol
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ contract MockPlatformIntegration is IPlatformIntegration, ImmutableModule {
* @param _bAsset Address of the bAsset
* @return balance Total value of the bAsset in the platform
*/
function checkBalance(address _bAsset) external override returns (uint256 balance) {
function checkBalance(address _bAsset) external view override returns (uint256 balance) {
// balance is always with token aToken decimals
IAaveATokenV2 aToken = _getATokenFor(_bAsset);
return _checkBalance(aToken);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
Expand Down
14 changes: 7 additions & 7 deletions contracts/z_mocks/shared/MockAaveIncentivesController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ contract MockAaveIncentivesController is IAaveIncentivesController {
return 1e20;
}

function getRewardsBalance(address[] calldata assets, address user)
external
view
override
returns (uint256)
{
function getRewardsBalance(
address[] calldata, /*assets*/
address /*user*/
) external pure override returns (uint256) {
return 1e20;
}

function getUserUnclaimedRewards(address user) external view override returns (uint256) {
function getUserUnclaimedRewards(
address /*user*/
) external pure override returns (uint256) {
return 1e20;
}
}
5 changes: 4 additions & 1 deletion contracts/z_mocks/shared/MockStakedAave.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ contract MockStakedAave is IStakedAave, ERC20 {
_mint(to, amount);
}

function redeem(address to, uint256 amount) external override {
function redeem(
address to,
uint256 /*amount*/
) external override {
require(
block.timestamp > stakersCooldowns[msg.sender] + COOLDOWN_SECONDS,
"INSUFFICIENT_COOLDOWN"
Expand Down
18 changes: 8 additions & 10 deletions contracts/z_mocks/shared/MockUniswap.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,18 @@ contract MockUniswap is IUniswapV2Router02 {
}

function swapExactETHForTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
uint256, /*amountOutMin*/
address[] calldata, /*path*/
address, /*to*/
uint256 /*deadline*/
) external payable override returns (uint256[] memory amounts) {
return new uint256[](0);
}

function getAmountsOut(uint256 amountIn, address[] calldata path)
external
view
override
returns (uint256[] memory amounts)
{
function getAmountsOut(
uint256, /*amountIn*/
address[] calldata /*path*/
) external pure override returns (uint256[] memory amounts) {
return new uint256[](0);
}
}
6 changes: 3 additions & 3 deletions contracts/z_mocks/shared/MockUniswapV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ contract MockUniswapV3 is IUniswapV3SwapRouter, IUniswapV3Quoter {
address tokenOut,
uint24 fee,
uint256 amountIn,
uint160 sqrtPriceLimitX96
uint160 /*sqrtPriceLimitX96*/
) external view override returns (uint256 amountOut) {
uint256 rate = rates[tokenIn][tokenOut];
amountOut = amountIn * rate * ((FEE_SCALE - fee) / FEE_SCALE);
Expand All @@ -147,8 +147,8 @@ contract MockUniswapV3 is IUniswapV3SwapRouter, IUniswapV3Quoter {
address tokenOut,
uint24 fee,
uint256 amountOut,
uint160 sqrtPriceLimitX96
) external override returns (uint256 amountIn) {
uint160 /*sqrtPriceLimitX96*/
) external view override returns (uint256 amountIn) {
uint256 rate = rates[tokenIn][tokenOut];
amountIn = (amountOut * RATE_SCALE * FEE_SCALE) / (rate * (FEE_SCALE - fee));
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"ethers-multicall": "^0.2.0",
"graphql": "^15.5.0",
"graphql-request": "^3.5.0",
"hardhat": "^2.6.0",
"hardhat": "^2.6.4",
"hardhat-gas-reporter": "^1.0.1",
"solidity-coverage": "0.7.16",
"ts-node": "^10.2.0",
Expand Down
Loading

0 comments on commit 0bd7c3e

Please sign in to comment.