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

feat(x/protocolpool)!: allow any coins in continuous funds #21916

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
266 changes: 150 additions & 116 deletions api/cosmos/protocolpool/v1/genesis.pulsar.go

Large diffs are not rendered by default.

246 changes: 182 additions & 64 deletions api/cosmos/protocolpool/v1/tx.pulsar.go

Large diffs are not rendered by default.

692 changes: 624 additions & 68 deletions api/cosmos/protocolpool/v1/types.pulsar.go

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions x/protocolpool/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"time"

"cosmossdk.io/math"
"cosmossdk.io/x/protocolpool/types"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -56,19 +55,19 @@ func (k Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) error
return fmt.Errorf("failed to set last balance: %w", err)
}

totalToBeDistributed := math.ZeroInt()
totalToBeDistributed := sdk.NewCoins()
for _, distribution := range data.Distributions {
totalToBeDistributed = totalToBeDistributed.Add(distribution.Amount)
totalToBeDistributed = totalToBeDistributed.Add(distribution.Amount.Amount...)
if err := k.Distributions.Set(ctx, *distribution.Time, distribution.Amount); err != nil {
return fmt.Errorf("failed to set distribution: %w", err)
}
}

// sanity check to avoid trying to distribute more than what is available
if data.LastBalance.LT(totalToBeDistributed) {
return errors.New("total to be distributed is greater than the last balance")
}

if data.LastBalance.Amount.IsAnyGT(totalToBeDistributed) || !totalToBeDistributed.DenomsSubsetOf(data.LastBalance.Amount) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last balance should always be >= total to be distributed.

Simplest thing would be to flip the check: totalToBeDistributed.IsAnyGT(last balance)
This includes the denoms implicite so that you can drop the DenomsSubsetOf check

return errors.New("total to be distributed is greater than the last balance" + fmt.Sprint(data.LastBalance.Amount, totalToBeDistributed))
}
Comment on lines +68 to +70
Copy link
Contributor

@coderabbitai coderabbitai bot Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix the logical inconsistency in the condition and error message

There's a mismatch between the condition being checked and the error message returned. The condition data.LastBalance.Amount.IsAnyGT(totalToBeDistributed) checks if the last balance amount is greater than the total to be distributed. However, the error message states "total to be distributed is greater than the last balance," which implies the opposite.

To correct this, the condition should check if totalToBeDistributed.IsAnyGT(data.LastBalance.Amount) instead.

Apply this diff to fix the condition:

-if data.LastBalance.Amount.IsAnyGT(totalToBeDistributed) || !totalToBeDistributed.DenomsSubsetOf(data.LastBalance.Amount) {
+if totalToBeDistributed.IsAnyGT(data.LastBalance.Amount) || !totalToBeDistributed.DenomsSubsetOf(data.LastBalance.Amount) {
    return errors.New("total to be distributed is greater than the last balance" + fmt.Sprint(data.LastBalance.Amount, totalToBeDistributed))
}

This change ensures that the error is returned when the total to be distributed exceeds the last balance, aligning the condition with the error message.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if data.LastBalance.Amount.IsAnyGT(totalToBeDistributed) || !totalToBeDistributed.DenomsSubsetOf(data.LastBalance.Amount) {
return errors.New("total to be distributed is greater than the last balance" + fmt.Sprint(data.LastBalance.Amount, totalToBeDistributed))
}
if totalToBeDistributed.IsAnyGT(data.LastBalance.Amount) || !totalToBeDistributed.DenomsSubsetOf(data.LastBalance.Amount) {
return errors.New("total to be distributed is greater than the last balance" + fmt.Sprint(data.LastBalance.Amount, totalToBeDistributed))
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused a bit about the 1st condition, should return an error when totalToBeDistributed > lastBalance?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hieuvubk, you're correct. The error should be returned when totalToBeDistributed is greater than data.LastBalance.Amount. Currently, the condition:

if data.LastBalance.Amount.IsAnyGT(totalToBeDistributed) || !totalToBeDistributed.DenomsSubsetOf(data.LastBalance.Amount) {
    return errors.New("total to be distributed is greater than the last balance" + fmt.Sprint(data.LastBalance.Amount, totalToBeDistributed))
}

checks if data.LastBalance.Amount is greater than totalToBeDistributed, which is the opposite of the intended logic based on the error message.

To fix this inconsistency, the condition should be:

if totalToBeDistributed.IsAnyGT(data.LastBalance.Amount) || !totalToBeDistributed.DenomsSubsetOf(data.LastBalance.Amount) {
    return errors.New("total to be distributed is greater than the last balance" + fmt.Sprint(data.LastBalance.Amount, totalToBeDistributed))
}

This change ensures that an error is returned when totalToBeDistributed exceeds data.LastBalance.Amount, aligning the condition with the error message and the expected behavior.

/_/\
( •.• )

🚀<
A curious rabbit pondering over the code!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not simply go with fmt.Errorf instead which is typically used in these scenarios? For example:

fmt.Errorf("an amount to be distributed is greater than the last balance: %s > %s", totalToBeDistributed, data.LastBalance.Amount))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was actually for testing, but I think it can be useful if we ever encounter this, I'll modify it.

return nil
}

Expand Down Expand Up @@ -112,12 +111,14 @@ func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error)

genState := types.NewGenesisState(cf, budget)

genState.LastBalance, err = k.LastBalance.Get(ctx)
lastBalance, err := k.LastBalance.Get(ctx)
if err != nil {
return nil, err
}

err = k.Distributions.Walk(ctx, nil, func(key time.Time, value math.Int) (stop bool, err error) {
genState.LastBalance = lastBalance

err = k.Distributions.Walk(ctx, nil, func(key time.Time, value types.DistributionAmount) (stop bool, err error) {
genState.Distributions = append(genState.Distributions, &types.Distribution{
Time: &key,
Amount: value,
Expand Down
6 changes: 3 additions & 3 deletions x/protocolpool/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ func (suite *KeeperTestSuite) TestInitGenesis() {
)

gs.Distributions = append(gs.Distributions, &types.Distribution{
Amount: math.OneInt(),
Amount: types.DistributionAmount{Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(100)))},
Time: &time.Time{},
})

err := suite.poolKeeper.InitGenesis(suite.ctx, gs)
suite.Require().ErrorContains(err, "total to be distributed is greater than the last balance")

// Set last balance
gs.LastBalance = math.NewInt(1)
gs.LastBalance = types.DistributionAmount{Amount: sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1)))}
err = suite.poolKeeper.InitGenesis(suite.ctx, gs)
suite.Require().NoError(err)

Expand All @@ -49,5 +49,5 @@ func (suite *KeeperTestSuite) TestInitGenesis() {
suite.Require().NoError(err)
suite.Require().Equal(gs.ContinuousFund, exportedGenState.ContinuousFund)
suite.Require().Equal(gs.Budget, exportedGenState.Budget)
suite.Require().Equal(math.OneInt(), exportedGenState.LastBalance)
suite.Require().Equal(math.OneInt(), exportedGenState.LastBalance.Amount.AmountOf("stake"))
}
106 changes: 48 additions & 58 deletions x/protocolpool/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ type Keeper struct {
BudgetProposal collections.Map[sdk.AccAddress, types.Budget]
ContinuousFund collections.Map[sdk.AccAddress, types.ContinuousFund]
// RecipientFundDistribution key: RecipientAddr | value: Claimable amount
RecipientFundDistribution collections.Map[sdk.AccAddress, math.Int]
Distributions collections.Map[time.Time, math.Int] // key: time.Time | value: amount
LastBalance collections.Item[math.Int]
RecipientFundDistribution collections.Map[sdk.AccAddress, types.DistributionAmount]
Distributions collections.Map[time.Time, types.DistributionAmount] // key: time.Time, denom | value: amounts
LastBalance collections.Item[types.DistributionAmount]
}

const (
Expand Down Expand Up @@ -69,9 +69,9 @@ func NewKeeper(cdc codec.BinaryCodec, env appmodule.Environment, ak types.Accoun
authority: authority,
BudgetProposal: collections.NewMap(sb, types.BudgetKey, "budget", sdk.AccAddressKey, codec.CollValue[types.Budget](cdc)),
ContinuousFund: collections.NewMap(sb, types.ContinuousFundKey, "continuous_fund", sdk.AccAddressKey, codec.CollValue[types.ContinuousFund](cdc)),
RecipientFundDistribution: collections.NewMap(sb, types.RecipientFundDistributionKey, "recipient_fund_distribution", sdk.AccAddressKey, sdk.IntValue),
Distributions: collections.NewMap(sb, types.DistributionsKey, "distributions", sdk.TimeKey, sdk.IntValue),
LastBalance: collections.NewItem(sb, types.LastBalanceKey, "last_balance", sdk.IntValue),
RecipientFundDistribution: collections.NewMap(sb, types.RecipientFundDistributionKey, "recipient_fund_distribution", sdk.AccAddressKey, codec.CollValue[types.DistributionAmount](cdc)),
Distributions: collections.NewMap(sb, types.DistributionsKey, "distributions", sdk.TimeKey, codec.CollValue[types.DistributionAmount](cdc)),
LastBalance: collections.NewItem(sb, types.LastBalanceKey, "last_balance", codec.CollValue[types.DistributionAmount](cdc)),
}

schema, err := sb.Build()
Expand Down Expand Up @@ -114,34 +114,27 @@ func (k Keeper) GetCommunityPool(ctx context.Context) (sdk.Coins, error) {
return k.bankKeeper.GetAllBalances(ctx, moduleAccount.GetAddress()), nil
}

func (k Keeper) withdrawRecipientFunds(ctx context.Context, recipient []byte) (sdk.Coin, error) {
func (k Keeper) withdrawRecipientFunds(ctx context.Context, recipient []byte) (sdk.Coins, error) {
// get allocated continuous fund
fundsAllocated, err := k.RecipientFundDistribution.Get(ctx, recipient)
if err != nil {
if errors.Is(err, collections.ErrNotFound) {
return sdk.Coin{}, types.ErrNoRecipientFound
return nil, types.ErrNoRecipientFound
}
return sdk.Coin{}, err
}

denom, err := k.stakingKeeper.BondDenom(ctx)
if err != nil {
return sdk.Coin{}, err
return nil, err
}

// Distribute funds to the recipient from pool module account
withdrawnAmount := sdk.NewCoin(denom, fundsAllocated)
err = k.DistributeFromStreamFunds(ctx, sdk.NewCoins(withdrawnAmount), recipient)
err = k.DistributeFromStreamFunds(ctx, fundsAllocated.Amount, recipient)
if err != nil {
return sdk.Coin{}, fmt.Errorf("error while distributing funds: %w", err)
return nil, fmt.Errorf("error while distributing funds: %w", err)
}

// reset fund distribution
err = k.RecipientFundDistribution.Set(ctx, recipient, math.ZeroInt())
err = k.RecipientFundDistribution.Set(ctx, recipient, types.DistributionAmount{Amount: sdk.NewCoins()})
if err != nil {
return sdk.Coin{}, err
return nil, err
}
return withdrawnAmount, nil
return fundsAllocated.Amount, nil
}

// SetToDistribute sets the amount to be distributed among recipients.
Expand All @@ -152,30 +145,29 @@ func (k Keeper) SetToDistribute(ctx context.Context) error {
return errorsmod.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", types.ProtocolPoolDistrAccount)
}

denom, err := k.stakingKeeper.BondDenom(ctx)
if err != nil {
return err
}

currentBalance := k.bankKeeper.GetAllBalances(ctx, moduleAccount.GetAddress())
distributionBalance := currentBalance.AmountOf(denom)

// if the balance is zero, return early
if distributionBalance.IsZero() {
if currentBalance.IsZero() {
return nil
}

// if the balance does not have any of the allowed denoms, return early // TODO

lastBalance, err := k.LastBalance.Get(ctx)
if err != nil {
if errors.Is(err, collections.ErrNotFound) {
lastBalance = math.ZeroInt()
lastBalance = types.DistributionAmount{Amount: sdk.NewCoins()}
} else {
return err
}
}

// Calculate the amount to be distributed
amountToDistribute := distributionBalance.Sub(lastBalance)
amountToDistribute, anyNegative := currentBalance.SafeSub(lastBalance.Amount...)
if anyNegative {
return errors.New("error while calculating the amount to distribute, result can't be negative")
}

// Check if there are any recipients to distribute to, if not, send straight to the community pool and avoid
// setting the distributions
Expand All @@ -190,24 +182,23 @@ func (k Keeper) SetToDistribute(ctx context.Context) error {

// if there are no continuous funds, send all the funds to the community pool and reset the last balance
if !hasContinuousFunds {
poolCoins := sdk.NewCoins(sdk.NewCoin(denom, amountToDistribute))
if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ProtocolPoolDistrAccount, types.ModuleName, poolCoins); err != nil {
if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ProtocolPoolDistrAccount, types.ModuleName, amountToDistribute); err != nil {
return err
}

if !lastBalance.IsZero() { // only reset if the last balance is not zero (so we leave it at zero/nil)
return k.LastBalance.Set(ctx, math.ZeroInt())
if !lastBalance.Amount.IsZero() { // only reset if the last balance is not zero (so we leave it at zero)
return k.LastBalance.Set(ctx, types.DistributionAmount{Amount: sdk.NewCoins()})
}

return nil
}

if err = k.Distributions.Set(ctx, k.HeaderService.HeaderInfo(ctx).Time, amountToDistribute); err != nil {
if err = k.Distributions.Set(ctx, k.HeaderService.HeaderInfo(ctx).Time, types.DistributionAmount{Amount: amountToDistribute}); err != nil {
return fmt.Errorf("error while setting Distributions: %w", err)
}

// Update the last balance
return k.LastBalance.Set(ctx, distributionBalance)
return k.LastBalance.Set(ctx, types.DistributionAmount{Amount: currentBalance})
}

func (k Keeper) IterateAndUpdateFundsDistribution(ctx context.Context) error {
Expand All @@ -229,11 +220,11 @@ func (k Keeper) IterateAndUpdateFundsDistribution(ctx context.Context) error {
}

// next we iterate over the distributions, calculate each recipient's share and the remaining pool funds
toDistribute := map[string]math.Int{}
poolFunds := math.ZeroInt()
fullAmountToDistribute := math.ZeroInt()
toDistribute := map[string]sdk.Coins{}
poolFunds := sdk.NewCoins()
fullAmountToDistribute := sdk.NewCoins()

if err = k.Distributions.Walk(ctx, nil, func(key time.Time, amount math.Int) (stop bool, err error) {
if err = k.Distributions.Walk(ctx, nil, func(key time.Time, amount types.DistributionAmount) (stop bool, err error) {
percentageToDistribute := math.LegacyZeroDec()
for _, f := range funds {
if f.Expiry != nil && f.Expiry.Before(key) {
Expand All @@ -244,20 +235,25 @@ func (k Keeper) IterateAndUpdateFundsDistribution(ctx context.Context) error {

_, ok := toDistribute[f.Recipient]
if !ok {
toDistribute[f.Recipient] = math.ZeroInt()
toDistribute[f.Recipient] = sdk.NewCoins()
}

for _, denom := range amount.Amount.Denoms() {
am := sdk.NewCoin(denom, f.Percentage.MulInt(amount.Amount.AmountOf(denom)).TruncateInt())
toDistribute[f.Recipient] = toDistribute[f.Recipient].Add(am)
fullAmountToDistribute = fullAmountToDistribute.Add(am)
Comment on lines +239 to +242
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Review the use of TruncateInt() in distribution calculations

When calculating each recipient's share, TruncateInt() is used after multiplying by the percentage. This could lead to loss of fractional amounts. Consider whether this aligns with the expected financial logic, or if using RoundInt() would be more appropriate to minimize discrepancies.

}
amountToDistribute := f.Percentage.MulInt(amount).TruncateInt()
toDistribute[f.Recipient] = toDistribute[f.Recipient].Add(amountToDistribute)
fullAmountToDistribute = fullAmountToDistribute.Add(amountToDistribute)
}

// sanity check for max percentage
if percentageToDistribute.GT(math.LegacyOneDec()) {
return true, errors.New("total funds percentage cannot exceed 100")
}

remaining := math.LegacyOneDec().Sub(percentageToDistribute).MulInt(amount).RoundInt()
poolFunds = poolFunds.Add(remaining)
for _, denom := range amount.Amount.Denoms() {
remaining := sdk.NewCoin(denom, math.LegacyOneDec().Sub(percentageToDistribute).MulInt(amount.Amount.AmountOf(denom)).TruncateInt())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar code was used before but is another round down which has a rest that is not distributed.
Better remaining = amount - distributed amount

poolFunds = poolFunds.Add(remaining)
}
Comment on lines +251 to +254
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Review the use of TruncateInt() in remaining funds calculation

Similarly, when calculating the remaining pool funds, TruncateInt() is used. Ensure this approach meets the desired precision and that any loss of fractional amounts is acceptable within the application's context.


return false, nil
}); err != nil {
Expand All @@ -269,26 +265,20 @@ func (k Keeper) IterateAndUpdateFundsDistribution(ctx context.Context) error {
return err
}

if err = k.LastBalance.Set(ctx, math.ZeroInt()); err != nil {
if err = k.LastBalance.Set(ctx, types.DistributionAmount{Amount: sdk.NewCoins()}); err != nil {
return err
}

// send the funds to the stream account to be distributed later, and the remaining to the community pool
bondDenom, err := k.stakingKeeper.BondDenom(ctx)
if err != nil {
return err
}

streamAmt := sdk.NewCoins(sdk.NewCoin(bondDenom, fullAmountToDistribute))
streamAmt := fullAmountToDistribute
if !streamAmt.IsZero() {
if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ProtocolPoolDistrAccount, types.StreamAccount, streamAmt); err != nil {
return err
}
}

if !poolFunds.IsZero() {
poolCoins := sdk.NewCoins(sdk.NewCoin(bondDenom, poolFunds))
if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ProtocolPoolDistrAccount, types.ModuleName, poolCoins); err != nil {
if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ProtocolPoolDistrAccount, types.ModuleName, poolFunds); err != nil {
return err
}
}
Expand All @@ -310,14 +300,14 @@ func (k Keeper) IterateAndUpdateFundsDistribution(ctx context.Context) error {
toClaim, err := k.RecipientFundDistribution.Get(ctx, bzAddr)
if err != nil {
if errors.Is(err, collections.ErrNotFound) {
toClaim = math.ZeroInt()
toClaim = types.DistributionAmount{Amount: sdk.NewCoins()}
} else {
return err
}
}

amount := toClaim.Add(toDistribute[recipient])
if err = k.RecipientFundDistribution.Set(ctx, bzAddr, amount); err != nil {
toClaim.Amount = toClaim.Amount.Add(toDistribute[recipient]...)
if err = k.RecipientFundDistribution.Set(ctx, bzAddr, toClaim); err != nil {
return err
}
}
Expand Down
16 changes: 8 additions & 8 deletions x/protocolpool/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,14 @@ func (s *KeeperTestSuite) TestIterateAndUpdateFundsDistribution() {
err = s.poolKeeper.IterateAndUpdateFundsDistribution(s.ctx)
s.Require().NoError(err)

err = s.poolKeeper.RecipientFundDistribution.Walk(s.ctx, nil, func(key sdk.AccAddress, value math.Int) (stop bool, err error) {
err = s.poolKeeper.RecipientFundDistribution.Walk(s.ctx, nil, func(key sdk.AccAddress, value types.DistributionAmount) (stop bool, err error) {
strAddr, err := s.authKeeper.AddressCodec().BytesToString(key)
s.Require().NoError(err)

if strAddr == "cosmos1qypq2q2l8z4wz2z2l8z4wz2z2l8z4wz2srklj6" {
s.Require().Equal(value, math.NewInt(300000))
s.Require().Equal(value.Amount, sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(300000))))
} else if strAddr == "cosmos1tygms3xhhs3yv487phx3dw4a95jn7t7lpm470r" {
s.Require().Equal(value, math.NewInt(300000))
s.Require().Equal(value.Amount, sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(300000))))
}
return false, nil
})
Expand Down Expand Up @@ -215,16 +215,16 @@ func (suite *KeeperTestSuite) TestSetToDistribute() {
// Verify that LastBalance was set correctly
lastBalance, err := suite.poolKeeper.LastBalance.Get(suite.ctx)
suite.Require().NoError(err)
suite.Require().Equal(math.NewInt(1000000), lastBalance)
suite.Require().Equal(sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1000000))), lastBalance.Amount)

// Verify that a distribution was set
var distribution math.Int
err = suite.poolKeeper.Distributions.Walk(suite.ctx, nil, func(key time.Time, value math.Int) (bool, error) {
var distribution types.DistributionAmount
err = suite.poolKeeper.Distributions.Walk(suite.ctx, nil, func(key time.Time, value types.DistributionAmount) (bool, error) {
distribution = value
return true, nil
})
suite.Require().NoError(err)
suite.Require().Equal(math.NewInt(1000000), distribution)
suite.Require().Equal(sdk.NewCoins(sdk.NewCoin("stake", math.NewInt(1000000))), distribution.Amount)

// Test case when balance is zero
zeroBal := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.ZeroInt()))
Expand All @@ -235,7 +235,7 @@ func (suite *KeeperTestSuite) TestSetToDistribute() {

// Verify that no new distribution was set
count := 0
err = suite.poolKeeper.Distributions.Walk(suite.ctx, nil, func(key time.Time, value math.Int) (bool, error) {
err = suite.poolKeeper.Distributions.Walk(suite.ctx, nil, func(key time.Time, value types.DistributionAmount) (bool, error) {
count++
return false, nil
})
Expand Down
2 changes: 1 addition & 1 deletion x/protocolpool/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (k MsgServer) CreateContinuousFund(ctx context.Context, msg *types.MsgCreat
return nil, err
}

err = k.RecipientFundDistribution.Set(ctx, recipient, math.ZeroInt())
err = k.RecipientFundDistribution.Set(ctx, recipient, types.DistributionAmount{Amount: sdk.NewCoins()})
if err != nil {
return nil, err
}
Expand Down
Loading
Loading