diff --git a/test/e2e/SetUp.sol b/test/e2e/SetUp.sol index 8b13789..8096483 100644 --- a/test/e2e/SetUp.sol +++ b/test/e2e/SetUp.sol @@ -1 +1,73 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity 0.8.24; + +import {DeployForTest, ODTest, COLLAT, DEBT, TKN} from '@opendollar/test/e2e/Common.t.sol'; +import {ERC20ForTest} from '@opendollar/test/mocks/ERC20ForTest.sol'; +import {ISAFEEngine} from '@opendollar/interfaces/ISAFEEngine.sol'; +import {BaseOrderTest} from 'seaport/test/foundry/utils/BaseOrderTest.sol'; +import { + IBaseOracle +} from '@opendollar/interfaces/oracles/IBaseOracle.sol'; + +contract SetUp is DeployForTest, ODTest, BaseOrderTest { + uint256 public constant MINT_AMOUNT = 1000 ether; + uint256 public constant MULTIPLIER = 10; // for over collateralization + uint256 public debtCeiling; + + address public aliceProxy; + address public bobProxy; + + ERC20ForTest public token; + + function setUp() public virtual override { + super.setUp(); + run(); + + for (uint256 i = 0; i < collateralTypes.length; i++) { + bytes32 _cType = collateralTypes[i]; + taxCollector.taxSingle(_cType); + } + + vm.label(deployer, 'Deployer'); + vm.label(alice, 'Alice'); + vm.label(bob, 'Bob'); + + vm.startPrank(deployer); // no governor on test deployment + accountingEngine.modifyParameters('extraSurplusReceiver', abi.encode(address(alice))); + aliceProxy = deployOrFind(alice); + bobProxy = deployOrFind(bob); + vm.label(aliceProxy, 'AliceProxy'); + vm.label(bobProxy, 'BobProxy'); + + token = ERC20ForTest(address(collateral[TKN])); + token.mint(alice, MINT_AMOUNT); + + ISAFEEngine.SAFEEngineParams memory params = safeEngine.params(); + debtCeiling = params.safeDebtCeiling; + } + + function deployOrFind(address owner) public returns (address) { + address proxy = vault721.getProxy(owner); + if (proxy == address(0)) { + return address(vault721.build(owner)); + } else { + return proxy; + } + } + +function _setCollateralPrice(bytes32 _collateral, uint256 _price) internal { + IBaseOracle _oracle = oracleRelayer.cParams(_collateral).oracle; + vm.mockCall( + address(_oracle), abi.encodeWithSelector(IBaseOracle.getResultWithValidity.selector), abi.encode(_price, true) + ); + vm.mockCall(address(_oracle), abi.encodeWithSelector(IBaseOracle.read.selector), abi.encode(_price)); + oracleRelayer.updateCollateralPrice(_collateral); + } + + function _collectFees(bytes32 _cType, uint256 _timeToWarp) internal { + vm.warp(block.timestamp + _timeToWarp); + taxCollector.taxSingle(_cType); + } + +} \ No newline at end of file diff --git a/test/e2e/TestTransferValidationODNFVZoneOffererTest.t.sol b/test/e2e/TestTransferValidationSIP15ZoneOffererTest.t.sol similarity index 98% rename from test/e2e/TestTransferValidationODNFVZoneOffererTest.t.sol rename to test/e2e/TestTransferValidationSIP15ZoneOffererTest.t.sol index 996a273..74336f8 100644 --- a/test/e2e/TestTransferValidationODNFVZoneOffererTest.t.sol +++ b/test/e2e/TestTransferValidationSIP15ZoneOffererTest.t.sol @@ -17,6 +17,7 @@ import { import {UnavailableReason} from 'seaport-sol/src/SpaceEnums.sol'; import {BaseOrderTest} from 'seaport/test/foundry/utils/BaseOrderTest.sol'; +import {SetUp} from './SetUp.sol'; import {ConsiderationInterface} from 'seaport-types/src/interfaces/ConsiderationInterface.sol'; import { @@ -47,7 +48,7 @@ import {IODSafeManager} from '@opendollar/interfaces/proxies/IODSafeManager.sol' import {SIP15Zone} from '../../src/contracts/SIP15Zone.sol'; import {SIP15Encoder, Substandard5Comparison} from '../../src/sips/SIP15Encoder.sol'; -contract TestTransferValidationODNFVZoneOffererTest is BaseOrderTest { +contract TestTransferValidationSIP15ZoneOffererTest is SetUp { using FulfillmentLib for Fulfillment; using FulfillmentComponentLib for FulfillmentComponent; using FulfillmentComponentLib for FulfillmentComponent[]; @@ -64,11 +65,6 @@ contract TestTransferValidationODNFVZoneOffererTest is BaseOrderTest { SIP15Zone zone; TestZone testZone; Vault721Adapter public vault721Adapter; - IVault721 public vault721; - IODSafeManager public safeManager; - - address public vault721Address = address(0x0005AFE00fF7E7FF83667bFe4F2996720BAf0B36); - address public safeManagerAddress = 0x8646CBd915eAAD1a4E2Ba5e2b67Acec4957d5f1a; // constant strings for recalling struct lib defaults // ideally these live in a base test class @@ -77,12 +73,9 @@ contract TestTransferValidationODNFVZoneOffererTest is BaseOrderTest { function setUp() public virtual override { super.setUp(); - vm.createSelectFork(vm.envString('ARB_MAINNET_RPC')); + zone = new SIP15Zone(); - - vault721 = IVault721(vault721Address); vault721Adapter = new Vault721Adapter(vault721); - safeManager = IODSafeManager(safeManagerAddress); matchFulfillmentHelper = new MatchFulfillmentHelper(); fulfillAvailableFulfillmentHelper = new FulfillAvailableHelper(); @@ -1198,12 +1191,12 @@ contract TestTransferValidationODNFVZoneOffererTest is BaseOrderTest { _zoneHash = SIP15Encoder.generateZoneHashForSubstandard5(_substandard5Comparison); } - function deployOrFind(address owner) public returns (address payable) { - address proxy = vault721.getProxy(owner); - if (proxy == address(0)) { - return vault721.build(owner); - } else { - return payable(address(proxy)); - } - } + // function deployOrFind(address owner) public returns (address payable) { + // address proxy = vault721.getProxy(owner); + // if (proxy == address(0)) { + // return vault721.build(owner); + // } else { + // return payable(address(proxy)); + // } + // } }