diff --git a/src/contracts/components/QWAaveV3.sol b/src/contracts/components/QWAaveV3.sol index c4ebba4..e8d03e0 100644 --- a/src/contracts/components/QWAaveV3.sol +++ b/src/contracts/components/QWAaveV3.sol @@ -41,7 +41,7 @@ contract QWAaveV3 is IQWComponent, QWComponentBase { function open(uint256 _amount) external override onlyQwManager returns (bool success, uint256 assetAmountReceived) { _checkInvestment(_amount); - token.approve(POOL, _amount); + IERC20(INVESTMENT_TOKEN).approve(POOL, _amount); IPool(POOL).supply(INVESTMENT_TOKEN, _amount, address(this), 0); assetAmountReceived = _checkAssetsAny(); @@ -61,7 +61,7 @@ contract QWAaveV3 is IQWComponent, QWComponentBase { function close(uint256 _amount) external override onlyQwManager returns (bool success, uint256 tokenAmountReceived) { _checkAssets(_amount); - IPool(POOL).withdraw(INVESTMENT_TOKEN, amountToWithdraw, QW_MANAGER); + IPool(POOL).withdraw(INVESTMENT_TOKEN, _amount, QW_MANAGER); tokenAmountReceived = _checkInvestmentAny(); diff --git a/src/contracts/components/QWComponentBase.sol b/src/contracts/components/QWComponentBase.sol index 3657608..ca3a67d 100644 --- a/src/contracts/components/QWComponentBase.sol +++ b/src/contracts/components/QWComponentBase.sol @@ -54,10 +54,12 @@ abstract contract QWComponentBase is IQWComponent { /** * @notice Checks whether we've received the proper amount of investment tokens. */ - function _checkInvestment(uint256 _expectedAmount) internal view { - if (IERC20(INVESTMENT_TOKEN).balanceOf(address(this)) != _expectedAmount) { + function _checkInvestment(uint256 _expectedAmount) internal view returns (uint256) { + uint256 balance = IERC20(INVESTMENT_TOKEN).balanceOf(address(this)); + if (balance != _expectedAmount) { revert IncorrectInvestmentTokensReceived(balance); } + return balance; } /** @@ -68,7 +70,7 @@ abstract contract QWComponentBase is IQWComponent { if (balance == 0) { revert IncorrectInvestmentTokensReceived(balance); } - return balance + return balance; } /** diff --git a/src/contracts/components/QWCompound.sol b/src/contracts/components/QWCompound.sol index e30f724..bef9e0a 100644 --- a/src/contracts/components/QWCompound.sol +++ b/src/contracts/components/QWCompound.sol @@ -43,7 +43,7 @@ contract QWCompound is IQWComponent, QWComponentBase { ) external override onlyQwManager returns (bool success, uint256 assetAmountReceived) { _checkInvestment(_amount); - token.approve(COMET, _amount); + IERC20(INVESTMENT_TOKEN).approve(COMET, _amount); // Perform the supply to Compound. IComet(COMET).supplyTo(address(this), INVESTMENT_TOKEN, _amount); @@ -67,7 +67,7 @@ contract QWCompound is IQWComponent, QWComponentBase { _checkAssets(_amount); // Perform the withdraw from Compound. - IComet(COMET).withdrawTo(address(this), INVESTMENT_TOKEN, amountToWithdraw); + IComet(COMET).withdrawTo(address(this), INVESTMENT_TOKEN, _amount); tokenAmountReceived = _checkInvestmentAny(); success = true; diff --git a/src/contracts/components/QWUniswapV3Stable.sol b/src/contracts/components/QWUniswapV3Stable.sol index 649e1d2..8435df1 100644 --- a/src/contracts/components/QWUniswapV3Stable.sol +++ b/src/contracts/components/QWUniswapV3Stable.sol @@ -81,9 +81,10 @@ contract QWUniswapV3Stable is IQWComponent, QWComponentBase, Ownable, IERC721Rec (liquidity, amount0, amount1) = increaseLiquidityCurrentRange(_amount); assetAmountReceived = amount0 + amount1; - success = true; // TODO: Send NFT to QWManager + + success = true; } /** @@ -101,8 +102,10 @@ contract QWUniswapV3Stable is IQWComponent, QWComponentBase, Ownable, IERC721Rec (uint256 amount0, uint256 amount1) = decreaseLiquidity(); tokenAmountReceived = amount0 + amount1; - success = true; + // TODO: Transfer NFT back to QWManager. + + success = true; } /** diff --git a/src/interfaces/IQWRegistry.sol b/src/interfaces/IQWRegistry.sol index a3a7856..d0d80dd 100644 --- a/src/interfaces/IQWRegistry.sol +++ b/src/interfaces/IQWRegistry.sol @@ -14,12 +14,12 @@ interface IQWRegistry { function registerComponent(address _component) external; /** - * @notice Checks if a child contract is whitelisted. - * @dev Returns true if the specified child contract is whitelisted, otherwise false. - * @param _child The address of the child contract to check. - * @return A boolean indicating whether the child contract is whitelisted. + * @notice Checks if a component contract is whitelisted. + * @dev Returns true if the specified component contract is whitelisted, otherwise false. + * @param _component The address of the component contract to check. + * @return boolean A boolean indicating whether the component contract is whitelisted. */ - function whitelist(address _child) external view returns (bool); + function whitelist(address _component) external view returns (bool); /** * @notice Gets the address of the Quant Wealth Manager contract. diff --git a/test/smock/MockQWManager.sol b/test/smock/MockQWManager.sol index 7de10b3..e19ff21 100644 --- a/test/smock/MockQWManager.sol +++ b/test/smock/MockQWManager.sol @@ -1,48 +1,41 @@ // SPDX-License-Identifier: APACHE pragma solidity ^0.8.0; -import { - IERC20, IQWComponent, IQWManager, IQWRegistry, Ownable, QWManager, QWRegistry -} from '../../src/contracts/QWManager.sol'; +import {IERC20, IQWComponent, IQWManager, IQWRegistry, Ownable, QWManager, QWRegistry} from '../../src/contracts/QWManager.sol'; import {Test} from 'forge-std/Test.sol'; contract MockQWManager is QWManager, Test { - constructor() QWManager() {} + constructor() QWManager() {} - function mock_call_execute( - address[] memory _targetQwChild, - bytes[] memory _callData, - address _tokenAddress, - uint256 _amount - ) public { - vm.mockCall( - address(this), - abi.encodeWithSignature( - 'execute(address[],bytes[],address,uint256)', _targetQwChild, _callData, _tokenAddress, _amount - ), - abi.encode() - ); - } + function mock_call_open(OpenBatch[] memory batches) public { + vm.mockCall( + address(this), + abi.encodeWithSignature('open((address,uint256)[])', batches), + abi.encode() + ); + } - function mock_call_close(address[] memory _targetQwChild, bytes[] memory _callData) public { - vm.mockCall( - address(this), abi.encodeWithSignature('close(address[],bytes[])', _targetQwChild, _callData), abi.encode() - ); - } + function mock_call_close(CloseBatch[] memory batches) public { + vm.mockCall( + address(this), + abi.encodeWithSignature('close((address,uint256)[])', batches), + abi.encode() + ); + } - function mock_call_withdraw(address user, address _tokenAddress, uint256 _amount) public { - vm.mockCall( - address(this), - abi.encodeWithSignature('withdraw(address,address,uint256)', user, _tokenAddress, _amount), - abi.encode() - ); - } + function mock_call_withdraw(address user, address _tokenAddress, uint256 _amount) public { + vm.mockCall( + address(this), + abi.encodeWithSignature('withdraw(address,address,uint256)', user, _tokenAddress, _amount), + abi.encode() + ); + } - function mock_call_receiveFunds(address user, address _tokenAddress, uint256 _amount) public { - vm.mockCall( - address(this), - abi.encodeWithSignature('receiveFunds(address,address,uint256)', user, _tokenAddress, _amount), - abi.encode() - ); - } + function mock_call_receiveFunds(address user, address _tokenAddress, uint256 _amount) public { + vm.mockCall( + address(this), + abi.encodeWithSignature('receiveFunds(address,address,uint256)', user, _tokenAddress, _amount), + abi.encode() + ); + } } diff --git a/test/smock/MockQWRegistry.sol b/test/smock/MockQWRegistry.sol index e9ca1ea..a2542e6 100644 --- a/test/smock/MockQWRegistry.sol +++ b/test/smock/MockQWRegistry.sol @@ -5,6 +5,8 @@ import {IQWComponent, IQWRegistry, Ownable, QWRegistry} from '../../src/contract import {Test} from 'forge-std/Test.sol'; contract MockQWRegistry is QWRegistry, Test { + constructor(address _qwManager) QWRegistry(_qwManager, msg.sender) {} + function set_whitelist(address _key0, bool _value) public { whitelist[_key0] = _value; } @@ -13,9 +15,7 @@ contract MockQWRegistry is QWRegistry, Test { vm.mockCall(address(this), abi.encodeWithSignature('whitelist(address)', _key0), abi.encode(_value)); } - constructor(address _qwManager) QWRegistry(_qwManager, msg.sender) {} - - function mock_call_registerChild(address _child) public { - vm.mockCall(address(this), abi.encodeWithSignature('registerChild(address)', _child), abi.encode()); + function mock_call_registerComponent(address _child) public { + vm.mockCall(address(this), abi.encodeWithSignature('registerComponent(address)', _child), abi.encode()); } } diff --git a/test/smock/components/MockQWAaveV2.sol b/test/smock/components/MockQWAaveV2.sol index f5f3dc5..6e991a1 100644 --- a/test/smock/components/MockQWAaveV2.sol +++ b/test/smock/components/MockQWAaveV2.sol @@ -5,17 +5,22 @@ import {IERC20, ILendingPool, IQWComponent, QWAaveV2} from '../../../src/contrac import {Test} from 'forge-std/Test.sol'; contract MockQWAaveV2 is QWAaveV2, Test { - constructor(address _qwManager, address _lendingPool) QWAaveV2(_qwManager, _lendingPool) {} + constructor( + address _qwManager, + address _investmentToken, + address _assetToken, + address _pool + ) QWAaveV2(_qwManager, _investmentToken, _assetToken, _pool) {} - function mock_call_create(bytes memory _callData, address _tokenAddress, uint256 _amount, bool success) public { + function mock_call_open(uint256 _amount, bool success) public { vm.mockCall( address(this), - abi.encodeWithSignature('create(bytes,address,uint256)', _callData, _tokenAddress, _amount), + abi.encodeWithSignature('open(uint256)', _amount), abi.encode(success) ); } - function mock_call_close(bytes memory _callData, bool success) public { - vm.mockCall(address(this), abi.encodeWithSignature('close(bytes)', _callData), abi.encode(success)); + function mock_call_close(uint256 _amount, bool success) public { + vm.mockCall(address(this), abi.encodeWithSignature('close(uint256)', _amount), abi.encode(success)); } } diff --git a/test/smock/components/MockQWAaveV3.sol b/test/smock/components/MockQWAaveV3.sol index fb238ee..f4b4960 100644 --- a/test/smock/components/MockQWAaveV3.sol +++ b/test/smock/components/MockQWAaveV3.sol @@ -5,17 +5,22 @@ import {IERC20, IPool, IQWComponent, QWAaveV3} from '../../../src/contracts/comp import {Test} from 'forge-std/Test.sol'; contract MockQWAaveV3 is QWAaveV3, Test { - constructor(address _qwManager, address _pool) QWAaveV3(_qwManager, _pool) {} + constructor( + address _qwManager, + address _investmentToken, + address _assetToken, + address _pool + ) QWAaveV3(_qwManager, _investmentToken, _assetToken, _pool) {} - function mock_call_create(bytes memory _callData, address _tokenAddress, uint256 _amount, bool success) public { + function mock_call_open(uint256 _amount, bool success) public { vm.mockCall( address(this), - abi.encodeWithSignature('create(bytes,address,uint256)', _callData, _tokenAddress, _amount), + abi.encodeWithSignature('open(uint256)', _amount), abi.encode(success) ); } - function mock_call_close(bytes memory _callData, bool success) public { - vm.mockCall(address(this), abi.encodeWithSignature('close(bytes)', _callData), abi.encode(success)); + function mock_call_close(uint256 _amount, bool success) public { + vm.mockCall(address(this), abi.encodeWithSignature('close(uint256)', _amount), abi.encode(success)); } } diff --git a/test/smock/components/MockQWCompound.sol b/test/smock/components/MockQWCompound.sol index bca04eb..9676c73 100644 --- a/test/smock/components/MockQWCompound.sol +++ b/test/smock/components/MockQWCompound.sol @@ -12,15 +12,15 @@ contract MockQWCompound is QWCompound, Test { address _comet ) QWCompound(_qwManager, _investmentToken, _assetToken, _comet) {} - function mock_call_create(bytes memory _callData, address _tokenAddress, uint256 _amount, bool success) public { + function mock_call_open(uint256 _amount, bool success) public { vm.mockCall( address(this), - abi.encodeWithSignature('create(bytes,address,uint256)', _callData, _tokenAddress, _amount), + abi.encodeWithSignature('open(uint256)', _amount), abi.encode(success) ); } - function mock_call_close(bytes memory _callData, bool success) public { - vm.mockCall(address(this), abi.encodeWithSignature('close(bytes)', _callData), abi.encode(success)); + function mock_call_close(uint256 _amount, bool success) public { + vm.mockCall(address(this), abi.encodeWithSignature('close(uint256)', _amount), abi.encode(success)); } } diff --git a/test/unit/QWManager.t.sol b/test/unit/QWManager.t.sol index c20bf88..1ef7733 100644 --- a/test/unit/QWManager.t.sol +++ b/test/unit/QWManager.t.sol @@ -12,22 +12,24 @@ contract UnitQWManagerTest is Test, SmockHelper { MockQWManager public mockQWManager; MockQWAaveV3 public mockQWAaveV3; MockQWRegistry public mockQWRegistry; - address public tokenAddress; + address public investmentToken; + address public assetToken; uint256 public amount; function setUp() public { + investmentToken = address(0x123); + assetToken = address(0x456); + amount = 100; + mockQWRegistry = new MockQWRegistry(); mockQWManager = MockQWManager(deployMock('QWManager', type(MockQWManager).creationCode, abi.encode(address(mockQWRegistry)))); - mockQWAaveV3 = new MockQWAaveV3(address(mockQWManager), address(0x456)); - - tokenAddress = address(0x123); - amount = 100; + mockQWAaveV3 = new MockQWAaveV3(address(mockQWManager), investmentToken, assetToken, address(0x789)); // Whitelist the mock protocol - mockQWRegistry.addToWhitelist(address(mockQWAaveV3)); + mockQWRegistry.whitelist(address(mockQWAaveV3)); } - function test_Open_Success() public { + function test_open_success() public { IQWManager.OpenBatch[] memory batches = new IQWManager.OpenBatch[](1); batches[0] = IQWManager.OpenBatch({ protocol: address(mockQWAaveV3), @@ -41,7 +43,7 @@ contract UnitQWManagerTest is Test, SmockHelper { mockQWManager.open(batches); } - function test_Open_Fail_NotWhitelisted() public { + function test_open_fail_NotWhitelisted() public { IQWManager.OpenBatch[] memory batches = new IQWManager.OpenBatch[](1); batches[0] = IQWManager.OpenBatch({ protocol: address(0x111), // not whitelisted @@ -49,11 +51,11 @@ contract UnitQWManagerTest is Test, SmockHelper { }); // Expect revert due to contract not whitelisted - vm.expectRevert("ContractNotWhitelisted"); + vm.expectRevert('ContractNotWhitelisted'); mockQWManager.open(batches); } - function test_Open_Fail_CallFailed() public { + function test_open_fail_CallFailed() public { IQWManager.OpenBatch[] memory batches = new IQWManager.OpenBatch[](1); batches[0] = IQWManager.OpenBatch({ protocol: address(mockQWAaveV3), @@ -64,11 +66,11 @@ contract UnitQWManagerTest is Test, SmockHelper { mockQWManager.mock_call_open_fails(batches); // Expect revert due to call failed - vm.expectRevert("CallFailed"); + vm.expectRevert('CallFailed'); mockQWManager.open(batches); } - function test_Close_Success() public { + function test_close_success() public { IQWManager.CloseBatch[] memory batches = new IQWManager.CloseBatch[](1); batches[0] = IQWManager.CloseBatch({ protocol: address(mockQWAaveV3), @@ -82,7 +84,7 @@ contract UnitQWManagerTest is Test, SmockHelper { mockQWManager.close(batches); } - function test_Close_Fail_CallFailed() public { + function test_close_fail_CallFailed() public { IQWManager.CloseBatch[] memory batches = new IQWManager.CloseBatch[](1); batches[0] = IQWManager.CloseBatch({ protocol: address(mockQWAaveV3), @@ -93,53 +95,53 @@ contract UnitQWManagerTest is Test, SmockHelper { mockQWManager.mock_call_close_fails(batches); // Expect revert due to call failed - vm.expectRevert("CallFailed"); + vm.expectRevert('CallFailed'); mockQWManager.close(batches); } - function test_Withdraw_Success() public { + function test_withdraw_success() public { address user = address(0x789); uint256 withdrawAmount = 50; // Mock a successful withdrawal - mockQWManager.mock_call_withdraw(user, tokenAddress, withdrawAmount); + mockQWManager.mock_call_withdraw(user, investmentToken, withdrawAmount); // Call the withdraw function - mockQWManager.withdraw(user, tokenAddress, withdrawAmount); + mockQWManager.withdraw(user, investmentToken, withdrawAmount); } - function test_Withdraw_Fail() public { + function test_withdraw_fail_TransferFailed() public { address user = address(0x789); uint256 withdrawAmount = 50; // Mock a failed withdrawal - mockQWManager.mock_call_withdraw_fails(user, tokenAddress, withdrawAmount); + mockQWManager.mock_call_withdraw_fails(user, investmentToken, withdrawAmount); // Expect revert due to transfer failed - vm.expectRevert("TransferFailed"); - mockQWManager.withdraw(user, tokenAddress, withdrawAmount); + vm.expectRevert('TransferFailed'); + mockQWManager.withdraw(user, investmentToken, withdrawAmount); } - function test_ReceiveFunds_Success() public { + function test_receiveFunds_success() public { address user = address(0x789); uint256 receiveAmount = 50; // Mock a successful receive funds - mockQWManager.mock_call_receiveFunds(user, tokenAddress, receiveAmount); + mockQWManager.mock_call_receiveFunds(user, investmentToken, receiveAmount); // Call the receiveFunds function - mockQWManager.receiveFunds(user, tokenAddress, receiveAmount); + mockQWManager.receiveFunds(user, investmentToken, receiveAmount); } - function test_ReceiveFunds_Fail() public { + function test_receiveFunds_fail_TransferFromFailed() public { address user = address(0x789); uint256 receiveAmount = 50; // Mock a failed receive funds - mockQWManager.mock_call_receiveFunds_fails(user, tokenAddress, receiveAmount); + mockQWManager.mock_call_receiveFunds_fails(user, investmentToken, receiveAmount); // Expect revert due to transferFrom failed - vm.expectRevert("TransferFromFailed"); - mockQWManager.receiveFunds(user, tokenAddress, receiveAmount); + vm.expectRevert('TransferFromFailed'); + mockQWManager.receiveFunds(user, investmentToken, receiveAmount); } } diff --git a/test/unit/QWRegistry.t.sol b/test/unit/QWRegistry.t.sol index 2252e2f..c8e4cf3 100644 --- a/test/unit/QWRegistry.t.sol +++ b/test/unit/QWRegistry.t.sol @@ -14,11 +14,16 @@ contract UnitQWRegistryTest is Test, SmockHelper { MockQWRegistry public mockQWRegistry; MockQWManager public mockQWManager; MockQWAaveV3 public mockQWAaveV3; + address public investmentToken; + address public assetToken; function setUp() public { + investmentToken = address(0x123); + assetToken = address(0x456); + mockQWManager = MockQWManager(deployMock('QWManager', type(MockQWManager).creationCode, abi.encode())); mockQWAaveV3 = MockQWAaveV3( - deployMock('QWAaveV3', type(MockQWAaveV3).creationCode, abi.encode(address(mockQWManager), address(0x456))) + deployMock('QWAaveV3', type(MockQWAaveV3).creationCode, abi.encode(address(mockQWManager), investmentToken, assetToken, address(0x789))) ); address validQWManager = address(mockQWManager); @@ -26,7 +31,7 @@ contract UnitQWRegistryTest is Test, SmockHelper { MockQWRegistry(deployMock('QWRegistry', type(MockQWRegistry).creationCode, abi.encode(validQWManager))); } - function testRegisterChild() public { + function test_registerComponent() public { address validChildContract = address(mockQWAaveV3); // Record logs to capture emitted events vm.recordLogs(); diff --git a/test/unit/components/QWAaveV2.t.sol b/test/unit/components/QWAaveV2.t.sol index 42ef9e6..7f6110d 100644 --- a/test/unit/components/QWAaveV2.t.sol +++ b/test/unit/components/QWAaveV2.t.sol @@ -15,28 +15,32 @@ contract UnitQWAaveV3Test is Test { mockQWAaveV2 = new MockQWAaveV2(qwManager, lendingPool); } - function test_Create_Success() public { + function test_open_success() public { bytes memory callData = ''; address tokenAddress = address(0x789); uint256 amount = 100; // Mock a successful call to IPool.supply - mockQWAaveV2.mock_call_create(callData, tokenAddress, amount, true); + mockQWAaveV2.mock_call_open(amount, true); // Call the create function - bool success = mockQWAaveV2.create(callData, tokenAddress, amount); + (bool success, uint256 assetAmountReceived) = mockQWAaveV2.open(amount); + + // TODO: check asset amount received, ensure QWManager received assets assertTrue(success, 'Create function should return true on success'); } - function test_Close_Success() public { - bytes memory callData = abi.encode(address(0x123), uint256(100)); + function test_close_success() public { + uint256 amount = 100; // Mock a successful call to IPool.withdraw - mockQWAaveV2.mock_call_close(callData, true); + mockQWAaveV2.mock_call_close(amount, true); // Call the close function - bool success = mockQWAaveV2.close(callData); + (bool success, uint256 tokenAmountReceived) = mockQWAaveV2.close(amount); + + // TODO: Check token amount received, ensure QWManager received it assertTrue(success, 'Close function should return true on success'); } diff --git a/test/unit/components/QWAaveV3.t.sol b/test/unit/components/QWAaveV3.t.sol index b8a154d..3ec73f3 100644 --- a/test/unit/components/QWAaveV3.t.sol +++ b/test/unit/components/QWAaveV3.t.sol @@ -16,28 +16,31 @@ contract UnitQWAaveV3Test is Test { mockQWAaveV3 = new MockQWAaveV3(qwManager, pool); } - function test_Create_Success() public { - bytes memory callData = ''; + function test_open_success() public { address tokenAddress = address(0x789); uint256 amount = 100; // Mock a successful call to IPool.supply - mockQWAaveV3.mock_call_create(callData, tokenAddress, amount, true); + mockQWAaveV3.mock_call_open(amount, true); - // Call the create function - bool success = mockQWAaveV3.create(callData, tokenAddress, amount); + // Call the open function + (bool success, uint256 assetAmountReceived) = mockQWAaveV3.open(amount); + + // TODO: check asset amount received, ensure QWManager received assets assertTrue(success, 'Create function should return true on success'); } - function test_Close_Success() public { - bytes memory callData = abi.encode(address(0x123), uint256(100)); + function test_close_success() public { + uint256 amount = 100; // Mock a successful call to IPool.withdraw - mockQWAaveV3.mock_call_close(callData, true); + mockQWAaveV3.mock_call_close(amount, true); // Call the close function - bool success = mockQWAaveV3.close(callData); + (bool success, uint256 tokenAmountReceived) = mockQWAaveV3.close(amount); + + // TODO: Check token amount received, ensure QWManager received it assertTrue(success, 'Close function should return true on success'); } diff --git a/test/unit/components/QWCompound.t.sol b/test/unit/components/QWCompound.t.sol index 5af138d..8fff276 100644 --- a/test/unit/components/QWCompound.t.sol +++ b/test/unit/components/QWCompound.t.sol @@ -9,37 +9,44 @@ contract UnitQWAaveV3Test is Test { MockQWCompound public mockQWCompund; address public qwManager; address public comet; + address public investmentToken; + address public assetToken; function setUp() public { qwManager = address(0x123); investmentToken = address(0x789); - assetToken = + assetToken = address(0x777); // TODO: Should the asset token be the comet? comet = address(0x456); - mockQWCompund = new MockQWCompound(qwManager, comet); + mockQWCompund = new MockQWCompound(qwManager, investmentToken, assetToken, comet); } - function test_Open_Success() public { - bytes memory callData = ''; - address tokenAddress = address(0x789); + function test_open_success() public { uint256 amount = 100; // Mock a successful call to IPool.supply - mockQWCompund.mock_call_create(callData, tokenAddress, amount, true); + mockQWCompund.mock_call_open(amount, true); // Call the create function - bool success = mockQWCompund.open(callData, tokenAddress, amount); + (bool success, uint256 assetAmountReceived) = mockQWCompund.open(amount); + + // TODO: check asset amount received, ensure QWManager received assets assertTrue(success, 'Create function should return true on success'); } - function test_Close_Success() public { - bytes memory callData = abi.encode(address(0x123), uint256(100)); + function test_close_success() public { + // TODO: Do we need to mint/supply this amount of asset tokens to QWManager first? + uint256 amount = 100; + + // TODO: Transfer asset tokens to QWCompound. // Mock a successful call to IPool.withdraw - mockQWCompund.mock_call_close(callData, true); + mockQWCompund.mock_call_close(amount, true); // Call the close function - bool success = mockQWCompund.close(callData); + (bool success, uint256 tokenAmountReceived) = mockQWCompund.close(amount); + + // TODO: check asset amount received, ensure QWManager received assets assertTrue(success, 'Close function should return true on success'); }