From faca8b2788608550c7b328910e8fc13b2a43e93d Mon Sep 17 00:00:00 2001 From: Gino Date: Sun, 10 Dec 2023 04:21:37 +0100 Subject: [PATCH 1/2] initialize data feeds contract address --- .DS_Store | Bin 0 -> 6148 bytes contracts/Lock.sol | 34 ------------------ .../LinkiSwapMultipleFeeTokenSender.sol | 14 ++++++++ 3 files changed, 14 insertions(+), 34 deletions(-) create mode 100644 .DS_Store delete mode 100644 contracts/Lock.sol diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..eda0dbc1ebf673414ef4f226276962d684dd5e3d GIT binary patch literal 6148 zcmeHKO>fgM7=FDKnlL7H5(q9xk+_aB*i<2L38g#iz-2{n092ADbfH;XB`G~rm3jsK z1Al=d|AfB-&ue>9(ss8Ap~GFTC*+F z!aSj39;daFQlPd2sMsY;8Ag+-y2cXUF-_Ka;b58I;qa8|3e}_FBp`yeJ3Zn%dR3dQZ~4##!eLF?Xpess9+J?%VO?0fSLmyZrRi-qgl zefaqK>0q3mXY#B1bP_nKlRBCQ>3t@wh`|WB{V`! z9ey?Oeu7mMZ;vMGm>eS?QB030h5SPrgZ-HbUW${n8bLf*iEw)*!ezYgD?FD@=@^UI zqgTK-ol{gFNiFn`%0f5sJwwbk!HAn@R`qVcCkCUeM^)cn_1ooGE4po-InSWVMAh0= zDPT5&vvXAeZ5*qBRp8nvz~_U9#ONDbYE(xDGW7%iHqfjLW&UAcj%Uy}xYURqn9x+9 zrV8`K5Sos5&-nQUml`#lgn4`jGqNx*6rn~(d{4QP@HN`pDqt0;E3mDrEx!McFMt2n zNw#JcunJr&1w^CQ?{zUHbGNQdj_+Cz=_3*w`z= 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..ca8b6e6 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,13 @@ contract LinkiSwapMultipleFeeTokenTransferor is OwnerIsCreator { /// It is automatically called when Ether is transferred to the contract without any data. receive() external payable {} + + + + + + + /// @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. From ff0e6f06f061a57c0d86700317622960eb3ac797 Mon Sep 17 00:00:00 2001 From: Gino Date: Sun, 10 Dec 2023 04:26:30 +0100 Subject: [PATCH 2/2] create the getChainlinkDataFeeds function --- .../LinkiSwapMultipleFeeTokenSender.sol | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/contracts/ccip_token_transfer/LinkiSwapMultipleFeeTokenSender.sol b/contracts/ccip_token_transfer/LinkiSwapMultipleFeeTokenSender.sol index ca8b6e6..56ad629 100644 --- a/contracts/ccip_token_transfer/LinkiSwapMultipleFeeTokenSender.sol +++ b/contracts/ccip_token_transfer/LinkiSwapMultipleFeeTokenSender.sol @@ -236,12 +236,19 @@ 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.