@@ -10,7 +10,6 @@ import (
1010 sdk "github.com/cosmos/cosmos-sdk/types"
1111
1212 osmosislockuptypes "github.com/quicksilver-zone/quicksilver/third-party-chains/osmosis-types/lockup"
13- "github.com/quicksilver-zone/quicksilver/utils"
1413 participationrewardstypes "github.com/quicksilver-zone/quicksilver/x/participationrewards/types"
1514
1615 cl "github.com/quicksilver-zone/quicksilver/third-party-chains/osmosis-types/concentrated-liquidity"
@@ -22,7 +21,7 @@ type ParticipationRewardsKeeper interface {
2221 GetProtocolData (ctx sdk.Context , pdType participationrewardstypes.ProtocolDataType , key string ) (participationrewardstypes.ProtocolData , bool )
2322}
2423
25- func DetermineApplicableTokensInPool (ctx sdk.Context , prKeeper ParticipationRewardsKeeper , lock osmosislockuptypes.PeriodLock , chainID string ) (math.Int , error ) {
24+ func DetermineApplicableTokensInPool (ctx sdk.Context , prKeeper ParticipationRewardsKeeper , lock osmosislockuptypes.PeriodLock , chainID string , poolDenom string ) (math.Int , error ) {
2625 gammtoken , err := lock .SingleCoin ()
2726 if err != nil {
2827 return sdk .ZeroInt (), err
@@ -40,18 +39,6 @@ func DetermineApplicableTokensInPool(ctx sdk.Context, prKeeper ParticipationRewa
4039 }
4140 pool , _ := ipool .(* participationrewardstypes.OsmosisPoolProtocolData )
4241
43- poolDenom := ""
44- for _ , zk := range utils .Keys (pool .Denoms ) {
45- if pool .Denoms [zk ].ChainID == chainID {
46- poolDenom = zk
47- break
48- }
49- }
50-
51- if poolDenom == "" {
52- return sdk .ZeroInt (), fmt .Errorf ("invalid zone, pool zone must match %s" , chainID )
53- }
54-
5542 poolData , err := pool .GetPool ()
5643 if err != nil {
5744 return sdk .ZeroInt (), err
@@ -91,8 +78,10 @@ func CalculateUnderlyingAssetsFromPosition(ctx sdk.Context, position clmodel.Pos
9178 return coin0 , coin1 , nil
9279}
9380
94- func DetermineApplicableTokensInClPool (ctx sdk.Context , prKeeper ParticipationRewardsKeeper , position clmodel.Position , chainID string ) (math.Int , error ) {
81+ func DetermineApplicableTokensInClPool (ctx sdk.Context , prKeeper ParticipationRewardsKeeper , position clmodel.Position , chainID string , poolDenom string ) (math.Int , error ) {
9582 poolID := position .PoolId
83+
84+ ctx .Logger ().Info ("DetermineApplicableTokensInClPool" , "poolID" , poolID , "position" , position )
9685 pd , ok := prKeeper .GetProtocolData (ctx , participationrewardstypes .ProtocolDataTypeOsmosisCLPool , fmt .Sprintf ("%d" , poolID ))
9786 if ! ok {
9887 return sdk .ZeroInt (), fmt .Errorf ("unable to obtain protocol data for poolID=%d" , poolID )
@@ -104,18 +93,6 @@ func DetermineApplicableTokensInClPool(ctx sdk.Context, prKeeper ParticipationRe
10493 }
10594 pool , _ := ipool .(* participationrewardstypes.OsmosisClPoolProtocolData )
10695
107- poolDenom := ""
108- for _ , zk := range utils .Keys (pool .Denoms ) {
109- if pool .Denoms [zk ].ChainID == chainID {
110- poolDenom = zk
111- break
112- }
113- }
114-
115- if poolDenom == "" {
116- return sdk .ZeroInt (), fmt .Errorf ("invalid zone, pool zone must match %s" , chainID )
117- }
118-
11996 poolData , err := pool .GetPool ()
12097 if err != nil {
12198 return sdk .ZeroInt (), err
@@ -126,13 +103,16 @@ func DetermineApplicableTokensInClPool(ctx sdk.Context, prKeeper ParticipationRe
126103 if err != nil {
127104 return sdk .ZeroInt (), errors .New ("unable to determine underlying assets for position" )
128105 }
106+
107+ ctx .Logger ().Info ("DetermineApplicableTokensInClPool" , "asset0" , asset0 , "asset1" , asset1 )
108+
129109 switch true {
130110 case asset0 .Denom == poolDenom :
131111 asset = asset0
132112 case asset1 .Denom == poolDenom :
133113 asset = asset1
134114 default :
135- return sdk .ZeroInt (), fmt .Errorf ("position does not match local denom for %s" , chainID )
115+ return sdk .ZeroInt (), fmt .Errorf ("position does not match local denom for %s (poolDenom: %s) " , chainID , poolDenom )
136116 }
137117
138118 return asset .Amount , nil
0 commit comments