Skip to content

Commit 50a3206

Browse files
authored
test: add more gas snapshots for relevant contracts (#92)
1 parent 3f70474 commit 50a3206

File tree

5 files changed

+166
-3
lines changed

5 files changed

+166
-3
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"getATokenTotalSupply": "57882",
3+
"getFlashLoanEnabled": "16717",
4+
"getInterestRateStrategyAddress": "43034",
5+
"getIsVirtualAccActive": "16767",
6+
"getLiquidationProtocolFee": "16766",
7+
"getPaused": "16855",
8+
"getReserveCaps": "16767",
9+
"getReserveConfigurationData": "17181",
10+
"getReserveTokensAddresses": "43054",
11+
"getSiloedBorrowing": "16770",
12+
"getTotalDebt": "57882",
13+
"getUnbackedMintCap": "16721",
14+
"getUserReserveData": "32363",
15+
"getVirtualUnderlyingBalance": "16533"
16+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"borrowETH": "250143",
3+
"depositETH": "222665",
4+
"repayETH": "205774",
5+
"withdrawETH": "269647"
6+
}

src/contracts/helpers/AaveProtocolDataProvider.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ contract AaveProtocolDataProvider is IPoolDataProvider {
154154
uint256 unbacked,
155155
uint256 accruedToTreasuryScaled,
156156
uint256 totalAToken,
157-
uint256 totalStableDebt,
157+
uint256,
158158
uint256 totalVariableDebt,
159159
uint256 liquidityRate,
160160
uint256 variableBorrowRate,
161-
uint256 stableBorrowRate,
162-
uint256 averageStableBorrowRate,
161+
uint256,
162+
uint256,
163163
uint256 liquidityIndex,
164164
uint256 variableBorrowIndex,
165165
uint40 lastUpdateTimestamp
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.0;
3+
4+
import 'forge-std/Test.sol';
5+
6+
import {Errors} from '../../src/contracts/protocol/libraries/helpers/Errors.sol';
7+
import {UserConfiguration} from '../../src/contracts/protocol/libraries/configuration/UserConfiguration.sol';
8+
import {Testhelpers, IERC20} from './Testhelpers.sol';
9+
10+
/**
11+
* Scenario suite for PDP getters.
12+
*/
13+
contract ProtocolDataProvider_gas_Tests is Testhelpers {
14+
// mock users to supply and borrow liquidity
15+
address user = makeAddr('user');
16+
17+
function test_getReserveConfigurationData() external {
18+
contracts.protocolDataProvider.getReserveConfigurationData(tokenList.usdx);
19+
vm.snapshotGasLastCall('ProtocolDataProvider', 'getReserveConfigurationData');
20+
}
21+
22+
function test_getReserveCaps() external {
23+
contracts.protocolDataProvider.getReserveCaps(tokenList.usdx);
24+
vm.snapshotGasLastCall('ProtocolDataProvider', 'getReserveCaps');
25+
}
26+
27+
function test_getPaused() external {
28+
contracts.protocolDataProvider.getPaused(tokenList.usdx);
29+
vm.snapshotGasLastCall('ProtocolDataProvider', 'getPaused');
30+
}
31+
32+
function test_getSiloedBorrowing() external {
33+
contracts.protocolDataProvider.getSiloedBorrowing(tokenList.usdx);
34+
vm.snapshotGasLastCall('ProtocolDataProvider', 'getSiloedBorrowing');
35+
}
36+
37+
function test_getLiquidationProtocolFee() external {
38+
contracts.protocolDataProvider.getLiquidationProtocolFee(tokenList.usdx);
39+
vm.snapshotGasLastCall('ProtocolDataProvider', 'getLiquidationProtocolFee');
40+
}
41+
42+
function test_getUnbackedMintCap() external {
43+
contracts.protocolDataProvider.getUnbackedMintCap(tokenList.usdx);
44+
vm.snapshotGasLastCall('ProtocolDataProvider', 'getUnbackedMintCap');
45+
}
46+
47+
function test_getDebtCeiling() external {
48+
contracts.protocolDataProvider.getDebtCeiling(tokenList.usdx);
49+
vm.snapshotGasLastCall('ProtocolDataProvider', 'getPaused');
50+
}
51+
52+
function test_getATokenTotalSupply() external {
53+
contracts.protocolDataProvider.getATokenTotalSupply(tokenList.usdx);
54+
vm.snapshotGasLastCall('ProtocolDataProvider', 'getATokenTotalSupply');
55+
}
56+
57+
function test_getTotalDebt() external {
58+
contracts.protocolDataProvider.getATokenTotalSupply(tokenList.usdx);
59+
vm.snapshotGasLastCall('ProtocolDataProvider', 'getTotalDebt');
60+
}
61+
62+
function test_getUserReserveData() external {
63+
_supplyOnReserve(user, 1e6, tokenList.usdx);
64+
65+
contracts.protocolDataProvider.getUserReserveData(tokenList.usdx, user);
66+
vm.snapshotGasLastCall('ProtocolDataProvider', 'getUserReserveData');
67+
}
68+
69+
function test_getReserveTokensAddresses() external {
70+
contracts.protocolDataProvider.getReserveTokensAddresses(tokenList.usdx);
71+
vm.snapshotGasLastCall('ProtocolDataProvider', 'getReserveTokensAddresses');
72+
}
73+
74+
function test_getInterestRateStrategyAddress() external {
75+
contracts.protocolDataProvider.getInterestRateStrategyAddress(tokenList.usdx);
76+
vm.snapshotGasLastCall('ProtocolDataProvider', 'getInterestRateStrategyAddress');
77+
}
78+
79+
function test_getFlashLoanEnabled() external {
80+
contracts.protocolDataProvider.getFlashLoanEnabled(tokenList.usdx);
81+
vm.snapshotGasLastCall('ProtocolDataProvider', 'getFlashLoanEnabled');
82+
}
83+
84+
function test_getIsVirtualAccActive() external {
85+
contracts.protocolDataProvider.getIsVirtualAccActive(tokenList.usdx);
86+
vm.snapshotGasLastCall('ProtocolDataProvider', 'getIsVirtualAccActive');
87+
}
88+
89+
function test_getVirtualUnderlyingBalance() external {
90+
contracts.protocolDataProvider.getVirtualUnderlyingBalance(tokenList.usdx);
91+
vm.snapshotGasLastCall('ProtocolDataProvider', 'getVirtualUnderlyingBalance');
92+
}
93+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.0;
3+
4+
import 'forge-std/Test.sol';
5+
6+
import {Errors} from '../../src/contracts/protocol/libraries/helpers/Errors.sol';
7+
import {UserConfiguration} from '../../src/contracts/protocol/libraries/configuration/UserConfiguration.sol';
8+
import {Testhelpers, IERC20} from './Testhelpers.sol';
9+
import {VariableDebtToken} from '../../src/contracts/protocol/tokenization/VariableDebtToken.sol';
10+
11+
/**
12+
* Scenario suite for PDP getters.
13+
*/
14+
contract WrappedTokenGatewayV3_gas_Tests is Testhelpers {
15+
// mock users to supply and borrow liquidity
16+
address user = makeAddr('user');
17+
18+
function test_flow() external {
19+
vm.startPrank(user);
20+
deal(user, 2 ether);
21+
(address aEthToken, , address wEthVariableDebt) = contracts
22+
.protocolDataProvider
23+
.getReserveTokensAddresses(tokenList.weth);
24+
25+
contracts.wrappedTokenGateway.depositETH{value: 1 ether}(address(0), user, 0);
26+
vm.snapshotGasLastCall('WrappedTokenGatewayV3', 'depositETH');
27+
28+
_skip(100);
29+
30+
VariableDebtToken(wEthVariableDebt).approveDelegation(
31+
report.wrappedTokenGateway,
32+
type(uint256).max
33+
);
34+
contracts.wrappedTokenGateway.borrowETH(address(0), 0.1 ether, 0);
35+
vm.snapshotGasLastCall('WrappedTokenGatewayV3', 'borrowETH');
36+
37+
_skip(100);
38+
39+
contracts.wrappedTokenGateway.repayETH{value: 0.2 ether}(address(0), type(uint256).max, user);
40+
vm.snapshotGasLastCall('WrappedTokenGatewayV3', 'repayETH');
41+
42+
_skip(100);
43+
44+
IERC20(aEthToken).approve(report.wrappedTokenGateway, type(uint256).max);
45+
contracts.wrappedTokenGateway.withdrawETH(address(0), type(uint256).max, user);
46+
vm.snapshotGasLastCall('WrappedTokenGatewayV3', 'withdrawETH');
47+
}
48+
}

0 commit comments

Comments
 (0)