-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add more gas snapshots for relevant contracts (#92)
- Loading branch information
Showing
5 changed files
with
166 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"getATokenTotalSupply": "57882", | ||
"getFlashLoanEnabled": "16717", | ||
"getInterestRateStrategyAddress": "43034", | ||
"getIsVirtualAccActive": "16767", | ||
"getLiquidationProtocolFee": "16766", | ||
"getPaused": "16855", | ||
"getReserveCaps": "16767", | ||
"getReserveConfigurationData": "17181", | ||
"getReserveTokensAddresses": "43054", | ||
"getSiloedBorrowing": "16770", | ||
"getTotalDebt": "57882", | ||
"getUnbackedMintCap": "16721", | ||
"getUserReserveData": "32363", | ||
"getVirtualUnderlyingBalance": "16533" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"borrowETH": "250143", | ||
"depositETH": "222665", | ||
"repayETH": "205774", | ||
"withdrawETH": "269647" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
|
||
import 'forge-std/Test.sol'; | ||
|
||
import {Errors} from '../../src/contracts/protocol/libraries/helpers/Errors.sol'; | ||
import {UserConfiguration} from '../../src/contracts/protocol/libraries/configuration/UserConfiguration.sol'; | ||
import {Testhelpers, IERC20} from './Testhelpers.sol'; | ||
|
||
/** | ||
* Scenario suite for PDP getters. | ||
*/ | ||
contract ProtocolDataProvider_gas_Tests is Testhelpers { | ||
// mock users to supply and borrow liquidity | ||
address user = makeAddr('user'); | ||
|
||
function test_getReserveConfigurationData() external { | ||
contracts.protocolDataProvider.getReserveConfigurationData(tokenList.usdx); | ||
vm.snapshotGasLastCall('ProtocolDataProvider', 'getReserveConfigurationData'); | ||
} | ||
|
||
function test_getReserveCaps() external { | ||
contracts.protocolDataProvider.getReserveCaps(tokenList.usdx); | ||
vm.snapshotGasLastCall('ProtocolDataProvider', 'getReserveCaps'); | ||
} | ||
|
||
function test_getPaused() external { | ||
contracts.protocolDataProvider.getPaused(tokenList.usdx); | ||
vm.snapshotGasLastCall('ProtocolDataProvider', 'getPaused'); | ||
} | ||
|
||
function test_getSiloedBorrowing() external { | ||
contracts.protocolDataProvider.getSiloedBorrowing(tokenList.usdx); | ||
vm.snapshotGasLastCall('ProtocolDataProvider', 'getSiloedBorrowing'); | ||
} | ||
|
||
function test_getLiquidationProtocolFee() external { | ||
contracts.protocolDataProvider.getLiquidationProtocolFee(tokenList.usdx); | ||
vm.snapshotGasLastCall('ProtocolDataProvider', 'getLiquidationProtocolFee'); | ||
} | ||
|
||
function test_getUnbackedMintCap() external { | ||
contracts.protocolDataProvider.getUnbackedMintCap(tokenList.usdx); | ||
vm.snapshotGasLastCall('ProtocolDataProvider', 'getUnbackedMintCap'); | ||
} | ||
|
||
function test_getDebtCeiling() external { | ||
contracts.protocolDataProvider.getDebtCeiling(tokenList.usdx); | ||
vm.snapshotGasLastCall('ProtocolDataProvider', 'getPaused'); | ||
} | ||
|
||
function test_getATokenTotalSupply() external { | ||
contracts.protocolDataProvider.getATokenTotalSupply(tokenList.usdx); | ||
vm.snapshotGasLastCall('ProtocolDataProvider', 'getATokenTotalSupply'); | ||
} | ||
|
||
function test_getTotalDebt() external { | ||
contracts.protocolDataProvider.getATokenTotalSupply(tokenList.usdx); | ||
vm.snapshotGasLastCall('ProtocolDataProvider', 'getTotalDebt'); | ||
} | ||
|
||
function test_getUserReserveData() external { | ||
_supplyOnReserve(user, 1e6, tokenList.usdx); | ||
|
||
contracts.protocolDataProvider.getUserReserveData(tokenList.usdx, user); | ||
vm.snapshotGasLastCall('ProtocolDataProvider', 'getUserReserveData'); | ||
} | ||
|
||
function test_getReserveTokensAddresses() external { | ||
contracts.protocolDataProvider.getReserveTokensAddresses(tokenList.usdx); | ||
vm.snapshotGasLastCall('ProtocolDataProvider', 'getReserveTokensAddresses'); | ||
} | ||
|
||
function test_getInterestRateStrategyAddress() external { | ||
contracts.protocolDataProvider.getInterestRateStrategyAddress(tokenList.usdx); | ||
vm.snapshotGasLastCall('ProtocolDataProvider', 'getInterestRateStrategyAddress'); | ||
} | ||
|
||
function test_getFlashLoanEnabled() external { | ||
contracts.protocolDataProvider.getFlashLoanEnabled(tokenList.usdx); | ||
vm.snapshotGasLastCall('ProtocolDataProvider', 'getFlashLoanEnabled'); | ||
} | ||
|
||
function test_getIsVirtualAccActive() external { | ||
contracts.protocolDataProvider.getIsVirtualAccActive(tokenList.usdx); | ||
vm.snapshotGasLastCall('ProtocolDataProvider', 'getIsVirtualAccActive'); | ||
} | ||
|
||
function test_getVirtualUnderlyingBalance() external { | ||
contracts.protocolDataProvider.getVirtualUnderlyingBalance(tokenList.usdx); | ||
vm.snapshotGasLastCall('ProtocolDataProvider', 'getVirtualUnderlyingBalance'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
|
||
import 'forge-std/Test.sol'; | ||
|
||
import {Errors} from '../../src/contracts/protocol/libraries/helpers/Errors.sol'; | ||
import {UserConfiguration} from '../../src/contracts/protocol/libraries/configuration/UserConfiguration.sol'; | ||
import {Testhelpers, IERC20} from './Testhelpers.sol'; | ||
import {VariableDebtToken} from '../../src/contracts/protocol/tokenization/VariableDebtToken.sol'; | ||
|
||
/** | ||
* Scenario suite for PDP getters. | ||
*/ | ||
contract WrappedTokenGatewayV3_gas_Tests is Testhelpers { | ||
// mock users to supply and borrow liquidity | ||
address user = makeAddr('user'); | ||
|
||
function test_flow() external { | ||
vm.startPrank(user); | ||
deal(user, 2 ether); | ||
(address aEthToken, , address wEthVariableDebt) = contracts | ||
.protocolDataProvider | ||
.getReserveTokensAddresses(tokenList.weth); | ||
|
||
contracts.wrappedTokenGateway.depositETH{value: 1 ether}(address(0), user, 0); | ||
vm.snapshotGasLastCall('WrappedTokenGatewayV3', 'depositETH'); | ||
|
||
_skip(100); | ||
|
||
VariableDebtToken(wEthVariableDebt).approveDelegation( | ||
report.wrappedTokenGateway, | ||
type(uint256).max | ||
); | ||
contracts.wrappedTokenGateway.borrowETH(address(0), 0.1 ether, 0); | ||
vm.snapshotGasLastCall('WrappedTokenGatewayV3', 'borrowETH'); | ||
|
||
_skip(100); | ||
|
||
contracts.wrappedTokenGateway.repayETH{value: 0.2 ether}(address(0), type(uint256).max, user); | ||
vm.snapshotGasLastCall('WrappedTokenGatewayV3', 'repayETH'); | ||
|
||
_skip(100); | ||
|
||
IERC20(aEthToken).approve(report.wrappedTokenGateway, type(uint256).max); | ||
contracts.wrappedTokenGateway.withdrawETH(address(0), type(uint256).max, user); | ||
vm.snapshotGasLastCall('WrappedTokenGatewayV3', 'withdrawETH'); | ||
} | ||
} |