You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we check for fluctuation limit we use a snapshot which can come from a different pool than the one we are looking at.
Here's a log :
/**Check's that a pool that we're about to save to state does not violate the fluctuation limit.Always tries to check against a snapshot from a previous block. If one doesn't exist, then it just uses the current snapshot.This should run prior to updating the snapshot, otherwise it will compare the currently updated vpool to itself.args: - ctx: the cosmos-sdk context - pool: the updated vpoolret: - err: error if any*/func (kKeeper) checkFluctuationLimitRatio(ctx sdk.Context, pool types.VPool) error {
ifpool.FluctuationLimitRatio.IsZero() {
// early return to avoid expensive state operationsreturnnil
}
it:=k.ReserveSnapshots.Iterate(ctx, keys.NewRange[keys.Pair[common.AssetPair, keys.Uint64Key]]().Descending())
deferit.Close()
if!it.Valid() {
returnfmt.Errorf("error getting last snapshot number for pair %s", pool.Pair)
}
latestSnapshot:=it.Value()
fmt.Println("##########################################################")
fmt.Println("##########################################################")
fmt.Println("##########################################################")
fmt.Println("markPrice", pool.GetMarkPrice())
fmt.Println("snapshotUpperLimit", latestSnapshot.GetUpperMarkPriceFluctuationLimit(pool.FluctuationLimitRatio))
fmt.Println("snapshotLowerLimit", latestSnapshot.GetLowerMarkPriceFluctuationLimit(pool.FluctuationLimitRatio))
markPrice:=pool.GetMarkPrice()
snapshotUpperLimit:=latestSnapshot.GetUpperMarkPriceFluctuationLimit(pool.FluctuationLimitRatio)
snapshotLowerLimit:=latestSnapshot.GetLowerMarkPriceFluctuationLimit(pool.FluctuationLimitRatio)
fmt.Println(markPrice.GT(snapshotUpperLimit) ||markPrice.LT(snapshotLowerLimit))
fmt.Println("latestSnapshot", latestSnapshot)
ifpool.IsOverFluctuationLimitInRelationWithSnapshot(latestSnapshot) {
returntypes.ErrOverFluctuationLimit
}
returnnil
}
When we check for fluctuation limit we use a snapshot which can come from a different pool than the one we are looking at.
Here's a log :
The text was updated successfully, but these errors were encountered: