Skip to content

Commit

Permalink
Jl/add in and out coins to cl swap listener (#4950)
Browse files Browse the repository at this point in the history
* Add input and output

- Follows gamm module patterns such as 1) naming convention and 2) providing tokens (sdk.Coins) even though it's currently expected to be a single token in or out (sdk.Coin).

* Update modules that use hook

* add changelog entry
  • Loading branch information
NotJeremyLiu authored May 26, 2023
1 parent bb5fe6e commit fd3f811
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#5239](https://github.com/osmosis-labs/osmosis/pull/5239) Implement `GetTotalPoolShares` public keeper function for GAMM.
* [#5261](https://github.com/osmosis-labs/osmosis/pull/5261) Allows `UpdateFeeTokenProposal` to take in multiple fee tokens instead of just one.
* [#5265](https://github.com/osmosis-labs/osmosis/pull/5265) Ensure a lock cannot point to multiple synthetic locks. Deprecates `SyntheticLockupsByLockupID` in favor of `SyntheticLockupByLockupID`.
* [#4950] (https://github.com/osmosis-labs/osmosis/pull/4950) Add in/out tokens to Concentrated Liquidity's AfterConcentratedPoolSwap hook

### API breaks

Expand Down
2 changes: 1 addition & 1 deletion x/concentrated-liquidity/clmocks/listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ func (l *ConcentratedLiquidityListenerMock) AfterLastPoolPositionRemoved(ctx sdk
l.AfterLastPoolPositionRemovedCallCount += 1
}

func (l *ConcentratedLiquidityListenerMock) AfterConcentratedPoolSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64) {
func (l *ConcentratedLiquidityListenerMock) AfterConcentratedPoolSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) {
l.AfterConcentratedPoolSwapCallCount += 1
}
2 changes: 1 addition & 1 deletion x/concentrated-liquidity/swaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ func (k Keeper) updatePoolForSwap(
return err
}

k.listeners.AfterConcentratedPoolSwap(ctx, sender, poolId)
k.listeners.AfterConcentratedPoolSwap(ctx, sender, poolId, sdk.Coins{tokenIn}, sdk.Coins{tokenOut})

// TODO: move this to poolmanager and remove from here.
// Also, remove from gamm.
Expand Down
6 changes: 3 additions & 3 deletions x/concentrated-liquidity/types/listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type ConcentratedLiquidityListener interface {
// liquidity pool.
AfterLastPoolPositionRemoved(ctx sdk.Context, sender sdk.AccAddress, poolId uint64)
// AfterConcentratedPoolSwap is called after a swap in a concentrated liquidity pool.
AfterConcentratedPoolSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64)
AfterConcentratedPoolSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins)
}

type ConcentratedLiquidityListeners []ConcentratedLiquidityListener
Expand All @@ -37,9 +37,9 @@ func (l ConcentratedLiquidityListeners) AfterLastPoolPositionRemoved(ctx sdk.Con
}
}

func (l ConcentratedLiquidityListeners) AfterConcentratedPoolSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64) {
func (l ConcentratedLiquidityListeners) AfterConcentratedPoolSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) {
for i := range l {
l[i].AfterConcentratedPoolSwap(ctx, sender, poolId)
l[i].AfterConcentratedPoolSwap(ctx, sender, poolId, input, output)
}
}

Expand Down
2 changes: 1 addition & 1 deletion x/pool-incentives/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,5 @@ func (h Hooks) AfterLastPoolPositionRemoved(ctx sdk.Context, sender sdk.AccAddre
}

// AfterConcentratedPoolSwap is a noop.
func (h Hooks) AfterConcentratedPoolSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64) {
func (h Hooks) AfterConcentratedPoolSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) {
}
2 changes: 1 addition & 1 deletion x/twap/listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ func (l *concentratedLiquidityListener) AfterLastPoolPositionRemoved(ctx sdk.Con
l.k.trackChangedPool(ctx, poolId)
}

func (l *concentratedLiquidityListener) AfterConcentratedPoolSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64) {
func (l *concentratedLiquidityListener) AfterConcentratedPoolSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) {
l.k.trackChangedPool(ctx, poolId)
}

0 comments on commit fd3f811

Please sign in to comment.