From d810407d32467d3395e43cc97c1c5dc21c1e7d95 Mon Sep 17 00:00:00 2001 From: Mark Aiken Date: Tue, 14 Dec 2021 15:12:14 -0800 Subject: [PATCH] Address PR feedback, round 2 --- .../polygon/connectors/qidao/helpers.sol | 9 +- contracts/polygon/connectors/qidao/main.sol | 12 +-- test/polygon/qidao/qidao.test.ts | 102 ------------------ 3 files changed, 11 insertions(+), 112 deletions(-) diff --git a/contracts/polygon/connectors/qidao/helpers.sol b/contracts/polygon/connectors/qidao/helpers.sol index 6af8eaba..cf00d71a 100644 --- a/contracts/polygon/connectors/qidao/helpers.sol +++ b/contracts/polygon/connectors/qidao/helpers.sol @@ -27,6 +27,7 @@ abstract contract Helpers is DSMath, Basic { erc20StablecoinInterface vault = erc20StablecoinInterface(vaultAddress); uint256 _vaultId = getUint(getId, vaultId); vault.destroyVault(_vaultId); + return _vaultId; } function _deposit( @@ -35,9 +36,9 @@ abstract contract Helpers is DSMath, Basic { uint256 vaultId, uint256 amt ) public { - bool isEth = token == maticAddr; + bool isMatic = token == maticAddr; - if (isEth) { + if (isMatic) { maticStablecoinInterface vault = maticStablecoinInterface( vaultAddress ); @@ -58,9 +59,9 @@ abstract contract Helpers is DSMath, Basic { uint256 vaultId, uint256 amt ) public returns (uint256 initialBal, uint256 finalBal) { - bool isEth = token == maticAddr; + bool isMatic = token == maticAddr; - if (isEth) { + if (isMatic) { initialBal = address(this).balance; maticStablecoinInterface vault = maticStablecoinInterface( vaultAddress diff --git a/contracts/polygon/connectors/qidao/main.sol b/contracts/polygon/connectors/qidao/main.sol index c725e6e4..d101dba5 100644 --- a/contracts/polygon/connectors/qidao/main.sol +++ b/contracts/polygon/connectors/qidao/main.sol @@ -23,7 +23,7 @@ abstract contract QiDaoResolver is Events, Helpers { returns (string memory _eventName, bytes memory _eventParam) { uint256 _vaultId = getVaultId(vaultAddress, setId); - _eventName = "LogCreateVault(uint256, address)"; + _eventName = "LogCreateVault(uint256,address)"; _eventParam = abi.encode(_vaultId, address(this)); } @@ -44,7 +44,7 @@ abstract contract QiDaoResolver is Events, Helpers { returns (string memory _eventName, bytes memory _eventParam) { uint256 _vaultId = _destroyVault(vaultAddress, vaultId, getId); - _eventName = "LogDestroyVault(uint256, address)"; + _eventName = "LogDestroyVault(uint256,address)"; _eventParam = abi.encode(_vaultId, address(this)); } @@ -82,7 +82,7 @@ abstract contract QiDaoResolver is Events, Helpers { setUint(setAmtId, _amt); setUint(getVaultId, _vaultId); - _eventName = "LogDepositCollateral(uint256, uint256, uint256, uint256, uint256, uint256)"; + _eventName = "LogDepositCollateral(uint256,uint256,uint256,uint256,uint256,uint256)"; _eventParam = abi.encode( _vaultId, _amt, @@ -128,7 +128,7 @@ abstract contract QiDaoResolver is Events, Helpers { setUint(setAmtId, _amt); - _eventName = "LogWithdrawCollateral(uint256, uint256, uint256, uint256, uint256, uint256)"; + _eventName = "LogWithdrawCollateral(uint256,uint256,uint256,uint256,uint256,uint256)"; _eventParam = abi.encode( _vaultId, _amt, @@ -172,7 +172,7 @@ abstract contract QiDaoResolver is Events, Helpers { setUint(setAmtId, _amt); setUint(getVaultId, _vaultId); - _eventName = "LogBorrow(uint256, uint256, uint256, uint256, uint256, uint256);"; + _eventName = "LogBorrow(uint256,uint256,uint256,uint256,uint256,uint256);"; _eventParam = abi.encode( _vaultId, _amt, @@ -215,7 +215,7 @@ abstract contract QiDaoResolver is Events, Helpers { setUint(setAmtId, _amt); setUint(getVaultId, _vaultId); - _eventName = "LogPayBack(uint256, uint256, uint256, uint256, uint256, uint256)"; + _eventName = "LogPayBack(uint256,uint256,uint256,uint256,uint256,uint256)"; _eventParam = abi.encode( _vaultId, _amt, diff --git a/test/polygon/qidao/qidao.test.ts b/test/polygon/qidao/qidao.test.ts index 4daf463f..3168d8fc 100644 --- a/test/polygon/qidao/qidao.test.ts +++ b/test/polygon/qidao/qidao.test.ts @@ -164,107 +164,5 @@ describe("QiDao", function() { parseEther("9.975") ); }); - // it("Should borrow and payback half DAI from Aave V2", async function() { - // const amt = parseEther("100"); // 100 DAI - // // const setId = "83478237"; - // await addLiquidity("dai", dsaWallet0.address, parseEther("1")); - // let spells = [ - // { - // connector: connectorName, - // method: "borrow", - // args: [polygonTokens.dai.address, amt, 2, 0, 0], - // }, - // { - // connector: connectorName, - // method: "payback", - // args: [polygonTokens.dai.address, amt.div(2), 2, 0, 0], - // }, - // ]; - // - // let tx = await dsaWallet0 - // .connect(wallet0) - // .cast(...encodeSpells(spells), wallet1.address); - // await tx.wait(); - // expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte( - // ethers.utils.parseEther("9") - // ); - // - // spells = [ - // { - // connector: connectorName, - // method: "payback", - // args: [polygonTokens.dai.address, constants.max_value, 2, 0, 0], - // }, - // ]; - // - // tx = await dsaWallet0 - // .connect(wallet0) - // .cast(...encodeSpells(spells), wallet1.address); - // await tx.wait(); - // expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte( - // ethers.utils.parseEther("9") - // ); - // }); - // - // it("Should deposit all ETH in Aave V2", async function() { - // const spells = [ - // { - // connector: connectorName, - // method: "deposit", - // args: [polygonTokens.matic.address, constants.max_value, 0, 0], - // }, - // ]; - // - // const tx = await dsaWallet0 - // .connect(wallet0) - // .cast(...encodeSpells(spells), wallet1.address); - // await tx.wait(); - // expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte( - // ethers.utils.parseEther("0") - // ); - // }); - // - // it("Should withdraw all ETH from Aave V2", async function() { - // const spells = [ - // { - // connector: connectorName, - // method: "withdraw", - // args: [polygonTokens.eth.address, constants.max_value, 0, 0], - // }, - // ]; - // - // const tx = await dsaWallet0 - // .connect(wallet0) - // .cast(...encodeSpells(spells), wallet1.address); - // await tx.wait(); - // expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte( - // ethers.utils.parseEther("10") - // ); - // }); - // - // it("should deposit and withdraw", async () => { - // const amt = parseEther("1"); // 1 eth - // const setId = "834782373"; - // const spells = [ - // { - // connector: connectorName, - // method: "deposit", - // args: [polygonTokens.eth.address, amt, 0, setId], - // }, - // { - // connector: connectorName, - // method: "withdraw", - // args: [polygonTokens.eth.address, amt, setId, 0], - // }, - // ]; - // - // const tx = await dsaWallet0 - // .connect(wallet0) - // .cast(...encodeSpells(spells), wallet1.address); - // await tx.wait(); - // expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte( - // ethers.utils.parseEther("10") - // ); - // }); }); });