Skip to content

Commit

Permalink
docs(flash-swap): roll v1.6.0
Browse files Browse the repository at this point in the history
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
  • Loading branch information
PaulRBerg committed Oct 20, 2021
1 parent 1cff4ab commit a53aaf2
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 24 deletions.
21 changes: 21 additions & 0 deletions packages/flash-swap/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/[email protected]...@hifi/[email protected]
[1.5.0]: https://github.com/hifi-finance/hifi/compare/@hifi/[email protected]...@hifi/[email protected]
[1.4.0]: https://github.com/hifi-finance/hifi/compare/@hifi/[email protected]...@hifi/[email protected]
[1.3.1]: https://github.com/hifi-finance/hifi/compare/@hifi/[email protected]...@hifi/[email protected]
Expand Down
4 changes: 4 additions & 0 deletions packages/flash-swap/contracts/test/BalanceSheetV1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.4;

import "@hifi/protocol/contracts/core/balanceSheet/BalanceSheetV1.sol";
4 changes: 4 additions & 0 deletions packages/flash-swap/contracts/test/ChainlinkOperator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.4;

import "@hifi/protocol/contracts/oracles/ChainlinkOperator.sol";
4 changes: 4 additions & 0 deletions packages/flash-swap/contracts/test/FintrollerV1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// SPDX-License-Identifier: Unlicense
pragma solidity >=0.8.4;

import "@hifi/protocol/contracts/core/fintroller/FintrollerV1.sol";
14 changes: 7 additions & 7 deletions packages/flash-swap/package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
Expand All @@ -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",
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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);
});
});

Expand All @@ -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);
});
});

Expand Down
12 changes: 6 additions & 6 deletions packages/flash-swap/test/shared/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -49,15 +46,18 @@ export async function integrationFixture(signers: Signer[]): Promise<Integration
await waffle.deployContract(deployer, simplePriceFeedArtifact, [])
);

const chainlinkOperatorArtifact: Artifact = await artifacts.readArtifact("ChainlinkOperator");
const oracle: ChainlinkOperator = <ChainlinkOperator>(
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 = <FintrollerV1>await waffle.deployContract(deployer, fintrollerV1Artifact, []);
await fintroller.connect(deployer).initialize();

const balanceSheetV1Artifact: Artifact = await artifacts.readArtifact("BalanceSheetV1");
const balanceSheet: BalanceSheetV1 = <BalanceSheetV1>(
await waffle.deployContract(deployer, balanceSheetV1Artifact, [])
);
Expand Down
8 changes: 4 additions & 4 deletions packages/flash-swap/test/shared/types.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit a53aaf2

Please sign in to comment.