-
Notifications
You must be signed in to change notification settings - Fork 27
/
ERC721CWPaidUnstake.sol
37 lines (30 loc) · 1.21 KB
/
ERC721CWPaidUnstake.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
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "../extensions/ERC721CW.sol";
/**
* @title ERC721CWPaidUnstake
* @author Limit Break, Inc.
* @notice Extension of ERC721CW that enforces a payment to unstake the wrapped token.
*/
abstract contract ERC721CWPaidUnstake is ERC721CW {
error ERC721CWPaidUnstake__IncorrectUnstakePayment();
/// @dev The price required to unstake. This cannot be modified after contract creation.
uint256 immutable private unstakePrice;
constructor(
uint256 unstakePrice_,
address wrappedCollectionAddress_,
string memory name_,
string memory symbol_) ERC721CW(wrappedCollectionAddress_) ERC721OpenZeppelin(name_, symbol_) {
unstakePrice = unstakePrice_;
}
/// @notice Returns the price, in wei, required to unstake
function getUnstakePrice() external view returns (uint256) {
return unstakePrice;
}
/// @dev Reverts if the unstaking payment is not exactly equal to the unstaking price.
function _onUnstake(uint256 /*tokenId*/, uint256 value) internal virtual override {
if(value != unstakePrice) {
revert ERC721CWPaidUnstake__IncorrectUnstakePayment();
}
}
}