Skip to content

Commit

Permalink
fix: check msg.value when doing a token transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiTimesChi committed Oct 8, 2024
1 parent 84ca58b commit 8fd76b1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/contracts-rfq/contracts/FastBridgeV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,11 @@ contract FastBridgeV2 is Admin, IFastBridgeV2, IFastBridgeV2Errors {
function _pullToken(address recipient, address token, uint256 amount) internal returns (uint256 amountPulled) {
if (token != UniversalTokenLib.ETH_ADDRESS) {
token.assertIsContract();
// Record token balance before transfer
amountPulled = IERC20(token).balanceOf(recipient);
// Token needs to be pulled only if msg.value is zero
// This way user can specify WETH as the origin asset
if (msg.value != 0) revert MsgValueIncorrect();
// Record token balance before transfer
amountPulled = IERC20(token).balanceOf(recipient);
IERC20(token).safeTransferFrom(msg.sender, recipient, amount);
// Use the difference between the recorded balance and the current balance as the amountPulled
amountPulled = IERC20(token).balanceOf(recipient) - amountPulled;
Expand Down

0 comments on commit 8fd76b1

Please sign in to comment.