-
Notifications
You must be signed in to change notification settings - Fork 581
/
handler.go
57 lines (48 loc) · 2.44 KB
/
handler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package gamm
import (
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/osmosis-labs/osmosis/v21/x/gamm/keeper"
"github.com/osmosis-labs/osmosis/v21/x/gamm/types"
)
// NewGammProposalHandler is a handler for governance proposals for the GAMM module.
func NewGammProposalHandler(k keeper.Keeper) govtypesv1.Handler {
return func(ctx sdk.Context, content govtypesv1.Content) error {
switch c := content.(type) {
case *types.UpdateMigrationRecordsProposal:
return handleUpdateMigrationRecordsProposal(ctx, k, c)
case *types.ReplaceMigrationRecordsProposal:
return handleReplaceMigrationRecordsProposal(ctx, k, c)
case *types.CreateConcentratedLiquidityPoolsAndLinktoCFMMProposal:
return handleCreatingCLPoolAndLinkToCFMMProposal(ctx, k, c)
case *types.SetScalingFactorControllerProposal:
return handleSetScalingFactorControllerProposal(ctx, k, c)
default:
return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized migration record proposal content type: %T", c)
}
}
}
// handleReplaceMigrationRecordsProposal is a handler for replacing migration records governance proposals
func handleReplaceMigrationRecordsProposal(ctx sdk.Context, k keeper.Keeper, p *types.ReplaceMigrationRecordsProposal) error {
return k.HandleReplaceMigrationRecordsProposal(ctx, p)
}
// handleUpdateMigrationRecordsProposal is a handler for updating migration records governance proposals
func handleUpdateMigrationRecordsProposal(ctx sdk.Context, k keeper.Keeper, p *types.UpdateMigrationRecordsProposal) error {
return k.HandleUpdateMigrationRecordsProposal(ctx, p)
}
func handleCreatingCLPoolAndLinkToCFMMProposal(ctx sdk.Context, k keeper.Keeper, p *types.CreateConcentratedLiquidityPoolsAndLinktoCFMMProposal) error {
for _, record := range p.PoolRecordsWithCfmmLink {
_, err := k.CreateCanonicalConcentratedLiquidityPoolAndMigrationLink(ctx, record.BalancerPoolId, record.Denom0, record.SpreadFactor, record.TickSpacing)
if err != nil {
return err
}
}
return nil
}
// handleSetScalingFactorControllerProposal is a handler for gov proposals to set a stableswap pool's
// scaling factor controller address
func handleSetScalingFactorControllerProposal(ctx sdk.Context, k keeper.Keeper, p *types.SetScalingFactorControllerProposal) error {
return k.HandleSetScalingFactorControllerProposal(ctx, p)
}