Skip to content

Commit

Permalink
fix: add reduced interface
Browse files Browse the repository at this point in the history
  • Loading branch information
CheyenneAtapour committed Aug 9, 2024
1 parent 24a6ba9 commit 81a0ed1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/contracts/misc/GhoCcipSteward.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import {MockUpgradeableLockReleaseTokenPool as UpgradeableLockReleaseTokenPool} from '../../test/mocks/MockUpgradeableLockReleaseTokenPool.sol';
import {IUpgradeableLockReleaseTokenPool} from './deps/IUpgradeableLockReleaseTokenPool.sol';
import {RateLimiter} from './deps/RateLimiter.sol';
import {IGhoCcipSteward} from './interfaces/IGhoCcipSteward.sol';
import {RiskCouncilControlled} from './RiskCouncilControlled.sol';
Expand Down Expand Up @@ -63,13 +63,13 @@ contract GhoCcipSteward is RiskCouncilControlled, IGhoCcipSteward {
) external onlyRiskCouncil notTimelocked(_ccipTimelocks.bridgeLimitLastUpdate) {
require(BRIDGE_LIMIT_ENABLED, 'BRIDGE_LIMIT_DISABLED');

uint256 currentBridgeLimit = UpgradeableLockReleaseTokenPool(GHO_TOKEN_POOL).getBridgeLimit();
uint256 currentBridgeLimit = IUpgradeableLockReleaseTokenPool(GHO_TOKEN_POOL).getBridgeLimit();
require(
_isDifferenceLowerThanMax(currentBridgeLimit, newBridgeLimit, currentBridgeLimit),
'INVALID_BRIDGE_LIMIT_UPDATE'
);

UpgradeableLockReleaseTokenPool(GHO_TOKEN_POOL).setBridgeLimit(newBridgeLimit);
IUpgradeableLockReleaseTokenPool(GHO_TOKEN_POOL).setBridgeLimit(newBridgeLimit);

_ccipTimelocks.bridgeLimitLastUpdate = uint40(block.timestamp);
}
Expand All @@ -84,9 +84,9 @@ contract GhoCcipSteward is RiskCouncilControlled, IGhoCcipSteward {
uint128 inboundCapacity,
uint128 inboundRate
) external onlyRiskCouncil notTimelocked(_ccipTimelocks.rateLimitLastUpdate) {
RateLimiter.TokenBucket memory outboundConfig = UpgradeableLockReleaseTokenPool(GHO_TOKEN_POOL)
RateLimiter.TokenBucket memory outboundConfig = IUpgradeableLockReleaseTokenPool(GHO_TOKEN_POOL)
.getCurrentOutboundRateLimiterState(remoteChainSelector);
RateLimiter.TokenBucket memory inboundConfig = UpgradeableLockReleaseTokenPool(GHO_TOKEN_POOL)
RateLimiter.TokenBucket memory inboundConfig = IUpgradeableLockReleaseTokenPool(GHO_TOKEN_POOL)
.getCurrentInboundRateLimiterState(remoteChainSelector);

require(
Expand All @@ -106,7 +106,7 @@ contract GhoCcipSteward is RiskCouncilControlled, IGhoCcipSteward {
'INVALID_RATE_LIMIT_UPDATE'
);

UpgradeableLockReleaseTokenPool(GHO_TOKEN_POOL).setChainRateLimiterConfig(
IUpgradeableLockReleaseTokenPool(GHO_TOKEN_POOL).setChainRateLimiterConfig(
remoteChainSelector,
RateLimiter.Config({
isEnabled: outboundEnabled,
Expand Down
26 changes: 26 additions & 0 deletions src/contracts/misc/deps/IUpgradeableLockReleaseTokenPool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {RateLimiter} from './RateLimiter.sol';

/// @dev Reduced interface of CCIP UpgradeableLockReleaseTokenPool contract with needed functions only
/// @dev Adapted from https://github.com/aave/ccip/blob/ccip-gho/contracts/src/v0.8/ccip/pools/GHO/UpgradeableLockReleaseTokenPool.sol
interface IUpgradeableLockReleaseTokenPool {
function setBridgeLimit(uint256 newBridgeLimit) external;

function getBridgeLimit() external view returns (uint256);

function getCurrentOutboundRateLimiterState(
uint64 remoteChainSelector
) external view returns (RateLimiter.TokenBucket memory);

function getCurrentInboundRateLimiterState(
uint64 remoteChainSelector
) external view returns (RateLimiter.TokenBucket memory);

function setChainRateLimiterConfig(
uint64 remoteChainSelector,
RateLimiter.Config memory outboundConfig,
RateLimiter.Config memory inboundConfig
) external;
}

0 comments on commit 81a0ed1

Please sign in to comment.