Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update to use new proxy #75

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion certora/stata/harness/StataTokenV2Harness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.10;

import {IERC20} from 'openzeppelin-contracts/contracts/interfaces/IERC20.sol';
import {StataTokenV2, IPool, IRewardsController} from '../munged/src/contracts/extensions/static-a-token/StataTokenV2.sol';
import {StataTokenV2, IPool, IRewardsController} from '../munged/src/contracts/extensions/stata-token/StataTokenV2.sol';
import {SymbolicLendingPool} from './pool/SymbolicLendingPool.sol';

contract StataTokenV2Harness is StataTokenV2 {
Expand Down
20 changes: 12 additions & 8 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} from 'solidity-utils/contracts/transparent-proxy/interfaces/ITransparentProxyFactory.sol';
import {ITransparentProxyFactory, ProxyAdmin} 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 @@ -16,9 +16,16 @@ import {IStataTokenFactory} from './interfaces/IStataTokenFactory.sol';
* @author BGD labs
*/
contract StataTokenFactory is Initializable, IStataTokenFactory {
///@inheritdoc IStataTokenFactory
IPool public immutable POOL;

///@inheritdoc IStataTokenFactory
address public immutable PROXY_ADMIN;

///@inheritdoc IStataTokenFactory
ITransparentProxyFactory public immutable TRANSPARENT_PROXY_FACTORY;

///@inheritdoc IStataTokenFactory
address public immutable STATA_TOKEN_IMPL;

mapping(address => address) internal _underlyingToStataToken;
Expand Down Expand Up @@ -50,19 +57,16 @@ contract StataTokenFactory is Initializable, IStataTokenFactory {
if (reserveData.aTokenAddress == address(0))
revert NotListedUnderlying(reserveData.aTokenAddress);
bytes memory symbol = abi.encodePacked(
'stat',
IERC20Metadata(reserveData.aTokenAddress).symbol(),
'v2'
'w',
IERC20Metadata(reserveData.aTokenAddress).symbol()
);
address stataToken = TRANSPARENT_PROXY_FACTORY.createDeterministic(
STATA_TOKEN_IMPL,
PROXY_ADMIN,
ProxyAdmin(PROXY_ADMIN),
abi.encodeWithSelector(
StataTokenV2.initialize.selector,
reserveData.aTokenAddress,
string(
abi.encodePacked('Static ', IERC20Metadata(reserveData.aTokenAddress).name(), ' v2')
),
string(abi.encodePacked('Wrapped ', IERC20Metadata(reserveData.aTokenAddress).name())),
string(symbol)
),
bytes32(uint256(uint160(underlyings[i])))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import {ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/interfaces/ITransparentProxyFactory.sol';
import {IPool, IPoolAddressesProvider} from '../../../interfaces/IPool.sol';

interface IStataTokenFactory {
error NotListedUnderlying(address underlying);

/**
* @notice The pool associated with the factory.
* @return The pool address.
*/
function POOL() external view returns (IPool);

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

/**
* @notice The proxy factory used for all tokens created via the stata factory.
* @return The proxy factory address.
*/
function TRANSPARENT_PROXY_FACTORY() external view returns (ITransparentProxyFactory);

/**
* @notice The stata implementation used for all tokens created via the factory.
* @return The implementation address.
*/
function STATA_TOKEN_IMPL() external view returns (address);

/**
* @notice Creates new StataTokens
* @param underlyings the addresses of the underlyings to create.
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} from 'solidity-utils/contracts/transparent-proxy/interfaces/ITransparentProxyFactory.sol';
import {ITransparentProxyFactory, ProxyAdmin} 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 Down Expand Up @@ -33,7 +33,7 @@ contract AaveV3HelpersProcedureTwo is IErrors {
staticATokenReport.transparentProxyFactory
).create(
staticATokenReport.staticATokenFactoryImplementation,
proxyAdmin,
ProxyAdmin(proxyAdmin),
abi.encodeWithSelector(StataTokenFactory.initialize.selector)
);

Expand Down
14 changes: 7 additions & 7 deletions src/deployments/contracts/procedures/AaveV3SetupProcedure.sol
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 {IOwnable} from 'solidity-utils/contracts/transparent-proxy/interfaces/IOwnable.sol';
import {Ownable} from '../../../contracts/dependencies/openzeppelin/contracts/Ownable.sol';
import {ACLManager} from '../../../contracts/protocol/configuration/ACLManager.sol';
import {IPoolConfigurator} from '../../../contracts/interfaces/IPoolConfigurator.sol';
import {IPoolAddressesProvider} from '../../../contracts/interfaces/IPoolAddressesProvider.sol';
Expand Down Expand Up @@ -99,7 +99,7 @@ contract AaveV3SetupProcedure {
poolAddressesProvider,
providerId
);
IOwnable(poolAddressesProviderRegistry).transferOwnership(marketOwner);
Ownable(poolAddressesProviderRegistry).transferOwnership(marketOwner);
} else {
poolAddressesProviderRegistry = providerRegistry;
}
Expand Down Expand Up @@ -137,7 +137,7 @@ contract AaveV3SetupProcedure {
IRewardsController(report.rewardsControllerProxy).EMISSION_MANAGER()
);
emissionManager.setRewardsController(report.rewardsControllerProxy);
IOwnable(address(emissionManager)).transferOwnership(input.poolAdmin);
Ownable(address(emissionManager)).transferOwnership(input.poolAdmin);
} else {
provider.setAddress(controllerId, input.rewardsControllerProxy);
report.rewardsControllerProxy = provider.getAddress(controllerId);
Expand Down Expand Up @@ -199,15 +199,15 @@ contract AaveV3SetupProcedure {
}

function _transferMarketOwnership(Roles memory roles, InitialReport memory report) internal {
address addressesProviderOwner = IOwnable(report.poolAddressesProvider).owner();
address marketOwner = IOwnable(report.poolAddressesProviderRegistry).owner();
address addressesProviderOwner = Ownable(report.poolAddressesProvider).owner();
address marketOwner = Ownable(report.poolAddressesProviderRegistry).owner();

if (addressesProviderOwner == address(this)) {
IOwnable(report.poolAddressesProvider).transferOwnership(roles.marketOwner);
Ownable(report.poolAddressesProvider).transferOwnership(roles.marketOwner);
}

if (marketOwner == address(this)) {
IOwnable(report.poolAddressesProviderRegistry).transferOwnership(roles.marketOwner);
Ownable(report.poolAddressesProviderRegistry).transferOwnership(roles.marketOwner);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ 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 {IOwnable} from 'solidity-utils/contracts/transparent-proxy/interfaces/IOwnable.sol';
import {Collector} from '../../../contracts/treasury/Collector.sol';
import '../../interfaces/IMarketReportTypes.sol';

Expand All @@ -30,7 +29,7 @@ contract AaveV3TreasuryProcedure {
treasuryReport.treasury = address(
new TransparentUpgradeableProxy{salt: salt}(
treasuryReport.treasuryImplementation,
deployedProxyAdmin,
ProxyAdmin(deployedProxyAdmin),
abi.encodeWithSelector(
treasuryImplementation.initialize.selector,
address(treasuryOwner),
Expand All @@ -46,7 +45,7 @@ contract AaveV3TreasuryProcedure {
treasuryReport.treasury = address(
new TransparentUpgradeableProxy(
treasuryReport.treasuryImplementation,
deployedProxyAdmin,
ProxyAdmin(deployedProxyAdmin),
abi.encodeWithSelector(
treasuryImplementation.initialize.selector,
address(treasuryOwner),
Expand Down
34 changes: 0 additions & 34 deletions src/deployments/interfaces/IProxyAdmin.sol

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import {AaveV3TreasuryProcedure} from '../../../contracts/procedures/AaveV3Treas
import {AaveV3OracleProcedure} from '../../../contracts/procedures/AaveV3OracleProcedure.sol';
import {AaveV3IncentiveProcedure} from '../../../contracts/procedures/AaveV3IncentiveProcedure.sol';
import {AaveV3DefaultRateStrategyProcedure} from '../../../contracts/procedures/AaveV3DefaultRateStrategyProcedure.sol';
import {IOwnable} from 'solidity-utils/contracts/transparent-proxy/interfaces/IOwnable.sol';
import {Ownable} from '../../../../contracts/dependencies/openzeppelin/contracts/Ownable.sol';
import '../../../interfaces/IMarketReportTypes.sol';
import {IRewardsController} from '../../../../contracts/rewards/interfaces/IRewardsController.sol';
import {IOwnable} from 'solidity-utils/contracts/transparent-proxy/interfaces/IOwnable.sol';
import {RevenueSplitter} from '../../../../contracts/treasury/RevenueSplitter.sol';

contract AaveV3PeripheryBatch is
Expand All @@ -25,8 +24,7 @@ contract AaveV3PeripheryBatch is
address setupBatch
) {
if (config.proxyAdmin == address(0)) {
_report.proxyAdmin = address(new ProxyAdmin{salt: config.salt}());
IOwnable(_report.proxyAdmin).transferOwnership(poolAdmin);
_report.proxyAdmin = address(new ProxyAdmin{salt: config.salt}(poolAdmin));
} else {
_report.proxyAdmin = config.proxyAdmin;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/extensions/stata-token/StataTokenV2Getters.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ contract StataTokenV2GettersTest is BaseTest {
}

function test_getters() public view {
assertEq(stataTokenV2.name(), 'Static Aave Local WETH v2');
assertEq(stataTokenV2.symbol(), 'stataLocWETHv2');
assertEq(stataTokenV2.name(), 'Wrapped Aave Local WETH');
assertEq(stataTokenV2.symbol(), 'waLocWETH');

address referenceAsset = stataTokenV2.getReferenceAsset();
assertEq(referenceAsset, aToken);
Expand Down
2 changes: 0 additions & 2 deletions tests/extensions/stata-token/StataTokenV2Rescuable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ contract StataTokenV2RescuableTest is BaseTest {
_fundAToken(donation, address(stataTokenV2));
_fund4626(stake, address(this));

address treasury = IAToken(aToken).RESERVE_TREASURY_ADDRESS();

vm.expectEmit(true, true, true, true);
emit ERC20Rescued(poolAdmin, aToken, address(this), donation);
vm.startPrank(poolAdmin);
Expand Down
8 changes: 0 additions & 8 deletions tests/extensions/stata-token/TestBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@ abstract contract BaseTest is TestnetProcedures {
vm.warp(block.timestamp + blocks * 12); // assuming a block is around 12seconds
}

function testAdmin() public {
vm.stopPrank();
vm.startPrank(proxyAdmin);
assertEq(TransparentUpgradeableProxy(payable(address(stataTokenV2))).admin(), proxyAdmin);
assertEq(TransparentUpgradeableProxy(payable(address(factory))).admin(), proxyAdmin);
vm.stopPrank();
}

function _fundUnderlying(uint256 assets, address receiver) internal {
deal(underlying, receiver, assets);
}
Expand Down