reviews addresses

This commit is contained in:
Richa-iitr 2022-09-01 00:09:55 +05:30
parent 912f46949b
commit 6c457ea60b
3 changed files with 22 additions and 27 deletions

View File

@ -36,7 +36,6 @@ abstract contract Helpers is DSMath, Basic {
address to, address to,
uint256 amt uint256 amt
) internal { ) internal {
bytes memory data;
if (from == address(0) && to == address(0)) { if (from == address(0) && to == address(0)) {
CometInterface(market).withdraw(token, amt); CometInterface(market).withdraw(token, amt);
@ -53,7 +52,7 @@ abstract contract Helpers is DSMath, Basic {
address from, address from,
address to, address to,
uint256 amt uint256 amt
) public payable { ) internal {
bytes memory data; bytes memory data;
if (from == address(0)) { if (from == address(0)) {

View File

@ -7,6 +7,11 @@ struct UserCollateral {
uint128 _reserved; uint128 _reserved;
} }
struct RewardOwed {
address token;
uint256 owed;
}
interface CometInterface { interface CometInterface {
function supply(address asset, uint256 amount) external virtual; function supply(address asset, uint256 amount) external virtual;
@ -124,6 +129,10 @@ interface CometRewards {
bool shouldAccrue bool shouldAccrue
) external; ) external;
function getRewardOwed(address comet, address account)
external
returns (RewardOwed memory);
function rewardsClaimed(address cometProxy, address account) function rewardsClaimed(address cometProxy, address account)
external external
view view

View File

@ -455,7 +455,7 @@ abstract contract CompoundV3Resolver is Events, Helpers {
TokenInterface tokenContract = TokenInterface(token_); TokenInterface tokenContract = TokenInterface(token_);
amt_ = amt_ == uint256(-1) amt_ = amt_ == uint256(-1)
? CometInterface(market).borrowBalanceOf(address(this)) ? TokenInterface(market).balanceOf(address(this))
: amt_; : amt_;
if (isEth) { if (isEth) {
@ -500,7 +500,7 @@ abstract contract CompoundV3Resolver is Events, Helpers {
TokenInterface tokenContract = TokenInterface(token_); TokenInterface tokenContract = TokenInterface(token_);
amt_ = amt_ == uint256(-1) amt_ = amt_ == uint256(-1)
? CometInterface(market).borrowBalanceOf(to) ? TokenInterface(market).balanceOf(to)
: amt_; : amt_;
if (isEth) { if (isEth) {
@ -548,7 +548,7 @@ abstract contract CompoundV3Resolver is Events, Helpers {
TokenInterface tokenContract = TokenInterface(token_); TokenInterface tokenContract = TokenInterface(token_);
amt_ = amt_ == uint256(-1) amt_ = amt_ == uint256(-1)
? CometInterface(market).borrowBalanceOf(to) ? TokenInterface(market).balanceOf(to)
: amt_; : amt_;
if (isEth) { if (isEth) {
@ -634,23 +634,13 @@ abstract contract CompoundV3Resolver is Events, Helpers {
bool accrue, bool accrue,
uint256 setId uint256 setId
) public returns (string memory eventName_, bytes memory eventParam_) { ) public returns (string memory eventName_, bytes memory eventParam_) {
uint256 rewardsOwed = cometRewards.getRewardOwed(market, account).owed;
cometRewards.claim(market, account, accrue); cometRewards.claim(market, account, accrue);
//in reward token decimals setUint(setId, rewardsOwed);
uint256 totalRewardsClaimed = cometRewards.rewardsClaimed(
market,
account
);
setUint(setId, totalRewardsClaimed);
eventName_ = "LogRewardsClaimed(address,address,uint256,uint256,bool)"; eventName_ = "LogRewardsClaimed(address,address,uint256,uint256,bool)";
eventParam_ = abi.encode( eventParam_ = abi.encode(market, account, rewardsOwed, setId, accrue);
market,
account,
totalRewardsClaimed,
setId,
accrue
);
} }
/** /**
@ -669,21 +659,18 @@ abstract contract CompoundV3Resolver is Events, Helpers {
bool accrue, bool accrue,
uint256 setId uint256 setId
) public returns (string memory eventName_, bytes memory eventParam_) { ) public returns (string memory eventName_, bytes memory eventParam_) {
//in reward token decimals
uint256 rewardsOwed = cometRewards.getRewardOwed(market, account).owed;
cometRewards.claimTo(market, account, dest, accrue); cometRewards.claimTo(market, account, dest, accrue);
//in reward token decimals setUint(setId, rewardsOwed);
uint256 totalRewardsClaimed = cometRewards.rewardsClaimed(
market,
account
);
setUint(setId, totalRewardsClaimed);
eventName_ = "LogRewardsClaimedTo(address,address,address,uint256,uint256,bool)"; eventName_ = "LogRewardsClaimedTo(address,address,address,uint256,uint256,bool)";
eventParam_ = abi.encode( eventParam_ = abi.encode(
market, market,
account, account,
dest, dest,
totalRewardsClaimed, rewardsOwed,
setId, setId,
accrue accrue
); );
@ -880,7 +867,7 @@ abstract contract CompoundV3Resolver is Events, Helpers {
* @param manager The address to be authorized. * @param manager The address to be authorized.
* @param isAllowed Whether to allow or disallow the manager. * @param isAllowed Whether to allow or disallow the manager.
*/ */
function allow( function toggleAccountManager(
address market, address market,
address manager, address manager,
bool isAllowed bool isAllowed
@ -903,7 +890,7 @@ abstract contract CompoundV3Resolver is Events, Helpers {
* @param r Half of the ECDSA signature pair. * @param r Half of the ECDSA signature pair.
* @param s Half of the ECDSA signature pair. * @param s Half of the ECDSA signature pair.
*/ */
function allowWithPermit( function toggleAccountManagerWithPermit(
address market, address market,
address owner, address owner,
address manager, address manager,