From 5c1632d9b7fc4e8b058cc5bbb7fdb06b51714c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lz=2Esir=CE=94rthurmoney=28=29?= Date: Tue, 7 Nov 2023 17:46:24 -0800 Subject: [PATCH] adding outboundAmount to NativeOFTV2 and NativeOFTWithFee --- contracts/token/oft/v2/NativeOFTV2.sol | 5 +++++ contracts/token/oft/v2/fee/NativeOFTWithFee.sol | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/contracts/token/oft/v2/NativeOFTV2.sol b/contracts/token/oft/v2/NativeOFTV2.sol index 4db4c04d..76a067b2 100644 --- a/contracts/token/oft/v2/NativeOFTV2.sol +++ b/contracts/token/oft/v2/NativeOFTV2.sol @@ -6,6 +6,8 @@ import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "./OFTV2.sol"; contract NativeOFTV2 is OFTV2, ReentrancyGuard { + uint public outboundAmount; + event Deposit(address indexed _dst, uint _amount); event Withdrawal(address indexed _src, uint _amount); @@ -115,6 +117,7 @@ contract NativeOFTV2 is OFTV2, ReentrancyGuard { function _debitMsgSender(uint _amount) internal returns (uint messageFee) { uint msgSenderBalance = balanceOf(msg.sender); + outboundAmount += _amount; if (msgSenderBalance < _amount) { require(msgSenderBalance + msg.value >= _amount, "NativeOFTV2: Insufficient msg.value"); @@ -135,6 +138,7 @@ contract NativeOFTV2 is OFTV2, ReentrancyGuard { function _debitMsgFrom(address _from, uint _amount) internal returns (uint messageFee) { uint msgFromBalance = balanceOf(_from); + outboundAmount += _amount; if (msgFromBalance < _amount) { require(msgFromBalance + msg.value >= _amount, "NativeOFTV2: Insufficient msg.value"); @@ -165,6 +169,7 @@ contract NativeOFTV2 is OFTV2, ReentrancyGuard { address _toAddress, uint _amount ) internal override returns (uint) { + outboundAmount -= _amount; _burn(address(this), _amount); (bool success, ) = _toAddress.call{value: _amount}(""); require(success, "NativeOFTV2: failed to _creditTo"); diff --git a/contracts/token/oft/v2/fee/NativeOFTWithFee.sol b/contracts/token/oft/v2/fee/NativeOFTWithFee.sol index efe270a8..0d9cf62c 100644 --- a/contracts/token/oft/v2/fee/NativeOFTWithFee.sol +++ b/contracts/token/oft/v2/fee/NativeOFTWithFee.sol @@ -6,7 +6,6 @@ import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "./OFTWithFee.sol"; contract NativeOFTWithFee is OFTWithFee, ReentrancyGuard { - uint public outboundAmount; event Deposit(address indexed _dst, uint _amount); @@ -89,6 +88,7 @@ contract NativeOFTWithFee is OFTWithFee, ReentrancyGuard { function _debitMsgSender(uint _amount, uint currentMsgValue) internal returns (uint messageFee) { uint msgSenderBalance = balanceOf(msg.sender); + outboundAmount += _amount; if (msgSenderBalance < _amount) { require(msgSenderBalance + currentMsgValue >= _amount, "NativeOFTWithFee: Insufficient msg.value"); @@ -105,12 +105,12 @@ contract NativeOFTWithFee is OFTWithFee, ReentrancyGuard { } _transfer(msg.sender, address(this), _amount); - outboundAmount += _amount; return messageFee; } function _debitMsgFrom(address _from, uint _amount, uint currentMsgValue) internal returns (uint messageFee) { uint msgFromBalance = balanceOf(_from); + outboundAmount += _amount; if (msgFromBalance < _amount) { require(msgFromBalance + currentMsgValue >= _amount, "NativeOFTWithFee: Insufficient msg.value"); @@ -133,7 +133,6 @@ contract NativeOFTWithFee is OFTWithFee, ReentrancyGuard { _spendAllowance(_from, msg.sender, _amount); _transfer(_from, address(this), _amount); - outboundAmount += _amount; return messageFee; }