Skip to content

Commit

Permalink
fix(v4-sdk): switch back recipient (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
dianakocsis authored Feb 4, 2025
1 parent e03acbf commit 17c345d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions sdks/v4-sdk/src/PositionManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ describe('PositionManager', () => {

planner.addAction(Actions.SETTLE, [toAddress(pool_0_1.currency0), OPEN_DELTA, false])
planner.addAction(Actions.SETTLE, [toAddress(pool_0_1.currency1), OPEN_DELTA, false])
planner.addAction(Actions.SWEEP, [toAddress(pool_0_1.currency0), MSG_SENDER])
planner.addAction(Actions.SWEEP, [toAddress(pool_0_1.currency1), MSG_SENDER])
planner.addAction(Actions.SWEEP, [toAddress(pool_0_1.currency0), recipient])
planner.addAction(Actions.SWEEP, [toAddress(pool_0_1.currency1), recipient])
expect(calldata).toEqual(V4PositionManager.encodeModifyLiquidities(planner.finalize(), deadline))

expect(value).toEqual('0x00')
Expand Down Expand Up @@ -360,8 +360,8 @@ describe('PositionManager', () => {
planner.addAction(Actions.UNWRAP, [OPEN_DELTA])
planner.addAction(Actions.SETTLE, [toAddress(pool_1_eth.currency0), OPEN_DELTA, false])
planner.addAction(Actions.SETTLE, [toAddress(pool_1_eth.currency1), OPEN_DELTA, false])
planner.addAction(Actions.SWEEP, [toAddress(pool_1_eth.currency0.wrapped), MSG_SENDER])
planner.addAction(Actions.SWEEP, [toAddress(pool_1_eth.currency1), MSG_SENDER])
planner.addAction(Actions.SWEEP, [toAddress(pool_1_eth.currency0.wrapped), recipient])
planner.addAction(Actions.SWEEP, [toAddress(pool_1_eth.currency1), recipient])
expect(calldata).toEqual(V4PositionManager.encodeModifyLiquidities(planner.finalize(), deadline))

expect(value).toEqual('0x00')
Expand Down
10 changes: 6 additions & 4 deletions sdks/v4-sdk/src/PositionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,16 @@ export abstract class V4PositionManager {
planner.addSettle(position.pool.currency0, false)
planner.addSettle(position.pool.currency1, false)
// sweep any leftover wrapped native that was not unwrapped
planner.addSweep(position.pool.currency0.wrapped, MSG_SENDER)
planner.addSweep(position.pool.currency1, MSG_SENDER)
// recipient will be same as the v4 lp token recipient
planner.addSweep(position.pool.currency0.wrapped, options.recipient)
planner.addSweep(position.pool.currency1, options.recipient)
} else {
// payer is v4 position manager
planner.addSettle(position.pool.currency0, false)
planner.addSettle(position.pool.currency1, false)
planner.addSweep(position.pool.currency0, MSG_SENDER)
planner.addSweep(position.pool.currency1, MSG_SENDER)
// recipient will be same as the v4 lp token recipient
planner.addSweep(position.pool.currency0, options.recipient)
planner.addSweep(position.pool.currency1, options.recipient)
}
} else {
// need to settle both currencies when minting / adding liquidity (user is the payer)
Expand Down

0 comments on commit 17c345d

Please sign in to comment.