Skip to content

Commit

Permalink
feat: upgrade factory
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Jan 25, 2025
1 parent 1dab6e5 commit bf4cf6f
Show file tree
Hide file tree
Showing 13 changed files with 31 additions and 32 deletions.
8 changes: 4 additions & 4 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ test = 'tests'
script = 'scripts'
optimizer = true
optimizer_runs = 200
solc = '0.8.20'
solc = '0.8.21'
evm_version = 'shanghai'
bytecode_hash = 'none'
ignored_warnings_from = ["src/periphery/contracts/treasury/RevenueSplitter.sol"]
out = 'out'
libs = ['lib']
remappings = []
fs_permissions = [
{ access = "write", path = "./reports" },
{ access = "read", path = "./out" },
{ access = "read", path = "./config" },
{ access = "write", path = "./reports" },
{ access = "read", path = "./out" },
{ access = "read", path = "./config" },
]
ffi = true

Expand Down
10 changes: 5 additions & 5 deletions src/contracts/extensions/stata-token/StataTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.10;

import {IERC20Metadata} from 'solidity-utils/contracts/oz-common/interfaces/IERC20Metadata.sol';
import {ITransparentProxyFactory, ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/interfaces/ITransparentProxyFactory.sol';
import {ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/interfaces/ITransparentProxyFactory.sol';
import {Initializable} from 'solidity-utils/contracts/transparent-proxy/Initializable.sol';
import {IPool, DataTypes} from '../../../contracts/interfaces/IPool.sol';
import {StataTokenV2} from './StataTokenV2.sol';
Expand All @@ -20,7 +20,7 @@ contract StataTokenFactory is Initializable, IStataTokenFactory {
IPool public immutable POOL;

///@inheritdoc IStataTokenFactory
address public immutable PROXY_ADMIN;
address public immutable INITIAL_OWNER;

///@inheritdoc IStataTokenFactory
ITransparentProxyFactory public immutable TRANSPARENT_PROXY_FACTORY;
Expand All @@ -35,12 +35,12 @@ contract StataTokenFactory is Initializable, IStataTokenFactory {

constructor(
IPool pool,
address proxyAdmin,
address initialOwner,
ITransparentProxyFactory transparentProxyFactory,
address stataTokenImpl
) {
POOL = pool;
PROXY_ADMIN = proxyAdmin;
INITIAL_OWNER = initialOwner;
TRANSPARENT_PROXY_FACTORY = transparentProxyFactory;
STATA_TOKEN_IMPL = stataTokenImpl;
}
Expand All @@ -62,7 +62,7 @@ contract StataTokenFactory is Initializable, IStataTokenFactory {
);
address stataToken = TRANSPARENT_PROXY_FACTORY.createDeterministic(
STATA_TOKEN_IMPL,
ProxyAdmin(PROXY_ADMIN),
INITIAL_OWNER,
abi.encodeWithSelector(
StataTokenV2.initialize.selector,
reserveData.aTokenAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ interface IStataTokenFactory {
function POOL() external view returns (IPool);

/**
* @notice The proxy admin used for all tokens created via the factory.
* @return The proxy admin address.
* @notice The initial owner used for all tokens created via the factory.
* @return The address of the initial owner.
*/
function PROXY_ADMIN() external view returns (address);
function INITIAL_OWNER() external view returns (address);

/**
* @notice The proxy factory used for all tokens created via the stata factory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.0;

import '../../interfaces/IMarketReportTypes.sol';
import {ITransparentProxyFactory, ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/interfaces/ITransparentProxyFactory.sol';
import {ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/interfaces/ITransparentProxyFactory.sol';
import {TransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/TransparentProxyFactory.sol';
import {StataTokenV2} from '../../../contracts/extensions/stata-token/StataTokenV2.sol';
import {StataTokenFactory} from '../../../contracts/extensions/stata-token/StataTokenFactory.sol';
Expand All @@ -12,9 +12,9 @@ contract AaveV3HelpersProcedureTwo is IErrors {
function _deployStaticAToken(
address pool,
address rewardsController,
address proxyAdmin
address poolAdmin
) internal returns (StaticATokenReport memory staticATokenReport) {
if (proxyAdmin == address(0)) revert ProxyAdminNotFound();
if (poolAdmin == address(0)) revert PoolAdminNotFound();

staticATokenReport.transparentProxyFactory = address(new TransparentProxyFactory());
staticATokenReport.staticATokenImplementation = address(
Expand All @@ -23,7 +23,7 @@ contract AaveV3HelpersProcedureTwo is IErrors {
staticATokenReport.staticATokenFactoryImplementation = address(
new StataTokenFactory(
IPool(pool),
proxyAdmin,
poolAdmin,
ITransparentProxyFactory(staticATokenReport.transparentProxyFactory),
staticATokenReport.staticATokenImplementation
)
Expand All @@ -33,7 +33,7 @@ contract AaveV3HelpersProcedureTwo is IErrors {
staticATokenReport.transparentProxyFactory
).create(
staticATokenReport.staticATokenFactoryImplementation,
ProxyAdmin(proxyAdmin),
poolAdmin,
abi.encodeWithSelector(StataTokenFactory.initialize.selector)
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol';
import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol';
import {TransparentUpgradeableProxy} from 'openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol';
import {Collector} from '../../../contracts/treasury/Collector.sol';
import '../../interfaces/IMarketReportTypes.sol';

Expand All @@ -29,7 +28,7 @@ contract AaveV3TreasuryProcedure {
treasuryReport.treasury = address(
new TransparentUpgradeableProxy{salt: salt}(
treasuryReport.treasuryImplementation,
ProxyAdmin(deployedProxyAdmin),
poolAdmin,
abi.encodeWithSelector(
treasuryImplementation.initialize.selector,
address(treasuryOwner),
Expand All @@ -45,7 +44,7 @@ contract AaveV3TreasuryProcedure {
treasuryReport.treasury = address(
new TransparentUpgradeableProxy(
treasuryReport.treasuryImplementation,
ProxyAdmin(deployedProxyAdmin),
poolAdmin,
abi.encodeWithSelector(
treasuryImplementation.initialize.selector,
address(treasuryOwner),
Expand Down
2 changes: 1 addition & 1 deletion src/deployments/interfaces/IErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ interface IErrors {
error L2MustBeEnabled();
error L2MustBeDisabled();
error ProviderNotFound();
error ProxyAdminNotFound();
error PoolAdminNotFound();
}
2 changes: 1 addition & 1 deletion src/deployments/interfaces/IMarketReportTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import '../../contracts/extensions/paraswap-adapters/ParaSwapWithdrawSwapAdapter
import '../../contracts/helpers/interfaces/IWrappedTokenGatewayV3.sol';
import '../../contracts/helpers/L2Encoder.sol';
import {ICollector} from '../../contracts/treasury/ICollector.sol';
import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol';
import {ProxyAdmin} from 'openzeppelin-contracts/contracts/proxy/transparent/ProxyAdmin.sol';

struct ContractsReport {
IPoolAddressesProviderRegistry poolAddressesProviderRegistry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ library AaveV3BatchOrchestration {
StaticATokenReport memory staticATokenReport = _deployHelpersBatch2(
setupReport.poolProxy,
setupReport.rewardsControllerProxy,
peripheryReport.proxyAdmin
roles.poolAdmin
);

// Save final report at AaveV3SetupBatch contract
Expand Down Expand Up @@ -191,12 +191,12 @@ library AaveV3BatchOrchestration {
function _deployHelpersBatch2(
address pool,
address rewardsController,
address proxyAdmin
address poolAdmin
) internal returns (StaticATokenReport memory) {
AaveV3HelpersBatchTwo helpersBatchTwo = new AaveV3HelpersBatchTwo(
pool,
rewardsController,
proxyAdmin
poolAdmin
);

return helpersBatchTwo.staticATokenReport();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import '../../../interfaces/IMarketReportTypes.sol';
contract AaveV3HelpersBatchTwo is AaveV3HelpersProcedureTwo {
StaticATokenReport internal _report;

constructor(address pool, address rewardsController, address proxyAdmin) {
_report = _deployStaticAToken(pool, rewardsController, proxyAdmin);
constructor(address pool, address rewardsController, address poolAdmin) {
_report = _deployStaticAToken(pool, rewardsController, poolAdmin);
}

function staticATokenReport() external view returns (StaticATokenReport memory) {
Expand Down
2 changes: 1 addition & 1 deletion tests/deployments/AaveV3BatchTests.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ contract AaveV3BatchTests is BatchTestProcedures {
new AaveV3HelpersBatchTwo(
setupReportTwo.poolProxy,
setupReportTwo.rewardsControllerProxy,
peripheryReportOne.proxyAdmin
roles.poolAdmin
);
}
}
2 changes: 1 addition & 1 deletion tests/deployments/DeploymentsGasLimits.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ contract DeploymentsGasLimits is BatchTestProcedures {
new AaveV3HelpersBatchTwo(
setupReportTwo.poolProxy,
setupReportTwo.rewardsControllerProxy,
peripheryReportOne.proxyAdmin
roles.poolAdmin
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/extensions/stata-token/TestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.10;

import {IERC20Metadata, IERC20} from 'openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol';
import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol';
import {TransparentUpgradeableProxy} from 'openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol';
import {ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/interfaces/ITransparentProxyFactory.sol';
import {StataTokenFactory} from '../../../src/contracts/extensions/stata-token/StataTokenFactory.sol';
import {StataTokenV2} from '../../../src/contracts/extensions/stata-token/StataTokenV2.sol';
Expand Down

0 comments on commit bf4cf6f

Please sign in to comment.