Skip to content

Commit 2af2776

Browse files
authored
feat: Gaia liquid module (#423)
Add the 3rd party **Liquid Staking** module from Gaia project.
1 parent e27ff89 commit 2af2776

4 files changed

Lines changed: 135 additions & 90 deletions

File tree

app/app.go

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/cosmos/cosmos-sdk/x/group"
2929
groupmodule "github.com/cosmos/cosmos-sdk/x/group/module"
3030
"github.com/cosmos/cosmos-sdk/x/protocolpool"
31+
"github.com/cosmos/gaia/v25/x/liquid"
3132
"github.com/cosmos/gogoproto/proto"
3233
icacontroller "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/controller"
3334
ibccallbacks "github.com/cosmos/ibc-go/v10/modules/apps/callbacks"
@@ -121,6 +122,8 @@ import (
121122
"github.com/cosmos/cosmos-sdk/x/staking"
122123
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
123124
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
125+
liquidkeeper "github.com/cosmos/gaia/v25/x/liquid/keeper"
126+
liquidtypes "github.com/cosmos/gaia/v25/x/liquid/types"
124127
ica "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts"
125128
icacontrollerkeeper "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/controller/keeper"
126129
icacontrollertypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/controller/types"
@@ -198,12 +201,13 @@ var (
198201

199202
// module account permissions
200203
maccPerms = map[string][]string{
201-
authtypes.FeeCollectorName: nil,
202-
distrtypes.ModuleName: nil,
203-
minttypes.ModuleName: {authtypes.Minter},
204-
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
205-
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
206-
govtypes.ModuleName: {authtypes.Burner},
204+
authtypes.FeeCollectorName: nil,
205+
distrtypes.ModuleName: nil,
206+
minttypes.ModuleName: {authtypes.Minter},
207+
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
208+
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
209+
govtypes.ModuleName: {authtypes.Burner},
210+
// liquiditytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
207211
nft.ModuleName: nil,
208212
protocolpooltypes.ModuleName: nil,
209213
protocolpooltypes.ProtocolPoolEscrowAccount: nil,
@@ -253,6 +257,7 @@ type App struct {
253257
SlashingKeeper slashingkeeper.Keeper
254258
MintKeeper mintkeeper.Keeper
255259
DistrKeeper distrkeeper.Keeper
260+
LiquidKeeper *liquidkeeper.Keeper
256261
GovKeeper govkeeper.Keeper
257262
UpgradeKeeper *upgradekeeper.Keeper
258263
EvidenceKeeper evidencekeeper.Keeper
@@ -344,6 +349,7 @@ func New(
344349
icacontrollertypes.StoreKey,
345350
paramstypes.StoreKey,
346351
CapabilityStoreKey,
352+
liquidtypes.StoreKey,
347353
)
348354
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
349355
memkeys := storetypes.NewMemoryStoreKeys(CapabilityMemStoreKey)
@@ -475,6 +481,16 @@ func New(
475481
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
476482
)
477483

484+
app.LiquidKeeper = liquidkeeper.NewKeeper(
485+
appCodec,
486+
runtime.NewKVStoreService(keys[liquidtypes.StoreKey]),
487+
app.AccountKeeper,
488+
app.BankKeeper,
489+
app.StakingKeeper,
490+
app.DistrKeeper,
491+
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
492+
)
493+
478494
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(
479495
appCodec,
480496
runtime.NewKVStoreService(keys[feegrant.StoreKey]),
@@ -487,6 +503,7 @@ func New(
487503
stakingtypes.NewMultiStakingHooks(
488504
app.DistrKeeper.Hooks(),
489505
app.SlashingKeeper.Hooks(),
506+
app.LiquidKeeper.Hooks(),
490507
),
491508
)
492509

@@ -746,6 +763,7 @@ func New(
746763
transfer.NewAppModule(app.TransferKeeper),
747764
ica.NewAppModule(&app.ICAControllerKeeper, &app.ICAHostKeeper),
748765
ibctm.NewAppModule(tmLightClientModule),
766+
liquid.NewAppModule(appCodec, app.LiquidKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
749767
)
750768

751769
// BasicModuleManager defines the module BasicManager is in charge of setting up basic,
@@ -786,6 +804,7 @@ func New(
786804
ibctransfertypes.ModuleName,
787805
ibcexported.ModuleName,
788806
icatypes.ModuleName,
807+
liquidtypes.ModuleName,
789808
wasmtypes.ModuleName,
790809
)
791810

@@ -838,6 +857,7 @@ func New(
838857
icatypes.ModuleName,
839858
// wasm after ibc transfer
840859
wasmtypes.ModuleName,
860+
liquidtypes.ModuleName,
841861
}
842862

843863
exportModuleOrder := []string{
@@ -866,6 +886,7 @@ func New(
866886
icatypes.ModuleName,
867887
// wasm after ibc transfer
868888
wasmtypes.ModuleName,
889+
liquidtypes.ModuleName,
869890
}
870891

871892
app.mm.SetOrderInitGenesis(genesisModuleOrder...)

app/upgrades.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"strings"
99
"time"
1010

11+
"cosmossdk.io/math"
1112
storetypes "cosmossdk.io/store/types"
1213
circuittypes "cosmossdk.io/x/circuit/types"
1314
"cosmossdk.io/x/nft"
@@ -24,6 +25,8 @@ import (
2425
//minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
2526
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
2627
protocolpooltypes "github.com/cosmos/cosmos-sdk/x/protocolpool/types"
28+
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
29+
liquidtypes "github.com/cosmos/gaia/v25/x/liquid/types"
2730
icacontrollertypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/controller/types"
2831
icatypes "github.com/cosmos/ibc-go/v10/modules/apps/27-interchain-accounts/types"
2932
ibctransfertypes "github.com/cosmos/ibc-go/v10/modules/apps/transfer/types"
@@ -45,6 +48,7 @@ var v053StoreUpgrades = storetypes.StoreUpgrades{
4548
group.StoreKey,
4649
icacontrollertypes.StoreKey,
4750
nft.StoreKey,
51+
liquidtypes.StoreKey,
4852
},
4953
Renamed: []storetypes.StoreRename{
5054
// {OldKey: "oldkey", NewKey: "newkey"},
@@ -117,6 +121,22 @@ func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {
117121
return nil, err
118122
}
119123

124+
// Bootstrap liquid staking
125+
err = app.StakingKeeper.IterateValidators(ctx, func(_ int64, v stakingtypes.ValidatorI) (stop bool) {
126+
lv := liquidtypes.LiquidValidator{
127+
OperatorAddress: v.GetOperator(),
128+
LiquidShares: math.LegacyZeroDec(),
129+
}
130+
err := app.LiquidKeeper.SetLiquidValidator(ctx, lv)
131+
if err != nil {
132+
return false
133+
}
134+
return false
135+
})
136+
if err != nil {
137+
return nil, err
138+
}
139+
120140
// If you must pin any module "from" versions, adjust fromVM here.
121141
return app.mm.RunMigrations(ctx, cfg, fromVM)
122142
},

go.mod

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ require (
88
github.com/CosmWasm/wasmd v0.61.2
99
github.com/CosmWasm/wasmvm/v3 v3.0.0 // indirect
1010
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
11+
github.com/cosmos/gaia/v25 v25.1.1
1112
github.com/cosmos/gogogateway v1.2.0 // indirect
1213
github.com/cosmos/gogoproto v1.7.0
13-
github.com/cosmos/iavl v1.2.4 // indirect
14+
github.com/cosmos/iavl v1.2.6 // indirect
1415
github.com/cosmos/ics23/go v0.11.0 // indirect
1516
github.com/dvsekhvalnov/jose2go v1.7.0 // indirect
1617
github.com/golang/protobuf v1.5.4 // indirect
@@ -37,16 +38,16 @@ require (
3738

3839
require (
3940
cosmossdk.io/api v0.9.2
40-
cosmossdk.io/client/v2 v2.0.0-beta.3
41+
cosmossdk.io/client/v2 v2.0.0-beta.9
4142
cosmossdk.io/core v0.11.3
4243
cosmossdk.io/errors v1.0.2
4344
cosmossdk.io/log v1.6.0
4445
cosmossdk.io/math v1.5.3
4546
cosmossdk.io/store v1.1.2
4647
cosmossdk.io/tools/confix v0.1.2
4748
cosmossdk.io/x/circuit v0.1.1
48-
cosmossdk.io/x/evidence v0.1.1
49-
cosmossdk.io/x/feegrant v0.1.1
49+
cosmossdk.io/x/evidence v0.2.0
50+
cosmossdk.io/x/feegrant v0.2.0
5051
cosmossdk.io/x/nft v0.1.1
5152
cosmossdk.io/x/tx v0.14.0
5253
cosmossdk.io/x/upgrade v0.2.0
@@ -59,7 +60,7 @@ require (
5960
require (
6061
cel.dev/expr v0.20.0 // indirect
6162
cloud.google.com/go v0.116.0 // indirect
62-
cloud.google.com/go/auth v0.14.1 // indirect
63+
cloud.google.com/go/auth v0.15.0 // indirect
6364
cloud.google.com/go/auth/oauth2adapt v0.2.7 // indirect
6465
cloud.google.com/go/compute/metadata v0.6.0 // indirect
6566
cloud.google.com/go/iam v1.2.2 // indirect
@@ -91,29 +92,29 @@ require (
9192
github.com/cncf/xds/go v0.0.0-20250121191232-2f005788dc42 // indirect
9293
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
9394
github.com/cockroachdb/errors v1.12.0 // indirect
94-
github.com/cockroachdb/fifo v0.0.0-20240616162244-4768e80dfb9a // indirect
95+
github.com/cockroachdb/fifo v0.0.0-20240816210425-c5d0cb0b6fc0 // indirect
9596
github.com/cockroachdb/logtags v0.0.0-20241215232642-bb51bb14a506 // indirect
9697
github.com/cockroachdb/pebble v1.1.5 // indirect
9798
github.com/cockroachdb/redact v1.1.6 // indirect
98-
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
99-
github.com/cometbft/cometbft-db v0.14.1 // indirect
99+
github.com/cockroachdb/tokenbucket v0.0.0-20250429170803-42689b6311bb // indirect
100+
github.com/cometbft/cometbft-db v1.0.4 // indirect
100101
github.com/cosmos/go-bip39 v1.0.0 // indirect
101102
github.com/cosmos/ledger-cosmos-go v0.14.0 // indirect
102-
github.com/creachadair/atomicfile v0.3.1 // indirect
103-
github.com/creachadair/tomledit v0.0.24 // indirect
103+
github.com/creachadair/atomicfile v0.3.3 // indirect
104+
github.com/creachadair/tomledit v0.0.26 // indirect
104105
github.com/danieljoos/wincred v1.2.1 // indirect
105106
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
106107
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect
107108
github.com/desertbit/timer v1.0.1 // indirect
108-
github.com/dgraph-io/badger/v4 v4.2.0 // indirect
109-
github.com/dgraph-io/ristretto v0.1.1 // indirect
109+
github.com/dgraph-io/badger/v4 v4.5.1 // indirect
110+
github.com/dgraph-io/ristretto/v2 v2.1.0 // indirect
110111
github.com/distribution/reference v0.5.0 // indirect
111112
github.com/dustin/go-humanize v1.0.1 // indirect
112-
github.com/emicklei/dot v1.6.2 // indirect
113+
github.com/emicklei/dot v1.8.0 // indirect
113114
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
114115
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
115116
github.com/ethereum/go-ethereum v1.15.11 // indirect
116-
github.com/fatih/color v1.17.0 // indirect
117+
github.com/fatih/color v1.18.0 // indirect
117118
github.com/felixge/httpsnoop v1.0.4 // indirect
118119
github.com/fsnotify/fsnotify v1.9.0 // indirect
119120
github.com/getsentry/sentry-go v0.33.0 // indirect
@@ -127,16 +128,15 @@ require (
127128
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
128129
github.com/gogo/googleapis v1.4.1 // indirect
129130
github.com/gogo/protobuf v1.3.2 // indirect
130-
github.com/golang/glog v1.2.4 // indirect
131-
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
132-
github.com/golang/snappy v0.0.5-0.20231225225746-43d5d4cd4e0e // indirect
131+
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
132+
github.com/golang/snappy v1.0.0 // indirect
133133
github.com/google/btree v1.1.3 // indirect
134-
github.com/google/flatbuffers v24.3.25+incompatible // indirect
134+
github.com/google/flatbuffers v25.1.24+incompatible // indirect
135135
github.com/google/go-cmp v0.7.0 // indirect
136136
github.com/google/orderedcode v0.0.1 // indirect
137137
github.com/google/s2a-go v0.1.9 // indirect
138138
github.com/google/uuid v1.6.0 // indirect
139-
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
139+
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
140140
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
141141
github.com/gorilla/handlers v1.5.2 // indirect
142142
github.com/gorilla/websocket v1.5.3 // indirect
@@ -149,7 +149,7 @@ require (
149149
github.com/hashicorp/go-metrics v0.5.4 // indirect
150150
github.com/hashicorp/go-plugin v1.6.3 // indirect
151151
github.com/hashicorp/go-safetemp v1.0.0 // indirect
152-
github.com/hashicorp/go-version v1.6.0 // indirect
152+
github.com/hashicorp/go-version v1.7.0 // indirect
153153
github.com/hashicorp/golang-lru v1.0.2 // indirect
154154
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
155155
github.com/hashicorp/yamux v0.1.2 // indirect
@@ -166,7 +166,7 @@ require (
166166
github.com/kr/pretty v0.3.1 // indirect
167167
github.com/kr/text v0.2.0 // indirect
168168
github.com/lib/pq v1.10.9 // indirect
169-
github.com/linxGnu/grocksdb v1.9.2 // indirect
169+
github.com/linxGnu/grocksdb v1.10.1 // indirect
170170
github.com/manifoldco/promptui v0.9.0 // indirect
171171
github.com/mattn/go-colorable v0.1.14 // indirect
172172
github.com/mattn/go-isatty v0.0.20 // indirect
@@ -205,11 +205,11 @@ require (
205205
github.com/zeebo/errs v1.4.0 // indirect
206206
github.com/zondax/hid v0.9.2 // indirect
207207
github.com/zondax/ledger-go v0.14.3 // indirect
208-
go.etcd.io/bbolt v1.4.0-alpha.1 // indirect
208+
go.etcd.io/bbolt v1.4.0 // indirect
209209
go.opencensus.io v0.24.0 // indirect
210210
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
211211
go.opentelemetry.io/contrib/detectors/gcp v1.34.0 // indirect
212-
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.58.0 // indirect
212+
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0 // indirect
213213
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect
214214
go.opentelemetry.io/otel v1.34.0 // indirect
215215
go.opentelemetry.io/otel/metric v1.34.0 // indirect
@@ -219,17 +219,17 @@ require (
219219
go.uber.org/mock v0.5.2 // indirect
220220
go.uber.org/multierr v1.11.0 // indirect
221221
go.yaml.in/yaml/v2 v2.4.2 // indirect
222-
golang.org/x/arch v0.15.0 // indirect
222+
golang.org/x/arch v0.17.0 // indirect
223223
golang.org/x/crypto v0.38.0 // indirect
224-
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
224+
golang.org/x/exp v0.0.0-20250506013437-ce4c2cf36ca6 // indirect
225225
golang.org/x/net v0.40.0 // indirect
226226
golang.org/x/oauth2 v0.30.0 // indirect
227227
golang.org/x/sync v0.14.0 // indirect
228228
golang.org/x/sys v0.33.0 // indirect
229229
golang.org/x/term v0.32.0 // indirect
230230
golang.org/x/text v0.25.0 // indirect
231231
golang.org/x/time v0.10.0 // indirect
232-
google.golang.org/api v0.222.0 // indirect
232+
google.golang.org/api v0.223.0 // indirect
233233
google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a // indirect
234234
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect
235235
google.golang.org/protobuf v1.36.6 // indirect

0 commit comments

Comments
 (0)