|
| 1 | +// SPDX-License-Identifier: BUSL-1.1 |
| 2 | +pragma solidity ^0.8.0; |
| 3 | + |
| 4 | +import {Test} from 'forge-std/Test.sol'; |
| 5 | +import {DeployLiquidationDataProvider} from '../../scripts/misc/DeployLiquidationDataProvider.sol'; |
| 6 | +import {ILiquidationDataProvider} from '../../src/contracts/helpers/interfaces/ILiquidationDataProvider.sol'; |
| 7 | + |
| 8 | +contract DeployLiquidationDataProviderForkTest is Test { |
| 9 | + address public constant POOL = 0xAe05Cd22df81871bc7cC2a04BeCfb516bFe332C8; |
| 10 | + address public constant ADDRESSES_PROVIDER = 0x5D39E06b825C1F2B80bf2756a73e28eFAA128ba0; |
| 11 | + |
| 12 | + DeployLiquidationDataProvider internal deployLiquidationDataProvider; |
| 13 | + ILiquidationDataProvider internal liquidationDataProvider; |
| 14 | + |
| 15 | + function setUp() public virtual { |
| 16 | + vm.createSelectFork('mainnet', 23420687); |
| 17 | + |
| 18 | + deployLiquidationDataProvider = new DeployLiquidationDataProvider(); |
| 19 | + liquidationDataProvider = ILiquidationDataProvider( |
| 20 | + deployLiquidationDataProvider.run(POOL, ADDRESSES_PROVIDER) |
| 21 | + ); |
| 22 | + } |
| 23 | + |
| 24 | + function test_getUserPositionFullInfo() public view { |
| 25 | + address user = 0xFf09aAD651888ceFAd81271a79b4Ef7dEC245F49; // sample user with USDC debt |
| 26 | + address USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48; |
| 27 | + ILiquidationDataProvider.UserPositionFullInfo memory userInfo = liquidationDataProvider |
| 28 | + .getUserPositionFullInfo(user); |
| 29 | + |
| 30 | + assertGt(userInfo.healthFactor, 1e18); // healthy health factor |
| 31 | + |
| 32 | + ILiquidationDataProvider.DebtFullInfo memory debtInfo = liquidationDataProvider.getDebtFullInfo( |
| 33 | + user, |
| 34 | + USDC |
| 35 | + ); |
| 36 | + |
| 37 | + assertGt(debtInfo.debtBalanceInBaseCurrency, 0); |
| 38 | + } |
| 39 | + |
| 40 | + function test_deployLiquidationDataProvider() public view { |
| 41 | + assertEq(address(liquidationDataProvider.POOL()), POOL); |
| 42 | + assertEq(address(liquidationDataProvider.ADDRESSES_PROVIDER()), ADDRESSES_PROVIDER); |
| 43 | + } |
| 44 | +} |
0 commit comments