Skip to content

Commit

Permalink
fix: Add compilation config (#21)
Browse files Browse the repository at this point in the history
* fix: Add compilation config

* ci: Change to ubuntu-latest

* fix: Remove extra output files of compilation

* fix: Remove unnecessary getters for GhoToken and GhoFlashMinter

* fix: Lower compilation runs

* ci: Change to self-hosted
  • Loading branch information
miguelmtzinf authored Jun 2, 2023
1 parent f69e74e commit ee6b6d0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 42 deletions.
6 changes: 6 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ test = 'tests'
script = 'scripts'
out = 'out'
libs = ['lib']

remappings = [
'solidity-utils/=lib/solidity-utils/src'
]
fs_permissions = [{access = "write", path = "./reports"}]

solc_version = "0.8.10"
extra_output_files = ["metadata"]
optimizer = true
optimizer_runs = 5000

[rpc_endpoints]
mainnet = "${RPC_MAINNET}"
optimism = "${RPC_OPTIMISM}"
Expand Down
6 changes: 3 additions & 3 deletions scripts/LaunchGho.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ contract LaunchGho is Script {
aaveData.ghoInterestRateStrategy,
aaveData.ghoDiscountRateStrategy
);
console2.log('GhoToken:', GhoListingPayload(payload).precomputeGhoTokenAddress());
console2.log('FlashMinter:', GhoListingPayload(payload).precomputeGhoFlashMinterAddress());
console2.log('GhoToken:', GhoListingPayload(payload).GHO_TOKEN());
console2.log('FlashMinter:', GhoListingPayload(payload).GHO_FLASHMINTER());
console2.log('Payload:', payload);

// Deploy GhoUiDataProvider
address ghoUiDataProvider = Helpers.deployGhoUiDataProvider(
address(AaveV3Ethereum.POOL),
GhoListingPayload(payload).precomputeGhoTokenAddress()
GhoListingPayload(payload).GHO_TOKEN()
);
console2.log('GhoUiDataProvider:', ghoUiDataProvider);

Expand Down
52 changes: 17 additions & 35 deletions src/contracts/GhoListingPayload.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ library Create2Helper {
address public constant CREATE2_SINGLETON_FACTORY = 0x2401ae9bBeF67458362710f90302Eb52b5Ce835a;
bytes32 public constant CREATE2_SALT = bytes32(0);

function _precomputeAddress(bytes memory bytecode) internal pure returns (address) {
function _precomputeAddress(bytes memory bytecode) external pure returns (address) {
return
address(
uint160(
Expand All @@ -37,15 +37,15 @@ library Create2Helper {
);
}

function _deployCreate2(bytes memory bytecode) internal returns (address) {
function _deployCreate2(bytes memory bytecode) external returns (address) {
(bool success, bytes memory returnData) = CREATE2_SINGLETON_FACTORY.call(
abi.encodePacked(CREATE2_SALT, bytecode)
);
require(success, 'CREATE2_DEPLOYMENT_FAILED');
return address(bytes20(returnData));
}

function _isContract(address account) internal view returns (bool) {
function _isContract(address account) external view returns (bool) {
return account.code.length > 0;
}
}
Expand Down Expand Up @@ -88,8 +88,20 @@ contract GhoListingPayload is IProposalGenericExecutor {
address ghoInterestRateStrategy,
address ghoDiscountRateStrategy
) {
GHO_TOKEN = precomputeGhoTokenAddress();
GHO_FLASHMINTER = precomputeGhoFlashMinterAddress();
GHO_TOKEN = Create2Helper._precomputeAddress(
abi.encodePacked(type(GhoToken).creationCode, abi.encode(AaveGovernanceV2.SHORT_EXECUTOR))
);
GHO_FLASHMINTER = Create2Helper._precomputeAddress(
abi.encodePacked(
type(GhoFlashMinter).creationCode,
abi.encode(
GHO_TOKEN,
AaveV3Ethereum.COLLECTOR,
FLASHMINT_FEE,
address(AaveV3Ethereum.POOL_ADDRESSES_PROVIDER)
)
)
);
GHO_ORACLE = ghoOracle;
GHO_ATOKEN_IMPL = ghoATokenImpl;
GHO_VARIABLE_DEBT_TOKEN_IMPL = ghoVariableDebtTokenImpl;
Expand Down Expand Up @@ -240,34 +252,4 @@ contract GhoListingPayload is IProposalGenericExecutor {
FACILITATOR_FLASHMINTER_BUCKET_CAPACITY
);
}

/**
* @notice Returns the precomputed address of GHO token
* @return The precomputed address of the GhoToken
*/
function precomputeGhoTokenAddress() public pure returns (address) {
return
Create2Helper._precomputeAddress(
abi.encodePacked(type(GhoToken).creationCode, abi.encode(AaveGovernanceV2.SHORT_EXECUTOR))
);
}

/**
* @notice Returns the precomputed address of the GHO FlashMinter
* @return The precomputed address of the GhoFlashMinter
*/
function precomputeGhoFlashMinterAddress() public pure returns (address) {
return
Create2Helper._precomputeAddress(
abi.encodePacked(
type(GhoFlashMinter).creationCode,
abi.encode(
precomputeGhoTokenAddress(),
AaveV3Ethereum.COLLECTOR,
FLASHMINT_FEE,
address(AaveV3Ethereum.POOL_ADDRESSES_PROVIDER)
)
)
);
}
}
8 changes: 4 additions & 4 deletions tests/GhoListingTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ contract GhoListingTest is ProtocolV3TestBase {
aaveData.ghoDiscountRateStrategy
);
GhoListingPayload payload = GhoListingPayload(payloadAddress);
GHO_TOKEN = payload.precomputeGhoTokenAddress();
GHO_FLASHMINTER = payload.precomputeGhoFlashMinterAddress();
GHO_TOKEN = payload.GHO_TOKEN();
GHO_FLASHMINTER = payload.GHO_FLASHMINTER();

// Simulate GOV action
uint256 listingProposalId = _passProposal(AaveGovernanceV2.SHORT_EXECUTOR, address(payload));
Expand Down Expand Up @@ -95,8 +95,8 @@ contract GhoListingTest is ProtocolV3TestBase {
aaveData.ghoDiscountRateStrategy
);
GhoListingPayload payload = GhoListingPayload(payloadAddress);
GHO_TOKEN = payload.precomputeGhoTokenAddress();
GHO_FLASHMINTER = payload.precomputeGhoFlashMinterAddress();
GHO_TOKEN = payload.GHO_TOKEN();
GHO_FLASHMINTER = payload.GHO_FLASHMINTER();

// Simulate GOV action
uint256 listingProposalId = _passProposal(AaveGovernanceV2.SHORT_EXECUTOR, address(payload));
Expand Down

0 comments on commit ee6b6d0

Please sign in to comment.