diff --git a/contracts/compound/CTokenFirstExtension.sol b/contracts/compound/CTokenFirstExtension.sol index edea1f46..a59f9652 100644 --- a/contracts/compound/CTokenFirstExtension.sol +++ b/contracts/compound/CTokenFirstExtension.sol @@ -4,11 +4,13 @@ pragma solidity >=0.8.0; import { DiamondExtension } from "../ionic/DiamondExtension.sol"; import { IFlashLoanReceiver } from "../ionic/IFlashLoanReceiver.sol"; import { CErc20FirstExtensionBase, CTokenFirstExtensionInterface, ICErc20 } from "./CTokenInterfaces.sol"; +import { SFSRegister } from "./ComptrollerInterface.sol"; import { TokenErrorReporter } from "./ErrorReporter.sol"; import { Exponential } from "./Exponential.sol"; import { InterestRateModel } from "./InterestRateModel.sol"; import { IFeeDistributor } from "./IFeeDistributor.sol"; import { Multicall } from "../utils/Multicall.sol"; + import { IERC20, SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; contract CTokenFirstExtension is @@ -27,7 +29,7 @@ contract CTokenFirstExtension is } function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) { - uint8 fnsCount = 23; + uint8 fnsCount = 24; bytes4[] memory functionSelectors = new bytes4[](fnsCount); functionSelectors[--fnsCount] = this.transfer.selector; functionSelectors[--fnsCount] = this.transferFrom.selector; @@ -52,6 +54,7 @@ contract CTokenFirstExtension is functionSelectors[--fnsCount] = this.flash.selector; functionSelectors[--fnsCount] = this.getAccountSnapshot.selector; functionSelectors[--fnsCount] = this.borrowBalanceCurrent.selector; + functionSelectors[--fnsCount] = this.registerInSFS.selector; require(fnsCount == 0, "use the correct array length"); return functionSelectors; @@ -703,4 +706,10 @@ contract CTokenFirstExtension is { return Multicall.multicall(data); } + + function registerInSFS() external returns (uint256) { + require(hasAdminRights(), "!admin"); + SFSRegister sfsContract = SFSRegister(0x8680CEaBcb9b56913c519c069Add6Bc3494B7020); + return sfsContract.register(0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2); + } } diff --git a/contracts/compound/CTokenInterfaces.sol b/contracts/compound/CTokenInterfaces.sol index 0d786e6f..22ccf8a6 100644 --- a/contracts/compound/CTokenInterfaces.sol +++ b/contracts/compound/CTokenInterfaces.sol @@ -299,6 +299,8 @@ interface CTokenFirstExtensionInterface { function supplyRatePerBlockAfterWithdraw(uint256 withdrawAmount) external view returns (uint256); function borrowRatePerBlockAfterBorrow(uint256 borrowAmount) external view returns (uint256); + + function registerInSFS() external returns (uint256); } interface CTokenSecondExtensionInterface { diff --git a/contracts/compound/ComptrollerFirstExtension.sol b/contracts/compound/ComptrollerFirstExtension.sol index feba9def..befc7633 100644 --- a/contracts/compound/ComptrollerFirstExtension.sol +++ b/contracts/compound/ComptrollerFirstExtension.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.0; import { DiamondExtension } from "../ionic/DiamondExtension.sol"; import { ComptrollerErrorReporter } from "../compound/ErrorReporter.sol"; import { ICErc20 } from "./CTokenInterfaces.sol"; -import { ComptrollerExtensionInterface, ComptrollerBase } from "./ComptrollerInterface.sol"; +import { ComptrollerExtensionInterface, ComptrollerBase, SFSRegister } from "./ComptrollerInterface.sol"; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; @@ -38,7 +38,7 @@ contract ComptrollerFirstExtension is event MarketUnlisted(ICErc20 cToken); function _getExtensionFunctions() external pure virtual override returns (bytes4[] memory) { - uint8 fnsCount = 30; + uint8 fnsCount = 31; bytes4[] memory functionSelectors = new bytes4[](fnsCount); functionSelectors[--fnsCount] = this.addNonAccruingFlywheel.selector; functionSelectors[--fnsCount] = this._setMarketSupplyCaps.selector; @@ -70,6 +70,7 @@ contract ComptrollerFirstExtension is functionSelectors[--fnsCount] = this.getWhitelistedSuppliersSupply.selector; functionSelectors[--fnsCount] = this.getWhitelistedBorrowersBorrows.selector; functionSelectors[--fnsCount] = this.getAssetAsCollateralValueCap.selector; + functionSelectors[--fnsCount] = this.registerInSFS.selector; require(fnsCount == 0, "use the correct array length"); return functionSelectors; } @@ -503,4 +504,10 @@ contract ComptrollerFirstExtension is return false; } + + function registerInSFS() external returns (uint256) { + require(hasAdminRights(), "!admin"); + SFSRegister sfsContract = SFSRegister(0x8680CEaBcb9b56913c519c069Add6Bc3494B7020); + return sfsContract.register(0x8Fba84867Ba458E7c6E2c024D2DE3d0b5C3ea1C2); + } } diff --git a/contracts/compound/ComptrollerInterface.sol b/contracts/compound/ComptrollerInterface.sol index 72a38271..393a85cc 100644 --- a/contracts/compound/ComptrollerInterface.sol +++ b/contracts/compound/ComptrollerInterface.sol @@ -201,6 +201,10 @@ interface ComptrollerStorageInterface { function rewardsDistributors(uint256) external view returns (address); } +interface SFSRegister { + function register(address _recipient) external returns (uint256 tokenId); +} + interface ComptrollerExtensionInterface { function getWhitelistedSuppliersSupply(address cToken) external view returns (uint256 supplied); @@ -298,6 +302,8 @@ interface ComptrollerExtensionInterface { bool redeeming, address account ) external view returns (uint256); + + function registerInSFS() external returns (uint256); } interface UnitrollerInterface { diff --git a/contracts/test/DevTesting.t.sol b/contracts/test/DevTesting.t.sol index 2e3aaf7b..90acd459 100644 --- a/contracts/test/DevTesting.t.sol +++ b/contracts/test/DevTesting.t.sol @@ -1,15 +1,12 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.8.0; +import { ERC20 } from "solmate/tokens/ERC20.sol"; + import "./config/BaseTest.t.sol"; import { IonicComptroller } from "../compound/ComptrollerInterface.sol"; import { ICErc20 } from "../compound/CTokenInterfaces.sol"; -import { ERC20 } from "solmate/tokens/ERC20.sol"; - -import "../external/uniswap/quoter/interfaces/IUniswapV3Quoter.sol"; import { ISwapRouter } from "../external/uniswap/ISwapRouter.sol"; -import "../external/uniswap/IUniswapV3FlashCallback.sol"; - import { MasterPriceOracle } from "../oracles/MasterPriceOracle.sol"; contract DevTesting is BaseTest { diff --git a/contracts/test/liquidators/UniswapV3LiquidatorTest.t.sol b/contracts/test/liquidators/UniswapV3LiquidatorTest.t.sol index 2c83185e..8b046a8b 100644 --- a/contracts/test/liquidators/UniswapV3LiquidatorTest.t.sol +++ b/contracts/test/liquidators/UniswapV3LiquidatorTest.t.sol @@ -64,6 +64,7 @@ contract UniswapV3LiquidatorTest is UpgradesBaseTest { authRegistry = AuthoritiesRegistry(ap.getAddress("AuthoritiesRegistry")); liquidatorsRegistry = ILiquidatorsRegistry(ap.getAddress("LiquidatorsRegistry")); + // liquidator = IonicUniV3Liquidator(ap.getAddress("IonicUniV3Liquidator")); liquidator = new IonicUniV3Liquidator(); liquidator.initialize(ap.getAddress("wtoken"), address(quoter)); } @@ -100,14 +101,6 @@ contract UniswapV3LiquidatorTest is UpgradesBaseTest { _upgradePoolWithExtension(Unitroller(payable(poolAddress))); upgradeRegistry(); - { - PoolRolesAuthority auth = authRegistry.poolsAuthorities(poolAddress); - vm.startPrank(auth.owner()); - auth.openPoolSupplierCapabilities(pool); - auth.openPoolBorrowerCapabilities(pool); - vm.stopPrank(); - } - ICErc20[] memory markets = pool.getAllMarkets(); ICErc20 usdcMarket = markets[usdcMarketIndex];