From 6043e7ba66c3cc8c457b2184125983184aec0356 Mon Sep 17 00:00:00 2001 From: Kuba Wlodarczyk Date: Fri, 4 Aug 2023 10:32:48 +0200 Subject: [PATCH] Update SendToken v2 functionality and description --- .../contracts/v2/actions/common/SendToken.sol | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/packages/dma-contracts/contracts/v2/actions/common/SendToken.sol b/packages/dma-contracts/contracts/v2/actions/common/SendToken.sol index 4f1981705..4d5cd5bd6 100644 --- a/packages/dma-contracts/contracts/v2/actions/common/SendToken.sol +++ b/packages/dma-contracts/contracts/v2/actions/common/SendToken.sol @@ -9,15 +9,11 @@ import { ETH } from "../../../core/constants/Common.sol"; /** * @title SendToken Action contract - * @notice This contract has the ability to send ERC20 tokens and native ETH. + * @notice This contract has the ability to send ERC20 tokens and native token. * The assumption is that this contract is called with a delegatecall using a proxy contract. - * - The amount of ERC20 token can be transferred is either an amount + * The amount of ERC20 or native token can be transferred is either an amount * that's been received in the current transaction ( through the usage of other actions) - * or some amount that has been transferred prior this transaction - * - The amount of ETH that can be transferred is either the whole or - * partial ( whether some amount has been used in other actions) amount from the - * amount that the transaction has been called with ( msg.value ). If the proxy contract - * contains any prior ETH balance, it CANNOT be transferred. + * or some amount that has been transferred prior this transaction. */ contract SendTokenV2 is Executable, UseStorageSlot { using SafeERC20 for IERC20; @@ -30,13 +26,16 @@ contract SendTokenV2 is Executable, UseStorageSlot { SendTokenData memory send = parseInputs(data); send.amount = store().readUint(bytes32(send.amount), paramsMap[2]); - if (msg.value > 0) { - payable(send.to).transfer(msg.value); - } else { + if (send.asset != ETH) { if (send.amount == type(uint256).max) { send.amount = IERC20(send.asset).balanceOf(address(this)); } IERC20(send.asset).safeTransfer(send.to, send.amount); + } else { + if (send.amount == type(uint256).max) { + send.amount = address(this).balance; + } + payable(send.to).transfer(send.amount); } }