From 57619405e19d1873b639de0c29a3b77f26dde3f8 Mon Sep 17 00:00:00 2001 From: saucepoint Date: Fri, 15 Mar 2024 15:53:06 +0000 Subject: [PATCH] allow for manual fee updates --- contracts/hooks/examples/VolatilityOracle.sol | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/contracts/hooks/examples/VolatilityOracle.sol b/contracts/hooks/examples/VolatilityOracle.sol index b6507d00..76a3e8ce 100644 --- a/contracts/hooks/examples/VolatilityOracle.sol +++ b/contracts/hooks/examples/VolatilityOracle.sol @@ -48,14 +48,19 @@ contract VolatilityOracle is BaseHook { return VolatilityOracle.beforeInitialize.selector; } + function setFee(PoolKey calldata key) public { + uint24 startingFee = 3000; + uint32 lapsed = _blockTimestamp() - deployTimestamp; + uint24 fee = startingFee + (uint24(lapsed) * 100) / 60; // 100 bps a minute + poolManager.updateDynamicSwapFee(key, fee); // initial fee 0.30% + } + function afterInitialize(address, PoolKey calldata key, uint160, int24, bytes calldata) external override returns (bytes4) { - uint24 startingFee = 3000; - uint32 lapsed = _blockTimestamp() - deployTimestamp; - uint24 fee = startingFee + (uint24(lapsed) * 100) / 60; // 100 bps a minute - poolManager.updateDynamicSwapFee(key, fee); // initial fee 0.30% + setFee(key); + return BaseHook.afterInitialize.selector; } }