Skip to content

Commit

Permalink
FXD-78_StakingSystemForLiquidator 2024 Jan 18th FSLS replace FlashLen…
Browse files Browse the repository at this point in the history
…ding to VaultLending

Replaced flahsLending to vaultLending since the vaultLending contract(LiquidationStrategy contract that will be connected to FathomVault) will also include logic that deals with flashLending.
  • Loading branch information
codinghistorian committed Jan 18, 2024
1 parent ab2db54 commit 8590172
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 38 deletions.
11 changes: 11 additions & 0 deletions contracts/main/interfaces/IVaultLendingCallee.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.17;

interface IVaultLendingCallee {
function vaultLendingCall(
address caller,
uint256 debtValueToRepay, // [rad]
uint256 collateralAmountToLiquidate, // [wad]
bytes calldata
) external;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "../../interfaces/IPriceOracle.sol";
import "../../interfaces/ILiquidationEngine.sol";
import "../../interfaces/ILiquidationStrategy.sol";
import "../../interfaces/ISystemDebtEngine.sol";
import "../../interfaces/IFlashLendingCallee.sol";
import "../../interfaces/IVaultLendingCallee.sol";
import "../../interfaces/IGenericTokenAdapter.sol";
import "../../interfaces/IStablecoinAdapter.sol";
import "../../interfaces/IERC165.sol";
Expand Down Expand Up @@ -53,10 +53,6 @@ contract FixedSpreadLiquidationStrategy is CommonMath, PausableUpgradeable, Reen
IPriceOracle public priceOracle; // Collateral price module
IStablecoinAdapter public stablecoinAdapter; //StablecoinAdapter to deposit FXD to bookKeeper

uint256 public flashLendingEnabled;

bytes4 internal constant FLASH_LENDING_ID = 0xaf7bd142;

uint256 public vaultLendingEnabled;
//vaultLendingCall(address,uint256,uint256,bytes)
//2eccf79a3186340e98628dede5e030b3259989a3589735768de8a79f946dc5f6
Expand All @@ -76,7 +72,6 @@ contract FixedSpreadLiquidationStrategy is CommonMath, PausableUpgradeable, Reen
uint256 _collateralAmountToBeLiquidated,
uint256 _treasuryFees
);
event LogSetFlashLendingEnabled(address indexed _caller, uint256 _flashLendingEnabled);
event LogSetVaultLendingEnabled(address indexed _caller, uint256 _vaultLendingEnabled);
event LogSetBookKeeper(address _newAddress);

Expand Down Expand Up @@ -142,15 +137,10 @@ contract FixedSpreadLiquidationStrategy is CommonMath, PausableUpgradeable, Reen
_unpause();
}

/// @notice Sets the flash lending feature to enabled or disabled.
/// @param _flashLendingEnabled The value indicating whether flash lending should be enabled (1) or disabled (0).
/// @notice Sets the vault lending feature to enabled or disabled.
/// @param _vaultLendingEnabled The value indicating whether vault lending should be enabled (1) or disabled (0).
/// @dev This function can only be called by the contract owner or governance.
/// @dev Emits a LogSetFlashLendingEnabled event upon a successful update.
function setFlashLendingEnabled(uint256 _flashLendingEnabled) external onlyOwnerOrGov {
flashLendingEnabled = _flashLendingEnabled;
emit LogSetFlashLendingEnabled(msg.sender, _flashLendingEnabled);
}

/// @dev Emits a LogSetVaultLendingEnabled event upon a successful update.
function setVaultLendingEnabled(uint256 _vaultLendingEnabled) external onlyOwnerOrGov {
vaultLendingEnabled = _vaultLendingEnabled;
emit LogSetVaultLendingEnabled(msg.sender, _vaultLendingEnabled);
Expand Down Expand Up @@ -225,30 +215,6 @@ contract FixedSpreadLiquidationStrategy is CommonMath, PausableUpgradeable, Reen
info.collateralAmountToBeLiquidated - info.treasuryFees,
_data
);
//below flow will be done in VaultStrategyHandler(..which can be _collateralRecipient like FlashLiquidator contract)
// address _stablecoin = address(stablecoinAdapter.stablecoin());
// _stablecoin.safeTransferFrom(_liquidatorAddress, address(this), ((info.actualDebtValueToBeLiquidated / RAY) + 1));
// _stablecoin.safeApprove(address(stablecoinAdapter), ((info.actualDebtValueToBeLiquidated / RAY) + 1));
// stablecoinAdapter.depositRAD(_liquidatorAddress, info.actualDebtValueToBeLiquidated, _collateralPoolId, abi.encode(0));
} else if (
flashLendingEnabled == 1 &&
_data.length > 0 &&
_collateralRecipient != address(bookKeeper) &&
_collateralRecipient != address(liquidationEngine) &&
IERC165(_collateralRecipient).supportsInterface(FLASH_LENDING_ID)
) {
bookKeeper.moveCollateral(
_collateralPoolId,
address(this),
_collateralRecipient,
info.collateralAmountToBeLiquidated - info.treasuryFees
);
IFlashLendingCallee(_collateralRecipient).flashLendingCall(
msg.sender,
info.actualDebtValueToBeLiquidated,
info.collateralAmountToBeLiquidated - info.treasuryFees,
_data
);
} else {
IGenericTokenAdapter(ICollateralPoolConfig(bookKeeper.collateralPoolConfig()).getAdapter(_collateralPoolId)).withdraw(
_collateralRecipient,
Expand Down

0 comments on commit 8590172

Please sign in to comment.