Skip to content

Commit 3bba521

Browse files
committed
fix: require hook caller to be trusted
1 parent b77a390 commit 3bba521

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

contracts/v3/ReserveLiquidityStrategy.sol

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ contract ReserveLiquidityStrategy is ILiquidityStrategy, OwnableUpgradeable {
2626
/// @notice The reserve contract that holds collateral
2727
IReserve public reserve;
2828

29+
/// @notice Mapping of trusted liquidity pools
30+
mapping(address => bool) public trustedPools;
31+
2932
/* ============================================================ */
3033
/* ======================== Events ============================ */
3134
/* ============================================================ */
@@ -39,6 +42,7 @@ contract ReserveLiquidityStrategy is ILiquidityStrategy, OwnableUpgradeable {
3942
);
4043

4144
event ReserveSet(address indexed oldReserve, address indexed newReserve);
45+
event TrustedPoolUpdated(address indexed pool, bool isTrusted);
4246

4347
/* ============================================================ */
4448
/* ==================== Initialization ======================== */
@@ -78,6 +82,17 @@ contract ReserveLiquidityStrategy is ILiquidityStrategy, OwnableUpgradeable {
7882
emit ReserveSet(oldReserve, _reserve);
7983
}
8084

85+
/**
86+
* @notice Set a trusted liquidity pool
87+
* @param pool The address of the liquidity pool
88+
* @param isTrusted Whether the pool is trusted or not
89+
*/
90+
function setTrustedPool(address pool, bool isTrusted) external onlyOwner {
91+
require(pool != address(0), "RLS: INVALID_POOL");
92+
trustedPools[pool] = isTrusted;
93+
emit TrustedPoolUpdated(pool, isTrusted);
94+
}
95+
8196
/* ============================================================ */
8297
/* ===================== External Functions =================== */
8398
/* ============================================================ */
@@ -126,6 +141,7 @@ contract ReserveLiquidityStrategy is ILiquidityStrategy, OwnableUpgradeable {
126141
* @param data Encoded callback data
127142
*/
128143
function hook(address sender, uint256 amount0Out, uint256 amount1Out, bytes calldata data) external {
144+
require(trustedPools[msg.sender], "RLS: UNTRUSTED_POOL");
129145
require(sender == address(this), "RLS: INVALID_SENDER");
130146

131147
(uint256 inputAmount, LQ.Direction direction, uint256 incentiveAmount, bool isToken0Debt) = abi.decode(

0 commit comments

Comments
 (0)