-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathMetaTxn.sol
72 lines (63 loc) · 2.6 KB
/
MetaTxn.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-License-Identifier: MIT
pragma solidity =0.8.25;
import {SepoliaMixin} from "./Common.sol";
import {SettlerMetaTxn} from "../../SettlerMetaTxn.sol";
import {IERC20} from "@forge-std/interfaces/IERC20.sol";
import {ISignatureTransfer} from "@permit2/interfaces/ISignatureTransfer.sol";
import {ISettlerActions} from "../../ISettlerActions.sol";
// Solidity inheritance is stupid
import {SettlerAbstract} from "../../SettlerAbstract.sol";
import {SettlerBase} from "../../SettlerBase.sol";
import {AbstractContext} from "../../Context.sol";
/// @custom:security-contact [email protected]
contract SepoliaSettlerMetaTxn is SettlerMetaTxn, SepoliaMixin {
constructor(bytes20 gitCommit) SettlerBase(gitCommit) {}
function _dispatchVIP(uint256 action, bytes calldata data, bytes calldata sig)
internal
virtual
override
DANGEROUS_freeMemory
returns (bool)
{
if (super._dispatchVIP(action, data, sig)) {
return true;
} else if (action == uint32(ISettlerActions.METATXN_UNISWAPV4_VIP.selector)) {
(
address recipient,
bool feeOnTransfer,
uint256 hashMul,
uint256 hashMod,
bytes memory fills,
ISignatureTransfer.PermitTransferFrom memory permit,
uint256 amountOutMin
) = abi.decode(
data, (address, bool, uint256, uint256, bytes, ISignatureTransfer.PermitTransferFrom, uint256)
);
sellToUniswapV4VIP(recipient, feeOnTransfer, hashMul, hashMod, fills, permit, sig, amountOutMin);
} else if (action == uint32(ISettlerActions.METATXN_MAVERICKV2_VIP.selector)) {
(
address recipient,
bytes32 salt,
bool tokenAIn,
ISignatureTransfer.PermitTransferFrom memory permit,
uint256 minBuyAmount
) = abi.decode(data, (address, bytes32, bool, ISignatureTransfer.PermitTransferFrom, uint256));
sellToMaverickV2VIP(recipient, salt, tokenAIn, permit, sig, minBuyAmount);
} else {
return false;
}
return true;
}
// Solidity inheritance is stupid
function _dispatch(uint256 i, uint256 action, bytes calldata data)
internal
virtual
override(SettlerAbstract, SettlerBase, SepoliaMixin)
returns (bool)
{
return super._dispatch(i, action, data);
}
function _msgSender() internal view virtual override(SettlerMetaTxn, AbstractContext) returns (address) {
return super._msgSender();
}
}