mirror of
https://github.com/Instadapp/Gelato-automations.git
synced 2024-07-29 22:28:07 +00:00
feat: ConditionDestVaultWillBeSafe cleanup
This commit is contained in:
parent
7803bc5102
commit
22c4a0268f
|
@ -37,13 +37,13 @@ jobs: # a collection of steps
|
||||||
command: yarn lint
|
command: yarn lint
|
||||||
- restore_cache: # restore the Hardhat Network Fork Cache
|
- restore_cache: # restore the Hardhat Network Fork Cache
|
||||||
name: Restore Hardhat Network Fork Cache
|
name: Restore Hardhat Network Fork Cache
|
||||||
key: v2-hardhat-network-fork-cache
|
key: v3-hardhat-network-fork-cache
|
||||||
- run: # Tests
|
- run: # Tests
|
||||||
name: Tests using hardhat mainnet fork and gas reporter
|
name: Tests using hardhat mainnet fork and gas reporter
|
||||||
command: yarn test:gas
|
command: yarn test:gas
|
||||||
- save_cache: # special step to save the Hardhat Network Fork cache
|
- save_cache: # special step to save the Hardhat Network Fork cache
|
||||||
name: Save Hardhat Network Fork Cache
|
name: Save Hardhat Network Fork Cache
|
||||||
key: v2-hardhat-network-fork-cache
|
key: v3-hardhat-network-fork-cache
|
||||||
paths:
|
paths:
|
||||||
- ./cache/hardhat-network-fork
|
- ./cache/hardhat-network-fork
|
||||||
- run: # Codechecks
|
- run: # Codechecks
|
||||||
|
|
|
@ -2,5 +2,4 @@
|
||||||
artifacts
|
artifacts
|
||||||
cache
|
cache
|
||||||
assets
|
assets
|
||||||
coverage
|
coverage
|
||||||
contracts/vendor
|
|
|
@ -8,23 +8,22 @@ import {
|
||||||
import {
|
import {
|
||||||
_getMakerVaultDebt,
|
_getMakerVaultDebt,
|
||||||
_getMakerVaultCollateralBalance,
|
_getMakerVaultCollateralBalance,
|
||||||
_isVaultWillBeSafe,
|
_vaultWillBeSafe,
|
||||||
_isNewVaultWillBeSafe
|
_newVaultWillBeSafe
|
||||||
} from "../../../functions/dapps/FMaker.sol";
|
} from "../../../functions/dapps/FMaker.sol";
|
||||||
import {
|
import {
|
||||||
_getRealisedDebt
|
_getRealisedDebt
|
||||||
} from "../../../functions/gelato/FGelatoDebtBridge.sol";
|
} from "../../../functions/gelato/FGelatoDebtBridge.sol";
|
||||||
|
|
||||||
import {GelatoBytes} from "../../../lib/GelatoBytes.sol";
|
import {GelatoBytes} from "../../../lib/GelatoBytes.sol";
|
||||||
import "hardhat/console.sol";
|
|
||||||
|
|
||||||
contract ConditionIsDestVaultWillBeSafe is GelatoConditionsStandard {
|
contract ConditionDestVaultWillBeSafe is GelatoConditionsStandard {
|
||||||
using GelatoBytes for bytes;
|
using GelatoBytes for bytes;
|
||||||
|
|
||||||
function getConditionData(
|
function getConditionData(
|
||||||
uint256 _fromVaultId,
|
uint256 _fromVaultId,
|
||||||
uint256 _destVaultId,
|
uint256 _destVaultId,
|
||||||
string memory _destColType
|
string calldata _destColType
|
||||||
) public pure virtual returns (bytes memory) {
|
) public pure virtual returns (bytes memory) {
|
||||||
return abi.encode(_fromVaultId, _destVaultId, _destColType);
|
return abi.encode(_fromVaultId, _destVaultId, _destColType);
|
||||||
}
|
}
|
||||||
|
@ -53,7 +52,7 @@ contract ConditionIsDestVaultWillBeSafe is GelatoConditionsStandard {
|
||||||
uint256 wColToDeposit = _getMakerVaultCollateralBalance(_fromVaultId);
|
uint256 wColToDeposit = _getMakerVaultCollateralBalance(_fromVaultId);
|
||||||
|
|
||||||
return
|
return
|
||||||
isDestVaultWillBeSafe(
|
destVaultWillBeSafeExplicit(
|
||||||
_destVaultId,
|
_destVaultId,
|
||||||
wDaiToBorrow,
|
wDaiToBorrow,
|
||||||
wColToDeposit,
|
wColToDeposit,
|
||||||
|
@ -63,7 +62,7 @@ contract ConditionIsDestVaultWillBeSafe is GelatoConditionsStandard {
|
||||||
: "DestVaultWillNotBeSafe";
|
: "DestVaultWillNotBeSafe";
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDestVaultWillBeSafe(
|
function destVaultWillBeSafeExplicit(
|
||||||
uint256 _vaultId,
|
uint256 _vaultId,
|
||||||
uint256 _wDaiToBorrow,
|
uint256 _wDaiToBorrow,
|
||||||
uint256 _wColToDeposit,
|
uint256 _wColToDeposit,
|
||||||
|
@ -71,7 +70,7 @@ contract ConditionIsDestVaultWillBeSafe is GelatoConditionsStandard {
|
||||||
) public view returns (bool) {
|
) public view returns (bool) {
|
||||||
return
|
return
|
||||||
_vaultId == 0
|
_vaultId == 0
|
||||||
? _isNewVaultWillBeSafe(_colType, _wDaiToBorrow, _wColToDeposit)
|
? _newVaultWillBeSafe(_colType, _wDaiToBorrow, _wColToDeposit)
|
||||||
: _isVaultWillBeSafe(_vaultId, _wDaiToBorrow, _wColToDeposit);
|
: _vaultWillBeSafe(_vaultId, _wDaiToBorrow, _wColToDeposit);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,8 +5,8 @@ import {
|
||||||
_getMakerRawVaultDebt,
|
_getMakerRawVaultDebt,
|
||||||
_getMakerVaultDebt,
|
_getMakerVaultDebt,
|
||||||
_getMakerVaultCollateralBalance,
|
_getMakerVaultCollateralBalance,
|
||||||
_isVaultWillBeSafe,
|
_vaultWillBeSafe,
|
||||||
_isNewVaultWillBeSafe
|
_newVaultWillBeSafe
|
||||||
} from "../../functions/dapps/FMaker.sol";
|
} from "../../functions/dapps/FMaker.sol";
|
||||||
|
|
||||||
contract MakerResolver {
|
contract MakerResolver {
|
||||||
|
@ -32,19 +32,19 @@ contract MakerResolver {
|
||||||
return _getMakerVaultCollateralBalance(_vaultId);
|
return _getMakerVaultCollateralBalance(_vaultId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isVaultWillBeSafe(
|
function vaultWillBeSafe(
|
||||||
uint256 _vaultId,
|
uint256 _vaultId,
|
||||||
uint256 _amtToBorrow,
|
uint256 _amtToBorrow,
|
||||||
uint256 _colToDeposit
|
uint256 _colToDeposit
|
||||||
) public view returns (bool) {
|
) public view returns (bool) {
|
||||||
return _isVaultWillBeSafe(_vaultId, _amtToBorrow, _colToDeposit);
|
return _vaultWillBeSafe(_vaultId, _amtToBorrow, _colToDeposit);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isNewVaultWillBeSafe(
|
function newVaultWillBeSafe(
|
||||||
string memory _colType,
|
string memory _colType,
|
||||||
uint256 _amtToBorrow,
|
uint256 _amtToBorrow,
|
||||||
uint256 _colToDeposit
|
uint256 _colToDeposit
|
||||||
) public view returns (bool) {
|
) public view returns (bool) {
|
||||||
return _isNewVaultWillBeSafe(_colType, _amtToBorrow, _colToDeposit);
|
return _newVaultWillBeSafe(_colType, _amtToBorrow, _colToDeposit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,12 +54,12 @@ function _getMakerVaultCollateralBalance(uint256 _vaultId)
|
||||||
return ink;
|
return ink;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _isVaultWillBeSafe(
|
function _vaultWillBeSafe(
|
||||||
uint256 _vaultId,
|
uint256 _vaultId,
|
||||||
uint256 _amtToBorrow,
|
uint256 _amtToBorrow,
|
||||||
uint256 _colToDeposit
|
uint256 _colToDeposit
|
||||||
) view returns (bool) {
|
) view returns (bool) {
|
||||||
require(_vaultId != 0, "_isVaultWillBeSafe: invalid vault id.");
|
require(_vaultId != 0, "_vaultWillBeSafe: invalid vault id.");
|
||||||
|
|
||||||
IMcdManager manager = IMcdManager(MCD_MANAGER);
|
IMcdManager manager = IMcdManager(MCD_MANAGER);
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ function _isVaultWillBeSafe(
|
||||||
return tab <= mul(ink, spot);
|
return tab <= mul(ink, spot);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _isNewVaultWillBeSafe(
|
function _newVaultWillBeSafe(
|
||||||
string memory _colType,
|
string memory _colType,
|
||||||
uint256 _amtToBorrow,
|
uint256 _amtToBorrow,
|
||||||
uint256 _colToDeposit
|
uint256 _colToDeposit
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity 0.7.4;
|
pragma solidity 0.7.4;
|
||||||
pragma experimental ABIEncoderV2;
|
|
||||||
|
|
||||||
interface ITokenJoinInterface {
|
interface ITokenJoinInterface {
|
||||||
function dec() external view returns (uint256);
|
function dec() external view returns (uint256);
|
||||||
|
|
7
contracts/vendor/Address.sol
vendored
7
contracts/vendor/Address.sol
vendored
|
@ -145,9 +145,8 @@ library Address {
|
||||||
require(isContract(target), "Address: call to non-contract");
|
require(isContract(target), "Address: call to non-contract");
|
||||||
|
|
||||||
// solhint-disable-next-line avoid-low-level-calls
|
// solhint-disable-next-line avoid-low-level-calls
|
||||||
(bool success, bytes memory returndata) = target.call{value: value}(
|
(bool success, bytes memory returndata) =
|
||||||
data
|
target.call{value: value}(data);
|
||||||
);
|
|
||||||
return _verifyCallResult(success, returndata, errorMessage);
|
return _verifyCallResult(success, returndata, errorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,4 +172,4 @@ library Address {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
22
contracts/vendor/Convert.sol
vendored
22
contracts/vendor/Convert.sol
vendored
|
@ -1,19 +1,15 @@
|
||||||
// SPDX-License-Identifier: UNLICENSED
|
// SPDX-License-Identifier: UNLICENSED
|
||||||
pragma solidity 0.7.4;
|
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)
|
function _stringToBytes32(string memory str) pure returns (bytes32 result) {
|
||||||
pure
|
require(bytes(str).length != 0, "string-empty");
|
||||||
returns (bytes32 result)
|
assembly {
|
||||||
{
|
result := mload(add(str, 32))
|
||||||
require(bytes(str).length != 0, "string-empty");
|
|
||||||
assembly {
|
|
||||||
result := mload(add(str, 32))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function _convertTo18(uint256 _dec, uint256 _amt)
|
function _convertTo18(uint256 _dec, uint256 _amt) pure returns (uint256 amt) {
|
||||||
pure returns (uint256 amt) {
|
amt = _mul(_amt, 10**(18 - _dec));
|
||||||
amt = mul(_amt, 10**(18 - _dec));
|
}
|
||||||
}
|
|
||||||
|
|
44
contracts/vendor/DSMath.sol
vendored
44
contracts/vendor/DSMath.sol
vendored
|
@ -16,46 +16,54 @@
|
||||||
|
|
||||||
pragma solidity 0.7.4;
|
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");
|
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");
|
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");
|
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;
|
return x <= y ? x : y;
|
||||||
}
|
}
|
||||||
function max(uint x, uint y) pure returns (uint z) {
|
|
||||||
return x >= y ? x : y;
|
function max(uint256 x, uint256 y) pure returns (uint256 z) {
|
||||||
}
|
|
||||||
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) {
|
|
||||||
return x >= y ? x : y;
|
return x >= y ? x : y;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint constant WAD = 10 ** 18;
|
function imin(int256 x, int256 y) pure returns (int256 z) {
|
||||||
uint constant RAY = 10 ** 27;
|
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
|
//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;
|
z = add(mul(x, y), WAD / 2) / WAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
//rounds to zero if x*y < WAD / 2
|
//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;
|
z = add(mul(x, y), RAY / 2) / RAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
//rounds to zero if x*y < WAD / 2
|
//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;
|
z = add(mul(x, WAD), y / 2) / y;
|
||||||
}
|
}
|
||||||
|
|
||||||
//rounds to zero if x*y < RAY / 2
|
//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;
|
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
|
// Also, EVM division is flooring and
|
||||||
// floor[(n-1) / 2] = floor[n / 2].
|
// 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;
|
z = n % 2 != 0 ? x : RAY;
|
||||||
|
|
||||||
for (n /= 2; n != 0; n /= 2) {
|
for (n /= 2; n != 0; n /= 2) {
|
||||||
|
|
23
contracts/vendor/IERC20.sol
vendored
23
contracts/vendor/IERC20.sol
vendored
|
@ -22,7 +22,9 @@ interface IERC20 {
|
||||||
*
|
*
|
||||||
* Emits a {Transfer} event.
|
* 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
|
* @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.
|
* 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.
|
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
|
||||||
|
@ -58,7 +63,11 @@ interface IERC20 {
|
||||||
*
|
*
|
||||||
* Emits a {Transfer} event.
|
* 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
|
* @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
|
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
|
||||||
* a call to {approve}. `value` is the new allowance.
|
* a call to {approve}. `value` is the new allowance.
|
||||||
*/
|
*/
|
||||||
event Approval(address indexed owner, address indexed spender, uint256 value);
|
event Approval(
|
||||||
}
|
address indexed owner,
|
||||||
|
address indexed spender,
|
||||||
|
uint256 value
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
92
contracts/vendor/SafeERC20.sol
vendored
92
contracts/vendor/SafeERC20.sol
vendored
|
@ -18,12 +18,27 @@ library SafeERC20 {
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
using Address for address;
|
using Address for address;
|
||||||
|
|
||||||
function safeTransfer(IERC20 token, address to, uint256 value) internal {
|
function safeTransfer(
|
||||||
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
|
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 {
|
function safeTransferFrom(
|
||||||
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
|
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
|
* Whenever possible, use {safeIncreaseAllowance} and
|
||||||
* {safeDecreaseAllowance} instead.
|
* {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,
|
// safeApprove should only be called when setting an initial allowance,
|
||||||
// or when resetting it to zero. To increase and decrease it, use
|
// or when resetting it to zero. To increase and decrease it, use
|
||||||
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
|
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
|
||||||
// solhint-disable-next-line max-line-length
|
// 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"
|
"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 {
|
function safeIncreaseAllowance(
|
||||||
uint256 newAllowance = token.allowance(address(this), spender).add(value);
|
IERC20 token,
|
||||||
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
|
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 {
|
function safeDecreaseAllowance(
|
||||||
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
|
IERC20 token,
|
||||||
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
|
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
|
// 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.
|
// 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");
|
bytes memory returndata =
|
||||||
if (returndata.length > 0) { // Return data is optional
|
address(token).functionCall(
|
||||||
|
data,
|
||||||
|
"SafeERC20: low-level call failed"
|
||||||
|
);
|
||||||
|
if (returndata.length > 0) {
|
||||||
|
// Return data is optional
|
||||||
// solhint-disable-next-line max-line-length
|
// 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"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
20
contracts/vendor/SafeMath.sol
vendored
20
contracts/vendor/SafeMath.sol
vendored
|
@ -56,7 +56,11 @@ library SafeMath {
|
||||||
*
|
*
|
||||||
* - Subtraction cannot overflow.
|
* - 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);
|
require(b <= a, errorMessage);
|
||||||
uint256 c = a - b;
|
uint256 c = a - b;
|
||||||
|
|
||||||
|
@ -115,7 +119,11 @@ library SafeMath {
|
||||||
*
|
*
|
||||||
* - The divisor cannot be zero.
|
* - 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);
|
require(b > 0, errorMessage);
|
||||||
uint256 c = a / b;
|
uint256 c = a / b;
|
||||||
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
|
// 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.
|
* - 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);
|
require(b != 0, errorMessage);
|
||||||
return a % b;
|
return a % b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ const { sleep } = require("@gelatonetwork/core");
|
||||||
module.exports = async (hre) => {
|
module.exports = async (hre) => {
|
||||||
if (hre.network.name === "mainnet") {
|
if (hre.network.name === "mainnet") {
|
||||||
console.log(
|
console.log(
|
||||||
"Deploying ConditionIsDestVaultWillBeSafe to mainnet. Hit ctrl + c to abort"
|
"Deploying ConditionDestVaultWillBeSafe to mainnet. Hit ctrl + c to abort"
|
||||||
);
|
);
|
||||||
await sleep(10000);
|
await sleep(10000);
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,9 @@ module.exports = async (hre) => {
|
||||||
const { deploy } = deployments;
|
const { deploy } = deployments;
|
||||||
const { deployer } = await hre.getNamedAccounts();
|
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
|
// if the contract was never deployed or if the code changed since last deployment
|
||||||
await deploy("ConditionIsDestVaultWillBeSafe", {
|
await deploy("ConditionDestVaultWillBeSafe", {
|
||||||
from: deployer,
|
from: deployer,
|
||||||
gasPrice: hre.network.config.gasPrice,
|
gasPrice: hre.network.config.gasPrice,
|
||||||
log: hre.network.name === "mainnet" ? true : false,
|
log: hre.network.name === "mainnet" ? true : false,
|
||||||
|
@ -24,4 +24,4 @@ module.exports = async (hre) => {
|
||||||
module.exports.skip = async (hre) => {
|
module.exports.skip = async (hre) => {
|
||||||
return hre.network.name === "mainnet" ? true : false;
|
return hre.network.name === "mainnet" ? true : false;
|
||||||
};
|
};
|
||||||
module.exports.tags = ["ConditionIsDestVaultWillBeSafe"];
|
module.exports.tags = ["ConditionDestVaultWillBeSafe"];
|
|
@ -12,7 +12,7 @@ const { utils } = require("ethers");
|
||||||
|
|
||||||
const GelatoCoreLib = require("@gelatonetwork/core");
|
const GelatoCoreLib = require("@gelatonetwork/core");
|
||||||
|
|
||||||
const mainnetDeployments = require("./tool/config/mainnet-deployments");
|
const mainnetDeployments = require("./_hardhat/config/mainnet-deployments");
|
||||||
|
|
||||||
// Process Env Variables
|
// Process Env Variables
|
||||||
require("dotenv").config();
|
require("dotenv").config();
|
||||||
|
|
|
@ -24,7 +24,7 @@ describe("Gas Measurements: Full Debt Bridge From Maker ETH-A to ETH-B", functio
|
||||||
|
|
||||||
let conditionMakerVaultUnsafeObj;
|
let conditionMakerVaultUnsafeObj;
|
||||||
let conditionDebtBridgeIsAffordableObj;
|
let conditionDebtBridgeIsAffordableObj;
|
||||||
let conditionIsDestVaultWillBeSafe;
|
let conditionDestVaultWillBeSafe;
|
||||||
|
|
||||||
// For TaskSpec and for Task
|
// For TaskSpec and for Task
|
||||||
let gelatoDebtBridgeSpells = [];
|
let gelatoDebtBridgeSpells = [];
|
||||||
|
@ -84,9 +84,9 @@ describe("Gas Measurements: Full Debt Bridge From Maker ETH-A to ETH-B", functio
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
conditionIsDestVaultWillBeSafe = new GelatoCoreLib.Condition({
|
conditionDestVaultWillBeSafe = new GelatoCoreLib.Condition({
|
||||||
inst: contracts.conditionIsDestVaultWillBeSafe.address,
|
inst: contracts.conditionDestVaultWillBeSafe.address,
|
||||||
data: await contracts.conditionIsDestVaultWillBeSafe.getConditionData(
|
data: await contracts.conditionDestVaultWillBeSafe.getConditionData(
|
||||||
vaultAId,
|
vaultAId,
|
||||||
vaultBId,
|
vaultBId,
|
||||||
"ETH-B"
|
"ETH-B"
|
||||||
|
@ -97,7 +97,7 @@ describe("Gas Measurements: Full Debt Bridge From Maker ETH-A to ETH-B", functio
|
||||||
conditions: [
|
conditions: [
|
||||||
conditionMakerVaultUnsafeObj,
|
conditionMakerVaultUnsafeObj,
|
||||||
conditionDebtBridgeIsAffordableObj,
|
conditionDebtBridgeIsAffordableObj,
|
||||||
conditionIsDestVaultWillBeSafe,
|
conditionDestVaultWillBeSafe,
|
||||||
],
|
],
|
||||||
actions: gelatoDebtBridgeSpells,
|
actions: gelatoDebtBridgeSpells,
|
||||||
});
|
});
|
||||||
|
|
|
@ -41,7 +41,7 @@ module.exports = async function (
|
||||||
conditions: [
|
conditions: [
|
||||||
contracts.conditionMakerVaultUnsafe.address,
|
contracts.conditionMakerVaultUnsafe.address,
|
||||||
contracts.conditionDebtBridgeIsAffordable.address,
|
contracts.conditionDebtBridgeIsAffordable.address,
|
||||||
contracts.conditionIsDestVaultWillBeSafe.address,
|
contracts.conditionDestVaultWillBeSafe.address,
|
||||||
],
|
],
|
||||||
actions: spells,
|
actions: spells,
|
||||||
gasPriceCeil,
|
gasPriceCeil,
|
||||||
|
|
|
@ -113,8 +113,8 @@ module.exports = async function () {
|
||||||
"MockConnectGelatoDataFullRefinanceMaker"
|
"MockConnectGelatoDataFullRefinanceMaker"
|
||||||
);
|
);
|
||||||
|
|
||||||
const conditionIsDestVaultWillBeSafe = await ethers.getContract(
|
const conditionDestVaultWillBeSafe = await ethers.getContract(
|
||||||
"ConditionIsDestVaultWillBeSafe"
|
"ConditionDestVaultWillBeSafe"
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -145,6 +145,6 @@ module.exports = async function () {
|
||||||
conditionDebtBridgeIsAffordable,
|
conditionDebtBridgeIsAffordable,
|
||||||
mockDebtBridgeETHBExecutor,
|
mockDebtBridgeETHBExecutor,
|
||||||
mockConnectGelatoDataFullRefinanceMaker,
|
mockConnectGelatoDataFullRefinanceMaker,
|
||||||
conditionIsDestVaultWillBeSafe,
|
conditionDestVaultWillBeSafe,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -102,9 +102,9 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B with vault creat
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
const conditionIsDestVaultWillBeSafe = new GelatoCoreLib.Condition({
|
const conditionDestVaultWillBeSafe = new GelatoCoreLib.Condition({
|
||||||
inst: contracts.conditionIsDestVaultWillBeSafe.address,
|
inst: contracts.conditionDestVaultWillBeSafe.address,
|
||||||
data: await contracts.conditionIsDestVaultWillBeSafe.getConditionData(
|
data: await contracts.conditionDestVaultWillBeSafe.getConditionData(
|
||||||
vaultAId,
|
vaultAId,
|
||||||
0,
|
0,
|
||||||
"ETH-B"
|
"ETH-B"
|
||||||
|
@ -116,7 +116,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B with vault creat
|
||||||
conditions: [
|
conditions: [
|
||||||
conditionMakerVaultUnsafeObj,
|
conditionMakerVaultUnsafeObj,
|
||||||
conditionDebtBridgeIsAffordableObj,
|
conditionDebtBridgeIsAffordableObj,
|
||||||
conditionIsDestVaultWillBeSafe,
|
conditionDestVaultWillBeSafe,
|
||||||
],
|
],
|
||||||
actions: gelatoDebtBridgeSpells,
|
actions: gelatoDebtBridgeSpells,
|
||||||
});
|
});
|
||||||
|
|
|
@ -104,9 +104,9 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () {
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
const conditionIsDestVaultWillBeSafe = new GelatoCoreLib.Condition({
|
const conditionDestVaultWillBeSafe = new GelatoCoreLib.Condition({
|
||||||
inst: contracts.conditionIsDestVaultWillBeSafe.address,
|
inst: contracts.conditionDestVaultWillBeSafe.address,
|
||||||
data: await contracts.conditionIsDestVaultWillBeSafe.getConditionData(
|
data: await contracts.conditionDestVaultWillBeSafe.getConditionData(
|
||||||
vaultAId,
|
vaultAId,
|
||||||
vaultBId,
|
vaultBId,
|
||||||
"ETH-B"
|
"ETH-B"
|
||||||
|
@ -118,7 +118,7 @@ describe("Full Debt Bridge refinancing loan from ETH-A to ETH-B", function () {
|
||||||
conditions: [
|
conditions: [
|
||||||
conditionMakerVaultUnsafeObj,
|
conditionMakerVaultUnsafeObj,
|
||||||
conditionDebtBridgeIsAffordableObj,
|
conditionDebtBridgeIsAffordableObj,
|
||||||
conditionIsDestVaultWillBeSafe,
|
conditionDestVaultWillBeSafe,
|
||||||
],
|
],
|
||||||
actions: gelatoDebtBridgeSpells,
|
actions: gelatoDebtBridgeSpells,
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,7 +35,7 @@ module.exports = async function (wallets, contracts, constants, vaultId) {
|
||||||
conditions: [
|
conditions: [
|
||||||
contracts.conditionMakerVaultUnsafe.address,
|
contracts.conditionMakerVaultUnsafe.address,
|
||||||
contracts.conditionDebtBridgeIsAffordable.address,
|
contracts.conditionDebtBridgeIsAffordable.address,
|
||||||
contracts.conditionIsDestVaultWillBeSafe.address,
|
contracts.conditionDestVaultWillBeSafe.address,
|
||||||
],
|
],
|
||||||
actions: spells,
|
actions: spells,
|
||||||
gasPriceCeil,
|
gasPriceCeil,
|
||||||
|
|
|
@ -41,7 +41,7 @@ module.exports = async function (
|
||||||
conditions: [
|
conditions: [
|
||||||
contracts.conditionMakerVaultUnsafe.address,
|
contracts.conditionMakerVaultUnsafe.address,
|
||||||
contracts.conditionDebtBridgeIsAffordable.address,
|
contracts.conditionDebtBridgeIsAffordable.address,
|
||||||
contracts.conditionIsDestVaultWillBeSafe.address,
|
contracts.conditionDestVaultWillBeSafe.address,
|
||||||
],
|
],
|
||||||
actions: spells,
|
actions: spells,
|
||||||
gasPriceCeil,
|
gasPriceCeil,
|
||||||
|
|
|
@ -15,7 +15,7 @@ const IERC20 = require("../../../pre-compiles/IERC20.json");
|
||||||
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
describe("ConditionIsDestVaultWillBeSafe Unit Test", function () {
|
describe("ConditionDestVaultWillBeSafe Unit Test", function () {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
if (hre.network.name !== "hardhat") {
|
if (hre.network.name !== "hardhat") {
|
||||||
console.error("Test Suite is meant to be run on hardhat only");
|
console.error("Test Suite is meant to be run on hardhat only");
|
||||||
|
@ -32,7 +32,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () {
|
||||||
let DAI;
|
let DAI;
|
||||||
let vat;
|
let vat;
|
||||||
|
|
||||||
let conditionIsDestVaultWillBeSafe;
|
let conditionDestVaultWillBeSafe;
|
||||||
|
|
||||||
let dsa;
|
let dsa;
|
||||||
let cdpId;
|
let cdpId;
|
||||||
|
@ -73,8 +73,8 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () {
|
||||||
DAI = await ethers.getContractAt(IERC20.abi, hre.network.config.DAI);
|
DAI = await ethers.getContractAt(IERC20.abi, hre.network.config.DAI);
|
||||||
|
|
||||||
// ========== Test Setup ============
|
// ========== Test Setup ============
|
||||||
conditionIsDestVaultWillBeSafe = await ethers.getContract(
|
conditionDestVaultWillBeSafe = await ethers.getContract(
|
||||||
"ConditionIsDestVaultWillBeSafe"
|
"ConditionDestVaultWillBeSafe"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create DeFi Smart Account
|
// 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 () {
|
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,
|
cdpId,
|
||||||
0,
|
0,
|
||||||
"ETH-B"
|
"ETH-B"
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
await conditionIsDestVaultWillBeSafe.ok(0, conditionData, 0)
|
await conditionDestVaultWillBeSafe.ok(0, conditionData, 0)
|
||||||
).to.be.equal("OK");
|
).to.be.equal("OK");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("#2: New Vault Case : isDestVaultWillBeSafe should return false when col is lower than borrow amount / spot", async function () {
|
it("#2: New Vault Case : destVaultWillBeSafeExplicit should return false when col is lower than borrow amount / spot", async function () {
|
||||||
var amountOfColToDepo = amountToBorrow
|
let amountOfColToDepo = amountToBorrow
|
||||||
.mul(ilk[1])
|
.mul(ilk[1])
|
||||||
.div(ethers.utils.parseUnits("1", 27));
|
.div(ethers.utils.parseUnits("1", 27));
|
||||||
amountOfColToDepo = amountOfColToDepo
|
amountOfColToDepo = amountOfColToDepo
|
||||||
|
@ -164,7 +164,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () {
|
||||||
.div(ilk[2]);
|
.div(ilk[2]);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await conditionIsDestVaultWillBeSafe.isDestVaultWillBeSafe(
|
await conditionDestVaultWillBeSafe.destVaultWillBeSafeExplicit(
|
||||||
0,
|
0,
|
||||||
amountToBorrow,
|
amountToBorrow,
|
||||||
amountOfColToDepo,
|
amountOfColToDepo,
|
||||||
|
@ -173,7 +173,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () {
|
||||||
).to.be.false;
|
).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
|
let amountOfColToDepo = amountToBorrow
|
||||||
.mul(ilk[1])
|
.mul(ilk[1])
|
||||||
.div(ethers.utils.parseUnits("1", 27));
|
.div(ethers.utils.parseUnits("1", 27));
|
||||||
|
@ -183,7 +183,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () {
|
||||||
.div(ilk[2]);
|
.div(ilk[2]);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await conditionIsDestVaultWillBeSafe.isDestVaultWillBeSafe(
|
await conditionDestVaultWillBeSafe.destVaultWillBeSafeExplicit(
|
||||||
0,
|
0,
|
||||||
amountToBorrow,
|
amountToBorrow,
|
||||||
amountOfColToDepo,
|
amountOfColToDepo,
|
||||||
|
@ -192,7 +192,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () {
|
||||||
).to.be.true;
|
).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", {
|
const openVault = await hre.run("abi-encode-withselector", {
|
||||||
abi: ConnectMaker.abi,
|
abi: ConnectMaker.abi,
|
||||||
functionname: "open",
|
functionname: "open",
|
||||||
|
@ -214,7 +214,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () {
|
||||||
.div(ilk[2]);
|
.div(ilk[2]);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await conditionIsDestVaultWillBeSafe.isDestVaultWillBeSafe(
|
await conditionDestVaultWillBeSafe.destVaultWillBeSafeExplicit(
|
||||||
cdpIdB,
|
cdpIdB,
|
||||||
amountToBorrow,
|
amountToBorrow,
|
||||||
amountOfColToDepo,
|
amountOfColToDepo,
|
||||||
|
@ -223,7 +223,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () {
|
||||||
).to.be.false;
|
).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", {
|
const openVault = await hre.run("abi-encode-withselector", {
|
||||||
abi: ConnectMaker.abi,
|
abi: ConnectMaker.abi,
|
||||||
functionname: "open",
|
functionname: "open",
|
||||||
|
@ -245,7 +245,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () {
|
||||||
.div(ilk[2]);
|
.div(ilk[2]);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await conditionIsDestVaultWillBeSafe.isDestVaultWillBeSafe(
|
await conditionDestVaultWillBeSafe.destVaultWillBeSafeExplicit(
|
||||||
cdpIdB,
|
cdpIdB,
|
||||||
amountToBorrow,
|
amountToBorrow,
|
||||||
amountOfColToDepo,
|
amountOfColToDepo,
|
||||||
|
@ -254,7 +254,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () {
|
||||||
).to.be.true;
|
).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", {
|
const openVault = await hre.run("abi-encode-withselector", {
|
||||||
abi: ConnectMaker.abi,
|
abi: ConnectMaker.abi,
|
||||||
functionname: "open",
|
functionname: "open",
|
||||||
|
@ -295,7 +295,7 @@ describe("ConditionIsDestVaultWillBeSafe Unit Test", function () {
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
await conditionIsDestVaultWillBeSafe.isDestVaultWillBeSafe(
|
await conditionDestVaultWillBeSafe.destVaultWillBeSafeExplicit(
|
||||||
cdpIdB,
|
cdpIdB,
|
||||||
amountToBorrow,
|
amountToBorrow,
|
||||||
amountOfColToDepo,
|
amountOfColToDepo,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user