mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
fixes
This commit is contained in:
parent
791d04091a
commit
611ff8a3e7
|
@ -28,8 +28,7 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
|
|
||||||
enum Action {
|
enum Action {
|
||||||
REPAY,
|
REPAY,
|
||||||
DEPOSIT,
|
DEPOSIT
|
||||||
TRANSFER
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBaseToken(address market)
|
function getBaseToken(address market)
|
||||||
|
@ -52,11 +51,7 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
address to,
|
address to,
|
||||||
uint256 amt
|
uint256 amt
|
||||||
) internal {
|
) internal {
|
||||||
if (from == address(this)) {
|
CometInterface(market).withdrawFrom(from, to, token, amt);
|
||||||
CometInterface(market).withdrawTo(to, token, amt);
|
|
||||||
} else {
|
|
||||||
CometInterface(market).withdrawFrom(from, to, token, amt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _borrow(BorrowWithdrawParams memory params)
|
function _borrow(BorrowWithdrawParams memory params)
|
||||||
|
@ -173,11 +168,7 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
address to,
|
address to,
|
||||||
uint256 amt
|
uint256 amt
|
||||||
) internal {
|
) internal {
|
||||||
if (from == address(0)) {
|
CometInterface(market).transferAssetFrom(from, to, token, amt);
|
||||||
CometInterface(market).transferAsset(to, token, amt);
|
|
||||||
} else {
|
|
||||||
CometInterface(market).transferAssetFrom(from, to, token, amt);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getAccountSupplyBalanceOfAsset(
|
function _getAccountSupplyBalanceOfAsset(
|
||||||
|
@ -213,13 +204,9 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
} else if (action == Action.DEPOSIT) {
|
} else if (action == Action.DEPOSIT) {
|
||||||
if (isEth) bal_ = src.balance;
|
if (isEth) bal_ = src.balance;
|
||||||
else bal_ = TokenInterface(token).balanceOf(src);
|
else bal_ = TokenInterface(token).balanceOf(src);
|
||||||
} else if (action == Action.TRANSFER) {
|
|
||||||
bal_ = (token == getBaseToken(market))
|
|
||||||
? TokenInterface(market).balanceOf(src)
|
|
||||||
: CometInterface(market).userCollateral(src, token).balance;
|
|
||||||
}
|
}
|
||||||
if (action == Action.TRANSFER) amt = bal_;
|
|
||||||
else amt = bal_ < allowance_ ? bal_ : allowance_;
|
amt = bal_ < allowance_ ? bal_ : allowance_;
|
||||||
}
|
}
|
||||||
if (src == address(this))
|
if (src == address(this))
|
||||||
convertEthToWeth(isEth, TokenInterface(token), amt);
|
convertEthToWeth(isEth, TokenInterface(token), amt);
|
||||||
|
|
|
@ -287,7 +287,7 @@ abstract contract CompoundV3Resolver is Events, Helpers {
|
||||||
BorrowWithdrawParams({
|
BorrowWithdrawParams({
|
||||||
market: market,
|
market: market,
|
||||||
token: token,
|
token: token,
|
||||||
from: address(0),
|
from: address(this),
|
||||||
to: to,
|
to: to,
|
||||||
amt: amt,
|
amt: amt,
|
||||||
getId: getId,
|
getId: getId,
|
||||||
|
@ -407,12 +407,10 @@ abstract contract CompoundV3Resolver is Events, Helpers {
|
||||||
|
|
||||||
TokenInterface tokenContract = TokenInterface(token_);
|
TokenInterface tokenContract = TokenInterface(token_);
|
||||||
|
|
||||||
if (token_ == getBaseToken(market)) {
|
require(
|
||||||
require(
|
CometInterface(market).balanceOf(address(this)) == 0,
|
||||||
CometInterface(market).balanceOf(address(this)) == 0,
|
"borrow-disabled-when-supplied-base"
|
||||||
"borrow-disabled-when-supplied-base"
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint256 initialBal = CometInterface(market).borrowBalanceOf(
|
uint256 initialBal = CometInterface(market).borrowBalanceOf(
|
||||||
address(this)
|
address(this)
|
||||||
|
@ -464,7 +462,7 @@ abstract contract CompoundV3Resolver is Events, Helpers {
|
||||||
BorrowWithdrawParams({
|
BorrowWithdrawParams({
|
||||||
market: market,
|
market: market,
|
||||||
token: token,
|
token: token,
|
||||||
from: address(0),
|
from: address(this),
|
||||||
to: to,
|
to: to,
|
||||||
amt: amt,
|
amt: amt,
|
||||||
getId: getId,
|
getId: getId,
|
||||||
|
@ -804,23 +802,11 @@ abstract contract CompoundV3Resolver is Events, Helpers {
|
||||||
"invalid market/token/to address"
|
"invalid market/token/to address"
|
||||||
);
|
);
|
||||||
|
|
||||||
bool isEth = token == ethAddr;
|
address token_ = token == ethAddr ? wethAddr : token;
|
||||||
address token_ = isEth ? wethAddr : token;
|
|
||||||
TokenInterface tokenContract = TokenInterface(token_);
|
|
||||||
|
|
||||||
convertEthToWeth(isEth, tokenContract, amt_);
|
amt_ = amt_ == uint256(-1) ? _getAccountSupplyBalanceOfAsset(address(this)) : amt_;
|
||||||
|
|
||||||
amt_ = amt_ == uint256(-1)
|
CometInterface(market).transferAssetFrom(address(this), dest, token_, amt);
|
||||||
? (
|
|
||||||
(token_ == getBaseToken(market))
|
|
||||||
? TokenInterface(market).balanceOf(address(this))
|
|
||||||
: CometInterface(market)
|
|
||||||
.userCollateral(address(this), token_)
|
|
||||||
.balance
|
|
||||||
)
|
|
||||||
: amt_;
|
|
||||||
|
|
||||||
_transfer(market, token_, address(0), dest, amt_);
|
|
||||||
|
|
||||||
setUint(setId, amt_);
|
setUint(setId, amt_);
|
||||||
|
|
||||||
|
@ -858,20 +844,11 @@ abstract contract CompoundV3Resolver is Events, Helpers {
|
||||||
"invalid market/token/to address"
|
"invalid market/token/to address"
|
||||||
);
|
);
|
||||||
|
|
||||||
bool isEth = token == ethAddr;
|
address token_ = token == ethAddr ? wethAddr : token;
|
||||||
address token_ = isEth ? wethAddr : token;
|
|
||||||
TokenInterface tokenContract = TokenInterface(token_);
|
|
||||||
|
|
||||||
amt_ = _calculateFromAmount(
|
amt_ = amt_ == uint256(-1) ? _getAccountSupplyBalanceOfAsset(src) : amt_;
|
||||||
market,
|
|
||||||
token_,
|
|
||||||
src,
|
|
||||||
amt_,
|
|
||||||
isEth,
|
|
||||||
Action.TRANSFER
|
|
||||||
);
|
|
||||||
|
|
||||||
_transfer(market, token_, src, dest, amt_);
|
CometInterface(market).transferAssetFrom(src, dest, token_, amt_);
|
||||||
|
|
||||||
setUint(setId, amt_);
|
setUint(setId, amt_);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user