diff --git a/contracts/Strategy.sol b/contracts/Strategy.sol index b8fd01a..c7d10e5 100644 --- a/contracts/Strategy.sol +++ b/contracts/Strategy.sol @@ -26,10 +26,8 @@ contract Strategy is BaseStrategy, Ownable { // eth blocks are mined every 12s -> 3600 * 24 * 365 / 12 = 2_628_000 uint256 private constant BLOCKS_PER_YEAR = 2_628_000; - address internal constant COMP = - address(0xc00e94Cb662C3520282E6f5717214004A7f26888); - address internal constant WETH = - address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); + address internal constant COMP = 0xc00e94Cb662C3520282E6f5717214004A7f26888; + address internal constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; ComptrollerI public constant COMPTROLLER = ComptrollerI(0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B); UniswapAnchoredViewI public constant PRICE_FEED = @@ -125,12 +123,14 @@ contract Strategy is BaseStrategy, Ownable { } function balanceOfCToken() public view returns (uint256) { - uint256 balance = cToken.balanceOf(address(this)); + (, uint256 balance, , uint256 exchangeRate) = cToken.getAccountSnapshot( + address(this) + ); if (balance == 0) { return 0; } else { //The current exchange rate as an unsigned integer, scaled by 1e18. - return (balance * cToken.exchangeRateStored()) / 1e18; + return (balance * exchangeRate) / 1e18; } } @@ -355,7 +355,7 @@ contract Strategy is BaseStrategy, Ownable { function _removeTradeFactoryPermissions() internal { IERC20(COMP).safeApprove(tradeFactory, 0); - + ITradeFactory(tradeFactory).disable(COMP, IVault(vault).asset()); tradeFactory = address(0); } } diff --git a/contracts/interfaces/ITradeFactory.sol b/contracts/interfaces/ITradeFactory.sol index bb8e129..543eea4 100644 --- a/contracts/interfaces/ITradeFactory.sol +++ b/contracts/interfaces/ITradeFactory.sol @@ -3,4 +3,6 @@ pragma solidity 0.8.14; interface ITradeFactory { function enable(address, address) external; + + function disable(address, address) external; } diff --git a/contracts/interfaces/comp/CTokenI.sol b/contracts/interfaces/comp/CTokenI.sol index 6881807..e506261 100644 --- a/contracts/interfaces/comp/CTokenI.sol +++ b/contracts/interfaces/comp/CTokenI.sol @@ -136,7 +136,15 @@ interface CTokenI { function getAccountSnapshot( address account - ) external view returns (uint256, uint256, uint256, uint256); + ) + external + view + returns ( + uint256 error, + uint256 tokenBalance, + uint256 borrowBalance, + uint256 exchangeRate + ); function borrowRatePerBlock() external view returns (uint256);