Skip to content

Commit

Permalink
fixed lint errors in the rest of stakeibc
Browse files Browse the repository at this point in the history
  • Loading branch information
sampocs committed Aug 23, 2024
1 parent ad10e1e commit 03d7f00
Show file tree
Hide file tree
Showing 15 changed files with 96 additions and 183 deletions.
41 changes: 15 additions & 26 deletions x/stakeibc/keeper/claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,13 @@ func (k msgServer) ClaimUndelegatedTokens(goCtx context.Context, msg *types.MsgC
k.Logger(ctx).Info(fmt.Sprintf("ClaimUndelegatedTokens %v", msg))
userRedemptionRecord, err := k.GetClaimableRedemptionRecord(ctx, msg)
if err != nil {
errMsg := fmt.Sprintf("unable to find claimable redemption record for msg: %v, error %s", msg, err.Error())
k.Logger(ctx).Error(errMsg)
return nil, errorsmod.Wrap(types.ErrRecordNotFound, errMsg)
return nil, errorsmod.Wrapf(err, "unable to find claimable redemption record for msg %+v", msg)
}

hostZone, found := k.GetHostZone(ctx, msg.HostZoneId)
if !found {
return nil, errorsmod.Wrap(types.ErrHostZoneNotFound, fmt.Sprintf("Host zone %s not found", msg.HostZoneId))
}

if hostZone.Halted {
k.Logger(ctx).Error(fmt.Sprintf("Host Zone %s halted", msg.HostZoneId))
return nil, errorsmod.Wrapf(types.ErrHaltedHostZone, "Host Zone %s halted", msg.HostZoneId)
// Confirm host zone is not halted
_, err = k.GetActiveHostZone(ctx, msg.HostZoneId)
if err != nil {
return nil, err
}

icaTx, err := k.GetRedemptionTransferMsg(ctx, userRedemptionRecord, msg.HostZoneId)
Expand Down Expand Up @@ -75,29 +69,26 @@ func (k Keeper) GetClaimableRedemptionRecord(ctx sdk.Context, msg *types.MsgClai
userRedemptionRecordKey := recordstypes.UserRedemptionRecordKeyFormatter(msg.HostZoneId, msg.Epoch, msg.Receiver)
userRedemptionRecord, found := k.RecordsKeeper.GetUserRedemptionRecord(ctx, userRedemptionRecordKey)
if !found {
errMsg := fmt.Sprintf("User redemption record %s not found on host zone %s", userRedemptionRecordKey, msg.HostZoneId)
k.Logger(ctx).Error(errMsg)
return nil, errorsmod.Wrap(types.ErrInvalidUserRedemptionRecord, errMsg)
return nil, errorsmod.Wrapf(types.ErrInvalidUserRedemptionRecord,
"user redemption record %s not found on host zone %s", userRedemptionRecordKey, msg.HostZoneId)
}

// check that the record is claimable
hostZoneUnbonding, found := k.RecordsKeeper.GetHostZoneUnbondingByChainId(ctx, userRedemptionRecord.EpochNumber, msg.HostZoneId)
if !found {
errMsg := fmt.Sprintf("Host zone unbonding record %s not found on host zone %s", userRedemptionRecordKey, msg.HostZoneId)
k.Logger(ctx).Error(errMsg)
return nil, errorsmod.Wrapf(types.ErrInvalidUserRedemptionRecord, errMsg)
return nil, errorsmod.Wrapf(types.ErrInvalidUserRedemptionRecord,
"host zone unbonding record %s not found on host zone %s", userRedemptionRecordKey, msg.HostZoneId)
}
// records associated with host zone unbondings are claimable after the host zone unbonding tokens have been CLAIMABLE to the redemption account
if hostZoneUnbonding.Status != recordstypes.HostZoneUnbonding_CLAIMABLE {
errMsg := fmt.Sprintf("User redemption record %s is not claimable, host zone unbonding has status: %s, requires status CLAIMABLE", userRedemptionRecord.Id, hostZoneUnbonding.Status)
k.Logger(ctx).Error(errMsg)
return nil, errorsmod.Wrapf(types.ErrInvalidUserRedemptionRecord, errMsg)
return nil, errorsmod.Wrapf(types.ErrInvalidUserRedemptionRecord,
"user redemption record %s is not claimable, host zone unbonding has status: %s, requires status CLAIMABLE",
userRedemptionRecord.Id, hostZoneUnbonding.Status)
}
// records that have claimIsPending set to True have already been claimed (and are pending an ack)
if userRedemptionRecord.ClaimIsPending {
errMsg := fmt.Sprintf("User redemption record %s is not claimable, pending ack", userRedemptionRecord.Id)
k.Logger(ctx).Error(errMsg)
return nil, errorsmod.Wrapf(types.ErrInvalidUserRedemptionRecord, errMsg)
return nil, errorsmod.Wrapf(types.ErrInvalidUserRedemptionRecord,
"user redemption record %s is not claimable, pending ack", userRedemptionRecord.Id)
}
return &userRedemptionRecord, nil
}
Expand All @@ -124,9 +115,7 @@ func (k Keeper) GetRedemptionTransferMsg(ctx sdk.Context, userRedemptionRecord *
// TODO [optimization]: Remove reference to epoch time (make timeout relative to block time)
epochTracker, found := k.GetEpochTracker(ctx, epochstypes.STRIDE_EPOCH)
if !found {
errMsg := fmt.Sprintf("Epoch tracker not found for epoch %s", epochstypes.STRIDE_EPOCH)
k.Logger(ctx).Error(errMsg)
return nil, errorsmod.Wrap(types.ErrEpochNotFound, errMsg)
return nil, errorsmod.Wrapf(types.ErrEpochNotFound, "epoch tracker not found for epoch %s", epochstypes.STRIDE_EPOCH)
}
icaTimeOutNanos := k.GetParam(ctx, types.KeyICATimeoutNanos)
nextEpochStarttime := epochTracker.NextEpochStartTime
Expand Down
12 changes: 5 additions & 7 deletions x/stakeibc/keeper/claim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (s *KeeperTestSuite) TestClaimUndelegatedTokens_NoUserRedemptionRecord() {
s.App.RecordsKeeper.RemoveUserRedemptionRecord(s.Ctx, tc.initialState.redemptionRecordId)

_, err := s.GetMsgServer().ClaimUndelegatedTokens(sdk.WrapSDKContext(s.Ctx), &tc.validMsg)
s.Require().ErrorContains(err, "user redemption record error: record not found")
s.Require().ErrorContains(err, "unable to find claimable redemption record")
}

func (s *KeeperTestSuite) TestClaimUndelegatedTokens_RecordNotClaimable() {
Expand All @@ -144,7 +144,7 @@ func (s *KeeperTestSuite) TestClaimUndelegatedTokens_RecordNotClaimable() {
s.App.RecordsKeeper.SetUserRedemptionRecord(s.Ctx, alreadyClaimedRedemptionRecord)

_, err := s.GetMsgServer().ClaimUndelegatedTokens(sdk.WrapSDKContext(s.Ctx), &tc.validMsg)
s.Require().ErrorContains(err, "User redemption record GAIA.1.cosmos_RECEIVER is not claimable")
s.Require().ErrorContains(err, "user redemption record GAIA.1.cosmos_RECEIVER is not claimable")
}

func (s *KeeperTestSuite) TestClaimUndelegatedTokens_RecordNotFound() {
Expand All @@ -154,7 +154,7 @@ func (s *KeeperTestSuite) TestClaimUndelegatedTokens_RecordNotFound() {
invalidMsg.HostZoneId = "fake_host_zone"

_, err := s.GetMsgServer().ClaimUndelegatedTokens(sdk.WrapSDKContext(s.Ctx), &invalidMsg)
s.Require().ErrorContains(err, "User redemption record fake_host_zone.1.cosmos_RECEIVER not found on host zone fake_host_zone")
s.Require().ErrorContains(err, "user redemption record fake_host_zone.1.cosmos_RECEIVER not found on host zone fake_host_zone")
}

func (s *KeeperTestSuite) TestClaimUndelegatedTokens_HostZoneNotFound() {
Expand All @@ -180,17 +180,15 @@ func (s *KeeperTestSuite) TestClaimUndelegatedTokens_NoRedemptionAccount() {
s.App.StakeibcKeeper.SetHostZone(s.Ctx, hostZone)

_, err := s.App.StakeibcKeeper.GetRedemptionTransferMsg(s.Ctx, &tc.initialState.redemptionRecord, tc.validMsg.HostZoneId)
s.Require().EqualError(err, "Redemption account not found for host zone GAIA: ICA acccount not found on host zone")
s.Require().ErrorContains(err, "Redemption account not found for host zone GAIA")
}

func (s *KeeperTestSuite) TestClaimUndelegatedTokens_NoEpochTracker() {
tc := s.SetupClaimUndelegatedTokens()
s.App.StakeibcKeeper.RemoveEpochTracker(s.Ctx, epochtypes.STRIDE_EPOCH)

_, err := s.GetMsgServer().ClaimUndelegatedTokens(sdk.WrapSDKContext(s.Ctx), &tc.validMsg)
expectedErr := "unable to build redemption transfer message: "
expectedErr += "Epoch tracker not found for epoch stride_epoch: epoch not found"
s.Require().EqualError(err, expectedErr)
s.Require().ErrorContains(err, "epoch tracker not found for epoch stride_epoch")
}

func (s *KeeperTestSuite) TestClaimUndelegatedTokens_HzuNotStatusTransferred() {
Expand Down
8 changes: 4 additions & 4 deletions x/stakeibc/keeper/community_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (k Keeper) QueryCommunityPoolIcaBalance(
// Timeout query at end of epoch
strideEpochTracker, found := k.GetEpochTracker(ctx, epochstypes.STRIDE_EPOCH)
if !found {
return errorsmod.Wrapf(types.ErrEpochNotFound, epochstypes.STRIDE_EPOCH)
return errorsmod.Wrapf(types.ErrEpochNotFound, "epoch %s not found", epochstypes.STRIDE_EPOCH)
}
timeout := time.Unix(0, int64(strideEpochTracker.NextEpochStartTime))
timeoutDuration := timeout.Sub(ctx.BlockTime())
Expand Down Expand Up @@ -184,7 +184,7 @@ func (k Keeper) LiquidStakeCommunityPoolTokens(ctx sdk.Context, hostZone types.H
}
resp, err := msgServer.LiquidStake(ctx, &liquidStakeRequest)
if err != nil {
return types.ErrFailedToLiquidStake.Wrapf(err.Error())
return errorsmod.Wrap(err, "failed to liquid stake community pool tokens")
}

// If the liquid stake was successful, transfer the stTokens to the return ICA
Expand Down Expand Up @@ -220,7 +220,7 @@ func (k Keeper) RedeemCommunityPoolTokens(ctx sdk.Context, hostZone types.HostZo
Receiver: hostZone.CommunityPoolReturnIcaAddress,
}
if _, err := msgServer.RedeemStake(ctx, &redeemStakeRequest); err != nil {
return types.ErrUnableToRedeemStake.Wrapf(err.Error())
return errorsmod.Wrap(err, "failed to redeem community pool tokens")
}

return nil
Expand Down Expand Up @@ -286,7 +286,7 @@ func (k Keeper) FundCommunityPool(
// Timeout the ICA at the end of the epoch
strideEpochTracker, found := k.GetEpochTracker(ctx, epochstypes.STRIDE_EPOCH)
if !found {
return errorsmod.Wrapf(types.ErrEpochNotFound, epochstypes.STRIDE_EPOCH)
return errorsmod.Wrapf(types.ErrEpochNotFound, "epoch %s not found", epochstypes.STRIDE_EPOCH)
}
timeoutTimestamp := uint64(strideEpochTracker.NextEpochStartTime)

Expand Down
4 changes: 2 additions & 2 deletions x/stakeibc/keeper/community_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (s *KeeperTestSuite) TestQueryCommunityPoolBalance_Failure_MissingEpoch() {
s.App.StakeibcKeeper.RemoveEpochTracker(s.Ctx, epochtypes.STRIDE_EPOCH)

err := s.App.StakeibcKeeper.QueryCommunityPoolIcaBalance(s.Ctx, tc.hostZone, icaAccountType, Atom)
s.Require().ErrorContains(err, "stride_epoch: epoch not found")
s.Require().ErrorContains(err, "epoch stride_epoch not found")
}

// Tests a community pool balance query that fails to submit the query
Expand Down Expand Up @@ -297,7 +297,7 @@ func (s *KeeperTestSuite) TestLiquidStakeCommunityPoolTokens_LiquidStakeFailure(
invalidHostZone.HostDenom = "invalid"

err := s.App.StakeibcKeeper.LiquidStakeCommunityPoolTokens(s.Ctx, invalidHostZone)
s.Require().ErrorContains(err, "Failed to liquid stake")
s.Require().ErrorContains(err, "failed to liquid stake community pool tokens")
}

// Set an invalid transfer channel on the host so that the transfer fails
Expand Down
2 changes: 1 addition & 1 deletion x/stakeibc/keeper/host_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (k Keeper) GetTargetValAmtsForHostZone(ctx sdk.Context, hostZone types.Host
func (k Keeper) EnableRedemptions(ctx sdk.Context, chainId string) error {
hostZone, found := k.GetHostZone(ctx, chainId)
if !found {
return types.ErrHostZoneNotFound.Wrapf(chainId)
return types.ErrHostZoneNotFound.Wrap(chainId)
}

hostZone.RedemptionsEnabled = true
Expand Down
26 changes: 13 additions & 13 deletions x/stakeibc/keeper/icqcallbacks_validator_exchange_rate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (s *KeeperTestSuite) SetupValidatorICQCallback(validatorSlashed, liquidStak
}

// Helper function to check the validator's shares to tokens rate after the query
func (s *KeeperTestSuite) checkValidatorSharesToTokensRate(expectedSharesToTokensRate sdk.Dec, tc ValidatorICQCallbackTestCase) {
func (s *KeeperTestSuite) checkValidatorSharesToTokensRate(expectedSharesToTokensRate sdk.Dec) {
hostZone, found := s.App.StakeibcKeeper.GetHostZone(s.Ctx, HostChainId)
s.Require().True(found, "host zone found")
s.Require().Equal(expectedSharesToTokensRate.String(), hostZone.Validators[0].SharesToTokensRate.String(),
Expand Down Expand Up @@ -188,7 +188,7 @@ func (s *KeeperTestSuite) checkLSMLiquidStakeNotCalled() {

// Helper function to check that the delegator shares query was submitted by checking
// that the query object was stored
func (s *KeeperTestSuite) checkDelegatorSharesQuerySubmitted(liquidStakeCallback bool, tc ValidatorICQCallbackTestCase) {
func (s *KeeperTestSuite) checkDelegatorSharesQuerySubmitted(tc ValidatorICQCallbackTestCase) {
// Check that this is only one query in the store
queries := s.App.InterchainqueryKeeper.AllQueries(s.Ctx)
s.Require().Len(queries, 1, "there should be one new query submitted for delegator shares")
Expand Down Expand Up @@ -251,7 +251,7 @@ func (s *KeeperTestSuite) TestValidatorSharesToTokensRateCallback_Successful_NoS

// Confirm validator's sharesToTokens rate DID NOT update
expectedSharesToTokensRate := tc.initialState.validator.SharesToTokensRate
s.checkValidatorSharesToTokensRate(expectedSharesToTokensRate, tc)
s.checkValidatorSharesToTokensRate(expectedSharesToTokensRate)

// Confirm the delegator shares query WAS NOT submitted
s.checkDelegatorSharesQueryNotSubmitted()
Expand All @@ -271,10 +271,10 @@ func (s *KeeperTestSuite) TestValidatorSharesToTokensRateCallback_Successful_Sla
s.Require().NoError(err, "validator sharesToTokens rate callback error")

// Confirm validator's sharesToTokens rate DID update
s.checkValidatorSharesToTokensRate(tc.sharesToTokensRateIfSlashed, tc)
s.checkValidatorSharesToTokensRate(tc.sharesToTokensRateIfSlashed)

// Confirm delegator shares query WAS submitted
s.checkDelegatorSharesQuerySubmitted(lsmCallback, tc)
s.checkDelegatorSharesQuerySubmitted(tc)

// Confirm the liquid stake flow as not touched
s.checkLSMLiquidStakeNotCalled()
Expand All @@ -293,7 +293,7 @@ func (s *KeeperTestSuite) TestValidatorSharesToTokensRateCallback_Successful_NoS

// Confirm validator's sharesToTokens rate DID NOT update
expectedSharesToTokensRate := tc.initialState.validator.SharesToTokensRate
s.checkValidatorSharesToTokensRate(expectedSharesToTokensRate, tc)
s.checkValidatorSharesToTokensRate(expectedSharesToTokensRate)

// Confirm the delegator shares query WAS NOT submitted
s.checkDelegatorSharesQueryNotSubmitted()
Expand Down Expand Up @@ -331,7 +331,7 @@ func (s *KeeperTestSuite) TestValidatorSharesToTokensRateCallback_Successful_NoS

// Confirm validator's sharesToTokens rate DID NOT update
expectedSharesToTokensRate := tc.initialState.validator.SharesToTokensRate
s.checkValidatorSharesToTokensRate(expectedSharesToTokensRate, tc)
s.checkValidatorSharesToTokensRate(expectedSharesToTokensRate)

// Confirm delegator shares query WAS NOT submitted
s.checkDelegatorSharesQueryNotSubmitted()
Expand Down Expand Up @@ -359,10 +359,10 @@ func (s *KeeperTestSuite) TestValidatorSharesToTokensRateCallback_Successful_Sla
s.Require().NoError(err, "validator sharesToTokens rate callback error")

// Confirm validator's sharesToTokens rate DID update
s.checkValidatorSharesToTokensRate(tc.sharesToTokensRateIfSlashed, tc)
s.checkValidatorSharesToTokensRate(tc.sharesToTokensRateIfSlashed)

// Confirm delegator shares query WAS submitted
s.checkDelegatorSharesQuerySubmitted(lsmCallback, tc)
s.checkDelegatorSharesQuerySubmitted(tc)

// Confirm the liquid stake failed
s.checkLSMLiquidStakeFailed()
Expand All @@ -385,7 +385,7 @@ func (s *KeeperTestSuite) TestValidatorSharesToTokensRateCallback_Successful_NoP
s.Require().NoError(err, "validator sharesToTokens rate callback error")

// Confirm validator's sharesToTokens rate DID update
s.checkValidatorSharesToTokensRate(expectedSharesToTokensRate, tc)
s.checkValidatorSharesToTokensRate(expectedSharesToTokensRate)

// Confirm delegator shares query WAS NOT submitted
s.checkDelegatorSharesQueryNotSubmitted()
Expand All @@ -410,7 +410,7 @@ func (s *KeeperTestSuite) TestValidatorSharesToTokensRateCallback_NoSlash_LiqudS

// Confirm validator's sharesToTokens rate DID update
expectedSharesToTokensRate := tc.initialState.validator.SharesToTokensRate
s.checkValidatorSharesToTokensRate(expectedSharesToTokensRate, tc)
s.checkValidatorSharesToTokensRate(expectedSharesToTokensRate)

// Confirm delegator shares query WAS NOT submitted
s.checkDelegatorSharesQueryNotSubmitted()
Expand All @@ -432,7 +432,7 @@ func (s *KeeperTestSuite) TestValidatorSharesToTokensRateCallback_NoLiquidStake_

// Confirm validator's shares to tokens rate DID NOT update
expectedSharesToTokensRate := tc.initialState.validator.SharesToTokensRate
s.checkValidatorSharesToTokensRate(expectedSharesToTokensRate, tc)
s.checkValidatorSharesToTokensRate(expectedSharesToTokensRate)

// Confirm delegator shares query WAS NOT submitted
s.checkDelegatorSharesQueryNotSubmitted()
Expand All @@ -451,7 +451,7 @@ func (s *KeeperTestSuite) TestValidatorSharesToTokensRateCallback_LiquidStake_Qu

// Confirm validator's shares to tokens rate DID NOT update
expectedSharesToTokensRate := tc.initialState.validator.SharesToTokensRate
s.checkValidatorSharesToTokensRate(expectedSharesToTokensRate, tc)
s.checkValidatorSharesToTokensRate(expectedSharesToTokensRate)

// Confirm delegator shares query WAS NOT submitted
s.checkDelegatorSharesQueryNotSubmitted()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,8 @@ func (s *KeeperTestSuite) SetupWithdrawalHostBalanceCallbackTest() WithdrawalBal
s.App.StakeibcKeeper.SetEpochTracker(s.Ctx, strideEpochTracker)

withdrawalBalance := int64(1000)
commission := uint64(10)
expectedReinvestment := sdk.NewCoin(Atom, sdkmath.NewInt(int64(900)))

params := s.App.StakeibcKeeper.GetParams(s.Ctx)
params.StrideCommission = uint64(commission)

queryResponse := s.CreateBalanceQueryResponse(withdrawalBalance, Atom)

return WithdrawalBalanceICQCallbackTestCase{
Expand Down
6 changes: 3 additions & 3 deletions x/stakeibc/keeper/interchainaccounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,18 @@ func (s *KeeperTestSuite) ClaimAccruedStakingRewardsOnHost() {
// Attempt to call it with a host zone without a delegation ICA address, it should fail
invalidHostZone := hostZone
invalidHostZone.DelegationIcaAddress = ""
err = s.App.StakeibcKeeper.ClaimAccruedStakingRewardsOnHost(s.Ctx, hostZone)
err = s.App.StakeibcKeeper.ClaimAccruedStakingRewardsOnHost(s.Ctx, invalidHostZone)
s.Require().ErrorContains(err, "ICA account not found")

// Attempt to call it with a host zone without a withdrawal ICA address, it should fail
invalidHostZone = hostZone
invalidHostZone.WithdrawalIcaAddress = ""
err = s.App.StakeibcKeeper.ClaimAccruedStakingRewardsOnHost(s.Ctx, hostZone)
err = s.App.StakeibcKeeper.ClaimAccruedStakingRewardsOnHost(s.Ctx, invalidHostZone)
s.Require().ErrorContains(err, "ICA account not found")

// Attempt to call claim with an invalid connection ID on the host zone so the ica fails
invalidHostZone = hostZone
invalidHostZone.ConnectionId = ""
err = s.App.StakeibcKeeper.ClaimAccruedStakingRewardsOnHost(s.Ctx, hostZone)
err = s.App.StakeibcKeeper.ClaimAccruedStakingRewardsOnHost(s.Ctx, invalidHostZone)
s.Require().ErrorContains(err, "Failed to SubmitTxs")
}
2 changes: 1 addition & 1 deletion x/stakeibc/keeper/interchainqueries.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (k Keeper) SubmitWithdrawalHostBalanceICQ(ctx sdk.Context, hostZone types.H
// Timeout query at end of epoch
strideEpochTracker, found := k.GetEpochTracker(ctx, epochstypes.STRIDE_EPOCH)
if !found {
return errorsmod.Wrapf(types.ErrEpochNotFound, epochstypes.STRIDE_EPOCH)
return errorsmod.Wrapf(types.ErrEpochNotFound, "epoch %s not found", epochstypes.STRIDE_EPOCH)
}
timeout := time.Unix(0, int64(strideEpochTracker.NextEpochStartTime))
timeoutDuration := timeout.Sub(ctx.BlockTime())
Expand Down
12 changes: 4 additions & 8 deletions x/stakeibc/keeper/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package keeper
// DONTCOVER

import (
"fmt"

errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"

Expand Down Expand Up @@ -50,9 +48,8 @@ func (k Keeper) IsRedemptionRateWithinSafetyBounds(ctx sdk.Context, zone types.H
redemptionRate := zone.RedemptionRate

if redemptionRate.LT(minSafetyThreshold) || redemptionRate.GT(maxSafetyThreshold) {
errMsg := fmt.Sprintf("IsRedemptionRateWithinSafetyBounds check failed %s is outside safety bounds [%s, %s]", redemptionRate.String(), minSafetyThreshold.String(), maxSafetyThreshold.String())
k.Logger(ctx).Error(errMsg)
return false, errorsmod.Wrapf(types.ErrRedemptionRateOutsideSafetyBounds, errMsg)
return false, errorsmod.Wrapf(types.ErrRedemptionRateOutsideSafetyBounds,
"redemption rate %v is outside safety bounds [%v, %v]", redemptionRate, minSafetyThreshold, maxSafetyThreshold)
}

// Verify the redemption rate is within the inner safety bounds
Expand All @@ -61,9 +58,8 @@ func (k Keeper) IsRedemptionRateWithinSafetyBounds(ctx sdk.Context, zone types.H
// There is also one scenario where the outer bounds go within the inner bounds - if they're updated as part of a param change proposal.
minInnerSafetyThreshold, maxInnerSafetyThreshold := k.GetInnerSafetyBounds(ctx, zone)
if redemptionRate.LT(minInnerSafetyThreshold) || redemptionRate.GT(maxInnerSafetyThreshold) {
errMsg := fmt.Sprintf("IsRedemptionRateWithinSafetyBounds check failed %s is outside inner safety bounds [%s, %s]", redemptionRate.String(), minInnerSafetyThreshold.String(), maxInnerSafetyThreshold.String())
k.Logger(ctx).Error(errMsg)
return false, errorsmod.Wrapf(types.ErrRedemptionRateOutsideSafetyBounds, errMsg)
return false, errorsmod.Wrapf(types.ErrRedemptionRateOutsideSafetyBounds,
"redemption rate %v is outside inner safety bounds [%v, %v]", redemptionRate, minInnerSafetyThreshold, maxInnerSafetyThreshold)
}

return true, nil
Expand Down
Loading

0 comments on commit 03d7f00

Please sign in to comment.