-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIRebornPortal.sol
executable file
·219 lines (185 loc) · 5.78 KB
/
IRebornPortal.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.17;
import {PortalLib} from "src/PortalLib.sol";
import {SingleRanking} from "src/lib/SingleRanking.sol";
import {BitMapsUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/structs/BitMapsUpgradeable.sol";
interface IRebornDefination {
struct Innate {
uint256 talentPrice;
uint256 propertyPrice;
}
struct LifeDetail {
bytes32 seed;
address creator;
uint16 age;
uint32 round;
uint48 nothing;
uint128 cost;
uint128 reward;
uint256 score;
string creatorName;
}
struct SeasonData {
mapping(uint256 => PortalLib.Pool) pools;
/// @dev user address => pool tokenId => Portfolio
mapping(address => mapping(uint256 => PortalLib.Portfolio)) portfolios;
SingleRanking.Data _tributeRank;
SingleRanking.Data _scoreRank;
mapping(uint256 => uint256) _oldStakeAmounts;
/// tokenId => bool
BitMapsUpgradeable.BitMap _isTopHundredScore;
}
enum AirdropVrfType {
Invalid,
DropReborn,
DropNative
}
struct RequestStatus {
bool fulfilled; // whether the request has been successfully fulfilled
bool exists; // whether a requestId exists
bool executed; // whether the airdrop is executed
AirdropVrfType t;
uint256[] randomWords;
}
event Incarnate(
address indexed user,
uint256 indexed talentPrice,
uint256 indexed PropertyPrice,
uint256 soupPrice
);
event Engrave(
bytes32 indexed seed,
address indexed user,
uint256 indexed tokenId,
uint256 score,
uint256 reward
);
event Infuse(address indexed user, uint256 indexed tokenId, uint256 amount);
event Dry(address indexed user, uint256 indexed tokenId, uint256 amount);
event Baptise(address indexed user, uint256 amount);
event NewSoupPrice(uint256 price);
event Refer(address referee, address referrer);
event DecreaseFromPool(
address indexed account,
uint256 tokenId,
uint256 amount
);
event IncreaseToPool(
address indexed account,
uint256 tokenId,
uint256 amount
);
event Drop(uint256[] tokenIds);
event NewSeason(uint256);
/// @dev revert when msg.value is insufficient
error InsufficientAmount();
/// @dev revert when to caller is not signer
error NotSigner();
/// @dev revert when the random seed is duplicated
error SameSeed();
/// @dev revert when swith amount from pool exceed staked balance
error SwitchAmountExceedBalance();
/// @dev revert when set ZeroAddress
error ZeroAddressSet();
/// @dev revert if burnPool address not set when infuse
error NotSetBurnPoolAddress();
/// @dev revert when the drop is not on
error DropOff();
}
interface IRebornPortal is IRebornDefination {
/**
* @dev user buy the innate for the life
* @param innate talent and property choice
* @param referrer the referrer address
*/
function incarnate(
Innate memory innate,
address referrer,
uint256 soupPrice
) external payable;
/**
* @dev engrave the result on chain and reward
* @param seed random seed in bytes32
* @param user user address
* @param reward $REBORN user earns, decimal 10^18
* @param score life score
* @param cost user cost for this life
*/
function engrave(
bytes32 seed,
address user,
uint256 reward,
uint256 score,
uint256 age,
uint256 cost,
string calldata creatorName
) external;
/**
* @dev reward for share the game
* @param user user address
* @param amount amount for reward
*/
function baptise(address user, uint256 amount) external;
/**
* @dev stake $REBORN on this tombstone
* @param tokenId tokenId of the life to stake
* @param amount stake amount, decimal 10^18
*/
function infuse(uint256 tokenId, uint256 amount) external;
/**
* @dev stake $REBORN with permit
* @param tokenId tokenId of the life to stake
* @param amount amount of $REBORN to stake
* @param permitAmount amount of $REBORN to approve
* @param r r of signature
* @param s v of signature
* @param v v of signature
*/
function infuse(
uint256 tokenId,
uint256 amount,
uint256 permitAmount,
uint256 deadline,
bytes32 r,
bytes32 s,
uint8 v
) external;
/**
* @dev switch stake amount from poolFrom to poolTo
* @param fromTokenId tokenId of from pool
* @param toTokenId tokenId of to pool
* @param amount amount to switch
*/
function switchPool(
uint256 fromTokenId,
uint256 toTokenId,
uint256 amount
) external;
/**
* @dev set new airdrop config
*/
function setDropConf(PortalLib.AirdropConf calldata conf) external;
/**
* @dev set new chainlink vrf v2 config
*/
function setVrfConf(PortalLib.VrfConf calldata conf) external;
/**
* @dev user claim many pools' native token airdrop
* @param tokenIds pools' tokenId array to claim
*/
function claimNativeDrops(uint256[] calldata tokenIds) external;
/**
* @dev user claim many pools' reborn token airdrop
* @param tokenIds pools' tokenId array to claim
*/
function claimRebornDrops(uint256[] calldata tokenIds) external;
/**
* @dev user claim many pools' airdrop
* @param tokenIds pools' tokenId array to claim
*/
function claimDrops(uint256[] calldata tokenIds) external;
/**
* @dev switch to next season, call by owner
*/
function toNextSeason() external;
}