Skip to content

Commit

Permalink
update core; fix renaming of swap fee to lp fee
Browse files Browse the repository at this point in the history
  • Loading branch information
saucepoint committed Apr 24, 2024
1 parent 095fb31 commit a57ae47
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeAddInitialLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
313314
313230
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeAddLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
124785
124701
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeFirstSwap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
84215
84275
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeInitialize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1016633
1016655
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeRemoveLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
112118
111972
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeRemoveLiquidityAndRebalance.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
246098
246070
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeSecondSwap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
49217
49237
2 changes: 1 addition & 1 deletion .forge-snapshots/FullRangeSwap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
83017
83020
12 changes: 10 additions & 2 deletions contracts/hooks/examples/TWAMM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,22 @@ contract TWAMM is BaseHook, ITWAMM {

if (swapParams.zeroForOne) {
if (delta.amount0() < 0) {
key.currency0.settle(poolManager, uint256(uint128(-delta.amount0())), false);
// TODO: use settle syntax when it supports transfers
// key.currency0.settle(poolManager, uint256(uint128(-delta.amount0())), false);
poolManager.sync(key.currency0);
key.currency0.transfer(address(poolManager), uint256(uint128(-delta.amount0())));
poolManager.settle(key.currency0);
}
if (delta.amount1() > 0) {
key.currency1.take(poolManager, address(this), uint256(uint128(delta.amount1())), false);
}
} else {
if (delta.amount1() < 0) {
key.currency1.settle(poolManager, uint256(uint128(-delta.amount1())), false);
// TODO: use settle syntax when it supports transfers
// key.currency1.settle(poolManager, uint256(uint128(-delta.amount1())), false);
poolManager.sync(key.currency1);
key.currency1.transfer(address(poolManager), uint256(uint128(-delta.amount1())));
poolManager.settle(key.currency1);
}
if (delta.amount0() > 0) {
key.currency0.take(poolManager, address(this), uint256(uint128(delta.amount0())), false);
Expand Down
6 changes: 3 additions & 3 deletions contracts/hooks/examples/VolatilityOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ pragma solidity ^0.8.19;

import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
import {Hooks} from "@uniswap/v4-core/src/libraries/Hooks.sol";
import {SwapFeeLibrary} from "@uniswap/v4-core/src/libraries/SwapFeeLibrary.sol";
import {LPFeeLibrary} from "@uniswap/v4-core/src/libraries/LPFeeLibrary.sol";
import {BaseHook} from "../../BaseHook.sol";
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";

contract VolatilityOracle is BaseHook {
using SwapFeeLibrary for uint24;
using LPFeeLibrary for uint24;

error MustUseDynamicFee();

Expand Down Expand Up @@ -52,7 +52,7 @@ contract VolatilityOracle is BaseHook {
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%
poolManager.updateDynamicLPFee(key, fee); // initial fee 0.30%
}

function afterInitialize(address, PoolKey calldata key, uint160, int24, bytes calldata)
Expand Down
2 changes: 1 addition & 1 deletion lib/v4-core
Submodule v4-core updated 74 files
+1 −1 .forge-snapshots/SwapMath_oneForZero_exactInCapped.snap
+1 −1 .forge-snapshots/SwapMath_oneForZero_exactInPartial.snap
+1 −1 .forge-snapshots/SwapMath_oneForZero_exactOutCapped.snap
+1 −1 .forge-snapshots/SwapMath_oneForZero_exactOutPartial.snap
+1 −1 .forge-snapshots/SwapMath_zeroForOne_exactInCapped.snap
+1 −1 .forge-snapshots/SwapMath_zeroForOne_exactInPartial.snap
+1 −1 .forge-snapshots/SwapMath_zeroForOne_exactOutCapped.snap
+1 −1 .forge-snapshots/SwapMath_zeroForOne_exactOutPartial.snap
+1 −1 .forge-snapshots/addLiquidity with empty hook.snap
+1 −1 .forge-snapshots/addLiquidity with native token.snap
+1 −1 .forge-snapshots/addLiquidity.snap
+1 −1 .forge-snapshots/donate gas with 1 token.snap
+1 −1 .forge-snapshots/donate gas with 2 tokens.snap
+1 −1 .forge-snapshots/erc20 collect protocol fees.snap
+1 −1 .forge-snapshots/initialize.snap
+1 −1 .forge-snapshots/native collect protocol fees.snap
+1 −1 .forge-snapshots/poolManager bytecode size.snap
+1 −1 .forge-snapshots/removeLiquidity with empty hook.snap
+1 −1 .forge-snapshots/removeLiquidity with native token.snap
+1 −1 .forge-snapshots/removeLiquidity.snap
+1 −1 .forge-snapshots/simple swap with native.snap
+1 −1 .forge-snapshots/simple swap.snap
+1 −1 .forge-snapshots/swap against liquidity with native token.snap
+1 −1 .forge-snapshots/swap against liquidity.snap
+1 −1 .forge-snapshots/swap burn 6909 for input.snap
+1 −1 .forge-snapshots/swap burn native 6909 for input.snap
+1 −1 .forge-snapshots/swap mint native output as 6909.snap
+1 −1 .forge-snapshots/swap mint output as 6909.snap
+1 −1 .forge-snapshots/swap skips hook call if hook is caller.snap
+1 −1 .forge-snapshots/swap with dynamic fee.snap
+1 −1 .forge-snapshots/swap with hooks.snap
+1 −0 .forge-snapshots/swap with lp fee and protocol fee.snap
+1 −1 .forge-snapshots/update dynamic fee in before swap.snap
+2 −2 .github/workflows/coverage.yml
+44 −33 src/PoolManager.sol
+3 −3 src/ProtocolFees.sol
+18 −9 src/interfaces/IPoolManager.sol
+5 −6 src/interfaces/IProtocolFees.sol
+40 −0 src/libraries/CurrencySettleTake.sol
+2 −2 src/libraries/Hooks.sol
+8 −8 src/libraries/LPFeeLibrary.sol
+5 −4 src/libraries/NonZeroDeltaCount.sol
+44 −25 src/libraries/Pool.sol
+17 −5 src/libraries/ProtocolFeeLibrary.sol
+40 −0 src/libraries/Reserves.sol
+1 −1 src/libraries/SwapMath.sol
+111 −0 src/test/ActionsRouter.sol
+3 −3 src/test/DynamicFeesTestHook.sol
+3 −3 src/test/MockHooks.sol
+6 −4 src/test/PoolClaimsTest.sol
+6 −4 src/test/PoolDonateTest.sol
+15 −15 src/test/PoolModifyLiquidityTest.sol
+12 −10 src/test/PoolNestedActionsTest.sol
+28 −0 src/test/PoolSettleTest.sol
+18 −25 src/test/PoolSwapTest.sol
+4 −2 src/test/PoolTakeTest.sol
+0 −23 src/test/PoolTestBase.sol
+2 −2 src/test/ProtocolFeeControllerTest.sol
+10 −15 src/test/SkipCallsTestHook.sol
+195 −26 test/DynamicFees.t.sol
+108 −82 test/PoolManager.t.sol
+5 −8 test/PoolManagerInitialize.t.sol
+50 −0 test/Reserves.t.sol
+1 −3 test/SkipCallsTestHook.t.sol
+269 −0 test/Sync.t.sol
+6 −8 test/libraries/Hooks.t.sol
+4 −0 test/libraries/Lock.t.sol
+4 −0 test/libraries/NonZeroDeltaCount.t.sol
+30 −5 test/libraries/Pool.t.sol
+73 −0 test/libraries/ProtocolFeeLibrary.t.sol
+25 −25 test/libraries/SwapFeeLibrary.t.sol
+16 −16 test/libraries/SwapMath.t.sol
+20 −9 test/utils/Deployers.sol
+0 −1 test/utils/SwapHelper.t.sol

0 comments on commit a57ae47

Please sign in to comment.