Skip to content

Commit

Permalink
rename CurrencySettleTake, move to test (#712)
Browse files Browse the repository at this point in the history
  • Loading branch information
snreynolds authored May 24, 2024
1 parent 379799d commit 15ec9af
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/test/CustomCurveHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import {PoolKey} from "../types/PoolKey.sol";
import {BeforeSwapDelta, toBeforeSwapDelta} from "../types/BeforeSwapDelta.sol";
import {BalanceDelta} from "../types/BalanceDelta.sol";
import {Currency} from "../types/Currency.sol";
import {CurrencySettleTake} from "../libraries/CurrencySettleTake.sol";
import {CurrencySettler} from "../../test/utils/CurrencySettler.sol";
import {BaseTestHooks} from "./BaseTestHooks.sol";
import {IERC20Minimal} from "../interfaces/external/IERC20Minimal.sol";
import {CurrencyLibrary, Currency} from "../types/Currency.sol";

contract CustomCurveHook is BaseTestHooks {
using Hooks for IHooks;
using CurrencyLibrary for Currency;
using CurrencySettleTake for Currency;
using CurrencySettler for Currency;

error AddLiquidityDirectToHook();

Expand Down
4 changes: 2 additions & 2 deletions src/test/DeltaReturningHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Hooks} from "../libraries/Hooks.sol";
import {SafeCast} from "../libraries/SafeCast.sol";
import {IHooks} from "../interfaces/IHooks.sol";
import {IPoolManager} from "../interfaces/IPoolManager.sol";
import {CurrencySettleTake} from "../libraries/CurrencySettleTake.sol";
import {CurrencySettler} from "../../test/utils/CurrencySettler.sol";
import {PoolKey} from "../types/PoolKey.sol";
import {BalanceDelta, toBalanceDelta} from "../types/BalanceDelta.sol";
import {Currency} from "../types/Currency.sol";
Expand All @@ -17,7 +17,7 @@ import {BeforeSwapDelta, toBeforeSwapDelta} from "../types/BeforeSwapDelta.sol";
contract DeltaReturningHook is BaseTestHooks {
using Hooks for IHooks;
using CurrencyLibrary for Currency;
using CurrencySettleTake for Currency;
using CurrencySettler for Currency;

IPoolManager immutable manager;

Expand Down
4 changes: 2 additions & 2 deletions src/test/PoolClaimsTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {IPoolManager} from "../interfaces/IPoolManager.sol";
import {PoolKey} from "../types/PoolKey.sol";
import {PoolTestBase} from "./PoolTestBase.sol";
import {SafeCast} from "../libraries/SafeCast.sol";
import {CurrencySettleTake} from "../libraries/CurrencySettleTake.sol";
import {CurrencySettler} from "../../test/utils/CurrencySettler.sol";

contract PoolClaimsTest is PoolTestBase {
using CurrencyLibrary for Currency;
using CurrencySettleTake for Currency;
using CurrencySettler for Currency;
using SafeCast for uint256;

constructor(IPoolManager _manager) PoolTestBase(_manager) {}
Expand Down
4 changes: 2 additions & 2 deletions src/test/PoolDonateTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {BalanceDelta, BalanceDeltaLibrary} from "../types/BalanceDelta.sol";
import {PoolTestBase} from "./PoolTestBase.sol";
import {IHooks} from "../interfaces/IHooks.sol";
import {Hooks} from "../libraries/Hooks.sol";
import {CurrencySettleTake} from "../libraries/CurrencySettleTake.sol";
import {CurrencySettler} from "../../test/utils/CurrencySettler.sol";

contract PoolDonateTest is PoolTestBase {
using CurrencyLibrary for Currency;
using CurrencySettleTake for Currency;
using CurrencySettler for Currency;
using Hooks for IHooks;

constructor(IPoolManager _manager) PoolTestBase(_manager) {}
Expand Down
4 changes: 2 additions & 2 deletions src/test/PoolModifyLiquidityTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import {PoolTestBase} from "./PoolTestBase.sol";
import {IHooks} from "../interfaces/IHooks.sol";
import {Hooks} from "../libraries/Hooks.sol";
import {LPFeeLibrary} from "../libraries/LPFeeLibrary.sol";
import {CurrencySettleTake} from "../libraries/CurrencySettleTake.sol";
import {CurrencySettler} from "../../test/utils/CurrencySettler.sol";
import {StateLibrary} from "../libraries/StateLibrary.sol";

contract PoolModifyLiquidityTest is PoolTestBase {
using CurrencyLibrary for Currency;
using CurrencySettleTake for Currency;
using CurrencySettler for Currency;
using Hooks for IHooks;
using LPFeeLibrary for uint24;
using PoolIdLibrary for PoolKey;
Expand Down
4 changes: 2 additions & 2 deletions src/test/PoolModifyLiquidityTestNoChecks.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import {PoolTestBase} from "./PoolTestBase.sol";
import {IHooks} from "../interfaces/IHooks.sol";
import {Hooks} from "../libraries/Hooks.sol";
import {LPFeeLibrary} from "../libraries/LPFeeLibrary.sol";
import {CurrencySettleTake} from "../libraries/CurrencySettleTake.sol";
import {CurrencySettler} from "../../test/utils/CurrencySettler.sol";
import {Constants} from "../../test/utils/Constants.sol";

contract PoolModifyLiquidityTestNoChecks is PoolTestBase {
using CurrencyLibrary for Currency;
using CurrencySettleTake for Currency;
using CurrencySettler for Currency;
using Hooks for IHooks;
using LPFeeLibrary for uint24;
using PoolIdLibrary for PoolKey;
Expand Down
4 changes: 2 additions & 2 deletions src/test/PoolNestedActionsTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {Test} from "forge-std/Test.sol";
import {BalanceDelta} from "../types/BalanceDelta.sol";
import {Currency} from "../types/Currency.sol";
import {PoolId, PoolIdLibrary} from "../types/PoolId.sol";
import {CurrencySettleTake} from "../libraries/CurrencySettleTake.sol";
import {CurrencySettler} from "../../test/utils/CurrencySettler.sol";
import {StateLibrary} from "../libraries/StateLibrary.sol";
import {TransientStateLibrary} from "../libraries/TransientStateLibrary.sol";

Expand Down Expand Up @@ -66,7 +66,7 @@ contract PoolNestedActionsTest is Test, IUnlockCallback {
contract NestedActionExecutor is Test, PoolTestBase {
using StateLibrary for IPoolManager;
using TransientStateLibrary for IPoolManager;
using CurrencySettleTake for Currency;
using CurrencySettler for Currency;
using PoolIdLibrary for PoolKey;

PoolKey internal key;
Expand Down
4 changes: 2 additions & 2 deletions src/test/PoolSwapTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {PoolKey} from "../types/PoolKey.sol";
import {IHooks} from "../interfaces/IHooks.sol";
import {Hooks} from "../libraries/Hooks.sol";
import {PoolTestBase} from "./PoolTestBase.sol";
import {CurrencySettleTake} from "../libraries/CurrencySettleTake.sol";
import {CurrencySettler} from "../../test/utils/CurrencySettler.sol";

contract PoolSwapTest is PoolTestBase {
using CurrencyLibrary for Currency;
using CurrencySettleTake for Currency;
using CurrencySettler for Currency;
using Hooks for IHooks;

constructor(IPoolManager _manager) PoolTestBase(_manager) {}
Expand Down
4 changes: 2 additions & 2 deletions src/test/PoolTakeTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {IPoolManager} from "../interfaces/IPoolManager.sol";
import {PoolKey} from "../types/PoolKey.sol";
import {PoolTestBase} from "./PoolTestBase.sol";
import {SafeCast} from "../libraries/SafeCast.sol";
import {CurrencySettleTake} from "../libraries/CurrencySettleTake.sol";
import {CurrencySettler} from "../../test/utils/CurrencySettler.sol";

contract PoolTakeTest is PoolTestBase {
using CurrencyLibrary for Currency;
using CurrencySettleTake for Currency;
using CurrencySettler for Currency;
using SafeCast for uint256;

constructor(IPoolManager _manager) PoolTestBase(_manager) {}
Expand Down
4 changes: 2 additions & 2 deletions src/test/SkipCallsTestHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import {CurrencyLibrary, Currency} from "../types/Currency.sol";
import {PoolTestBase} from "./PoolTestBase.sol";
import {Constants} from "../../test/utils/Constants.sol";
import {Test} from "forge-std/Test.sol";
import {CurrencySettleTake} from "../libraries/CurrencySettleTake.sol";
import {CurrencySettler} from "../../test/utils/CurrencySettler.sol";
import {StateLibrary} from "../libraries/StateLibrary.sol";
import {TransientStateLibrary} from "../libraries/TransientStateLibrary.sol";
import {BeforeSwapDelta, BeforeSwapDeltaLibrary} from "../types/BeforeSwapDelta.sol";

contract SkipCallsTestHook is BaseTestHooks, Test {
using CurrencySettleTake for Currency;
using CurrencySettler for Currency;
using PoolIdLibrary for PoolKey;
using Hooks for IHooks;
using StateLibrary for IPoolManager;
Expand Down
4 changes: 2 additions & 2 deletions src/test/SwapRouterNoChecks.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {PoolKey} from "../types/PoolKey.sol";
import {IHooks} from "../interfaces/IHooks.sol";
import {Hooks} from "../libraries/Hooks.sol";
import {PoolTestBase} from "./PoolTestBase.sol";
import {CurrencySettleTake} from "../libraries/CurrencySettleTake.sol";
import {CurrencySettler} from "../../test/utils/CurrencySettler.sol";

contract SwapRouterNoChecks is PoolTestBase {
using CurrencyLibrary for Currency;
using CurrencySettleTake for Currency;
using CurrencySettler for Currency;
using Hooks for IHooks;

constructor(IPoolManager _manager) PoolTestBase(_manager) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {Currency, CurrencyLibrary} from "../types/Currency.sol";
import {IERC20Minimal} from "../interfaces/external/IERC20Minimal.sol";
import {IPoolManager} from "../interfaces/IPoolManager.sol";
import {Currency, CurrencyLibrary} from "../../src/types/Currency.sol";
import {IERC20Minimal} from "../../src/interfaces/external/IERC20Minimal.sol";
import {IPoolManager} from "../../src/interfaces/IPoolManager.sol";

library CurrencySettleTake {
/// @notice Library used to interact with PoolManager.sol to settle any open deltas.
/// To settle a positive delta (a credit to the user), a user may take or mint.
/// To settle a negative delta (a debt on the user), a user make transfer or burn to pay off a debt.
/// @dev Note that sync() is called before any erc-20 transfer in `settle`.
library CurrencySettler {
using CurrencyLibrary for Currency;

/// @notice Settle (pay) a currency to the PoolManager
Expand Down

0 comments on commit 15ec9af

Please sign in to comment.