Skip to content

FPL missing ext fn #673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions contracts/compound/CTokenFirstExtension.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.0;

import { DiamondExtension } from "../midas/DiamondExtension.sol";
import { DiamondExtension, LibDiamond } from "../midas/DiamondExtension.sol";
import { IFlashLoanReceiver } from "../midas/IFlashLoanReceiver.sol";
import { CTokenExtensionBase, CTokenExtensionInterface, CTokenInterface } from "./CTokenInterfaces.sol";
import { ComptrollerV3Storage, UnitrollerAdminStorage } from "./ComptrollerStorage.sol";
Expand Down Expand Up @@ -47,15 +47,14 @@ contract CTokenFirstExtension is
functionSelectors[--fnsCount] = this.flash.selector;
functionSelectors[--fnsCount] = this.getAccountSnapshot.selector;
functionSelectors[--fnsCount] = this.borrowBalanceCurrent.selector;
functionSelectors[--fnsCount] = this.asCTokenExtensionInterface.selector;
functionSelectors[--fnsCount] = this.getExtensionForSig.selector;

require(fnsCount == 0, "use the correct array length");
return functionSelectors;
}

// TODO remove after next deploy
function asCTokenExtensionInterface() external view returns (CTokenFirstExtension) {
return this;
function getExtensionForSig(bytes4 fnSig) external view returns (address) {
return LibDiamond.getExtensionForFunction(fnSig);
}

function getTotalUnderlyingSupplied() public view override returns (uint256) {
Expand Down
27 changes: 27 additions & 0 deletions contracts/test/ExtensionsTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,33 @@ contract ExtensionsTest is MarketsTest {
third = new MockThirdComptrollerExtension();
}

function testChapelAccrue() public fork(BSC_CHAPEL) {
address marketAddress = 0x5aF82b72E4fA372e69765DeAc2e1B06acCD8DE15;
CTokenFirstExtension asExt = CTokenFirstExtension(marketAddress);

emit log_named_address("irm", address(asExt.interestRateModel()));

asExt.accrueInterest();
}

function testChapelExtensionFns() public fork(BSC_CHAPEL) {
address marketAddress = 0x5aF82b72E4fA372e69765DeAc2e1B06acCD8DE15;
DiamondBase asBase = DiamondBase(marketAddress);
address[] memory extensions = asBase._listExtensions();

emit log_named_address("first ext", extensions[0]);

DiamondExtension firstExt = DiamondExtension(extensions[0]);
bytes4[] memory fns = firstExt._getExtensionFunctions();

CTokenFirstExtension asExt = CTokenFirstExtension(marketAddress);

asExt.getExtensionForSig(asExt.borrowBalanceCurrent.selector);
//asExt.supplyRatePerBlock();

// emit log_named_array("fn selectors", fns);
}

function testExtensionReplace() public debuggingOnly fork(BSC_MAINNET) {
address payable jFiatPoolAddress = payable(0x31d76A64Bc8BbEffb601fac5884372DEF910F044);
_upgradeExistingPool(jFiatPoolAddress);
Expand Down
7 changes: 4 additions & 3 deletions contracts/test/FusePoolLensTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ contract FusePoolLensTest is BaseTest {
fpl.getPoolAssetsWithData(IComptroller(0xB08A309eFBFFa41f36A06b2D0C9a4629749b17a2));
}

function testWhitelistsFPL() public debuggingOnly fork(BSC_CHAPEL) {
FusePoolLens fpl = FusePoolLens(0x604805B587C939042120D2e22398f299547A130c);
fpl.getSupplyCapsDataForPool(IComptroller(0x307BEc9d1368A459E9168fa6296C1e69025ab30f));
function testChapelFPL() public debuggingOnly fork(BSC_CHAPEL) {
FusePoolLens fpl = FusePoolLens(0xD880d5D33221F3992E695f5C6bFBC558e9Ad31cF);
vm.prank(0x8982aa50bb919E42e9204f12e5b59D053Eb2A602);
fpl.getPoolAssetsWithData(IComptroller(0x044c436b2f3EF29D30f89c121f9240cf0a08Ca4b));
}
}
5 changes: 5 additions & 0 deletions contracts/test/LiquidatorsRegistryTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ contract LiquidatorsRegistryTest is BaseTest {
return returndata;
}

function testSwapAllowance() public debuggingOnly fork(BSC_CHAPEL) {
vm.prank(0xdc3d8A4ee43dDe6a4E92F0D7A749C8eBD921239b);
registry.amountOutAndSlippageOfSwap(chapelBomb, 1e18, chapelTUsd);
}

function testResetStrategies() public debuggingOnly fork(BSC_CHAPEL) {
upgradeRegistry();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,31 +84,27 @@ contract BalancerLpTokenLiquidatorTest is BaseTest {
address lpToken = 0x82d7f08026e21c7713CfAd1071df7C8271B17Eae; //MIMO-PAR 8020
address lpTokenWhale = 0xbB60ADbe38B4e6ab7fb0f9546C2C1b665B86af11;
address outputTokenAddress = 0xE2Aa7db6dA1dAE97C5f5C6914d285fBfCC32A128; // PAR

testRedeemLpToken(lpTokenWhale, lpToken, outputTokenAddress);
}

function testWmaticStmaticLPLiquidatorRedeem() public fork(POLYGON_MAINNET) {
address lpToken = 0x8159462d255C1D24915CB51ec361F700174cD994; // stMATIC-WMATIC stable
address lpTokenWhale = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; // Balancer V2
address outputTokenAddress = 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270; // WMATIC

testRedeemLpToken(lpTokenWhale, lpToken, outputTokenAddress);
}

function testWmaticMaticXLPLiquidatorRedeem() public fork(POLYGON_MAINNET) {
address lpToken = 0xC17636e36398602dd37Bb5d1B3a9008c7629005f; // WMATIC-MaticX stable
address lpTokenWhale = 0x48534d027f8962692122dB440714fFE88Ab1fA85;
address outputTokenAddress = 0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270; // WMATIC

testRedeemLpToken(lpTokenWhale, lpToken, outputTokenAddress);
}

function testJbrlBrzLiquidatorRedeem() public fork(POLYGON_MAINNET) {
address lpToken = 0xE22483774bd8611bE2Ad2F4194078DaC9159F4bA; // jBRL-BRZ stable
address lpTokenWhale = 0xBA12222222228d8Ba445958a75a0704d566BF2C8; // Balancer V2
address outputTokenAddress = 0xf2f77FE7b8e66571E0fca7104c4d670BF1C8d722; // jBRL

testRedeemLpToken(lpTokenWhale, lpToken, outputTokenAddress);
}

Expand Down