Skip to content

Commit

Permalink
feat: FlashmintHYETHV2 (#179)
Browse files Browse the repository at this point in the history
* First version of FlashhMintHyETHV2 contract

* Run old integration tests against new version

* Adjust contract logic for swapping between eth and erc4626 asset

* Adjust tests to new composition including morpho

* Fix arbitrum integration tests
  • Loading branch information
ckoopmann authored Jun 27, 2024
1 parent 6477886 commit cf72538
Show file tree
Hide file tree
Showing 8 changed files with 1,194 additions and 9 deletions.
693 changes: 693 additions & 0 deletions contracts/exchangeIssuance/FlashMintHyETHV2.sol

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions contracts/interfaces/IERC4626.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity 0.6.10;

interface IERC4626 {
function asset() external view returns (address);
function deposit(uint256 assets_, address receiver_) external returns (uint256 shares_);
function mint(uint256 shares_, address receiver_) external returns (uint256 assets_);
function redeem(uint256 shares_, address receiver_, address owner_) external returns (uint256 assetsAfterFee_);
Expand Down
1 change: 1 addition & 0 deletions test/integration/arbitrum/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const PRODUCTION_ADDRESSES = {
setFork: {
controller: "0xCd79A0B9aeca0eCE7eA59d14338ea330cb1cb2d7",
debtIssuanceModuleV2: "0x120d2f26B7ffd35a8917415A5766Fa63B2af94aa",
debtIssuanceModuleV3: "0x4AC26c26116Fa976352b70700af58Bc2442489d8",
aaveV3LeverageModule: "0x6D1b74e18064172D028C5EE7Af5D0ccC26f2A4Ae",
extensions: {
ETH2X: {
Expand Down
16 changes: 8 additions & 8 deletions test/integration/arbitrum/flashMintLeveragedExtended.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if (process.env.INTEGRATIONTEST) {
let weth: IWETH;
let usdc: IERC20;

setBlockNumber(201830000);
setBlockNumber(225770000);

before(async () => {
[owner] = await getAccounts();
Expand All @@ -69,7 +69,7 @@ if (process.env.INTEGRATIONTEST) {
addresses.dexes.uniV3.router,
addresses.dexes.uniV3.quoter,
addresses.setFork.controller,
addresses.setFork.debtIssuanceModuleV2,
addresses.setFork.debtIssuanceModuleV3,
addresses.setFork.aaveV3LeverageModule,
addresses.lending.aaveV3.lendingPool,
addresses.dexes.curve.addressProvider,
Expand Down Expand Up @@ -103,7 +103,7 @@ if (process.env.INTEGRATIONTEST) {

it("debt issuance module address is set correctly", async () => {
expect(await flashMintLeveraged.debtIssuanceModule()).to.eq(
utils.getAddress(addresses.setFork.debtIssuanceModuleV2),
utils.getAddress(addresses.setFork.debtIssuanceModuleV3),
);
});

Expand Down Expand Up @@ -131,11 +131,11 @@ if (process.env.INTEGRATIONTEST) {

await aweth
.connect(owner.wallet)
.approve(addresses.setFork.debtIssuanceModuleV2, ether(10));
.approve(addresses.setFork.debtIssuanceModuleV3, ether(10));
await weth.connect(owner.wallet).approve(flashMintLeveraged.address, ether(100));
const debtIssuanceModule = (await ethers.getContractAt(
"IDebtIssuanceModule",
addresses.setFork.debtIssuanceModuleV2,
addresses.setFork.debtIssuanceModuleV3,
owner.wallet,
)) as IDebtIssuanceModule;

Expand Down Expand Up @@ -173,15 +173,15 @@ if (process.env.INTEGRATIONTEST) {
expect(
await collateralAToken.allowance(
flashMintLeveraged.address,
addresses.setFork.debtIssuanceModuleV2,
addresses.setFork.debtIssuanceModuleV3,
),
).to.equal(MAX_UINT_256);
});
it("should adjust debt token allowance correctly", async () => {
expect(
await debtToken.allowance(
flashMintLeveraged.address,
addresses.setFork.debtIssuanceModuleV2,
addresses.setFork.debtIssuanceModuleV3,
),
).to.equal(MAX_UINT_256);
});
Expand All @@ -198,7 +198,7 @@ if (process.env.INTEGRATIONTEST) {
.transfer(owner.address, utils.parseUnits("10000", 6));
}
// This is done to avoid flaky "Invalid transfer in, results in undercollateralization" error
// See: https://github.com/IndexCoop/index-protocol/blob/1a587d93d273d9004d03f1235c395f6f7cd147dc/test/protocol/modules/v1/debtIssuanceModuleV2.spec.ts#L730
// See: https://github.com/IndexCoop/index-protocol/blob/1a587d93d273d9004d03f1235c395f6f7cd147dc/test/protocol/modules/v1/debtIssuanceModuleV3.spec.ts#L730
// TODO: Review if we have to do this in production.
await aweth.transfer(setToken.address, ether(0.000001));
});
Expand Down
1 change: 1 addition & 0 deletions test/integration/ethereum/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const PRODUCTION_ADDRESSES = {
rsEth: "0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7",
rswEth: "0xFAe103DC9cf190eD75350761e95403b7b8aFa6c0",
acrossWethLP: "0x28F77208728B0A45cAb24c4868334581Fe86F95B",
morphoRe7WETH: "0x78Fc2c2eD1A4cDb5402365934aE5648aDAd094d0",
},
whales: {
stEth: "0xdc24316b9ae028f1497c275eb9192a3ea0f67022",
Expand Down
2 changes: 1 addition & 1 deletion test/integration/ethereum/flashMintHyETH.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const NO_OP_SWAP_DATA: SwapData = {
};

if (process.env.INTEGRATIONTEST) {
describe.only("FlashMintHyETH - Integration Test", async () => {
describe("FlashMintHyETH - Integration Test", async () => {
const addresses = PRODUCTION_ADDRESSES;
let owner: Account;
let deployer: DeployHelper;
Expand Down
Loading

0 comments on commit cf72538

Please sign in to comment.