-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add basic upgrade handler for commitment, incentive, masterchef, dist…
…ribution
- Loading branch information
Showing
25 changed files
with
1,518 additions
and
241 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
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,29 @@ | ||
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"; | ||
|
||
// DexRewardsTracker is used for tracking rewards for stakers and LPs, all | ||
// amount here is in USDC | ||
message DexRewardsTracker { | ||
// Number of blocks since start of epoch (distribution epoch) | ||
string num_blocks = 1 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
(gogoproto.nullable) = false | ||
]; | ||
// Accumulated amount at distribution epoch - recalculated at every | ||
// distribution epoch | ||
string amount = 2 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", | ||
(gogoproto.nullable) = false | ||
]; | ||
// Accumulated rewards tracked by other (when it's for staking, from lp, if | ||
// it's for lp, from staking) | ||
string amount_collected_by_other_tracker = 3 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", | ||
(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
syntax = "proto3"; | ||
package elys.incentive; | ||
import "gogoproto/gogo.proto"; | ||
import "google/protobuf/timestamp.proto"; | ||
|
||
option go_package = "github.com/elys-network/elys/x/incentive/types"; | ||
|
||
// Incentive Info | ||
message IncentiveInfo { | ||
// reward amount in eden for 1 year | ||
string eden_amount_per_year = 1 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
(gogoproto.nullable) = false | ||
]; | ||
// starting block height of the distribution | ||
string distribution_start_block = 2 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
(gogoproto.nullable) = false | ||
]; | ||
// distribution duration - block number per year | ||
string total_blocks_per_year = 3 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
(gogoproto.nullable) = false | ||
]; | ||
// unused | ||
string epoch_num_blocks = 4 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
(gogoproto.nullable) = false | ||
]; | ||
// unused | ||
string max_eden_per_allocation = 5 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
(gogoproto.nullable) = false | ||
]; | ||
// unused | ||
string distribution_epoch_in_blocks = 6 [ | ||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", | ||
(gogoproto.nullable) = false | ||
]; | ||
// current epoch in block number | ||
string current_epoch_in_blocks = 7 [ | ||
(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
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 |
---|---|---|
@@ -1,60 +1,10 @@ | ||
package migrations | ||
|
||
import ( | ||
"cosmossdk.io/math" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/elys-network/elys/x/commitment/types" | ||
) | ||
|
||
func (m Migrator) V3Migration(ctx sdk.Context) error { | ||
legacyParams := m.keeper.GetLegacyParams(ctx) | ||
|
||
totalCommitted := sdk.Coins{} | ||
legacyCommitments := m.keeper.GetAllLegacyCommitments(ctx) | ||
for _, legacy := range legacyCommitments { | ||
|
||
vestingTokens := []*types.VestingTokens{} | ||
for _, vt := range legacy.VestingTokens { | ||
blockMultiplier := int64(17280) // "day" | ||
if vt.EpochIdentifier == "tenseconds" { | ||
blockMultiplier = int64(2) | ||
} else { | ||
blockMultiplier = int64(720) // "hour" | ||
} | ||
vestingTokens = append(vestingTokens, &types.VestingTokens{ | ||
Denom: vt.Denom, | ||
TotalAmount: vt.UnvestedAmount, | ||
ClaimedAmount: math.ZeroInt(), | ||
NumBlocks: vt.NumEpochs * blockMultiplier, | ||
StartBlock: ctx.BlockHeight(), | ||
VestStartedTimestamp: vt.VestStartedTimestamp, | ||
}) | ||
} | ||
m.keeper.SetCommitments(ctx, types.Commitments{ | ||
Creator: legacy.Creator, | ||
CommittedTokens: legacy.CommittedTokens, | ||
Claimed: legacy.Claimed, | ||
VestingTokens: vestingTokens, | ||
}) | ||
for _, token := range legacy.CommittedTokens { | ||
totalCommitted = totalCommitted.Add(sdk.NewCoin(token.Denom, token.Amount)) | ||
} | ||
} | ||
|
||
vestingInfos := []*types.VestingInfo{} | ||
for _, legacy := range legacyParams.VestingInfos { | ||
vestingInfos = append(vestingInfos, &types.VestingInfo{ | ||
BaseDenom: legacy.BaseDenom, | ||
VestingDenom: legacy.VestingDenom, | ||
NumBlocks: legacy.NumEpochs * 17280, | ||
VestNowFactor: legacy.VestNowFactor, | ||
NumMaxVestings: legacy.NumMaxVestings, | ||
}) | ||
} | ||
|
||
m.keeper.SetParams(ctx, types.Params{ | ||
VestingInfos: vestingInfos, | ||
TotalCommitted: totalCommitted, | ||
}) | ||
return nil | ||
} |
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
Oops, something went wrong.