From e7913c3ec27afccc8342ccb1eefc2f195985eb83 Mon Sep 17 00:00:00 2001 From: sampocs Date: Tue, 4 Jun 2024 16:46:17 -0500 Subject: [PATCH 1/9] removed redemption rate from host zone and renamed delegated balance --- proto/stride/staketia/staketia.proto | 10 +- x/staketia/types/staketia.pb.go | 203 ++++++++++----------------- 2 files changed, 81 insertions(+), 132 deletions(-) diff --git a/proto/stride/staketia/staketia.proto b/proto/stride/staketia/staketia.proto index c9171ae2e..c09bc4e29 100644 --- a/proto/stride/staketia/staketia.proto +++ b/proto/stride/staketia/staketia.proto @@ -41,12 +41,6 @@ message HostZone { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - // Current redemption rate - string redemption_rate = 13 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; // Min outer redemption rate - adjusted by governance string min_redemption_rate = 14 [ (cosmos_proto.scalar) = "cosmos.Dec", @@ -73,7 +67,7 @@ message HostZone { ]; // Total delegated balance on the host zone delegation account - string delegated_balance = 18 [ + string remaining_delegated_balance = 18 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; @@ -82,6 +76,8 @@ message HostZone { uint64 unbonding_period_seconds = 19; // Indicates whether the host zone has been halted bool halted = 20; + + reserved 13; } // Status fields for a delegation record diff --git a/x/staketia/types/staketia.pb.go b/x/staketia/types/staketia.pb.go index d756658aa..72ba89366 100644 --- a/x/staketia/types/staketia.pb.go +++ b/x/staketia/types/staketia.pb.go @@ -144,8 +144,6 @@ type HostZone struct { SafeAddressOnStride string `protobuf:"bytes,11,opt,name=safe_address_on_stride,json=safeAddressOnStride,proto3" json:"safe_address_on_stride,omitempty"` // Previous redemption rate LastRedemptionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,12,opt,name=last_redemption_rate,json=lastRedemptionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"last_redemption_rate"` - // Current redemption rate - RedemptionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,13,opt,name=redemption_rate,json=redemptionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"redemption_rate"` // Min outer redemption rate - adjusted by governance MinRedemptionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,14,opt,name=min_redemption_rate,json=minRedemptionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_redemption_rate"` // Max outer redemption rate - adjusted by governance @@ -155,7 +153,7 @@ type HostZone struct { // Max inner redemption rate - adjusted by controller MaxInnerRedemptionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,17,opt,name=max_inner_redemption_rate,json=maxInnerRedemptionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_inner_redemption_rate"` // Total delegated balance on the host zone delegation account - DelegatedBalance github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,18,opt,name=delegated_balance,json=delegatedBalance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"delegated_balance"` + RemainingDelegatedBalance github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,18,opt,name=remaining_delegated_balance,json=remainingDelegatedBalance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"remaining_delegated_balance"` // The undelegation period for Celestia in days UnbondingPeriodSeconds uint64 `protobuf:"varint,19,opt,name=unbonding_period_seconds,json=unbondingPeriodSeconds,proto3" json:"unbonding_period_seconds,omitempty"` // Indicates whether the host zone has been halted @@ -581,77 +579,78 @@ func init() { func init() { proto.RegisterFile("stride/staketia/staketia.proto", fileDescriptor_d306d9365b78f7b2) } var fileDescriptor_d306d9365b78f7b2 = []byte{ - // 1119 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x57, 0x4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 0x00, 0x00, 0xff, 0xff, 0xb0, 0xdb, 0x16, 0xf1, 0x3e, 0x0c, 0x00, 0x00, + // 1124 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x4f, 0x6f, 0x1a, 0xc7, + 0x1b, 0x66, 0x81, 0xd8, 0xe4, 0xb5, 0x81, 0x65, 0x20, 0x64, 0xed, 0x5f, 0x44, 0xf2, 0xf3, 0x21, + 0x8d, 0xd2, 0x1a, 0x57, 0xce, 0xa5, 0x87, 0x36, 0x11, 0x86, 0x8d, 0xb3, 0x15, 0xc6, 0xee, 0x02, + 0x3d, 0xe4, 0xb2, 0x1a, 0x76, 0x27, 0xb0, 0x0a, 0x3b, 0x8b, 0x76, 0x06, 0x9b, 0x4a, 0xfd, 0x00, + 0x95, 0x7a, 0xe9, 0xa5, 0x9f, 0xa0, 0x1f, 0xa1, 0xb9, 0xf4, 0x1b, 0x44, 0xea, 0x25, 0xcd, 0xa9, + 0xea, 0x21, 0xaa, 0xec, 0x2f, 0x52, 0xed, 0xec, 0x1f, 0x30, 0x60, 0xa1, 0x54, 0x5c, 0x7a, 0xda, + 0x9d, 0x79, 0xde, 0xf7, 0x79, 0x66, 0xde, 0x77, 0xe6, 0x7d, 0x07, 0x2a, 0x8c, 0x7b, 0xb6, 0x45, + 0x0e, 0x18, 0xc7, 0xaf, 0x09, 0xb7, 0x71, 0xfc, 0x53, 0x1d, 0x79, 0x2e, 0x77, 0x51, 0x3e, 0xc0, + 0xab, 0xd1, 0xf4, 0xee, 0x8e, 0xe9, 0x32, 0xc7, 0x65, 0x86, 0x80, 0x0f, 0x82, 0x41, 0x60, 0xbb, + 0x5b, 0xea, 0xbb, 0x7d, 0x37, 0x98, 0xf7, 0xff, 0x82, 0xd9, 0xbd, 0xdf, 0xb6, 0x20, 0xf3, 0xc2, + 0x65, 0xfc, 0xa5, 0x4b, 0x09, 0xda, 0x81, 0x8c, 0x39, 0xc0, 0x36, 0x35, 0x6c, 0x4b, 0x91, 0x1e, + 0x48, 0x8f, 0x6e, 0xeb, 0x9b, 0x62, 0xac, 0x59, 0xe8, 0x33, 0x40, 0x14, 0x73, 0xfb, 0x9c, 0x18, + 0xdc, 0x7d, 0x4d, 0xa8, 0x61, 0x11, 0xea, 0x3a, 0x4a, 0x52, 0x18, 0xc9, 0x01, 0xd2, 0xf1, 0x81, + 0x86, 0x3f, 0x8f, 0x9e, 0x40, 0xf9, 0x9a, 0xb5, 0xdd, 0x33, 0x43, 0x8f, 0x94, 0xf0, 0x28, 0xce, + 0x78, 0x68, 0x3d, 0x33, 0x70, 0xaa, 0x42, 0x91, 0x7b, 0x98, 0xb2, 0x57, 0xc4, 0x33, 0xcc, 0x01, + 0xa6, 0x94, 0x0c, 0xfd, 0x85, 0xa4, 0x85, 0x47, 0x21, 0x82, 0xea, 0x01, 0xa2, 0x59, 0xe8, 0x18, + 0x90, 0x45, 0x86, 0xa4, 0x8f, 0xb9, 0xed, 0x52, 0x03, 0x5b, 0x96, 0x47, 0x18, 0x53, 0x6e, 0xf9, + 0xe6, 0x47, 0xca, 0xfb, 0x37, 0xfb, 0xa5, 0x70, 0xfb, 0xb5, 0x00, 0x69, 0x73, 0xcf, 0xa6, 0x7d, + 0xbd, 0x30, 0xf5, 0x09, 0x01, 0xf4, 0x0c, 0x72, 0x1e, 0xb9, 0xc0, 0x9e, 0x15, 0x93, 0x6c, 0xac, + 0x20, 0xc9, 0x06, 0xf6, 0x11, 0x41, 0x0d, 0xf2, 0x16, 0x19, 0xb9, 0xcc, 0xe6, 0x31, 0xc3, 0xe6, + 0x0a, 0x86, 0x5c, 0xe8, 0x10, 0x51, 0x1c, 0x03, 0xf2, 0x88, 0x45, 0x9c, 0xd1, 0xb5, 0xcd, 0x64, + 0x56, 0x6d, 0x66, 0xea, 0x13, 0x11, 0x7d, 0x05, 0x59, 0x73, 0x88, 0x6d, 0x27, 0xe6, 0xb8, 0xbd,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 0x49, 0x49, 0xf0, 0x5c, 0xd9, + 0x6f, 0xe2, 0x1e, 0x3b, 0x08, 0x9f, 0xf2, 0xe7, 0x87, 0x87, 0x07, 0x93, 0xe9, 0x83, 0x5e, 0xa4, + 0xa8, 0xb7, 0x21, 0x1e, 0xe3, 0x4f, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0x1b, 0x99, 0x90, 0x15, + 0xf0, 0x0b, 0x00, 0x00, } func (m *HostZone) Marshal() (dAtA []byte, err error) { @@ -694,9 +693,9 @@ func (m *HostZone) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x98 } { - size := m.DelegatedBalance.Size() + size := m.RemainingDelegatedBalance.Size() i -= size - if _, err := m.DelegatedBalance.MarshalTo(dAtA[i:]); err != nil { + if _, err := m.RemainingDelegatedBalance.MarshalTo(dAtA[i:]); err != nil { return 0, err } i = encodeVarintStaketia(dAtA, i, uint64(size)) @@ -749,16 +748,6 @@ func (m *HostZone) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x72 - { - size := m.RedemptionRate.Size() - i -= size - if _, err := m.RedemptionRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaketia(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6a { size := m.LastRedemptionRate.Size() i -= size @@ -1139,8 +1128,6 @@ func (m *HostZone) Size() (n int) { } l = m.LastRedemptionRate.Size() n += 1 + l + sovStaketia(uint64(l)) - l = m.RedemptionRate.Size() - n += 1 + l + sovStaketia(uint64(l)) l = m.MinRedemptionRate.Size() n += 1 + l + sovStaketia(uint64(l)) l = m.MaxRedemptionRate.Size() @@ -1149,7 +1136,7 @@ func (m *HostZone) Size() (n int) { n += 2 + l + sovStaketia(uint64(l)) l = m.MaxInnerRedemptionRate.Size() n += 2 + l + sovStaketia(uint64(l)) - l = m.DelegatedBalance.Size() + l = m.RemainingDelegatedBalance.Size() n += 2 + l + sovStaketia(uint64(l)) if m.UnbondingPeriodSeconds != 0 { n += 2 + sovStaketia(uint64(m.UnbondingPeriodSeconds)) @@ -1673,40 +1660,6 @@ func (m *HostZone) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 13: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RedemptionRate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaketia - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStaketia - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaketia - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RedemptionRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 14: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MinRedemptionRate", wireType) @@ -1845,7 +1798,7 @@ func (m *HostZone) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 18: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegatedBalance", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RemainingDelegatedBalance", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1873,7 +1826,7 @@ func (m *HostZone) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.DelegatedBalance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.RemainingDelegatedBalance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex From 761f16db31ef15e9a72adaf2208ad45c4fee23ab Mon Sep 17 00:00:00 2001 From: sampocs Date: Tue, 4 Jun 2024 16:49:38 -0500 Subject: [PATCH 2/9] removed redemption rate hooks --- x/staketia/keeper/abci.go | 11 +- x/staketia/keeper/hooks.go | 14 -- x/staketia/keeper/redemption_rate.go | 105 --------------- x/staketia/keeper/redemption_rate_test.go | 151 ---------------------- 4 files changed, 1 insertion(+), 280 deletions(-) diff --git a/x/staketia/keeper/abci.go b/x/staketia/keeper/abci.go index 6e55a665c..600ad6d01 100644 --- a/x/staketia/keeper/abci.go +++ b/x/staketia/keeper/abci.go @@ -4,13 +4,4 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (k Keeper) BeginBlocker(ctx sdk.Context) { - // Check invariants - - // Check redemption rate is within safety bounds - if err := k.CheckRedemptionRateExceedsBounds(ctx); err != nil { - k.Logger(ctx).Error(err.Error()) - // If not, halt the zone - k.HaltZone(ctx) - } -} +func (k Keeper) BeginBlocker(ctx sdk.Context) {} diff --git a/x/staketia/keeper/hooks.go b/x/staketia/keeper/hooks.go index b91efc6ee..8dd6eb9b3 100644 --- a/x/staketia/keeper/hooks.go +++ b/x/staketia/keeper/hooks.go @@ -23,20 +23,6 @@ func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochInfo epochstypes.EpochInf // Every day, refresh the redemption rate and prepare delegations // Every 4 days, prepare undelegations if epochInfo.Identifier == epochstypes.DAY_EPOCH { - // Update the redemption rate - // If this fails, do not proceed to the delegation or undelegation step - // Note: This must be run first because it is used when refreshing the native token - // balance in prepare undelegation - if err := k.UpdateRedemptionRate(ctx); err != nil { - k.Logger(ctx).Error(fmt.Sprintf("Unable update redemption rate: %s", err.Error())) - return - } - - // Post the redemption rate to the oracle (if it doesn't exceed the bounds) - if err := k.PostRedemptionRateToOracles(ctx); err != nil { - k.Logger(ctx).Error(fmt.Sprintf("Unable to post redemption rate to oracle: %s", err.Error())) - } - // Prepare delegations by transferring the deposited tokens to the host zone if err := k.SafelyPrepareDelegation(ctx, epochNumber, epochInfo.Duration); err != nil { k.Logger(ctx).Error(fmt.Sprintf("Unable to prepare delegation for epoch %d: %s", epochNumber, err.Error())) diff --git a/x/staketia/keeper/redemption_rate.go b/x/staketia/keeper/redemption_rate.go index 2de6398dd..b385d95b8 100644 --- a/x/staketia/keeper/redemption_rate.go +++ b/x/staketia/keeper/redemption_rate.go @@ -1,87 +1,11 @@ package keeper import ( - "encoding/json" - "errors" - "fmt" - - errorsmod "cosmossdk.io/errors" - sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/Stride-Labs/stride/v22/utils" - icaoracletypes "github.com/Stride-Labs/stride/v22/x/icaoracle/types" "github.com/Stride-Labs/stride/v22/x/staketia/types" ) -// Updates the redemption rate for each host zone -// At a high level, the redemption rate is equal to the amount of native tokens locked divided by the stTokens in existence. -// The equation is broken down further into the following sub-components: -// -// Native Tokens Locked: -// 1. Deposit Account Balance: tokens deposited from liquid stakes, that are still living on Stride -// 2. Undelegated Balance: tokens that are ready to be staked -// (they're either currently in the delegation account or currently being transferred there) -// 3. Delegated Balance: Delegations on the host zone -// -// StToken Amount: -// 1. Total Supply of the stToken -// -// Redemption Rate = (Deposit Account Balance + Undelegated Balance + Delegated Balance) / (stToken Supply) -// -// Note: Reinvested tokens are sent to the deposit account and are automatically included in this formula -func (k Keeper) UpdateRedemptionRate(ctx sdk.Context) error { - k.Logger(ctx).Info(utils.LogWithHostZone(types.CelestiaChainId, "Updating redemption rate")) - - hostZone, err := k.GetHostZone(ctx) - if err != nil { - return err - } - - // Get the number of stTokens from the supply - stTokenSupply := k.bankKeeper.GetSupply(ctx, utils.StAssetDenomFromHostZoneDenom(hostZone.NativeTokenDenom)).Amount - if stTokenSupply.IsZero() { - k.Logger(ctx).Info(utils.LogWithHostZone(hostZone.ChainId, - "No st%s in circulation - redemption rate is unchanged", hostZone.NativeTokenDenom)) - return nil - } - - // Get the balance of the deposit address - depositAddress, err := sdk.AccAddressFromBech32(hostZone.DepositAddress) - if err != nil { - return errorsmod.Wrapf(err, "invalid deposit address") - } - depositAccountBalance := k.bankKeeper.GetBalance(ctx, depositAddress, hostZone.NativeTokenIbcDenom) - - // Then add that to the sum of the delegation records to get the undelegated balance - // Delegation records are only created once the tokens leave the deposit address - // and the record is deleted once the tokens are delegated - undelegatedBalance := sdkmath.ZeroInt() - for _, delegationRecord := range k.GetAllActiveDelegationRecords(ctx) { - undelegatedBalance = undelegatedBalance.Add(delegationRecord.NativeAmount) - } - - // Finally, calculated the redemption rate as the native tokens locked divided by the stTokens - nativeTokensLocked := depositAccountBalance.Amount.Add(undelegatedBalance).Add(hostZone.DelegatedBalance) - if !nativeTokensLocked.IsPositive() { - return errors.New("Non-zero stToken supply, yet the zero delegated and undelegated balance") - } - redemptionRate := sdk.NewDecFromInt(nativeTokensLocked).Quo(sdk.NewDecFromInt(stTokenSupply)) - - // Set the old and update redemption rate on the host - hostZone.LastRedemptionRate = hostZone.RedemptionRate - hostZone.RedemptionRate = redemptionRate - k.SetHostZone(ctx, hostZone) - - k.Logger(ctx).Info(utils.LogWithHostZone(types.CelestiaChainId, "Redemption rate updated from %v to %v", - hostZone.LastRedemptionRate, hostZone.RedemptionRate)) - k.Logger(ctx).Info(utils.LogWithHostZone(types.CelestiaChainId, - "Deposit Account Balance: %v, Undelegated Balance: %v, Delegated Balance: %v, StToken Supply: %v", - depositAccountBalance.Amount, undelegatedBalance, hostZone.DelegatedBalance, stTokenSupply)) - - return nil -} - // Checks whether the redemption rate has exceeded the inner or outer safety bounds // and returns an error if so func (k Keeper) CheckRedemptionRateExceedsBounds(ctx sdk.Context) error { @@ -108,32 +32,3 @@ func (k Keeper) CheckRedemptionRateExceedsBounds(ctx sdk.Context) error { return nil } - -// Pushes a redemption rate update to the ICA oracle -func (k Keeper) PostRedemptionRateToOracles(ctx sdk.Context) error { - if err := k.CheckRedemptionRateExceedsBounds(ctx); err != nil { - return errorsmod.Wrapf(err, "preventing oracle update since redemption rate exceeded bounds") - } - - hostZone, err := k.GetHostZone(ctx) - if err != nil { - return err - } - redemptionRate := hostZone.RedemptionRate - - stDenom := utils.StAssetDenomFromHostZoneDenom(hostZone.NativeTokenDenom) - attributes, err := json.Marshal(icaoracletypes.RedemptionRateAttributes{ - SttokenDenom: stDenom, - }) - if err != nil { - return err - } - - // Metric Key is of format: {stToken}_redemption_rate - metricKey := fmt.Sprintf("%s_%s", stDenom, icaoracletypes.MetricType_RedemptionRate) - metricValue := redemptionRate.String() - metricType := icaoracletypes.MetricType_RedemptionRate - k.icaOracleKeeper.QueueMetricUpdate(ctx, metricKey, metricValue, metricType, string(attributes)) - - return nil -} diff --git a/x/staketia/keeper/redemption_rate_test.go b/x/staketia/keeper/redemption_rate_test.go index d4a771755..7b2b424a3 100644 --- a/x/staketia/keeper/redemption_rate_test.go +++ b/x/staketia/keeper/redemption_rate_test.go @@ -1,162 +1,11 @@ package keeper_test import ( - "fmt" - - sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/Stride-Labs/stride/v22/x/staketia/types" ) -func (s *KeeperTestSuite) TestUpdateRedemptionRate() { - depositAddress := s.TestAccs[0] - - testCases := []struct { - expectedRedemptionRate sdk.Dec - depositBalance sdkmath.Int - delegatedBalance sdkmath.Int - stTokenSupply sdkmath.Int - delegationRecords []types.DelegationRecord - }{ - { - // Deposit: 250, Undelegated: 500, Delegated: 250, StTokens: 1000 - // (250 + 500 + 250 / 1000) = 1000 / 1000 = 1.0 - expectedRedemptionRate: sdk.MustNewDecFromStr("1.0"), - depositBalance: sdkmath.NewInt(250), - delegatedBalance: sdkmath.NewInt(250), - delegationRecords: []types.DelegationRecord{ - {Id: 1, NativeAmount: sdkmath.NewInt(250), Status: types.TRANSFER_IN_PROGRESS}, - {Id: 2, NativeAmount: sdkmath.NewInt(250), Status: types.DELEGATION_QUEUE}, - }, - stTokenSupply: sdkmath.NewInt(1000), - }, - { - // Deposit: 500, Undelegated: 500, Delegated: 250, StTokens: 1000 - // (500 + 500 + 250 / 1000) = 1250 / 1000 = 1.25 - expectedRedemptionRate: sdk.MustNewDecFromStr("1.25"), - depositBalance: sdkmath.NewInt(500), - delegatedBalance: sdkmath.NewInt(250), - delegationRecords: []types.DelegationRecord{ - {Id: 1, NativeAmount: sdkmath.NewInt(250), Status: types.TRANSFER_IN_PROGRESS}, - {Id: 2, NativeAmount: sdkmath.NewInt(250), Status: types.DELEGATION_QUEUE}, - }, - stTokenSupply: sdkmath.NewInt(1000), - }, - { - // Deposit: 250, Undelegated: 500, Delegated: 500, StTokens: 1000 - // (500 + 500 + 250 / 1000) = 1250 / 1000 = 1.250 - expectedRedemptionRate: sdk.MustNewDecFromStr("1.25"), - depositBalance: sdkmath.NewInt(250), - delegatedBalance: sdkmath.NewInt(500), - delegationRecords: []types.DelegationRecord{ - {Id: 2, NativeAmount: sdkmath.NewInt(250), Status: types.TRANSFER_IN_PROGRESS}, - {Id: 3, NativeAmount: sdkmath.NewInt(250), Status: types.DELEGATION_QUEUE}, - }, - stTokenSupply: sdkmath.NewInt(1000), - }, - { - // Deposit: 250, Undelegated: 1000, Delegated: 250, StTokens: 1000 - // (250 + 1000 + 250 / 1000) = 1500 / 1000 = 1.5 - expectedRedemptionRate: sdk.MustNewDecFromStr("1.5"), - depositBalance: sdkmath.NewInt(250), - delegatedBalance: sdkmath.NewInt(250), - delegationRecords: []types.DelegationRecord{ - {Id: 1, NativeAmount: sdkmath.NewInt(250), Status: types.TRANSFER_IN_PROGRESS}, - {Id: 2, NativeAmount: sdkmath.NewInt(250), Status: types.DELEGATION_QUEUE}, - {Id: 4, NativeAmount: sdkmath.NewInt(250), Status: types.TRANSFER_IN_PROGRESS}, - {Id: 6, NativeAmount: sdkmath.NewInt(250), Status: types.DELEGATION_QUEUE}, - }, - stTokenSupply: sdkmath.NewInt(1000), - }, - { - // Deposit: 250, Undelegated: 500, Delegated: 250, StTokens: 2000 - // (250 + 500 + 250 / 2000) = 1000 / 2000 = 0.5 - expectedRedemptionRate: sdk.MustNewDecFromStr("0.5"), - depositBalance: sdkmath.NewInt(250), - delegatedBalance: sdkmath.NewInt(250), - delegationRecords: []types.DelegationRecord{ - {Id: 1, NativeAmount: sdkmath.NewInt(250), Status: types.TRANSFER_IN_PROGRESS}, - {Id: 2, NativeAmount: sdkmath.NewInt(250), Status: types.DELEGATION_QUEUE}, - }, - stTokenSupply: sdkmath.NewInt(2000), - }, - } - - for i, tc := range testCases { - s.Run(fmt.Sprintf("test-%d", i), func() { - s.SetupTest() // reset state - - // Fund the deposit balance - s.FundAccount(depositAddress, sdk.NewCoin(HostIBCDenom, tc.depositBalance)) - - // Create the host zone with the delegated balance and deposit address - initialRedemptionRate := sdk.MustNewDecFromStr("0.999") - s.App.StaketiaKeeper.SetHostZone(s.Ctx, types.HostZone{ - NativeTokenDenom: HostNativeDenom, - NativeTokenIbcDenom: HostIBCDenom, - DepositAddress: depositAddress.String(), - DelegatedBalance: tc.delegatedBalance, - RedemptionRate: initialRedemptionRate, - }) - - // Set each delegation record - for _, delegationRecord := range tc.delegationRecords { - s.App.StaketiaKeeper.SetDelegationRecord(s.Ctx, delegationRecord) - } - - // Add some archive delegation records that should be excluded - // We'll create these by first creating normal records and then removing them - for i := 0; i <= 5; i++ { - id := uint64(i * 1000) - s.App.StaketiaKeeper.SetArchivedDelegationRecord(s.Ctx, types.DelegationRecord{Id: id}) - } - - // Mint sttokens for the supply (fund account calls mint) - s.FundAccount(s.TestAccs[1], sdk.NewCoin(StDenom, tc.stTokenSupply)) - - // Update the redemption rate and check that it matches - err := s.App.StaketiaKeeper.UpdateRedemptionRate(s.Ctx) - s.Require().NoError(err, "no error expected when calculating redemption rate") - - hostZone := s.MustGetHostZone() - s.Require().Equal(tc.expectedRedemptionRate, hostZone.RedemptionRate, "redemption rate") - - // Check that the last redemption rate was set - s.Require().Equal(initialRedemptionRate, hostZone.LastRedemptionRate, "redemption rate") - }) - - } -} - -func (s *KeeperTestSuite) TestUpdateRedemptionRate_NoTokens() { - depositAddress := s.TestAccs[0] - - // Create the host zone with no delegated balance - s.App.StaketiaKeeper.SetHostZone(s.Ctx, types.HostZone{ - NativeTokenDenom: HostNativeDenom, - NativeTokenIbcDenom: HostIBCDenom, - DepositAddress: depositAddress.String(), - DelegatedBalance: sdkmath.ZeroInt(), - RedemptionRate: sdk.OneDec(), - }) - - // Check that the update funtion returns nil, since there are no stTokens - err := s.App.StaketiaKeeper.UpdateRedemptionRate(s.Ctx) - s.Require().NoError(err, "no error when there are no stTokens") - - // Check that the redemption rate was not updated - hostZone := s.MustGetHostZone() - s.Require().Equal(sdk.OneDec(), hostZone.RedemptionRate, "redemption rate should not have been updated") - - // Mint stTokens - s.FundAccount(s.TestAccs[1], sdk.NewCoin(StDenom, sdkmath.NewInt(1000))) - - // Try to update again, now it should error since there's stTokens but no native tokens - err = s.App.StaketiaKeeper.UpdateRedemptionRate(s.Ctx) - s.Require().ErrorContains(err, "Non-zero stToken supply, yet the zero delegated and undelegated balance") -} - func (s *KeeperTestSuite) TestCheckRedemptionRateExceedsBounds() { testCases := []struct { name string From 6c781405d2e17214c651fc72d5a40d0206f41ccb Mon Sep 17 00:00:00 2001 From: sampocs Date: Tue, 4 Jun 2024 16:52:03 -0500 Subject: [PATCH 3/9] updated redemption rate check to use stakeibc RR --- x/staketia/keeper/redemption_rate.go | 11 +++-------- x/staketia/keeper/redemption_rate_test.go | 4 ++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/x/staketia/keeper/redemption_rate.go b/x/staketia/keeper/redemption_rate.go index b385d95b8..b93143138 100644 --- a/x/staketia/keeper/redemption_rate.go +++ b/x/staketia/keeper/redemption_rate.go @@ -9,17 +9,12 @@ import ( // Checks whether the redemption rate has exceeded the inner or outer safety bounds // and returns an error if so func (k Keeper) CheckRedemptionRateExceedsBounds(ctx sdk.Context) error { - hostZone, err := k.GetHostZone(ctx) - if err != nil { - return err + hostZone, found := k.stakeibcKeeper.GetHostZone(ctx, types.CelestiaChainId) + if !found { + return types.ErrHostZoneNotFound } redemptionRate := hostZone.RedemptionRate - // Validate the safety bounds (e.g. that the inner is inside the outer) - if err := hostZone.ValidateRedemptionRateBoundsInitalized(); err != nil { - return err - } - // Check if the redemption rate is outside the outer bounds if redemptionRate.LT(hostZone.MinRedemptionRate) || redemptionRate.GT(hostZone.MaxRedemptionRate) { return types.ErrRedemptionRateOutsideSafetyBounds.Wrapf("redemption rate outside outer safety bounds") diff --git a/x/staketia/keeper/redemption_rate_test.go b/x/staketia/keeper/redemption_rate_test.go index 7b2b424a3..813790aca 100644 --- a/x/staketia/keeper/redemption_rate_test.go +++ b/x/staketia/keeper/redemption_rate_test.go @@ -3,7 +3,7 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/Stride-Labs/stride/v22/x/staketia/types" + "github.com/Stride-Labs/stride/v22/x/stakeibc/types" ) func (s *KeeperTestSuite) TestCheckRedemptionRateExceedsBounds() { @@ -71,7 +71,7 @@ func (s *KeeperTestSuite) TestCheckRedemptionRateExceedsBounds() { for _, tc := range testCases { s.Run(tc.name, func() { - s.App.StaketiaKeeper.SetHostZone(s.Ctx, tc.hostZone) + s.App.StakeibcKeeper.SetHostZone(s.Ctx, tc.hostZone) err := s.App.StaketiaKeeper.CheckRedemptionRateExceedsBounds(s.Ctx) if tc.exceedsBounds { s.Require().ErrorIs(err, types.ErrRedemptionRateOutsideSafetyBounds) From 8d5c03f50c4863f2de1722730259805d744b4a92 Mon Sep 17 00:00:00 2001 From: sampocs Date: Tue, 4 Jun 2024 16:55:54 -0500 Subject: [PATCH 4/9] removed VerifyImpliedRRFromUnbonding --- x/staketia/keeper/unbonding.go | 38 ---------- x/staketia/keeper/unbonding_test.go | 107 ---------------------------- 2 files changed, 145 deletions(-) diff --git a/x/staketia/keeper/unbonding.go b/x/staketia/keeper/unbonding.go index fb2359936..f0377797f 100644 --- a/x/staketia/keeper/unbonding.go +++ b/x/staketia/keeper/unbonding.go @@ -183,8 +183,6 @@ func (k Keeper) ConfirmUndelegation(ctx sdk.Context, recordId uint64, txHash str // sanity check: store down the stToken supply and DelegatedBalance for checking against after burn stDenom := utils.StAssetDenomFromHostZoneDenom(hostZone.NativeTokenDenom) - stTokenSupplyBefore := k.bankKeeper.GetSupply(ctx, stDenom).Amount - delegatedBalanceBefore := hostZone.DelegatedBalance // update the record's txhash, status, and unbonding completion time unbondingLength := time.Duration(hostZone.UnbondingPeriodSeconds) * time.Second // 21 days @@ -212,11 +210,6 @@ func (k Keeper) ConfirmUndelegation(ctx sdk.Context, recordId uint64, txHash str return errorsmod.Wrapf(err, "unable to burn stTokens in ConfirmUndelegation") } - // sanity check: check that (DelegatedBalance increment / stToken supply decrement) is within outer bounds - if err := k.VerifyImpliedRedemptionRateFromUnbonding(ctx, stTokenSupplyBefore, delegatedBalanceBefore); err != nil { - return errorsmod.Wrap(err, "ratio of delegation change to burned tokens exceeds redemption rate bounds") - } - EmitSuccessfulConfirmUndelegationEvent(ctx, recordId, record.NativeAmount, txHash, sender) return nil } @@ -245,37 +238,6 @@ func (k Keeper) BurnRedeemedStTokens(ctx sdk.Context, stTokensToBurn sdk.Coins, return nil } -// Sanity check helper for checking diffs on delegated balance and stToken supply are within outer RR bounds -func (k Keeper) VerifyImpliedRedemptionRateFromUnbonding(ctx sdk.Context, stTokenSupplyBefore sdkmath.Int, delegatedBalanceBefore sdkmath.Int) error { - hostZoneAfter, err := k.GetHostZone(ctx) - if err != nil { - return types.ErrHostZoneNotFound - } - stDenom := utils.StAssetDenomFromHostZoneDenom(hostZoneAfter.NativeTokenDenom) - - // grab the delegated balance and token supply after the burn - delegatedBalanceAfter := hostZoneAfter.DelegatedBalance - stTokenSupplyAfter := k.bankKeeper.GetSupply(ctx, stDenom).Amount - - // calculate the delta for both the delegated balance and stToken burn - delegatedBalanceDecremented := delegatedBalanceBefore.Sub(delegatedBalanceAfter) - stTokenSupplyBurned := stTokenSupplyBefore.Sub(stTokenSupplyAfter) - - // It shouldn't be possible for this to be zero, but this will prevent a division by zero error - if stTokenSupplyBurned.IsZero() { - return types.ErrDivisionByZero - } - - // calculate the ratio of delegated balance change to stToken burn - it should be close to the redemption rate - ratio := sdk.NewDecFromInt(delegatedBalanceDecremented).Quo(sdk.NewDecFromInt(stTokenSupplyBurned)) - - // check ratio against bounds - if ratio.LT(hostZoneAfter.MinRedemptionRate) || ratio.GT(hostZoneAfter.MaxRedemptionRate) { - return types.ErrRedemptionRateOutsideSafetyBounds - } - return nil -} - // Checks for any unbonding records that have finished unbonding, // identified by having status UNBONDING_IN_PROGRESS and an // unbonding that's older than the current time. diff --git a/x/staketia/keeper/unbonding_test.go b/x/staketia/keeper/unbonding_test.go index b05c37aba..f198a8d5e 100644 --- a/x/staketia/keeper/unbonding_test.go +++ b/x/staketia/keeper/unbonding_test.go @@ -642,113 +642,6 @@ func (s *KeeperTestSuite) TestBurnRedeemedStTokens_BadRedemptionAddress() { s.Require().Error(err, "could not bech32 decode addres") } -func (s *KeeperTestSuite) TestVerifyImpliedRedemptionRateFromUnbonding() { - minRRBound := sdk.MustNewDecFromStr("0.9") - maxRRBound := sdk.MustNewDecFromStr("1.1") - - testCases := []struct { - name string - delegatedBalanceBefore sdkmath.Int - delegatedBalanceAfter sdkmath.Int - stTokenSupplyBefore sdkmath.Int - stTokenSupplyAfter sdkmath.Int - expectedError string - }{ - { - // Undelegated: 1000, Burned: 1000, Implied Rate: 1.0 - name: "valid implied rate - 1", - delegatedBalanceBefore: sdkmath.NewInt(5000), - delegatedBalanceAfter: sdkmath.NewInt(4000), // 5000 - 4000 = 1000 undelegated - stTokenSupplyBefore: sdkmath.NewInt(5000), - stTokenSupplyAfter: sdkmath.NewInt(4000), // 5000 - 4000 = 1000 burned - }, - { - // Undelegated: 950, Burned: 1000, Implied Rate: 0.95 - name: "valid implied rate below 1", - delegatedBalanceBefore: sdkmath.NewInt(5000), - delegatedBalanceAfter: sdkmath.NewInt(4050), // 5000 - 4050 = 950 undelegated - stTokenSupplyBefore: sdkmath.NewInt(5000), - stTokenSupplyAfter: sdkmath.NewInt(4000), // 5000 - 4000 = 1000 burned - }, - { - // Undelegated: 1050, Burned: 1000, Implied Rate: 1.05 - name: "valid implied rate above 1", - delegatedBalanceBefore: sdkmath.NewInt(5000), - delegatedBalanceAfter: sdkmath.NewInt(3950), // 5000 - 3950 = 1050 undelegated - stTokenSupplyBefore: sdkmath.NewInt(5000), - stTokenSupplyAfter: sdkmath.NewInt(4000), // 5000 - 4000 = 1000 burned - }, - { - // Undelegated: 900, Burned: 1000, Implied Rate: 0.9 - name: "valid implied rate at min", - delegatedBalanceBefore: sdkmath.NewInt(5000), - delegatedBalanceAfter: sdkmath.NewInt(4000), // 5000 - 4000 = 900 undelegated - stTokenSupplyBefore: sdkmath.NewInt(5000), - stTokenSupplyAfter: sdkmath.NewInt(4000), // 5000 - 4000 = 1000 burned - }, - { - // Undelegated: 1100, Burned: 1000, Implied Rate: 1.1 - name: "valid implied rate at max", - delegatedBalanceBefore: sdkmath.NewInt(5000), - delegatedBalanceAfter: sdkmath.NewInt(3900), // 5000 - 3900 = 1100 undelegated - stTokenSupplyBefore: sdkmath.NewInt(5000), - stTokenSupplyAfter: sdkmath.NewInt(4000), // 5000 - 4000 = 1000 burned - }, - { - // Undelegated: 899, Burned: 1000, Implied Rate: 0.899 - name: "valid implied rate below min", - delegatedBalanceBefore: sdkmath.NewInt(5000), - delegatedBalanceAfter: sdkmath.NewInt(4101), // 5000 - 4101 = 899 undelegated - stTokenSupplyBefore: sdkmath.NewInt(5000), - stTokenSupplyAfter: sdkmath.NewInt(4000), // 5000 - 4000 = 1000 burned - expectedError: "redemption rate outside safety bounds", - }, - { - // Undelegated: 1101, Burned: 1000, Implied Rate: 1.101 - name: "valid implied rate above max", - delegatedBalanceBefore: sdkmath.NewInt(5000), - delegatedBalanceAfter: sdkmath.NewInt(3899), // 5000 - 3899 = 1101 undelegated - stTokenSupplyBefore: sdkmath.NewInt(5000), - stTokenSupplyAfter: sdkmath.NewInt(4000), // 5000 - 4000 = 1000 burned - expectedError: "redemption rate outside safety bounds", - }, - { - name: "division by zero", - delegatedBalanceBefore: sdkmath.NewInt(1000), - delegatedBalanceAfter: sdkmath.NewInt(2000), - stTokenSupplyBefore: sdkmath.NewInt(4000), - stTokenSupplyAfter: sdkmath.NewInt(4000), // same as before -> supply change is 0 - expectedError: "division by zero", - }, - } - - for _, tc := range testCases { - s.Run(tc.name, func() { - s.SetupTest() // reset state - - // Mint stTokens to a random account to create supply - s.FundAccount(s.TestAccs[0], sdk.NewCoin(StDenom, tc.stTokenSupplyAfter)) - - // Set the delegated balance on the host zone - s.App.StaketiaKeeper.SetHostZone(s.Ctx, types.HostZone{ - NativeTokenDenom: HostNativeDenom, - DelegatedBalance: tc.delegatedBalanceAfter, - MinRedemptionRate: minRRBound, - MaxRedemptionRate: maxRRBound, - }) - - // verify that the implied redemption rate is between the bounds - err := s.App.StaketiaKeeper.VerifyImpliedRedemptionRateFromUnbonding(s.Ctx, tc.stTokenSupplyBefore, tc.delegatedBalanceBefore) - - if tc.expectedError == "" { - s.Require().NoError(err) - } else { - s.Require().ErrorContains(err, tc.expectedError) - } - }) - } -} - // ---------------------------------------------- // ConfirmUnbondedTokensSwept // ---------------------------------------------- From e1be294f795f7120899587d7856bea3f8a5cbe70 Mon Sep 17 00:00:00 2001 From: sampocs Date: Tue, 4 Jun 2024 17:11:41 -0500 Subject: [PATCH 5/9] updated references to delegated balance --- x/staketia/keeper/delegation.go | 2 +- x/staketia/keeper/delegation_test.go | 6 +++--- x/staketia/keeper/msg_server.go | 4 ++-- x/staketia/keeper/msg_server_test.go | 7 +++---- x/staketia/keeper/unbonding.go | 20 ++++++++++++-------- x/staketia/keeper/unbonding_test.go | 27 ++++++++++++++++++--------- x/staketia/types/expected_keepers.go | 1 + 7 files changed, 40 insertions(+), 27 deletions(-) diff --git a/x/staketia/keeper/delegation.go b/x/staketia/keeper/delegation.go index 69f841fdd..cefef6d34 100644 --- a/x/staketia/keeper/delegation.go +++ b/x/staketia/keeper/delegation.go @@ -171,7 +171,7 @@ func (k Keeper) ConfirmDelegation(ctx sdk.Context, recordId uint64, txHash strin k.ArchiveDelegationRecord(ctx, delegationRecord) // increment delegation on Host Zone - hostZone.DelegatedBalance = hostZone.DelegatedBalance.Add(delegationRecord.NativeAmount) + hostZone.RemainingDelegatedBalance = hostZone.RemainingDelegatedBalance.Add(delegationRecord.NativeAmount) k.SetHostZone(ctx, hostZone) EmitSuccessfulConfirmDelegationEvent(ctx, recordId, delegationRecord.NativeAmount, txHash, sender) diff --git a/x/staketia/keeper/delegation_test.go b/x/staketia/keeper/delegation_test.go index 2ad2fc330..7484288cc 100644 --- a/x/staketia/keeper/delegation_test.go +++ b/x/staketia/keeper/delegation_test.go @@ -372,7 +372,7 @@ func (s *KeeperTestSuite) SetupDelegationRecords() { // Set HostZone hostZone := s.initializeHostZone() - hostZone.DelegatedBalance = InitialDelegation + hostZone.RemainingDelegatedBalance = InitialDelegation s.App.StaketiaKeeper.SetHostZone(s.Ctx, hostZone) } @@ -415,7 +415,7 @@ func (s *KeeperTestSuite) VerifyDelegationRecords(verifyIdentical bool, archiveI // if nothing should have changed, verify that host zone balance is unmodified if verifyIdentical { // verify hostZone delegated balance is same as initial delegation - s.Require().Equal(InitialDelegation.Int64(), hostZone.DelegatedBalance.Int64(), "hostZone delegated balance should not have changed") + s.Require().Equal(InitialDelegation.Int64(), hostZone.RemainingDelegatedBalance.Int64(), "hostZone delegated balance should not have changed") } } } @@ -439,7 +439,7 @@ func (s *KeeperTestSuite) TestConfirmDelegation_Successful() { // verify hostZone delegated balance is same as initial delegation + 6000 hostZone := s.MustGetHostZone() - s.Require().Equal(InitialDelegation.Int64()+6000, hostZone.DelegatedBalance.Int64(), "hostZone delegated balance should have increased by 6000") + s.Require().Equal(InitialDelegation.Int64()+6000, hostZone.RemainingDelegatedBalance.Int64(), "hostZone delegated balance should have increased by 6000") } func (s *KeeperTestSuite) TestConfirmDelegation_DelegationZero() { diff --git a/x/staketia/keeper/msg_server.go b/x/staketia/keeper/msg_server.go index d5be19939..a956cbd65 100644 --- a/x/staketia/keeper/msg_server.go +++ b/x/staketia/keeper/msg_server.go @@ -111,10 +111,10 @@ func (k msgServer) AdjustDelegatedBalance(goCtx context.Context, msg *types.MsgA if err != nil { return nil, err } - hostZone.DelegatedBalance = hostZone.DelegatedBalance.Add(msg.DelegationOffset) + hostZone.RemainingDelegatedBalance = hostZone.RemainingDelegatedBalance.Add(msg.DelegationOffset) // safety check that this will not cause the delegated balance to be negative - if hostZone.DelegatedBalance.IsNegative() { + if hostZone.RemainingDelegatedBalance.IsNegative() { return nil, types.ErrNegativeNotAllowed.Wrapf("offset would cause the delegated balance to be negative") } k.SetHostZone(ctx, hostZone) diff --git a/x/staketia/keeper/msg_server_test.go b/x/staketia/keeper/msg_server_test.go index 699f36b46..027f24b7e 100644 --- a/x/staketia/keeper/msg_server_test.go +++ b/x/staketia/keeper/msg_server_test.go @@ -184,8 +184,8 @@ func (s *KeeperTestSuite) TestAdjustDelegatedBalance() { // Create the host zone s.App.StaketiaKeeper.SetHostZone(s.Ctx, types.HostZone{ - SafeAddressOnStride: safeAddress, - DelegatedBalance: sdk.NewInt(0), + SafeAddressOnStride: safeAddress, + RemainingDelegatedBalance: sdk.NewInt(0), }) // we're halting the zone to test that the tx works even when the host zone is halted @@ -213,7 +213,7 @@ func (s *KeeperTestSuite) TestAdjustDelegatedBalance() { s.Require().NoError(err, "no error expected when adjusting delegated bal properly for %s", tc.address) hostZone := s.MustGetHostZone() - s.Require().Equal(tc.endDelegation, hostZone.DelegatedBalance, "delegation after change for %s", tc.address) + s.Require().Equal(tc.endDelegation, hostZone.RemainingDelegatedBalance, "delegation after change for %s", tc.address) } // Attempt to call it with an amount that would make it negative, it should fail @@ -233,7 +233,6 @@ func (s *KeeperTestSuite) TestAdjustDelegatedBalance() { s.App.StaketiaKeeper.RemoveHostZone(s.Ctx) _, err = s.GetMsgServer().AdjustDelegatedBalance(s.Ctx, &types.MsgAdjustDelegatedBalance{}) s.Require().ErrorContains(err, "host zone not found") - } // ---------------------------------------------- diff --git a/x/staketia/keeper/unbonding.go b/x/staketia/keeper/unbonding.go index f0377797f..7ed70cfe0 100644 --- a/x/staketia/keeper/unbonding.go +++ b/x/staketia/keeper/unbonding.go @@ -176,17 +176,21 @@ func (k Keeper) ConfirmUndelegation(ctx sdk.Context, recordId uint64, txHash str } // Note: we're intentionally not checking that the host zone is halted, because we still want to process this tx in that case - hostZone, err := k.GetHostZone(ctx) + staketiaHostZone, err := k.GetHostZone(ctx) if err != nil { return err } + stakeibcHostZone, found := k.stakeibcKeeper.GetHostZone(ctx, types.CelestiaChainId) + if !found { + return types.ErrHostZoneNotFound.Wrapf("host zone not found from stakeibc") + } // sanity check: store down the stToken supply and DelegatedBalance for checking against after burn - stDenom := utils.StAssetDenomFromHostZoneDenom(hostZone.NativeTokenDenom) + stDenom := utils.StAssetDenomFromHostZoneDenom(staketiaHostZone.NativeTokenDenom) // update the record's txhash, status, and unbonding completion time - unbondingLength := time.Duration(hostZone.UnbondingPeriodSeconds) * time.Second // 21 days - unbondingCompletionTime := uint64(ctx.BlockTime().Add(unbondingLength).Unix()) // now + 21 days + unbondingLength := time.Duration(staketiaHostZone.UnbondingPeriodSeconds) * time.Second // 21 days + unbondingCompletionTime := uint64(ctx.BlockTime().Add(unbondingLength).Unix()) // now + 21 days record.UndelegationTxHash = txHash record.Status = types.UNBONDING_IN_PROGRESS @@ -195,18 +199,18 @@ func (k Keeper) ConfirmUndelegation(ctx sdk.Context, recordId uint64, txHash str // update host zone struct's delegated balance amountAddedToDelegation := record.NativeAmount - newDelegatedBalance := hostZone.DelegatedBalance.Sub(amountAddedToDelegation) + newDelegatedBalance := stakeibcHostZone.TotalDelegations.Sub(amountAddedToDelegation) // sanity check: if the new balance is negative, throw an error if newDelegatedBalance.IsNegative() { return errorsmod.Wrapf(types.ErrNegativeNotAllowed, "host zone's delegated balance would be negative after undelegation") } - hostZone.DelegatedBalance = newDelegatedBalance - k.SetHostZone(ctx, hostZone) + stakeibcHostZone.TotalDelegations = newDelegatedBalance + k.stakeibcKeeper.SetHostZone(ctx, stakeibcHostZone) // burn the corresponding stTokens from the redemptionAddress stTokensToBurn := sdk.NewCoins(sdk.NewCoin(stDenom, record.StTokenAmount)) - if err := k.BurnRedeemedStTokens(ctx, stTokensToBurn, hostZone.RedemptionAddress); err != nil { + if err := k.BurnRedeemedStTokens(ctx, stTokensToBurn, staketiaHostZone.RedemptionAddress); err != nil { return errorsmod.Wrapf(err, "unable to burn stTokens in ConfirmUndelegation") } diff --git a/x/staketia/keeper/unbonding_test.go b/x/staketia/keeper/unbonding_test.go index f198a8d5e..344d0e22d 100644 --- a/x/staketia/keeper/unbonding_test.go +++ b/x/staketia/keeper/unbonding_test.go @@ -9,6 +9,7 @@ import ( "github.com/Stride-Labs/stride/v22/app/apptesting" "github.com/Stride-Labs/stride/v22/utils" + stakeibctypes "github.com/Stride-Labs/stride/v22/x/stakeibc/types" "github.com/Stride-Labs/stride/v22/x/staketia/types" ) @@ -438,7 +439,8 @@ type ConfirmUndelegationTestCase struct { amountToUndelegate sdkmath.Int delegatedBalance sdkmath.Int redemptionAccountBalance sdkmath.Int - hostZone types.HostZone + staketiaHostZone types.HostZone + stakeibcHostZone stakeibctypes.HostZone expectedUnbondingTime uint64 } @@ -453,16 +455,21 @@ func (s *KeeperTestSuite) SetupTestConfirmUndelegation(amountToUndelegate sdkmat expectedUnbondingTime := uint64(s.Ctx.BlockTime().Add(time.Minute * 2).Unix()) // Create a host zone with delegatedBalance and RedemptionAddresses - hostZone := types.HostZone{ - DelegatedBalance: delegatedBalance, + staketiaHostZone := types.HostZone{ RedemptionAddress: redemptionAddress.String(), NativeTokenDenom: HostNativeDenom, UnbondingPeriodSeconds: unbondingPeriodSeconds, MinRedemptionRate: sdk.MustNewDecFromStr("0.9"), MaxRedemptionRate: sdk.MustNewDecFromStr("1.2"), - RedemptionRate: sdk.MustNewDecFromStr("1.1"), } - s.App.StaketiaKeeper.SetHostZone(s.Ctx, hostZone) + s.App.StaketiaKeeper.SetHostZone(s.Ctx, staketiaHostZone) + + stakeibcHostZone := stakeibctypes.HostZone{ + ChainId: HostChainId, + RedemptionRate: sdk.MustNewDecFromStr("1.1"), + TotalDelegations: delegatedBalance, + } + s.App.StakeibcKeeper.SetHostZone(s.Ctx, stakeibcHostZone) // Fund the redemption account with tokens that will be burned stTokensInRedemption := sdk.NewCoin(StDenom, redemptionAccountBalance) @@ -470,7 +477,7 @@ func (s *KeeperTestSuite) SetupTestConfirmUndelegation(amountToUndelegate sdkmat // create an unbonding record in status UNBONDING_QUEUE // - stToken amount to burn as if the RR is 1.1 - stTokenAmountToBurn := sdk.NewDecFromInt(amountToUndelegate).Mul(hostZone.RedemptionRate).TruncateInt() + stTokenAmountToBurn := sdk.NewDecFromInt(amountToUndelegate).Mul(stakeibcHostZone.RedemptionRate).TruncateInt() unbondingRecord := types.UnbondingRecord{ Id: 1, Status: types.UNBONDING_QUEUE, @@ -487,7 +494,8 @@ func (s *KeeperTestSuite) SetupTestConfirmUndelegation(amountToUndelegate sdkmat amountToUndelegate: amountToUndelegate, delegatedBalance: delegatedBalance, redemptionAccountBalance: redemptionAccountBalance, - hostZone: hostZone, + stakeibcHostZone: stakeibcHostZone, + staketiaHostZone: staketiaHostZone, expectedUnbondingTime: expectedUnbondingTime, } return tc @@ -517,8 +525,9 @@ func (s *KeeperTestSuite) TestConfirmUndelegation_Success() { s.Require().Equal(expectedRedemptionAccountBalance, actualRedemptionAccountBalance, "redemption account balance") // check that delegated balance was updated - hostZone := s.MustGetHostZone() - s.Require().Equal(tc.delegatedBalance.Sub(tc.amountToUndelegate), hostZone.DelegatedBalance, "delegated balance") + stakeibcHostZone, found := s.App.StakeibcKeeper.GetHostZone(s.Ctx, HostChainId) + s.Require().True(found) + s.Require().Equal(tc.delegatedBalance.Sub(tc.amountToUndelegate), stakeibcHostZone.TotalDelegations, "delegated balance") } // unit test ConfirmUndelegation with nothing to unbond diff --git a/x/staketia/types/expected_keepers.go b/x/staketia/types/expected_keepers.go index cc9970573..c56fadeda 100644 --- a/x/staketia/types/expected_keepers.go +++ b/x/staketia/types/expected_keepers.go @@ -47,4 +47,5 @@ type ICAOracleKeeper interface { // Required StakeibcKeeper functions type StakeibcKeeper interface { GetHostZone(ctx sdk.Context, chainId string) (val stakeibctypes.HostZone, found bool) + SetHostZone(ctx sdk.Context, hostZone stakeibctypes.HostZone) } From a68981c8da6a04c7b579fe3324fc9768060af314 Mon Sep 17 00:00:00 2001 From: sampocs Date: Tue, 4 Jun 2024 17:34:36 -0500 Subject: [PATCH 6/9] removed other redemption rate fields --- proto/stride/staketia/staketia.proto | 31 --- x/staketia/types/staketia.pb.go | 379 +++++---------------------- 2 files changed, 64 insertions(+), 346 deletions(-) diff --git a/proto/stride/staketia/staketia.proto b/proto/stride/staketia/staketia.proto index c09bc4e29..e40d928fd 100644 --- a/proto/stride/staketia/staketia.proto +++ b/proto/stride/staketia/staketia.proto @@ -35,37 +35,6 @@ message HostZone { string safe_address_on_stride = 11 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; - // Previous redemption rate - string last_redemption_rate = 12 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - // Min outer redemption rate - adjusted by governance - string min_redemption_rate = 14 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - // Max outer redemption rate - adjusted by governance - string max_redemption_rate = 15 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - // Min inner redemption rate - adjusted by controller - string min_inner_redemption_rate = 16 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - // Max inner redemption rate - adjusted by controller - string max_inner_redemption_rate = 17 [ - (cosmos_proto.scalar) = "cosmos.Dec", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; - // Total delegated balance on the host zone delegation account string remaining_delegated_balance = 18 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", diff --git a/x/staketia/types/staketia.pb.go b/x/staketia/types/staketia.pb.go index 72ba89366..c99023459 100644 --- a/x/staketia/types/staketia.pb.go +++ b/x/staketia/types/staketia.pb.go @@ -142,16 +142,6 @@ type HostZone struct { OperatorAddressOnStride string `protobuf:"bytes,10,opt,name=operator_address_on_stride,json=operatorAddressOnStride,proto3" json:"operator_address_on_stride,omitempty"` // admin address set upon host zone creation, on stride SafeAddressOnStride string `protobuf:"bytes,11,opt,name=safe_address_on_stride,json=safeAddressOnStride,proto3" json:"safe_address_on_stride,omitempty"` - // Previous redemption rate - LastRedemptionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,12,opt,name=last_redemption_rate,json=lastRedemptionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"last_redemption_rate"` - // Min outer redemption rate - adjusted by governance - MinRedemptionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,14,opt,name=min_redemption_rate,json=minRedemptionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_redemption_rate"` - // Max outer redemption rate - adjusted by governance - MaxRedemptionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,15,opt,name=max_redemption_rate,json=maxRedemptionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_redemption_rate"` - // Min inner redemption rate - adjusted by controller - MinInnerRedemptionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,16,opt,name=min_inner_redemption_rate,json=minInnerRedemptionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"min_inner_redemption_rate"` - // Max inner redemption rate - adjusted by controller - MaxInnerRedemptionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,17,opt,name=max_inner_redemption_rate,json=maxInnerRedemptionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_inner_redemption_rate"` // Total delegated balance on the host zone delegation account RemainingDelegatedBalance github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,18,opt,name=remaining_delegated_balance,json=remainingDelegatedBalance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"remaining_delegated_balance"` // The undelegation period for Celestia in days @@ -579,78 +569,71 @@ func init() { func init() { proto.RegisterFile("stride/staketia/staketia.proto", fileDescriptor_d306d9365b78f7b2) } var fileDescriptor_d306d9365b78f7b2 = []byte{ - // 1124 bytes of a gzipped FileDescriptorProto + // 1024 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x4f, 0x6f, 0x1a, 0xc7, - 0x1b, 0x66, 0x81, 0xd8, 0xe4, 0xb5, 0x81, 0x65, 0x20, 0x64, 0xed, 0x5f, 0x44, 0xf2, 0xf3, 0x21, - 0x8d, 0xd2, 0x1a, 0x57, 0xce, 0xa5, 0x87, 0x36, 0x11, 0x86, 0x8d, 0xb3, 0x15, 0xc6, 0xee, 0x02, - 0x3d, 0xe4, 0xb2, 0x1a, 0x76, 0x27, 0xb0, 0x0a, 0x3b, 0x8b, 0x76, 0x06, 0x9b, 0x4a, 0xfd, 0x00, - 0x95, 0x7a, 0xe9, 0xa5, 0x9f, 0xa0, 0x1f, 0xa1, 0xb9, 0xf4, 0x1b, 0x44, 0xea, 0x25, 0xcd, 0xa9, - 0xea, 0x21, 0xaa, 0xec, 0x2f, 0x52, 0xed, 0xec, 0x1f, 0x30, 0x60, 0xa1, 0x54, 0x5c, 0x7a, 0xda, - 0x9d, 0x79, 0xde, 0xf7, 0x79, 0x66, 0xde, 0x77, 0xe6, 0x7d, 0x07, 0x2a, 0x8c, 0x7b, 0xb6, 0x45, - 0x0e, 0x18, 0xc7, 0xaf, 0x09, 0xb7, 0x71, 0xfc, 0x53, 0x1d, 0x79, 0x2e, 0x77, 0x51, 0x3e, 0xc0, - 0xab, 0xd1, 0xf4, 0xee, 0x8e, 0xe9, 0x32, 0xc7, 0x65, 0x86, 0x80, 0x0f, 0x82, 0x41, 0x60, 0xbb, - 0x5b, 0xea, 0xbb, 0x7d, 0x37, 0x98, 0xf7, 0xff, 0x82, 0xd9, 0xbd, 0xdf, 0xb6, 0x20, 0xf3, 0xc2, - 0x65, 0xfc, 0xa5, 0x4b, 0x09, 0xda, 0x81, 0x8c, 0x39, 0xc0, 0x36, 0x35, 0x6c, 0x4b, 0x91, 0x1e, - 0x48, 0x8f, 0x6e, 0xeb, 0x9b, 0x62, 0xac, 0x59, 0xe8, 0x33, 0x40, 0x14, 0x73, 0xfb, 0x9c, 0x18, - 0xdc, 0x7d, 0x4d, 0xa8, 0x61, 0x11, 0xea, 0x3a, 0x4a, 0x52, 0x18, 0xc9, 0x01, 0xd2, 0xf1, 0x81, - 0x86, 0x3f, 0x8f, 0x9e, 0x40, 0xf9, 0x9a, 0xb5, 0xdd, 0x33, 0x43, 0x8f, 0x94, 0xf0, 0x28, 0xce, - 0x78, 0x68, 0x3d, 0x33, 0x70, 0xaa, 0x42, 0x91, 0x7b, 0x98, 0xb2, 0x57, 0xc4, 0x33, 0xcc, 0x01, - 0xa6, 0x94, 0x0c, 0xfd, 0x85, 0xa4, 0x85, 0x47, 0x21, 0x82, 0xea, 0x01, 0xa2, 0x59, 0xe8, 0x18, - 0x90, 0x45, 0x86, 0xa4, 0x8f, 0xb9, 0xed, 0x52, 0x03, 0x5b, 0x96, 0x47, 0x18, 0x53, 0x6e, 0xf9, - 0xe6, 0x47, 0xca, 0xfb, 0x37, 0xfb, 0xa5, 0x70, 0xfb, 0xb5, 0x00, 0x69, 0x73, 0xcf, 0xa6, 0x7d, - 0xbd, 0x30, 0xf5, 0x09, 0x01, 0xf4, 0x0c, 0x72, 0x1e, 0xb9, 0xc0, 0x9e, 0x15, 0x93, 0x6c, 0xac, - 0x20, 0xc9, 0x06, 0xf6, 0x11, 0x41, 0x0d, 0xf2, 0x16, 0x19, 0xb9, 0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 0x13, 0x63, 0x80, 0xd9, 0x20, 0xac, 0xef, - 0x1b, 0x7c, 0xf2, 0x02, 0xb3, 0xc1, 0xde, 0xef, 0x29, 0xc8, 0x77, 0xa3, 0x60, 0xdc, 0xb0, 0xa5, - 0xa7, 0xb1, 0x7a, 0x52, 0xa8, 0x3f, 0x5c, 0x50, 0x9f, 0x63, 0x98, 0x13, 0xff, 0x16, 0xf2, 0x8c, - 0x87, 0x9d, 0x29, 0x0c, 0x4a, 0xea, 0x5f, 0x05, 0x25, 0xcb, 0xb8, 0x68, 0x61, 0x61, 0x54, 0x16, - 0x42, 0x9d, 0x5e, 0x43, 0xa8, 0x35, 0xf8, 0xff, 0xf4, 0xf0, 0x98, 0xae, 0x33, 0x1a, 0x12, 0x71, - 0x4b, 0xb8, 0xed, 0x90, 0xf8, 0x14, 0xdd, 0x12, 0xb1, 0xa9, 0xc4, 0x86, 0xf5, 0xd8, 0xae, 0x63, - 0x3b, 0x24, 0x3a, 0x4d, 0x9f, 0x43, 0x69, 0x4c, 0x67, 0x5a, 0x66, 0x94, 0x01, 0xd1, 0xed, 0x74, - 0x34, 0x8b, 0x75, 0x44, 0x36, 0xd0, 0x53, 0xb8, 0x17, 0x70, 0x12, 0x2b, 0x8c, 0x17, 0xbb, 0x20, - 0x64, 0x14, 0x7b, 0x8a, 0x2e, 0xa7, 0x2b, 0x91, 0x8d, 0x08, 0x46, 0xdb, 0xb7, 0x08, 0xfc, 0xf7, - 0x7e, 0x4c, 0x82, 0x3c, 0x73, 0xf9, 0x82, 0x74, 0x56, 0xa1, 0x38, 0xdd, 0x91, 0x27, 0xe6, 0x8c, - 0x38, 0xbf, 0x85, 0xf1, 0xf5, 0xd4, 0x69, 0x16, 0xda, 0x85, 0x8c, 0x5f, 0x1d, 0x88, 0x43, 0xbc, - 0xf0, 0xc1, 0x11, 0x8f, 0xff, 0x53, 0xa9, 0xdc, 0xfb, 0x55, 0x82, 0xad, 0xf6, 0x10, 0xb3, 0xc1, - 0x0d, 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0x05, 0xaa, 0xb0, 0x4a, 0xe8, 0x98, 0x0b, 0x4f, 0x26, 0x0a, 0x0b, 0x73, 0x14, 0x56, 0x34, 0x21, + 0x96, 0x38, 0x02, 0x14, 0x50, 0x42, 0xfd, 0xf1, 0xb5, 0xcb, 0xe4, 0xe7, 0x5d, 0x66, 0xca, 0x89, + 0x85, 0x3e, 0x87, 0x42, 0x7f, 0x84, 0x3d, 0x3f, 0xd1, 0x58, 0x9c, 0xa3, 0xb1, 0xac, 0xdc, 0x63, + 0x7a, 0x17, 0xb6, 0xf8, 0x98, 0x06, 0x58, 0xf2, 0x20, 0x56, 0x70, 0x39, 0x73, 0xa3, 0x3a, 0xb3, + 0x60, 0x8e, 0xd6, 0x46, 0xcc, 0xd5, 0xe6, 0x13, 0xd6, 0x56, 0x44, 0x74, 0x0c, 0xeb, 0x02, 0xbf, + 0xa2, 0x77, 0x48, 0x2e, 0xcd, 0x91, 0x2c, 0x86, 0xbc, 0x9b, 0x72, 0x0c, 0xfe, 0x17, 0x50, 0x1f, + 0x7b, 0xcc, 0x63, 0x03, 0x57, 0x27, 0x94, 0x12, 0xb7, 0x87, 0x47, 0x98, 0xf5, 0xa9, 0x85, 0x94, + 0x66, 0xe5, 0xcd, 0xbb, 0x87, 0xa9, 0x3f, 0xde, 0x3d, 0x7c, 0x34, 0xf0, 0xe4, 0x70, 0xd2, 0xab, + 0xf4, 0xb9, 0xaf, 0x3b, 0x42, 0xff, 0xec, 0x09, 0x72, 0xb6, 0x2f, 0xbf, 0x1e, 0x53, 0x51, 0x69, + 0x30, 0xe9, 0x6c, 0x26, 0x92, 0xf5, 0x58, 0xf1, 0x30, 0x12, 0x44, 0x9f, 0x81, 0x35, 0x61, 0x3d, + 0xce, 0x48, 0xb8, 0xdf, 0x98, 0x06, 0x1e, 0x27, 0xae, 0xa0, 0x7d, 0xce, 0x88, 0xb0, 0x8a, 0xdb, + 0xc6, 0x6e, 0xd6, 0x59, 0x4f, 0xf0, 0x53, 0x05, 0x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d, 0xb5, 0xcd, 0x34, 0xda, 0x80, 0xe2, 0x8c, 0xb5, 0x76, 0x72, 0x7c, + 0xda, 0xb4, 0x3b, 0xb6, 0x99, 0xd9, 0xca, 0x7e, 0xfb, 0x63, 0x39, 0xf5, 0xf8, 0x07, 0x03, 0xee, + 0xdf, 0xd9, 0xcd, 0xe8, 0x01, 0x58, 0xd5, 0x5a, 0xad, 0x7b, 0xdc, 0x6d, 0x56, 0x3b, 0x8d, 0xd6, + 0x91, 0xeb, 0xd8, 0x75, 0xfb, 0xf8, 0x34, 0x54, 0xd1, 0x27, 0xe8, 0xb6, 0x0e, 0x4f, 0x5a, 0xf5, + 0x10, 0x8a, 0xf6, 0x32, 0xd0, 0x26, 0xdc, 0x9f, 0x1a, 0x67, 0x4f, 0x9c, 0x46, 0xcb, 0x90, 0x8f, + 0x20, 0xbb, 0x6e, 0x66, 0x50, 0x01, 0x16, 0x6b, 0xcd, 0x6a, 0xe3, 0xb8, 0x7a, 0xd8, 0xb4, 0xcd, + 0x2c, 0x5a, 0x82, 0x05, 0xb5, 0xb4, 0xeb, 0xe6, 0xbd, 0xe8, 0x5c, 0x87, 0xcd, 0x37, 0x97, 0x65, + 0xe3, 0xed, 0x65, 0xd9, 0xf8, 0xf3, 0xb2, 0x6c, 0x7c, 0x7f, 0x55, 0x4e, 0xbd, 0xbd, 0x2a, 0xa7, + 0x7e, 0xbf, 0x2a, 0xa7, 0x5e, 0x1e, 0xcc, 0xa4, 0x24, 0xfa, 0xc3, 0xd9, 0x6b, 0xe2, 0x9e, 0xd8, + 0xd7, 0x8f, 0xb1, 0xf3, 0x83, 0x83, 0xfd, 0x8b, 0xe9, 0x93, 0x4c, 0xa5, 0xa8, 0x97, 0x53, 0xcf, + 0xa9, 0x27, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0x48, 0x5b, 0x05, 0xbc, 0xb2, 0x09, 0x00, 0x00, } func (m *HostZone) Marshal() (dAtA []byte, err error) { @@ -704,60 +687,6 @@ func (m *HostZone) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x1 i-- dAtA[i] = 0x92 - { - size := m.MaxInnerRedemptionRate.Size() - i -= size - if _, err := m.MaxInnerRedemptionRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaketia(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x8a - { - size := m.MinInnerRedemptionRate.Size() - i -= size - if _, err := m.MinInnerRedemptionRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaketia(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0x82 - { - size := m.MaxRedemptionRate.Size() - i -= size - if _, err := m.MaxRedemptionRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaketia(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x7a - { - size := m.MinRedemptionRate.Size() - i -= size - if _, err := m.MinRedemptionRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaketia(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x72 - { - size := m.LastRedemptionRate.Size() - i -= size - if _, err := m.LastRedemptionRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaketia(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x62 if len(m.SafeAddressOnStride) > 0 { i -= len(m.SafeAddressOnStride) copy(dAtA[i:], m.SafeAddressOnStride) @@ -1126,16 +1055,6 @@ func (m *HostZone) Size() (n int) { if l > 0 { n += 1 + l + sovStaketia(uint64(l)) } - l = m.LastRedemptionRate.Size() - n += 1 + l + sovStaketia(uint64(l)) - l = m.MinRedemptionRate.Size() - n += 1 + l + sovStaketia(uint64(l)) - l = m.MaxRedemptionRate.Size() - n += 1 + l + sovStaketia(uint64(l)) - l = m.MinInnerRedemptionRate.Size() - n += 2 + l + sovStaketia(uint64(l)) - l = m.MaxInnerRedemptionRate.Size() - n += 2 + l + sovStaketia(uint64(l)) l = m.RemainingDelegatedBalance.Size() n += 2 + l + sovStaketia(uint64(l)) if m.UnbondingPeriodSeconds != 0 { @@ -1626,176 +1545,6 @@ func (m *HostZone) Unmarshal(dAtA []byte) error { } m.SafeAddressOnStride = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 12: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LastRedemptionRate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaketia - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStaketia - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaketia - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.LastRedemptionRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 14: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinRedemptionRate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaketia - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStaketia - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaketia - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MinRedemptionRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 15: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxRedemptionRate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaketia - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStaketia - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaketia - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MaxRedemptionRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 16: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinInnerRedemptionRate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaketia - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStaketia - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaketia - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MinInnerRedemptionRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 17: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxInnerRedemptionRate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaketia - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStaketia - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaketia - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MaxInnerRedemptionRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 18: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field RemainingDelegatedBalance", wireType) From f7955d5a0d6322bff4c0ea38d74f1a4457c0ff28 Mon Sep 17 00:00:00 2001 From: sampocs Date: Tue, 4 Jun 2024 17:46:31 -0500 Subject: [PATCH 7/9] updated first batch of redemption rate references --- x/staketia/keeper/delegation.go | 2 +- x/staketia/keeper/delegation_test.go | 40 ++++---- x/staketia/keeper/events.go | 1 - x/staketia/keeper/host_zone_test.go | 31 +++---- x/staketia/keeper/invariants.go | 2 +- x/staketia/keeper/msg_server.go | 4 +- x/staketia/keeper/msg_server_test.go | 44 --------- x/staketia/keeper/unbonding.go | 6 +- x/staketia/types/expected_keepers.go | 1 + x/staketia/types/host_zone.go | 40 -------- x/staketia/types/host_zone_test.go | 133 --------------------------- 11 files changed, 39 insertions(+), 265 deletions(-) diff --git a/x/staketia/keeper/delegation.go b/x/staketia/keeper/delegation.go index cefef6d34..ddf7487a0 100644 --- a/x/staketia/keeper/delegation.go +++ b/x/staketia/keeper/delegation.go @@ -49,7 +49,7 @@ func (k Keeper) LiquidStake(ctx sdk.Context, liquidStaker string, nativeAmount s } // Determine the amount of stTokens to mint using the redemption rate - stAmount := (sdk.NewDecFromInt(nativeAmount).Quo(hostZone.RedemptionRate)).TruncateInt() + stAmount := sdkmath.ZeroInt() // temporary to prevent lint error - this full function is removed in a different PR if stAmount.IsZero() { return stToken, errorsmod.Wrapf(stakeibctypes.ErrInsufficientLiquidStake, "Liquid stake of %s%s would return 0 stTokens", nativeAmount.String(), hostZone.NativeTokenDenom) diff --git a/x/staketia/keeper/delegation_test.go b/x/staketia/keeper/delegation_test.go index 7484288cc..06aa2f64b 100644 --- a/x/staketia/keeper/delegation_test.go +++ b/x/staketia/keeper/delegation_test.go @@ -37,15 +37,15 @@ func (s *KeeperTestSuite) SetupTestLiquidStake( // Create a host zone with relevant denom's and addresses s.App.StaketiaKeeper.SetHostZone(s.Ctx, types.HostZone{ - ChainId: HostChainId, - NativeTokenDenom: HostNativeDenom, - NativeTokenIbcDenom: HostIBCDenom, - DepositAddress: depositAddress.String(), - RedemptionRate: redemptionRate, - MinRedemptionRate: redemptionRate.Sub(sdk.MustNewDecFromStr("0.2")), - MinInnerRedemptionRate: redemptionRate.Sub(sdk.MustNewDecFromStr("0.1")), - MaxInnerRedemptionRate: redemptionRate.Add(sdk.MustNewDecFromStr("0.1")), - MaxRedemptionRate: redemptionRate.Add(sdk.MustNewDecFromStr("0.2")), + ChainId: HostChainId, + NativeTokenDenom: HostNativeDenom, + NativeTokenIbcDenom: HostIBCDenom, + DepositAddress: depositAddress.String(), + // RedemptionRate: redemptionRate, + // MinRedemptionRate: redemptionRate.Sub(sdk.MustNewDecFromStr("0.2")), + // MinInnerRedemptionRate: redemptionRate.Sub(sdk.MustNewDecFromStr("0.1")), + // MaxInnerRedemptionRate: redemptionRate.Add(sdk.MustNewDecFromStr("0.1")), + // MaxRedemptionRate: redemptionRate.Add(sdk.MustNewDecFromStr("0.2")), }) // Fund the staker @@ -191,7 +191,7 @@ func (s *KeeperTestSuite) TestLiquidStake_InvalidRedemptionRate() { // Update the redemption rate so it exceeds the bounds hostZone := s.MustGetHostZone() - hostZone.RedemptionRate = hostZone.MaxInnerRedemptionRate.Add(sdk.MustNewDecFromStr("0.01")) + // hostZone.RedemptionRate = hostZone.MaxInnerRedemptionRate.Add(sdk.MustNewDecFromStr("0.01")) s.App.StaketiaKeeper.SetHostZone(s.Ctx, hostZone) _, err := s.App.StaketiaKeeper.LiquidStake(s.Ctx, tc.stakerAddress.String(), tc.liquidStakeAmount) @@ -501,20 +501,20 @@ func (s *KeeperTestSuite) TestLiquidStakeAndDistributeFees() { // Liquid stake 1000 with a RR of 2, should return 500 tokens liquidStakeAmount := sdkmath.NewInt(1000) - redemptionRate := sdk.NewDec(2) + // redemptionRate := sdk.NewDec(2) expectedStTokens := sdkmath.NewInt(500) // Create a host zone with relevant denom's and addresses hostZone := types.HostZone{ - ChainId: HostChainId, - NativeTokenDenom: HostNativeDenom, - NativeTokenIbcDenom: HostIBCDenom, - DepositAddress: depositAddress.String(), - RedemptionRate: redemptionRate, - MinRedemptionRate: redemptionRate.Sub(sdk.MustNewDecFromStr("0.2")), - MinInnerRedemptionRate: redemptionRate.Sub(sdk.MustNewDecFromStr("0.1")), - MaxInnerRedemptionRate: redemptionRate.Add(sdk.MustNewDecFromStr("0.1")), - MaxRedemptionRate: redemptionRate.Add(sdk.MustNewDecFromStr("0.2")), + ChainId: HostChainId, + NativeTokenDenom: HostNativeDenom, + NativeTokenIbcDenom: HostIBCDenom, + DepositAddress: depositAddress.String(), + // RedemptionRate: redemptionRate, + // MinRedemptionRate: redemptionRate.Sub(sdk.MustNewDecFromStr("0.2")), + // MinInnerRedemptionRate: redemptionRate.Sub(sdk.MustNewDecFromStr("0.1")), + // MaxInnerRedemptionRate: redemptionRate.Add(sdk.MustNewDecFromStr("0.1")), + // MaxRedemptionRate: redemptionRate.Add(sdk.MustNewDecFromStr("0.2")), } s.App.StaketiaKeeper.SetHostZone(s.Ctx, hostZone) diff --git a/x/staketia/keeper/events.go b/x/staketia/keeper/events.go index 674745a1c..5f88955ff 100644 --- a/x/staketia/keeper/events.go +++ b/x/staketia/keeper/events.go @@ -90,7 +90,6 @@ func EmitHaltZoneEvent(ctx sdk.Context, hostZone types.HostZone) { sdk.NewEvent( types.EventTypeHostZoneHalt, sdk.NewAttribute(types.AttributeKeyHostZone, hostZone.ChainId), - sdk.NewAttribute(types.AttributeKeyRedemptionRate, hostZone.RedemptionRate.String()), ), ) } diff --git a/x/staketia/keeper/host_zone_test.go b/x/staketia/keeper/host_zone_test.go index 0141c6345..1a47b6fe9 100644 --- a/x/staketia/keeper/host_zone_test.go +++ b/x/staketia/keeper/host_zone_test.go @@ -9,23 +9,17 @@ import ( // Helper function to create the singleton HostZone with attributes func (s *KeeperTestSuite) initializeHostZone() types.HostZone { hostZone := types.HostZone{ - ChainId: "CELESTIA", - NativeTokenDenom: "utia", - NativeTokenIbcDenom: "ibc/utia", - TransferChannelId: "channel-05", - DelegationAddress: "tia0384a", - RewardAddress: "tia144f42e9", - DepositAddress: "stride8abb3e", - RedemptionAddress: "stride3400de1", - ClaimAddress: "stride00b1a83", - LastRedemptionRate: sdk.MustNewDecFromStr("1.0"), - RedemptionRate: sdk.MustNewDecFromStr("1.0"), - MinRedemptionRate: sdk.MustNewDecFromStr("0.95"), - MaxRedemptionRate: sdk.MustNewDecFromStr("1.10"), - MinInnerRedemptionRate: sdk.MustNewDecFromStr("0.97"), - MaxInnerRedemptionRate: sdk.MustNewDecFromStr("1.07"), - DelegatedBalance: sdk.NewInt(1_000_000), - Halted: false, + ChainId: "CELESTIA", + NativeTokenDenom: "utia", + NativeTokenIbcDenom: "ibc/utia", + TransferChannelId: "channel-05", + DelegationAddress: "tia0384a", + RewardAddress: "tia144f42e9", + DepositAddress: "stride8abb3e", + RedemptionAddress: "stride3400de1", + ClaimAddress: "stride00b1a83", + RemainingDelegatedBalance: sdk.NewInt(1_000_000), + Halted: false, } s.App.StaketiaKeeper.SetHostZone(s.Ctx, hostZone) return hostZone @@ -47,8 +41,7 @@ func (s *KeeperTestSuite) TestRemoveHostZone() { func (s *KeeperTestSuite) TestSetHostZone() { hostZone := s.initializeHostZone() - hostZone.RedemptionRate = hostZone.RedemptionRate.Add(sdk.MustNewDecFromStr("0.1")) - hostZone.DelegatedBalance = hostZone.DelegatedBalance.Add(sdk.NewInt(100_000)) + hostZone.RemainingDelegatedBalance = hostZone.RemainingDelegatedBalance.Add(sdk.NewInt(100_000)) s.App.StaketiaKeeper.SetHostZone(s.Ctx, hostZone) loadedHostZone := s.MustGetHostZone() diff --git a/x/staketia/keeper/invariants.go b/x/staketia/keeper/invariants.go index 562caa9af..58f883b23 100644 --- a/x/staketia/keeper/invariants.go +++ b/x/staketia/keeper/invariants.go @@ -24,7 +24,7 @@ func (k Keeper) HaltZone(ctx sdk.Context) { stDenom := utils.StAssetDenomFromHostZoneDenom(hostZone.NativeTokenDenom) k.ratelimitKeeper.AddDenomToBlacklist(ctx, stDenom) - k.Logger(ctx).Error(fmt.Sprintf("[INVARIANT BROKEN!!!] %s's RR is %s.", hostZone.GetChainId(), hostZone.RedemptionRate.String())) + k.Logger(ctx).Error(fmt.Sprintf("[INVARIANT BROKEN!!!] %s's RR is %s.", hostZone.GetChainId())) EmitHaltZoneEvent(ctx, hostZone) } diff --git a/x/staketia/keeper/msg_server.go b/x/staketia/keeper/msg_server.go index a956cbd65..417a97638 100644 --- a/x/staketia/keeper/msg_server.go +++ b/x/staketia/keeper/msg_server.go @@ -211,9 +211,7 @@ func (k msgServer) RefreshRedemptionRate(goCtx context.Context, msgTriggerRedemp return nil, err } - err := k.UpdateRedemptionRate(ctx) - - return &types.MsgRefreshRedemptionRateResponse{}, err + return &types.MsgRefreshRedemptionRateResponse{}, nil } // overwrite a delegation record diff --git a/x/staketia/keeper/msg_server_test.go b/x/staketia/keeper/msg_server_test.go index 027f24b7e..9700042f9 100644 --- a/x/staketia/keeper/msg_server_test.go +++ b/x/staketia/keeper/msg_server_test.go @@ -374,50 +374,6 @@ func (s *KeeperTestSuite) TestResumeHostZone() { s.Require().ErrorContains(err, "signer is not an admin") } -// ---------------------------------------------- -// MsgRefreshRedemptionRate -// ---------------------------------------------- - -func (s *KeeperTestSuite) TestRefreshRedemptionRate() { - safeAddress := "safe" - depositAddress := s.TestAccs[0] - redemptionAddress := s.TestAccs[1] - - // Create host zone with initial redemption rate of 1 - // There will be 1000 delegated tokens, and 500 stTokens - // implying an updated redemption rate of 2 - initialRedemptionRate := sdk.OneDec() - expectedRedemptionRate := sdk.NewDec(2) - - s.App.StaketiaKeeper.SetHostZone(s.Ctx, types.HostZone{ - DelegatedBalance: sdkmath.NewInt(1000), - RedemptionRate: initialRedemptionRate, - NativeTokenDenom: HostNativeDenom, - NativeTokenIbcDenom: HostIBCDenom, - SafeAddressOnStride: safeAddress, - DepositAddress: depositAddress.String(), - }) - - // Mint 500 stTokens (implying a redemption rate of 2) - s.FundAccount(redemptionAddress, sdk.NewCoin(StDenom, sdkmath.NewInt(500))) - - // Attempt to refresh the rate with a non-safe address, it should fail - _, err := s.GetMsgServer().RefreshRedemptionRate(s.Ctx, &types.MsgRefreshRedemptionRate{ - Creator: "non-admin", - }) - s.Require().ErrorContains(err, "signer is not an admin") - - // Attempt to refresh the rate with the safe address, it should succeed - _, err = s.GetMsgServer().RefreshRedemptionRate(s.Ctx, &types.MsgRefreshRedemptionRate{ - Creator: safeAddress, - }) - s.Require().NoError(err, "no error expected when using safe address") - - // Confirm the redemption rate was updated - hostZone := s.MustGetHostZone() - s.Require().Equal(expectedRedemptionRate, hostZone.RedemptionRate) -} - // ---------------------------------------------- // MsgOverwriteDelgationRecord // ---------------------------------------------- diff --git a/x/staketia/keeper/unbonding.go b/x/staketia/keeper/unbonding.go index 7ed70cfe0..c3ae5f163 100644 --- a/x/staketia/keeper/unbonding.go +++ b/x/staketia/keeper/unbonding.go @@ -180,9 +180,9 @@ func (k Keeper) ConfirmUndelegation(ctx sdk.Context, recordId uint64, txHash str if err != nil { return err } - stakeibcHostZone, found := k.stakeibcKeeper.GetHostZone(ctx, types.CelestiaChainId) - if !found { - return types.ErrHostZoneNotFound.Wrapf("host zone not found from stakeibc") + stakeibcHostZone, err := k.stakeibcKeeper.GetActiveHostZone(ctx, types.CelestiaChainId) + if err != nil { + return err } // sanity check: store down the stToken supply and DelegatedBalance for checking against after burn diff --git a/x/staketia/types/expected_keepers.go b/x/staketia/types/expected_keepers.go index c56fadeda..6e1fd143b 100644 --- a/x/staketia/types/expected_keepers.go +++ b/x/staketia/types/expected_keepers.go @@ -47,5 +47,6 @@ type ICAOracleKeeper interface { // Required StakeibcKeeper functions type StakeibcKeeper interface { GetHostZone(ctx sdk.Context, chainId string) (val stakeibctypes.HostZone, found bool) + GetActiveHostZone(ctx sdk.Context, chainId string) (hostZone stakeibctypes.HostZone, err error) SetHostZone(ctx sdk.Context, hostZone stakeibctypes.HostZone) } diff --git a/x/staketia/types/host_zone.go b/x/staketia/types/host_zone.go index c5b9ee25e..d50b833b4 100644 --- a/x/staketia/types/host_zone.go +++ b/x/staketia/types/host_zone.go @@ -76,14 +76,6 @@ func (h HostZone) ValidateGenesis() error { return errorsmod.Wrapf(err, "invalid safe address") } - // Validate the redemption rate bounds are set properly - if !h.RedemptionRate.IsPositive() { - return ErrInvalidHostZone.Wrap("redemption rate must be positive") - } - if err := h.ValidateRedemptionRateBoundsInitalized(); err != nil { - return err - } - // Validate unbonding period is set if h.UnbondingPeriodSeconds == 0 { return ErrInvalidHostZone.Wrap("unbonding period must be set") @@ -91,35 +83,3 @@ func (h HostZone) ValidateGenesis() error { return nil } - -// Verify the redemption rate bounds are set properly on the host zone -func (h HostZone) ValidateRedemptionRateBoundsInitalized() error { - // Validate outer bounds are set - if h.MinRedemptionRate.IsNil() || !h.MinRedemptionRate.IsPositive() { - return ErrInvalidRedemptionRateBounds.Wrapf("min outer redemption rate bound not set") - } - if h.MaxRedemptionRate.IsNil() || !h.MaxRedemptionRate.IsPositive() { - return ErrInvalidRedemptionRateBounds.Wrapf("max outer redemption rate bound not set") - } - - // Validate inner bounds set - if h.MinInnerRedemptionRate.IsNil() || !h.MinInnerRedemptionRate.IsPositive() { - return ErrInvalidRedemptionRateBounds.Wrapf("min inner redemption rate bound not set") - } - if h.MaxInnerRedemptionRate.IsNil() || !h.MaxInnerRedemptionRate.IsPositive() { - return ErrInvalidRedemptionRateBounds.Wrapf("max inner redemption rate bound not set") - } - - // Validate inner bounds are within outer bounds - if h.MinInnerRedemptionRate.LT(h.MinRedemptionRate) { - return ErrInvalidRedemptionRateBounds.Wrapf("min inner redemption rate bound outside of min outer bound") - } - if h.MaxInnerRedemptionRate.GT(h.MaxRedemptionRate) { - return ErrInvalidRedemptionRateBounds.Wrapf("max inner redemption rate bound outside of max outer bound") - } - if h.MinInnerRedemptionRate.GT(h.MaxInnerRedemptionRate) { - return ErrInvalidRedemptionRateBounds.Wrapf("min inner redemption rate greater than max inner bound") - } - - return nil -} diff --git a/x/staketia/types/host_zone_test.go b/x/staketia/types/host_zone_test.go index ca4c49212..b23b3d219 100644 --- a/x/staketia/types/host_zone_test.go +++ b/x/staketia/types/host_zone_test.go @@ -3,7 +3,6 @@ package types_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" "github.com/stretchr/testify/require" @@ -52,14 +51,6 @@ func fillDefaultHostZone(hostZone types.HostZone) types.HostZone { hostZone.OperatorAddressOnStride = fillDefaultValue(hostZone.OperatorAddressOnStride, validAddress) hostZone.SafeAddressOnStride = fillDefaultValue(hostZone.SafeAddressOnStride, validAddress) - if hostZone.RedemptionRate.IsNil() { - hostZone.RedemptionRate = sdk.OneDec() - hostZone.MinRedemptionRate = sdk.MustNewDecFromStr("0.8") - hostZone.MinInnerRedemptionRate = sdk.MustNewDecFromStr("0.9") - hostZone.MaxInnerRedemptionRate = sdk.MustNewDecFromStr("1.1") - hostZone.MaxRedemptionRate = sdk.MustNewDecFromStr("1.2") - } - if hostZone.UnbondingPeriodSeconds == UninitializedInt { hostZone.UnbondingPeriodSeconds = 0 // invalid } else { @@ -200,22 +191,6 @@ func TestValidateHostZoneGenesis(t *testing.T) { }, expectedError: "invalid safe address", }, - { - name: "invalid redemption rate", - hostZone: types.HostZone{ - RedemptionRate: sdk.OneDec().Neg(), - }, - expectedError: "redemption rate must be positive", - }, - { - name: "invalid redemption rate bounds", - hostZone: types.HostZone{ - RedemptionRate: sdk.OneDec(), - MinRedemptionRate: sdk.MustNewDecFromStr("1.1"), - MinInnerRedemptionRate: sdk.MustNewDecFromStr("0.9"), - }, - expectedError: "invalid host zone redemption rate inner bounds", - }, { name: "missing unbonding period", hostZone: types.HostZone{ @@ -238,111 +213,3 @@ func TestValidateHostZoneGenesis(t *testing.T) { }) } } - -func TestValidateRedemptionRateBoundsInitalized(t *testing.T) { - testCases := []struct { - name string - hostZone types.HostZone - valid bool - }{ - { - name: "valid bounds", - hostZone: types.HostZone{ - MinRedemptionRate: sdk.MustNewDecFromStr("0.8"), - MinInnerRedemptionRate: sdk.MustNewDecFromStr("0.9"), - RedemptionRate: sdk.MustNewDecFromStr("1.0"), - MaxInnerRedemptionRate: sdk.MustNewDecFromStr("1.1"), - MaxRedemptionRate: sdk.MustNewDecFromStr("1.2"), - }, - valid: true, - }, - { - name: "min outer negative", - hostZone: types.HostZone{ - MinRedemptionRate: sdk.MustNewDecFromStr("0.8").Neg(), - MinInnerRedemptionRate: sdk.MustNewDecFromStr("0.9"), - RedemptionRate: sdk.MustNewDecFromStr("1.0"), - MaxInnerRedemptionRate: sdk.MustNewDecFromStr("1.1"), - MaxRedemptionRate: sdk.MustNewDecFromStr("1.2"), - }, - valid: false, - }, - { - name: "min inner negative", - hostZone: types.HostZone{ - MinRedemptionRate: sdk.MustNewDecFromStr("0.8"), - MinInnerRedemptionRate: sdk.MustNewDecFromStr("0.9").Neg(), - RedemptionRate: sdk.MustNewDecFromStr("1.0"), - MaxInnerRedemptionRate: sdk.MustNewDecFromStr("1.1"), - MaxRedemptionRate: sdk.MustNewDecFromStr("1.2"), - }, - valid: false, - }, - { - name: "max inner negative", - hostZone: types.HostZone{ - MinRedemptionRate: sdk.MustNewDecFromStr("0.8"), - MinInnerRedemptionRate: sdk.MustNewDecFromStr("0.9"), - RedemptionRate: sdk.MustNewDecFromStr("1.0"), - MaxInnerRedemptionRate: sdk.MustNewDecFromStr("1.1").Neg(), - MaxRedemptionRate: sdk.MustNewDecFromStr("1.2"), - }, - valid: false, - }, - { - name: "max outer negative", - hostZone: types.HostZone{ - MinRedemptionRate: sdk.MustNewDecFromStr("0.8"), - MinInnerRedemptionRate: sdk.MustNewDecFromStr("0.9"), - RedemptionRate: sdk.MustNewDecFromStr("1.0"), - MaxInnerRedemptionRate: sdk.MustNewDecFromStr("1.1"), - MaxRedemptionRate: sdk.MustNewDecFromStr("1.2").Neg(), - }, - valid: false, - }, - { - name: "max inner outside outer", - hostZone: types.HostZone{ - MinRedemptionRate: sdk.MustNewDecFromStr("0.8"), - MinInnerRedemptionRate: sdk.MustNewDecFromStr("0.9"), - RedemptionRate: sdk.MustNewDecFromStr("1.0"), - MaxInnerRedemptionRate: sdk.MustNewDecFromStr("1.3"), // <-- - MaxRedemptionRate: sdk.MustNewDecFromStr("1.2"), - }, - valid: false, - }, - { - name: "min inner outside outer", - hostZone: types.HostZone{ - MinRedemptionRate: sdk.MustNewDecFromStr("0.8"), - MinInnerRedemptionRate: sdk.MustNewDecFromStr("0.7"), // <-- - RedemptionRate: sdk.MustNewDecFromStr("1.0"), - MaxInnerRedemptionRate: sdk.MustNewDecFromStr("1.1"), - MaxRedemptionRate: sdk.MustNewDecFromStr("1.2"), - }, - valid: false, - }, - { - name: "min inner greater than min outer", - hostZone: types.HostZone{ - MinRedemptionRate: sdk.MustNewDecFromStr("0.8"), - MinInnerRedemptionRate: sdk.MustNewDecFromStr("1.1"), // <-- - RedemptionRate: sdk.MustNewDecFromStr("1.0"), - MaxInnerRedemptionRate: sdk.MustNewDecFromStr("0.9"), // <-- - MaxRedemptionRate: sdk.MustNewDecFromStr("1.2"), - }, - valid: false, - }, - } - - for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { - err := tc.hostZone.ValidateRedemptionRateBoundsInitalized() - if tc.valid { - require.NoError(t, err, "no error expected") - } else { - require.ErrorIs(t, err, types.ErrInvalidRedemptionRateBounds) - } - }) - } -} From ea2b9d7f3052b6d86bfac831c1ec1ab13af139cc Mon Sep 17 00:00:00 2001 From: sampocs Date: Tue, 4 Jun 2024 17:57:47 -0500 Subject: [PATCH 8/9] updated second batch of redemption rate updates --- x/staketia/keeper/msg_server.go | 64 +----------- x/staketia/keeper/msg_server_test.go | 140 --------------------------- x/staketia/keeper/unbonding.go | 14 ++- x/staketia/keeper/unbonding_test.go | 5 +- x/staketia/types/genesis.go | 11 +-- 5 files changed, 15 insertions(+), 219 deletions(-) diff --git a/x/staketia/keeper/msg_server.go b/x/staketia/keeper/msg_server.go index 417a97638..f7606b53e 100644 --- a/x/staketia/keeper/msg_server.go +++ b/x/staketia/keeper/msg_server.go @@ -3,11 +3,8 @@ package keeper import ( "context" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/Stride-Labs/stride/v22/utils" - "github.com/Stride-Labs/stride/v22/x/staketia/types" ) @@ -134,71 +131,14 @@ func (k msgServer) AdjustDelegatedBalance(goCtx context.Context, msg *types.MsgA // Adjusts the inner redemption rate bounds on the host zone func (k msgServer) UpdateInnerRedemptionRateBounds(goCtx context.Context, msg *types.MsgUpdateInnerRedemptionRateBounds) (*types.MsgUpdateInnerRedemptionRateBoundsResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - // gate this transaction to the BOUNDS address - if err := utils.ValidateAdminAddress(msg.Creator); err != nil { - return nil, types.ErrInvalidAdmin - } - - // Fetch the zone - zone, err := k.GetHostZone(ctx) - if err != nil { - return nil, err - } - - // Get the outer bounds - maxOuterBound := zone.MaxRedemptionRate - minOuterBound := zone.MinRedemptionRate - - // Confirm the inner bounds are within the outer bounds - maxInnerBound := msg.MaxInnerRedemptionRate - minInnerBound := msg.MinInnerRedemptionRate - if maxInnerBound.GT(maxOuterBound) { - return nil, types.ErrInvalidRedemptionRateBounds - } - if minInnerBound.LT(minOuterBound) { - return nil, types.ErrInvalidRedemptionRateBounds - } - - // Set the inner bounds on the host zone - zone.MinInnerRedemptionRate = minInnerBound - zone.MaxInnerRedemptionRate = maxInnerBound - - // Update the host zone - k.SetHostZone(ctx, zone) - + _ = sdk.UnwrapSDKContext(goCtx) return &types.MsgUpdateInnerRedemptionRateBoundsResponse{}, nil } // Unhalts the host zone if redemption rates were exceeded // BOUNDS: verified in ValidateBasic func (k msgServer) ResumeHostZone(goCtx context.Context, msg *types.MsgResumeHostZone) (*types.MsgResumeHostZoneResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - // gate this transaction to the BOUNDS address - if err := utils.ValidateAdminAddress(msg.Creator); err != nil { - return nil, types.ErrInvalidAdmin - } - - // Note: of course we don't want to fail this if the zone is halted! - zone, err := k.GetHostZone(ctx) - if err != nil { - return nil, err - } - - // Check the zone is halted - if !zone.Halted { - return nil, errorsmod.Wrapf(types.ErrHostZoneNotHalted, "zone is not halted") - } - - stDenom := utils.StAssetDenomFromHostZoneDenom(zone.NativeTokenDenom) - k.ratelimitKeeper.RemoveDenomFromBlacklist(ctx, stDenom) - - // Resume zone - zone.Halted = false - k.SetHostZone(ctx, zone) - + _ = sdk.UnwrapSDKContext(goCtx) return &types.MsgResumeHostZoneResponse{}, nil } diff --git a/x/staketia/keeper/msg_server_test.go b/x/staketia/keeper/msg_server_test.go index 9700042f9..666aa739e 100644 --- a/x/staketia/keeper/msg_server_test.go +++ b/x/staketia/keeper/msg_server_test.go @@ -4,7 +4,6 @@ import ( sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/Stride-Labs/stride/v22/app/apptesting" "github.com/Stride-Labs/stride/v22/x/staketia/types" ) @@ -235,145 +234,6 @@ func (s *KeeperTestSuite) TestAdjustDelegatedBalance() { s.Require().ErrorContains(err, "host zone not found") } -// ---------------------------------------------- -// MsgUpdateInnerRedemptionRateBounds -// ---------------------------------------------- - -func (s *KeeperTestSuite) TestUpdateInnerRedemptionRateBounds() { - adminAddress, ok := apptesting.GetAdminAddress() - s.Require().True(ok) - - // Register a host zone - zone := types.HostZone{ - ChainId: HostChainId, - // Upper bound 1.5 - MaxRedemptionRate: sdk.NewDec(3).Quo(sdk.NewDec(2)), - // Lower bound 0.9 - MinRedemptionRate: sdk.NewDec(9).Quo(sdk.NewDec(10)), - } - - s.App.StaketiaKeeper.SetHostZone(s.Ctx, zone) - // we're halting the zone to test that the tx works even when the host zone is halted - s.App.StaketiaKeeper.HaltZone(s.Ctx) - - initialMsg := types.MsgUpdateInnerRedemptionRateBounds{ - Creator: adminAddress, - MinInnerRedemptionRate: sdk.NewDec(90).Quo(sdk.NewDec(100)), - MaxInnerRedemptionRate: sdk.NewDec(105).Quo(sdk.NewDec(100)), - } - - updateMsg := types.MsgUpdateInnerRedemptionRateBounds{ - Creator: adminAddress, - MinInnerRedemptionRate: sdk.NewDec(95).Quo(sdk.NewDec(100)), - MaxInnerRedemptionRate: sdk.NewDec(11).Quo(sdk.NewDec(10)), - } - - invalidMsg := types.MsgUpdateInnerRedemptionRateBounds{ - Creator: adminAddress, - MinInnerRedemptionRate: sdk.NewDec(0), - MaxInnerRedemptionRate: sdk.NewDec(2), - } - - nonAdminMsg := types.MsgUpdateInnerRedemptionRateBounds{ - Creator: "non-admin", - MinInnerRedemptionRate: sdk.NewDec(0), - MaxInnerRedemptionRate: sdk.NewDec(2), - } - - // Set the inner bounds on the host zone for the first time - _, err := s.GetMsgServer().UpdateInnerRedemptionRateBounds(s.Ctx, &initialMsg) - s.Require().NoError(err, "should not throw an error") - - // Confirm the inner bounds were set - zone = s.MustGetHostZone() - s.Require().Equal(initialMsg.MinInnerRedemptionRate, zone.MinInnerRedemptionRate, "min inner redemption rate should be set") - s.Require().Equal(initialMsg.MaxInnerRedemptionRate, zone.MaxInnerRedemptionRate, "max inner redemption rate should be set") - - // Update the inner bounds on the host zone - _, err = s.GetMsgServer().UpdateInnerRedemptionRateBounds(s.Ctx, &updateMsg) - s.Require().NoError(err, "should not throw an error") - - // Confirm the inner bounds were set - zone = s.MustGetHostZone() - s.Require().Equal(updateMsg.MinInnerRedemptionRate, zone.MinInnerRedemptionRate, "min inner redemption rate should be set") - s.Require().Equal(updateMsg.MaxInnerRedemptionRate, zone.MaxInnerRedemptionRate, "max inner redemption rate should be set") - - // Set the inner bounds on the host zone for the first time - _, err = s.GetMsgServer().UpdateInnerRedemptionRateBounds(s.Ctx, &invalidMsg) - s.Require().ErrorContains(err, "invalid host zone redemption rate inner bounds") - - // Attempt to update bounds with a non-admin address, it should fail - _, err = s.GetMsgServer().UpdateInnerRedemptionRateBounds(s.Ctx, &nonAdminMsg) - s.Require().ErrorContains(err, "signer is not an admin") -} - -// ---------------------------------------------- -// MsgResumeHostZone -// ---------------------------------------------- - -// Test cases -// - Zone is not halted -// - Zone is halted - unhalt it -func (s *KeeperTestSuite) TestResumeHostZone() { - // TODO [sttia]: verify denom blacklisting removal works - - adminAddress, ok := apptesting.GetAdminAddress() - s.Require().True(ok) - - zone := types.HostZone{ - ChainId: HostChainId, - RedemptionRate: sdk.NewDec(1), - Halted: false, - NativeTokenDenom: HostNativeDenom, - } - s.App.StaketiaKeeper.SetHostZone(s.Ctx, zone) - - msg := types.MsgResumeHostZone{ - Creator: adminAddress, - } - - // TEST 1: Zone is not halted - // Try to unhalt the unhalted zone - _, err := s.GetMsgServer().ResumeHostZone(s.Ctx, &msg) - s.Require().ErrorContains(err, "zone is not halted") - - // Verify the denom is not in the blacklist - blacklist := s.App.RatelimitKeeper.GetAllBlacklistedDenoms(s.Ctx) - s.Require().NotContains(blacklist, StDenom, "denom should not be blacklisted") - - // Confirm the zone is not halted - zone, err = s.App.StaketiaKeeper.GetHostZone(s.Ctx) - s.Require().NoError(err, "should not throw an error") - s.Require().False(zone.Halted, "zone should not be halted") - - // TEST 2: Zone is halted - // Halt the zone - s.App.StaketiaKeeper.HaltZone(s.Ctx) - - // Verify the denom is in the blacklist - blacklist = s.App.RatelimitKeeper.GetAllBlacklistedDenoms(s.Ctx) - s.Require().Contains(blacklist, StDenom, "denom should be blacklisted") - - // Try to unhalt the halted zone - _, err = s.GetMsgServer().ResumeHostZone(s.Ctx, &msg) - s.Require().NoError(err, "should not throw an error") - - // Confirm the zone is not halted - zone, err = s.App.StaketiaKeeper.GetHostZone(s.Ctx) - s.Require().NoError(err, "should not throw an error") - s.Require().False(zone.Halted, "zone should not be halted") - - // Verify the denom is not in the blacklist - blacklist = s.App.RatelimitKeeper.GetAllBlacklistedDenoms(s.Ctx) - s.Require().NotContains(blacklist, StDenom, "denom should not be blacklisted") - - // Attempt to resume with a non-admin address, it should fail - _, err = s.GetMsgServer().ResumeHostZone(s.Ctx, &types.MsgResumeHostZone{ - Creator: "non-admin", - }) - s.Require().ErrorContains(err, "signer is not an admin") -} - // ---------------------------------------------- // MsgOverwriteDelgationRecord // ---------------------------------------------- diff --git a/x/staketia/keeper/unbonding.go b/x/staketia/keeper/unbonding.go index c3ae5f163..fe124d407 100644 --- a/x/staketia/keeper/unbonding.go +++ b/x/staketia/keeper/unbonding.go @@ -24,6 +24,10 @@ func (k Keeper) RedeemStake(ctx sdk.Context, redeemer string, stTokenAmount sdkm if err != nil { return nativeToken, err } + stakeibcHostZone, err := k.stakeibcKeeper.GetActiveHostZone(ctx, types.CelestiaChainId) + if err != nil { + return nativeToken, err + } escrowAccount, err := sdk.AccAddressFromBech32(hostZone.RedemptionAddress) if err != nil { @@ -56,10 +60,10 @@ func (k Keeper) RedeemStake(ctx sdk.Context, redeemer string, stTokenAmount sdkm // Estimate a placeholder native amount with current RedemptionRate // this estimate will be updated when the Undelegation record is finalized - nativeAmount := sdk.NewDecFromInt(stTokenAmount).Mul(hostZone.RedemptionRate).TruncateInt() - if nativeAmount.GT(hostZone.DelegatedBalance) { + nativeAmount := sdk.NewDecFromInt(stTokenAmount).Mul(stakeibcHostZone.RedemptionRate).TruncateInt() + if nativeAmount.GT(stakeibcHostZone.TotalDelegations) { return nativeToken, errorsmod.Wrapf(types.ErrUnbondAmountToLarge, - "cannot unstake an amount g.t. total staked balance: %v > %v", nativeAmount, hostZone.DelegatedBalance) + "cannot unstake an amount g.t. total staked balance: %v > %v", nativeAmount, stakeibcHostZone.TotalDelegations) } // Update the accumulating UnbondingRecord with the undelegation amounts @@ -104,11 +108,11 @@ func (k Keeper) PrepareUndelegation(ctx sdk.Context, epochNumber uint64) error { k.Logger(ctx).Info(utils.LogWithHostZone(types.CelestiaChainId, "Preparing undelegation for epoch %d", epochNumber)) // Get the redemption record from the host zone (to calculate the native tokens) - hostZone, err := k.GetUnhaltedHostZone(ctx) + stakeibcHostZone, err := k.stakeibcKeeper.GetActiveHostZone(ctx, types.CelestiaChainId) if err != nil { return err } - redemptionRate := hostZone.RedemptionRate + redemptionRate := stakeibcHostZone.RedemptionRate // Get the one accumulating record that has the redemptions for the past epoch unbondingRecord, err := k.GetAccumulatingUnbondingRecord(ctx) diff --git a/x/staketia/keeper/unbonding_test.go b/x/staketia/keeper/unbonding_test.go index 344d0e22d..daa88812f 100644 --- a/x/staketia/keeper/unbonding_test.go +++ b/x/staketia/keeper/unbonding_test.go @@ -332,7 +332,8 @@ func (s *KeeperTestSuite) TestPrepareUndelegation() { // (an uneven number is used to test rounding/truncation) oldRedemptionRate := sdk.MustNewDecFromStr("1.9") redemptionRate := sdk.MustNewDecFromStr("1.999") - s.App.StaketiaKeeper.SetHostZone(s.Ctx, types.HostZone{ + s.App.StakeibcKeeper.SetHostZone(s.Ctx, stakeibctypes.HostZone{ + ChainId: HostChainId, RedemptionRate: redemptionRate, }) @@ -459,8 +460,6 @@ func (s *KeeperTestSuite) SetupTestConfirmUndelegation(amountToUndelegate sdkmat RedemptionAddress: redemptionAddress.String(), NativeTokenDenom: HostNativeDenom, UnbondingPeriodSeconds: unbondingPeriodSeconds, - MinRedemptionRate: sdk.MustNewDecFromStr("0.9"), - MaxRedemptionRate: sdk.MustNewDecFromStr("1.2"), } s.App.StaketiaKeeper.SetHostZone(s.Ctx, staketiaHostZone) diff --git a/x/staketia/types/genesis.go b/x/staketia/types/genesis.go index 7baba778e..17ecb4c4b 100644 --- a/x/staketia/types/genesis.go +++ b/x/staketia/types/genesis.go @@ -2,7 +2,6 @@ package types import ( sdkmath "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" ) // DefaultGenesis returns the default genesis state @@ -30,14 +29,8 @@ func DefaultGenesis() *GenesisState { SafeAddressOnStride: SafeAddressOnStride, OperatorAddressOnStride: OperatorAddressOnStride, - RedemptionRate: sdk.OneDec(), - LastRedemptionRate: sdk.OneDec(), - MinRedemptionRate: sdk.MustNewDecFromStr("0.95"), - MaxRedemptionRate: sdk.MustNewDecFromStr("1.1"), - MinInnerRedemptionRate: sdk.MustNewDecFromStr("0.95"), - MaxInnerRedemptionRate: sdk.MustNewDecFromStr("1.1"), - DelegatedBalance: sdkmath.ZeroInt(), - Halted: false, + RemainingDelegatedBalance: sdkmath.ZeroInt(), + Halted: false, }, UnbondingRecords: []UnbondingRecord{ { From 317367049e2dad24ca702f4a42b8ea8b903a2c98 Mon Sep 17 00:00:00 2001 From: sampocs Date: Thu, 6 Jun 2024 22:51:09 -0500 Subject: [PATCH 9/9] merge conflicts --- x/staketia/keeper/delegation_test.go | 62 ---------------------------- 1 file changed, 62 deletions(-) diff --git a/x/staketia/keeper/delegation_test.go b/x/staketia/keeper/delegation_test.go index ba5d5431e..0c396f58c 100644 --- a/x/staketia/keeper/delegation_test.go +++ b/x/staketia/keeper/delegation_test.go @@ -270,65 +270,3 @@ func (s *KeeperTestSuite) TestConfirmDelegation_RecordIncorrectState() { s.VerifyDelegationRecords(true) } } -<<<<<<< HEAD - -// ---------------------------------------------------- -// LiquidStakeAndDistributeFees -// ---------------------------------------------------- - -func (s *KeeperTestSuite) TestLiquidStakeAndDistributeFees() { - // Create relevant addresses - depositAddress := s.TestAccs[0] - feeAddress := s.App.AccountKeeper.GetModuleAddress(types.FeeAddress) - - // Liquid stake 1000 with a RR of 2, should return 500 tokens - liquidStakeAmount := sdkmath.NewInt(1000) - // redemptionRate := sdk.NewDec(2) - expectedStTokens := sdkmath.NewInt(500) - - // Create a host zone with relevant denom's and addresses - hostZone := types.HostZone{ - ChainId: HostChainId, - NativeTokenDenom: HostNativeDenom, - NativeTokenIbcDenom: HostIBCDenom, - DepositAddress: depositAddress.String(), - // RedemptionRate: redemptionRate, - // MinRedemptionRate: redemptionRate.Sub(sdk.MustNewDecFromStr("0.2")), - // MinInnerRedemptionRate: redemptionRate.Sub(sdk.MustNewDecFromStr("0.1")), - // MaxInnerRedemptionRate: redemptionRate.Add(sdk.MustNewDecFromStr("0.1")), - // MaxRedemptionRate: redemptionRate.Add(sdk.MustNewDecFromStr("0.2")), - } - s.App.StaketiaKeeper.SetHostZone(s.Ctx, hostZone) - - // Fund the fee address with native tokens - liquidStakeToken := sdk.NewCoin(HostIBCDenom, liquidStakeAmount) - s.FundAccount(feeAddress, liquidStakeToken) - - // Call liquid stake and distribute - err := s.App.StaketiaKeeper.LiquidStakeAndDistributeFees(s.Ctx) - s.Require().NoError(err, "no error expected when liquid staking fee tokens") - - // Confirm stTokens were sent to the fee collector - feeCollectorAddress := s.App.AccountKeeper.GetModuleAddress(authtypes.FeeCollectorName) - feeCollectorBalance := s.App.BankKeeper.GetBalance(s.Ctx, feeCollectorAddress, StDenom) - s.Require().Equal(expectedStTokens.Int64(), feeCollectorBalance.Amount.Int64(), - "fee collector should have received sttokens") - - // Attempt to liquid stake again when there are no more rewards, it should succeed but do nothing - err = s.App.StaketiaKeeper.LiquidStakeAndDistributeFees(s.Ctx) - s.Require().NoError(err, "no error expected when liquid staking again") - - feeCollectorBalance = s.App.BankKeeper.GetBalance(s.Ctx, feeCollectorAddress, StDenom) - s.Require().Equal(expectedStTokens.Int64(), feeCollectorBalance.Amount.Int64(), - "fee collector should not have changed") - - // Test that if the host zone is halted, it will error - haltedHostZone := hostZone - haltedHostZone.Halted = true - s.App.StaketiaKeeper.SetHostZone(s.Ctx, haltedHostZone) - - err = s.App.StaketiaKeeper.LiquidStakeAndDistributeFees(s.Ctx) - s.Require().ErrorContains(err, "host zone is halted") -} -======= ->>>>>>> staketia-migration