tx · CDpwHRtmo6zdWy3NCUS5Rw66qFpeG3gn1asXF4FW8SDH 3N7HtrKeFFLz5oy6PfGv1Lg3GwPk4gCPdGy: -0.01200000 Waves 2023.07.01 14:12 [2646750] smart account 3N7HtrKeFFLz5oy6PfGv1Lg3GwPk4gCPdGy > SELF 0.00000000 Waves
{ "type": 13, "id": "CDpwHRtmo6zdWy3NCUS5Rw66qFpeG3gn1asXF4FW8SDH", "fee": 1200000, "feeAssetId": null, "timestamp": 1688209913455, "version": 2, "chainId": 84, "sender": "3N7HtrKeFFLz5oy6PfGv1Lg3GwPk4gCPdGy", "senderPublicKey": "FsR18761ZAsUqsTd7TK3XmR6bhihs1UXVmpHYxz5JzQ1", "proofs": [ "5r3LdRDPk4WSVR1sGymL8zEHoWtmXPku9CHnb1aDFMKLEfDvYCPz8J6v71gvh5gS4XVc5FtB9ijGKhuRZxxEXVVR" ], "script": "base64:BgIgCAISBgoECAgICBIDCgEBEgMKAQESABIDCgEIEgMKAQhFAQprZXlCbG9ja2VkAAIQY29udHJhY3RzQmxvY2tlZAALSWR4RWZmVG90YWwAAAAKSWR4RWZmVXNlcgABAAVjaGFpbgkAyQECCQDKAQIIBQR0aGlzBWJ5dGVzAAEAAQALdXNkdEFzc2V0SWQEByRtYXRjaDAFBWNoYWluAwkAAAIBAVcFByRtYXRjaDABIITaerIIAz9O0bvKju6Lk7zJgt0LXfoHlqjUI/moD/+5AwkAAAIBAVQFByRtYXRjaDABIFWx2J9yh4Lv5eNbjawFq2XemkOhLxa7BfMat4el8cUYCQACAQINVW5rbm93biBjaGFpbgAVZGVmYXVsdFJlc3RBZGRyZXNzU3RyBAckbWF0Y2gwBQVjaGFpbgMJAAACAQFXBQckbWF0Y2gwAiMzUFFDdXZGYnZoNExrUFVucm5VMXozam5iQTFwOW0zV05odgMJAAACAQFUBQckbWF0Y2gwAiMzTXVta0dHenRDS0FYcFdEcXhrZGRvZnFYU1VicVFrdlNKeQkAAgECDVVua25vd24gY2hhaW4ADmFyY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5pZWQJAQ1jbGFpbUludGVybmFsAQkBEUBleHRyTmF0aXZlKDEwNjIpAQUEYWRkcgFpAQ1vblVuc3Rha2VMYW5kAQRhZGRyAwkBAiE9AggFAWkGY2FsbGVyBQ9zdGFraW5nQ29udHJhY3QJAAIBAhFQZXJtaXNzaW9uIGRlbmllZAkBDWNsYWltSW50ZXJuYWwBCQERQGV4dHJOYXRpdmUoMTA2MikBBQRhZGRyADE9pBo=", "height": 2646750, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AHMNGC3CAwwpLGD94tHVmMCM7HjxvbZtfp87jUJ3gu2m Next: 6eK19d1JP3qiR2a8AaK6PBGhZ9GXZL9EVFoU65mehnvT Diff:
Old | New | Differences | |
---|---|---|---|
186 | 186 | let restUsd = assetBalance(restContract, usdtAssetId) | |
187 | 187 | let wlgUsd = assetBalance(wlgContract, usdtAssetId) | |
188 | 188 | let puzzleUsd = assetBalance(puzzlePoolContract, usdtAssetId) | |
189 | - | let totalUsd = (((economyUsd + restUsd) + wlgUsd) + puzzleUsd) | |
190 | - | [issuedAmount, fraction(totalUsd, MULT8, issuedAmount), totalUsd, economyUsd, restUsd, wlgUsd, puzzleUsd] | |
189 | + | let totalFundsUsd = (((economyUsd + restUsd) + wlgUsd) + puzzleUsd) | |
190 | + | [issuedAmount, fraction(totalFundsUsd, MULT8, issuedAmount), totalFundsUsd, economyUsd, restUsd, wlgUsd, puzzleUsd] | |
191 | + | } | |
192 | + | ||
193 | + | ||
194 | + | func fixedPoint (val,decimals) = { | |
195 | + | let tenPow = pow(10, 0, decimals, 0, 0, DOWN) | |
196 | + | ((toString((val / tenPow)) + ".") + toString((val % tenPow))) | |
191 | 197 | } | |
192 | 198 | ||
193 | 199 | ||
216 | 222 | let marketingAddrKey = "marketingAddr" | |
217 | 223 | ||
218 | 224 | let teamAddrKey = "teamAddr" | |
225 | + | ||
226 | + | let profitAddrKey = "profitAddr" | |
219 | 227 | ||
220 | 228 | let lastMarketingTimeKey = "lastClaimedTime_marketing" | |
221 | 229 | ||
254 | 262 | } | |
255 | 263 | ||
256 | 264 | ||
257 | - | @Callable(i) | |
258 | - | func constructorV1 (restAddr,marketingAddr,teamAddr) = if ((i.caller != this)) | |
259 | - | then throw("Permission denied") | |
260 | - | else if (isDefined(getBinary(wlgAssetIdKey))) | |
261 | - | then throw("Already initialized") | |
262 | - | else { | |
263 | - | let issuedAmount = MULT14 | |
264 | - | let issue = Issue("WLGOLD", "WavesLands Gold investment token", issuedAmount, 8, true, unit, 0) | |
265 | - | let assetId = calculateAssetId(issue) | |
266 | - | [issue, IntegerEntry(wlgIssueTimeKey, lastBlock.timestamp), IntegerEntry(wlgIssuedAmountKey, issuedAmount), IntegerEntry(stakersAmountPaidTotalKey, 0), IntegerEntry(stakersAmountLeftKey, fraction(MULT14, PLAYERSHARE, MULT6)), BinaryEntry(wlgAssetIdKey, assetId), StringEntry(keyRestAddress(), restAddr), StringEntry(marketingAddrKey, marketingAddr), StringEntry(teamAddrKey, teamAddr)] | |
267 | - | } | |
268 | - | ||
269 | - | ||
270 | - | ||
271 | - | @Callable(i) | |
272 | - | func buyWlg () = { | |
273 | - | let prologResult = prolog() | |
274 | - | if ((size(i.payments) != 1)) | |
275 | - | then throw("exactly 1 payment must be attached") | |
276 | - | else { | |
277 | - | let pmt = i.payments[0] | |
278 | - | let usdtAmt = pmt.amount | |
279 | - | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment") | |
280 | - | if ((pmtAssetId != usdtAssetId)) | |
281 | - | then throw("USDT payments only!") | |
282 | - | else { | |
283 | - | let caller = i.caller | |
284 | - | let addr = toString(caller) | |
285 | - | let maxUsdt = getSwapLimit(addr) | |
286 | - | if ((usdtAmt > maxUsdt)) | |
287 | - | then throw((("You can spend max " + toString(maxUsdt)) + " USDT")) | |
288 | - | else { | |
289 | - | let curStats = getWlgStats() | |
290 | - | let curAmount = curStats[idxWlgAmount] | |
291 | - | let buyPrice = fraction(curStats[idxWlgPrice], 6, 5) | |
292 | - | let wlgAmount = fraction(usdtAmt, MULT8, buyPrice) | |
293 | - | let reissued = fraction(usdtAmt, curAmount, (curStats[idxWlgFunds] - usdtAmt)) | |
294 | - | $Tuple2([Reissue(wlgAssetId, reissued, true), IntegerEntry(wlgIssuedAmountKey, (curAmount + reissued)), IntegerEntry(keyLastArbTimeByUser(addr), lastBlock.timestamp), ScriptTransfer(caller, wlgAmount, wlgAssetId)], prologResult) | |
295 | - | } | |
296 | - | } | |
297 | - | } | |
298 | - | } | |
299 | - | ||
300 | - | ||
301 | - | ||
302 | - | @Callable(i) | |
303 | - | func sellWlg () = { | |
304 | - | let prologResult = prolog() | |
305 | - | if ((size(i.payments) != 1)) | |
306 | - | then throw("exactly 1 payment must be attached") | |
307 | - | else { | |
308 | - | let pmt = i.payments[0] | |
309 | - | let wlgAmt = pmt.amount | |
310 | - | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment") | |
311 | - | if ((pmtAssetId != wlgAssetId)) | |
312 | - | then throw("WLGOLD payments only!") | |
313 | - | else { | |
314 | - | let caller = i.caller | |
315 | - | let addr = toString(caller) | |
316 | - | let maxUsdt = getSwapLimit(addr) | |
317 | - | let curStats = getWlgStats() | |
318 | - | let curAmount = (curStats[idxWlgAmount] - wlgAmt) | |
319 | - | let sellPrice = fraction(curStats[idxWlgPrice], 4, 5) | |
320 | - | let usdtAmount = fraction(wlgAmt, sellPrice, MULT8) | |
321 | - | if ((usdtAmount > maxUsdt)) | |
322 | - | then throw((("You can get max " + toString(maxUsdt)) + " USDT")) | |
323 | - | else { | |
324 | - | let burned = fraction(usdtAmount, curAmount, curStats[idxWlgFunds]) | |
325 | - | $Tuple2([Burn(wlgAssetId, burned), IntegerEntry(wlgIssuedAmountKey, (curAmount - burned)), IntegerEntry(keyLastArbTimeByUser(addr), lastBlock.timestamp), ScriptTransfer(caller, usdtAmount, usdtAssetId)], prologResult) | |
326 | - | } | |
327 | - | } | |
328 | - | } | |
329 | - | } | |
330 | - | ||
331 | - | ||
332 | - | ||
333 | - | @Callable(i) | |
334 | - | func claim () = { | |
335 | - | let prologResult = prolog() | |
336 | - | let caller = i.caller | |
265 | + | func claimInternal (caller) = { | |
337 | 266 | let callerAddr = toString(caller) | |
338 | 267 | let now = lastBlock.timestamp | |
339 | 268 | let issueTime = valueOrErrorMessage(getInteger(wlgIssueTimeKey), "Not initialized") | |
357 | 286 | let lastUserTime = valueOrElse(getInteger(userTimeKey), issueTime) | |
358 | 287 | let userAmount = fraction(fraction(curPeriodDistribution, eff[IdxEffUser], totalPieces), (now - lastUserTime), (3 * YEARMILLIS)) | |
359 | 288 | let userKey = keyStakersAmountPaidUser(callerAddr) | |
360 | - | $Tuple2([ScriptTransfer(marketingAddr, marketingAmount, wlgAssetId), ScriptTransfer(teamAddr, teamAmount, wlgAssetId), ScriptTransfer(restContract, actAmount, wlgAssetId), ScriptTransfer(caller, userAmount, wlgAssetId), IntegerEntry(userKey, (valueOrElse(getInteger(userKey), 0) + userAmount)), IntegerEntry(stakersAmountPaidTotalKey, (valueOrElse(getInteger(stakersAmountPaidTotalKey), 0) + userAmount)), IntegerEntry(stakersAmountLeftKey, (amountLeftTotal - userAmount)), IntegerEntry(lastMarketingTimeKey, now), IntegerEntry(lastTeamTimeKey, now), IntegerEntry(lastActivitiesTimeKey, now), IntegerEntry(userTimeKey, now)], | |
289 | + | $Tuple2([ScriptTransfer(marketingAddr, marketingAmount, wlgAssetId), ScriptTransfer(teamAddr, teamAmount, wlgAssetId), ScriptTransfer(restContract, actAmount, wlgAssetId), ScriptTransfer(caller, userAmount, wlgAssetId), IntegerEntry(userKey, (valueOrElse(getInteger(userKey), 0) + userAmount)), IntegerEntry(stakersAmountPaidTotalKey, (valueOrElse(getInteger(stakersAmountPaidTotalKey), 0) + userAmount)), IntegerEntry(stakersAmountLeftKey, (amountLeftTotal - userAmount)), IntegerEntry(lastMarketingTimeKey, now), IntegerEntry(lastTeamTimeKey, now), IntegerEntry(lastActivitiesTimeKey, now), IntegerEntry(userTimeKey, now)], userAmount) | |
361 | 290 | } | |
291 | + | } | |
292 | + | ||
293 | + | ||
294 | + | @Callable(i) | |
295 | + | func constructorV1 (restAddr,marketingAddr,teamAddr,profitAddr) = if ((i.caller != this)) | |
296 | + | then throw("Permission denied") | |
297 | + | else if (isDefined(getBinary(wlgAssetIdKey))) | |
298 | + | then throw("Already initialized") | |
299 | + | else { | |
300 | + | let issuedAmount = MULT14 | |
301 | + | let issue = Issue("WLGOLD", "WavesLands Gold investment token", issuedAmount, 8, true, unit, 0) | |
302 | + | let assetId = calculateAssetId(issue) | |
303 | + | [issue, IntegerEntry(wlgIssueTimeKey, lastBlock.timestamp), IntegerEntry(wlgIssuedAmountKey, issuedAmount), IntegerEntry(stakersAmountPaidTotalKey, 0), IntegerEntry(stakersAmountLeftKey, fraction(MULT14, PLAYERSHARE, MULT6)), BinaryEntry(wlgAssetIdKey, assetId), StringEntry(keyRestAddress(), restAddr), StringEntry(marketingAddrKey, marketingAddr), StringEntry(teamAddrKey, teamAddr), StringEntry(profitAddrKey, profitAddr)] | |
304 | + | } | |
305 | + | ||
306 | + | ||
307 | + | ||
308 | + | @Callable(i) | |
309 | + | func buyWlg (minAmount) = { | |
310 | + | let prologResult = prolog() | |
311 | + | if ((size(i.payments) != 1)) | |
312 | + | then throw("exactly 1 payment must be attached") | |
313 | + | else { | |
314 | + | let pmt = i.payments[0] | |
315 | + | let usdtAmt = pmt.amount | |
316 | + | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment") | |
317 | + | if ((pmtAssetId != usdtAssetId)) | |
318 | + | then throw("USDT payments only!") | |
319 | + | else { | |
320 | + | let caller = i.caller | |
321 | + | let addr = toString(caller) | |
322 | + | let maxUsdt = getSwapLimit(addr) | |
323 | + | if ((usdtAmt > maxUsdt)) | |
324 | + | then throw((("You can spend max " + fixedPoint(maxUsdt, 6)) + " USDT")) | |
325 | + | else { | |
326 | + | let curStats = getWlgStats() | |
327 | + | let curWlgAmount = curStats[idxWlgAmount] | |
328 | + | let oldFundsUsd = (curStats[idxWlgFunds] - usdtAmt) | |
329 | + | let wlgPrice = fraction(oldFundsUsd, MULT8, curWlgAmount) | |
330 | + | let buyPrice = fraction(wlgPrice, 6, 5) | |
331 | + | let wlgAmount = fraction(usdtAmt, MULT8, buyPrice) | |
332 | + | if ((minAmount > wlgAmount)) | |
333 | + | then throw("Price changed during operation, please try again") | |
334 | + | else { | |
335 | + | let profitAmount = (usdtAmt / 6) | |
336 | + | let deltaFunds = (usdtAmt - profitAmount) | |
337 | + | let reissued = fraction(curWlgAmount, deltaFunds, oldFundsUsd) | |
338 | + | $Tuple2([Reissue(wlgAssetId, reissued, true), IntegerEntry(wlgIssuedAmountKey, (curWlgAmount + reissued)), IntegerEntry(keyLastArbTimeByUser(addr), lastBlock.timestamp), ScriptTransfer(addressFromStringValue(value(getString(profitAddrKey))), profitAmount, usdtAssetId), ScriptTransfer(caller, wlgAmount, wlgAssetId)], prologResult) | |
339 | + | } | |
340 | + | } | |
341 | + | } | |
342 | + | } | |
343 | + | } | |
344 | + | ||
345 | + | ||
346 | + | ||
347 | + | @Callable(i) | |
348 | + | func sellWlg (minAmount) = { | |
349 | + | let prologResult = prolog() | |
350 | + | if ((size(i.payments) != 1)) | |
351 | + | then throw("exactly 1 payment must be attached") | |
352 | + | else { | |
353 | + | let pmt = i.payments[0] | |
354 | + | let wlgAmt = pmt.amount | |
355 | + | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment") | |
356 | + | if ((pmtAssetId != wlgAssetId)) | |
357 | + | then throw("WLGOLD payments only!") | |
358 | + | else { | |
359 | + | let caller = i.caller | |
360 | + | let addr = toString(caller) | |
361 | + | let maxUsdt = getSwapLimit(addr) | |
362 | + | let curStats = getWlgStats() | |
363 | + | let curWlgAmount = curStats[idxWlgAmount] | |
364 | + | let sellPrice = fraction(curStats[idxWlgPrice], 4, 5) | |
365 | + | let usdtAmt = fraction(wlgAmt, sellPrice, MULT8) | |
366 | + | if ((usdtAmt > maxUsdt)) | |
367 | + | then throw((("You can get max " + fixedPoint(maxUsdt, 6)) + " USDT")) | |
368 | + | else if ((minAmount > usdtAmt)) | |
369 | + | then throw("Price changed during operation, please try again") | |
370 | + | else { | |
371 | + | let profitAmount = (usdtAmt / 4) | |
372 | + | let burned = fraction((usdtAmt + profitAmount), curWlgAmount, curStats[idxWlgFunds]) | |
373 | + | $Tuple2([Burn(wlgAssetId, burned), IntegerEntry(wlgIssuedAmountKey, (curWlgAmount - burned)), IntegerEntry(keyLastArbTimeByUser(addr), lastBlock.timestamp), ScriptTransfer(addressFromStringValue(value(getString(profitAddrKey))), profitAmount, usdtAssetId), ScriptTransfer(caller, usdtAmt, usdtAssetId)], prologResult) | |
374 | + | } | |
375 | + | } | |
376 | + | } | |
377 | + | } | |
378 | + | ||
379 | + | ||
380 | + | ||
381 | + | @Callable(i) | |
382 | + | func claim () = { | |
383 | + | let prologResult = prolog() | |
384 | + | let actions = claimInternal(i.caller)._1 | |
385 | + | $Tuple2(actions, prologResult) | |
362 | 386 | } | |
363 | 387 | ||
364 | 388 | ||
366 | 390 | @Callable(i) | |
367 | 391 | func onStakeLand (addr) = if ((i.caller != stakingContract)) | |
368 | 392 | then throw("Permission denied") | |
369 | - | else | |
393 | + | else claimInternal(addressFromStringValue(addr)) | |
370 | 394 | ||
371 | 395 | ||
372 | 396 | ||
373 | 397 | @Callable(i) | |
374 | 398 | func onUnstakeLand (addr) = if ((i.caller != stakingContract)) | |
375 | 399 | then throw("Permission denied") | |
376 | - | else | |
400 | + | else claimInternal(addressFromStringValue(addr)) | |
377 | 401 | ||
378 | 402 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func keyBlocked () = "contractsBlocked" | |
5 | 5 | ||
6 | 6 | ||
7 | 7 | let IdxEffTotal = 0 | |
8 | 8 | ||
9 | 9 | let IdxEffUser = 1 | |
10 | 10 | ||
11 | 11 | let chain = take(drop(this.bytes, 1), 1) | |
12 | 12 | ||
13 | 13 | let usdtAssetId = match chain { | |
14 | 14 | case _ => | |
15 | 15 | if ((base58'2W' == $match0)) | |
16 | 16 | then base58'9wc3LXNA4TEBsXyKtoLE9mrbDD7WMHXvXrCjZvabLAsi' | |
17 | 17 | else if ((base58'2T' == $match0)) | |
18 | 18 | then base58'6mWwf9mZBjVgkC54idpyaZLQfAosD914wT8fGf2iiY63' | |
19 | 19 | else throw("Unknown chain") | |
20 | 20 | } | |
21 | 21 | ||
22 | 22 | let defaultRestAddressStr = match chain { | |
23 | 23 | case _ => | |
24 | 24 | if ((base58'2W' == $match0)) | |
25 | 25 | then "3PQCuvFbvh4LkPUnrnU1z3jnbA1p9m3WNhv" | |
26 | 26 | else if ((base58'2T' == $match0)) | |
27 | 27 | then "3MumkGGztCKAXpWDqxkddofqXSUbqQkvSJy" | |
28 | 28 | else throw("Unknown chain") | |
29 | 29 | } | |
30 | 30 | ||
31 | 31 | let arbitrageDelay = match chain { | |
32 | 32 | case _ => | |
33 | 33 | if ((base58'2W' == $match0)) | |
34 | 34 | then 600000 | |
35 | 35 | else if ((base58'2T' == $match0)) | |
36 | 36 | then 60000 | |
37 | 37 | else throw("Unknown chain") | |
38 | 38 | } | |
39 | 39 | ||
40 | 40 | let SEP = "__" | |
41 | 41 | ||
42 | 42 | let MULT6 = 1000000 | |
43 | 43 | ||
44 | 44 | let MULT8 = 100000000 | |
45 | 45 | ||
46 | 46 | let SSIZE = 25 | |
47 | 47 | ||
48 | 48 | let MSIZE = 100 | |
49 | 49 | ||
50 | 50 | let LSIZE = 225 | |
51 | 51 | ||
52 | 52 | let XLSIZE = 400 | |
53 | 53 | ||
54 | 54 | let XXLSIZE = 625 | |
55 | 55 | ||
56 | 56 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
57 | 57 | ||
58 | 58 | ||
59 | 59 | let IdxCfgStakingDapp = 1 | |
60 | 60 | ||
61 | 61 | let IdxCfgEconomyDapp = 2 | |
62 | 62 | ||
63 | 63 | let IdxCfgWlgDapp = 4 | |
64 | 64 | ||
65 | 65 | let IdxCfgPuzzlePoolDapp = 5 | |
66 | 66 | ||
67 | 67 | func keyRestCfg () = "%s__restConfig" | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | func keyRestAddress () = "%s__restAddr" | |
71 | 71 | ||
72 | 72 | ||
73 | 73 | func readRestCfgOrFail (rest) = split_4C(getStringOrFail(rest, keyRestCfg()), SEP) | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | func getContractAddressOrFail (restCfg,idx) = valueOrErrorMessage(addressFromString(restCfg[idx]), ("Rest cfg doesn't contain address at index " + toString(idx))) | |
77 | 77 | ||
78 | 78 | ||
79 | 79 | let restContract = addressFromStringValue(valueOrElse(getString(this, keyRestAddress()), defaultRestAddressStr)) | |
80 | 80 | ||
81 | 81 | let restCfg = readRestCfgOrFail(restContract) | |
82 | 82 | ||
83 | 83 | let stakingContract = getContractAddressOrFail(restCfg, IdxCfgStakingDapp) | |
84 | 84 | ||
85 | 85 | let economyContract = getContractAddressOrFail(restCfg, IdxCfgEconomyDapp) | |
86 | 86 | ||
87 | 87 | let wlgContract = getContractAddressOrFail(restCfg, IdxCfgWlgDapp) | |
88 | 88 | ||
89 | 89 | let puzzlePoolContract = getContractAddressOrFail(restCfg, IdxCfgPuzzlePoolDapp) | |
90 | 90 | ||
91 | 91 | let recLandSize = 1 | |
92 | 92 | ||
93 | 93 | func keyResProportions () = "resTypesProportions" | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func keyStakedLandsByOwner (ownerAddr) = ("stakedLandsByOwner_" + ownerAddr) | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | let wlgIssuedAmountKey = "wlg_issuedAmount" | |
100 | 100 | ||
101 | 101 | let wlgAssetIdKey = "wlg_assetId" | |
102 | 102 | ||
103 | 103 | let wlgAssetId = valueOrErrorMessage(getBinary(wlgContract, wlgAssetIdKey), "Not initialized yet") | |
104 | 104 | ||
105 | 105 | let idxWlgAmount = 0 | |
106 | 106 | ||
107 | 107 | let idxWlgPrice = 1 | |
108 | 108 | ||
109 | 109 | let idxWlgFunds = 2 | |
110 | 110 | ||
111 | 111 | func asInt (v) = match v { | |
112 | 112 | case n: Int => | |
113 | 113 | n | |
114 | 114 | case _ => | |
115 | 115 | throw("fail to cast into Int") | |
116 | 116 | } | |
117 | 117 | ||
118 | 118 | ||
119 | 119 | func numPiecesBySize (landSize) = match landSize { | |
120 | 120 | case _ => | |
121 | 121 | if (("S" == $match0)) | |
122 | 122 | then SSIZE | |
123 | 123 | else if (("M" == $match0)) | |
124 | 124 | then MSIZE | |
125 | 125 | else if (("L" == $match0)) | |
126 | 126 | then LSIZE | |
127 | 127 | else if (("XL" == $match0)) | |
128 | 128 | then XLSIZE | |
129 | 129 | else if (("XXL" == $match0)) | |
130 | 130 | then XXLSIZE | |
131 | 131 | else throw("Unknown land size") | |
132 | 132 | } | |
133 | 133 | ||
134 | 134 | ||
135 | 135 | func getVotingPower (userAddrStrOrEmpty) = { | |
136 | 136 | let props = split(valueOrElse(getString(stakingContract, keyResProportions()), "0_0_0_0_0_0"), "_") | |
137 | 137 | func adder (acc,item) = (acc + parseIntValue(item)) | |
138 | 138 | ||
139 | 139 | let totalPower = { | |
140 | 140 | let $l = props | |
141 | 141 | let $s = size($l) | |
142 | 142 | let $acc0 = 0 | |
143 | 143 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
144 | 144 | then $a | |
145 | 145 | else adder($a, $l[$i]) | |
146 | 146 | ||
147 | 147 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
148 | 148 | then $a | |
149 | 149 | else throw("List size exceeds 6") | |
150 | 150 | ||
151 | 151 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
152 | 152 | } | |
153 | 153 | let usersPower = if ((userAddrStrOrEmpty == "")) | |
154 | 154 | then 0 | |
155 | 155 | else { | |
156 | 156 | let landsStr = getString(stakingContract, keyStakedLandsByOwner(userAddrStrOrEmpty)) | |
157 | 157 | let lands = if (isDefined(landsStr)) | |
158 | 158 | then split_51C(value(landsStr), "_") | |
159 | 159 | else nil | |
160 | 160 | func oneLand (acc,landAssetId) = { | |
161 | 161 | let asset = value(assetInfo(fromBase58String(landAssetId))) | |
162 | 162 | let landSize = split(asset.description, "_")[recLandSize] | |
163 | 163 | (acc + numPiecesBySize(landSize)) | |
164 | 164 | } | |
165 | 165 | ||
166 | 166 | let $l = lands | |
167 | 167 | let $s = size($l) | |
168 | 168 | let $acc0 = 0 | |
169 | 169 | func $f1_1 ($a,$i) = if (($i >= $s)) | |
170 | 170 | then $a | |
171 | 171 | else oneLand($a, $l[$i]) | |
172 | 172 | ||
173 | 173 | func $f1_2 ($a,$i) = if (($i >= $s)) | |
174 | 174 | then $a | |
175 | 175 | else throw("List size exceeds 100") | |
176 | 176 | ||
177 | 177 | $f1_2($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_1($f1_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), 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) | |
178 | 178 | } | |
179 | 179 | [totalPower, usersPower] | |
180 | 180 | } | |
181 | 181 | ||
182 | 182 | ||
183 | 183 | func getWlgStats () = { | |
184 | 184 | let issuedAmount = valueOrErrorMessage(getInteger(wlgContract, wlgIssuedAmountKey), "WLGOLD is not issued yet") | |
185 | 185 | let economyUsd = assetBalance(economyContract, usdtAssetId) | |
186 | 186 | let restUsd = assetBalance(restContract, usdtAssetId) | |
187 | 187 | let wlgUsd = assetBalance(wlgContract, usdtAssetId) | |
188 | 188 | let puzzleUsd = assetBalance(puzzlePoolContract, usdtAssetId) | |
189 | - | let totalUsd = (((economyUsd + restUsd) + wlgUsd) + puzzleUsd) | |
190 | - | [issuedAmount, fraction(totalUsd, MULT8, issuedAmount), totalUsd, economyUsd, restUsd, wlgUsd, puzzleUsd] | |
189 | + | let totalFundsUsd = (((economyUsd + restUsd) + wlgUsd) + puzzleUsd) | |
190 | + | [issuedAmount, fraction(totalFundsUsd, MULT8, issuedAmount), totalFundsUsd, economyUsd, restUsd, wlgUsd, puzzleUsd] | |
191 | + | } | |
192 | + | ||
193 | + | ||
194 | + | func fixedPoint (val,decimals) = { | |
195 | + | let tenPow = pow(10, 0, decimals, 0, 0, DOWN) | |
196 | + | ((toString((val / tenPow)) + ".") + toString((val % tenPow))) | |
191 | 197 | } | |
192 | 198 | ||
193 | 199 | ||
194 | 200 | let MULT14 = 100000000000000 | |
195 | 201 | ||
196 | 202 | let MARKETINGSHARE = 100000 | |
197 | 203 | ||
198 | 204 | let TEAMSHARE = 200000 | |
199 | 205 | ||
200 | 206 | let ACTIVITYSHARE = 100000 | |
201 | 207 | ||
202 | 208 | let PLAYERSHARE = 400000 | |
203 | 209 | ||
204 | 210 | let YEARMILLIS = 31557600000 | |
205 | 211 | ||
206 | 212 | let WEEKMILLIS = 604800000 | |
207 | 213 | ||
208 | 214 | let MAXPERIOD = 156 | |
209 | 215 | ||
210 | 216 | let A6 = 100000000 | |
211 | 217 | ||
212 | 218 | let B8 = 50000000 | |
213 | 219 | ||
214 | 220 | let wlgIssueTimeKey = "wlg_issueTime" | |
215 | 221 | ||
216 | 222 | let marketingAddrKey = "marketingAddr" | |
217 | 223 | ||
218 | 224 | let teamAddrKey = "teamAddr" | |
225 | + | ||
226 | + | let profitAddrKey = "profitAddr" | |
219 | 227 | ||
220 | 228 | let lastMarketingTimeKey = "lastClaimedTime_marketing" | |
221 | 229 | ||
222 | 230 | let lastTeamTimeKey = "lastClaimedTime_team" | |
223 | 231 | ||
224 | 232 | let lastActivitiesTimeKey = "lastClaimedTime_activities" | |
225 | 233 | ||
226 | 234 | func keyLastClaimedTimeByUser (addr) = ("lastClaimedTimeUser_" + addr) | |
227 | 235 | ||
228 | 236 | ||
229 | 237 | func keyLastArbTimeByUser (addr) = ("lastArbTimeUser_" + addr) | |
230 | 238 | ||
231 | 239 | ||
232 | 240 | let stakersAmountLeftKey = "stakersAmountLeft" | |
233 | 241 | ||
234 | 242 | let stakersAmountPaidTotalKey = "stakersAmountPaidTotal" | |
235 | 243 | ||
236 | 244 | func keyStakersAmountPaidUser (addr) = ("stakersAmountPaidUser_" + addr) | |
237 | 245 | ||
238 | 246 | ||
239 | 247 | func prolog () = if (valueOrElse(getBoolean(stakingContract, keyBlocked()), false)) | |
240 | 248 | then throw("Contracts are under maintenance") | |
241 | 249 | else asInt(invoke(stakingContract, "saveLastTx", nil, nil)) | |
242 | 250 | ||
243 | 251 | ||
244 | 252 | func getSwapLimit (addr) = { | |
245 | 253 | let lastTime = valueOrElse(getInteger(keyLastArbTimeByUser(addr)), 0) | |
246 | 254 | let now = lastBlock.timestamp | |
247 | 255 | if ((arbitrageDelay > (now - lastTime))) | |
248 | 256 | then throw("Arbitrages are possible once a 10 minutes") | |
249 | 257 | else { | |
250 | 258 | let pieces = getVotingPower(addr)[IdxEffUser] | |
251 | 259 | let pow8 = pow(pieces, 0, B8, 8, 8, CEILING) | |
252 | 260 | fraction(A6, pow8, MULT8) | |
253 | 261 | } | |
254 | 262 | } | |
255 | 263 | ||
256 | 264 | ||
257 | - | @Callable(i) | |
258 | - | func constructorV1 (restAddr,marketingAddr,teamAddr) = if ((i.caller != this)) | |
259 | - | then throw("Permission denied") | |
260 | - | else if (isDefined(getBinary(wlgAssetIdKey))) | |
261 | - | then throw("Already initialized") | |
262 | - | else { | |
263 | - | let issuedAmount = MULT14 | |
264 | - | let issue = Issue("WLGOLD", "WavesLands Gold investment token", issuedAmount, 8, true, unit, 0) | |
265 | - | let assetId = calculateAssetId(issue) | |
266 | - | [issue, IntegerEntry(wlgIssueTimeKey, lastBlock.timestamp), IntegerEntry(wlgIssuedAmountKey, issuedAmount), IntegerEntry(stakersAmountPaidTotalKey, 0), IntegerEntry(stakersAmountLeftKey, fraction(MULT14, PLAYERSHARE, MULT6)), BinaryEntry(wlgAssetIdKey, assetId), StringEntry(keyRestAddress(), restAddr), StringEntry(marketingAddrKey, marketingAddr), StringEntry(teamAddrKey, teamAddr)] | |
267 | - | } | |
268 | - | ||
269 | - | ||
270 | - | ||
271 | - | @Callable(i) | |
272 | - | func buyWlg () = { | |
273 | - | let prologResult = prolog() | |
274 | - | if ((size(i.payments) != 1)) | |
275 | - | then throw("exactly 1 payment must be attached") | |
276 | - | else { | |
277 | - | let pmt = i.payments[0] | |
278 | - | let usdtAmt = pmt.amount | |
279 | - | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment") | |
280 | - | if ((pmtAssetId != usdtAssetId)) | |
281 | - | then throw("USDT payments only!") | |
282 | - | else { | |
283 | - | let caller = i.caller | |
284 | - | let addr = toString(caller) | |
285 | - | let maxUsdt = getSwapLimit(addr) | |
286 | - | if ((usdtAmt > maxUsdt)) | |
287 | - | then throw((("You can spend max " + toString(maxUsdt)) + " USDT")) | |
288 | - | else { | |
289 | - | let curStats = getWlgStats() | |
290 | - | let curAmount = curStats[idxWlgAmount] | |
291 | - | let buyPrice = fraction(curStats[idxWlgPrice], 6, 5) | |
292 | - | let wlgAmount = fraction(usdtAmt, MULT8, buyPrice) | |
293 | - | let reissued = fraction(usdtAmt, curAmount, (curStats[idxWlgFunds] - usdtAmt)) | |
294 | - | $Tuple2([Reissue(wlgAssetId, reissued, true), IntegerEntry(wlgIssuedAmountKey, (curAmount + reissued)), IntegerEntry(keyLastArbTimeByUser(addr), lastBlock.timestamp), ScriptTransfer(caller, wlgAmount, wlgAssetId)], prologResult) | |
295 | - | } | |
296 | - | } | |
297 | - | } | |
298 | - | } | |
299 | - | ||
300 | - | ||
301 | - | ||
302 | - | @Callable(i) | |
303 | - | func sellWlg () = { | |
304 | - | let prologResult = prolog() | |
305 | - | if ((size(i.payments) != 1)) | |
306 | - | then throw("exactly 1 payment must be attached") | |
307 | - | else { | |
308 | - | let pmt = i.payments[0] | |
309 | - | let wlgAmt = pmt.amount | |
310 | - | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment") | |
311 | - | if ((pmtAssetId != wlgAssetId)) | |
312 | - | then throw("WLGOLD payments only!") | |
313 | - | else { | |
314 | - | let caller = i.caller | |
315 | - | let addr = toString(caller) | |
316 | - | let maxUsdt = getSwapLimit(addr) | |
317 | - | let curStats = getWlgStats() | |
318 | - | let curAmount = (curStats[idxWlgAmount] - wlgAmt) | |
319 | - | let sellPrice = fraction(curStats[idxWlgPrice], 4, 5) | |
320 | - | let usdtAmount = fraction(wlgAmt, sellPrice, MULT8) | |
321 | - | if ((usdtAmount > maxUsdt)) | |
322 | - | then throw((("You can get max " + toString(maxUsdt)) + " USDT")) | |
323 | - | else { | |
324 | - | let burned = fraction(usdtAmount, curAmount, curStats[idxWlgFunds]) | |
325 | - | $Tuple2([Burn(wlgAssetId, burned), IntegerEntry(wlgIssuedAmountKey, (curAmount - burned)), IntegerEntry(keyLastArbTimeByUser(addr), lastBlock.timestamp), ScriptTransfer(caller, usdtAmount, usdtAssetId)], prologResult) | |
326 | - | } | |
327 | - | } | |
328 | - | } | |
329 | - | } | |
330 | - | ||
331 | - | ||
332 | - | ||
333 | - | @Callable(i) | |
334 | - | func claim () = { | |
335 | - | let prologResult = prolog() | |
336 | - | let caller = i.caller | |
265 | + | func claimInternal (caller) = { | |
337 | 266 | let callerAddr = toString(caller) | |
338 | 267 | let now = lastBlock.timestamp | |
339 | 268 | let issueTime = valueOrErrorMessage(getInteger(wlgIssueTimeKey), "Not initialized") | |
340 | 269 | let lastMarketingTime = valueOrElse(getInteger(lastMarketingTimeKey), issueTime) | |
341 | 270 | let marketingAddr = addressFromStringValue(value(getString(marketingAddrKey))) | |
342 | 271 | let marketingAmount = fraction(fraction(MULT14, MARKETINGSHARE, MULT6), (now - lastMarketingTime), YEARMILLIS) | |
343 | 272 | let lastTeamTime = valueOrElse(getInteger(lastTeamTimeKey), issueTime) | |
344 | 273 | let teamAddr = addressFromStringValue(value(getString(teamAddrKey))) | |
345 | 274 | let teamAmount = fraction(fraction(MULT14, TEAMSHARE, MULT6), (now - lastTeamTime), (3 * YEARMILLIS)) | |
346 | 275 | let lastActivitiesTime = valueOrElse(getInteger(lastActivitiesTimeKey), issueTime) | |
347 | 276 | let actAmount = fraction(fraction(MULT14, ACTIVITYSHARE, MULT6), (now - lastActivitiesTime), (3 * YEARMILLIS)) | |
348 | 277 | let curPeriod = ((now - issueTime) / WEEKMILLIS) | |
349 | 278 | if ((curPeriod > (MAXPERIOD / 2))) | |
350 | 279 | then throw("Please modify contract for next 1.5 years, according to stats") | |
351 | 280 | else { | |
352 | 281 | let eff = getVotingPower(callerAddr) | |
353 | 282 | let totalPieces = eff[IdxEffTotal] | |
354 | 283 | let amountLeftTotal = valueOrElse(getInteger(stakersAmountLeftKey), 0) | |
355 | 284 | let curPeriodDistribution = fraction(amountLeftTotal, (2 * totalPieces), (totalPieces + (max([100000, totalPieces]) * (MAXPERIOD - curPeriod)))) | |
356 | 285 | let userTimeKey = keyLastClaimedTimeByUser(callerAddr) | |
357 | 286 | let lastUserTime = valueOrElse(getInteger(userTimeKey), issueTime) | |
358 | 287 | let userAmount = fraction(fraction(curPeriodDistribution, eff[IdxEffUser], totalPieces), (now - lastUserTime), (3 * YEARMILLIS)) | |
359 | 288 | let userKey = keyStakersAmountPaidUser(callerAddr) | |
360 | - | $Tuple2([ScriptTransfer(marketingAddr, marketingAmount, wlgAssetId), ScriptTransfer(teamAddr, teamAmount, wlgAssetId), ScriptTransfer(restContract, actAmount, wlgAssetId), ScriptTransfer(caller, userAmount, wlgAssetId), IntegerEntry(userKey, (valueOrElse(getInteger(userKey), 0) + userAmount)), IntegerEntry(stakersAmountPaidTotalKey, (valueOrElse(getInteger(stakersAmountPaidTotalKey), 0) + userAmount)), IntegerEntry(stakersAmountLeftKey, (amountLeftTotal - userAmount)), IntegerEntry(lastMarketingTimeKey, now), IntegerEntry(lastTeamTimeKey, now), IntegerEntry(lastActivitiesTimeKey, now), IntegerEntry(userTimeKey, now)], | |
289 | + | $Tuple2([ScriptTransfer(marketingAddr, marketingAmount, wlgAssetId), ScriptTransfer(teamAddr, teamAmount, wlgAssetId), ScriptTransfer(restContract, actAmount, wlgAssetId), ScriptTransfer(caller, userAmount, wlgAssetId), IntegerEntry(userKey, (valueOrElse(getInteger(userKey), 0) + userAmount)), IntegerEntry(stakersAmountPaidTotalKey, (valueOrElse(getInteger(stakersAmountPaidTotalKey), 0) + userAmount)), IntegerEntry(stakersAmountLeftKey, (amountLeftTotal - userAmount)), IntegerEntry(lastMarketingTimeKey, now), IntegerEntry(lastTeamTimeKey, now), IntegerEntry(lastActivitiesTimeKey, now), IntegerEntry(userTimeKey, now)], userAmount) | |
361 | 290 | } | |
291 | + | } | |
292 | + | ||
293 | + | ||
294 | + | @Callable(i) | |
295 | + | func constructorV1 (restAddr,marketingAddr,teamAddr,profitAddr) = if ((i.caller != this)) | |
296 | + | then throw("Permission denied") | |
297 | + | else if (isDefined(getBinary(wlgAssetIdKey))) | |
298 | + | then throw("Already initialized") | |
299 | + | else { | |
300 | + | let issuedAmount = MULT14 | |
301 | + | let issue = Issue("WLGOLD", "WavesLands Gold investment token", issuedAmount, 8, true, unit, 0) | |
302 | + | let assetId = calculateAssetId(issue) | |
303 | + | [issue, IntegerEntry(wlgIssueTimeKey, lastBlock.timestamp), IntegerEntry(wlgIssuedAmountKey, issuedAmount), IntegerEntry(stakersAmountPaidTotalKey, 0), IntegerEntry(stakersAmountLeftKey, fraction(MULT14, PLAYERSHARE, MULT6)), BinaryEntry(wlgAssetIdKey, assetId), StringEntry(keyRestAddress(), restAddr), StringEntry(marketingAddrKey, marketingAddr), StringEntry(teamAddrKey, teamAddr), StringEntry(profitAddrKey, profitAddr)] | |
304 | + | } | |
305 | + | ||
306 | + | ||
307 | + | ||
308 | + | @Callable(i) | |
309 | + | func buyWlg (minAmount) = { | |
310 | + | let prologResult = prolog() | |
311 | + | if ((size(i.payments) != 1)) | |
312 | + | then throw("exactly 1 payment must be attached") | |
313 | + | else { | |
314 | + | let pmt = i.payments[0] | |
315 | + | let usdtAmt = pmt.amount | |
316 | + | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment") | |
317 | + | if ((pmtAssetId != usdtAssetId)) | |
318 | + | then throw("USDT payments only!") | |
319 | + | else { | |
320 | + | let caller = i.caller | |
321 | + | let addr = toString(caller) | |
322 | + | let maxUsdt = getSwapLimit(addr) | |
323 | + | if ((usdtAmt > maxUsdt)) | |
324 | + | then throw((("You can spend max " + fixedPoint(maxUsdt, 6)) + " USDT")) | |
325 | + | else { | |
326 | + | let curStats = getWlgStats() | |
327 | + | let curWlgAmount = curStats[idxWlgAmount] | |
328 | + | let oldFundsUsd = (curStats[idxWlgFunds] - usdtAmt) | |
329 | + | let wlgPrice = fraction(oldFundsUsd, MULT8, curWlgAmount) | |
330 | + | let buyPrice = fraction(wlgPrice, 6, 5) | |
331 | + | let wlgAmount = fraction(usdtAmt, MULT8, buyPrice) | |
332 | + | if ((minAmount > wlgAmount)) | |
333 | + | then throw("Price changed during operation, please try again") | |
334 | + | else { | |
335 | + | let profitAmount = (usdtAmt / 6) | |
336 | + | let deltaFunds = (usdtAmt - profitAmount) | |
337 | + | let reissued = fraction(curWlgAmount, deltaFunds, oldFundsUsd) | |
338 | + | $Tuple2([Reissue(wlgAssetId, reissued, true), IntegerEntry(wlgIssuedAmountKey, (curWlgAmount + reissued)), IntegerEntry(keyLastArbTimeByUser(addr), lastBlock.timestamp), ScriptTransfer(addressFromStringValue(value(getString(profitAddrKey))), profitAmount, usdtAssetId), ScriptTransfer(caller, wlgAmount, wlgAssetId)], prologResult) | |
339 | + | } | |
340 | + | } | |
341 | + | } | |
342 | + | } | |
343 | + | } | |
344 | + | ||
345 | + | ||
346 | + | ||
347 | + | @Callable(i) | |
348 | + | func sellWlg (minAmount) = { | |
349 | + | let prologResult = prolog() | |
350 | + | if ((size(i.payments) != 1)) | |
351 | + | then throw("exactly 1 payment must be attached") | |
352 | + | else { | |
353 | + | let pmt = i.payments[0] | |
354 | + | let wlgAmt = pmt.amount | |
355 | + | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment") | |
356 | + | if ((pmtAssetId != wlgAssetId)) | |
357 | + | then throw("WLGOLD payments only!") | |
358 | + | else { | |
359 | + | let caller = i.caller | |
360 | + | let addr = toString(caller) | |
361 | + | let maxUsdt = getSwapLimit(addr) | |
362 | + | let curStats = getWlgStats() | |
363 | + | let curWlgAmount = curStats[idxWlgAmount] | |
364 | + | let sellPrice = fraction(curStats[idxWlgPrice], 4, 5) | |
365 | + | let usdtAmt = fraction(wlgAmt, sellPrice, MULT8) | |
366 | + | if ((usdtAmt > maxUsdt)) | |
367 | + | then throw((("You can get max " + fixedPoint(maxUsdt, 6)) + " USDT")) | |
368 | + | else if ((minAmount > usdtAmt)) | |
369 | + | then throw("Price changed during operation, please try again") | |
370 | + | else { | |
371 | + | let profitAmount = (usdtAmt / 4) | |
372 | + | let burned = fraction((usdtAmt + profitAmount), curWlgAmount, curStats[idxWlgFunds]) | |
373 | + | $Tuple2([Burn(wlgAssetId, burned), IntegerEntry(wlgIssuedAmountKey, (curWlgAmount - burned)), IntegerEntry(keyLastArbTimeByUser(addr), lastBlock.timestamp), ScriptTransfer(addressFromStringValue(value(getString(profitAddrKey))), profitAmount, usdtAssetId), ScriptTransfer(caller, usdtAmt, usdtAssetId)], prologResult) | |
374 | + | } | |
375 | + | } | |
376 | + | } | |
377 | + | } | |
378 | + | ||
379 | + | ||
380 | + | ||
381 | + | @Callable(i) | |
382 | + | func claim () = { | |
383 | + | let prologResult = prolog() | |
384 | + | let actions = claimInternal(i.caller)._1 | |
385 | + | $Tuple2(actions, prologResult) | |
362 | 386 | } | |
363 | 387 | ||
364 | 388 | ||
365 | 389 | ||
366 | 390 | @Callable(i) | |
367 | 391 | func onStakeLand (addr) = if ((i.caller != stakingContract)) | |
368 | 392 | then throw("Permission denied") | |
369 | - | else | |
393 | + | else claimInternal(addressFromStringValue(addr)) | |
370 | 394 | ||
371 | 395 | ||
372 | 396 | ||
373 | 397 | @Callable(i) | |
374 | 398 | func onUnstakeLand (addr) = if ((i.caller != stakingContract)) | |
375 | 399 | then throw("Permission denied") | |
376 | - | else | |
400 | + | else claimInternal(addressFromStringValue(addr)) | |
377 | 401 | ||
378 | 402 |
github/deemru/w8io/026f985 64.17 ms ◑