aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts
diff options
context:
space:
mode:
authorRemco Bloemen <remco@wicked.ventures>2018-06-24 00:03:49 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-06-26 07:19:07 +0800
commitb8051c8fed0f42778692de135df922626da3fb4f (patch)
treeb1be526e9fedcbbed137895d01e8347add2c8b5a /packages/contracts
parent4df66a4802fc75cd9d3e0c01a92e1cc1ae3dfd58 (diff)
downloaddexon-sol-tools-b8051c8fed0f42778692de135df922626da3fb4f.tar.gz
dexon-sol-tools-b8051c8fed0f42778692de135df922626da3fb4f.tar.zst
dexon-sol-tools-b8051c8fed0f42778692de135df922626da3fb4f.zip
Gas golf the transfer success logic
Diffstat (limited to 'packages/contracts')
-rw-r--r--packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC20Transfer.sol21
1 files changed, 10 insertions, 11 deletions
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,