This repository has been archived by the owner on Jul 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@0x/contracts-zero-ex
: Introduce the TransformERC20
feature.
- Loading branch information
1 parent
f9cf097
commit 1fc7d3f
Showing
43 changed files
with
3,520 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
contracts/zero-ex/contracts/src/errors/LibPuppetRichErrors.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
Copyright 2020 ZeroEx Intl. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
pragma solidity ^0.6.5; | ||
|
||
|
||
library LibPuppetRichErrors { | ||
|
||
// solhint-disable func-name-mixedcase | ||
|
||
function PuppetExecuteFailedError( | ||
address puppet, | ||
address callTarget, | ||
bytes memory callData, | ||
uint256 callValue, | ||
bytes memory errorData | ||
) | ||
internal | ||
pure | ||
returns (bytes memory) | ||
{ | ||
return abi.encodeWithSelector( | ||
bytes4(keccak256("PuppetExecuteFailedError(address,address,bytes,uint256,bytes)")), | ||
puppet, | ||
callTarget, | ||
callData, | ||
callValue, | ||
errorData | ||
); | ||
} | ||
|
||
function InvalidPuppetInstanceError(address puppet) | ||
internal | ||
pure | ||
returns (bytes memory) | ||
{ | ||
return abi.encodeWithSelector( | ||
bytes4(keccak256("InvalidPuppetInstanceError(address)")), | ||
puppet | ||
); | ||
} | ||
|
||
function PuppetNotAcquiredError(address puppet) | ||
internal | ||
pure | ||
returns (bytes memory) | ||
{ | ||
return abi.encodeWithSelector( | ||
bytes4(keccak256("PuppetNotAcquiredError(address)")), | ||
puppet | ||
); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
contracts/zero-ex/contracts/src/errors/LibSpenderRichErrors.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
Copyright 2020 ZeroEx Intl. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
pragma solidity ^0.6.5; | ||
|
||
|
||
library LibSpenderRichErrors { | ||
|
||
// solhint-disable func-name-mixedcase | ||
|
||
function SpenderERC20TransferFromFailedError( | ||
address token, | ||
address owner, | ||
address to, | ||
uint256 amount, | ||
bytes memory errorData | ||
) | ||
internal | ||
pure | ||
returns (bytes memory) | ||
{ | ||
return abi.encodeWithSelector( | ||
bytes4(keccak256("SpenderERC20TransferFromFailedError(address,address,address,uint256,bytes)")), | ||
token, | ||
owner, | ||
to, | ||
amount, | ||
errorData | ||
); | ||
} | ||
} |
219 changes: 219 additions & 0 deletions
219
contracts/zero-ex/contracts/src/errors/LibTransformERC20RichErrors.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
/* | ||
Copyright 2020 ZeroEx Intl. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
pragma solidity ^0.6.5; | ||
|
||
|
||
library LibTransformERC20RichErrors { | ||
|
||
// solhint-disable func-name-mixedcase,separate-by-one-line-in-contract | ||
|
||
function InsufficientEthAttachedError( | ||
uint256 ethAttached, | ||
uint256 ethNeeded | ||
) | ||
internal | ||
pure | ||
returns (bytes memory) | ||
{ | ||
return abi.encodeWithSelector( | ||
bytes4(keccak256("InsufficientEthAttachedError(uint256,uint256)")), | ||
ethAttached, | ||
ethNeeded | ||
); | ||
} | ||
|
||
function IncompleteERC20TransformError( | ||
address outputToken, | ||
uint256 outputTokenAmount, | ||
uint256 minOutputTokenAmount | ||
) | ||
internal | ||
pure | ||
returns (bytes memory) | ||
{ | ||
return abi.encodeWithSelector( | ||
bytes4(keccak256("IncompleteERC20TransformError(address,uint256,uint256)")), | ||
outputToken, | ||
outputTokenAmount, | ||
minOutputTokenAmount | ||
); | ||
} | ||
|
||
function TransferERC20FailedError( | ||
address token, | ||
address to, | ||
uint256 amount | ||
) | ||
internal | ||
pure | ||
returns (bytes memory) | ||
{ | ||
return abi.encodeWithSelector( | ||
bytes4(keccak256("TransferERC20FailedError(address,address,uint256)")), | ||
token, | ||
to, | ||
amount | ||
); | ||
} | ||
|
||
function ERC20TransformerFailedError( | ||
address transformer, | ||
address[] memory tokens, | ||
uint256[] memory amounts | ||
) | ||
internal | ||
pure | ||
returns (bytes memory) | ||
{ | ||
return abi.encodeWithSelector( | ||
bytes4(keccak256("ERC20TransformerFailedError(address,address[],uint256[])")), | ||
transformer, | ||
tokens, | ||
amounts | ||
); | ||
} | ||
|
||
function InvalidTransformationError( | ||
address transformer, | ||
address[] memory tokens, | ||
uint256[] memory amounts, | ||
bytes memory data | ||
) | ||
internal | ||
pure | ||
returns (bytes memory) | ||
{ | ||
return abi.encodeWithSelector( | ||
bytes4(keccak256("InvalidTransformationError(address,address[],uint256[],bytes)")), | ||
transformer, | ||
tokens, | ||
amounts, | ||
data | ||
); | ||
} | ||
|
||
// FillQuoteTransformer errors ///////////////////////////////////////////// | ||
|
||
function IncompleteFillSellQuoteError( | ||
address sellToken, | ||
uint256 soldAmount, | ||
uint256 sellAmount | ||
) | ||
internal | ||
pure | ||
returns (bytes memory) | ||
{ | ||
return abi.encodeWithSelector( | ||
bytes4(keccak256("IncompleteFillSellQuoteError(address,uint256,uint256)")), | ||
sellToken, | ||
soldAmount, | ||
sellAmount | ||
); | ||
} | ||
|
||
function IncompleteFillBuyQuoteError( | ||
address buyToken, | ||
uint256 boughtAmount, | ||
uint256 buyAmount | ||
) | ||
internal | ||
pure | ||
returns (bytes memory) | ||
{ | ||
return abi.encodeWithSelector( | ||
bytes4(keccak256("IncompleteFillBuyQuoteError(address,uint256,uint256)")), | ||
buyToken, | ||
boughtAmount, | ||
buyAmount | ||
); | ||
} | ||
|
||
function InsufficientTakerTokenError( | ||
uint256 tokenBalance, | ||
uint256 tokensNeeded | ||
) | ||
internal | ||
pure | ||
returns (bytes memory) | ||
{ | ||
return abi.encodeWithSelector( | ||
bytes4(keccak256("InsufficientTakerTokenError(uint256,uint256)")), | ||
tokenBalance, | ||
tokensNeeded | ||
); | ||
} | ||
|
||
function InsufficientProtocolFeeError( | ||
uint256 ethBalance, | ||
uint256 ethNeeded | ||
) | ||
internal | ||
pure | ||
returns (bytes memory) | ||
{ | ||
return abi.encodeWithSelector( | ||
bytes4(keccak256("InsufficientProtocolFeeError(uint256,uint256)")), | ||
ethBalance, | ||
ethNeeded | ||
); | ||
} | ||
|
||
function InvalidERC20AssetDataError( | ||
bytes memory assetData | ||
) | ||
internal | ||
pure | ||
returns (bytes memory) | ||
{ | ||
return abi.encodeWithSelector( | ||
bytes4(keccak256("InvalidERC20AssetDataError(bytes)")), | ||
assetData | ||
); | ||
} | ||
|
||
// WethTransformer rors //////////////////////////////////////////////////// | ||
|
||
function WrongNumberOfTokensReceivedError( | ||
uint256 actual, | ||
uint256 expected | ||
) | ||
internal | ||
pure | ||
returns (bytes memory) | ||
{ | ||
return abi.encodeWithSelector( | ||
bytes4(keccak256("WrongNumberOfTokensReceivedError(uint256,uint256)")), | ||
actual, | ||
expected | ||
); | ||
} | ||
|
||
function InvalidTokenReceivedError( | ||
address token | ||
) | ||
internal | ||
pure | ||
returns (bytes memory) | ||
{ | ||
return abi.encodeWithSelector( | ||
bytes4(keccak256("InvalidTokenReceivedError(address)")), | ||
token | ||
); | ||
} | ||
} |
Oops, something went wrong.