Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jl/add in and out coins to cl swap listener #4950

Merged
merged 6 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}