diff --git a/.circleci/config.yml b/.circleci/config.yml index 1492585..cbc5fab 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,13 +37,13 @@ jobs: # a collection of steps command: yarn lint - restore_cache: # restore the Hardhat Network Fork Cache name: Restore Hardhat Network Fork Cache - key: v2-hardhat-network-fork-cache + key: v3-hardhat-network-fork-cache - run: # Tests name: Tests using hardhat mainnet fork and gas reporter command: yarn test:gas - save_cache: # special step to save the Hardhat Network Fork cache name: Save Hardhat Network Fork Cache - key: v2-hardhat-network-fork-cache + key: v3-hardhat-network-fork-cache paths: - ./cache/hardhat-network-fork - run: # Codechecks diff --git a/.prettierignore b/.prettierignore index da5fa0f..10fda71 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,5 +2,4 @@ artifacts cache assets -coverage -contracts/vendor \ No newline at end of file +coverage \ No newline at end of file diff --git a/tool/config/mainnet-deployments.js b/_hardhat/config/mainnet-deployments.js similarity index 100% rename from tool/config/mainnet-deployments.js rename to _hardhat/config/mainnet-deployments.js diff --git a/contracts/contracts/gelato/conditions/ConditionIsDestVaultWillBeSafe.sol b/contracts/contracts/gelato/conditions/ConditionDestVaultWillBeSafe.sol similarity index 82% rename from contracts/contracts/gelato/conditions/ConditionIsDestVaultWillBeSafe.sol rename to contracts/contracts/gelato/conditions/ConditionDestVaultWillBeSafe.sol index 30aa6a7..3c99f20 100644 --- a/contracts/contracts/gelato/conditions/ConditionIsDestVaultWillBeSafe.sol +++ b/contracts/contracts/gelato/conditions/ConditionDestVaultWillBeSafe.sol @@ -8,23 +8,22 @@ import { import { _getMakerVaultDebt, _getMakerVaultCollateralBalance, - _isVaultWillBeSafe, - _isNewVaultWillBeSafe + _vaultWillBeSafe, + _newVaultWillBeSafe } from "../../../functions/dapps/FMaker.sol"; import { _getRealisedDebt } from "../../../functions/gelato/FGelatoDebtBridge.sol"; import {GelatoBytes} from "../../../lib/GelatoBytes.sol"; -import "hardhat/console.sol"; -contract ConditionIsDestVaultWillBeSafe is GelatoConditionsStandard { +contract ConditionDestVaultWillBeSafe is GelatoConditionsStandard { using GelatoBytes for bytes; function getConditionData( uint256 _fromVaultId, uint256 _destVaultId, - string memory _destColType + string calldata _destColType ) public pure virtual returns (bytes memory) { return abi.encode(_fromVaultId, _destVaultId, _destColType); } @@ -53,7 +52,7 @@ contract ConditionIsDestVaultWillBeSafe is GelatoConditionsStandard { uint256 wColToDeposit = _getMakerVaultCollateralBalance(_fromVaultId); return - isDestVaultWillBeSafe( + destVaultWillBeSafeExplicit( _destVaultId, wDaiToBorrow, wColToDeposit, @@ -63,7 +62,7 @@ contract ConditionIsDestVaultWillBeSafe is GelatoConditionsStandard { : "DestVaultWillNotBeSafe"; } - function isDestVaultWillBeSafe( + function destVaultWillBeSafeExplicit( uint256 _vaultId, uint256 _wDaiToBorrow, uint256 _wColToDeposit, @@ -71,7 +70,7 @@ contract ConditionIsDestVaultWillBeSafe is GelatoConditionsStandard { ) public view returns (bool) { return _vaultId == 0 - ? _isNewVaultWillBeSafe(_colType, _wDaiToBorrow, _wColToDeposit) - : _isVaultWillBeSafe(_vaultId, _wDaiToBorrow, _wColToDeposit); + ? _newVaultWillBeSafe(_colType, _wDaiToBorrow, _wColToDeposit) + : _vaultWillBeSafe(_vaultId, _wDaiToBorrow, _wColToDeposit); } } diff --git a/contracts/contracts/resolvers/MakerResolver.sol b/contracts/contracts/resolvers/MakerResolver.sol index 6dd07f1..d249413 100644 --- a/contracts/contracts/resolvers/MakerResolver.sol +++ b/contracts/contracts/resolvers/MakerResolver.sol @@ -5,8 +5,8 @@ import { _getMakerRawVaultDebt, _getMakerVaultDebt, _getMakerVaultCollateralBalance, - _isVaultWillBeSafe, - _isNewVaultWillBeSafe + _vaultWillBeSafe, + _newVaultWillBeSafe } from "../../functions/dapps/FMaker.sol"; contract MakerResolver { @@ -32,19 +32,19 @@ contract MakerResolver { return _getMakerVaultCollateralBalance(_vaultId); } - function isVaultWillBeSafe( + function vaultWillBeSafe( uint256 _vaultId, uint256 _amtToBorrow, uint256 _colToDeposit ) public view returns (bool) { - return _isVaultWillBeSafe(_vaultId, _amtToBorrow, _colToDeposit); + return _vaultWillBeSafe(_vaultId, _amtToBorrow, _colToDeposit); } - function isNewVaultWillBeSafe( + function newVaultWillBeSafe( string memory _colType, uint256 _amtToBorrow, uint256 _colToDeposit ) public view returns (bool) { - return _isNewVaultWillBeSafe(_colType, _amtToBorrow, _colToDeposit); + return _newVaultWillBeSafe(_colType, _amtToBorrow, _colToDeposit); } } diff --git a/contracts/functions/dapps/FMaker.sol b/contracts/functions/dapps/FMaker.sol index f3ce747..e875103 100644 --- a/contracts/functions/dapps/FMaker.sol +++ b/contracts/functions/dapps/FMaker.sol @@ -54,12 +54,12 @@ function _getMakerVaultCollateralBalance(uint256 _vaultId) return ink; } -function _isVaultWillBeSafe( +function _vaultWillBeSafe( uint256 _vaultId, uint256 _amtToBorrow, uint256 _colToDeposit ) view returns (bool) { - require(_vaultId != 0, "_isVaultWillBeSafe: invalid vault id."); + require(_vaultId != 0, "_vaultWillBeSafe: invalid vault id."); IMcdManager manager = IMcdManager(MCD_MANAGER); @@ -84,7 +84,7 @@ function _isVaultWillBeSafe( return tab <= mul(ink, spot); } -function _isNewVaultWillBeSafe( +function _newVaultWillBeSafe( string memory _colType, uint256 _amtToBorrow, uint256 _colToDeposit diff --git a/contracts/interfaces/dapps/Maker/ITokenJoinInterface.sol b/contracts/interfaces/dapps/Maker/ITokenJoinInterface.sol index f51c661..1eb233f 100644 --- a/contracts/interfaces/dapps/Maker/ITokenJoinInterface.sol +++ b/contracts/interfaces/dapps/Maker/ITokenJoinInterface.sol @@ -1,6 +1,5 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.4; -pragma experimental ABIEncoderV2; interface ITokenJoinInterface { function dec() external view returns (uint256); diff --git a/contracts/vendor/Address.sol b/contracts/vendor/Address.sol index 0ed6b65..5a43156 100644 --- a/contracts/vendor/Address.sol +++ b/contracts/vendor/Address.sol @@ -145,9 +145,8 @@ library Address { require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls - (bool success, bytes memory returndata) = target.call{value: value}( - data - ); + (bool success, bytes memory returndata) = + target.call{value: value}(data); return _verifyCallResult(success, returndata, errorMessage); } @@ -173,4 +172,4 @@ library Address { } } } -} \ No newline at end of file +} diff --git a/contracts/vendor/Convert.sol b/contracts/vendor/Convert.sol index 3115376..dfadec3 100644 --- a/contracts/vendor/Convert.sol +++ b/contracts/vendor/Convert.sol @@ -1,19 +1,15 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity 0.7.4; -import {RAY, add, sub, mul} from "./DSMath.sol"; +import {mul as _mul} from "./DSMath.sol"; - function _stringToBytes32(string memory str) - pure - returns (bytes32 result) - { - require(bytes(str).length != 0, "string-empty"); - assembly { - result := mload(add(str, 32)) - } +function _stringToBytes32(string memory str) pure returns (bytes32 result) { + require(bytes(str).length != 0, "string-empty"); + assembly { + result := mload(add(str, 32)) } +} - function _convertTo18(uint256 _dec, uint256 _amt) - pure returns (uint256 amt) { - amt = mul(_amt, 10**(18 - _dec)); - } \ No newline at end of file +function _convertTo18(uint256 _dec, uint256 _amt) pure returns (uint256 amt) { + amt = _mul(_amt, 10**(18 - _dec)); +} diff --git a/contracts/vendor/DSMath.sol b/contracts/vendor/DSMath.sol index bcfe15a..bfef3db 100644 --- a/contracts/vendor/DSMath.sol +++ b/contracts/vendor/DSMath.sol @@ -16,46 +16,54 @@ pragma solidity 0.7.4; -function add(uint x, uint y) pure returns (uint z) { +function add(uint256 x, uint256 y) pure returns (uint256 z) { require((z = x + y) >= x, "ds-math-add-overflow"); } -function sub(uint x, uint y) pure returns (uint z) { + +function sub(uint256 x, uint256 y) pure returns (uint256 z) { require((z = x - y) <= x, "ds-math-sub-underflow"); } -function mul(uint x, uint y) pure returns (uint z) { + +function mul(uint256 x, uint256 y) pure returns (uint256 z) { require(y == 0 || (z = x * y) / y == x, "ds-math-mul-overflow"); } -function min(uint x, uint y) pure returns (uint z) { +function min(uint256 x, uint256 y) pure returns (uint256 z) { return x <= y ? x : y; } -function max(uint x, uint y) pure returns (uint z) { - return x >= y ? x : y; -} -function imin(int x, int y) pure returns (int z) { - return x <= y ? x : y; -} -function imax(int x, int y) pure returns (int z) { + +function max(uint256 x, uint256 y) pure returns (uint256 z) { return x >= y ? x : y; } -uint constant WAD = 10 ** 18; -uint constant RAY = 10 ** 27; +function imin(int256 x, int256 y) pure returns (int256 z) { + return x <= y ? x : y; +} + +function imax(int256 x, int256 y) pure returns (int256 z) { + return x >= y ? x : y; +} + +uint256 constant WAD = 10**18; +uint256 constant RAY = 10**27; //rounds to zero if x*y < WAD / 2 -function wmul(uint x, uint y) pure returns (uint z) { +function wmul(uint256 x, uint256 y) pure returns (uint256 z) { z = add(mul(x, y), WAD / 2) / WAD; } + //rounds to zero if x*y < WAD / 2 -function rmul(uint x, uint y) pure returns (uint z) { +function rmul(uint256 x, uint256 y) pure returns (uint256 z) { z = add(mul(x, y), RAY / 2) / RAY; } + //rounds to zero if x*y < WAD / 2 -function wdiv(uint x, uint y) pure returns (uint z) { +function wdiv(uint256 x, uint256 y) pure returns (uint256 z) { z = add(mul(x, WAD), y / 2) / y; } + //rounds to zero if x*y < RAY / 2 -function rdiv(uint x, uint y) pure returns (uint z) { +function rdiv(uint256 x, uint256 y) pure returns (uint256 z) { z = add(mul(x, RAY), y / 2) / y; } @@ -74,7 +82,7 @@ function rdiv(uint x, uint y) pure returns (uint z) { // Also, EVM division is flooring and // floor[(n-1) / 2] = floor[n / 2]. // -function rpow(uint x, uint n) pure returns (uint z) { +function rpow(uint256 x, uint256 n) pure returns (uint256 z) { z = n % 2 != 0 ? x : RAY; for (n /= 2; n != 0; n /= 2) { diff --git a/contracts/vendor/IERC20.sol b/contracts/vendor/IERC20.sol index 823643e..b604f05 100644 --- a/contracts/vendor/IERC20.sol +++ b/contracts/vendor/IERC20.sol @@ -22,7 +22,9 @@ interface IERC20 { * * Emits a {Transfer} event. */ - function transfer(address recipient, uint256 amount) external returns (bool); + function transfer(address recipient, uint256 amount) + external + returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be @@ -31,7 +33,10 @@ interface IERC20 { * * This value changes when {approve} or {transferFrom} are called. */ - function allowance(address owner, address spender) external view returns (uint256); + function allowance(address owner, address spender) + external + view + returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. @@ -58,7 +63,11 @@ interface IERC20 { * * Emits a {Transfer} event. */ - function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); + function transferFrom( + address sender, + address recipient, + uint256 amount + ) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to @@ -72,5 +81,9 @@ interface IERC20 { * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ - event Approval(address indexed owner, address indexed spender, uint256 value); -} \ No newline at end of file + event Approval( + address indexed owner, + address indexed spender, + uint256 value + ); +} diff --git a/contracts/vendor/SafeERC20.sol b/contracts/vendor/SafeERC20.sol index 9c420fa..5a69674 100644 --- a/contracts/vendor/SafeERC20.sol +++ b/contracts/vendor/SafeERC20.sol @@ -18,12 +18,27 @@ library SafeERC20 { using SafeMath for uint256; using Address for address; - function safeTransfer(IERC20 token, address to, uint256 value) internal { - _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value)); + function safeTransfer( + IERC20 token, + address to, + uint256 value + ) internal { + _callOptionalReturn( + token, + abi.encodeWithSelector(token.transfer.selector, to, value) + ); } - function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal { - _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value)); + function safeTransferFrom( + IERC20 token, + address from, + address to, + uint256 value + ) internal { + _callOptionalReturn( + token, + abi.encodeWithSelector(token.transferFrom.selector, from, to, value) + ); } /** @@ -33,25 +48,60 @@ library SafeERC20 { * Whenever possible, use {safeIncreaseAllowance} and * {safeDecreaseAllowance} instead. */ - function safeApprove(IERC20 token, address spender, uint256 value) internal { + function safeApprove( + IERC20 token, + address spender, + uint256 value + ) internal { // safeApprove should only be called when setting an initial allowance, // or when resetting it to zero. To increase and decrease it, use // 'safeIncreaseAllowance' and 'safeDecreaseAllowance' // solhint-disable-next-line max-line-length - require((value == 0) || (token.allowance(address(this), spender) == 0), + require( + (value == 0) || (token.allowance(address(this), spender) == 0), "SafeERC20: approve from non-zero to non-zero allowance" ); - _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value)); + _callOptionalReturn( + token, + abi.encodeWithSelector(token.approve.selector, spender, value) + ); } - function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal { - uint256 newAllowance = token.allowance(address(this), spender).add(value); - _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); + function safeIncreaseAllowance( + IERC20 token, + address spender, + uint256 value + ) internal { + uint256 newAllowance = + token.allowance(address(this), spender).add(value); + _callOptionalReturn( + token, + abi.encodeWithSelector( + token.approve.selector, + spender, + newAllowance + ) + ); } - function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal { - uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero"); - _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance)); + function safeDecreaseAllowance( + IERC20 token, + address spender, + uint256 value + ) internal { + uint256 newAllowance = + token.allowance(address(this), spender).sub( + value, + "SafeERC20: decreased allowance below zero" + ); + _callOptionalReturn( + token, + abi.encodeWithSelector( + token.approve.selector, + spender, + newAllowance + ) + ); } /** @@ -65,10 +115,18 @@ library SafeERC20 { // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that // the target address contains contract code and also asserts for success in the low-level call. - bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed"); - if (returndata.length > 0) { // Return data is optional + bytes memory returndata = + address(token).functionCall( + data, + "SafeERC20: low-level call failed" + ); + if (returndata.length > 0) { + // Return data is optional // solhint-disable-next-line max-line-length - require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed"); + require( + abi.decode(returndata, (bool)), + "SafeERC20: ERC20 operation did not succeed" + ); } } -} \ No newline at end of file +} diff --git a/contracts/vendor/SafeMath.sol b/contracts/vendor/SafeMath.sol index db2b907..adf5019 100644 --- a/contracts/vendor/SafeMath.sol +++ b/contracts/vendor/SafeMath.sol @@ -56,7 +56,11 @@ library SafeMath { * * - Subtraction cannot overflow. */ - function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + function sub( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; @@ -115,7 +119,11 @@ library SafeMath { * * - The divisor cannot be zero. */ - function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + function div( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold @@ -151,8 +159,12 @@ library SafeMath { * * - The divisor cannot be zero. */ - function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { + function mod( + uint256 a, + uint256 b, + string memory errorMessage + ) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } -} \ No newline at end of file +} diff --git a/deploy/gelato/conditions/ConditionIsDestVaultWillBeSafe.deploy.js b/deploy/gelato/conditions/ConditionDestVaultWillBeSafe.deploy.js similarity index 70% rename from deploy/gelato/conditions/ConditionIsDestVaultWillBeSafe.deploy.js rename to deploy/gelato/conditions/ConditionDestVaultWillBeSafe.deploy.js index 96cd639..d62a839 100644 --- a/deploy/gelato/conditions/ConditionIsDestVaultWillBeSafe.deploy.js +++ b/deploy/gelato/conditions/ConditionDestVaultWillBeSafe.deploy.js @@ -3,7 +3,7 @@ const { sleep } = require("@gelatonetwork/core"); module.exports = async (hre) => { if (hre.network.name === "mainnet") { console.log( - "Deploying ConditionIsDestVaultWillBeSafe to mainnet. Hit ctrl + c to abort" + "Deploying ConditionDestVaultWillBeSafe to mainnet. Hit ctrl + c to abort" ); await sleep(10000); } @@ -12,9 +12,9 @@ module.exports = async (hre) => { const { deploy } = deployments; const { deployer } = await hre.getNamedAccounts(); - // the following will only deploy "ConditionIsDestVaultWillBeSafe" + // the following will only deploy "ConditionDestVaultWillBeSafe" // if the contract was never deployed or if the code changed since last deployment - await deploy("ConditionIsDestVaultWillBeSafe", { + await deploy("ConditionDestVaultWillBeSafe", { from: deployer, gasPrice: hre.network.config.gasPrice, log: hre.network.name === "mainnet" ? true : false, @@ -24,4 +24,4 @@ module.exports = async (hre) => { module.exports.skip = async (hre) => { return hre.network.name === "mainnet" ? true : false; }; -module.exports.tags = ["ConditionIsDestVaultWillBeSafe"]; +module.exports.tags = ["ConditionDestVaultWillBeSafe"]; diff --git a/hardhat.config.js b/hardhat.config.js index 3105810..de18347 100644 --- a/hardhat.config.js +++ b/hardhat.config.js @@ -12,7 +12,7 @@ const { utils } = require("ethers"); const GelatoCoreLib = require("@gelatonetwork/core"); -const mainnetDeployments = require("./tool/config/mainnet-deployments"); +const mainnetDeployments = require("./_hardhat/config/mainnet-deployments"); // Process Env Variables require("dotenv").config(); diff --git a/test/gas/debt_bridge/full/from_maker/1_ETHA-ETHB-WITH-Vault-Creation.mock.test.js b/test/gas/debt_bridge/full/from_maker/1_ETHA-ETHB-WITH-Vault-Creation.mock.test.js index d48febf..59aabcd 100644 --- a/test/gas/debt_bridge/full/from_maker/1_ETHA-ETHB-WITH-Vault-Creation.mock.test.js +++ b/test/gas/debt_bridge/full/from_maker/1_ETHA-ETHB-WITH-Vault-Creation.mock.test.js @@ -24,7 +24,7 @@ describe("Gas Measurements: Full Debt Bridge From Maker ETH-A to ETH-B", functio let conditionMakerVaultUnsafeObj; let conditionDebtBridgeIsAffordableObj; - let conditionIsDestVaultWillBeSafe; + let conditionDestVaultWillBeSafe; // For TaskSpec and for Task let gelatoDebtBridgeSpells = []; @@ -84,9 +84,9 @@ describe("Gas Measurements: Full Debt Bridge From Maker ETH-A to ETH-B", functio ), }); - conditionIsDestVaultWillBeSafe = new GelatoCoreLib.Condition({ - inst: contracts.conditionIsDestVaultWillBeSafe.address, - data: await contracts.conditionIsDestVaultWillBeSafe.getConditionData( + conditionDestVaultWillBeSafe = new GelatoCoreLib.Condition({ + inst: contracts.conditionDestVaultWillBeSafe.address, + data: await contracts.conditionDestVaultWillBeSafe.getConditionData( vaultAId, vaultBId, "ETH-B" @@ -97,7 +97,7 @@ describe("Gas Measurements: Full Debt Bridge From Maker ETH-A to ETH-B", functio conditions: [ conditionMakerVaultUnsafeObj, conditionDebtBridgeIsAffordableObj, - conditionIsDestVaultWillBeSafe, + conditionDestVaultWillBeSafe, ], actions: gelatoDebtBridgeSpells, }); diff --git a/test/gas/debt_bridge/full/from_maker/helpers/services/getSpells-ETHA-ETHB-With-Vault-Creation.mock.js b/test/gas/debt_bridge/full/from_maker/helpers/services/getSpells-ETHA-ETHB-With-Vault-Creation.mock.js index f107fa4..6fb5866 100644 --- a/test/gas/debt_bridge/full/from_maker/helpers/services/getSpells-ETHA-ETHB-With-Vault-Creation.mock.js +++ b/test/gas/debt_bridge/full/from_maker/helpers/services/getSpells-ETHA-ETHB-With-Vault-Creation.mock.js @@ -41,7 +41,7 @@ module.exports = async function ( conditions: [ contracts.conditionMakerVaultUnsafe.address, contracts.conditionDebtBridgeIsAffordable.address, - contracts.conditionIsDestVaultWillBeSafe.address, + contracts.conditionDestVaultWillBeSafe.address, ], actions: spells, gasPriceCeil, diff --git a/test/helpers/services/getContracts.js b/test/helpers/services/getContracts.js index 644b737..21373eb 100644 --- a/test/helpers/services/getContracts.js +++ b/test/helpers/services/getContracts.js @@ -113,8 +113,8 @@ module.exports = async function () { "MockConnectGelatoDataFullRefinanceMaker" ); - const conditionIsDestVaultWillBeSafe = await ethers.getContract( - "ConditionIsDestVaultWillBeSafe" + const conditionDestVaultWillBeSafe = await ethers.getContract( + "ConditionDestVaultWillBeSafe" ); return { @@ -145,6 +145,6 @@ module.exports = async function () { conditionDebtBridgeIsAffordable, mockDebtBridgeETHBExecutor, mockConnectGelatoDataFullRefinanceMaker, - conditionIsDestVaultWillBeSafe, + conditionDestVaultWillBeSafe, }; }; diff --git a/test/integration/debt_bridge/from_maker/full/1_ETHA-ETHB-With-Vault-Creation.test.js b/test/integration/debt_bridge/from_maker/full/1_ETHA-ETHB-With-Vault-Creation.test.js index cf48a11..48728db 100644 --- a/test/integration/debt_bridge/from_maker/full/1_ETHA-ETHB-With-Vault-Creation.test.js +++ b/test/integration/debt_bridge/from_maker/full/1_ETHA-ETHB-With-Vault-Creation.test.js @@ -102,9 +102,9 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B with vault creat ), }); - const conditionIsDestVaultWillBeSafe = new GelatoCoreLib.Condition({ - inst: contracts.conditionIsDestVaultWillBeSafe.address, - data: await contracts.conditionIsDestVaultWillBeSafe.getConditionData( + const conditionDestVaultWillBeSafe = new GelatoCoreLib.Condition({ + inst: contracts.conditionDestVaultWillBeSafe.address, + data: await contracts.conditionDestVaultWillBeSafe.getConditionData( vaultAId, 0, "ETH-B" @@ -116,7 +116,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B with vault creat conditions: [ conditionMakerVaultUnsafeObj, conditionDebtBridgeIsAffordableObj, - conditionIsDestVaultWillBeSafe, + conditionDestVaultWillBeSafe, ], actions: gelatoDebtBridgeSpells, }); diff --git a/test/integration/debt_bridge/from_maker/full/2_ETHA-ETHB.test.js b/test/integration/debt_bridge/from_maker/full/2_ETHA-ETHB.test.js index bb34b0e..b00fbf2 100644 --- a/test/integration/debt_bridge/from_maker/full/2_ETHA-ETHB.test.js +++ b/test/integration/debt_bridge/from_maker/full/2_ETHA-ETHB.test.js @@ -104,9 +104,9 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () { ), }); - const conditionIsDestVaultWillBeSafe = new GelatoCoreLib.Condition({ - inst: contracts.conditionIsDestVaultWillBeSafe.address, - data: await contracts.conditionIsDestVaultWillBeSafe.getConditionData( + const conditionDestVaultWillBeSafe = new GelatoCoreLib.Condition({ + inst: contracts.conditionDestVaultWillBeSafe.address, + data: await contracts.conditionDestVaultWillBeSafe.getConditionData( vaultAId, vaultBId, "ETH-B" @@ -118,7 +118,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () { conditions: [ conditionMakerVaultUnsafeObj, conditionDebtBridgeIsAffordableObj, - conditionIsDestVaultWillBeSafe, + conditionDestVaultWillBeSafe, ], actions: gelatoDebtBridgeSpells, }); diff --git a/test/integration/debt_bridge/from_maker/full/helpers/services/getSpells-ETHA-ETHB-With-Vault-Creation.js b/test/integration/debt_bridge/from_maker/full/helpers/services/getSpells-ETHA-ETHB-With-Vault-Creation.js index a0698aa..22ac551 100644 --- a/test/integration/debt_bridge/from_maker/full/helpers/services/getSpells-ETHA-ETHB-With-Vault-Creation.js +++ b/test/integration/debt_bridge/from_maker/full/helpers/services/getSpells-ETHA-ETHB-With-Vault-Creation.js @@ -35,7 +35,7 @@ module.exports = async function (wallets, contracts, constants, vaultId) { conditions: [ contracts.conditionMakerVaultUnsafe.address, contracts.conditionDebtBridgeIsAffordable.address, - contracts.conditionIsDestVaultWillBeSafe.address, + contracts.conditionDestVaultWillBeSafe.address, ], actions: spells, gasPriceCeil, diff --git a/test/integration/debt_bridge/from_maker/full/helpers/services/getSpells-ETHA-ETHB.js b/test/integration/debt_bridge/from_maker/full/helpers/services/getSpells-ETHA-ETHB.js index d1d5365..ccb6e72 100644 --- a/test/integration/debt_bridge/from_maker/full/helpers/services/getSpells-ETHA-ETHB.js +++ b/test/integration/debt_bridge/from_maker/full/helpers/services/getSpells-ETHA-ETHB.js @@ -41,7 +41,7 @@ module.exports = async function ( conditions: [ contracts.conditionMakerVaultUnsafe.address, contracts.conditionDebtBridgeIsAffordable.address, - contracts.conditionIsDestVaultWillBeSafe.address, + contracts.conditionDestVaultWillBeSafe.address, ], actions: spells, gasPriceCeil, diff --git a/test/unit/conditions/2_ConditionIsDestVaultWillBeSafe.test.js b/test/unit/conditions/2_ConditionIsDestVaultWillBeSafe.test.js index 0fcb786..218b11f 100644 --- a/test/unit/conditions/2_ConditionIsDestVaultWillBeSafe.test.js +++ b/test/unit/conditions/2_ConditionIsDestVaultWillBeSafe.test.js @@ -15,7 +15,7 @@ const IERC20 = require("../../../pre-compiles/IERC20.json"); // #endregion -describe("ConditionIsDestVaultWillBeSafe Unit Test", function () { +describe("ConditionDestVaultWillBeSafe Unit Test", function () { this.timeout(0); if (hre.network.name !== "hardhat") { console.error("Test Suite is meant to be run on hardhat only"); @@ -32,7 +32,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () { let DAI; let vat; - let conditionIsDestVaultWillBeSafe; + let conditionDestVaultWillBeSafe; let dsa; let cdpId; @@ -73,8 +73,8 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () { DAI = await ethers.getContractAt(IERC20.abi, hre.network.config.DAI); // ========== Test Setup ============ - conditionIsDestVaultWillBeSafe = await ethers.getContract( - "ConditionIsDestVaultWillBeSafe" + conditionDestVaultWillBeSafe = await ethers.getContract( + "ConditionDestVaultWillBeSafe" ); // Create DeFi Smart Account @@ -144,18 +144,18 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () { }); it("#1: ok should return DebtBridgeNotAffordable when the gas fees exceed a define amount", async function () { - const conditionData = await conditionIsDestVaultWillBeSafe.getConditionData( + const conditionData = await conditionDestVaultWillBeSafe.getConditionData( cdpId, 0, "ETH-B" ); expect( - await conditionIsDestVaultWillBeSafe.ok(0, conditionData, 0) + await conditionDestVaultWillBeSafe.ok(0, conditionData, 0) ).to.be.equal("OK"); }); - it("#2: New Vault Case : isDestVaultWillBeSafe should return false when col is lower than borrow amount / spot", async function () { - var amountOfColToDepo = amountToBorrow + it("#2: New Vault Case : destVaultWillBeSafeExplicit should return false when col is lower than borrow amount / spot", async function () { + let amountOfColToDepo = amountToBorrow .mul(ilk[1]) .div(ethers.utils.parseUnits("1", 27)); amountOfColToDepo = amountOfColToDepo @@ -164,7 +164,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () { .div(ilk[2]); expect( - await conditionIsDestVaultWillBeSafe.isDestVaultWillBeSafe( + await conditionDestVaultWillBeSafe.destVaultWillBeSafeExplicit( 0, amountToBorrow, amountOfColToDepo, @@ -173,7 +173,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () { ).to.be.false; }); - it("#3: New Vault Case : isDestVaultWillBeSafe should return true when col is greater than borrow amount / spot", async function () { + it("#3: New Vault Case : destVaultWillBeSafeExplicit should return true when col is greater than borrow amount / spot", async function () { let amountOfColToDepo = amountToBorrow .mul(ilk[1]) .div(ethers.utils.parseUnits("1", 27)); @@ -183,7 +183,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () { .div(ilk[2]); expect( - await conditionIsDestVaultWillBeSafe.isDestVaultWillBeSafe( + await conditionDestVaultWillBeSafe.destVaultWillBeSafeExplicit( 0, amountToBorrow, amountOfColToDepo, @@ -192,7 +192,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () { ).to.be.true; }); - it("#4: Old Vault Case : isDestVaultWillBeSafe should return false when col is lower than borrow amount / spot", async function () { + it("#4: Old Vault Case : destVaultWillBeSafeExplicit should return false when col is lower than borrow amount / spot", async function () { const openVault = await hre.run("abi-encode-withselector", { abi: ConnectMaker.abi, functionname: "open", @@ -214,7 +214,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () { .div(ilk[2]); expect( - await conditionIsDestVaultWillBeSafe.isDestVaultWillBeSafe( + await conditionDestVaultWillBeSafe.destVaultWillBeSafeExplicit( cdpIdB, amountToBorrow, amountOfColToDepo, @@ -223,7 +223,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () { ).to.be.false; }); - it("#5: Old Vault Case : isDestVaultWillBeSafe should return true when col is lower than borrow amount / spot", async function () { + it("#5: Old Vault Case : destVaultWillBeSafeExplicit should return true when col is lower than borrow amount / spot", async function () { const openVault = await hre.run("abi-encode-withselector", { abi: ConnectMaker.abi, functionname: "open", @@ -245,7 +245,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () { .div(ilk[2]); expect( - await conditionIsDestVaultWillBeSafe.isDestVaultWillBeSafe( + await conditionDestVaultWillBeSafe.destVaultWillBeSafeExplicit( cdpIdB, amountToBorrow, amountOfColToDepo, @@ -254,7 +254,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () { ).to.be.true; }); - it("#6: Old Vault Case with existing deposit : isDestVaultWillBeSafe should return true when col is lower than borrow amount / spot due to initial deposit on Vault B", async function () { + it("#6: Old Vault Case with existing deposit : destVaultWillBeSafeExplicit should return true when col is lower than borrow amount / spot due to initial deposit on Vault B", async function () { const openVault = await hre.run("abi-encode-withselector", { abi: ConnectMaker.abi, functionname: "open", @@ -295,7 +295,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () { ); expect( - await conditionIsDestVaultWillBeSafe.isDestVaultWillBeSafe( + await conditionDestVaultWillBeSafe.destVaultWillBeSafeExplicit( cdpIdB, amountToBorrow, amountOfColToDepo,