From b8051c8fed0f42778692de135df922626da3fb4f Mon Sep 17 00:00:00 2001 From: Remco Bloemen Date: Sat, 23 Jun 2018 18:03:49 +0200 Subject: Gas golf the transfer success logic --- .../protocol/AssetProxy/MixinERC20Transfer.sol | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'packages/contracts/src') diff --git a/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC20Transfer.sol b/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC20Transfer.sol index b5f1f9480..54fe7d726 100644 --- a/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC20Transfer.sol +++ b/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC20Transfer.sol @@ -74,17 +74,16 @@ contract MixinERC20Transfer is cdStart, 32 ) - if success { - if returndatasize { - success := 0 - if eq(returndatasize, 32) { - // First 64 bytes of memory are reserved scratch space - returndatacopy(0, 0, 32) - success := mload(0) - } - } - - } + + // The transfer succeeded if the call succeeded and either + // returned nothing, or returned a non-zero 32 byte value. + success := and(success, or( + iszero(returndatasize), + and( + eq(returndatasize, 32), + gt(mload(cdStart), 0) + ) + )) } require( success, -- cgit v1.2.3