-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: manage eden boost burning from elys unstake and eden uncommitted
- Loading branch information
1 parent
b337ad1
commit c06f61e
Showing
15 changed files
with
686 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
syntax = "proto3"; | ||
package elys.incentive; | ||
|
||
option go_package = "github.com/elys-network/elys/x/incentive/types"; | ||
option (gogoproto.equal_all) = true; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
// Elys staked | ||
message ElysStaked { | ||
string address = 1; | ||
string amount = 2 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright 2022 Evmos Foundation | ||
// This file is part of the Evmos Network packages. | ||
// | ||
// Evmos is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Lesser General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// The Evmos packages are distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Lesser General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Lesser General Public License | ||
// along with the Evmos packages. If not, see https://github.com/evmos/evmos/blob/main/LICENSE | ||
|
||
package keeper | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/cosmos/cosmos-sdk/telemetry" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
ctypes "github.com/elys-network/elys/x/commitment/types" | ||
"github.com/elys-network/elys/x/incentive/types" | ||
) | ||
|
||
// EndBlocker of incentive module | ||
func (k Keeper) EndBlocker(ctx sdk.Context) { | ||
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker) | ||
// Track the amount of Elys staked | ||
k.cmk.IterateCommitments( | ||
ctx, func(commitments ctypes.Commitments) bool { | ||
// Commitment owner | ||
creator := commitments.Creator | ||
_, err := sdk.AccAddressFromBech32(creator) | ||
if err != nil { | ||
// This could be validator address | ||
return false | ||
} | ||
|
||
// Calculate delegated amount per delegator | ||
delegatedAmt := k.CalculateDelegatedAmount(ctx, creator) | ||
|
||
elysStaked := types.ElysStaked{ | ||
Address: creator, | ||
Amount: delegatedAmt, | ||
} | ||
|
||
// Set Elys staked amount | ||
k.SetElysStaked(ctx, elysStaked) | ||
|
||
return false | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package keeper | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/store/prefix" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/elys-network/elys/x/incentive/types" | ||
) | ||
|
||
// SetSuperAdmin set a specific superAdmin in the store from its index | ||
func (k Keeper) SetElysStaked(ctx sdk.Context, elysStaked types.ElysStaked) { | ||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ElysStakedKeyPrefix)) | ||
b := k.cdc.MustMarshal(&elysStaked) | ||
store.Set(types.ElysStakedKey( | ||
elysStaked.Address, | ||
), b) | ||
} | ||
|
||
// GetSuperAdmin returns a superAdmin from its index | ||
func (k Keeper) GetElysStaked( | ||
ctx sdk.Context, | ||
address string, | ||
|
||
) (val types.ElysStaked, found bool) { | ||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ElysStakedKeyPrefix)) | ||
|
||
b := store.Get(types.ElysStakedKey( | ||
address, | ||
)) | ||
if b == nil { | ||
return val, false | ||
} | ||
|
||
k.cdc.MustUnmarshal(b, &val) | ||
return val, true | ||
} | ||
|
||
// RemoveSuperAdmin removes a superAdmin from the store | ||
func (k Keeper) RemoveElysStaked( | ||
ctx sdk.Context, | ||
address string, | ||
|
||
) { | ||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ElysStakedKeyPrefix)) | ||
store.Delete(types.ElysStakedKey( | ||
address, | ||
)) | ||
} | ||
|
||
// GetAllSuperAdmin returns all superAdmin | ||
func (k Keeper) GetAllElysStaked(ctx sdk.Context) (list []types.ElysStaked) { | ||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ElysStakedKeyPrefix)) | ||
iterator := sdk.KVStorePrefixIterator(store, []byte{}) | ||
|
||
defer iterator.Close() | ||
|
||
for ; iterator.Valid(); iterator.Next() { | ||
var val types.ElysStaked | ||
k.cdc.MustUnmarshal(iterator.Value(), &val) | ||
list = append(list, val) | ||
} | ||
|
||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.