-
Notifications
You must be signed in to change notification settings - Fork 1
/
StrategyAnyItemFromCollectionForFixedPrice.sol
73 lines (67 loc) · 2.18 KB
/
StrategyAnyItemFromCollectionForFixedPrice.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
73
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {OrderTypes} from "../libraries/OrderTypes.sol";
import {IExecutionStrategy} from "../interfaces/IExecutionStrategy.sol";
/**
* @title StrategyAnyItemFromCollectionForFixedPrice
* @notice Strategy to send an order at a fixed price that can be
* matched by any tokenId for the collection.
*/
contract StrategyAnyItemFromCollectionForFixedPrice is IExecutionStrategy {
uint256 public immutable PROTOCOL_FEE;
/**
* @notice Constructor
* @param _protocolFee protocol fee (200 --> 2%, 400 --> 4%)
*/
constructor(uint256 _protocolFee) {
PROTOCOL_FEE = _protocolFee;
}
/**
* @notice Check whether a taker ask order can be executed against a maker bid
* @param takerAsk taker ask order
* @param makerBid maker bid order
* @return (whether strategy can be executed, tokenId to execute, amount of tokens to execute)
*/
function canExecuteTakerAsk(OrderTypes.TakerOrder calldata takerAsk, OrderTypes.MakerOrder calldata makerBid)
external
view
override
returns (
bool,
uint256,
uint256
)
{
return (
((makerBid.price == takerAsk.price) &&
(makerBid.endTime >= block.timestamp) &&
(makerBid.startTime <= block.timestamp)),
takerAsk.tokenId,
makerBid.amount
);
}
/**
* @notice Check whether a taker bid order can be executed against a maker ask
* @return (whether strategy can be executed, tokenId to execute, amount of tokens to execute)
* @dev It cannot execute but it is left for compatibility purposes with the interface.
*/
function canExecuteTakerBid(OrderTypes.TakerOrder calldata, OrderTypes.MakerOrder calldata)
external
pure
override
returns (
bool,
uint256,
uint256
)
{
return (false, 0, 0);
}
/**
* @notice Return protocol fee for this strategy
* @return protocol fee
*/
function viewProtocolFee() external view override returns (uint256) {
return PROTOCOL_FEE;
}
}