aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorRemco Bloemen <remco@wicked.ventures>2018-06-26 03:40:10 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-06-27 03:23:19 +0800
commitb79588c4a0802e37f8e173846ad0b12e88901ae3 (patch)
tree21cf694dcd3443c6723f35ebf20ae659c1d12176 /packages
parent3b46e82625fbb16ad4068851df5a2d96ff448f35 (diff)
downloaddexon-sol-tools-b79588c4a0802e37f8e173846ad0b12e88901ae3.tar
dexon-sol-tools-b79588c4a0802e37f8e173846ad0b12e88901ae3.tar.gz
dexon-sol-tools-b79588c4a0802e37f8e173846ad0b12e88901ae3.tar.bz2
dexon-sol-tools-b79588c4a0802e37f8e173846ad0b12e88901ae3.tar.lz
dexon-sol-tools-b79588c4a0802e37f8e173846ad0b12e88901ae3.tar.xz
dexon-sol-tools-b79588c4a0802e37f8e173846ad0b12e88901ae3.tar.zst
dexon-sol-tools-b79588c4a0802e37f8e173846ad0b12e88901ae3.zip
ERC20 manual memory layout
Diffstat (limited to 'packages')
-rw-r--r--packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC20Transfer.sol17
1 files changed, 6 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 fce8da7c7..2cb12aa6b 100644
--- a/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC20Transfer.sol
+++ b/packages/contracts/src/contracts/current/protocol/AssetProxy/MixinERC20Transfer.sol
@@ -99,29 +99,25 @@ contract MixinERC20Transfer is
// So we read location 4 and add 32 + 4 + 4 to it.
let token := calldataload(add(calldataload(4), 40))
- /////// Setup State ///////
- // `cdStart` is the start of the calldata for `token.transferFrom` (equal to free memory ptr).
- let cdStart := mload(64)
-
/////// Setup Header Area ///////
// This area holds the 4-byte `transferFrom` selector.
// Any trailing data in transferFromSelector will be
// overwritten in the next `mstore` call.
- mstore(cdStart, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
+ mstore(0, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
/////// Setup Params Area ///////
// We copy the fields `from`, `to` and `amount` in bulk
// from our own calldata to the new calldata.
- calldatacopy(add(cdStart, 4), 36, 96)
+ calldatacopy(4, 36, 96)
/////// Call `token.transferFrom` using the calldata ///////
let success := call(
gas, // forward all gas
token, // call address of token contract
0, // don't send any ETH
- cdStart, // pointer to start of input
+ 0, // pointer to start of input
100, // length of input
- cdStart, // write output over input
+ 0, // write output over input
32 // output size should be 32 bytes
)
@@ -137,7 +133,7 @@ contract MixinERC20Transfer is
iszero(returndatasize),
and(
eq(returndatasize, 32),
- gt(mload(cdStart), 0)
+ gt(mload(0), 0)
)
))
if success {
@@ -152,8 +148,7 @@ contract MixinERC20Transfer is
revert(0, 100)
}
}
-
-
+
/// @dev Internal version of `transferFrom`.
/// @param assetData Encoded byte array.
/// @param from Address to transfer asset from.