-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hard fork for fix rate limit with osmo token
- Loading branch information
Showing
3 changed files
with
81 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package v5_1_0 | ||
|
||
import "github.com/notional-labs/centauri/v5/app/upgrades" | ||
|
||
const ( | ||
// UpgradeName defines the on-chain upgrade name for the Composable v5 upgrade. | ||
UpgradeName = "v5_1_0" | ||
|
||
// UpgradeHeight defines the block height at which the Composable v6 upgrade is | ||
// triggered. | ||
UpgradeHeight = 1532990 | ||
) | ||
|
||
var Fork = upgrades.Fork{ | ||
UpgradeName: UpgradeName, | ||
UpgradeHeight: UpgradeHeight, | ||
BeginForkLogic: RunForkLogic, | ||
} |
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,61 @@ | ||
package v5_1_0 | ||
|
||
import ( | ||
"cosmossdk.io/math" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/notional-labs/centauri/v5/app/keepers" | ||
rateLimitKeeper "github.com/notional-labs/centauri/v5/x/ratelimit/keeper" | ||
"github.com/notional-labs/centauri/v5/x/ratelimit/types" | ||
) | ||
|
||
const uosmo = "ibc/47BD209179859CDE4A2806763D7189B6E6FE13A17880FE2B42DE1E6C1E329E23" | ||
|
||
func RunForkLogic(ctx sdk.Context, keepers *keepers.AppKeepers) { | ||
ctx.Logger().Info("Applying v5_1_0 upgrade" + | ||
"Fix Rate Limit With Osmosis Token", | ||
) | ||
|
||
FixRateLimit(ctx, &keepers.RatelimitKeeper) | ||
} | ||
|
||
func FixRateLimit(ctx sdk.Context, rlKeeper *rateLimitKeeper.Keeper) { | ||
uosmoRateLimit, found := rlKeeper.GetRateLimit(ctx, uosmo, "channel-2") | ||
if !found { | ||
channelValue := rlKeeper.GetChannelValue(ctx, uosmo) | ||
// Create and store the rate limit object | ||
path := types.Path{ | ||
Denom: uosmo, | ||
ChannelID: "channel-2", | ||
} | ||
quota := types.Quota{ | ||
MaxPercentSend: sdk.NewInt(30), | ||
MaxPercentRecv: sdk.NewInt(30), | ||
DurationHours: 24, | ||
} | ||
flow := types.Flow{ | ||
Inflow: math.ZeroInt(), | ||
Outflow: math.ZeroInt(), | ||
ChannelValue: channelValue, | ||
} | ||
uosmoRateLimit = types.RateLimit{ | ||
Path: &path, | ||
Quota: "a, | ||
Flow: &flow, | ||
MinRateLimitAmount: sdk.NewInt(1), // decimal 6 | ||
} | ||
rlKeeper.SetRateLimit(ctx, uosmoRateLimit) | ||
} else { | ||
uosmoRateLimit.MinRateLimitAmount = sdk.NewInt(1282_000_000) | ||
rlKeeper.SetRateLimit(ctx, uosmoRateLimit) | ||
} | ||
|
||
// double check | ||
allRateLiit := rlKeeper.GetAllRateLimits(ctx) | ||
for _, ratelimit := range allRateLiit { | ||
if ratelimit.MinRateLimitAmount.IsNil() { | ||
ratelimit.MinRateLimitAmount = sdk.NewInt(1) | ||
rlKeeper.SetRateLimit(ctx, ratelimit) | ||
} | ||
} | ||
} |