-
Notifications
You must be signed in to change notification settings - Fork 1
/
StrategyPrivateSale.sol
77 lines (70 loc) · 2.23 KB
/
StrategyPrivateSale.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
74
75
76
77
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {OrderTypes} from "../libraries/OrderTypes.sol";
import {IExecutionStrategy} from "../interfaces/IExecutionStrategy.sol";
/**
* @title StrategyPrivateSale
* @notice Strategy to set up an order that can only be executed by
* a specific address.
*/
contract StrategyPrivateSale 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
* @return (whether strategy can be executed, tokenId to execute, amount of tokens to execute)
*/
function canExecuteTakerAsk(OrderTypes.TakerOrder calldata, OrderTypes.MakerOrder calldata)
external
pure
override
returns (
bool,
uint256,
uint256
)
{
return (false, 0, 0);
}
/**
* @notice Check whether a taker bid order can be executed against a maker ask
* @param takerBid taker bid order
* @param makerAsk maker ask order
* @return (whether strategy can be executed, tokenId to execute, amount of tokens to execute)
*/
function canExecuteTakerBid(OrderTypes.TakerOrder calldata takerBid, OrderTypes.MakerOrder calldata makerAsk)
external
view
override
returns (
bool,
uint256,
uint256
)
{
// Retrieve target buyer
address targetBuyer = abi.decode(makerAsk.params, (address));
return (
((targetBuyer == takerBid.taker) &&
(makerAsk.price == takerBid.price) &&
(makerAsk.tokenId == takerBid.tokenId) &&
(makerAsk.startTime <= block.timestamp) &&
(makerAsk.endTime >= block.timestamp)),
makerAsk.tokenId,
makerAsk.amount
);
}
/**
* @notice Return protocol fee for this strategy
* @return protocol fee
*/
function viewProtocolFee() external view override returns (uint256) {
return PROTOCOL_FEE;
}
}