mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
isEth fix
This commit is contained in:
parent
f8f57d6b18
commit
c6c3244c1f
|
@ -207,14 +207,15 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
params.market != address(0) && params.buyAsset != address(0),
|
params.market != address(0) && params.buyAsset != address(0),
|
||||||
"invalid market/token address"
|
"invalid market/token address"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
bool isEth = params.sellToken == ethAddr;
|
||||||
|
params.sellToken = isEth ? wethAddr : params.sellToken;
|
||||||
|
|
||||||
require(
|
require(
|
||||||
params.sellToken == getBaseToken(params.market),
|
params.sellToken == getBaseToken(params.market),
|
||||||
"invalid-sell-token"
|
"invalid-sell-token"
|
||||||
);
|
);
|
||||||
|
|
||||||
bool isEth = params.sellToken == ethAddr;
|
|
||||||
params.sellToken = isEth ? wethAddr : params.sellToken;
|
|
||||||
|
|
||||||
if (sellAmt_ == uint256(-1)) {
|
if (sellAmt_ == uint256(-1)) {
|
||||||
sellAmt_ = isEth
|
sellAmt_ = isEth
|
||||||
? address(this).balance
|
? address(this).balance
|
||||||
|
@ -236,7 +237,9 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
uint256 initialCollBal_ = TokenInterface(params.buyAsset).balanceOf(address(this));
|
uint256 initialCollBal_ = TokenInterface(params.buyAsset).balanceOf(
|
||||||
|
address(this)
|
||||||
|
);
|
||||||
|
|
||||||
approve(TokenInterface(params.sellToken), params.market, sellAmt_);
|
approve(TokenInterface(params.sellToken), params.market, sellAmt_);
|
||||||
CometInterface(params.market).buyCollateral(
|
CometInterface(params.market).buyCollateral(
|
||||||
|
@ -246,7 +249,9 @@ abstract contract Helpers is DSMath, Basic {
|
||||||
address(this)
|
address(this)
|
||||||
);
|
);
|
||||||
|
|
||||||
uint256 finalCollBal_ = TokenInterface(params.buyAsset).balanceOf(address(this));
|
uint256 finalCollBal_ = TokenInterface(params.buyAsset).balanceOf(
|
||||||
|
address(this)
|
||||||
|
);
|
||||||
|
|
||||||
uint256 buyAmt_ = sub(finalCollBal_, initialCollBal_);
|
uint256 buyAmt_ = sub(finalCollBal_, initialCollBal_);
|
||||||
require(slippageAmt_ <= buyAmt_, "too-much-slippage");
|
require(slippageAmt_ <= buyAmt_, "too-much-slippage");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user