|
| 1 | +package v8 |
| 2 | + |
| 3 | +import ( |
| 4 | + sdk "github.com/cosmos/cosmos-sdk/types" |
| 5 | + "github.com/osmosis-labs/osmosis/v7/osmoutils" |
| 6 | + poolincentiveskeeper "github.com/osmosis-labs/osmosis/v7/x/pool-incentives/keeper" |
| 7 | + poolincentivestypes "github.com/osmosis-labs/osmosis/v7/x/pool-incentives/types" |
| 8 | +) |
| 9 | + |
| 10 | +// This file implements logic for accelerated incentive proposals. |
| 11 | + |
| 12 | +// This function is common to all the props, |
| 13 | +// executing the equivalent result of the "UpdatePoolIncentives" proposals, inside of this upgrade logic. |
| 14 | +func applyPoolIncentivesUpdate(ctx sdk.Context, poolincentiveskeeper *poolincentiveskeeper.Keeper, records []poolincentivestypes.DistrRecord) { |
| 15 | + // Notice that the pool incentives update proposal code, just calls UpdateDistrRecords: |
| 16 | + // https://github.com/osmosis-labs/osmosis/blob/v7.3.0/x/pool-incentives/keeper/gov.go#L13-L15 |
| 17 | + // And that p.Records is the field output by the gov queries. |
| 18 | + |
| 19 | + // If error, undo state update, log, and proceed. We don't want to stop the entire upgrade due to |
| 20 | + // an unexpected error here. |
| 21 | + _ = osmoutils.ApplyFuncIfNoError(ctx, func(wrappedCtx sdk.Context) error { |
| 22 | + err := poolincentiveskeeper.UpdateDistrRecords(wrappedCtx, records...) |
| 23 | + if err != nil { |
| 24 | + ctx.Logger().Error("Something has happened, prop update did not apply. Continuing to proceed with other components of the upgrade.") |
| 25 | + } |
| 26 | + return err |
| 27 | + }) |
| 28 | +} |
| 29 | + |
| 30 | +// Apply prop 222 change |
| 31 | +func ApplyProp222Change(ctx sdk.Context, poolincentiveskeeper *poolincentiveskeeper.Keeper) { |
| 32 | + // Pool records obtained right off proposal |
| 33 | + // osmosisd q gov proposal 222 |
| 34 | + // records: |
| 35 | + // - gauge_id: "1718" |
| 36 | + // weight: "9138119" |
| 37 | + // - gauge_id: "1719" |
| 38 | + // weight: "5482871" |
| 39 | + // - gauge_id: "1720" |
| 40 | + // weight: "3655247" |
| 41 | + // - gauge_id: "2965" |
| 42 | + // weight: "9138119" |
| 43 | + // - gauge_id: "2966" |
| 44 | + // weight: "5482872" |
| 45 | + // - gauge_id: "2967" |
| 46 | + // weight: "3655248" |
| 47 | + // _PLEASE_ double check these numbers, and double the check the proposals choice itself |
| 48 | + records := []poolincentivestypes.DistrRecord{ |
| 49 | + {GaugeId: 1718, Weight: sdk.NewInt(9138119)}, |
| 50 | + {GaugeId: 1719, Weight: sdk.NewInt(5482871)}, |
| 51 | + {GaugeId: 1720, Weight: sdk.NewInt(3655247)}, |
| 52 | + {GaugeId: 2965, Weight: sdk.NewInt(9138119)}, |
| 53 | + {GaugeId: 2966, Weight: sdk.NewInt(5482872)}, |
| 54 | + {GaugeId: 2967, Weight: sdk.NewInt(3655248)}, |
| 55 | + } |
| 56 | + |
| 57 | + ctx.Logger().Info("Applying proposal 222 update") |
| 58 | + applyPoolIncentivesUpdate(ctx, poolincentiveskeeper, records) |
| 59 | +} |
| 60 | + |
| 61 | +// Apply prop 223 change |
| 62 | +func ApplyProp223Change(ctx sdk.Context, poolincentiveskeeper *poolincentiveskeeper.Keeper) { |
| 63 | + // Pool records obtained right off proposal |
| 64 | + // osmosisd q gov proposal 223 |
| 65 | + // records: |
| 66 | + // - gauge_id: "1721" |
| 67 | + // weight: "2831977" |
| 68 | + // - gauge_id: "1722" |
| 69 | + // weight: "1699186" |
| 70 | + // - gauge_id: "1723" |
| 71 | + // weight: "1132791" |
| 72 | + // - gauge_id: "3383" |
| 73 | + // weight: "2831978" |
| 74 | + // - gauge_id: "3384" |
| 75 | + // weight: "1699187" |
| 76 | + // - gauge_id: "3385" |
| 77 | + // weight: "1132791" |
| 78 | + |
| 79 | + // _PLEASE_ double check these numbers, and double the check the proposals choice itself |
| 80 | + records := []poolincentivestypes.DistrRecord{ |
| 81 | + {GaugeId: 1721, Weight: sdk.NewInt(2831977)}, |
| 82 | + {GaugeId: 1722, Weight: sdk.NewInt(1699186)}, |
| 83 | + {GaugeId: 1723, Weight: sdk.NewInt(1132791)}, |
| 84 | + {GaugeId: 3383, Weight: sdk.NewInt(2831978)}, |
| 85 | + {GaugeId: 3384, Weight: sdk.NewInt(1699187)}, |
| 86 | + {GaugeId: 3385, Weight: sdk.NewInt(1132791)}, |
| 87 | + } |
| 88 | + |
| 89 | + ctx.Logger().Info("Applying proposal 223 update") |
| 90 | + applyPoolIncentivesUpdate(ctx, poolincentiveskeeper, records) |
| 91 | +} |
| 92 | + |
| 93 | +// Apply prop 224 change |
| 94 | +func ApplyProp224Change(ctx sdk.Context, poolincentiveskeeper *poolincentiveskeeper.Keeper) { |
| 95 | + // Pool records obtained right off proposal |
| 96 | + // osmosisd q gov proposal 224 |
| 97 | + // records: |
| 98 | + // - gauge_id: "1724" |
| 99 | + // weight: "1881159" |
| 100 | + // - gauge_id: "1725" |
| 101 | + // weight: "1128695" |
| 102 | + // - gauge_id: "1726" |
| 103 | + // weight: "752463" |
| 104 | + // - gauge_id: "2949" |
| 105 | + // weight: "1881160" |
| 106 | + // - gauge_id: "2950" |
| 107 | + // weight: "1128696" |
| 108 | + // - gauge_id: "2951" |
| 109 | + // weight: "752464" |
| 110 | + // _PLEASE_ double check these numbers, and double the check the proposals choice itself |
| 111 | + records := []poolincentivestypes.DistrRecord{ |
| 112 | + {GaugeId: 1724, Weight: sdk.NewInt(1881159)}, |
| 113 | + {GaugeId: 1725, Weight: sdk.NewInt(1128695)}, |
| 114 | + {GaugeId: 1726, Weight: sdk.NewInt(752463)}, |
| 115 | + {GaugeId: 2949, Weight: sdk.NewInt(1881160)}, |
| 116 | + {GaugeId: 2950, Weight: sdk.NewInt(1128696)}, |
| 117 | + {GaugeId: 2951, Weight: sdk.NewInt(752464)}, |
| 118 | + } |
| 119 | + |
| 120 | + ctx.Logger().Info("Applying proposal 224 update") |
| 121 | + applyPoolIncentivesUpdate(ctx, poolincentiveskeeper, records) |
| 122 | +} |
0 commit comments