@@ -35,6 +35,13 @@ export type PriceConfig = {
35
35
36
36
// An early update happens when another price has met the conditions to be pushed, so this
37
37
// price can be included in a batch update for minimal gas cost.
38
+ // By default, every price feed will be early updated in a batch if any other price update triggers
39
+ // the conditions. This configuration will typically minimize gas usage.
40
+ //
41
+ // However, if you would like to customize this behavior, set `customEarlyUpdate: true` in your config
42
+ // for the price feed, then set the specific conditions (time / price / confidence) under which you would
43
+ // like the early update to trigger.
44
+ customEarlyUpdate : boolean | undefined ;
38
45
earlyUpdateTimeDifference : DurationInSeconds | undefined ;
39
46
earlyUpdatePriceDeviation : PctNumber | undefined ;
40
47
earlyUpdateConfidenceRatio : PctNumber | undefined ;
@@ -56,6 +63,7 @@ export function readPriceConfigFile(path: string): PriceConfig[] {
56
63
priceDeviation : priceConfigRaw . price_deviation ,
57
64
confidenceRatio : priceConfigRaw . confidence_ratio ,
58
65
66
+ customEarlyUpdate : priceConfigRaw . early_update !== undefined ,
59
67
earlyUpdateTimeDifference : priceConfigRaw . early_update ?. time_difference ,
60
68
earlyUpdatePriceDeviation : priceConfigRaw . early_update ?. price_deviation ,
61
69
earlyUpdateConfidenceRatio : priceConfigRaw . early_update ?. confidence_ratio ,
@@ -139,6 +147,8 @@ export function shouldUpdate(
139
147
) {
140
148
return UpdateCondition . YES ;
141
149
} else if (
150
+ priceConfig . customEarlyUpdate === undefined ||
151
+ ! priceConfig . customEarlyUpdate ||
142
152
( priceConfig . earlyUpdateTimeDifference !== undefined &&
143
153
timeDifference >= priceConfig . earlyUpdateTimeDifference ) ||
144
154
( priceConfig . earlyUpdatePriceDeviation !== undefined &&
0 commit comments