1 | | - | {-# STDLIB_VERSION 5 #-} |
---|
2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let lpAssetId = base58'97zHFp1C3cB7qfvx8Xv5f2rWp9nUSG5UnAamfPcW6txf' |
---|
5 | | - | |
---|
6 | | - | let wxAssetId = base58'Atqv59EYzjFGuitKVnMRk6H8FukjoV3ktPorbEys25on' |
---|
7 | | - | |
---|
8 | | - | let wxbAssetId = base58'BbP9tmd5Zxk345y9zipXkYaqDfxDG1suTj64eJmy1BAT' |
---|
9 | | - | |
---|
10 | | - | let proxyAddress = Address(base58'3PC9xNkxwtsRA9ep91EV67Mdpv1NT64r3Mg') |
---|
11 | | - | |
---|
12 | | - | let roundHeight = 120 |
---|
13 | | - | |
---|
14 | | - | let targetBlock = 2990340 |
---|
15 | | - | |
---|
16 | | - | let limit = 100000000000 |
---|
17 | | - | |
---|
18 | | - | @Callable(i) |
---|
19 | | - | func deposit () = { |
---|
20 | | - | let isDepositLocked = valueOrElse(getBoolean("deposit_locked"), false) |
---|
21 | | - | let previousBalance = valueOrElse(getInteger("total_balance"), 0) |
---|
22 | | - | let isValidBlock = (targetBlock > height) |
---|
23 | | - | let isInitialized = valueOrElse(getBoolean("initialized"), false) |
---|
24 | | - | let isFirstBlockReached = (height >= valueOrElse(getInteger("first_block"), 0)) |
---|
25 | | - | if (if (if (if (if (if (if (if (!(isDepositLocked)) |
---|
26 | | - | then isInitialized |
---|
27 | | - | else false) |
---|
28 | | - | then isFirstBlockReached |
---|
29 | | - | else false) |
---|
30 | | - | then (size(i.payments) == 1) |
---|
31 | | - | else false) |
---|
32 | | - | then (i.payments[0].amount > 0) |
---|
33 | | - | else false) |
---|
34 | | - | then (i.payments[0].assetId == lpAssetId) |
---|
35 | | - | else false) |
---|
36 | | - | then isValidBlock |
---|
37 | | - | else false) |
---|
38 | | - | then (limit >= (previousBalance + i.payments[0].amount)) |
---|
39 | | - | else false) |
---|
40 | | - | then { |
---|
41 | | - | let startBlock = getIntegerValue("start_block") |
---|
42 | | - | func getWalletPreviousShare () = { |
---|
43 | | - | let lastDepositBlock = valueOrElse(getInteger((toString(i.caller) + "_last_deposit_block")), 0) |
---|
44 | | - | let lastWithdrawBlock = valueOrElse(getInteger((toString(i.caller) + "_last_withdraw_block")), 0) |
---|
45 | | - | let previousShare = if (if (if ((lastDepositBlock != 0)) |
---|
46 | | - | then (startBlock > lastDepositBlock) |
---|
47 | | - | else false) |
---|
48 | | - | then (startBlock > lastWithdrawBlock) |
---|
49 | | - | else false) |
---|
50 | | - | then { |
---|
51 | | - | let walletBalance = valueOrElse(getInteger((toString(i.caller) + "_balance")), 0) |
---|
52 | | - | (toBigInt(walletBalance) * toBigInt(roundHeight)) |
---|
53 | | - | } |
---|
54 | | - | else parseBigIntValue(valueOrElse(getString((((toString(i.caller) + "_") + toString(startBlock)) + "_share")), "0")) |
---|
55 | | - | previousShare |
---|
56 | | - | } |
---|
57 | | - | |
---|
58 | | - | func getTotalPreviousShare () = { |
---|
59 | | - | let lastDepositBlock = valueOrElse(getInteger("last_deposit_block"), 0) |
---|
60 | | - | let lastWithdrawBlock = valueOrElse(getInteger("last_withdraw_block"), 0) |
---|
61 | | - | let previousShare = if (if (if ((lastDepositBlock != 0)) |
---|
62 | | - | then (startBlock > lastDepositBlock) |
---|
63 | | - | else false) |
---|
64 | | - | then (startBlock > lastWithdrawBlock) |
---|
65 | | - | else false) |
---|
66 | | - | then { |
---|
67 | | - | let totalBalance = valueOrElse(getInteger("total_balance"), 0) |
---|
68 | | - | (toBigInt(totalBalance) * toBigInt(roundHeight)) |
---|
69 | | - | } |
---|
70 | | - | else parseBigIntValue(valueOrElse(getString((toString(startBlock) + "_total_share")), "0")) |
---|
71 | | - | previousShare |
---|
72 | | - | } |
---|
73 | | - | |
---|
74 | | - | let walletPreviousShare = getWalletPreviousShare() |
---|
75 | | - | let depositShare = if ((height > (startBlock + roundHeight))) |
---|
76 | | - | then toBigInt(0) |
---|
77 | | - | else (toBigInt(i.payments[0].amount) * toBigInt(((startBlock + roundHeight) - height))) |
---|
78 | | - | let walletShare = (walletPreviousShare + depositShare) |
---|
79 | | - | let walletPreviousBalance = valueOrElse(getInteger((toString(i.caller) + "_balance")), 0) |
---|
80 | | - | let walletBalance = (walletPreviousBalance + i.payments[0].amount) |
---|
81 | | - | let totalPreviousShare = getTotalPreviousShare() |
---|
82 | | - | let totalShare = (totalPreviousShare + depositShare) |
---|
83 | | - | let previousTotalBalance = valueOrElse(getInteger("total_balance"), 0) |
---|
84 | | - | let totalBalance = (previousTotalBalance + i.payments[0].amount) |
---|
85 | | - | let depositCall = invoke(proxyAddress, "stakeLP", nil, [AttachedPayment(i.payments[0].assetId, i.payments[0].amount)]) |
---|
86 | | - | if ((depositCall == depositCall)) |
---|
87 | | - | then { |
---|
88 | | - | let previousWalletActivity = match getString((toString(i.caller) + "_activity")) { |
---|
89 | | - | case p: String => |
---|
90 | | - | true |
---|
91 | | - | case n: Unit => |
---|
92 | | - | false |
---|
93 | | - | case _ => |
---|
94 | | - | throw("Match error") |
---|
95 | | - | } |
---|
96 | | - | let walletActivity = if (previousWalletActivity) |
---|
97 | | - | then if (!(contains(getStringValue((toString(i.caller) + "_activity")), toString(startBlock)))) |
---|
98 | | - | then ((getStringValue((toString(i.caller) + "_activity")) + "_") + toString(startBlock)) |
---|
99 | | - | else getStringValue((toString(i.caller) + "_activity")) |
---|
100 | | - | else toString(startBlock) |
---|
101 | | - | let firstDeposit = match getInteger((toString(i.caller) + "_first_deposit")) { |
---|
102 | | - | case p: Int => |
---|
103 | | - | p |
---|
104 | | - | case n: Unit => |
---|
105 | | - | startBlock |
---|
106 | | - | case _ => |
---|
107 | | - | throw("Match error") |
---|
108 | | - | } |
---|
109 | | - | $Tuple2([IntegerEntry((toString(i.caller) + "_balance"), walletBalance), StringEntry((((toString(i.caller) + "_") + toString(startBlock)) + "_share"), toString(walletShare)), IntegerEntry((((toString(i.caller) + "_") + toString(startBlock)) + "_balance"), walletBalance), StringEntry((toString(i.caller) + "_activity"), walletActivity), IntegerEntry((toString(i.caller) + "_last_deposit_block"), startBlock), IntegerEntry((toString(i.caller) + "_first_deposit"), firstDeposit), IntegerEntry("total_balance", totalBalance), StringEntry((toString(startBlock) + "_total_share"), toString(totalShare)), IntegerEntry("last_deposit_block", startBlock)], unit) |
---|
110 | | - | } |
---|
111 | | - | else throw("Strict value is not equal to itself.") |
---|
112 | | - | } |
---|
113 | | - | else throw("") |
---|
114 | | - | } |
---|
115 | | - | |
---|
116 | | - | |
---|
117 | | - | |
---|
118 | | - | @Callable(i) |
---|
119 | | - | func withdraw (amount) = { |
---|
120 | | - | let isWithdrawLocked = valueOrElse(getBoolean("withdraw_locked"), false) |
---|
121 | | - | let walletPreviousBalance = valueOrElse(getInteger((toString(i.caller) + "_balance")), 0) |
---|
122 | | - | if (if (if (if (!(isWithdrawLocked)) |
---|
123 | | - | then (amount > 0) |
---|
124 | | - | else false) |
---|
125 | | - | then (walletPreviousBalance > 0) |
---|
126 | | - | else false) |
---|
127 | | - | then (walletPreviousBalance >= amount) |
---|
128 | | - | else false) |
---|
129 | | - | then { |
---|
130 | | - | let startBlock = getIntegerValue("start_block") |
---|
131 | | - | func getWalletPreviousShare () = { |
---|
132 | | - | let lastDepositBlock = valueOrElse(getInteger((toString(i.caller) + "_last_deposit_block")), 0) |
---|
133 | | - | let lastWithdrawBlock = valueOrElse(getInteger((toString(i.caller) + "_last_withdraw_block")), 0) |
---|
134 | | - | let previousShare = if (if ((startBlock > lastDepositBlock)) |
---|
135 | | - | then (startBlock > lastWithdrawBlock) |
---|
136 | | - | else false) |
---|
137 | | - | then { |
---|
138 | | - | let walletBalance = valueOrElse(getInteger((toString(i.caller) + "_balance")), 0) |
---|
139 | | - | (toBigInt(walletBalance) * toBigInt(roundHeight)) |
---|
140 | | - | } |
---|
141 | | - | else parseBigIntValue(valueOrElse(getString((((toString(i.caller) + "_") + toString(startBlock)) + "_share")), "0")) |
---|
142 | | - | previousShare |
---|
143 | | - | } |
---|
144 | | - | |
---|
145 | | - | func getTotalPreviousShare () = { |
---|
146 | | - | let lastDepositBlock = valueOrElse(getInteger("last_deposit_block"), 0) |
---|
147 | | - | let lastWithdrawBlock = valueOrElse(getInteger("last_withdraw_block"), 0) |
---|
148 | | - | let previousShare = if (if ((startBlock > lastDepositBlock)) |
---|
149 | | - | then (startBlock > lastWithdrawBlock) |
---|
150 | | - | else false) |
---|
151 | | - | then { |
---|
152 | | - | let totalBalance = valueOrElse(getInteger("total_balance"), 0) |
---|
153 | | - | (toBigInt(totalBalance) * toBigInt(roundHeight)) |
---|
154 | | - | } |
---|
155 | | - | else parseBigIntValue(valueOrElse(getString((toString(startBlock) + "_total_share")), "0")) |
---|
156 | | - | previousShare |
---|
157 | | - | } |
---|
158 | | - | |
---|
159 | | - | let walletBalance = (walletPreviousBalance - amount) |
---|
160 | | - | let withdrawShare = if ((height > (startBlock + roundHeight))) |
---|
161 | | - | then toBigInt(0) |
---|
162 | | - | else (toBigInt(amount) * toBigInt(((startBlock + roundHeight) - height))) |
---|
163 | | - | let walletShare = (getWalletPreviousShare() - withdrawShare) |
---|
164 | | - | let totalBalance = (valueOrElse(getInteger("total_balance"), 0) - amount) |
---|
165 | | - | let totalShare = (getTotalPreviousShare() - withdrawShare) |
---|
166 | | - | let previousWalletActivity = match getString((toString(i.caller) + "_activity")) { |
---|
167 | | - | case p: String => |
---|
168 | | - | true |
---|
169 | | - | case n: Unit => |
---|
170 | | - | false |
---|
171 | | - | case _ => |
---|
172 | | - | throw("Match error") |
---|
173 | | - | } |
---|
174 | | - | let walletActivity = if (previousWalletActivity) |
---|
175 | | - | then if (!(contains(getStringValue((toString(i.caller) + "_activity")), toString(startBlock)))) |
---|
176 | | - | then ((getStringValue((toString(i.caller) + "_activity")) + "_") + toString(startBlock)) |
---|
177 | | - | else getStringValue((toString(i.caller) + "_activity")) |
---|
178 | | - | else toString(startBlock) |
---|
179 | | - | let isEnded = valueOrElse(getBoolean("ended"), false) |
---|
180 | | - | if (!(isEnded)) |
---|
181 | | - | then { |
---|
182 | | - | let withdrawCall = invoke(proxyAddress, "unstakeLP", [amount], nil) |
---|
183 | | - | if ((withdrawCall == withdrawCall)) |
---|
184 | | - | then $Tuple2([ScriptTransfer(i.caller, amount, lpAssetId), IntegerEntry((toString(i.caller) + "_balance"), walletBalance), StringEntry((((toString(i.caller) + "_") + toString(startBlock)) + "_share"), toString(walletShare)), IntegerEntry((((toString(i.caller) + "_") + toString(startBlock)) + "_balance"), walletBalance), StringEntry((toString(i.caller) + "_activity"), walletActivity), IntegerEntry((toString(i.caller) + "_last_withdraw_block"), startBlock), IntegerEntry("total_balance", totalBalance), StringEntry((toString(startBlock) + "_total_share"), toString(totalShare)), IntegerEntry("last_withdraw_block", startBlock)], unit) |
---|
185 | | - | else throw("Strict value is not equal to itself.") |
---|
186 | | - | } |
---|
187 | | - | else { |
---|
188 | | - | let endBlock = getIntegerValue("end_block") |
---|
189 | | - | $Tuple2([ScriptTransfer(i.caller, amount, lpAssetId), IntegerEntry((toString(i.caller) + "_balance"), walletBalance), IntegerEntry((toString(i.caller) + "_last_withdraw_block"), endBlock), IntegerEntry("total_balance", totalBalance), IntegerEntry("last_withdraw_block", endBlock)], unit) |
---|
190 | | - | } |
---|
191 | | - | } |
---|
192 | | - | else throw("") |
---|
193 | | - | } |
---|
194 | | - | |
---|
195 | | - | |
---|
196 | | - | |
---|
197 | | - | @Callable(i) |
---|
198 | | - | func end () = { |
---|
199 | | - | let isEndLocked = valueOrElse(getBoolean("end_locked"), false) |
---|
200 | | - | let startBlock = getIntegerValue("start_block") |
---|
201 | | - | let isEnded = valueOrElse(getBoolean((("start_block_" + toString(startBlock)) + "_ended")), false) |
---|
202 | | - | let isValidBlock = (height >= (startBlock + roundHeight)) |
---|
203 | | - | if (if (if (if (!(isEndLocked)) |
---|
204 | | - | then !(isEnded) |
---|
205 | | - | else false) |
---|
206 | | - | then isValidBlock |
---|
207 | | - | else false) |
---|
208 | | - | then (targetBlock > startBlock) |
---|
209 | | - | else false) |
---|
210 | | - | then { |
---|
211 | | - | let previousWXAmount = assetBalance(this, wxAssetId) |
---|
212 | | - | if ((previousWXAmount == previousWXAmount)) |
---|
213 | | - | then { |
---|
214 | | - | let previousWXBAmount = assetBalance(this, wxbAssetId) |
---|
215 | | - | if ((previousWXBAmount == previousWXBAmount)) |
---|
216 | | - | then { |
---|
217 | | - | let claimWXCall = invoke(proxyAddress, "claim", nil, nil) |
---|
218 | | - | if ((claimWXCall == claimWXCall)) |
---|
219 | | - | then { |
---|
220 | | - | let roundWXRewardAmount = (assetBalance(this, wxAssetId) - previousWXAmount) |
---|
221 | | - | if ((roundWXRewardAmount == roundWXRewardAmount)) |
---|
222 | | - | then { |
---|
223 | | - | let roundWXBRewardAmount = (assetBalance(this, wxbAssetId) - previousWXBAmount) |
---|
224 | | - | if ((roundWXBRewardAmount == roundWXBRewardAmount)) |
---|
225 | | - | then { |
---|
226 | | - | let totalWXRewardAmount = (valueOrElse(getInteger(this, "total_wx_reward_amount"), 0) + roundWXRewardAmount) |
---|
227 | | - | let totalWXBRewardAmount = (valueOrElse(getInteger(this, "total_wxb_reward_amount"), 0) + roundWXBRewardAmount) |
---|
228 | | - | let roundShare = match getString((toString(startBlock) + "_total_share")) { |
---|
229 | | - | case p: String => |
---|
230 | | - | p |
---|
231 | | - | case n: Unit => |
---|
232 | | - | toString((toBigInt(valueOrElse(getInteger("total_balance"), 0)) * toBigInt(roundHeight))) |
---|
233 | | - | case _ => |
---|
234 | | - | throw("Match error") |
---|
235 | | - | } |
---|
236 | | - | let roundActivity = match getString("round_activity") { |
---|
237 | | - | case p: String => |
---|
238 | | - | ((p + "_") + toString(startBlock)) |
---|
239 | | - | case n: Unit => |
---|
240 | | - | toString(startBlock) |
---|
241 | | - | case _ => |
---|
242 | | - | throw("Match error") |
---|
243 | | - | } |
---|
244 | | - | let rewardAmount = getIntegerValue("reward_amount") |
---|
245 | | - | if ((height >= targetBlock)) |
---|
246 | | - | then { |
---|
247 | | - | let totalBalance = valueOrElse(getInteger("total_balance"), 0) |
---|
248 | | - | let withdrawAll = invoke(proxyAddress, "unstakeLP", [totalBalance], nil) |
---|
249 | | - | if ((withdrawAll == withdrawAll)) |
---|
250 | | - | then $Tuple2([ScriptTransfer(i.caller, rewardAmount, wxbAssetId), IntegerEntry((("start_block_" + toString(startBlock)) + "_end_block"), height), BooleanEntry((("start_block_" + toString(startBlock)) + "_ended"), true), IntegerEntry((("start_block_" + toString(startBlock)) + "_wx_reward_amount"), roundWXRewardAmount), IntegerEntry((("start_block_" + toString(startBlock)) + "_wxb_reward_amount"), roundWXBRewardAmount), IntegerEntry("total_wx_reward_amount", totalWXRewardAmount), IntegerEntry("total_wxb_reward_amount", totalWXBRewardAmount), StringEntry((toString(startBlock) + "_total_share"), roundShare), StringEntry("round_activity", roundActivity), BooleanEntry("ended", true), IntegerEntry("end_block", height)], unit) |
---|
251 | | - | else throw("Strict value is not equal to itself.") |
---|
252 | | - | } |
---|
253 | | - | else $Tuple2([ScriptTransfer(i.caller, rewardAmount, wxbAssetId), IntegerEntry((("start_block_" + toString(startBlock)) + "_end_block"), height), BooleanEntry((("start_block_" + toString(startBlock)) + "_ended"), true), IntegerEntry((("start_block_" + toString(startBlock)) + "_wx_reward_amount"), roundWXRewardAmount), IntegerEntry((("start_block_" + toString(startBlock)) + "_wxb_reward_amount"), roundWXBRewardAmount), IntegerEntry("total_wx_reward_amount", totalWXRewardAmount), IntegerEntry("total_wxb_reward_amount", totalWXBRewardAmount), StringEntry((toString(startBlock) + "_total_share"), roundShare), StringEntry("round_activity", roundActivity), IntegerEntry("start_block", height)], unit) |
---|
254 | | - | } |
---|
255 | | - | else throw("Strict value is not equal to itself.") |
---|
256 | | - | } |
---|
257 | | - | else throw("Strict value is not equal to itself.") |
---|
258 | | - | } |
---|
259 | | - | else throw("Strict value is not equal to itself.") |
---|
260 | | - | } |
---|
261 | | - | else throw("Strict value is not equal to itself.") |
---|
262 | | - | } |
---|
263 | | - | else throw("Strict value is not equal to itself.") |
---|
264 | | - | } |
---|
265 | | - | else throw("") |
---|
266 | | - | } |
---|
267 | | - | |
---|
268 | | - | |
---|
269 | | - | |
---|
270 | | - | @Callable(i) |
---|
271 | | - | func claim (startBlock) = { |
---|
272 | | - | let isClaimLocked = valueOrElse(getBoolean("claim_locked"), false) |
---|
273 | | - | let isEnded = valueOrElse(getBoolean((("start_block_" + toString(startBlock)) + "_ended")), false) |
---|
274 | | - | let isClaimed = valueOrElse(getBoolean((((toString(i.caller) + "_") + toString(startBlock)) + "_claimed")), false) |
---|
275 | | - | let firstBlock = getIntegerValue("first_block") |
---|
276 | | - | if (if (if (if (if (!(isClaimLocked)) |
---|
277 | | - | then isEnded |
---|
278 | | - | else false) |
---|
279 | | - | then !(isClaimed) |
---|
280 | | - | else false) |
---|
281 | | - | then (targetBlock > startBlock) |
---|
282 | | - | else false) |
---|
283 | | - | then (startBlock >= firstBlock) |
---|
284 | | - | else false) |
---|
285 | | - | then { |
---|
286 | | - | func getWalletShare () = { |
---|
287 | | - | let lastDepositBlock = valueOrElse(getInteger((toString(i.caller) + "_last_deposit_block")), 0) |
---|
288 | | - | let lastWithdrawBlock = valueOrElse(getInteger((toString(i.caller) + "_last_withdraw_block")), 0) |
---|
289 | | - | let walletShare = if ((lastDepositBlock == 0)) |
---|
290 | | - | then throw("") |
---|
291 | | - | else if ((valueOrElse(getString((((toString(i.caller) + "_") + toString(startBlock)) + "_share")), "0") != "0")) |
---|
292 | | - | then parseBigIntValue(getStringValue((((toString(i.caller) + "_") + toString(startBlock)) + "_share"))) |
---|
293 | | - | else if ((valueOrElse(getString((((toString(i.caller) + "_") + toString(startBlock)) + "_share")), "-1") == "0")) |
---|
294 | | - | then toBigInt(0) |
---|
295 | | - | else if (if ((startBlock > lastDepositBlock)) |
---|
296 | | - | then (startBlock > lastWithdrawBlock) |
---|
297 | | - | else false) |
---|
298 | | - | then { |
---|
299 | | - | let walletBalance = valueOrElse(getInteger((toString(i.caller) + "_balance")), 0) |
---|
300 | | - | (toBigInt(walletBalance) * toBigInt(roundHeight)) |
---|
301 | | - | } |
---|
302 | | - | else { |
---|
303 | | - | let firstDeposit = getIntegerValue((toString(i.caller) + "_first_deposit")) |
---|
304 | | - | if (!((startBlock > firstDeposit))) |
---|
305 | | - | then throw("") |
---|
306 | | - | else { |
---|
307 | | - | let rounds = getStringValue("round_activity") |
---|
308 | | - | let previousRounds = dropRight(rounds, ((size(rounds) + 1) - value(indexOf(rounds, toString(startBlock))))) |
---|
309 | | - | let theIndexOfTheClosestRound = if ((valueOrElse(lastIndexOf(previousRounds, "_"), 0) != 0)) |
---|
310 | | - | then (value(lastIndexOf(previousRounds, "_")) + 1) |
---|
311 | | - | else 0 |
---|
312 | | - | let closestRound = drop(previousRounds, theIndexOfTheClosestRound) |
---|
313 | | - | let activities = split(getStringValue((toString(i.caller) + "_activity")), "_") |
---|
314 | | - | func findClosest (acc,next) = { |
---|
315 | | - | let closest = if (if ((value(parseInt(closestRound)) > value(parseInt(next)))) |
---|
316 | | - | then (value(parseInt(next)) > value(parseInt(acc))) |
---|
317 | | - | else false) |
---|
318 | | - | then next |
---|
319 | | - | else acc |
---|
320 | | - | closest |
---|
321 | | - | } |
---|
322 | | - | |
---|
323 | | - | let closestActivity = if (containsElement(activities, closestRound)) |
---|
324 | | - | then closestRound |
---|
325 | | - | else { |
---|
326 | | - | let closest = { |
---|
327 | | - | let $l = activities |
---|
328 | | - | let $s = size($l) |
---|
329 | | - | let $acc0 = "0" |
---|
330 | | - | func $f0_1 ($a,$i) = if (($i >= $s)) |
---|
331 | | - | then $a |
---|
332 | | - | else findClosest($a, $l[$i]) |
---|
333 | | - | |
---|
334 | | - | func $f0_2 ($a,$i) = if (($i >= $s)) |
---|
335 | | - | then $a |
---|
336 | | - | else throw("List size exceeds 53") |
---|
337 | | - | |
---|
338 | | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 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) |
---|
339 | | - | } |
---|
340 | | - | closest |
---|
341 | | - | } |
---|
342 | | - | let theShare = (toBigInt(getIntegerValue((((toString(i.caller) + "_") + closestActivity) + "_balance"))) * toBigInt(roundHeight)) |
---|
343 | | - | theShare |
---|
344 | | - | } |
---|
345 | | - | } |
---|
346 | | - | walletShare |
---|
347 | | - | } |
---|
348 | | - | |
---|
349 | | - | let walletShare = getWalletShare() |
---|
350 | | - | if ((walletShare > toBigInt(0))) |
---|
351 | | - | then { |
---|
352 | | - | let totalShare = parseBigIntValue(getStringValue((toString(startBlock) + "_total_share"))) |
---|
353 | | - | let roundTotalWXReward = valueOrElse(getInteger((("start_block_" + toString(startBlock)) + "_wx_reward_amount")), 0) |
---|
354 | | - | let roundUserWXReward = toInt(fraction(walletShare, toBigInt(roundTotalWXReward), totalShare)) |
---|
355 | | - | let roundTotalWXBReward = valueOrElse(getInteger((("start_block_" + toString(startBlock)) + "_wxb_reward_amount")), 0) |
---|
356 | | - | let roundUserWXBReward = toInt(fraction(walletShare, toBigInt(roundTotalWXBReward), totalShare)) |
---|
357 | | - | let roundTotalClaimedWX = (valueOrElse(getInteger((toString(startBlock) + "_total_claimed_wx_reward_amount")), 0) + roundUserWXReward) |
---|
358 | | - | let totalClaimedWX = (valueOrElse(getInteger("total_claimed_wx_reward_amount"), 0) + roundUserWXReward) |
---|
359 | | - | let roundTotalClaimedWXB = (valueOrElse(getInteger((toString(startBlock) + "_total_claimed_wxb_reward_amount")), 0) + roundUserWXBReward) |
---|
360 | | - | let totalClaimedWXB = (valueOrElse(getInteger("total_claimed_wxb_reward_amount"), 0) + roundUserWXBReward) |
---|
361 | | - | let userTotalClaimedWX = (valueOrElse(getInteger((toString(i.caller) + "_total_claimed_wx_amount")), 0) + roundUserWXReward) |
---|
362 | | - | let userTotalClaimedWXB = (valueOrElse(getInteger((toString(i.caller) + "_total_claimed_wxb_amount")), 0) + roundUserWXBReward) |
---|
363 | | - | $Tuple2([ScriptTransfer(i.caller, roundUserWXReward, wxAssetId), ScriptTransfer(i.caller, roundUserWXBReward, wxbAssetId), BooleanEntry((((toString(i.caller) + "_") + toString(startBlock)) + "_claimed"), true), IntegerEntry((toString(i.caller) + "_total_claimed_wx_amount"), userTotalClaimedWX), IntegerEntry((toString(startBlock) + "_total_claimed_wx_reward_amount"), roundTotalClaimedWX), IntegerEntry("total_claimed_wx_reward_amount", totalClaimedWX), IntegerEntry((toString(i.caller) + "_total_claimed_wxb_amount"), userTotalClaimedWXB), IntegerEntry((toString(startBlock) + "_total_claimed_wxb_reward_amount"), roundTotalClaimedWXB), IntegerEntry("total_claimed_wxb_reward_amount", totalClaimedWXB)], unit) |
---|
364 | | - | } |
---|
365 | | - | else throw("") |
---|
366 | | - | } |
---|
367 | | - | else throw("") |
---|
368 | | - | } |
---|
369 | | - | |
---|
370 | | - | |
---|
371 | | - | |
---|
372 | | - | @Callable(i) |
---|
373 | | - | func init (startBlock) = { |
---|
374 | | - | let isInitialized = valueOrElse(getBoolean("initialized"), false) |
---|
375 | | - | if (!(isInitialized)) |
---|
376 | | - | then $Tuple2([BooleanEntry("initialized", true), IntegerEntry("start_block", startBlock), IntegerEntry("first_block", startBlock), IntegerEntry("reward_amount", 10000000000)], unit) |
---|
377 | | - | else throw("") |
---|
378 | | - | } |
---|
379 | | - | |
---|
380 | | - | |
---|
381 | | - | |
---|
382 | | - | @Callable(i) |
---|
383 | | - | func changeRewardAmount (amount) = if ((i.caller == this)) |
---|
384 | | - | then $Tuple2([IntegerEntry("reward_amount", amount)], unit) |
---|
385 | | - | else throw("") |
---|
386 | | - | |
---|
387 | | - | |
---|
388 | | - | |
---|
389 | | - | @Callable(i) |
---|
390 | | - | func lock (deposit,withdraw,end,claim) = if ((i.caller == this)) |
---|
391 | | - | then $Tuple2([BooleanEntry("deposit_locked", deposit), BooleanEntry("withdraw_locked", withdraw), BooleanEntry("end_locked", end), BooleanEntry("claim_locked", claim)], unit) |
---|
392 | | - | else throw("") |
---|
393 | | - | |
---|
394 | | - | |
---|
| 1 | + | # no script |
---|