Skip to content

Commit

Permalink
refactor: minor pass through twap imrovements (#2284)
Browse files Browse the repository at this point in the history
Closes: #XXX

## What is the purpose of the change

Some minor pass through changes discovered while reviewing #2168 
## Documentation and Release Note

  - Does this pull request introduce a new feature or user-facing behavior changes? no
  - Is a relevant changelog entry added to the `Unreleased` section in `CHANGELOG.md`? no
  - How is the feature or change documented? not applicable
  • Loading branch information
p0mvn authored Aug 3, 2022
1 parent 1592bb8 commit 4d50629
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion x/gamm/twap/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ type Keeper struct {
ammkeeper types.AmmInterface
}

const pruneEpochIdentifier = "day"

func NewKeeper(storeKey sdk.StoreKey, transientKey *sdk.TransientStoreKey, paramSpace paramtypes.Subspace, ammKeeper types.AmmInterface) *Keeper {
return &Keeper{storeKey: storeKey, transientKey: transientKey, paramSpace: paramSpace, ammkeeper: ammKeeper}
}

// TODO: make this read from a parameter, or hardcode it.
func (k *Keeper) PruneEpochIdentifier(ctx sdk.Context) string {
return "daily"
return pruneEpochIdentifier
}
4 changes: 2 additions & 2 deletions x/gamm/twap/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (k Keeper) storeNewRecord(ctx sdk.Context, twap types.TwapRecord) {
// returns the TWAP record from state for (id, t', asset0, asset1),
// where t' is such that:
// * t' <= t
// * there exists no t'' in state, where t'' < t'
// * there exists no `t'' <= t` in state, where `t' < t''`
//
// This returns an error if:
// * there is no historical record in state at or before t
Expand Down Expand Up @@ -140,6 +140,6 @@ func (k Keeper) getRecordAtOrBeforeTime(ctx sdk.Context, poolId uint64, t time.T
return twap, nil
}
}
return types.TwapRecord{}, fmt.Errorf("TWAP not found, but there are twaps available for this time."+
return types.TwapRecord{}, fmt.Errorf("TWAP not found, but there are other twaps available for this time."+
" Were provided asset0denom and asset1denom (%s, %s) correct, and in order (asset0 > asset1)?", asset0Denom, asset1Denom)
}

0 comments on commit 4d50629

Please sign in to comment.