Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devnet Bump #607

Merged
merged 3 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ jobs:
r2-bucket: ${{ secrets.R2_BUCKET }}
source-dir: ${{env.NAME_WITH_VERSION}}
destination-dir: releases
- name: Backup Devnet
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
script: /bin/bash /home/ubuntu/ci-cd-devnet-backup-and-rollback/backup.sh
- name: Creating software upgrade proposal
run: |

Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/devnet-branch-protection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Devnet branch protection"

on:
pull_request:

jobs:
check_branch:
runs-on: ubuntu-latest
steps:
- name: Check branch
if: github.base_ref == 'devnet' && github.head_ref != 'develop'
run: |
echo "ERROR: You can only merge to devnet from develop."
exit 1
14 changes: 14 additions & 0 deletions .github/workflows/main-branch-protection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Main branch protection"

on:
pull_request:

jobs:
check_branch:
runs-on: ubuntu-latest
steps:
- name: Check branch
if: github.base_ref == 'main' && github.head_ref != 'devnet'
run: |
echo "ERROR: You can only merge to main from devnet."
exit 1
24 changes: 13 additions & 11 deletions docs/static/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42247,10 +42247,10 @@ paths:
title: Eden APR, updated at every distribution
dex_apr:
type: string
title: Dex APR, updated at every distribution
title: Dex APR, updated based on 24hr accumulation
gas_apr:
type: string
title: Gas APR, updated at every distribution
title: Gas APR, updated based on 24hr accumulation
external_incentive_apr:
type: string
title: External Incentive APR, updated at every distribution
Expand Down Expand Up @@ -44842,7 +44842,7 @@ paths:
type: string
tags:
- Query
/elys-network/elys/tier/leverage_lp_total/{user}/{realtime}:
/elys-network/elys/tier/leverage_lp_total/{user}:
get:
summary: Queries a list of LeverageLpTotal items.
operationId: ElysTierLeverageLpTotal
Expand All @@ -44851,6 +44851,9 @@ paths:
description: A successful response.
schema:
type: object
properties:
total:
type: string
default:
description: An unexpected error response.
schema:
Expand All @@ -44874,10 +44877,6 @@ paths:
in: path
required: true
type: string
- name: realtime
in: path
required: true
type: boolean
tags:
- Query
/elys-network/elys/tokenomics/airdrop:
Expand Down Expand Up @@ -87438,10 +87437,10 @@ definitions:
title: Eden APR, updated at every distribution
dex_apr:
type: string
title: Dex APR, updated at every distribution
title: Dex APR, updated based on 24hr accumulation
gas_apr:
type: string
title: Gas APR, updated at every distribution
title: Gas APR, updated based on 24hr accumulation
external_incentive_apr:
type: string
title: External Incentive APR, updated at every distribution
Expand Down Expand Up @@ -87583,10 +87582,10 @@ definitions:
title: Eden APR, updated at every distribution
dex_apr:
type: string
title: Dex APR, updated at every distribution
title: Dex APR, updated based on 24hr accumulation
gas_apr:
type: string
title: Gas APR, updated at every distribution
title: Gas APR, updated based on 24hr accumulation
external_incentive_apr:
type: string
title: External Incentive APR, updated at every distribution
Expand Down Expand Up @@ -89209,6 +89208,9 @@ definitions:
type: string
elys.tier.QueryLeverageLpTotalResponse:
type: object
properties:
total:
type: string
elys.tier.QueryParamsResponse:
type: object
properties:
Expand Down
45 changes: 0 additions & 45 deletions proto/elys/masterchef/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,48 +43,3 @@ message SupportedRewardDenom {
(gogoproto.nullable) = false
];
}

message LegacyDexRewardsTracker {
// 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
];
}

// Params defines the parameters for the module.
message LegacyParams {
option (gogoproto.goproto_stringer) = false;
IncentiveInfo lp_incentives = 1;

// gas fees and swap fees portion for lps, `100 - reward_portion_for_lps -
// reward_portion_for_stakers = revenue percent for protocol`.
string reward_portion_for_lps = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

// gas fees and swap fees portion for stakers, `100 - reward_portion_for_lps -
// reward_portion_for_stakers = revenue percent for protocol`.
string reward_portion_for_stakers = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];

// Tracking dex rewards given to LPs
LegacyDexRewardsTracker dex_rewards_lps = 4 [ (gogoproto.nullable) = false ];

// Maximum eden reward apr for lps - [0 - 0.3]
string max_eden_reward_apr_lps = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
repeated SupportedRewardDenom supported_reward_denoms = 6;
string protocol_revenue_address = 7;
}
38 changes: 2 additions & 36 deletions proto/elys/masterchef/pool.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ message PoolInfo {
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// Dex APR, updated at every distribution
// Dex APR, updated based on 24hr accumulation
string dex_apr = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
// Gas APR, updated at every distribution
// Gas APR, updated based on 24hr accumulation
string gas_apr = 6 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
Expand Down Expand Up @@ -79,37 +79,3 @@ message PoolRewardsAccum {
(gogoproto.nullable) = false
];
}

message LegacyPoolInfo {
uint64 pool_id = 1;
string reward_wallet = 2;
string multiplier = 3 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string num_blocks = 4 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
string dex_reward_amount_given = 5 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string eden_reward_amount_given = 6 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
string eden_apr = 7 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string dex_apr = 8 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
string external_incentive_apr = 9 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
repeated string external_reward_denoms = 10;
}
2 changes: 1 addition & 1 deletion x/incentive/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (k Keeper) GetDailyRewardsAmountForPool(ctx sdk.Context, poolId uint64) (sd
dailyGasRewardsTotal := math.LegacyZeroDec()
dailyEdenRewardsTotal := math.LegacyZeroDec()
firstAccum := k.masterchef.FirstPoolRewardsAccum(ctx, poolId)
lastAccum := k.masterchef.FirstPoolRewardsAccum(ctx, poolId)
lastAccum := k.masterchef.LastPoolRewardsAccum(ctx, poolId)
if lastAccum.Timestamp != 0 {
if firstAccum.Timestamp == lastAccum.Timestamp {
dailyDexRewardsTotal = lastAccum.DexReward
Expand Down
18 changes: 7 additions & 11 deletions x/masterchef/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ func (k Keeper) UpdateLPRewards(ctx sdk.Context) error {
}
k.DeletePoolRewardsAccum(ctx, firstAccum)
}

pool.EdenApr = newEdenAllocatedForPool.
MulInt64(totalBlocksPerYear).
Mul(edenDenomPrice).
Quo(tvl)

k.SetPool(ctx, pool)
}

// Update APR for amm pools
Expand Down Expand Up @@ -547,11 +554,6 @@ func (k Keeper) UpdateAmmPoolAPR(ctx sdk.Context, totalBlocksPerYear int64, tota
MulInt64(totalBlocksPerYear).
Mul(usdcDenomPrice).
Quo(tvl)

poolInfo.EdenApr = lastAccum.EdenReward.
MulInt(sdk.NewInt(totalBlocksPerYear)).
Mul(edenDenomPrice).
Quo(tvl)
} else {
duration := lastAccum.Timestamp - firstAccum.Timestamp
secondsInYear := int64(86400 * 360)
Expand All @@ -567,12 +569,6 @@ func (k Keeper) UpdateAmmPoolAPR(ctx sdk.Context, totalBlocksPerYear int64, tota
QuoInt64(int64(duration)).
Mul(usdcDenomPrice).
Quo(tvl)

poolInfo.EdenApr = lastAccum.EdenReward.Sub(firstAccum.EdenReward).
MulInt64(secondsInYear).
QuoInt64(int64(duration)).
Mul(edenDenomPrice).
Quo(tvl)
}
k.SetPool(ctx, poolInfo)
return false
Expand Down
13 changes: 0 additions & 13 deletions x/masterchef/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,3 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
b := k.cdc.MustMarshal(&params)
store.Set([]byte(types.ParamsKey), b)
}

// GetParams get all parameters as types.Params
func (k Keeper) GetLegacyParams(ctx sdk.Context) (params types.LegacyParams) {
store := ctx.KVStore(k.storeKey)

b := store.Get([]byte(types.ParamsKey))
if b == nil {
return
}

k.cdc.MustUnmarshal(b, &params)
return
}
15 changes: 0 additions & 15 deletions x/masterchef/keeper/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,3 @@ func (k Keeper) UpdatePoolMultipliers(ctx sdk.Context, poolMultipliers []types.P

return true
}

func (k Keeper) GetAllLegacyPools(ctx sdk.Context) (list []types.LegacyPoolInfo) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PoolInfoKeyPrefix))
iterator := sdk.KVStorePrefixIterator(store, []byte{})

defer iterator.Close()

for ; iterator.Valid(); iterator.Next() {
var val types.LegacyPoolInfo
k.cdc.MustUnmarshal(iterator.Value(), &val)
list = append(list, val)
}

return
}
28 changes: 0 additions & 28 deletions x/masterchef/migrations/v2_migration.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,9 @@
package migrations

import (
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/elys-network/elys/x/masterchef/types"
)

func (m Migrator) V2Migration(ctx sdk.Context) error {
// migrate params
legacy := m.keeper.GetLegacyParams(ctx)
params := types.NewParams(
legacy.LpIncentives,
legacy.RewardPortionForLps,
legacy.RewardPortionForStakers,
legacy.MaxEdenRewardAprLps,
legacy.ProtocolRevenueAddress,
)
m.keeper.SetParams(ctx, params)

// migrate pools
legacyPools := m.keeper.GetAllLegacyPools(ctx)
for _, legacyPool := range legacyPools {
m.keeper.SetPool(ctx, types.PoolInfo{
PoolId: legacyPool.PoolId,
RewardWallet: legacyPool.RewardWallet,
Multiplier: legacyPool.Multiplier,
EdenApr: legacyPool.EdenApr,
DexApr: legacyPool.DexApr,
GasApr: math.LegacyZeroDec(),
ExternalIncentiveApr: legacyPool.ExternalIncentiveApr,
ExternalRewardDenoms: legacyPool.ExternalRewardDenoms,
})
}

return nil
}
6 changes: 0 additions & 6 deletions x/masterchef/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,3 @@ func validateDexRewardsLps(i interface{}) error {

return nil
}

// String implements the Stringer interface.
func (p LegacyParams) String() string {
out, _ := yaml.Marshal(p)
return string(out)
}
Loading
Loading