diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..eda0dbc Binary files /dev/null and b/.DS_Store differ diff --git a/contracts/Lock.sol b/contracts/Lock.sol deleted file mode 100644 index 50935f6..0000000 --- a/contracts/Lock.sol +++ /dev/null @@ -1,34 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.9; - -// Uncomment this line to use console.log -// import "hardhat/console.sol"; - -contract Lock { - uint public unlockTime; - address payable public owner; - - event Withdrawal(uint amount, uint when); - - constructor(uint _unlockTime) payable { - require( - block.timestamp < _unlockTime, - "Unlock time should be in the future" - ); - - unlockTime = _unlockTime; - owner = payable(msg.sender); - } - - function withdraw() public { - // Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal - // console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp); - - require(block.timestamp >= unlockTime, "You can't withdraw yet"); - require(msg.sender == owner, "You aren't the owner"); - - emit Withdrawal(address(this).balance, block.timestamp); - - owner.transfer(address(this).balance); - } -} diff --git a/contracts/ccip_token_transfer/LinkiSwapMultipleFeeTokenSender.sol b/contracts/ccip_token_transfer/LinkiSwapMultipleFeeTokenSender.sol index c67ab50..56ad629 100644 --- a/contracts/ccip_token_transfer/LinkiSwapMultipleFeeTokenSender.sol +++ b/contracts/ccip_token_transfer/LinkiSwapMultipleFeeTokenSender.sol @@ -5,6 +5,7 @@ import {IRouterClient} from "@chainlink/contracts-ccip/src/v0.8/ccip/interfaces/ import {OwnerIsCreator} from "@chainlink/contracts-ccip/src/v0.8/shared/access/OwnerIsCreator.sol"; import {Client} from "@chainlink/contracts-ccip/src/v0.8/ccip/libraries/Client.sol"; import {IERC20} from "@chainlink/contracts-ccip/src/v0.8/vendor/openzeppelin-solidity/v4.8.0/token/ERC20/IERC20.sol"; +import {AggregatorV3Interface} from "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; contract LinkiSwapMultipleFeeTokenTransferor is OwnerIsCreator { @@ -32,12 +33,18 @@ contract LinkiSwapMultipleFeeTokenTransferor is OwnerIsCreator { IERC20 private s_linkToken; + AggregatorV3Interface internal dataFeed; + /// @notice Constructor initializes the contract with the router address. /// @param _router The address of the router contract. /// @param _link The address of the link contract. constructor(address _router, address _link) { s_router = IRouterClient(_router); s_linkToken = IERC20(_link); + + // BTC/ETH price feed contract address + dataFeed = AggregatorV3Interface(0x5fb1616F78dA7aFC9FF79e0371741a747D2a7F22); + // Other price feed for other cryptos should be initialise here } /// @dev Modifier that checks if the chain with the given destinationChainSelector is allowlisted. @@ -229,6 +236,20 @@ contract LinkiSwapMultipleFeeTokenTransferor is OwnerIsCreator { /// It is automatically called when Ether is transferred to the contract without any data. receive() external payable {} + /** + * Returns the latest answer. + */ + function getChainlinkDataFeedLatestAnswer() public view returns (int) { + ( + /* uint80 roundID */, + int answer, + /*uint startedAt*/, + /*uint timeStamp*/, + /*uint80 answeredInRound*/ + ) = dataFeed.latestRoundData(); + return answer; + } + /// @notice Allows the contract owner to withdraw the entire balance of Ether from the contract. /// @dev This function reverts if there are no funds to withdraw or if the transfer fails. /// It should only be callable by the owner of the contract.