aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/src/2.0.0/protocol/Exchange
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/src/2.0.0/protocol/Exchange')
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/MixinAssetProxyDispatcher.sol6
-rw-r--r--packages/contracts/src/2.0.0/protocol/Exchange/libs/LibAbiEncoder.sol18
2 files changed, 13 insertions, 11 deletions
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/MixinAssetProxyDispatcher.sol b/packages/contracts/src/2.0.0/protocol/Exchange/MixinAssetProxyDispatcher.sol
index e9f882194..b34903668 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/MixinAssetProxyDispatcher.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/MixinAssetProxyDispatcher.sol
@@ -159,18 +159,22 @@ contract MixinAssetProxyDispatcher is
}
/////// Call `assetProxy.transferFrom` using the constructed calldata ///////
+ let inputLen := sub(cdEnd, cdStart)
let success := call(
gas, // forward all gas
assetProxy, // call address of asset proxy
0, // don't send any ETH
cdStart, // pointer to start of input
- sub(cdEnd, cdStart), // length of input
+ inputLen, // length of input
cdStart, // write output over input
512 // reserve 512 bytes for output
)
if iszero(success) {
revert(cdStart, returndatasize())
}
+
+ // Increment free memory pointer
+ mstore(64, add(cdStart, inputLen))
}
}
}
diff --git a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibAbiEncoder.sol b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibAbiEncoder.sol
index 704c7061c..f047342b3 100644
--- a/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibAbiEncoder.sol
+++ b/packages/contracts/src/2.0.0/protocol/Exchange/libs/LibAbiEncoder.sol
@@ -24,20 +24,17 @@ import "./LibOrder.sol";
contract LibAbiEncoder {
- /// @dev ABI encodes calldata for `fillOrder` in memory and returns the address range.
- /// This range can be passed into `call` or `delegatecall` to invoke an external
- /// call to `fillOrder`.
+ /// @dev ABI encodes calldata for `fillOrder`.
/// @param order Order struct containing order specifications.
/// @param takerAssetFillAmount Desired amount of takerAsset to sell.
/// @param signature Proof that order has been created by maker.
- /// @return calldataBegin Memory address of ABI encoded calldata.
- /// @return calldataLength Lenfgth of ABI encoded calldata.
+ /// @return ABI encoded calldata for `fillOrder`.
function abiEncodeFillOrder(
LibOrder.Order memory order,
uint256 takerAssetFillAmount,
bytes memory signature
)
- public
+ internal
pure
returns (bytes memory fillOrderCalldata)
{
@@ -207,10 +204,11 @@ contract LibAbiEncoder {
}
// Set length of calldata
- mstore(
- fillOrderCalldata,
- sub(dataAreaEnd, add(fillOrderCalldata, 0x20))
- )
+ let calldataLen := sub(dataAreaEnd, add(fillOrderCalldata, 0x20))
+ mstore(fillOrderCalldata, calldataLen)
+
+ // Increment free memory pointer
+ mstore(0x40, add(fillOrderCalldata, add(calldataLen, 0x20)))
}
return fillOrderCalldata;