function names

This commit is contained in:
Richa-iitr 2022-09-02 20:07:38 +05:30
parent 5571cf187e
commit cf3c71986d
2 changed files with 18 additions and 18 deletions

View File

@ -18,10 +18,10 @@ abstract contract Helpers is DSMath, Basic {
uint256 setId;
}
enum ACTION {
repay,
deposit,
transfer
enum Action {
REPAY,
DEPOSIT,
TRANSFER
}
function getBaseToken(address market)
@ -113,7 +113,7 @@ abstract contract Helpers is DSMath, Basic {
TokenInterface tokenContract = TokenInterface(token_);
params.from = params.from == address(0) ? address(this) : params.from;
uint256 initialBal = getAccountSupplyBalanceOfAsset(
uint256 initialBal = _getAccountSupplyBalanceOfAsset(
params.from,
params.market,
token_
@ -131,7 +131,7 @@ abstract contract Helpers is DSMath, Basic {
_withdrawHelper(params.market, token_, params.from, params.to, amt_);
uint256 finalBal = getAccountSupplyBalanceOfAsset(
uint256 finalBal = _getAccountSupplyBalanceOfAsset(
params.from,
params.market,
token_
@ -161,7 +161,7 @@ abstract contract Helpers is DSMath, Basic {
}
}
function getAccountSupplyBalanceOfAsset(
function _getAccountSupplyBalanceOfAsset(
address account,
address market,
address asset
@ -177,29 +177,29 @@ abstract contract Helpers is DSMath, Basic {
}
}
function setAmt(
function _setAmt(
address market,
address token,
address src,
uint256 amt,
bool isEth,
ACTION action
Action action
) internal returns (uint256) {
if (amt == uint256(-1)) {
uint256 allowance_ = TokenInterface(token).allowance(src, market);
uint256 bal_;
if (action == ACTION.repay) {
if (action == Action.REPAY) {
bal_ = CometInterface(market).borrowBalanceOf(src);
} else if (action == ACTION.deposit) {
} else if (action == Action.DEPOSIT) {
if (isEth) bal_ = src.balance;
else bal_ = TokenInterface(token).balanceOf(src);
} else if (action == ACTION.transfer) {
} 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_;
if (action == Action.TRANSFER) amt = bal_;
else amt = bal_ < allowance_ ? bal_ : allowance_;
}
if (src == address(this))

View File

@ -168,7 +168,7 @@ abstract contract CompoundV3Resolver is Events, Helpers {
);
}
amt_ = setAmt(market, token_, from, amt_, isEth, ACTION.deposit);
amt_ = _setAmt(market, token_, from, amt_, isEth, Action.DEPOSIT);
CometInterface(market).supplyFrom(from, to, token_, amt_);
setUint(setId, amt_);
@ -209,7 +209,7 @@ abstract contract CompoundV3Resolver is Events, Helpers {
TokenInterface tokenContract = TokenInterface(token_);
uint256 initialBal = getAccountSupplyBalanceOfAsset(
uint256 initialBal = _getAccountSupplyBalanceOfAsset(
address(this),
market,
token_
@ -226,7 +226,7 @@ abstract contract CompoundV3Resolver is Events, Helpers {
CometInterface(market).withdraw(token_, amt_);
uint256 finalBal = getAccountSupplyBalanceOfAsset(
uint256 finalBal = _getAccountSupplyBalanceOfAsset(
address(this),
market,
token_
@ -602,7 +602,7 @@ abstract contract CompoundV3Resolver is Events, Helpers {
TokenInterface tokenContract = TokenInterface(token_);
amt_ = setAmt(market, token_, from, amt_, isEth, ACTION.repay);
amt_ = _setAmt(market, token_, from, amt_, isEth, Action.REPAY);
uint256 borrowBal = CometInterface(market).borrowBalanceOf(to);
if (borrowBal > 0) {
@ -764,7 +764,7 @@ abstract contract CompoundV3Resolver is Events, Helpers {
address token_ = isEth ? wethAddr : token;
TokenInterface tokenContract = TokenInterface(token_);
amt_ = setAmt(market, token_, src, amt_, isEth, ACTION.transfer);
amt_ = _setAmt(market, token_, src, amt_, isEth, Action.TRANSFER);
_transfer(market, token_, src, dest, amt_);