Skip to content

Commit

Permalink
allow for manual fee updates
Browse files Browse the repository at this point in the history
  • Loading branch information
saucepoint committed Mar 15, 2024
1 parent 3bfede2 commit 5761940
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions contracts/hooks/examples/VolatilityOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 5761940

Please sign in to comment.