generated from ZumZoom/solidity-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from 1inch/feature/SC-1213
[SC-1213] Add support for new matcha contracts
- Loading branch information
Showing
32 changed files
with
3,178 additions
and
2,120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ on: | |
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
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 |
---|---|---|
@@ -1,26 +1,27 @@ | ||
/* eslint-disable no-multi-spaces */ | ||
module.exports = { | ||
configureYulOptimizer: true, | ||
solcOptimizerDetails: { | ||
yul: true, | ||
yulDetails: { | ||
optimizerSteps: | ||
"dhfoDgvlfnTUtnIf" + // None of these can make stack problems worse | ||
"[" + | ||
"xa[r]EscLM" + // Turn into SSA and simplify | ||
"cCTUtTOntnfDIl" + // Perform structural simplification | ||
"Lcl" + // Simplify again | ||
"Vcl [j]" + // Reverse SSA | ||
'dhfoDgvlfnTUtnIf' + // None of these can make stack problems worse | ||
'[' + | ||
'xa[r]EscLM' + // Turn into SSA and simplify | ||
'cCTUtTOntnfDIl' + // Perform structural simplification | ||
'Lcl' + // Simplify again | ||
'Vcl [j]' + // Reverse SSA | ||
|
||
// should have good "compilability" property here. | ||
// should have good "compilability" property here. | ||
|
||
"Tpel" + // Run functional expression inliner | ||
"xa[rl]" + // Prune a bit more in SSA | ||
"xa[r]cL" + // Turn into SSA again and simplify | ||
"gvf" + // Run full inliner | ||
"CTUca[r]LSsTFOtfDnca[r]Ilc" + // SSA plus simplify | ||
"]" + | ||
"jml[jl] VcTOcl jml : fDnTOcm", | ||
'Tpel' + // Run functional expression inliner | ||
'xa[rl]' + // Prune a bit more in SSA | ||
'xa[r]cL' + // Turn into SSA again and simplify | ||
'gvf' + // Run full inliner | ||
'CTUca[r]LSsTFOtfDnca[r]Ilc' + // SSA plus simplify | ||
']' + | ||
'jml[jl] VcTOcl jml : fDnTOcm', | ||
}, | ||
}, | ||
skipFiles: ['mocks', 'interfaces'], | ||
} | ||
}; |
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
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,132 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
/// @title SignatureTransfer | ||
/// @notice Handles ERC20 token transfers through signature based actions | ||
/// @dev Requires user's token approval on the Permit2 contract | ||
interface ISignatureTransfer { | ||
/// @notice Thrown when the requested amount for a transfer is larger than the permissioned amount | ||
/// @param maxAmount The maximum amount a spender can request to transfer | ||
error InvalidAmount(uint256 maxAmount); | ||
|
||
/// @notice Thrown when the number of tokens permissioned to a spender does not match the number of tokens being transferred | ||
/// @dev If the spender does not need to transfer the number of tokens permitted, the spender can request amount 0 to be transferred | ||
error LengthMismatch(); | ||
|
||
/// @notice Emits an event when the owner successfully invalidates an unordered nonce. | ||
event UnorderedNonceInvalidation(address indexed owner, uint256 word, uint256 mask); | ||
|
||
/// @notice The token and amount details for a transfer signed in the permit transfer signature | ||
struct TokenPermissions { | ||
// ERC20 token address | ||
address token; | ||
// the maximum amount that can be spent | ||
uint256 amount; | ||
} | ||
|
||
/// @notice The signed permit message for a single token transfer | ||
struct PermitTransferFrom { | ||
TokenPermissions permitted; | ||
// a unique value for every token owner's signature to prevent signature replays | ||
uint256 nonce; | ||
// deadline on the permit signature | ||
uint256 deadline; | ||
} | ||
|
||
/// @notice Specifies the recipient address and amount for batched transfers. | ||
/// @dev Recipients and amounts correspond to the index of the signed token permissions array. | ||
/// @dev Reverts if the requested amount is greater than the permitted signed amount. | ||
struct SignatureTransferDetails { | ||
// recipient address | ||
address to; | ||
// spender requested amount | ||
uint256 requestedAmount; | ||
} | ||
|
||
/// @notice Used to reconstruct the signed permit message for multiple token transfers | ||
/// @dev Do not need to pass in spender address as it is required that it is msg.sender | ||
/// @dev Note that a user still signs over a spender address | ||
struct PermitBatchTransferFrom { | ||
// the tokens and corresponding amounts permitted for a transfer | ||
TokenPermissions[] permitted; | ||
// a unique value for every token owner's signature to prevent signature replays | ||
uint256 nonce; | ||
// deadline on the permit signature | ||
uint256 deadline; | ||
} | ||
|
||
/// @notice A map from token owner address and a caller specified word index to a bitmap. Used to set bits in the bitmap to prevent against signature replay protection | ||
/// @dev Uses unordered nonces so that permit messages do not need to be spent in a certain order | ||
/// @dev The mapping is indexed first by the token owner, then by an index specified in the nonce | ||
/// @dev It returns a uint256 bitmap | ||
/// @dev The index, or wordPosition is capped at type(uint248).max | ||
function nonceBitmap(address, uint256) external view returns (uint256); | ||
|
||
/// @notice Transfers a token using a signed permit message | ||
/// @dev Reverts if the requested amount is greater than the permitted signed amount | ||
/// @param permit The permit data signed over by the owner | ||
/// @param owner The owner of the tokens to transfer | ||
/// @param transferDetails The spender's requested transfer details for the permitted token | ||
/// @param signature The signature to verify | ||
function permitTransferFrom( | ||
PermitTransferFrom memory permit, | ||
SignatureTransferDetails calldata transferDetails, | ||
address owner, | ||
bytes calldata signature | ||
) external; | ||
|
||
/// @notice Transfers a token using a signed permit message | ||
/// @notice Includes extra data provided by the caller to verify signature over | ||
/// @dev The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition | ||
/// @dev Reverts if the requested amount is greater than the permitted signed amount | ||
/// @param permit The permit data signed over by the owner | ||
/// @param owner The owner of the tokens to transfer | ||
/// @param transferDetails The spender's requested transfer details for the permitted token | ||
/// @param witness Extra data to include when checking the user signature | ||
/// @param witnessTypeString The EIP-712 type definition for remaining string stub of the typehash | ||
/// @param signature The signature to verify | ||
function permitWitnessTransferFrom( | ||
PermitTransferFrom memory permit, | ||
SignatureTransferDetails calldata transferDetails, | ||
address owner, | ||
bytes32 witness, | ||
string calldata witnessTypeString, | ||
bytes calldata signature | ||
) external; | ||
|
||
/// @notice Transfers multiple tokens using a signed permit message | ||
/// @param permit The permit data signed over by the owner | ||
/// @param owner The owner of the tokens to transfer | ||
/// @param transferDetails Specifies the recipient and requested amount for the token transfer | ||
/// @param signature The signature to verify | ||
function permitTransferFrom( | ||
PermitBatchTransferFrom memory permit, | ||
SignatureTransferDetails[] calldata transferDetails, | ||
address owner, | ||
bytes calldata signature | ||
) external; | ||
|
||
/// @notice Transfers multiple tokens using a signed permit message | ||
/// @dev The witness type string must follow EIP712 ordering of nested structs and must include the TokenPermissions type definition | ||
/// @notice Includes extra data provided by the caller to verify signature over | ||
/// @param permit The permit data signed over by the owner | ||
/// @param owner The owner of the tokens to transfer | ||
/// @param transferDetails Specifies the recipient and requested amount for the token transfer | ||
/// @param witness Extra data to include when checking the user signature | ||
/// @param witnessTypeString The EIP-712 type definition for remaining string stub of the typehash | ||
/// @param signature The signature to verify | ||
function permitWitnessTransferFrom( | ||
PermitBatchTransferFrom memory permit, | ||
SignatureTransferDetails[] calldata transferDetails, | ||
address owner, | ||
bytes32 witness, | ||
string calldata witnessTypeString, | ||
bytes calldata signature | ||
) external; | ||
|
||
/// @notice Invalidates the bits specified in mask for the bitmap at the word position | ||
/// @dev The wordPos is maxed at type(uint248).max | ||
/// @param wordPos A number to index the nonceBitmap at | ||
/// @param mask A bitmap masked against msg.sender's current bitmap at the word position | ||
function invalidateUnorderedNonces(uint256 wordPos, uint256 mask) external; | ||
} |
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
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
35 changes: 35 additions & 0 deletions
35
contracts/interfaces/router/0xSettler/IAllowanceHolder.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,35 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
interface IAllowanceHolder { | ||
/// @notice Executes against `target` with the `data` payload. Prior to execution, token permits | ||
/// are temporarily stored for the duration of the transaction. These permits can be | ||
/// consumed by the `operator` during the execution | ||
/// @notice `operator` consumes the funds during its operations by calling back into | ||
/// `AllowanceHolder` with `transferFrom`, consuming a token permit. | ||
/// @dev Neither `exec` nor `transferFrom` check that `token` contains code. | ||
/// @dev msg.sender is forwarded to target appended to the msg data (similar to ERC-2771) | ||
/// @param operator An address which is allowed to consume the token permits | ||
/// @param token The ERC20 token the caller has authorised to be consumed | ||
/// @param amount The quantity of `token` the caller has authorised to be consumed | ||
/// @param target A contract to execute operations with `data` | ||
/// @param data The data to forward to `target` | ||
/// @return result The returndata from calling `target` with `data` | ||
/// @notice If calling `target` with `data` reverts, the revert is propagated | ||
function exec(address operator, address token, uint256 amount, address payable target, bytes calldata data) | ||
external | ||
payable | ||
returns (bytes memory result); | ||
|
||
/// @notice The counterpart to `exec` which allows for the consumption of token permits later | ||
/// during execution | ||
/// @dev *DOES NOT* check that `token` contains code. This function vacuously succeeds if | ||
/// `token` is empty. | ||
/// @dev can only be called by the `operator` previously registered in `exec` | ||
/// @param token The ERC20 token to transfer | ||
/// @param owner The owner of tokens to transfer | ||
/// @param recipient The destination/beneficiary of the ERC20 `transferFrom` | ||
/// @param amount The quantity of `token` to transfer` | ||
/// @return true | ||
function transferFrom(address token, address owner, address recipient, uint256 amount) external returns (bool); | ||
} |
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,7 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
interface IAllowanceTransfer { | ||
function nonceBitmap(address, uint256) external view returns(uint256); | ||
} |
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,18 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
import { IERC20 } from "@openzeppelin/contracts/interfaces/IERC20.sol"; | ||
|
||
interface ISettler { | ||
struct AllowedSlippage { | ||
address recipient; | ||
IERC20 buyToken; | ||
uint256 minAmountOut; | ||
} | ||
|
||
function execute( | ||
AllowedSlippage calldata slippage, | ||
bytes[] calldata actions, | ||
bytes32 affiliate | ||
) external payable returns (bool); | ||
} |
Oops, something went wrong.