Skip to content

Commit

Permalink
setup collateral testing environment
Browse files Browse the repository at this point in the history
  • Loading branch information
daopunk committed May 24, 2024
1 parent 07e5917 commit 326cd82
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 14 deletions.
81 changes: 81 additions & 0 deletions test/e2e/E2ELiquidationFee.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

Check warning on line 2 in test/e2e/E2ELiquidationFee.t.sol

View workflow job for this annotation

GitHub Actions / Run Linters (18.x)

Found more than One contract per file. 2 contracts found!

import {Math} from '@opendollar/libraries/Math.sol';

Check warning on line 4 in test/e2e/E2ELiquidationFee.t.sol

View workflow job for this annotation

GitHub Actions / Run Linters (18.x)

imported name Math is not used
import {ERC20ForTest} from '@opendollar/test/mocks/ERC20ForTest.sol';
import {Common, TKN, TEST_TKN_PRICE} from '@opendollar/test/e2e/Common.t.sol';

Check warning on line 6 in test/e2e/E2ELiquidationFee.t.sol

View workflow job for this annotation

GitHub Actions / Run Linters (18.x)

imported name TKN is not used
import {DelayedOracleForTest} from '@opendollar/test/mocks/DelayedOracleForTest.sol';
import {IDelayedOracle} from '@opendollar/interfaces/oracles/IDelayedOracle.sol';

Check warning on line 8 in test/e2e/E2ELiquidationFee.t.sol

View workflow job for this annotation

GitHub Actions / Run Linters (18.x)

imported name IDelayedOracle is not used
import {IOracleRelayer} from '@opendollar/interfaces/IOracleRelayer.sol';
import {ITaxCollector} from '@opendollar/interfaces/ITaxCollector.sol';
import {ISAFEEngine} from '@opendollar/interfaces/ISAFEEngine.sol';
import {ILiquidationEngine} from '@opendollar/interfaces/ILiquidationEngine.sol';
import {ICollateralAuctionHouse} from '@opendollar/interfaces/ICollateralAuctionHouse.sol';
import {IAuthorizable} from '@opendollar/interfaces/utils/IAuthorizable.sol';
import {Data} from 'test/e2e/utils/Data.t.sol';

uint256 constant RAD = 1e45;
uint256 constant RAY = 1e27;
uint256 constant WAD = 1e18;
uint256 constant MINUS_0_5_PERCENT_PER_HOUR = 999_998_607_628_240_588_157_433_861;

contract E2ELiquidationFeeSetup is Common, Data {
/**
* @notice testing for Super Over-Collateralized (SOC) Token
* 0x534f430000000000000000000000000000000000000000000000000000000000
*/
bytes32 public constant SOC = bytes32('SOC');

function setUp() public virtual override {
super.setUp();
collateral[SOC] = new ERC20ForTest();
delayedOracle[SOC] = new DelayedOracleForTest(TEST_TKN_PRICE, address(0xabcdef));
collateralTypes.push(SOC);

_collateralAuctionHouseParams[SOC] = ICollateralAuctionHouse.CollateralAuctionHouseParams({
minimumBid: 1,
minDiscount: WAD,
maxDiscount: 0.9e18,
perSecondDiscountUpdateRate: MINUS_0_5_PERCENT_PER_HOUR
});

vm.startPrank(tlcGov);
collateralJoin[SOC] = collateralJoinFactory.deployCollateralJoin(SOC, address(collateral[SOC]));
collateralAuctionHouseFactory.initializeCollateralType(SOC, abi.encode(_collateralAuctionHouseParams[SOC]));
collateralAuctionHouse[SOC] = ICollateralAuctionHouse(collateralAuctionHouseFactory.collateralAuctionHouses(SOC));
vm.stopPrank();

_oracleRelayerCParams[SOC] = IOracleRelayer.OracleRelayerCollateralParams({
oracle: delayedOracle[SOC],
safetyCRatio: 1.35e27,
liquidationCRatio: 1.25e27
});

_taxCollectorCParams[SOC] = ITaxCollector.TaxCollectorCollateralParams({stabilityFee: RAY + 1.54713e18});

_safeEngineCParams[SOC] = ISAFEEngine.SAFEEngineCollateralParams({debtCeiling: 1_000_000_000 * RAD, debtFloor: 0});

_liquidationEngineCParams[SOC] = ILiquidationEngine.LiquidationEngineCollateralParams({
collateralAuctionHouse: address(collateralAuctionHouse[SOC]),
liquidationPenalty: 1.1e18,
liquidationQuantity: 100_000e45
});

vm.startPrank(tlcGov);
_setupCollateral(SOC);
vm.stopPrank();
}
}

contract E2ELiquidationFeeTestSetup is E2ELiquidationFeeSetup {
function test_cTypes() public {
bytes32[] memory cTypes = collateralJoinFactory.collateralTypesList(); // bytes32 collateralTypes in the protocol
bytes32[] memory cList = collateralAuctionHouseFactory.collateralList(); // bytes32 collateralTypes for collateral auction
uint256 _l = cTypes.length;
assertEq(_l, cList.length);
for (uint256 _i = 0; _i < _l; _i++) {
assertTrue(cTypes[_i] == cList[_i]);
}
assertEq(cTypes[_l - 1], SOC);
}
}
16 changes: 2 additions & 14 deletions test/e2e/E2ESaviour.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,9 @@ import {ERC20ForTest} from '@opendollar/test/mocks/ERC20ForTest.sol';
import {Common, TKN} from '@opendollar/test/e2e/Common.t.sol';
import {ODSaviour} from 'src/contracts/ODSaviour.sol';
import {IODSaviour} from 'src/interfaces/IODSaviour.sol';
import {Data} from 'test/e2e/utils/Data.t.sol';

contract E2ESaviourSetup is Common {
uint256 public constant TREASURY_AMOUNT = 1_000_000_000_000_000_000_000_000_000 ether;
uint256 public constant PROTOCOL_AMOUNT = 1_000_000_000 ether;
uint256 public constant USER_AMOUNT = 1000 ether;

ODSaviour public saviour;
address public treasury;

address public aliceProxy;
address public bobProxy;
address public deployerProxy;

mapping(address proxy => uint256 safeId) public vaults;

contract E2ESaviourSetup is Common, Data {
function setUp() public virtual override {
super.setUp();
treasury = vm.addr(uint256(keccak256('ARB Treasury')));
Expand Down
19 changes: 19 additions & 0 deletions test/e2e/utils/Data.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.20;

import {ODSaviour} from 'src/contracts/ODSaviour.sol';

contract Data {
uint256 public constant TREASURY_AMOUNT = 1_000_000_000_000_000_000_000_000_000 ether;
uint256 public constant PROTOCOL_AMOUNT = 1_000_000_000 ether;
uint256 public constant USER_AMOUNT = 1000 ether;

ODSaviour public saviour;
address public treasury;

address public aliceProxy;
address public bobProxy;
address public deployerProxy;

mapping(address proxy => uint256 safeId) public vaults;
}

0 comments on commit 326cd82

Please sign in to comment.