diff --git a/contracts/upgradeable-Bridge/FiberRouter.sol b/contracts/upgradeable-Bridge/FiberRouter.sol index 1722416..a6b0b13 100644 --- a/contracts/upgradeable-Bridge/FiberRouter.sol +++ b/contracts/upgradeable-Bridge/FiberRouter.sol @@ -4,7 +4,6 @@ pragma solidity 0.8.2; import "./FundManager.sol"; import "../common/uniswap/IUniswapV2Router02.sol"; import "../common/uniswap/IWETH.sol"; -import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; @@ -73,11 +72,11 @@ contract FiberRouter is ReentrancyGuardUpgradeable, OwnableUpgradeable { @param _token The foundry token address @param _oracleAddress The oracle address for price feed */ - function setOracle(address _token, address _oracleAddress) + function setOracle(address _token, AggregatorV3Interface _oracleAddress) external onlyOwner { - priceFeed[_token] = AggregatorV3Interface(_oracleAddress); + priceFeed[_token] = _oracleAddress; } function getFoundryTokenPrice(address _token) @@ -86,12 +85,11 @@ contract FiberRouter is ReentrancyGuardUpgradeable, OwnableUpgradeable { returns (uint256) { ( - , - /*uint80 roundID*/ - int256 price, /*uint startedAt*/ /*uint timeStamp*/ /*uint80 answeredInRound*/ - , - , - + /*uint80 roundID*/, + int256 price, + /*uint startedAt*/, + /*uint timeStamp*/, + /*uint80 answeredInRound*/ ) = priceFeed[_token].latestRoundData(); uint8 baseDecimals = priceFeed[_token].decimals(); return uint256(price) * 10**(18 - baseDecimals); @@ -127,7 +125,7 @@ contract FiberRouter is ReentrancyGuardUpgradeable, OwnableUpgradeable { targetToken, targetAddress ); - Swap( + emit Swap( token, targetToken, block.chainid, @@ -217,7 +215,7 @@ contract FiberRouter is ReentrancyGuardUpgradeable, OwnableUpgradeable { crossTargetNetwork, crossTargetToken ); - Swap( + emit Swap( path[0], crossTargetToken, block.chainid, @@ -313,7 +311,7 @@ contract FiberRouter is ReentrancyGuardUpgradeable, OwnableUpgradeable { crossTargetNetwork, crossTargetToken ); - Swap( + emit Swap( path[0], crossTargetToken, block.chainid, diff --git a/contracts/upgradeable-Bridge/FundManager.sol b/contracts/upgradeable-Bridge/FundManager.sol index db7ab50..b3f8582 100644 --- a/contracts/upgradeable-Bridge/FundManager.sol +++ b/contracts/upgradeable-Bridge/FundManager.sol @@ -1,17 +1,14 @@ // SPDX-License-Identifier: MIT pragma solidity 0.8.2; -import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; -import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol"; import "../common/signature/SigCheckable.sol"; import "../common/SafeAmount.sol"; import "../common/WithAdmin.sol"; import "../taxing/IGeneralTaxDistributor.sol"; -contract FundManager is SigCheckable, WithAdmin, ReentrancyGuardUpgradeable { +contract FundManager is SigCheckable, WithAdmin { using SafeERC20Upgradeable for IERC20Upgradeable; address public router; @@ -74,7 +71,6 @@ contract FundManager is SigCheckable, WithAdmin, ReentrancyGuardUpgradeable { function initialize() external initializer { __EIP712_init(NAME, VERSION); __Ownable_init(); - __ReentrancyGuard_init(); } /** @@ -313,14 +309,13 @@ contract FundManager is SigCheckable, WithAdmin, ReentrancyGuardUpgradeable { address _signer = signerUnique(message, signature); require(signers[_signer], "BridgePool: Invalid signer"); - uint256 fee = 0; - address _feeDistributor = feeDistributor; - if (_feeDistributor != address(0)) { + uint256 fee; + if (feeDistributor != address(0)) { fee = (amount * fees[token]) / 10000; amount -= fee; if (fee != 0) { - IERC20Upgradeable(token).safeTransfer(_feeDistributor, fee); - IGeneralTaxDistributor(_feeDistributor).distributeTax(token); + IERC20Upgradeable(token).safeTransfer(feeDistributor, fee); + IGeneralTaxDistributor(feeDistributor).distributeTax(token); } } IERC20Upgradeable(token).safeTransfer(payee, amount); @@ -430,15 +425,15 @@ contract FundManager is SigCheckable, WithAdmin, ReentrancyGuardUpgradeable { address targetToken, address targetAddress ) internal returns (uint256) { - require( - targetAddress != address(0), - "BridgePool: targetAddress is required" - ); require(from != address(0), "BP: bad from"); require(token != address(0), "BP: bad token"); + require(amount != 0, "BP: bad amount"); require(targetNetwork != 0, "BP: targetNetwork is requried"); require(targetToken != address(0), "BP: bad target token"); - require(amount != 0, "BP: bad amount"); + require( + targetAddress != address(0), + "BridgePool: targetAddress is required" + ); require( allowedTargets[token][targetNetwork] == targetToken, "BP: target not allowed"