Skip to content

Commit

Permalink
fix todo, use CurrencySettleTake
Browse files Browse the repository at this point in the history
  • Loading branch information
saucepoint committed May 10, 2024
1 parent 32dd585 commit baa1334
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions contracts/hooks/examples/TWAMM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -314,22 +314,14 @@ contract TWAMM is BaseHook, ITWAMM {

if (swapParams.zeroForOne) {
if (delta.amount0() < 0) {
// 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);
key.currency0.settle(poolManager, address(this), uint256(uint128(-delta.amount0())), false);
}
if (delta.amount1() > 0) {
key.currency1.take(poolManager, address(this), uint256(uint128(delta.amount1())), false);
}
} else {
if (delta.amount1() < 0) {
// 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);
key.currency1.settle(poolManager, address(this), uint256(uint128(-delta.amount1())), false);
}
if (delta.amount0() > 0) {
key.currency0.take(poolManager, address(this), uint256(uint128(delta.amount0())), false);
Expand Down

0 comments on commit baa1334

Please sign in to comment.