From a53aaf2d76561f7ac97c61572fbd5c4cc8fd9b62 Mon Sep 17 00:00:00 2001 From: Paul Razvan Berg Date: Wed, 20 Oct 2021 18:16:48 +0100 Subject: [PATCH] docs(flash-swap): roll v1.6.0 build(flash-swap): mark "@ethersproject/{abi,bytes,providers}" as normal deps instead of dev build(flash-swap): upgrade to "@hifi/protocol" v1.7.0 build(flash-swap): upgrade to "ethers" v5.5.1 test(flash-swap): update imports to use the latest API of the "@hifi/protocol" package --- packages/flash-swap/CHANGELOG.md | 21 +++++++++++++++++++ .../contracts/test/BalanceSheetV1.sol | 4 ++++ .../contracts/test/ChainlinkOperator.sol | 4 ++++ .../contracts/test/FintrollerV1.sol | 4 ++++ packages/flash-swap/package.json | 14 ++++++------- .../effects/uniswapV2Call.ts | 7 +++---- packages/flash-swap/test/shared/fixtures.ts | 12 +++++------ packages/flash-swap/test/shared/types.ts | 8 +++---- yarn.lock | 6 +++--- 9 files changed, 56 insertions(+), 24 deletions(-) create mode 100644 packages/flash-swap/contracts/test/BalanceSheetV1.sol create mode 100644 packages/flash-swap/contracts/test/ChainlinkOperator.sol create mode 100644 packages/flash-swap/contracts/test/FintrollerV1.sol diff --git a/packages/flash-swap/CHANGELOG.md b/packages/flash-swap/CHANGELOG.md index 8c34804c..dc442cf9 100644 --- a/packages/flash-swap/CHANGELOG.md +++ b/packages/flash-swap/CHANGELOG.md @@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.6.0] - 2021-10-20 + +### Changed + +- Mark `@ethersproject/abi`, `@ethersproject/bytes` and `@ethersproject/providers` as normal deps instead of dev deps. +- Move types from `typechain` directory to `dist/types`. +- Ship declaration maps and source maps with the npm package. +- Upgrade to `@hifi/protocol` v1.7.0. +- Upgrade to `@paulrberg/contracts` v3.6.1. +- Upgrade to `ethers` v5.5.1. +- Upgrade to Solidity v0.8.9. + +### Fixed + +- Check `mintedHTokenAmount` against `debtAmount` in the `HifiFlashUniswapV2` contract. + +## Removed + +- `artifacts` from npm package. + ## [1.5.0] - 2021-09-24 ### Changed @@ -93,6 +113,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - First release of the package. +[1.6.0]: https://github.com/hifi-finance/hifi/compare/@hifi/flash-swap@1.5.0...@hifi/flash-swap@1.6.0 [1.5.0]: https://github.com/hifi-finance/hifi/compare/@hifi/flash-swap@1.4.0...@hifi/flash-swap@1.5.0 [1.4.0]: https://github.com/hifi-finance/hifi/compare/@hifi/flash-swap@1.3.1...@hifi/flash-swap@1.4.0 [1.3.1]: https://github.com/hifi-finance/hifi/compare/@hifi/flash-swap@1.3.0...@hifi/flash-swap@1.3.1 diff --git a/packages/flash-swap/contracts/test/BalanceSheetV1.sol b/packages/flash-swap/contracts/test/BalanceSheetV1.sol new file mode 100644 index 00000000..c5f517a0 --- /dev/null +++ b/packages/flash-swap/contracts/test/BalanceSheetV1.sol @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity >=0.8.4; + +import "@hifi/protocol/contracts/core/balanceSheet/BalanceSheetV1.sol"; diff --git a/packages/flash-swap/contracts/test/ChainlinkOperator.sol b/packages/flash-swap/contracts/test/ChainlinkOperator.sol new file mode 100644 index 00000000..cea7ac14 --- /dev/null +++ b/packages/flash-swap/contracts/test/ChainlinkOperator.sol @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity >=0.8.4; + +import "@hifi/protocol/contracts/oracles/ChainlinkOperator.sol"; diff --git a/packages/flash-swap/contracts/test/FintrollerV1.sol b/packages/flash-swap/contracts/test/FintrollerV1.sol new file mode 100644 index 00000000..a6ac1ee3 --- /dev/null +++ b/packages/flash-swap/contracts/test/FintrollerV1.sol @@ -0,0 +1,4 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity >=0.8.4; + +import "@hifi/protocol/contracts/core/fintroller/FintrollerV1.sol"; diff --git a/packages/flash-swap/package.json b/packages/flash-swap/package.json index 917b6dc8..5bb7e039 100644 --- a/packages/flash-swap/package.json +++ b/packages/flash-swap/package.json @@ -1,7 +1,7 @@ { "name": "@hifi/flash-swap", "description": "Flash swap implementations for liquidating underwater accounts", - "version": "1.5.0", + "version": "1.6.0", "author": { "name": "Hifi", "email": "contact@hifi.finance", @@ -11,19 +11,19 @@ "url": "https://github.com/hifi-finance/hifi/issues" }, "dependencies": { - "@hifi/protocol": "1.6.0", + "@ethersproject/abi": "^5.5.0", + "@ethersproject/bytes": "^5.5.0", + "@ethersproject/providers": "^5.5.0", + "@hifi/protocol": "1.7.0", "@paulrberg/contracts": "3.6.1", "@uniswap/v2-core": "1.0.1", "ethers": "^5.5.1" }, "devDependencies": { - "@ethersproject/abi": "^5.5.0", "@ethersproject/abstract-signer": "^5.5.0", "@ethersproject/bignumber": "^5.5.0", - "@ethersproject/bytes": "^5.5.0", "@ethersproject/constants": "^5.5.0", "@ethersproject/keccak256": "^5.5.0", - "@ethersproject/providers": "^5.5.0", "@hifi/errors": "workspace:*", "@hifi/helpers": "workspace:*", "@nomiclabs/hardhat-ethers": "^2.0.2", @@ -81,10 +81,10 @@ ], "license": "LGPL-3.0-or-later", "peerDependencies": { - "@hifi/protocol": "1.6.0", + "@hifi/protocol": "1.7.0", "@paulrberg/contracts": "3.6.1", "@uniswap/v2-core": "1.0.1", - "ethers": "^5.4.7" + "ethers": "^5.5.1" }, "publishConfig": { "access": "public" diff --git a/packages/flash-swap/test/integration/hifiFlashUniswapV2/effects/uniswapV2Call.ts b/packages/flash-swap/test/integration/hifiFlashUniswapV2/effects/uniswapV2Call.ts index 7bada29b..8631e6eb 100644 --- a/packages/flash-swap/test/integration/hifiFlashUniswapV2/effects/uniswapV2Call.ts +++ b/packages/flash-swap/test/integration/hifiFlashUniswapV2/effects/uniswapV2Call.ts @@ -1,7 +1,7 @@ import { defaultAbiCoder } from "@ethersproject/abi"; import { BigNumber } from "@ethersproject/bignumber"; import { Zero } from "@ethersproject/constants"; -import { HifiFlashUniswapV2Errors } from "@hifi/errors"; +import { BalanceSheetErrors, HifiFlashUniswapV2Errors } from "@hifi/errors"; import { USDC, WBTC, hUSDC, price } from "@hifi/helpers"; import { expect } from "chai"; import { toBn } from "evm-bn"; @@ -210,12 +210,11 @@ export function shouldBehaveLikeUniswapV2Call(): void { context("when the borrower does not have a liquidity shortfall", function () { it("reverts", async function () { const to: string = this.contracts.hifiFlashUniswapV2.address; - // TODO: change the revert reason with a BalanceSheet error once Hardhat enables external custom errors. await expect( this.contracts.uniswapV2Pair .connect(this.signers.liquidator) .swap(token0Amount, token1Amount, to, data), - ).to.be.revertedWith("Transaction reverted without a reason string"); + ).to.be.revertedWith(BalanceSheetErrors.NO_LIQUIDITY_SHORTFALL); }); }); @@ -233,7 +232,7 @@ export function shouldBehaveLikeUniswapV2Call(): void { this.contracts.uniswapV2Pair .connect(this.signers.liquidator) .swap(token0Amount, token1Amount, to, data), - ).to.be.revertedWith("Transaction reverted without a reason string"); + ).to.be.revertedWith(BalanceSheetErrors.LIQUIDATE_BORROW_INSUFFICIENT_COLLATERAL); }); }); diff --git a/packages/flash-swap/test/shared/fixtures.ts b/packages/flash-swap/test/shared/fixtures.ts index 48087c27..68f38afb 100644 --- a/packages/flash-swap/test/shared/fixtures.ts +++ b/packages/flash-swap/test/shared/fixtures.ts @@ -3,12 +3,9 @@ import { keccak256 } from "@ethersproject/keccak256"; import { H_TOKEN_MATURITY_ONE_YEAR } from "@hifi/constants"; import { USDC_DECIMALS, USDC_NAME, USDC_SYMBOL, WBTC_DECIMALS, WBTC_NAME, WBTC_SYMBOL } from "@hifi/constants"; import { getHTokenName, getHTokenSymbol } from "@hifi/helpers"; -import balanceSheetV1Artifact from "@hifi/protocol/artifacts/BalanceSheetV1.json"; -import chainlinkOperatorArtifact from "@hifi/protocol/artifacts/ChainlinkOperator.json"; -import fintrollerV1Artifact from "@hifi/protocol/artifacts/FintrollerV1.json"; -import { BalanceSheetV1 } from "@hifi/protocol/typechain/BalanceSheetV1"; -import { ChainlinkOperator } from "@hifi/protocol/typechain/ChainlinkOperator"; -import { FintrollerV1 } from "@hifi/protocol/typechain/FintrollerV1"; +import type { BalanceSheetV1 } from "@hifi/protocol/dist/types/BalanceSheetV1"; +import type { ChainlinkOperator } from "@hifi/protocol/dist/types/ChainlinkOperator"; +import type { FintrollerV1 } from "@hifi/protocol/dist/types/FintrollerV1"; import { artifacts, waffle } from "hardhat"; import type { Artifact } from "hardhat/types"; @@ -49,15 +46,18 @@ export async function integrationFixture(signers: Signer[]): Promise( await waffle.deployContract(deployer, chainlinkOperatorArtifact, []) ); await oracle.setFeed(wbtc.address, wbtcPriceFeed.address); await oracle.setFeed(usdc.address, usdcPriceFeed.address); + const fintrollerV1Artifact: Artifact = await artifacts.readArtifact("FintrollerV1"); const fintroller: FintrollerV1 = await waffle.deployContract(deployer, fintrollerV1Artifact, []); await fintroller.connect(deployer).initialize(); + const balanceSheetV1Artifact: Artifact = await artifacts.readArtifact("BalanceSheetV1"); const balanceSheet: BalanceSheetV1 = ( await waffle.deployContract(deployer, balanceSheetV1Artifact, []) ); diff --git a/packages/flash-swap/test/shared/types.ts b/packages/flash-swap/test/shared/types.ts index c69cdd0d..fd82e796 100644 --- a/packages/flash-swap/test/shared/types.ts +++ b/packages/flash-swap/test/shared/types.ts @@ -1,7 +1,7 @@ -import { BalanceSheetV1 } from "@hifi/protocol/typechain/BalanceSheetV1"; -import { ChainlinkOperator } from "@hifi/protocol/typechain/ChainlinkOperator"; -import { FintrollerV1 } from "@hifi/protocol/typechain/FintrollerV1"; -import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; +import type { BalanceSheetV1 } from "@hifi/protocol/dist/types/BalanceSheetV1"; +import type { ChainlinkOperator } from "@hifi/protocol/dist/types/ChainlinkOperator"; +import type { FintrollerV1 } from "@hifi/protocol/dist/types/FintrollerV1"; +import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address"; import type { GodModeErc20 } from "../../src/types/GodModeErc20"; import type { GodModeHToken } from "../../src/types/GodModeHToken"; diff --git a/yarn.lock b/yarn.lock index bd240362..b22e407d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1494,7 +1494,7 @@ __metadata: "@ethersproject/providers": ^5.5.0 "@hifi/errors": "workspace:*" "@hifi/helpers": "workspace:*" - "@hifi/protocol": 1.6.0 + "@hifi/protocol": 1.7.0 "@nomiclabs/hardhat-ethers": ^2.0.2 "@nomiclabs/hardhat-etherscan": ^2.1.6 "@nomiclabs/hardhat-waffle": ^2.0.1 @@ -1532,10 +1532,10 @@ __metadata: typechain: ^5.2.0 typescript: ^4.4.4 peerDependencies: - "@hifi/protocol": 1.6.0 + "@hifi/protocol": 1.7.0 "@paulrberg/contracts": 3.6.1 "@uniswap/v2-core": 1.0.1 - ethers: ^5.4.7 + ethers: ^5.5.1 languageName: unknown linkType: soft