-
Notifications
You must be signed in to change notification settings - Fork 86
/
LimitOrderReactor.sol
45 lines (40 loc) · 1.51 KB
/
LimitOrderReactor.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
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
import {BaseReactor} from "./BaseReactor.sol";
import {Permit2Lib} from "../lib/Permit2Lib.sol";
import {LimitOrderLib, LimitOrder} from "../lib/LimitOrderLib.sol";
import {SignedOrder, ResolvedOrder} from "../base/ReactorStructs.sol";
import {IPermit2} from "permit2/src/interfaces/IPermit2.sol";
/// @notice Reactor for simple limit orders
contract LimitOrderReactor is BaseReactor {
using Permit2Lib for ResolvedOrder;
using LimitOrderLib for LimitOrder;
constructor(IPermit2 _permit2, address _protocolFeeOwner) BaseReactor(_permit2, _protocolFeeOwner) {}
/// @inheritdoc BaseReactor
function _resolve(SignedOrder calldata signedOrder)
internal
pure
override
returns (ResolvedOrder memory resolvedOrder)
{
LimitOrder memory limitOrder = abi.decode(signedOrder.order, (LimitOrder));
resolvedOrder = ResolvedOrder({
info: limitOrder.info,
input: limitOrder.input,
outputs: limitOrder.outputs,
sig: signedOrder.sig,
hash: limitOrder.hash()
});
}
/// @inheritdoc BaseReactor
function _transferInputTokens(ResolvedOrder memory order, address to) internal override {
permit2.permitWitnessTransferFrom(
order.toPermit(),
order.transferDetails(to),
order.info.swapper,
order.hash,
LimitOrderLib.PERMIT2_ORDER_TYPE,
order.sig
);
}
}