From a5a1ca237a2eea8f3c689a59a2dbb35067e2ffaa Mon Sep 17 00:00:00 2001 From: Sahil-Gujrati Date: Sat, 23 Mar 2024 13:40:43 +0530 Subject: [PATCH] chore: Better format solidity files --- script/DeployThunderSwapPoolFactory.sol | 7 +- test/unit/deployPool/DeployPool.t.sol | 18 ++-- test/unit/flashSwapTests/FlashSwap.t.sol | 102 +++++++++++------------ test/utils/helpers/PoolFactoryHelper.sol | 2 +- 4 files changed, 67 insertions(+), 62 deletions(-) diff --git a/script/DeployThunderSwapPoolFactory.sol b/script/DeployThunderSwapPoolFactory.sol index 252e3ec..b892113 100644 --- a/script/DeployThunderSwapPoolFactory.sol +++ b/script/DeployThunderSwapPoolFactory.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.20; -import {Script} from "forge-std/Script.sol"; -import {ThunderSwapPoolFactory} from "@src/ThunderSwapPoolFactory.sol"; +import { ThunderSwapPoolFactory } from "@src/ThunderSwapPoolFactory.sol"; +import { Script } from "forge-std/Script.sol"; contract DeployThunderSwapPoolFactory is Script { function run() external { @@ -10,5 +10,4 @@ contract DeployThunderSwapPoolFactory is Script { ThunderSwapPoolFactory thunderSwapPoolFactory = new ThunderSwapPoolFactory(); vm.stopBroadcast(); } - -} \ No newline at end of file +} diff --git a/test/unit/deployPool/DeployPool.t.sol b/test/unit/deployPool/DeployPool.t.sol index ef13cba..864ea85 100644 --- a/test/unit/deployPool/DeployPool.t.sol +++ b/test/unit/deployPool/DeployPool.t.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.20; -import {PoolFactoryHelper} from "../../utils/helpers/PoolFactoryHelper.sol"; -import {UniversalHelper} from "../../utils/helpers/UniversalHelper.sol"; -import {Token} from "../../utils/mocks/Token.sol"; +import { PoolFactoryHelper } from "../../utils/helpers/PoolFactoryHelper.sol"; +import { UniversalHelper } from "../../utils/helpers/UniversalHelper.sol"; +import { Token } from "../../utils/mocks/Token.sol"; contract DeployPool is UniversalHelper, PoolFactoryHelper { function testDeployingThunderSwapPoolRevertsIfTokenNotSupported() public { @@ -22,8 +22,14 @@ contract DeployPool is UniversalHelper, PoolFactoryHelper { thunderSwapPoolFactory.deployThunderSwapPool(tokenAddress, tokenAddress); } - function testDeployingThunderSwapPoolRevertsIfPoolAlreadyExists() public distributeTokensToUsers(1e18, 2e18) addInitialLiquidity(1e18, 2e18) { - vm.expectRevert(abi.encodeWithSelector(PoolAlreadyExists.selector, address(thunderSwapPool))); + function testDeployingThunderSwapPoolRevertsIfPoolAlreadyExists() + public + distributeTokensToUsers(1e18, 2e18) + addInitialLiquidity(1e18, 2e18) + { + vm.expectRevert( + abi.encodeWithSelector(PoolAlreadyExists.selector, address(thunderSwapPool)) + ); thunderSwapPoolFactory.deployThunderSwapPool(address(tokenB), address(tokenA)); } @@ -40,4 +46,4 @@ contract DeployPool is UniversalHelper, PoolFactoryHelper { thunderSwapPoolFactory.deployThunderSwapPool(address(tokenC), address(tokenD)); vm.stopPrank(); } -} \ No newline at end of file +} diff --git a/test/unit/flashSwapTests/FlashSwap.t.sol b/test/unit/flashSwapTests/FlashSwap.t.sol index eb1cae9..63a3f13 100644 --- a/test/unit/flashSwapTests/FlashSwap.t.sol +++ b/test/unit/flashSwapTests/FlashSwap.t.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.20; -import {FlashSwapHelper} from "../../utils/helpers/FlashSwapHelper.sol"; import { ThunderSwapper } from "../../utils/ThunderSwapper.sol"; +import { FlashSwapHelper } from "../../utils/helpers/FlashSwapHelper.sol"; import { UniversalHelper } from "../../utils/helpers/UniversalHelper.sol"; contract FlashSwap is UniversalHelper, FlashSwapHelper { @@ -84,7 +84,17 @@ contract FlashSwap is UniversalHelper, FlashSwapHelper { vm.startPrank(user1); tokenA.transfer(address(thunderSwapper), tokenA.balanceOf(user1)); vm.expectEmit(true, true, true, false); - emit FlashSwapped(user1, tokenA, tokenB,inputAmount, thunderSwapPool.getOutputBasedOnInput(inputAmount, tokenA.balanceOf(address(thunderSwapPool)), tokenB.balanceOf(address(thunderSwapPool)))); + emit FlashSwapped( + user1, + tokenA, + tokenB, + inputAmount, + thunderSwapPool.getOutputBasedOnInput( + inputAmount, + tokenA.balanceOf(address(thunderSwapPool)), + tokenB.balanceOf(address(thunderSwapPool)) + ) + ); thunderSwapPool.flashSwapExactInput( tokenA, inputAmount, @@ -96,35 +106,19 @@ contract FlashSwap is UniversalHelper, FlashSwapHelper { vm.stopPrank(); } - function flashSwappingRevertsIfInputOrOutputAmountsAreZero() - public - deployThunderSwapper - { + function flashSwappingRevertsIfInputOrOutputAmountsAreZero() public deployThunderSwapper { vm.expectRevert(InputValueZeroNotAllowed.selector); thunderSwapPool.flashSwapExactInput( - tokenA, - 0, - 0, - address(thunderSwapper), - true, - uint256(block.timestamp) + tokenA, 0, 0, address(thunderSwapper), true, uint256(block.timestamp) ); vm.expectRevert(InputValueZeroNotAllowed.selector); thunderSwapPool.flashSwapExactOutput( - tokenA, - 0, - 0, - address(thunderSwapper), - true, - uint256(block.timestamp) + tokenA, 0, 0, address(thunderSwapper), true, uint256(block.timestamp) ); } - function flashSwappingRevertsIfDeadlinePassed() - public - deployThunderSwapper - { + function flashSwappingRevertsIfDeadlinePassed() public deployThunderSwapper { uint256 dummyValue1 = 1e18; uint256 dummyValue2 = 2e18; @@ -132,22 +126,12 @@ contract FlashSwap is UniversalHelper, FlashSwapHelper { uint256 deadline = uint256(block.timestamp - 1); vm.expectRevert(abi.encodeWithSelector(DeadlinePassed.selector, deadline)); thunderSwapPool.flashSwapExactInput( - tokenA, - dummyValue1, - dummyValue2, - address(thunderSwapper), - true, - deadline + tokenA, dummyValue1, dummyValue2, address(thunderSwapper), true, deadline ); vm.expectRevert(abi.encodeWithSelector(DeadlinePassed.selector, deadline)); thunderSwapPool.flashSwapExactOutput( - tokenA, - dummyValue1, - dummyValue2, - address(thunderSwapper), - true, - deadline + tokenA, dummyValue1, dummyValue2, address(thunderSwapper), true, deadline ); } @@ -157,33 +141,38 @@ contract FlashSwap is UniversalHelper, FlashSwapHelper { vm.expectRevert(ReceiverZeroAddress.selector); thunderSwapPool.flashSwapExactInput( - tokenA, - dummyValue1, - dummyValue2, - address(0), - true, - uint256(block.timestamp) + tokenA, dummyValue1, dummyValue2, address(0), true, uint256(block.timestamp) ); vm.expectRevert(ReceiverZeroAddress.selector); thunderSwapPool.flashSwapExactOutput( - tokenA, - dummyValue1, - dummyValue2, - address(0), - true, - uint256(block.timestamp) + tokenA, dummyValue1, dummyValue2, address(0), true, uint256(block.timestamp) ); } - function flashSwappingExactInputRevertsIfOutputAmountisLessThanMinimumOutputAmountToReceive() public distributeTokensToUsers(1e18, 2e18) addInitialLiquidity(1e18, 2e18) { + function flashSwappingExactInputRevertsIfOutputAmountisLessThanMinimumOutputAmountToReceive() + public + distributeTokensToUsers(1e18, 2e18) + addInitialLiquidity(1e18, 2e18) + { uint256 inputAmount = 1e18; uint256 minimumOutputTokensToReceive = 5e18; - uint256 calculatedOutputAmount = thunderSwapPool.getOutputBasedOnInput(inputAmount, tokenA.balanceOf(address(thunderSwapPool)), tokenB.balanceOf(address(thunderSwapPool))); + uint256 calculatedOutputAmount = thunderSwapPool.getOutputBasedOnInput( + inputAmount, + tokenA.balanceOf(address(thunderSwapPool)), + tokenB.balanceOf(address(thunderSwapPool)) + ); vm.startPrank(user1); tokenA.transfer(address(thunderSwapper), tokenA.balanceOf(user1)); - vm.expectRevert(abi.encodeWithSelector(PoolTokenToReceiveLessThanMinimumPoolTokenToReceive.selector, tokenB, calculatedOutputAmount, minimumOutputTokensToReceive)); + vm.expectRevert( + abi.encodeWithSelector( + PoolTokenToReceiveLessThanMinimumPoolTokenToReceive.selector, + tokenB, + calculatedOutputAmount, + minimumOutputTokensToReceive + ) + ); thunderSwapPool.flashSwapExactInput( tokenA, inputAmount, @@ -203,11 +192,22 @@ contract FlashSwap is UniversalHelper, FlashSwapHelper { { uint256 outputAmount = 5e17; uint256 maximumInputTokensToSend = 1e18; - uint256 calculatedInputAmount = thunderSwapPool.getInputBasedOnOuput(outputAmount, tokenB.balanceOf(address(thunderSwapPool)), tokenA.balanceOf(address(thunderSwapPool))); + uint256 calculatedInputAmount = thunderSwapPool.getInputBasedOnOuput( + outputAmount, + tokenB.balanceOf(address(thunderSwapPool)), + tokenA.balanceOf(address(thunderSwapPool)) + ); vm.startPrank(user1); tokenB.transfer(address(thunderSwapper), tokenB.balanceOf(user1)); - vm.expectRevert(abi.encodeWithSelector(PoolTokenToSendMoreThanMaximumPoolTokenToSend.selector, tokenB, calculatedInputAmount, maximumInputTokensToSend)); + vm.expectRevert( + abi.encodeWithSelector( + PoolTokenToSendMoreThanMaximumPoolTokenToSend.selector, + tokenB, + calculatedInputAmount, + maximumInputTokensToSend + ) + ); thunderSwapPool.flashSwapExactOutput( tokenA, outputAmount, diff --git a/test/utils/helpers/PoolFactoryHelper.sol b/test/utils/helpers/PoolFactoryHelper.sol index 00ca7dd..7f1d4fc 100644 --- a/test/utils/helpers/PoolFactoryHelper.sol +++ b/test/utils/helpers/PoolFactoryHelper.sol @@ -8,4 +8,4 @@ contract PoolFactoryHelper { error PoolAlreadyExists(address pool); error PoolCannotHaveTwoTokensOfTheSameType(); error TokenNotSupported(address tokenAddress); -} \ No newline at end of file +}