Skip to content

Commit

Permalink
fix: some minor patches
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Oct 25, 2023
1 parent 008a61f commit 8aa8b71
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 13 deletions.
20 changes: 12 additions & 8 deletions generator/features/__snapshots__/assetListing.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pragma solidity ^0.8.0;
import {AaveV3Ethereum, AaveV3EthereumEModes} from 'aave-address-book/AaveV3Ethereum.sol';
import {AaveV3PayloadEthereum} from 'aave-helpers/v3-config-engine/AaveV3PayloadEthereum.sol';
import {IAaveV3ConfigEngine} from 'aave-helpers/v3-config-engine/IAaveV3ConfigEngine.sol';
import {IV3RateStrategyFactory} from 'aave-helpers/v3-config-engine/IV3RateStrategyFactory.sol';
/**
* @title test
Expand All @@ -100,7 +101,7 @@ contract AaveV3Ethereum_Test_20231023 is AaveV3PayloadEthereum {
address public constant PSP = address(0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5);
function _postExecute() internal override {
AaveV3Ethereum.POOL.supply(PSP, 10 ** 18, AaveV3Ethereum.COLLECTOR, 0);
AaveV3Ethereum.POOL.supply(PSP, 10 ** 18, address(AaveV3Ethereum.COLLECTOR), 0);
}
function newListings() public pure override returns (IAaveV3ConfigEngine.Listing[] memory) {
Expand All @@ -124,7 +125,7 @@ contract AaveV3Ethereum_Test_20231023 is AaveV3PayloadEthereum {
borrowCap: 5_000,
debtCeiling: 100_000,
liqProtocolFee: 20_00,
rateStrategyParams: Rates.RateStrategyParams({
rateStrategyParams: IV3RateStrategyFactory.RateStrategyParams({
optimalUsageRatio: _bpsToRay(80_00),
baseVariableBorrowRate: _bpsToRay(0_00),
variableRateSlope1: _bpsToRay(10_00),
Expand All @@ -146,6 +147,7 @@ pragma solidity ^0.8.0;
import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol';
import {AaveV3Ethereum} from 'aave-address-book/AaveV3Ethereum.sol';
import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol';
import 'forge-std/Test.sol';
import {ProtocolV3TestBase, ReserveConfig} from 'aave-helpers/ProtocolV3TestBase.sol';
Expand All @@ -159,7 +161,7 @@ contract AaveV3Ethereum_Test_20231023_Test is ProtocolV3TestBase {
AaveV3Ethereum_Test_20231023 internal proposal;
function setUp() public {
vm.createSelectFork(vm.rpcUrl('mainnet'), 18420741);
vm.createSelectFork(vm.rpcUrl('mainnet'), 18430155);
proposal = new AaveV3Ethereum_Test_20231023();
}
Expand All @@ -172,8 +174,10 @@ contract AaveV3Ethereum_Test_20231023_Test is ProtocolV3TestBase {
function test_collectorHasPSPFunds() public {
GovV3Helpers.executePayload(vm, address(proposal));
assertGte(
IERC20(0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5).balanceOf(AaveV3Ethereum.COLLECTOR),
assertGe(
IERC20(0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5).balanceOf(
address(AaveV3Ethereum.COLLECTOR)
),
10 ** 18
);
}
Expand Down Expand Up @@ -240,7 +244,7 @@ exports[`feature: assetListing > should return reasonable code 1`] = `
"address public constant PSP = address(0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5);",
],
"execute": [
"AaveV3Ethereum.POOL.supply(PSP, 10 ** 18, AaveV3Ethereum.COLLECTOR, 0);",
"AaveV3Ethereum.POOL.supply(PSP, 10 ** 18, address(AaveV3Ethereum.COLLECTOR), 0);",
],
"fn": [
"function newListings() public pure override returns (IAaveV3ConfigEngine.Listing[] memory) {
Expand All @@ -264,7 +268,7 @@ exports[`feature: assetListing > should return reasonable code 1`] = `
borrowCap: 5_000,
debtCeiling: 100_000,
liqProtocolFee: 20_00,
rateStrategyParams: Rates.RateStrategyParams({
rateStrategyParams: IV3RateStrategyFactory.RateStrategyParams({
optimalUsageRatio: _bpsToRay(80_00),
baseVariableBorrowRate: _bpsToRay(0_00),
variableRateSlope1: _bpsToRay(10_00),
Expand All @@ -285,7 +289,7 @@ exports[`feature: assetListing > should return reasonable code 1`] = `
"fn": [
"function test_collectorHasPSPFunds() public {
GovV3Helpers.executePayload(vm,address(proposal));
assertGte(IERC20(0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5).balanceOf(AaveV3Ethereum.COLLECTOR), 10 ** 18);
assertGe(IERC20(0xcAfE001067cDEF266AfB7Eb5A286dCFD277f3dE5).balanceOf(address(AaveV3Ethereum.COLLECTOR)), 10 ** 18);
}",
],
},
Expand Down
4 changes: 2 additions & 2 deletions generator/features/assetListing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const assetListing: FeatureModule<Listing[]> = {
),
execute: cfg.map(
(cfg) =>
`${pool}.POOL.supply(${cfg.assetSymbol}, 10 ** ${cfg.decimals}, ${pool}.COLLECTOR, 0);`
`${pool}.POOL.supply(${cfg.assetSymbol}, 10 ** ${cfg.decimals}, address(${pool}.COLLECTOR), 0);`
),
fn: [
`function newListings() public pure override returns (IAaveV3ConfigEngine.Listing[] memory) {
Expand Down Expand Up @@ -156,7 +156,7 @@ export const assetListing: FeatureModule<Listing[]> = {
fn: cfg.map(
(cfg) => `function test_collectorHas${cfg.assetSymbol}Funds() public {
${TEST_EXECUTE_PROPOSAL}
assertGte(IERC20(${cfg.asset}).balanceOf(${pool}.COLLECTOR), 10 ** ${cfg.decimals});
assertGe(IERC20(${cfg.asset}).balanceOf(address(${pool}.COLLECTOR)), 10 ** ${cfg.decimals});
}`
),
},
Expand Down
1 change: 1 addition & 0 deletions generator/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function translateJsAddressToSol(value: string) {
}

function translateJsBoolToSol(value: string) {
console.log(value);
switch (value) {
case ENGINE_FLAGS.ENABLED:
return `EngineFlags.ENABLED`;
Expand Down
6 changes: 6 additions & 0 deletions generator/utils/importsResolver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import {expect, describe, it} from 'vitest';
import {prefixWithImports} from './importsResolver';

describe('prefixWithImports', () => {
it('should resolve IProposalGenericExecutor', () => {
expect(prefixWithImports(`is IProposalGenericExecutor {`)).toContain(
`import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol';`
);
});

it('should resolve Engine imports', () => {
expect(prefixWithImports(`GovV3Helpers.createPayload`)).toContain(
`import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol';`
Expand Down
8 changes: 6 additions & 2 deletions generator/utils/importsResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ function generateEngineImport(code: string) {
}

function findMatches(code: string, needles: string[] | readonly string[]) {
return needles.filter((needle) => RegExp(needle + '\\.', 'g').test(code));
return needles.filter((needle) => RegExp(needle, 'g').test(code));
}

function findMatch(code: string, needle: string) {
return RegExp(needle + '\\.', 'g').test(code);
return RegExp(needle, 'g').test(code);
}

/**
Expand Down Expand Up @@ -93,6 +93,10 @@ export function prefixWithImports(code: string) {
if (findMatch(code, 'IV2RateStrategyFactory')) {
imports += `import {IV2RateStrategyFactory} from 'aave-helpers/v2-config-engine/IV2RateStrategyFactory.sol';\n`;
}
// common imports
if (findMatch(code, 'IERC20')) {
imports += `import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol';\n`;
}

return imports + code;
}
2 changes: 1 addition & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@aave/core-v3/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-core/
@aave/periphery-v3/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-periphery/
aave-address-book/=lib/aave-address-book/src/
aave-address-book/=lib/aave-helpers/lib/lib/aave-address-book/src/
aave-helpers/=lib/aave-helpers/src/
aave-v3-core/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-core/
aave-v3-periphery/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-periphery/
Expand Down

0 comments on commit 8aa8b71

Please sign in to comment.