Skip to content

Commit

Permalink
Minor swap speedup (osmosis-labs#7606)
Browse files Browse the repository at this point in the history
* Minor swap speedup

* Remove another DecCoin construction
  • Loading branch information
ValarDragon authored Feb 25, 2024
1 parent a96d23f commit 083258c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions x/concentrated-liquidity/swaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ func (k Keeper) computeOutAmtGivenIn(
}

// Add spread reward growth per share to the pool-global spread reward accumulator.
spreadRewardGrowth := sdk.NewDecCoinFromDec(tokenInMin.Denom, swapState.globalSpreadRewardGrowthPerUnitLiquidity)
spreadRewardGrowth := sdk.DecCoin{Denom: tokenInMin.Denom, Amount: swapState.globalSpreadRewardGrowthPerUnitLiquidity}
spreadRewardAccumulator.AddToAccumulator(sdk.NewDecCoins(spreadRewardGrowth))

// Coin amounts require int values
Expand Down Expand Up @@ -670,7 +670,8 @@ func (k Keeper) swapCrossTickLogic(ctx sdk.Context,
}

// Retrieve the liquidity held in the next closest initialized tick
liquidityNet, err := k.crossTick(ctx, p.GetId(), nextInitializedTick, &nextInitializedTickInfo, sdk.NewDecCoinFromDec(tokenInDenom, swapState.globalSpreadRewardGrowthPerUnitLiquidity), spreadRewardAccum.GetValue(), *uptimeAccums)
spreadRewardGrowth := sdk.DecCoin{Denom: tokenInDenom, Amount: swapState.globalSpreadRewardGrowthPerUnitLiquidity}
liquidityNet, err := k.crossTick(ctx, p.GetId(), nextInitializedTick, &nextInitializedTickInfo, spreadRewardGrowth, spreadRewardAccum.GetValue(), *uptimeAccums)
if err != nil {
return swapState, err
}
Expand Down

0 comments on commit 083258c

Please sign in to comment.