-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
168 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
162044 | ||
112467 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
86285 | ||
86214 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
71441 | ||
69428 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule forge-gas-snapshot
updated
19 files
+0 −1 | .forge-snapshots/add.snap | |
+0 −1 | .forge-snapshots/addClosure.snap | |
+1 −1 | .forge-snapshots/checkManyAdd.snap | |
+1 −1 | .forge-snapshots/checkSize.snap | |
+1 −1 | .forge-snapshots/internalClosure.snap | |
+1 −1 | .forge-snapshots/manyAdd.snap | |
+1 −1 | .forge-snapshots/manySstore.snap | |
+1 −0 | .forge-snapshots/singleSstore.snap | |
+1 −0 | .forge-snapshots/singleSstoreClosure.snap | |
+1 −0 | .forge-snapshots/singleSstoreLastCall.snap | |
+1 −1 | .forge-snapshots/sizeTarget.snap | |
+1 −1 | .forge-snapshots/sstoreClosure.snap | |
+1 −1 | .github/workflows/test.yml | |
+21 −0 | LICENSE | |
+1 −1 | lib/forge-std | |
+11 −2 | src/GasSnapshot.sol | |
+4 −0 | src/test/SimpleOperations.sol | |
+5 −2 | src/utils/UintString.sol | |
+31 −23 | test/GasSnapshot.t.sol |
Submodule forge-std
updated
41 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.24; | ||
|
||
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol"; | ||
import {SafeCast} from "@uniswap/v4-core/src/libraries/SafeCast.sol"; | ||
import {Owned} from "solmate/auth/Owned.sol"; | ||
import {FeeTaker} from "./../../../contracts/hooks/examples/FeeTaker.sol"; | ||
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol"; | ||
import {BalanceDelta} from "@uniswap/v4-core/src/types/BalanceDelta.sol"; | ||
import {BaseHook} from "./../../../contracts/BaseHook.sol"; | ||
import {Currency, CurrencyLibrary} from "@uniswap/v4-core/src/types/Currency.sol"; | ||
|
||
contract FeeTakingExtension is FeeTaker, Owned { | ||
using SafeCast for uint256; | ||
using CurrencyLibrary for Currency; | ||
|
||
uint128 private constant TOTAL_BIPS = 10000; | ||
uint128 public immutable swapFeeBips; | ||
address public treasury; | ||
|
||
uint256 public afterSwapCounter; | ||
int128 public DONATION_AMOUNT = 1 gwei; | ||
|
||
constructor(IPoolManager _poolManager, uint128 _swapFeeBips, address _owner, address _treasury) | ||
FeeTaker(_poolManager) | ||
Owned(_owner) | ||
{ | ||
swapFeeBips = _swapFeeBips; | ||
treasury = _treasury; | ||
} | ||
|
||
function _afterSwap( | ||
address, | ||
PoolKey memory key, | ||
IPoolManager.SwapParams memory params, | ||
BalanceDelta, | ||
bytes calldata | ||
) internal override returns (bytes4, int128) { | ||
afterSwapCounter++; | ||
bool currency0Specified = (params.amountSpecified < 0 == params.zeroForOne); | ||
Currency currencyUnspecified = currency0Specified ? key.currency1 : key.currency0; | ||
currencyUnspecified.transfer(address(manager), uint256(int256(DONATION_AMOUNT))); | ||
manager.settle(currencyUnspecified); | ||
return (BaseHook.afterSwap.selector, -DONATION_AMOUNT); | ||
} | ||
|
||
function setTreasury(address _treasury) external onlyOwner { | ||
treasury = _treasury; | ||
} | ||
|
||
function _feeAmount(int128 amountUnspecified) internal view override returns (uint256) { | ||
return uint128(amountUnspecified) * swapFeeBips / TOTAL_BIPS; | ||
} | ||
|
||
function _recipient() internal view override returns (address) { | ||
return treasury; | ||
} | ||
|
||
// make this a no-op in testing | ||
function validateHookAddress(BaseHook _this) internal pure override {} | ||
} |