diff --git a/.forge-snapshots/poolManager bytecode size.snap b/.forge-snapshots/poolManager bytecode size.snap index 5456a36c8..ba031d117 100644 --- a/.forge-snapshots/poolManager bytecode size.snap +++ b/.forge-snapshots/poolManager bytecode size.snap @@ -1 +1 @@ -24607 \ No newline at end of file +24361 \ No newline at end of file diff --git a/.forge-snapshots/simpleSwapEOAInitiated.snap b/.forge-snapshots/simpleSwapEOAInitiated.snap index 8e9a64b50..87888e02c 100644 --- a/.forge-snapshots/simpleSwapEOAInitiated.snap +++ b/.forge-snapshots/simpleSwapEOAInitiated.snap @@ -1 +1 @@ -173820 \ No newline at end of file +172919 \ No newline at end of file diff --git a/src/Claims.sol b/src/Claims.sol deleted file mode 100644 index e9311eff0..000000000 --- a/src/Claims.sol +++ /dev/null @@ -1,51 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.20; - -import {Currency, CurrencyLibrary} from "./types/Currency.sol"; -import {IClaims} from "./interfaces/IClaims.sol"; - -/// An intentionally barebones balance mapping only supporting mint/burn/transfer -contract Claims is IClaims { - using CurrencyLibrary for Currency; - - // Mapping from Currency to account balances - mapping(Currency currency => mapping(address account => uint256)) private balances; - - /// @inheritdoc IClaims - function balanceOf(address account, Currency currency) public view returns (uint256) { - return balances[currency][account]; - } - - /// @inheritdoc IClaims - function transfer(address to, Currency currency, uint256 amount) public { - if (to == address(this)) revert InvalidAddress(); - - if (amount > balances[currency][msg.sender]) revert InsufficientBalance(); - unchecked { - balances[currency][msg.sender] -= amount; - } - balances[currency][to] += amount; - emit Transfer(msg.sender, to, currency, amount); - } - - /// @notice Mint `amount` of currency to address - /// @param to The address to mint to - /// @param currency The currency to mint - /// @param amount The amount to mint - function _mint(address to, Currency currency, uint256 amount) internal { - balances[currency][to] += amount; - emit Mint(to, currency, amount); - } - - /// @notice Burn `amount` of currency from msg.sender - /// @param currency The currency to mint - /// @param amount The amount to burn - /// @dev Will revert if the sender does not have enough balance - function _burn(Currency currency, uint256 amount) internal { - if (amount > balances[currency][msg.sender]) revert InsufficientBalance(); - unchecked { - balances[currency][msg.sender] -= amount; - } - emit Burn(msg.sender, currency, amount); - } -} diff --git a/src/interfaces/IClaims.sol b/src/interfaces/IClaims.sol deleted file mode 100644 index dabc238f5..000000000 --- a/src/interfaces/IClaims.sol +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -import {Currency} from "../types/Currency.sol"; - -interface IClaims { - /// @notice Thrown when user has insufficient Claims balance - error InsufficientBalance(); - - /// @notice Thrown when transferring Claims to this address - error InvalidAddress(); - - /// @notice Get the balance of `account` for `currency` - /// @param account The account to get the balance of - /// @param currency The currency to get the balance of - function balanceOf(address account, Currency currency) external returns (uint256); - - /// @notice Transfer `amount` of `currency` from sender to `to` - /// @param to The address to transfer to - /// @param currency The currency to transfer - /// @param amount The amount to transfer - /// @dev Will revert if the sender does not have enough balance - function transfer(address to, Currency currency, uint256 amount) external; - - /// @notice Emitted when minting `amount` of currency Claims to address - event Mint(address indexed to, Currency indexed currency, uint256 amount); - /// @notice Emitted when burning `amount` of currency Claims from address - event Burn(address indexed from, Currency indexed currency, uint256 amount); - /// @notice Emitted when transferring `amount` of currency Claims - event Transfer(address indexed from, address indexed to, Currency indexed currency, uint256 amount); -} diff --git a/src/interfaces/IPoolManager.sol b/src/interfaces/IPoolManager.sol index 193e45f79..a21ecfeb3 100644 --- a/src/interfaces/IPoolManager.sol +++ b/src/interfaces/IPoolManager.sol @@ -7,7 +7,6 @@ import {Pool} from "../libraries/Pool.sol"; import {IHooks} from "./IHooks.sol"; import {IERC6909Claims} from "./external/IERC6909Claims.sol"; import {IFees} from "./IFees.sol"; -import {IClaims} from "./IClaims.sol"; import {BalanceDelta} from "../types/BalanceDelta.sol"; import {PoolId} from "../types/PoolId.sol"; import {Position} from "../libraries/Position.sol"; diff --git a/src/test/MockClaims.sol b/src/test/MockClaims.sol deleted file mode 100644 index 9dccea00f..000000000 --- a/src/test/MockClaims.sol +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; - -import {Test} from "forge-std/Test.sol"; -import {Claims} from "../Claims.sol"; -import {IClaims} from "../interfaces/IClaims.sol"; -import {CurrencyLibrary, Currency} from "../types/Currency.sol"; - -contract MockClaims is Claims { - using CurrencyLibrary for Currency; - - function mint(address to, Currency currency, uint256 amount) public { - _mint(to, currency, amount); - } - - function burn(Currency currency, uint256 amount) public { - _burn(currency, amount); - } -} diff --git a/test/Claims.t.sol b/test/Claims.t.sol deleted file mode 100644 index 436c671ea..000000000 --- a/test/Claims.t.sol +++ /dev/null @@ -1,99 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; - -import {Test} from "forge-std/Test.sol"; -import {Claims} from "../src/Claims.sol"; -import {IClaims} from "../src/interfaces/IClaims.sol"; -import {CurrencyLibrary, Currency} from "../src/types/Currency.sol"; -import {MockClaims} from "../src/test/MockClaims.sol"; -import {Deployers} from "./utils/Deployers.sol"; - -contract ClaimsTest is Test, Deployers { - using CurrencyLibrary for Currency; - - MockClaims claimsImpl = new MockClaims(); - - event Mint(address indexed to, Currency indexed currency, uint256 amount); - event Burn(address indexed from, Currency indexed currency, uint256 amount); - event Transfer(address indexed from, address indexed to, Currency indexed currency, uint256 amount); - - function setUp() public { - (currency0, currency1) = deployMintAndApprove2Currencies(); - } - - function testCanBurn(uint256 amount) public { - assertEq(claimsImpl.balanceOf(address(this), currency0), 0); - vm.expectEmit(true, true, false, false); - emit Mint(address(this), currency0, amount); - claimsImpl.mint(address(this), currency0, amount); - assertEq(claimsImpl.balanceOf(address(this), currency0), amount); - - vm.expectEmit(true, true, false, false); - emit Burn(address(this), currency0, amount); - claimsImpl.burn(currency0, amount); - assertEq(claimsImpl.balanceOf(address(this), currency0), 0); - } - - function testCatchesUnderflowOnBurn(uint256 amount) public { - vm.assume(amount < type(uint256).max - 1); - vm.expectEmit(true, true, false, false); - emit Mint(address(this), currency0, amount); - claimsImpl.mint(address(this), currency0, amount); - assertEq(claimsImpl.balanceOf(address(this), currency0), amount); - - vm.expectRevert(abi.encodeWithSelector(IClaims.InsufficientBalance.selector)); - claimsImpl.burn(currency0, amount + 1); - } - - function testCanTransfer(uint256 amount) public { - vm.expectEmit(true, true, false, false); - emit Mint(address(this), currency0, amount); - claimsImpl.mint(address(this), currency0, amount); - assertEq(claimsImpl.balanceOf(address(this), currency0), amount); - - vm.expectEmit(true, true, true, false); - emit Transfer(address(this), address(1), currency0, amount); - claimsImpl.transfer(address(1), currency0, amount); - assertEq(claimsImpl.balanceOf(address(this), currency0), 0); - assertEq(claimsImpl.balanceOf(address(1), currency0), amount); - } - - function testCatchesUnderflowOnTransfer(uint256 amount) public { - vm.assume(amount < type(uint256).max - 1); - - vm.expectEmit(true, true, false, false); - emit Mint(address(this), currency0, amount); - claimsImpl.mint(address(this), currency0, amount); - assertEq(claimsImpl.balanceOf(address(this), currency0), amount); - - vm.expectRevert(abi.encodeWithSelector(IClaims.InsufficientBalance.selector)); - claimsImpl.transfer(address(1), currency0, amount + 1); - } - - function testCatchesOverflowOnTransfer() public { - claimsImpl.mint(address(0xdead), currency0, type(uint256).max); - claimsImpl.mint(address(this), currency0, 1); - // transfer will revert since overflow - vm.expectRevert(); - claimsImpl.transfer(address(0xdead), currency0, 1); - } - - function testCanTransferToZeroAddress() public { - claimsImpl.mint(address(this), currency0, 1); - assertEq(claimsImpl.balanceOf(address(this), currency0), 1); - assertEq(claimsImpl.balanceOf(address(0), currency0), 0); - - vm.expectEmit(true, true, true, false); - emit Transfer(address(this), address(0), currency0, 1); - claimsImpl.transfer(address(0), currency0, 1); - - assertEq(claimsImpl.balanceOf(address(this), currency0), 0); - assertEq(claimsImpl.balanceOf(address(0), currency0), 1); - } - - function testTransferToClaimsContractFails() public { - claimsImpl.mint(address(this), currency0, 1); - vm.expectRevert(abi.encodeWithSelector(IClaims.InvalidAddress.selector)); - claimsImpl.transfer(address(claimsImpl), currency0, 1); - } -}