Skip to content

Commit

Permalink
feat: remove ccip dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
CheyenneAtapour committed Jul 18, 2024
1 parent 2b87923 commit cd06a01
Show file tree
Hide file tree
Showing 25 changed files with 1,190 additions and 17 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,3 @@
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/ccip"]
path = lib/ccip
url = https://github.com/aave/ccip
1 change: 0 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ aave-v3-periphery/=lib/aave-address-book/lib/aave-v3-periphery/
erc4626-tests/=lib/aave-stk-v1-5/lib/openzeppelin-contracts/lib/erc4626-tests/
openzeppelin-contracts/=lib/aave-stk-v1-5/lib/openzeppelin-contracts/
solidity-utils/=lib/solidity-utils/src/
ccip/=lib/ccip/contracts/src/
6 changes: 3 additions & 3 deletions src/contracts/misc/ArbGhoSteward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.10;

import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol';
import {IOwnable} from 'ccip/v0.8/shared/interfaces/IOwnable.sol';
import {IOwnable} from './mocks/IOwnable.sol';
import {EnumerableSet} from '@openzeppelin/contracts/utils/structs/EnumerableSet.sol';
import {IPoolAddressesProvider} from '@aave/core-v3/contracts/interfaces/IPoolAddressesProvider.sol';
import {IPoolConfigurator} from '@aave/core-v3/contracts/interfaces/IPoolConfigurator.sol';
Expand All @@ -16,8 +16,8 @@ import {IGsm} from '../facilitators/gsm/interfaces/IGsm.sol';
import {IGsmFeeStrategy} from '../facilitators/gsm/feeStrategy/interfaces/IGsmFeeStrategy.sol';
import {IGhoToken} from '../gho/interfaces/IGhoToken.sol';
import {IArbGhoSteward} from './interfaces/IArbGhoSteward.sol';
import {UpgradeableBurnMintTokenPool} from 'ccip/v0.8/ccip/pools/GHO/UpgradeableBurnMintTokenPool.sol';
import {RateLimiter} from 'ccip/v0.8/ccip/libraries/RateLimiter.sol';
import {UpgradeableBurnMintTokenPool} from './mocks/UpgradeableBurnMintTokenPool.sol';
import {RateLimiter} from './mocks/RateLimiter.sol';

/**
* @title ArbGhoSteward
Expand Down
4 changes: 2 additions & 2 deletions src/contracts/misc/GhoStewardV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {IGsm} from '../facilitators/gsm/interfaces/IGsm.sol';
import {IGsmFeeStrategy} from '../facilitators/gsm/feeStrategy/interfaces/IGsmFeeStrategy.sol';
import {IGhoToken} from '../gho/interfaces/IGhoToken.sol';
import {IGhoStewardV2} from './interfaces/IGhoStewardV2.sol';
import {UpgradeableLockReleaseTokenPool} from 'ccip/v0.8/ccip/pools/GHO/UpgradeableLockReleaseTokenPool.sol';
import {RateLimiter} from 'ccip/v0.8/ccip/libraries/RateLimiter.sol';
import {UpgradeableLockReleaseTokenPool} from './mocks/UpgradeableLockReleaseTokenPool.sol';
import {RateLimiter} from './mocks/RateLimiter.sol';

/**
* @title GhoStewardV2
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/misc/interfaces/IArbGhoSteward.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 {RateLimiter} from 'ccip/v0.8/ccip/libraries/RateLimiter.sol';
import {RateLimiter} from '../mocks/RateLimiter.sol';

/**
* @title IGhoStewardV2
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/misc/interfaces/IGhoStewardV2.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 {RateLimiter} from 'ccip/v0.8/ccip/libraries/RateLimiter.sol';
import {RateLimiter} from '../mocks/RateLimiter.sol';

/**
* @title IGhoStewardV2
Expand Down
38 changes: 38 additions & 0 deletions src/contracts/misc/mocks/Client.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

// End consumer library.
library Client {
/// @dev RMN depends on this struct, if changing, please notify the RMN maintainers.
struct EVMTokenAmount {
address token; // token address on the local chain.
uint256 amount; // Amount of tokens.
}

struct Any2EVMMessage {
bytes32 messageId; // MessageId corresponding to ccipSend on source.
uint64 sourceChainSelector; // Source chain selector.
bytes sender; // abi.decode(sender) if coming from an EVM chain.
bytes data; // payload sent in original message.
EVMTokenAmount[] destTokenAmounts; // Tokens and their amounts in their destination chain representation.
}

// If extraArgs is empty bytes, the default is 200k gas limit.
struct EVM2AnyMessage {
bytes receiver; // abi.encode(receiver address) for dest EVM chains
bytes data; // Data payload
EVMTokenAmount[] tokenAmounts; // Token transfers
address feeToken; // Address of feeToken. address(0) means you will send msg.value.
bytes extraArgs; // Populate this with _argsToBytes(EVMExtraArgsV1)
}

// bytes4(keccak256("CCIP EVMExtraArgsV1"));
bytes4 public constant EVM_EXTRA_ARGS_V1_TAG = 0x97a657c9;
struct EVMExtraArgsV1 {
uint256 gasLimit;
}

function _argsToBytes(EVMExtraArgsV1 memory extraArgs) internal pure returns (bytes memory bts) {
return abi.encodeWithSelector(EVM_EXTRA_ARGS_V1_TAG, extraArgs);
}
}
10 changes: 10 additions & 0 deletions src/contracts/misc/mocks/ConfirmedOwner.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

/// @title The ConfirmedOwner contract
/// @notice A contract with helpers for basic contract ownership.
contract ConfirmedOwner is ConfirmedOwnerWithProposal {
constructor(address newOwner) ConfirmedOwnerWithProposal(newOwner, address(0)) {}
}
65 changes: 65 additions & 0 deletions src/contracts/misc/mocks/ConfirmedOwnerWithProposal.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

/// @title The ConfirmedOwner contract
/// @notice A contract with helpers for basic contract ownership.
contract ConfirmedOwnerWithProposal is IOwnable {
address private s_owner;
address private s_pendingOwner;

event OwnershipTransferRequested(address indexed from, address indexed to);
event OwnershipTransferred(address indexed from, address indexed to);

constructor(address newOwner, address pendingOwner) {
// solhint-disable-next-line custom-errors
require(newOwner != address(0), 'Cannot set owner to zero');

s_owner = newOwner;
if (pendingOwner != address(0)) {
_transferOwnership(pendingOwner);
}
}

/// @notice Allows an owner to begin transferring ownership to a new address.
function transferOwnership(address to) public override onlyOwner {
_transferOwnership(to);
}

/// @notice Allows an ownership transfer to be completed by the recipient.
function acceptOwnership() external override {
// solhint-disable-next-line custom-errors
require(msg.sender == s_pendingOwner, 'Must be proposed owner');

address oldOwner = s_owner;
s_owner = msg.sender;
s_pendingOwner = address(0);

emit OwnershipTransferred(oldOwner, msg.sender);
}

/// @notice Get the current owner
function owner() public view override returns (address) {
return s_owner;
}

/// @notice validate, transfer ownership, and emit relevant events
function _transferOwnership(address to) internal {
s_pendingOwner = to;

emit OwnershipTransferRequested(s_owner, to);
}

/// @notice validate access
function _validateOwnership() internal view {
// solhint-disable-next-line custom-errors
require(msg.sender == s_owner, 'Only callable by owner');
}

/// @notice Reverts if called by anyone other than the contract owner.
modifier onlyOwner() {
_validateOwnership();
_;
}
}
17 changes: 17 additions & 0 deletions src/contracts/misc/mocks/IARM.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @notice This interface contains the only ARM-related functions that might be used on-chain by other CCIP contracts.
interface IARM {
/// @notice A Merkle root tagged with the address of the commit store contract it is destined for.
struct TaggedRoot {
address commitStore;
bytes32 root;
}

/// @notice Callers MUST NOT cache the return value as a blessed tagged root could become unblessed.
function isBlessed(TaggedRoot calldata taggedRoot) external view returns (bool);

/// @notice When the ARM is "cursed", CCIP pauses until the curse is lifted.
function isCursed() external view returns (bool);
}
29 changes: 29 additions & 0 deletions src/contracts/misc/mocks/IBurnMintERC20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';

interface IBurnMintERC20 is IERC20 {
/// @notice Mints new tokens for a given address.
/// @param account The address to mint the new tokens to.
/// @param amount The number of tokens to be minted.
/// @dev this function increases the total supply.
function mint(address account, uint256 amount) external;

/// @notice Burns tokens from the sender.
/// @param amount The number of tokens to be burned.
/// @dev this function decreases the total supply.
function burn(uint256 amount) external;

/// @notice Burns tokens from a given address..
/// @param account The address to burn tokens from.
/// @param amount The number of tokens to be burned.
/// @dev this function decreases the total supply.
function burn(address account, uint256 amount) external;

/// @notice Burns tokens from a given address..
/// @param account The address to burn tokens from.
/// @param amount The number of tokens to be burned.
/// @dev this function decreases the total supply.
function burnFrom(address account, uint256 amount) external;
}
16 changes: 16 additions & 0 deletions src/contracts/misc/mocks/ILiquidityContainer.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

/// @notice Interface for a liquidity container, this can be a CCIP token pool.
interface ILiquidityContainer {
event LiquidityAdded(address indexed provider, uint256 indexed amount);
event LiquidityRemoved(address indexed provider, uint256 indexed amount);

/// @notice Provide additional liquidity to the container.
/// @dev Should emit LiquidityAdded
function provideLiquidity(uint256 amount) external;

/// @notice Withdraws liquidity from the container to the msg sender
/// @dev Should emit LiquidityRemoved
function withdrawLiquidity(uint256 amount) external;
}
10 changes: 10 additions & 0 deletions src/contracts/misc/mocks/IOwnable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IOwnable {
function owner() external returns (address);

function transferOwnership(address recipient) external;

function acceptOwnership() external;
}
46 changes: 46 additions & 0 deletions src/contracts/misc/mocks/IPool.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol';

// Shared public interface for multiple pool types.
// Each pool type handles a different child token model (lock/unlock, mint/burn.)
interface IPool {
/// @notice Lock tokens into the pool or burn the tokens.
/// @param originalSender Original sender of the tokens.
/// @param receiver Receiver of the tokens on destination chain.
/// @param amount Amount to lock or burn.
/// @param remoteChainSelector Destination chain Id.
/// @param extraArgs Additional data passed in by sender for lockOrBurn processing
/// in custom pools on source chain.
/// @return retData Optional field that contains bytes. Unused for now but already
/// implemented to allow future upgrades while preserving the interface.
function lockOrBurn(
address originalSender,
bytes calldata receiver,
uint256 amount,
uint64 remoteChainSelector,
bytes calldata extraArgs
) external returns (bytes memory);

/// @notice Releases or mints tokens to the receiver address.
/// @param originalSender Original sender of the tokens.
/// @param receiver Receiver of the tokens.
/// @param amount Amount to release or mint.
/// @param remoteChainSelector Source chain Id.
/// @param extraData Additional data supplied offchain for releaseOrMint processing in
/// custom pools on dest chain. This could be an attestation that was retrieved through a
/// third party API.
/// @dev offchainData can come from any untrusted source.
function releaseOrMint(
bytes memory originalSender,
address receiver,
uint256 amount,
uint64 remoteChainSelector,
bytes memory extraData
) external;

/// @notice Gets the IERC20 token that this pool can lock or burn.
/// @return token The IERC20 token representation.
function getToken() external view returns (IERC20 token);
}
38 changes: 38 additions & 0 deletions src/contracts/misc/mocks/IRouter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

interface IRouter {
error OnlyOffRamp();

/// @notice Route the message to its intended receiver contract.
/// @param message Client.Any2EVMMessage struct.
/// @param gasForCallExactCheck of params for exec
/// @param gasLimit set of params for exec
/// @param receiver set of params for exec
/// @dev if the receiver is a contracts that signals support for CCIP execution through EIP-165.
/// the contract is called. If not, only tokens are transferred.
/// @return success A boolean value indicating whether the ccip message was received without errors.
/// @return retBytes A bytes array containing return data form CCIP receiver.
/// @return gasUsed the gas used by the external customer call. Does not include any overhead.
function routeMessage(
Client.Any2EVMMessage calldata message,
uint16 gasForCallExactCheck,
uint256 gasLimit,
address receiver
) external returns (bool success, bytes memory retBytes, uint256 gasUsed);

/// @notice Returns the configured onramp for a specific destination chain.
/// @param destChainSelector The destination chain Id to get the onRamp for.
/// @return onRampAddress The address of the onRamp.
function getOnRamp(uint64 destChainSelector) external view returns (address onRampAddress);

/// @notice Return true if the given offRamp is a configured offRamp for the given source chain.
/// @param sourceChainSelector The source chain selector to check.
/// @param offRamp The address of the offRamp to check.
function isOffRamp(
uint64 sourceChainSelector,
address offRamp
) external view returns (bool isOffRamp);
}
6 changes: 6 additions & 0 deletions src/contracts/misc/mocks/ITypeAndVersion.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface ITypeAndVersion {
function typeAndVersion() external pure returns (string memory);
}
10 changes: 10 additions & 0 deletions src/contracts/misc/mocks/OwnerIsCreator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

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

/// @title The OwnerIsCreator contract
/// @notice A contract with helpers for basic contract ownership.
contract OwnerIsCreator is ConfirmedOwner {
constructor() ConfirmedOwner(msg.sender) {}
}
Loading

0 comments on commit cd06a01

Please sign in to comment.