Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanzhelyazkov committed Oct 3, 2023
1 parent 99e55f8 commit 8800feb
Show file tree
Hide file tree
Showing 17 changed files with 24 additions and 62 deletions.
12 changes: 7 additions & 5 deletions contracts/helpers/MockBancorNetworkV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contract MockBancorNetworkV3 {
address private immutable _bnt;

// what amount is added or subtracted to/from the input amount on swap
uint private immutable _outputAmount;
uint256 private immutable _outputAmount;

// true if the gain amount is added to the swap input, false if subtracted
bool private immutable _profit;
Expand All @@ -22,7 +22,7 @@ contract MockBancorNetworkV3 {
error NotWhitelisted();
error ZeroValue();

constructor(address bnt, uint outputAmount, bool profit) {
constructor(address bnt, uint256 outputAmount, bool profit) {
_bnt = bnt;
_outputAmount = outputAmount;
_profit = profit;
Expand Down Expand Up @@ -66,16 +66,17 @@ contract MockBancorNetworkV3 {
Token targetToken,
uint256 amount,
address trader,
uint deadline,
uint minTargetAmount
uint256 deadline,
uint256 minTargetAmount
) private returns (uint256) {
/* solhint-disable custom-errors */
require(deadline >= block.timestamp, "Swap timeout");
// withdraw source amount
sourceToken.safeTransferFrom(trader, address(this), amount);

// transfer target amount
// receive _outputAmount tokens per swap
uint targetAmount;
uint256 targetAmount;
if (_profit) {
targetAmount = amount + _outputAmount;
} else {
Expand All @@ -84,5 +85,6 @@ contract MockBancorNetworkV3 {
require(targetAmount >= minTargetAmount, "InsufficientTargetAmount");
targetToken.safeTransfer(trader, targetAmount);
return targetAmount;
/* solhint-enable custom-errors */
}
}
1 change: 0 additions & 1 deletion contracts/helpers/TestBNT.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

import { TestERC20Token } from "./TestERC20Token.sol";
Expand Down
2 changes: 0 additions & 2 deletions contracts/helpers/TestTokenType.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity 0.8.19;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import { Token } from "../token/Token.sol";

contract TestTokenType {
Expand Down
1 change: 0 additions & 1 deletion contracts/helpers/TestUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity 0.8.19;

import { IVersioned } from "../utility/interfaces/IVersioned.sol";
import { Upgradeable } from "../utility/Upgradeable.sol";

contract TestUpgradeable is Upgradeable {
Expand Down
1 change: 0 additions & 1 deletion contracts/helpers/TestVoucher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity 0.8.19;

import { Voucher } from "../voucher/Voucher.sol";
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";

contract TestVoucher is Voucher {
function safeMintTest(address owner, uint256 tokenId) external {
Expand Down
2 changes: 1 addition & 1 deletion contracts/pol/CarbonPOL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Token } from "../token/Token.sol";
import { Utils } from "../utility/Utils.sol";
import { MathEx } from "../utility/MathEx.sol";
import { ExpDecayMath } from "../utility/ExpDecayMath.sol";
import { MAX_GAP, PPM_RESOLUTION } from "../utility/Constants.sol";
import { MAX_GAP } from "../utility/Constants.sol";

/**
* @notice CarbonPOL contract
Expand Down
1 change: 0 additions & 1 deletion contracts/utility/Utils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity 0.8.19;
import { Address } from "@openzeppelin/contracts/utils/Address.sol";

import { PPM_RESOLUTION } from "./Constants.sol";
import { Token } from "../token/Token.sol";

error AccessDenied();
error InvalidAddress();
Expand Down
2 changes: 1 addition & 1 deletion contracts/vortex/CarbonVortex.sol
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ contract CarbonVortex is ICarbonVortex, Upgradeable, ReentrancyGuardUpgradeable,
}

function _validateTokens(Token[] calldata tokens) private view {
uint len = tokens.length;
uint256 len = tokens.length;
if (len == 0) {
revert InvalidTokenLength();
}
Expand Down
15 changes: 2 additions & 13 deletions test/forge/CarbonController.t.sol
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity 0.8.19;

import { Test } from "forge-std/Test.sol";

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { OptimizedTransparentUpgradeableProxy } from "hardhat-deploy/solc_0.8/proxy/OptimizedTransparentUpgradeableProxy.sol";

import { TestFixture } from "./TestFixture.t.sol";
import { CarbonVortex } from "../../contracts/vortex/CarbonVortex.sol";

import { Order, TradeAction } from "../../contracts/carbon/Strategies.sol";

import { AccessDenied, ZeroValue, InvalidAddress, InvalidFee } from "../../contracts/utility/Utils.sol";
import { AccessDenied, InvalidAddress } from "../../contracts/utility/Utils.sol";
import { OnlyProxyDelegate } from "../../contracts/utility/OnlyProxyDelegate.sol";
import { PPM_RESOLUTION } from "../../contracts/utility/Constants.sol";

import { TestCarbonController } from "../../contracts/helpers/TestCarbonController.sol";

import { IVoucher } from "../../contracts/voucher/interfaces/IVoucher.sol";
import { ICarbonController } from "../../contracts/carbon/interfaces/ICarbonController.sol";
import { ICarbonVortex } from "../../contracts/vortex/interfaces/ICarbonVortex.sol";
import { IBancorNetwork } from "../../contracts/vortex/CarbonVortex.sol";

import { Token, toIERC20, NATIVE_TOKEN } from "../../contracts/token/Token.sol";
import { Token } from "../../contracts/token/Token.sol";

contract CarbonControllerTest is TestFixture {
using Address for address payable;
Expand Down
15 changes: 5 additions & 10 deletions test/forge/CarbonPOL.t.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity 0.8.19;

import { Test } from "forge-std/Test.sol";

import { Address } from "@openzeppelin/contracts/utils/Address.sol";

import { TestFixture } from "./TestFixture.t.sol";
import { CarbonPOL } from "../../contracts/pol/CarbonPOL.sol";
import { POLTestCaseParser } from "./POLTestCaseParser.t.sol";

import { AccessDenied, InvalidAddress, InvalidFee, ZeroValue } from "../../contracts/utility/Utils.sol";
import { PPM_RESOLUTION } from "../../contracts/utility/Constants.sol";
import { MathEx } from "../../contracts/utility/MathEx.sol";
import { AccessDenied, ZeroValue } from "../../contracts/utility/Utils.sol";
import { ExpDecayMath } from "../../contracts/utility/ExpDecayMath.sol";
import { Token, NATIVE_TOKEN } from "../../contracts/token/Token.sol";

Expand Down Expand Up @@ -319,24 +314,24 @@ contract CarbonPOLTest is TestFixture {
POLTestCaseParser.TestCase[] memory testCases = testCaseParser.getTestCases();

// go through each of the eth amounts, token amounts and timestamps to verify token price output matches test data
for (uint i = 0; i < ethAmounts.length; ++i) {
for (uint j = 0; j < tokenAmounts.length; ++j) {
for (uint256 i = 0; i < ethAmounts.length; ++i) {
for (uint256 j = 0; j < tokenAmounts.length; ++j) {
vm.warp(1);
uint128 ethAmount = uint128(ethAmounts[i]);
uint128 tokenAmount = uint128(tokenAmounts[j]);
ICarbonPOL.Price memory price = ICarbonPOL.Price({ ethAmount: ethAmount, tokenAmount: tokenAmount });
carbonPOL.enableTrading(token1, price);
// get the correct test case for this price
POLTestCaseParser.TestCase memory currentCase;
for (uint t = 0; t < testCases.length; ++t) {
for (uint256 t = 0; t < testCases.length; ++t) {
if (
testCases[t].initialPrice.ethAmount == ethAmount &&
testCases[t].initialPrice.tokenAmount == tokenAmount
) {
currentCase = testCases[t];
}
}
for (uint k = 0; k < timestamps.length; ++k) {
for (uint256 k = 0; k < timestamps.length; ++k) {
// set timestamp
vm.warp(timestamps[k]);
// get token price at this timestamp
Expand Down
4 changes: 0 additions & 4 deletions test/forge/CarbonVortex.t.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity 0.8.19;

import { Test } from "forge-std/Test.sol";

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Address } from "@openzeppelin/contracts/utils/Address.sol";

import { TestFixture } from "./TestFixture.t.sol";
Expand All @@ -12,7 +9,6 @@ import { CarbonVortex } from "../../contracts/vortex/CarbonVortex.sol";
import { AccessDenied, InvalidAddress, InvalidFee } from "../../contracts/utility/Utils.sol";
import { PPM_RESOLUTION } from "../../contracts/utility/Constants.sol";

import { IVoucher } from "../../contracts/voucher/interfaces/IVoucher.sol";
import { ICarbonController } from "../../contracts/carbon/interfaces/ICarbonController.sol";
import { ICarbonVortex } from "../../contracts/vortex/interfaces/ICarbonVortex.sol";
import { IBancorNetwork } from "../../contracts/vortex/CarbonVortex.sol";
Expand Down
6 changes: 3 additions & 3 deletions test/forge/POLTestCaseParser.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ contract POLTestCaseParser is Test {
// initialize test cases array
testCases = new TestCase[](testCaseLength);

for (uint i = 0; i < testCaseLength; ++i) {
for (uint256 i = 0; i < testCaseLength; ++i) {
// get the correct testCase index to parse
string memory parseString = string.concat(initialParseString, Strings.toString(i));

Expand All @@ -97,7 +97,7 @@ contract POLTestCaseParser is Test {
PriceAtTimestamp[] memory pricesAtTimestamp = new PriceAtTimestamp[](tokenPriceLen);

// fill in the token price at timestamp
for (uint j = 0; j < tokenPriceLen; ++j) {
for (uint256 j = 0; j < tokenPriceLen; ++j) {
// Parse the token price field into a bytes array
string memory fullParseString = string.concat(parseString, "].tokenPriceAtTimestamps[");
fullParseString = string.concat(fullParseString, Strings.toString(j));
Expand All @@ -113,7 +113,7 @@ contract POLTestCaseParser is Test {
return testCases;
}

/// @dev convert a price at timestamp struct to uint
/// @dev convert a price at timestamp struct to uint256
function convertPriceAtTimestampToUint(
PriceAtTimestampString memory priceAtTimestampString
) private pure returns (PriceAtTimestamp memory priceAtTimestamp) {
Expand Down
6 changes: 1 addition & 5 deletions test/forge/Pairs.t.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity 0.8.19;

import { Test } from "forge-std/Test.sol";

import { Address } from "@openzeppelin/contracts/utils/Address.sol";

import { TestFixture } from "./TestFixture.t.sol";
import { CarbonVortex } from "../../contracts/vortex/CarbonVortex.sol";

import { Pair, Pairs } from "../../contracts/carbon/Pairs.sol";

import { InvalidAddress, InvalidFee, InvalidIndices } from "../../contracts/utility/Utils.sol";
import { OnlyProxyDelegate } from "../../contracts/utility/OnlyProxyDelegate.sol";
import { InvalidAddress } from "../../contracts/utility/Utils.sol";

import { TestPairs } from "../../contracts/helpers/TestPairs.sol";
import { CarbonController } from "../../contracts/carbon/CarbonController.sol";
Expand Down
3 changes: 0 additions & 3 deletions test/forge/Strategies.t.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity 0.8.19;

import { Test } from "forge-std/Test.sol";

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
import { ITransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
Expand Down
6 changes: 3 additions & 3 deletions test/forge/TestCaseParser.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ contract TestCaseParser is Test {
// initialize strategies array
strategies = new TestStrategy[](strategiesLength);

for (uint i = 0; i < strategiesLength; ++i) {
for (uint256 i = 0; i < strategiesLength; ++i) {
// get the correct strategy index to parse
string memory parseString = string.concat(initialParseString, Strings.toString(i));

Expand Down Expand Up @@ -274,7 +274,7 @@ contract TestCaseParser is Test {
// initialize trade actions array
tradeActions = new TradeAction[](tradeActionsLength);

for (uint i = 0; i < tradeActionsLength; ++i) {
for (uint256 i = 0; i < tradeActionsLength; ++i) {
// get the correct trade action index to parse
string memory parseString = string.concat(initialParseString, Strings.toString(i));

Expand All @@ -294,7 +294,7 @@ contract TestCaseParser is Test {
return tradeActions;
}

/// @dev convert an order struct to uint
/// @dev convert an order struct to uint256
function convertOrderStructToUint(OrderString memory orderString) private pure returns (Order memory order) {
return
Order({
Expand Down
5 changes: 1 addition & 4 deletions test/forge/Trading.t.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity 0.8.19;

import { Test } from "forge-std/Test.sol";

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { Address } from "@openzeppelin/contracts/utils/Address.sol";

import { TestFixture } from "./TestFixture.t.sol";
Expand All @@ -20,7 +17,7 @@ import { Strategies } from "../../contracts/carbon/Strategies.sol";
import { Pair } from "../../contracts/carbon/Pairs.sol";
import { TestERC20FeeOnTransfer } from "../../contracts/helpers/TestERC20FeeOnTransfer.sol";

import { Token, toIERC20, NATIVE_TOKEN } from "../../contracts/token/Token.sol";
import { Token, NATIVE_TOKEN } from "../../contracts/token/Token.sol";

contract TradingTest is TestFixture {
using Address for address payable;
Expand Down
4 changes: 0 additions & 4 deletions test/forge/Voucher.t.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
// SPDX-License-Identifier: SEE LICENSE IN LICENSE
pragma solidity 0.8.19;

import { Test } from "forge-std/Test.sol";

import { Address } from "@openzeppelin/contracts/utils/Address.sol";

import { TestFixture } from "./TestFixture.t.sol";

import { AccessDenied, InvalidAddress, InvalidIndices } from "../../contracts/utility/Utils.sol";

import { Token } from "../../contracts/token/Token.sol";

contract VoucherTest is TestFixture {
using Address for address payable;

Expand Down

0 comments on commit 8800feb

Please sign in to comment.