fixed buyCollateral function

This commit is contained in:
Thrilok kumar 2022-09-03 01:56:13 +05:30
parent a4bf92bdbb
commit 15b978a577

View File

@ -253,9 +253,7 @@ abstract contract Helpers is DSMath, Basic {
)
);
uint256 initialCollBal_ = CometInterface(params.market)
.userCollateral(address(this), params.buyAsset)
.balance;
uint256 initialCollBal_ = TokenInterface(params.buyAsset).balanceOf(address(this));
approve(TokenInterface(params.sellToken), params.market, sellAmt_);
CometInterface(params.market).buyCollateral(
@ -264,9 +262,8 @@ abstract contract Helpers is DSMath, Basic {
sellAmt_,
address(this)
);
uint256 finalCollBal_ = CometInterface(params.market)
.userCollateral(address(this), params.buyAsset)
.balance;
uint256 finalCollBal_ = TokenInterface(params.buyAsset).balanceOf(address(this));
uint256 buyAmt_ = sub(finalCollBal_, initialCollBal_);
require(slippageAmt_ <= buyAmt_, "too-much-slippage");