From a3fcaff5377c427f8ae0941fa77357aab9e95a5a Mon Sep 17 00:00:00 2001 From: kartojal Date: Fri, 4 Mar 2022 12:25:38 +0100 Subject: [PATCH 1/2] feat: add owner constructor parameters to contracts that inherit Ownable. --- .../paraswap/ParaSwapLiquiditySwapAdapter.sol | 10 ++++--- .../paraswap/ParaSwapRepayAdapter.sol | 10 ++++--- contracts/misc/WETHGateway.sol | 4 ++- package.json | 2 +- test/__setup.spec.ts | 2 +- .../paraswapAdapters.liquiditySwap.spec.ts | 25 +++++++++++------ test/paraswap/paraswapAdapters.repay.spec.ts | 28 +++++++++++++------ .../rewards/claim-all-rewards-to-self.spec.ts | 6 ++-- 8 files changed, 55 insertions(+), 32 deletions(-) diff --git a/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol b/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol index 151058a3..b4aad577 100644 --- a/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol +++ b/contracts/adapters/paraswap/ParaSwapLiquiditySwapAdapter.sol @@ -18,10 +18,12 @@ import {ReentrancyGuard} from '../../dependencies/openzeppelin/ReentrancyGuard.s contract ParaSwapLiquiditySwapAdapter is BaseParaSwapSellAdapter, ReentrancyGuard { using SafeMath for uint256; - constructor(IPoolAddressesProvider addressesProvider, IParaSwapAugustusRegistry augustusRegistry) - BaseParaSwapSellAdapter(addressesProvider, augustusRegistry) - { - // This is only required to initialize BaseParaSwapSellAdapter + constructor( + IPoolAddressesProvider addressesProvider, + IParaSwapAugustusRegistry augustusRegistry, + address owner + ) BaseParaSwapSellAdapter(addressesProvider, augustusRegistry) { + transferOwnership(owner); } /** diff --git a/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol b/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol index 02687182..e12c6f7b 100644 --- a/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol +++ b/contracts/adapters/paraswap/ParaSwapRepayAdapter.sol @@ -28,10 +28,12 @@ contract ParaSwapRepayAdapter is BaseParaSwapBuyAdapter, ReentrancyGuard { bool useEthPath; } - constructor(IPoolAddressesProvider addressesProvider, IParaSwapAugustusRegistry augustusRegistry) - BaseParaSwapBuyAdapter(addressesProvider, augustusRegistry) - { - // This is only required to initialize BaseParaSwapBuyAdapter + constructor( + IPoolAddressesProvider addressesProvider, + IParaSwapAugustusRegistry augustusRegistry, + address owner + ) BaseParaSwapBuyAdapter(addressesProvider, augustusRegistry) { + transferOwnership(owner); } /** diff --git a/contracts/misc/WETHGateway.sol b/contracts/misc/WETHGateway.sol index 087e4c1d..f56a994a 100644 --- a/contracts/misc/WETHGateway.sol +++ b/contracts/misc/WETHGateway.sol @@ -21,9 +21,11 @@ contract WETHGateway is IWETHGateway, Ownable { /** * @dev Sets the WETH address and the PoolAddressesProvider address. Infinite approves pool. * @param weth Address of the Wrapped Ether contract + * @param owner Address of the owner of this contract **/ - constructor(address weth) { + constructor(address weth, address owner) { WETH = IWETH(weth); + transferOwnership(owner); } function authorizePool(address pool) external onlyOwner { diff --git a/package.json b/package.json index d9c2da90..3bbe8014 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aave/periphery-v3", - "version": "1.13.0", + "version": "1.13.1-beta.1", "description": "Aave Protocol V3 periphery smart contracts", "files": [ "contracts", diff --git a/test/__setup.spec.ts b/test/__setup.spec.ts index b2c38250..bc587571 100644 --- a/test/__setup.spec.ts +++ b/test/__setup.spec.ts @@ -3,7 +3,7 @@ import { initializeMakeSuite } from './helpers/make-suite'; before(async () => { if (process.env.EMPTY_RUN === 'true') { - console.log('Skipping due empty test run.') + console.log('Skipping due empty test run.'); return; } await hre.deployments.fixture(['market']); diff --git a/test/paraswap/paraswapAdapters.liquiditySwap.spec.ts b/test/paraswap/paraswapAdapters.liquiditySwap.spec.ts index 3d49c973..97cd33f4 100644 --- a/test/paraswap/paraswapAdapters.liquiditySwap.spec.ts +++ b/test/paraswap/paraswapAdapters.liquiditySwap.spec.ts @@ -35,7 +35,7 @@ makeSuite('ParaSwap adapters', (testEnv: TestEnv) => { let evmSnapshotId: string; before(async () => { - const { addressesProvider } = testEnv; + const { addressesProvider, deployer } = testEnv; mockAugustus = await new MockParaSwapAugustus__factory(await getFirstSigner()).deploy(); mockAugustusRegistry = await new MockParaSwapAugustusRegistry__factory( @@ -43,7 +43,8 @@ makeSuite('ParaSwap adapters', (testEnv: TestEnv) => { ).deploy(mockAugustus.address); paraswapLiquiditySwapAdapter = await deployParaSwapLiquiditySwapAdapter( addressesProvider.address, - mockAugustusRegistry.address + mockAugustusRegistry.address, + deployer.address ); }); @@ -58,28 +59,32 @@ makeSuite('ParaSwap adapters', (testEnv: TestEnv) => { describe('ParaSwapLiquiditySwapAdapter', () => { describe('constructor', () => { it('should deploy with correct parameters', async () => { - const { addressesProvider } = testEnv; + const { addressesProvider, deployer } = testEnv; await deployParaSwapLiquiditySwapAdapter( addressesProvider.address, - mockAugustusRegistry.address + mockAugustusRegistry.address, + deployer.address ); }); it('should revert if not valid addresses provider', async () => { + const { deployer } = testEnv; await expect( deployParaSwapLiquiditySwapAdapter( mockAugustus.address, // any invalid contract can be used here - mockAugustusRegistry.address + mockAugustusRegistry.address, + deployer.address ) ).to.be.reverted; }); it('should revert if not valid augustus registry', async () => { - const { addressesProvider } = testEnv; + const { addressesProvider, deployer } = testEnv; await expect( deployParaSwapLiquiditySwapAdapter( addressesProvider.address, - mockAugustus.address // any invalid contract can be used here + mockAugustus.address, // any invalid contract can be used here + deployer.address ) ).to.be.reverted; }); @@ -2677,10 +2682,12 @@ makeSuite('ParaSwap adapters', (testEnv: TestEnv) => { async function deployParaSwapLiquiditySwapAdapter( poolAddressesProvider: tEthereumAddress, - augustusRegistry: tEthereumAddress + augustusRegistry: tEthereumAddress, + owner: tEthereumAddress ) { return await new ParaSwapLiquiditySwapAdapter__factory(await getFirstSigner()).deploy( poolAddressesProvider, - augustusRegistry + augustusRegistry, + owner ); } diff --git a/test/paraswap/paraswapAdapters.repay.spec.ts b/test/paraswap/paraswapAdapters.repay.spec.ts index 80c9c28d..8b8d6907 100644 --- a/test/paraswap/paraswapAdapters.repay.spec.ts +++ b/test/paraswap/paraswapAdapters.repay.spec.ts @@ -37,7 +37,7 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => { let evmSnapshotId: string; before(async () => { - const { addressesProvider } = testEnv; + const { addressesProvider, deployer } = testEnv; mockAugustus = await new MockParaSwapAugustus__factory(await getFirstSigner()).deploy(); mockAugustusRegistry = await new MockParaSwapAugustusRegistry__factory( @@ -45,7 +45,8 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => { ).deploy(mockAugustus.address); paraswapRepayAdapter = await deployParaSwapRepayAdapter( addressesProvider.address, - mockAugustusRegistry.address + mockAugustusRegistry.address, + deployer.address ); }); @@ -96,25 +97,32 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => { describe('constructor', () => { it('should deploy with correct parameters', async () => { - const { addressesProvider } = testEnv; - await deployParaSwapRepayAdapter(addressesProvider.address, mockAugustusRegistry.address); + const { addressesProvider, deployer } = testEnv; + await deployParaSwapRepayAdapter( + addressesProvider.address, + mockAugustusRegistry.address, + deployer.address + ); }); it('should revert if not valid addresses provider', async () => { + const { deployer } = testEnv; await expect( deployParaSwapRepayAdapter( mockAugustus.address, // any invalid contract can be used here - mockAugustusRegistry.address + mockAugustusRegistry.address, + deployer.address ) ).to.be.reverted; }); it('should revert if not valid augustus registry', async () => { - const { addressesProvider } = testEnv; + const { addressesProvider, deployer } = testEnv; await expect( deployParaSwapRepayAdapter( addressesProvider.address, - mockAugustus.address // any invalid contract can be used here + mockAugustus.address, + deployer.address ) ).to.be.reverted; }); @@ -1666,10 +1674,12 @@ makeSuite('Paraswap adapters', (testEnv: TestEnv) => { async function deployParaSwapRepayAdapter( poolAddressesProvider: tEthereumAddress, - augustusRegistry: tEthereumAddress + augustusRegistry: tEthereumAddress, + owner: tEthereumAddress ) { return await new ParaSwapRepayAdapter__factory(await getFirstSigner()).deploy( poolAddressesProvider, - augustusRegistry + augustusRegistry, + owner ); } diff --git a/test/rewards/claim-all-rewards-to-self.spec.ts b/test/rewards/claim-all-rewards-to-self.spec.ts index 84017582..235c1737 100644 --- a/test/rewards/claim-all-rewards-to-self.spec.ts +++ b/test/rewards/claim-all-rewards-to-self.spec.ts @@ -229,7 +229,7 @@ makeSuite('Incentives Controller V2 claimRewards to self tests', (testEnv) => { assetDataAfter[i].index.toString(), 'user index are not correctly updated' ); - + if (!assetDataAfter[i].index.eq(assetDataBefore[i].index)) { await expect(action) .to.emit(rewardsController, 'Accrued') @@ -243,7 +243,7 @@ makeSuite('Incentives Controller V2 claimRewards to self tests', (testEnv) => { ); } - let expectedClaimedAmount: BigNumber = unclaimedRewardsStorageBefore[i].add( + const expectedClaimedAmount: BigNumber = unclaimedRewardsStorageBefore[i].add( expectedAccruedRewards[i] ); expect(unclaimedRewardsStorageAfter[i].toString()).to.be.equal( @@ -254,7 +254,7 @@ makeSuite('Incentives Controller V2 claimRewards to self tests', (testEnv) => { expect(claimedAmounts[i].toString()).to.be.equal( expectedClaimedAmount.toString(), 'claimed amount are wrong' - ); + ); if (expectedClaimedAmount.gt(0)) { await expect(action) .to.emit(rewardsController, 'RewardsClaimed') From 444139af5f216d9946c90ac833be4839749e9bc6 Mon Sep 17 00:00:00 2001 From: kartojal Date: Fri, 4 Mar 2022 18:56:49 +0100 Subject: [PATCH 2/2] feat: Added beta deploy package. Fix test that hangs due multiple deployments. --- package-lock.json | 106 ++++++++---------- package.json | 4 +- test/rewards/strategies/base-strategy.spec.ts | 3 +- 3 files changed, 53 insertions(+), 60 deletions(-) diff --git a/package-lock.json b/package-lock.json index a07e19c2..dee6c352 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,18 @@ { "name": "@aave/periphery-v3", - "version": "1.13.0", + "version": "1.13.1-beta.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@aave/periphery-v3", - "version": "1.13.0", + "version": "1.13.1-beta.1", "license": "AGPLv3", "dependencies": { - "@aave/core-v3": "^1.14.2" + "@aave/core-v3": "^1.14.3-beta.0" }, "devDependencies": { - "@aave/deploy-v3": "^1.19.0", + "@aave/deploy-v3": "^1.21.1-beta.4", "@ethersproject/abi": "^5.1.0", "@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.11", "@nomiclabs/hardhat-etherscan": "^2.1.1", @@ -57,9 +57,9 @@ } }, "node_modules/@aave/core-v3": { - "version": "1.14.2", - "resolved": "https://npm.pkg.github.com/download/@aave/core-v3/1.14.2/4f9d7f392d3801f1e30a8336d2eaba73a38c43f60f096871880683abccbbeac2", - "integrity": "sha512-3nq/WHuKpVU15yT3vemSx2gr8wzQuuzBjSailnnXbA4fMzHavZQLBTE0eLIbNFPkGAwx+jnECYZ2TuSnEqzMHQ==", + "version": "1.14.3-beta.0", + "resolved": "https://npm.pkg.github.com/download/@aave/core-v3/1.14.3-beta.0/936803c9e795294bde88e20e0b944765c5061a262ea12d8e1fca7169fa1d9382", + "integrity": "sha512-W+hhOQ+t2SVnEZXMJ3ONOYNOOdmxe9Th2ajBXmkLViW3Mr8vCFjQwReYRXF9e0yWg0XDmJ20NE76aE57MGlIUg==", "license": "BUSL-1.1", "dependencies": { "@nomiclabs/hardhat-etherscan": "^2.1.7", @@ -67,27 +67,10 @@ "tmp-promise": "^3.0.2" } }, - "node_modules/@aave/core-v3/node_modules/@nomiclabs/hardhat-etherscan": { - "version": "2.1.8", - "resolved": "https://registry.npmjs.org/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-2.1.8.tgz", - "integrity": "sha512-0+rj0SsZotVOcTLyDOxnOc3Gulo8upo0rsw/h+gBPcmtj91YqYJNhdARHoBxOhhE8z+5IUQPx+Dii04lXT14PA==", - "dependencies": { - "@ethersproject/abi": "^5.1.2", - "@ethersproject/address": "^5.0.2", - "cbor": "^5.0.2", - "debug": "^4.1.1", - "fs-extra": "^7.0.1", - "node-fetch": "^2.6.0", - "semver": "^6.3.0" - }, - "peerDependencies": { - "hardhat": "^2.0.4" - } - }, "node_modules/@aave/deploy-v3": { - "version": "1.19.0", - "resolved": "https://npm.pkg.github.com/download/@aave/deploy-v3/1.19.0/e7a601683e08aad6d72eb5b7f331da04b79a2d2bc12f40e5ea806ee0e20dfee0", - "integrity": "sha512-vFCxADcdiqraA2oBZU3lHqijobStTC1ODFEDVPwzZPteBRyCfeD7NSxnq6FLy4AHfqClm45ROeQ0RbvJxKmXbw==", + "version": "1.21.1-beta.4", + "resolved": "https://npm.pkg.github.com/download/@aave/deploy-v3/1.21.1-beta.4/379cc7907d7c26584ae52205062b10390b12562c1f20ee40cb476b3f8b36f6d7", + "integrity": "sha512-DCTxOk7nLhIasL14xSPUb+MqCH6NroX0JkcngrCyOj975s9ggrKcfqkVcew/zpHXPyJHRoBIb0fWjBg1vXBfjQ==", "dev": true, "license": "AGPLv3", "dependencies": { @@ -110,6 +93,19 @@ "@aave/core-v3": "^1.9.0" } }, + "node_modules/@aave/periphery-v3/node_modules/@aave/core-v3": { + "version": "1.14.2", + "resolved": "https://npm.pkg.github.com/download/@aave/core-v3/1.14.2/4f9d7f392d3801f1e30a8336d2eaba73a38c43f60f096871880683abccbbeac2", + "integrity": "sha512-3nq/WHuKpVU15yT3vemSx2gr8wzQuuzBjSailnnXbA4fMzHavZQLBTE0eLIbNFPkGAwx+jnECYZ2TuSnEqzMHQ==", + "dev": true, + "license": "BUSL-1.1", + "peer": true, + "dependencies": { + "@nomiclabs/hardhat-etherscan": "^2.1.7", + "axios-curlirize": "^1.3.7", + "tmp-promise": "^3.0.2" + } + }, "node_modules/@babel/code-frame": { "version": "7.12.11", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", @@ -1349,10 +1345,9 @@ "dev": true }, "node_modules/@nomiclabs/hardhat-etherscan": { - "version": "2.1.6", - "resolved": "https://registry.npmjs.org/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-2.1.6.tgz", - "integrity": "sha512-gCvT5fj8GbXS9+ACS3BzrX0pzYHHZqAHCb+NcipOkl2cy48FakUXlzrCf4P4sTH+Y7W10OgT62ezD1sJ+/NikQ==", - "dev": true, + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-2.1.8.tgz", + "integrity": "sha512-0+rj0SsZotVOcTLyDOxnOc3Gulo8upo0rsw/h+gBPcmtj91YqYJNhdARHoBxOhhE8z+5IUQPx+Dii04lXT14PA==", "dependencies": { "@ethersproject/abi": "^5.1.2", "@ethersproject/address": "^5.0.2", @@ -23119,35 +23114,19 @@ }, "dependencies": { "@aave/core-v3": { - "version": "1.14.2", - "resolved": "https://npm.pkg.github.com/download/@aave/core-v3/1.14.2/4f9d7f392d3801f1e30a8336d2eaba73a38c43f60f096871880683abccbbeac2", - "integrity": "sha512-3nq/WHuKpVU15yT3vemSx2gr8wzQuuzBjSailnnXbA4fMzHavZQLBTE0eLIbNFPkGAwx+jnECYZ2TuSnEqzMHQ==", + "version": "1.14.3-beta.0", + "resolved": "https://npm.pkg.github.com/download/@aave/core-v3/1.14.3-beta.0/936803c9e795294bde88e20e0b944765c5061a262ea12d8e1fca7169fa1d9382", + "integrity": "sha512-W+hhOQ+t2SVnEZXMJ3ONOYNOOdmxe9Th2ajBXmkLViW3Mr8vCFjQwReYRXF9e0yWg0XDmJ20NE76aE57MGlIUg==", "requires": { "@nomiclabs/hardhat-etherscan": "^2.1.7", "axios-curlirize": "^1.3.7", "tmp-promise": "^3.0.2" - }, - "dependencies": { - "@nomiclabs/hardhat-etherscan": { - "version": "2.1.8", - "resolved": "https://registry.npmjs.org/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-2.1.8.tgz", - "integrity": "sha512-0+rj0SsZotVOcTLyDOxnOc3Gulo8upo0rsw/h+gBPcmtj91YqYJNhdARHoBxOhhE8z+5IUQPx+Dii04lXT14PA==", - "requires": { - "@ethersproject/abi": "^5.1.2", - "@ethersproject/address": "^5.0.2", - "cbor": "^5.0.2", - "debug": "^4.1.1", - "fs-extra": "^7.0.1", - "node-fetch": "^2.6.0", - "semver": "^6.3.0" - } - } } }, "@aave/deploy-v3": { - "version": "1.19.0", - "resolved": "https://npm.pkg.github.com/download/@aave/deploy-v3/1.19.0/e7a601683e08aad6d72eb5b7f331da04b79a2d2bc12f40e5ea806ee0e20dfee0", - "integrity": "sha512-vFCxADcdiqraA2oBZU3lHqijobStTC1ODFEDVPwzZPteBRyCfeD7NSxnq6FLy4AHfqClm45ROeQ0RbvJxKmXbw==", + "version": "1.21.1-beta.4", + "resolved": "https://npm.pkg.github.com/download/@aave/deploy-v3/1.21.1-beta.4/379cc7907d7c26584ae52205062b10390b12562c1f20ee40cb476b3f8b36f6d7", + "integrity": "sha512-DCTxOk7nLhIasL14xSPUb+MqCH6NroX0JkcngrCyOj975s9ggrKcfqkVcew/zpHXPyJHRoBIb0fWjBg1vXBfjQ==", "dev": true, "requires": { "defender-relay-client": "^1.11.1" @@ -23161,6 +23140,20 @@ "peer": true, "requires": { "@aave/core-v3": "^1.9.0" + }, + "dependencies": { + "@aave/core-v3": { + "version": "1.14.2", + "resolved": "https://npm.pkg.github.com/download/@aave/core-v3/1.14.2/4f9d7f392d3801f1e30a8336d2eaba73a38c43f60f096871880683abccbbeac2", + "integrity": "sha512-3nq/WHuKpVU15yT3vemSx2gr8wzQuuzBjSailnnXbA4fMzHavZQLBTE0eLIbNFPkGAwx+jnECYZ2TuSnEqzMHQ==", + "dev": true, + "peer": true, + "requires": { + "@nomiclabs/hardhat-etherscan": "^2.1.7", + "axios-curlirize": "^1.3.7", + "tmp-promise": "^3.0.2" + } + } } }, "@babel/code-frame": { @@ -24043,10 +24036,9 @@ "dev": true }, "@nomiclabs/hardhat-etherscan": { - "version": "2.1.6", - "resolved": "https://registry.npmjs.org/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-2.1.6.tgz", - "integrity": "sha512-gCvT5fj8GbXS9+ACS3BzrX0pzYHHZqAHCb+NcipOkl2cy48FakUXlzrCf4P4sTH+Y7W10OgT62ezD1sJ+/NikQ==", - "dev": true, + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/@nomiclabs/hardhat-etherscan/-/hardhat-etherscan-2.1.8.tgz", + "integrity": "sha512-0+rj0SsZotVOcTLyDOxnOc3Gulo8upo0rsw/h+gBPcmtj91YqYJNhdARHoBxOhhE8z+5IUQPx+Dii04lXT14PA==", "requires": { "@ethersproject/abi": "^5.1.2", "@ethersproject/address": "^5.0.2", diff --git a/package.json b/package.json index 3bbe8014..38e913e7 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ }, "license": "AGPLv3", "devDependencies": { - "@aave/deploy-v3": "^1.19.0", + "@aave/deploy-v3": "^1.21.1-beta.4", "@ethersproject/abi": "^5.1.0", "@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.11", "@nomiclabs/hardhat-etherscan": "^2.1.1", @@ -88,6 +88,6 @@ "url": "git://github.com/aave/aave-v3-periphery" }, "dependencies": { - "@aave/core-v3": "^1.14.2" + "@aave/core-v3": "^1.14.3-beta.0" } } diff --git a/test/rewards/strategies/base-strategy.spec.ts b/test/rewards/strategies/base-strategy.spec.ts index 19df11c8..bdaaddc9 100644 --- a/test/rewards/strategies/base-strategy.spec.ts +++ b/test/rewards/strategies/base-strategy.spec.ts @@ -55,7 +55,8 @@ makeSuite('Base Transfer Strategy', (testEnv: TestEnv) => { const incentivesController = RANDOM_ADDRESSES[0]; const rewardsAdmin = RANDOM_ADDRESSES[1]; - const artifact = await hre.deployments.deploy('PullRewardsTransferStrategy', { + const artifact = await hre.deployments.deploy('PullRewardsTransferStrategy-Tests', { + contract: 'PullRewardsTransferStrategy', from: deployer.address, args: [incentivesController, rewardsAdmin, ZERO_ADDRESS], });