mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
commit
9aca1e987f
|
@ -39,21 +39,6 @@ abstract contract Helpers is DSMath, Basic {
|
|||
baseToken = CometInterface(market).baseToken();
|
||||
}
|
||||
|
||||
/**
|
||||
*@dev helper function for following withdraw or borrow cases:
|
||||
*withdrawFrom - for `withdrawFromUsingManager` withdraws from src to dest using DSA as manager
|
||||
*withdrawTo - for `withdrawTo` withdraws from DSA to dest address.
|
||||
*/
|
||||
function _withdrawHelper(
|
||||
address market,
|
||||
address token,
|
||||
address from,
|
||||
address to,
|
||||
uint256 amt
|
||||
) internal {
|
||||
CometInterface(market).withdrawFrom(from, to, token, amt);
|
||||
}
|
||||
|
||||
function _borrow(BorrowWithdrawParams memory params)
|
||||
internal
|
||||
returns (uint256 amt, uint256 setId)
|
||||
|
@ -82,7 +67,12 @@ abstract contract Helpers is DSMath, Basic {
|
|||
params.from
|
||||
);
|
||||
|
||||
CometInterface(params.market).withdrawFrom(params.from, params.to, token_, amt_);
|
||||
CometInterface(params.market).withdrawFrom(
|
||||
params.from,
|
||||
params.to,
|
||||
token_,
|
||||
amt_
|
||||
);
|
||||
|
||||
uint256 finalBal = CometInterface(params.market).borrowBalanceOf(
|
||||
params.from
|
||||
|
@ -143,7 +133,12 @@ abstract contract Helpers is DSMath, Basic {
|
|||
amt_ = amt_ == uint256(-1) ? initialBal : amt_;
|
||||
}
|
||||
|
||||
CometInterface(params.market).withdrawFrom(params.from, params.to, token_, amt_);
|
||||
CometInterface(params.market).withdrawFrom(
|
||||
params.from,
|
||||
params.to,
|
||||
token_,
|
||||
amt_
|
||||
);
|
||||
|
||||
uint256 finalBal = _getAccountSupplyBalanceOfAsset(
|
||||
params.from,
|
||||
|
@ -161,16 +156,6 @@ abstract contract Helpers is DSMath, Basic {
|
|||
setId = params.setId;
|
||||
}
|
||||
|
||||
function _transfer(
|
||||
address market,
|
||||
address token,
|
||||
address from,
|
||||
address to,
|
||||
uint256 amt
|
||||
) internal {
|
||||
CometInterface(market).transferAssetFrom(from, to, token, amt);
|
||||
}
|
||||
|
||||
function _getAccountSupplyBalanceOfAsset(
|
||||
address account,
|
||||
address market,
|
||||
|
@ -204,8 +189,8 @@ abstract contract Helpers is DSMath, Basic {
|
|||
} else if (action == Action.DEPOSIT) {
|
||||
if (isEth) bal_ = src.balance;
|
||||
else bal_ = TokenInterface(token).balanceOf(src);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
amt = bal_ < allowance_ ? bal_ : allowance_;
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ abstract contract CompoundV3Resolver is Events, Helpers {
|
|||
market != address(0) && token != address(0) && to != address(0),
|
||||
"invalid market/token/to address"
|
||||
);
|
||||
require(from != address(this), "from-cannot-be-address(this)-use-paybackOnBehalf");
|
||||
require(from != address(this), "from-cannot-be-address(this)-use-depositOnBehalf");
|
||||
|
||||
bool isEth = token == ethAddr;
|
||||
address token_ = isEth? wethAddr : token;
|
||||
|
@ -174,7 +174,7 @@ abstract contract CompoundV3Resolver is Events, Helpers {
|
|||
token_,
|
||||
from,
|
||||
amt_,
|
||||
isEth,
|
||||
token == ethAddr,
|
||||
Action.DEPOSIT
|
||||
);
|
||||
|
||||
|
@ -719,7 +719,7 @@ abstract contract CompoundV3Resolver is Events, Helpers {
|
|||
token_,
|
||||
from,
|
||||
amt_,
|
||||
isEth,
|
||||
token == ethAddr,
|
||||
Action.REPAY
|
||||
);
|
||||
} else {
|
||||
|
@ -811,9 +811,9 @@ abstract contract CompoundV3Resolver is Events, Helpers {
|
|||
|
||||
address token_ = token == ethAddr ? wethAddr : token;
|
||||
|
||||
amt_ = amt_ == uint256(-1) ? _getAccountSupplyBalanceOfAsset(address(this)) : amt_;
|
||||
amt_ = amt_ == uint256(-1) ? _getAccountSupplyBalanceOfAsset(address(this), market, token) : amt_;
|
||||
|
||||
CometInterface(market).transferAssetFrom(address(this), dest, token_, amt);
|
||||
CometInterface(market).transferAssetFrom(address(this), dest, token_, amt_);
|
||||
|
||||
setUint(setId, amt_);
|
||||
|
||||
|
@ -853,7 +853,7 @@ abstract contract CompoundV3Resolver is Events, Helpers {
|
|||
|
||||
address token_ = token == ethAddr ? wethAddr : token;
|
||||
|
||||
amt_ = amt_ == uint256(-1) ? _getAccountSupplyBalanceOfAsset(src) : amt_;
|
||||
amt_ = amt_ == uint256(-1) ? _getAccountSupplyBalanceOfAsset(src, market, token) : amt_;
|
||||
|
||||
CometInterface(market).transferAssetFrom(src, dest, token_, amt_);
|
||||
|
||||
|
|
|
@ -557,26 +557,6 @@ describe("Compound III", function () {
|
|||
expect(await wethContract.connect(wallet0).balanceOf(dsaWallet0.address)).to.be.lte(initialBal.sub(amount));
|
||||
});
|
||||
|
||||
it("should deposit eth using manager same as 'from'", async function () {
|
||||
const amount = ethers.utils.parseEther("1");
|
||||
await wethContract.connect(dsa0Signer).approve(market, amount);
|
||||
let initialBal = await ethers.provider.getBalance(dsaWallet0.address);
|
||||
|
||||
const spells = [
|
||||
{
|
||||
connector: connectorName,
|
||||
method: "depositFromUsingManager",
|
||||
args: [market, tokens.eth.address, dsaWallet0.address, dsaWallet1.address, amount, 0, 0]
|
||||
}
|
||||
];
|
||||
|
||||
const tx = await dsaWallet0.connect(wallet0).cast(...encodeSpells(spells), wallet1.address);
|
||||
const receipt = await tx.wait();
|
||||
expect((await comet.connect(signer).userCollateral(dsaWallet1.address, tokens.weth.address)).balance).to.be.gte(
|
||||
ethers.utils.parseEther("2")
|
||||
);
|
||||
expect(await ethers.provider.getBalance(dsaWallet0.address)).to.be.lte(initialBal.sub(amount));
|
||||
});
|
||||
it("should allow manager for dsaWallet0's collateral", async function () {
|
||||
const spells = [
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user