mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
errors fix
This commit is contained in:
parent
6289a0ae81
commit
c0ea8a5523
|
@ -39,29 +39,13 @@ abstract contract Helpers is DSMath, Basic {
|
|||
address to,
|
||||
uint256 amt
|
||||
) internal {
|
||||
if (from == address(0) && to == address(0)) {
|
||||
CometInterface(market).withdraw(token, amt);
|
||||
} else if (from == address(0)) {
|
||||
if (from == address(0)) {
|
||||
CometInterface(market).withdrawTo(to, token, amt);
|
||||
} else if (from != address(0) && to != address(0)) {
|
||||
CometInterface(market).withdrawFrom(from, to, token, amt);
|
||||
}
|
||||
}
|
||||
|
||||
function _transfer(
|
||||
address market,
|
||||
address token,
|
||||
address from,
|
||||
address to,
|
||||
uint256 amt
|
||||
) internal {
|
||||
if (from == address(0)) {
|
||||
CometInterface(market).transferAsset(to, token, amt);
|
||||
} else {
|
||||
CometInterface(market).transferAssetFrom(from, to, token, amt);
|
||||
}
|
||||
}
|
||||
|
||||
function _borrow(BorrowWithdrawParams memory params)
|
||||
internal
|
||||
returns (uint256 amt, uint256 setId)
|
||||
|
@ -93,6 +77,8 @@ abstract contract Helpers is DSMath, Basic {
|
|||
amt_ = sub(finalBal, initialBal);
|
||||
|
||||
convertWethToEth(isEth, tokenContract, amt_);
|
||||
if (params.from == address(0) || params.to == address(this))
|
||||
convertWethToEth(isEth, tokenContract, amt_);
|
||||
|
||||
setUint(params.setId, amt_);
|
||||
|
||||
|
@ -111,7 +97,7 @@ abstract contract Helpers is DSMath, Basic {
|
|||
"invalid market/token address"
|
||||
);
|
||||
|
||||
bool isEth = params.token == ethAddr || params.token == wethAddr;
|
||||
bool isEth = params.token == ethAddr;
|
||||
address token_ = isEth ? wethAddr : params.token;
|
||||
|
||||
TokenInterface tokenContract = TokenInterface(token_);
|
||||
|
@ -142,7 +128,8 @@ abstract contract Helpers is DSMath, Basic {
|
|||
);
|
||||
amt_ = sub(initialBal, finalBal);
|
||||
|
||||
convertWethToEth(isEth, tokenContract, amt_);
|
||||
if (params.from == address(0) || params.to == address(this))
|
||||
convertWethToEth(isEth, tokenContract, amt_);
|
||||
|
||||
setUint(params.setId, amt_);
|
||||
|
||||
|
@ -150,6 +137,20 @@ abstract contract Helpers is DSMath, Basic {
|
|||
setId = params.setId;
|
||||
}
|
||||
|
||||
function _transfer(
|
||||
address market,
|
||||
address token,
|
||||
address from,
|
||||
address to,
|
||||
uint256 amt
|
||||
) internal {
|
||||
if (from == address(0)) {
|
||||
CometInterface(market).transferAsset(to, token, amt);
|
||||
} else {
|
||||
CometInterface(market).transferAssetFrom(from, to, token, amt);
|
||||
}
|
||||
}
|
||||
|
||||
function getAccountSupplyBalanceOfAsset(
|
||||
address account,
|
||||
address market,
|
||||
|
|
|
@ -11,7 +11,6 @@ import { TokenInterface } from "../../../common/interfaces.sol";
|
|||
import { Helpers } from "./helpers.sol";
|
||||
import { Events } from "./events.sol";
|
||||
import { CometInterface } from "./interface.sol";
|
||||
import "hardhat/console.sol";
|
||||
|
||||
abstract contract CompoundV3Resolver is Events, Helpers {
|
||||
/**
|
||||
|
@ -235,10 +234,6 @@ abstract contract CompoundV3Resolver is Events, Helpers {
|
|||
|
||||
amt_ = sub(initialBal, finalBal);
|
||||
|
||||
console.log(amt_);
|
||||
console.log(initialBal);
|
||||
console.log(finalBal);
|
||||
|
||||
convertWethToEth(isEth, tokenContract, amt_);
|
||||
|
||||
setUint(setId, amt_);
|
||||
|
@ -580,7 +575,6 @@ abstract contract CompoundV3Resolver is Events, Helpers {
|
|||
require(amt_ <= borrowBal, "repay-amt-greater-than-debt");
|
||||
}
|
||||
|
||||
convertEthToWeth(isEth, tokenContract, amt_);
|
||||
approve(tokenContract, market, amt_);
|
||||
|
||||
CometInterface(market).supplyFrom(from, to, token_, amt_);
|
||||
|
|
|
@ -367,7 +367,7 @@ describe("Compound III", function () {
|
|||
|
||||
it("should withdraw some ETH collateral", async function () {
|
||||
let initialBal = await ethers.provider.getBalance(dsaWallet0.address);
|
||||
console.log(initialBal)
|
||||
console.log(initialBal);
|
||||
const amount = ethers.utils.parseEther("2");
|
||||
const spells = [
|
||||
{
|
||||
|
@ -382,12 +382,14 @@ describe("Compound III", function () {
|
|||
expect((await comet.connect(signer).userCollateral(dsaWallet0.address, tokens.weth.address)).balance).to.be.gte(
|
||||
ethers.utils.parseEther("4")
|
||||
);
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(
|
||||
ethers.utils.parseEther(initialBal.add(2).toString())
|
||||
);
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.gte(initialBal.add(2).toString());
|
||||
});
|
||||
|
||||
it("manager should be able to withdraw collateral from the position", async function () {
|
||||
await wallet1.sendTransaction({
|
||||
to: tokens.weth.address,
|
||||
value: ethers.utils.parseEther("10")
|
||||
});
|
||||
const amount = ethers.constants.MaxUint256;
|
||||
const spells = [
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user