Skip to content

Commit

Permalink
rename stalenessThreshold => tokenStalenessThreshold
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanRHall committed Oct 8, 2024
1 parent 95a7d48 commit 251be4f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions contracts/src/v0.8/ccip/FeeQuoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,
uint96 maxFeeJuelsPerMsg; // ─╮ Maximum fee that can be charged for a message
address linkToken; // ────────╯ LINK token address
// The amount of time a token price can be stale before it is considered invalid (gas price staleness is configured per dest chain)
uint32 stalenessThreshold;
uint32 tokenStalenessThreshold;
}

/// @dev The struct representing the received CCIP feed report from keystone IReceiver.onReport()
Expand Down Expand Up @@ -205,7 +205,7 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,
/// @dev Subset of tokens which prices tracked by this registry which are fee tokens.
EnumerableSet.AddressSet private s_feeTokens;
/// @dev The amount of time a token price can be stale before it is considered invalid.
uint32 private immutable i_stalenessThreshold;
uint32 private immutable i_tokenStalenessThreshold;

constructor(
StaticConfig memory staticConfig,
Expand All @@ -218,14 +218,14 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,
) AuthorizedCallers(priceUpdaters) {
if (
staticConfig.linkToken == address(0) || staticConfig.maxFeeJuelsPerMsg == 0
|| staticConfig.stalenessThreshold == 0
|| staticConfig.tokenStalenessThreshold == 0
) {
revert InvalidStaticConfig();
}

i_linkToken = staticConfig.linkToken;
i_maxFeeJuelsPerMsg = staticConfig.maxFeeJuelsPerMsg;
i_stalenessThreshold = staticConfig.stalenessThreshold;
i_tokenStalenessThreshold = staticConfig.tokenStalenessThreshold;

_applyFeeTokensUpdates(feeTokens, new address[](0));
_updateTokenPriceFeeds(tokenPriceFeeds);
Expand All @@ -243,7 +243,7 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,
Internal.TimestampedPackedUint224 memory tokenPrice = s_usdPerToken[token];

// If the token price is not stale, return it
if (block.timestamp - tokenPrice.timestamp < i_stalenessThreshold) {
if (block.timestamp - tokenPrice.timestamp < i_tokenStalenessThreshold) {
return tokenPrice;
}

Expand Down Expand Up @@ -1012,7 +1012,7 @@ contract FeeQuoter is AuthorizedCallers, IFeeQuoter, ITypeAndVersion, IReceiver,
return StaticConfig({
maxFeeJuelsPerMsg: i_maxFeeJuelsPerMsg,
linkToken: i_linkToken,
stalenessThreshold: i_stalenessThreshold
tokenStalenessThreshold: i_tokenStalenessThreshold
});
}
}
10 changes: 5 additions & 5 deletions contracts/src/v0.8/ccip/test/feeQuoter/FeeQuoter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ contract FeeQuoter_constructor is FeeQuoterSetup {
FeeQuoter.StaticConfig memory staticConfig = FeeQuoter.StaticConfig({
linkToken: s_sourceTokens[0],
maxFeeJuelsPerMsg: MAX_MSG_FEES_JUELS,
stalenessThreshold: uint32(TWELVE_HOURS)
tokenStalenessThreshold: uint32(TWELVE_HOURS)
});
s_feeQuoter = new FeeQuoterHelper(
staticConfig,
Expand Down Expand Up @@ -91,7 +91,7 @@ contract FeeQuoter_constructor is FeeQuoterSetup {
FeeQuoter.StaticConfig memory staticConfig = FeeQuoter.StaticConfig({
linkToken: s_sourceTokens[0],
maxFeeJuelsPerMsg: MAX_MSG_FEES_JUELS,
stalenessThreshold: 0
tokenStalenessThreshold: 0
});

vm.expectRevert(FeeQuoter.InvalidStaticConfig.selector);
Expand All @@ -111,7 +111,7 @@ contract FeeQuoter_constructor is FeeQuoterSetup {
FeeQuoter.StaticConfig memory staticConfig = FeeQuoter.StaticConfig({
linkToken: address(0),
maxFeeJuelsPerMsg: MAX_MSG_FEES_JUELS,
stalenessThreshold: uint32(TWELVE_HOURS)
tokenStalenessThreshold: uint32(TWELVE_HOURS)
});

vm.expectRevert(FeeQuoter.InvalidStaticConfig.selector);
Expand All @@ -131,7 +131,7 @@ contract FeeQuoter_constructor is FeeQuoterSetup {
FeeQuoter.StaticConfig memory staticConfig = FeeQuoter.StaticConfig({
linkToken: s_sourceTokens[0],
maxFeeJuelsPerMsg: 0,
stalenessThreshold: uint32(TWELVE_HOURS)
tokenStalenessThreshold: uint32(TWELVE_HOURS)
});

vm.expectRevert(FeeQuoter.InvalidStaticConfig.selector);
Expand Down Expand Up @@ -171,7 +171,7 @@ contract FeeQuoter_getTokenPrice is FeeQuoterSetup {
uint256 originalTimestampValue = block.timestamp;

// Above staleness threshold
vm.warp(originalTimestampValue + s_feeQuoter.getStaticConfig().stalenessThreshold + 1);
vm.warp(originalTimestampValue + s_feeQuoter.getStaticConfig().tokenStalenessThreshold + 1);

address sourceToken = _initialiseSingleTokenPriceFeed();
Internal.TimestampedPackedUint224 memory tokenPriceAnswer = s_feeQuoter.getTokenPrice(sourceToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ contract FeeQuoterSetup is TokenSetup {
FeeQuoter.StaticConfig({
linkToken: s_sourceTokens[0],
maxFeeJuelsPerMsg: MAX_MSG_FEES_JUELS,
stalenessThreshold: uint32(TWELVE_HOURS)
tokenStalenessThreshold: uint32(TWELVE_HOURS)
}),
priceUpdaters,
feeTokens,
Expand Down

0 comments on commit 251be4f

Please sign in to comment.