-
Notifications
You must be signed in to change notification settings - Fork 572
/
proposals.go
77 lines (64 loc) · 2.36 KB
/
proposals.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package simulation
import (
"math/rand"
sdk "github.com/cosmos/cosmos-sdk/types"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
gammtypes "github.com/osmosis-labs/osmosis/v17/x/gamm/types"
"github.com/osmosis-labs/osmosis/v17/x/superfluid/keeper"
"github.com/osmosis-labs/osmosis/v17/x/superfluid/types"
)
const (
OpWeightSetSuperfluidAssetsProposal = "op_weight_set_superfluid_assets_proposal"
OpWeightRemoveSuperfluidAssetsProposal = "op_weight_remove_superfluid_assets_proposal"
)
// ProposalContents defines the module weighted proposals' contents.
func ProposalContents(k keeper.Keeper, gk types.GammKeeper) []simtypes.WeightedProposalContent {
return []simtypes.WeightedProposalContent{
simulation.NewWeightedProposalContent(
OpWeightSetSuperfluidAssetsProposal,
DefaultWeightSetSuperfluidAssetsProposal,
SimulateSetSuperfluidAssetsProposal(k, gk),
),
}
}
// SimulateSetSuperfluidAssetsProposal generates random superfluid asset set proposal content.
func SimulateSetSuperfluidAssetsProposal(k keeper.Keeper, gk types.GammKeeper) simtypes.ContentSimulatorFn {
return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content {
pools, err := gk.GetPoolsAndPoke(ctx)
if err != nil {
return nil
}
if len(pools) == 0 {
return nil
}
poolIndex := r.Intn(len(pools))
pool := pools[poolIndex]
return &types.SetSuperfluidAssetsProposal{
Title: "set superfluid assets",
Description: "set superfluid assets description",
Assets: []types.SuperfluidAsset{
{
Denom: gammtypes.GetPoolShareDenom(pool.GetId()),
AssetType: types.SuperfluidAssetTypeLPShare,
},
},
}
}
}
// SimulateRemoveSuperfluidAssetsProposal generates random superfluid asset removal proposal content.
func SimulateRemoveSuperfluidAssetsProposal(k keeper.Keeper, gk types.GammKeeper) simtypes.ContentSimulatorFn {
return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content {
assets := k.GetAllSuperfluidAssets(ctx)
if len(assets) == 0 {
return nil
}
assetIndex := r.Intn(len(assets))
asset := assets[assetIndex]
return &types.RemoveSuperfluidAssetsProposal{
Title: "remove superfluid assets",
Description: "remove superfluid assets description",
SuperfluidAssetDenoms: []string{asset.Denom},
}
}
}