tx · CyTgVDAzhF9f1SfbEcttXUVfn6c4BnekdPZh161sFzW1 3N7HtrKeFFLz5oy6PfGv1Lg3GwPk4gCPdGy: -0.01500000 Waves 2023.08.06 20:22 [2699023] smart account 3N7HtrKeFFLz5oy6PfGv1Lg3GwPk4gCPdGy > SELF 0.00000000 Waves
{ "type": 13, "id": "CyTgVDAzhF9f1SfbEcttXUVfn6c4BnekdPZh161sFzW1", "fee": 1500000, "feeAssetId": null, "timestamp": 1691342694088, "version": 2, "chainId": 84, "sender": "3N7HtrKeFFLz5oy6PfGv1Lg3GwPk4gCPdGy", "senderPublicKey": "FsR18761ZAsUqsTd7TK3XmR6bhihs1UXVmpHYxz5JzQ1", "proofs": [ "2tEG9Fr9SX2pM1vqmHzMaJpetS9gkCX2GgNXXgAH96BqBCyA73u3bdYd5PqJdtAMgQWSoynEFR8BDP4RpW7YJHMo" ], "script": "base64:BgIbCAISBgoECAgICBIDCgEBEgMKAQESABIDCgEIWAACTTYAwIQ9AAJNOACAwtcvAAhNSUxMSU9ONgCAgOmDsd4WAA5NQVJLRVRJTkdTSEFSRQCgjQYACVRFQU1TSEFSRQDAmgwADUFDVElWSVRZU0hBUkUAoI0GAAtQTEFZRVJTSEFSRQCAtRgACllFQVJNSUxMSVMAgIbrx3UACUNIRUNLVElNRQCAyeCrsAEAA0RBWQCAuJkpABBtYXJrZXRpbmdBZGRyS2V5Ag1tYXJrZXRpbmdBZGRyAAt0ZWFtQWRkcktleQIIdGVhbUFkZHIAFGxhc3RNYXJrZXRpbmdUaW1lS2V5AhlsYXN0Q2xhaW1lZFRpbWVfbWFya2V0aW5nABZtYXJrZXRpbmdBbW91bnRMZWZ0S2V5AhNtYXJrZXRpbmdBbW91bnRMZWZ0AA9sYXN0VGVhbVRpbWVLZXkCFGxhc3RDbGFpbWVkVGltZV90ZWFtABF0ZWFtQW1vdW50TGVmdEtleQIOdGVhbUFtb3VudExlZnQAFWxhc3RBY3Rpdml0aWVzVGltZUtleQIabGFzdENsYWltZ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HMAAAkAAgECFE5vIHBheW1lbnRzIHJlcXVpcmVkBAdhY3Rpb25zCAkBDWNsYWltSW50ZXJuYWwBCQClCAEIBQFpBmNhbGxlcgJfMQkAlAoCBQdhY3Rpb25zBQxwcm9sb2dSZXN1bHQBaQESb25TdGFrZVVuc3Rha2VMYW5kAQRhZGRyAwkBAiE9AggFAWkGY2FsbGVyBQ9zdGFraW5nQ29udHJhY3QJAAIBAhFQZXJtaXNzaW9uIGRlbmllZAkBDWNsYWltSW50ZXJuYWwBBQRhZGRyAI1hySM=", "height": 2699023, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GtEuLs37Jn9PsBnEw44251korqSR7EFyYMXFz332XE29 Next: AZpenSdpDEr3T6NYRLJeAx6biDs47JvLuB2kCBBssEHQ Diff:
Old | New | Differences | |
---|---|---|---|
159 | 159 | } | |
160 | 160 | ||
161 | 161 | ||
162 | - | let KSALLOWWLGOLD = true | |
163 | - | ||
164 | 162 | let chain = take(drop(this.bytes, 1), 1) | |
165 | 163 | ||
166 | 164 | let usdtAssetId = match chain { | |
319 | 317 | } | |
320 | 318 | ||
321 | 319 | ||
322 | - | func claimInternal (addr) = if (!(KSALLOWWLGOLD)) | |
323 | - | then $Tuple2(nil, 0) | |
324 | - | else { | |
325 | - | let caller = addressFromStringValue(addr) | |
326 | - | let curStats = getWlgStats(addr, [restContract, stakingContract, economyContract, govContract, wlgContract, puzzlePoolContract, investFundContract], usdtAssetId, 0) | |
327 | - | let now = lastBlock.timestamp | |
328 | - | let issueTime = curStats[idxWlgIssueTime] | |
329 | - | let marketingAmountLeft = curStats[idxWlgMarketingAmLeft] | |
330 | - | let marketingAmount = curStats[idxWlgMarketingAmAvailNow] | |
331 | - | let teamAmountLeft = curStats[idxWlgTeamAmLeft] | |
332 | - | let teamAmount = curStats[idxWlgTeamAmAvailNow] | |
333 | - | let actAmountLeft = curStats[idxWlgActAmLeft] | |
334 | - | let actAmount = curStats[idxWlgActAmAvailNow] | |
335 | - | if (((now - issueTime) > CHECKTIME)) | |
336 | - | then throw("Please modify contract for next 1.5 years, according to stats") | |
337 | - | else { | |
338 | - | let userAmount = curStats[idxWlgUserAmAvailNow] | |
339 | - | let userKey = keyStakersAmountPaidUser(addr) | |
340 | - | $Tuple2([ScriptTransfer(addressFromStringValue(value(getString(marketingAddrKey))), marketingAmount, wlgAssetId), ScriptTransfer(addressFromStringValue(value(getString(teamAddrKey))), 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, (curStats[idxWlgAmLeftTotal] - userAmount)), IntegerEntry(marketingAmountLeftKey, (marketingAmountLeft - marketingAmount)), IntegerEntry(lastMarketingTimeKey, now), IntegerEntry(teamAmountLeftKey, (teamAmountLeft - teamAmount)), IntegerEntry(lastTeamTimeKey, now), IntegerEntry(actAmountLeftKey, (actAmountLeft - actAmount)), IntegerEntry(lastActivitiesTimeKey, now), IntegerEntry(keyLastClaimedTimeByUser(addr), now)], userAmount) | |
341 | - | } | |
342 | - | } | |
320 | + | func claimInternal (addr) = { | |
321 | + | let caller = addressFromStringValue(addr) | |
322 | + | let curStats = getWlgStats(addr, [restContract, stakingContract, economyContract, govContract, wlgContract, puzzlePoolContract, investFundContract], usdtAssetId, 0) | |
323 | + | let now = lastBlock.timestamp | |
324 | + | let issueTime = curStats[idxWlgIssueTime] | |
325 | + | let marketingAmountLeft = curStats[idxWlgMarketingAmLeft] | |
326 | + | let marketingAmount = curStats[idxWlgMarketingAmAvailNow] | |
327 | + | let teamAmountLeft = curStats[idxWlgTeamAmLeft] | |
328 | + | let teamAmount = curStats[idxWlgTeamAmAvailNow] | |
329 | + | let actAmountLeft = curStats[idxWlgActAmLeft] | |
330 | + | let actAmount = curStats[idxWlgActAmAvailNow] | |
331 | + | if (((now - issueTime) > CHECKTIME)) | |
332 | + | then throw("Please modify contract for next 1.5 years, according to stats") | |
333 | + | else { | |
334 | + | let userAmount = curStats[idxWlgUserAmAvailNow] | |
335 | + | let userKey = keyStakersAmountPaidUser(addr) | |
336 | + | $Tuple2([ScriptTransfer(addressFromStringValue(value(getString(marketingAddrKey))), marketingAmount, wlgAssetId), ScriptTransfer(addressFromStringValue(value(getString(teamAddrKey))), 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, (curStats[idxWlgAmLeftTotal] - userAmount)), IntegerEntry(marketingAmountLeftKey, (marketingAmountLeft - marketingAmount)), IntegerEntry(lastMarketingTimeKey, now), IntegerEntry(teamAmountLeftKey, (teamAmountLeft - teamAmount)), IntegerEntry(lastTeamTimeKey, now), IntegerEntry(actAmountLeftKey, (actAmountLeft - actAmount)), IntegerEntry(lastActivitiesTimeKey, now), IntegerEntry(keyLastClaimedTimeByUser(addr), now)], userAmount) | |
337 | + | } | |
338 | + | } | |
343 | 339 | ||
344 | 340 | ||
345 | 341 | @Callable(i) | |
357 | 353 | ||
358 | 354 | ||
359 | 355 | @Callable(i) | |
360 | - | func buyWlg (minAmount) = if (!(KSALLOWWLGOLD)) | |
361 | - | then $Tuple2(nil, 0) | |
362 | - | else { | |
363 | - | let prologResult = prolog() | |
364 | - | if ((size(i.payments) != 1)) | |
365 | - | then throw("exactly 1 payment must be attached") | |
366 | - | else { | |
367 | - | let pmt = i.payments[0] | |
368 | - | let usdtAmt = pmt.amount | |
369 | - | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "USDT payments only!") | |
370 | - | if ((pmtAssetId != usdtAssetId)) | |
371 | - | then throw("USDT payments only!") | |
372 | - | else { | |
373 | - | let caller = i.caller | |
374 | - | let addr = toString(caller) | |
375 | - | let maxUsdt = getSwapLimit(addr) | |
376 | - | if ((usdtAmt > maxUsdt)) | |
377 | - | then throw((("You can spend max " + fixedPoint(maxUsdt, 6)) + " USDT")) | |
378 | - | else if ((MINSHOPPAYMENT > usdtAmt)) | |
379 | - | then throw((("You can trade min " + fixedPoint(MINSHOPPAYMENT, 6)) + " USDT")) | |
380 | - | else { | |
381 | - | let curStats = getWlgStats("", [restContract, stakingContract, economyContract, govContract, wlgContract, puzzlePoolContract, investFundContract], usdtAssetId, usdtAmt) | |
382 | - | let curWlgAmount = curStats[idxWlgAmount] | |
383 | - | let fundsUsd = curStats[idxWlgFunds] | |
384 | - | let wlgPrice = fraction(fundsUsd, MULT8, curWlgAmount) | |
385 | - | let buyPrice = fraction(wlgPrice, 6, 5) | |
386 | - | let wlgAmount = fraction(usdtAmt, MULT8, buyPrice) | |
387 | - | if ((minAmount > wlgAmount)) | |
388 | - | then throw("Price changed during operation, please try again") | |
389 | - | else { | |
390 | - | let profitAmount = (usdtAmt / 6) | |
391 | - | let deltaFunds = (usdtAmt - profitAmount) | |
392 | - | let reissued = fraction(curWlgAmount, deltaFunds, fundsUsd) | |
393 | - | $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) | |
394 | - | } | |
395 | - | } | |
396 | - | } | |
397 | - | } | |
398 | - | } | |
356 | + | func buyWlg (minAmount) = { | |
357 | + | let prologResult = prolog() | |
358 | + | if ((size(i.payments) != 1)) | |
359 | + | then throw("exactly 1 payment must be attached") | |
360 | + | else { | |
361 | + | let pmt = i.payments[0] | |
362 | + | let usdtAmt = pmt.amount | |
363 | + | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "USDT payments only!") | |
364 | + | if ((pmtAssetId != usdtAssetId)) | |
365 | + | then throw("USDT payments only!") | |
366 | + | else { | |
367 | + | let caller = i.caller | |
368 | + | let addr = toString(caller) | |
369 | + | let maxUsdt = getSwapLimit(addr) | |
370 | + | if ((usdtAmt > maxUsdt)) | |
371 | + | then throw((("You can spend max " + fixedPoint(maxUsdt, 6)) + " USDT")) | |
372 | + | else if ((MINSHOPPAYMENT > usdtAmt)) | |
373 | + | then throw((("You can trade min " + fixedPoint(MINSHOPPAYMENT, 6)) + " USDT")) | |
374 | + | else { | |
375 | + | let curStats = getWlgStats("", [restContract, stakingContract, economyContract, govContract, wlgContract, puzzlePoolContract, investFundContract], usdtAssetId, usdtAmt) | |
376 | + | let curWlgAmount = curStats[idxWlgAmount] | |
377 | + | let fundsUsd = curStats[idxWlgFunds] | |
378 | + | let wlgPrice = fraction(fundsUsd, MULT8, curWlgAmount) | |
379 | + | let buyPrice = fraction(wlgPrice, 6, 5) | |
380 | + | let wlgAmount = fraction(usdtAmt, MULT8, buyPrice) | |
381 | + | if ((minAmount > wlgAmount)) | |
382 | + | then throw("Price changed during operation, please try again") | |
383 | + | else { | |
384 | + | let profitAmount = (usdtAmt / 6) | |
385 | + | let deltaFunds = (usdtAmt - profitAmount) | |
386 | + | let reissued = fraction(curWlgAmount, deltaFunds, fundsUsd) | |
387 | + | $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) | |
388 | + | } | |
389 | + | } | |
390 | + | } | |
391 | + | } | |
392 | + | } | |
399 | 393 | ||
400 | 394 | ||
401 | 395 | ||
402 | 396 | @Callable(i) | |
403 | - | func sellWlg (minAmount) = if (!(KSALLOWWLGOLD)) | |
404 | - | then $Tuple2(nil, 0) | |
405 | - | else { | |
406 | - | let prologResult = prolog() | |
407 | - | if ((size(i.payments) != 1)) | |
408 | - | then throw("exactly 1 payment must be attached") | |
409 | - | else { | |
410 | - | let pmt = i.payments[0] | |
411 | - | let wlgAmt = pmt.amount | |
412 | - | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WLGOLD payments only!") | |
413 | - | if ((pmtAssetId != wlgAssetId)) | |
414 | - | then throw("WLGOLD payments only!") | |
415 | - | else { | |
416 | - | let caller = i.caller | |
417 | - | let addr = toString(caller) | |
418 | - | let maxUsdt = getSwapLimit(addr) | |
419 | - | let curStats = getWlgStats("", [restContract, stakingContract, economyContract, govContract, wlgContract, puzzlePoolContract, investFundContract], usdtAssetId, 0) | |
420 | - | let curWlgAmount = curStats[idxWlgAmount] | |
421 | - | let sellPrice = fraction(curStats[idxWlgPrice], 4, 5) | |
422 | - | let usdtAmt = fraction(wlgAmt, sellPrice, MULT8) | |
423 | - | if ((usdtAmt > maxUsdt)) | |
424 | - | then throw((("You can get max " + fixedPoint(maxUsdt, 6)) + " USDT")) | |
425 | - | else if ((MINSHOPPAYMENT > usdtAmt)) | |
426 | - | then throw((("You can trade min " + fixedPoint(MINSHOPPAYMENT, 6)) + " USDT")) | |
427 | - | else if ((minAmount > usdtAmt)) | |
428 | - | then throw("Price changed during operation, please try again") | |
429 | - | else { | |
430 | - | let profitAmount = (usdtAmt / 4) | |
431 | - | let burned = fraction((usdtAmt + profitAmount), curWlgAmount, curStats[idxWlgFunds]) | |
432 | - | $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) | |
433 | - | } | |
434 | - | } | |
435 | - | } | |
436 | - | } | |
397 | + | func sellWlg (minAmount) = { | |
398 | + | let prologResult = prolog() | |
399 | + | if ((size(i.payments) != 1)) | |
400 | + | then throw("exactly 1 payment must be attached") | |
401 | + | else { | |
402 | + | let pmt = i.payments[0] | |
403 | + | let wlgAmt = pmt.amount | |
404 | + | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WLGOLD payments only!") | |
405 | + | if ((pmtAssetId != wlgAssetId)) | |
406 | + | then throw("WLGOLD payments only!") | |
407 | + | else { | |
408 | + | let caller = i.caller | |
409 | + | let addr = toString(caller) | |
410 | + | let maxUsdt = getSwapLimit(addr) | |
411 | + | let curStats = getWlgStats("", [restContract, stakingContract, economyContract, govContract, wlgContract, puzzlePoolContract, investFundContract], usdtAssetId, 0) | |
412 | + | let curWlgAmount = curStats[idxWlgAmount] | |
413 | + | let sellPrice = fraction(curStats[idxWlgPrice], 4, 5) | |
414 | + | let usdtAmt = fraction(wlgAmt, sellPrice, MULT8) | |
415 | + | if ((usdtAmt > maxUsdt)) | |
416 | + | then throw((("You can get max " + fixedPoint(maxUsdt, 6)) + " USDT")) | |
417 | + | else if ((MINSHOPPAYMENT > usdtAmt)) | |
418 | + | then throw((("You can trade min " + fixedPoint(MINSHOPPAYMENT, 6)) + " USDT")) | |
419 | + | else if ((minAmount > usdtAmt)) | |
420 | + | then throw("Price changed during operation, please try again") | |
421 | + | else { | |
422 | + | let profitAmount = (usdtAmt / 4) | |
423 | + | let burned = fraction((usdtAmt + profitAmount), curWlgAmount, curStats[idxWlgFunds]) | |
424 | + | $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) | |
425 | + | } | |
426 | + | } | |
427 | + | } | |
428 | + | } | |
437 | 429 | ||
438 | 430 | ||
439 | 431 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let M6 = 1000000 | |
5 | 5 | ||
6 | 6 | let M8 = 100000000 | |
7 | 7 | ||
8 | 8 | let MILLION6 = 100000000000000 | |
9 | 9 | ||
10 | 10 | let MARKETINGSHARE = 100000 | |
11 | 11 | ||
12 | 12 | let TEAMSHARE = 200000 | |
13 | 13 | ||
14 | 14 | let ACTIVITYSHARE = 100000 | |
15 | 15 | ||
16 | 16 | let PLAYERSHARE = 400000 | |
17 | 17 | ||
18 | 18 | let YEARMILLIS = 31557600000 | |
19 | 19 | ||
20 | 20 | let CHECKTIME = 47336400000 | |
21 | 21 | ||
22 | 22 | let DAY = 86400000 | |
23 | 23 | ||
24 | 24 | let marketingAddrKey = "marketingAddr" | |
25 | 25 | ||
26 | 26 | let teamAddrKey = "teamAddr" | |
27 | 27 | ||
28 | 28 | let lastMarketingTimeKey = "lastClaimedTime_marketing" | |
29 | 29 | ||
30 | 30 | let marketingAmountLeftKey = "marketingAmountLeft" | |
31 | 31 | ||
32 | 32 | let lastTeamTimeKey = "lastClaimedTime_team" | |
33 | 33 | ||
34 | 34 | let teamAmountLeftKey = "teamAmountLeft" | |
35 | 35 | ||
36 | 36 | let lastActivitiesTimeKey = "lastClaimedTime_activities" | |
37 | 37 | ||
38 | 38 | let actAmountLeftKey = "activitiesAmountLeft" | |
39 | 39 | ||
40 | 40 | let stakersAmountLeftKey = "stakersAmountLeft" | |
41 | 41 | ||
42 | 42 | func keyLastClaimedTimeByUser (addr) = ("lastClaimedTimeUser_" + addr) | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func keyLastArbTimeByUser (addr) = ("lastArbTimeUser_" + addr) | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func distributionByPeriod (period) = fraction(MILLION6, (PLAYERSHARE * (period + 1)), (6 * M6)) | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | let wlgIssueTimeKey = "wlg_issueTime" | |
52 | 52 | ||
53 | 53 | let wlgIssuedAmountKey = "wlg_issuedAmount" | |
54 | 54 | ||
55 | 55 | let zbIssuedAmountKey = "zbill_issuedAmount" | |
56 | 56 | ||
57 | 57 | let idxWlgAmount = 0 | |
58 | 58 | ||
59 | 59 | let idxWlgPrice = 1 | |
60 | 60 | ||
61 | 61 | let idxWlgFunds = 2 | |
62 | 62 | ||
63 | 63 | let idxWlgIssueTime = 7 | |
64 | 64 | ||
65 | 65 | let idxWlgMarketingAmLeft = 10 | |
66 | 66 | ||
67 | 67 | let idxWlgMarketingAmAvailNow = 11 | |
68 | 68 | ||
69 | 69 | let idxWlgTeamAmLeft = 14 | |
70 | 70 | ||
71 | 71 | let idxWlgTeamAmAvailNow = 15 | |
72 | 72 | ||
73 | 73 | let idxWlgActAmLeft = 18 | |
74 | 74 | ||
75 | 75 | let idxWlgActAmAvailNow = 19 | |
76 | 76 | ||
77 | 77 | let idxWlgAmLeftTotal = 22 | |
78 | 78 | ||
79 | 79 | let idxWlgUserAmAvailNow = 25 | |
80 | 80 | ||
81 | 81 | let dappRest = 0 | |
82 | 82 | ||
83 | 83 | let dappStaking = 1 | |
84 | 84 | ||
85 | 85 | let dappEconomy = 2 | |
86 | 86 | ||
87 | 87 | let dappWlg = 4 | |
88 | 88 | ||
89 | 89 | let dappPuzzle = 5 | |
90 | 90 | ||
91 | 91 | let dappInvestFund = 6 | |
92 | 92 | ||
93 | 93 | func getPieces (userAddrStrOrEmpty,stakingContract) = { | |
94 | 94 | let props = split(valueOrElse(getString(stakingContract, "resTypesProportions"), "0_0_0_0_0_0"), "_") | |
95 | 95 | func adder (acc,item) = (acc + parseIntValue(item)) | |
96 | 96 | ||
97 | 97 | let totalPower = { | |
98 | 98 | let $l = props | |
99 | 99 | let $s = size($l) | |
100 | 100 | let $acc0 = 0 | |
101 | 101 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
102 | 102 | then $a | |
103 | 103 | else adder($a, $l[$i]) | |
104 | 104 | ||
105 | 105 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
106 | 106 | then $a | |
107 | 107 | else throw("List size exceeds 6") | |
108 | 108 | ||
109 | 109 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
110 | 110 | } | |
111 | 111 | let usersPower = valueOrElse(getInteger(stakingContract, ("stakedPiecesByOwner_" + userAddrStrOrEmpty)), 0) | |
112 | 112 | [totalPower, usersPower] | |
113 | 113 | } | |
114 | 114 | ||
115 | 115 | ||
116 | 116 | func getWlgStats (userAddrOpt,contracts,usdtId,usdtBalanceCorrection) = { | |
117 | 117 | let issuedAmount = valueOrErrorMessage(getInteger(contracts[dappWlg], wlgIssuedAmountKey), "WLGOLD is not issued yet") | |
118 | 118 | let economyUsd = assetBalance(contracts[dappEconomy], usdtId) | |
119 | 119 | let restUsd = assetBalance(contracts[dappRest], usdtId) | |
120 | 120 | let wlgUsd = (assetBalance(contracts[dappWlg], usdtId) - usdtBalanceCorrection) | |
121 | 121 | let puzzleUsd = assetBalance(contracts[dappPuzzle], usdtId) | |
122 | 122 | let investFundContract = contracts[dappInvestFund] | |
123 | 123 | let investFundTotal = (assetBalance(investFundContract, usdtId) + valueOrElse(getInteger(investFundContract, zbIssuedAmountKey), 0)) | |
124 | 124 | let totalFundsUsd = ((economyUsd + wlgUsd) + investFundTotal) | |
125 | 125 | let wlgId = valueOrErrorMessage(getBinary(contracts[dappWlg], "wlg_assetId"), "Not initialized yet") | |
126 | 126 | let now = lastBlock.timestamp | |
127 | 127 | let issueTime = valueOrErrorMessage(getInteger(contracts[dappWlg], wlgIssueTimeKey), "Not initialized") | |
128 | 128 | let marketingTotal = fraction(MILLION6, MARKETINGSHARE, M6) | |
129 | 129 | let marketingAmountLeft = valueOrElse(getInteger(contracts[dappWlg], marketingAmountLeftKey), marketingTotal) | |
130 | 130 | let lastMarketingTime = valueOrElse(getInteger(contracts[dappWlg], lastMarketingTimeKey), issueTime) | |
131 | 131 | let marketingAddr = addressFromStringValue(value(getString(contracts[dappWlg], marketingAddrKey))) | |
132 | 132 | let marketingAmountAvailableNow = min([fraction(marketingTotal, (now - lastMarketingTime), YEARMILLIS), marketingAmountLeft]) | |
133 | 133 | let marketingWlgold = assetBalance(marketingAddr, wlgId) | |
134 | 134 | let teamTotal = fraction(MILLION6, TEAMSHARE, M6) | |
135 | 135 | let teamAmountLeft = valueOrElse(getInteger(contracts[dappWlg], teamAmountLeftKey), teamTotal) | |
136 | 136 | let lastTeamTime = valueOrElse(getInteger(contracts[dappWlg], lastTeamTimeKey), issueTime) | |
137 | 137 | let teamAddr = addressFromStringValue(value(getString(contracts[dappWlg], teamAddrKey))) | |
138 | 138 | let teamAmountAvailableNow = min([fraction(teamTotal, (now - lastTeamTime), (3 * YEARMILLIS)), teamAmountLeft]) | |
139 | 139 | let teamWlgold = assetBalance(teamAddr, wlgId) | |
140 | 140 | let actTotal = fraction(MILLION6, ACTIVITYSHARE, M6) | |
141 | 141 | let actAmountLeft = valueOrElse(getInteger(contracts[dappWlg], actAmountLeftKey), actTotal) | |
142 | 142 | let lastActivitiesTime = valueOrElse(getInteger(contracts[dappWlg], lastActivitiesTimeKey), issueTime) | |
143 | 143 | let actAmountAvailableNow = min([fraction(actTotal, (now - lastActivitiesTime), (3 * YEARMILLIS)), actAmountLeft]) | |
144 | 144 | let actWlgold = assetBalance(contracts[dappRest], wlgId) | |
145 | 145 | let lastUserTime = valueOrElse(getInteger(contracts[dappWlg], keyLastClaimedTimeByUser(userAddrOpt)), issueTime) | |
146 | 146 | let lastUserPeriod = ((lastUserTime - issueTime) / YEARMILLIS) | |
147 | 147 | let nowLimited = min([now, (issueTime + (3 * YEARMILLIS))]) | |
148 | 148 | let curPeriod = min([((now - issueTime) / YEARMILLIS), 2]) | |
149 | 149 | let eff = getPieces(userAddrOpt, contracts[dappStaking]) | |
150 | 150 | let curPeriodDistribution = distributionByPeriod(curPeriod) | |
151 | 151 | let userAmount = fraction(if ((lastUserPeriod == curPeriod)) | |
152 | 152 | then fraction(curPeriodDistribution, (nowLimited - lastUserTime), YEARMILLIS) | |
153 | 153 | else if ((lastUserPeriod == (curPeriod - 1))) | |
154 | 154 | then (fraction(distributionByPeriod((curPeriod - 1)), ((issueTime + (YEARMILLIS * curPeriod)) - lastUserTime), YEARMILLIS) + fraction(curPeriodDistribution, (nowLimited - (issueTime + (YEARMILLIS * curPeriod))), YEARMILLIS)) | |
155 | 155 | else ((fraction(distributionByPeriod((curPeriod - 2)), ((issueTime + (YEARMILLIS * (curPeriod - 1))) - lastUserTime), YEARMILLIS) + distributionByPeriod((curPeriod - 1))) + fraction(curPeriodDistribution, (nowLimited - (issueTime + (YEARMILLIS * curPeriod))), YEARMILLIS)), eff[1], eff[0]) | |
156 | 156 | let sLandDailyAmount = fraction(fraction(curPeriodDistribution, DAY, YEARMILLIS), 25, eff[0]) | |
157 | 157 | let amountLeftTotal = valueOrElse(getInteger(contracts[dappWlg], stakersAmountLeftKey), 0) | |
158 | 158 | [issuedAmount, fraction(totalFundsUsd, M8, issuedAmount), totalFundsUsd, economyUsd, restUsd, wlgUsd, puzzleUsd, issueTime, lastMarketingTime, marketingTotal, marketingAmountLeft, marketingAmountAvailableNow, marketingWlgold, teamTotal, teamAmountLeft, teamAmountAvailableNow, teamWlgold, actTotal, actAmountLeft, actAmountAvailableNow, actWlgold, curPeriod, amountLeftTotal, curPeriodDistribution, lastUserTime, userAmount, sLandDailyAmount, investFundTotal] | |
159 | 159 | } | |
160 | 160 | ||
161 | 161 | ||
162 | - | let KSALLOWWLGOLD = true | |
163 | - | ||
164 | 162 | let chain = take(drop(this.bytes, 1), 1) | |
165 | 163 | ||
166 | 164 | let usdtAssetId = match chain { | |
167 | 165 | case _ => | |
168 | 166 | if ((base58'2W' == $match0)) | |
169 | 167 | then base58'9wc3LXNA4TEBsXyKtoLE9mrbDD7WMHXvXrCjZvabLAsi' | |
170 | 168 | else if ((base58'2T' == $match0)) | |
171 | 169 | then base58'6mWwf9mZBjVgkC54idpyaZLQfAosD914wT8fGf2iiY63' | |
172 | 170 | else throw("Unknown chain") | |
173 | 171 | } | |
174 | 172 | ||
175 | 173 | let defaultRestAddressStr = match chain { | |
176 | 174 | case _ => | |
177 | 175 | if ((base58'2W' == $match0)) | |
178 | 176 | then "3PQCuvFbvh4LkPUnrnU1z3jnbA1p9m3WNhv" | |
179 | 177 | else if ((base58'2T' == $match0)) | |
180 | 178 | then "3MumkGGztCKAXpWDqxkddofqXSUbqQkvSJy" | |
181 | 179 | else throw("Unknown chain") | |
182 | 180 | } | |
183 | 181 | ||
184 | 182 | let arbitrageDelay = match chain { | |
185 | 183 | case _ => | |
186 | 184 | if ((base58'2W' == $match0)) | |
187 | 185 | then 600000 | |
188 | 186 | else if ((base58'2T' == $match0)) | |
189 | 187 | then 60000 | |
190 | 188 | else throw("Unknown chain") | |
191 | 189 | } | |
192 | 190 | ||
193 | 191 | let SEP = "__" | |
194 | 192 | ||
195 | 193 | let MULT6 = 1000000 | |
196 | 194 | ||
197 | 195 | let MULT8 = 100000000 | |
198 | 196 | ||
199 | 197 | let MINSHOPPAYMENT = 100000 | |
200 | 198 | ||
201 | 199 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
202 | 200 | ||
203 | 201 | ||
204 | 202 | let IdxCfgStakingDapp = 1 | |
205 | 203 | ||
206 | 204 | let IdxCfgEconomyDapp = 2 | |
207 | 205 | ||
208 | 206 | let IdxCfgGovernanceDapp = 3 | |
209 | 207 | ||
210 | 208 | let IdxCfgWlgDapp = 4 | |
211 | 209 | ||
212 | 210 | let IdxCfgPuzzlePoolDapp = 5 | |
213 | 211 | ||
214 | 212 | let IdxCfgInvestFundDapp = 6 | |
215 | 213 | ||
216 | 214 | func keyRestCfg () = "%s__restConfig" | |
217 | 215 | ||
218 | 216 | ||
219 | 217 | func keyRestAddress () = "%s__restAddr" | |
220 | 218 | ||
221 | 219 | ||
222 | 220 | func readRestCfgOrFail (rest) = split_4C(getStringOrFail(rest, keyRestCfg()), SEP) | |
223 | 221 | ||
224 | 222 | ||
225 | 223 | func getContractAddressOrFail (restCfg,idx) = valueOrErrorMessage(addressFromString(restCfg[idx]), ("Rest cfg doesn't contain address at index " + toString(idx))) | |
226 | 224 | ||
227 | 225 | ||
228 | 226 | let restContract = addressFromStringValue(valueOrElse(getString(this, keyRestAddress()), defaultRestAddressStr)) | |
229 | 227 | ||
230 | 228 | let restCfg = readRestCfgOrFail(restContract) | |
231 | 229 | ||
232 | 230 | let stakingContract = getContractAddressOrFail(restCfg, IdxCfgStakingDapp) | |
233 | 231 | ||
234 | 232 | let economyContract = getContractAddressOrFail(restCfg, IdxCfgEconomyDapp) | |
235 | 233 | ||
236 | 234 | let govContract = getContractAddressOrFail(restCfg, IdxCfgGovernanceDapp) | |
237 | 235 | ||
238 | 236 | let wlgContract = getContractAddressOrFail(restCfg, IdxCfgWlgDapp) | |
239 | 237 | ||
240 | 238 | let puzzlePoolContract = getContractAddressOrFail(restCfg, IdxCfgPuzzlePoolDapp) | |
241 | 239 | ||
242 | 240 | let investFundContract = getContractAddressOrFail(restCfg, IdxCfgInvestFundDapp) | |
243 | 241 | ||
244 | 242 | let wlgAssetIdKey = "wlg_assetId" | |
245 | 243 | ||
246 | 244 | let wlgAssetId = valueOrErrorMessage(getBinary(wlgContract, wlgAssetIdKey), "Not initialized yet") | |
247 | 245 | ||
248 | 246 | let IdxEffUser = 1 | |
249 | 247 | ||
250 | 248 | func keyResProportions () = "resTypesProportions" | |
251 | 249 | ||
252 | 250 | ||
253 | 251 | func keyStakedPiecesByOwner (ownerAddr) = ("stakedPiecesByOwner_" + ownerAddr) | |
254 | 252 | ||
255 | 253 | ||
256 | 254 | func asInt (v) = match v { | |
257 | 255 | case n: Int => | |
258 | 256 | n | |
259 | 257 | case _ => | |
260 | 258 | throw("fail to cast into Int") | |
261 | 259 | } | |
262 | 260 | ||
263 | 261 | ||
264 | 262 | func getVotingPower (userAddrStrOrEmpty) = { | |
265 | 263 | let props = split(valueOrElse(getString(stakingContract, keyResProportions()), "0_0_0_0_0_0"), "_") | |
266 | 264 | func adder (acc,item) = (acc + parseIntValue(item)) | |
267 | 265 | ||
268 | 266 | let totalPower = { | |
269 | 267 | let $l = props | |
270 | 268 | let $s = size($l) | |
271 | 269 | let $acc0 = 0 | |
272 | 270 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
273 | 271 | then $a | |
274 | 272 | else adder($a, $l[$i]) | |
275 | 273 | ||
276 | 274 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
277 | 275 | then $a | |
278 | 276 | else throw("List size exceeds 6") | |
279 | 277 | ||
280 | 278 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
281 | 279 | } | |
282 | 280 | let usersPower = valueOrElse(getInteger(stakingContract, keyStakedPiecesByOwner(userAddrStrOrEmpty)), 0) | |
283 | 281 | [totalPower, usersPower] | |
284 | 282 | } | |
285 | 283 | ||
286 | 284 | ||
287 | 285 | func fixedPoint (val,decimals) = { | |
288 | 286 | let tenPow = pow(10, 0, decimals, 0, 0, DOWN) | |
289 | 287 | let lowPart = toString((val % tenPow)) | |
290 | 288 | let zeroes = drop(toString(tenPow), (1 + size(lowPart))) | |
291 | 289 | (((toString((val / tenPow)) + ".") + zeroes) + lowPart) | |
292 | 290 | } | |
293 | 291 | ||
294 | 292 | ||
295 | 293 | let A6 = 100000000 | |
296 | 294 | ||
297 | 295 | let B8 = 50000000 | |
298 | 296 | ||
299 | 297 | let profitAddrKey = "profitAddr" | |
300 | 298 | ||
301 | 299 | let stakersAmountPaidTotalKey = "stakersAmountPaidTotal" | |
302 | 300 | ||
303 | 301 | func keyStakersAmountPaidUser (addr) = ("stakersAmountPaidUser_" + addr) | |
304 | 302 | ||
305 | 303 | ||
306 | 304 | func prolog () = asInt(invoke(stakingContract, "saveLastTx", nil, nil)) | |
307 | 305 | ||
308 | 306 | ||
309 | 307 | func getSwapLimit (addr) = { | |
310 | 308 | let lastTime = valueOrElse(getInteger(keyLastArbTimeByUser(addr)), 0) | |
311 | 309 | let now = lastBlock.timestamp | |
312 | 310 | if ((arbitrageDelay > (now - lastTime))) | |
313 | 311 | then throw((("Arbitrages are possible once a " + toString((arbitrageDelay / 60000))) + "min")) | |
314 | 312 | else { | |
315 | 313 | let pieces = getVotingPower(addr)[IdxEffUser] | |
316 | 314 | let pow8 = pow(pieces, 0, B8, 8, 8, CEILING) | |
317 | 315 | fraction(A6, pow8, MULT8) | |
318 | 316 | } | |
319 | 317 | } | |
320 | 318 | ||
321 | 319 | ||
322 | - | func claimInternal (addr) = if (!(KSALLOWWLGOLD)) | |
323 | - | then $Tuple2(nil, 0) | |
324 | - | else { | |
325 | - | let caller = addressFromStringValue(addr) | |
326 | - | let curStats = getWlgStats(addr, [restContract, stakingContract, economyContract, govContract, wlgContract, puzzlePoolContract, investFundContract], usdtAssetId, 0) | |
327 | - | let now = lastBlock.timestamp | |
328 | - | let issueTime = curStats[idxWlgIssueTime] | |
329 | - | let marketingAmountLeft = curStats[idxWlgMarketingAmLeft] | |
330 | - | let marketingAmount = curStats[idxWlgMarketingAmAvailNow] | |
331 | - | let teamAmountLeft = curStats[idxWlgTeamAmLeft] | |
332 | - | let teamAmount = curStats[idxWlgTeamAmAvailNow] | |
333 | - | let actAmountLeft = curStats[idxWlgActAmLeft] | |
334 | - | let actAmount = curStats[idxWlgActAmAvailNow] | |
335 | - | if (((now - issueTime) > CHECKTIME)) | |
336 | - | then throw("Please modify contract for next 1.5 years, according to stats") | |
337 | - | else { | |
338 | - | let userAmount = curStats[idxWlgUserAmAvailNow] | |
339 | - | let userKey = keyStakersAmountPaidUser(addr) | |
340 | - | $Tuple2([ScriptTransfer(addressFromStringValue(value(getString(marketingAddrKey))), marketingAmount, wlgAssetId), ScriptTransfer(addressFromStringValue(value(getString(teamAddrKey))), 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, (curStats[idxWlgAmLeftTotal] - userAmount)), IntegerEntry(marketingAmountLeftKey, (marketingAmountLeft - marketingAmount)), IntegerEntry(lastMarketingTimeKey, now), IntegerEntry(teamAmountLeftKey, (teamAmountLeft - teamAmount)), IntegerEntry(lastTeamTimeKey, now), IntegerEntry(actAmountLeftKey, (actAmountLeft - actAmount)), IntegerEntry(lastActivitiesTimeKey, now), IntegerEntry(keyLastClaimedTimeByUser(addr), now)], userAmount) | |
341 | - | } | |
342 | - | } | |
320 | + | func claimInternal (addr) = { | |
321 | + | let caller = addressFromStringValue(addr) | |
322 | + | let curStats = getWlgStats(addr, [restContract, stakingContract, economyContract, govContract, wlgContract, puzzlePoolContract, investFundContract], usdtAssetId, 0) | |
323 | + | let now = lastBlock.timestamp | |
324 | + | let issueTime = curStats[idxWlgIssueTime] | |
325 | + | let marketingAmountLeft = curStats[idxWlgMarketingAmLeft] | |
326 | + | let marketingAmount = curStats[idxWlgMarketingAmAvailNow] | |
327 | + | let teamAmountLeft = curStats[idxWlgTeamAmLeft] | |
328 | + | let teamAmount = curStats[idxWlgTeamAmAvailNow] | |
329 | + | let actAmountLeft = curStats[idxWlgActAmLeft] | |
330 | + | let actAmount = curStats[idxWlgActAmAvailNow] | |
331 | + | if (((now - issueTime) > CHECKTIME)) | |
332 | + | then throw("Please modify contract for next 1.5 years, according to stats") | |
333 | + | else { | |
334 | + | let userAmount = curStats[idxWlgUserAmAvailNow] | |
335 | + | let userKey = keyStakersAmountPaidUser(addr) | |
336 | + | $Tuple2([ScriptTransfer(addressFromStringValue(value(getString(marketingAddrKey))), marketingAmount, wlgAssetId), ScriptTransfer(addressFromStringValue(value(getString(teamAddrKey))), 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, (curStats[idxWlgAmLeftTotal] - userAmount)), IntegerEntry(marketingAmountLeftKey, (marketingAmountLeft - marketingAmount)), IntegerEntry(lastMarketingTimeKey, now), IntegerEntry(teamAmountLeftKey, (teamAmountLeft - teamAmount)), IntegerEntry(lastTeamTimeKey, now), IntegerEntry(actAmountLeftKey, (actAmountLeft - actAmount)), IntegerEntry(lastActivitiesTimeKey, now), IntegerEntry(keyLastClaimedTimeByUser(addr), now)], userAmount) | |
337 | + | } | |
338 | + | } | |
343 | 339 | ||
344 | 340 | ||
345 | 341 | @Callable(i) | |
346 | 342 | func constructorV1 (restAddr,marketingAddr,teamAddr,profitAddr) = if ((i.caller != this)) | |
347 | 343 | then throw("Permission denied") | |
348 | 344 | else if (isDefined(getBinary(wlgAssetIdKey))) | |
349 | 345 | then throw("Already initialized") | |
350 | 346 | else { | |
351 | 347 | let issuedAmount = MILLION6 | |
352 | 348 | let issue = Issue("WLGOLD", "WavesLands Gold investment token", issuedAmount, 8, true, unit, 0) | |
353 | 349 | let assetId = calculateAssetId(issue) | |
354 | 350 | [issue, IntegerEntry(wlgIssueTimeKey, lastBlock.timestamp), IntegerEntry(wlgIssuedAmountKey, issuedAmount), IntegerEntry(stakersAmountPaidTotalKey, 0), IntegerEntry(stakersAmountLeftKey, fraction(MILLION6, PLAYERSHARE, MULT6)), BinaryEntry(wlgAssetIdKey, assetId), StringEntry(keyRestAddress(), restAddr), StringEntry(marketingAddrKey, marketingAddr), StringEntry(teamAddrKey, teamAddr), StringEntry(profitAddrKey, profitAddr)] | |
355 | 351 | } | |
356 | 352 | ||
357 | 353 | ||
358 | 354 | ||
359 | 355 | @Callable(i) | |
360 | - | func buyWlg (minAmount) = if (!(KSALLOWWLGOLD)) | |
361 | - | then $Tuple2(nil, 0) | |
362 | - | else { | |
363 | - | let prologResult = prolog() | |
364 | - | if ((size(i.payments) != 1)) | |
365 | - | then throw("exactly 1 payment must be attached") | |
366 | - | else { | |
367 | - | let pmt = i.payments[0] | |
368 | - | let usdtAmt = pmt.amount | |
369 | - | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "USDT payments only!") | |
370 | - | if ((pmtAssetId != usdtAssetId)) | |
371 | - | then throw("USDT payments only!") | |
372 | - | else { | |
373 | - | let caller = i.caller | |
374 | - | let addr = toString(caller) | |
375 | - | let maxUsdt = getSwapLimit(addr) | |
376 | - | if ((usdtAmt > maxUsdt)) | |
377 | - | then throw((("You can spend max " + fixedPoint(maxUsdt, 6)) + " USDT")) | |
378 | - | else if ((MINSHOPPAYMENT > usdtAmt)) | |
379 | - | then throw((("You can trade min " + fixedPoint(MINSHOPPAYMENT, 6)) + " USDT")) | |
380 | - | else { | |
381 | - | let curStats = getWlgStats("", [restContract, stakingContract, economyContract, govContract, wlgContract, puzzlePoolContract, investFundContract], usdtAssetId, usdtAmt) | |
382 | - | let curWlgAmount = curStats[idxWlgAmount] | |
383 | - | let fundsUsd = curStats[idxWlgFunds] | |
384 | - | let wlgPrice = fraction(fundsUsd, MULT8, curWlgAmount) | |
385 | - | let buyPrice = fraction(wlgPrice, 6, 5) | |
386 | - | let wlgAmount = fraction(usdtAmt, MULT8, buyPrice) | |
387 | - | if ((minAmount > wlgAmount)) | |
388 | - | then throw("Price changed during operation, please try again") | |
389 | - | else { | |
390 | - | let profitAmount = (usdtAmt / 6) | |
391 | - | let deltaFunds = (usdtAmt - profitAmount) | |
392 | - | let reissued = fraction(curWlgAmount, deltaFunds, fundsUsd) | |
393 | - | $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) | |
394 | - | } | |
395 | - | } | |
396 | - | } | |
397 | - | } | |
398 | - | } | |
356 | + | func buyWlg (minAmount) = { | |
357 | + | let prologResult = prolog() | |
358 | + | if ((size(i.payments) != 1)) | |
359 | + | then throw("exactly 1 payment must be attached") | |
360 | + | else { | |
361 | + | let pmt = i.payments[0] | |
362 | + | let usdtAmt = pmt.amount | |
363 | + | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "USDT payments only!") | |
364 | + | if ((pmtAssetId != usdtAssetId)) | |
365 | + | then throw("USDT payments only!") | |
366 | + | else { | |
367 | + | let caller = i.caller | |
368 | + | let addr = toString(caller) | |
369 | + | let maxUsdt = getSwapLimit(addr) | |
370 | + | if ((usdtAmt > maxUsdt)) | |
371 | + | then throw((("You can spend max " + fixedPoint(maxUsdt, 6)) + " USDT")) | |
372 | + | else if ((MINSHOPPAYMENT > usdtAmt)) | |
373 | + | then throw((("You can trade min " + fixedPoint(MINSHOPPAYMENT, 6)) + " USDT")) | |
374 | + | else { | |
375 | + | let curStats = getWlgStats("", [restContract, stakingContract, economyContract, govContract, wlgContract, puzzlePoolContract, investFundContract], usdtAssetId, usdtAmt) | |
376 | + | let curWlgAmount = curStats[idxWlgAmount] | |
377 | + | let fundsUsd = curStats[idxWlgFunds] | |
378 | + | let wlgPrice = fraction(fundsUsd, MULT8, curWlgAmount) | |
379 | + | let buyPrice = fraction(wlgPrice, 6, 5) | |
380 | + | let wlgAmount = fraction(usdtAmt, MULT8, buyPrice) | |
381 | + | if ((minAmount > wlgAmount)) | |
382 | + | then throw("Price changed during operation, please try again") | |
383 | + | else { | |
384 | + | let profitAmount = (usdtAmt / 6) | |
385 | + | let deltaFunds = (usdtAmt - profitAmount) | |
386 | + | let reissued = fraction(curWlgAmount, deltaFunds, fundsUsd) | |
387 | + | $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) | |
388 | + | } | |
389 | + | } | |
390 | + | } | |
391 | + | } | |
392 | + | } | |
399 | 393 | ||
400 | 394 | ||
401 | 395 | ||
402 | 396 | @Callable(i) | |
403 | - | func sellWlg (minAmount) = if (!(KSALLOWWLGOLD)) | |
404 | - | then $Tuple2(nil, 0) | |
405 | - | else { | |
406 | - | let prologResult = prolog() | |
407 | - | if ((size(i.payments) != 1)) | |
408 | - | then throw("exactly 1 payment must be attached") | |
409 | - | else { | |
410 | - | let pmt = i.payments[0] | |
411 | - | let wlgAmt = pmt.amount | |
412 | - | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WLGOLD payments only!") | |
413 | - | if ((pmtAssetId != wlgAssetId)) | |
414 | - | then throw("WLGOLD payments only!") | |
415 | - | else { | |
416 | - | let caller = i.caller | |
417 | - | let addr = toString(caller) | |
418 | - | let maxUsdt = getSwapLimit(addr) | |
419 | - | let curStats = getWlgStats("", [restContract, stakingContract, economyContract, govContract, wlgContract, puzzlePoolContract, investFundContract], usdtAssetId, 0) | |
420 | - | let curWlgAmount = curStats[idxWlgAmount] | |
421 | - | let sellPrice = fraction(curStats[idxWlgPrice], 4, 5) | |
422 | - | let usdtAmt = fraction(wlgAmt, sellPrice, MULT8) | |
423 | - | if ((usdtAmt > maxUsdt)) | |
424 | - | then throw((("You can get max " + fixedPoint(maxUsdt, 6)) + " USDT")) | |
425 | - | else if ((MINSHOPPAYMENT > usdtAmt)) | |
426 | - | then throw((("You can trade min " + fixedPoint(MINSHOPPAYMENT, 6)) + " USDT")) | |
427 | - | else if ((minAmount > usdtAmt)) | |
428 | - | then throw("Price changed during operation, please try again") | |
429 | - | else { | |
430 | - | let profitAmount = (usdtAmt / 4) | |
431 | - | let burned = fraction((usdtAmt + profitAmount), curWlgAmount, curStats[idxWlgFunds]) | |
432 | - | $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) | |
433 | - | } | |
434 | - | } | |
435 | - | } | |
436 | - | } | |
397 | + | func sellWlg (minAmount) = { | |
398 | + | let prologResult = prolog() | |
399 | + | if ((size(i.payments) != 1)) | |
400 | + | then throw("exactly 1 payment must be attached") | |
401 | + | else { | |
402 | + | let pmt = i.payments[0] | |
403 | + | let wlgAmt = pmt.amount | |
404 | + | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WLGOLD payments only!") | |
405 | + | if ((pmtAssetId != wlgAssetId)) | |
406 | + | then throw("WLGOLD payments only!") | |
407 | + | else { | |
408 | + | let caller = i.caller | |
409 | + | let addr = toString(caller) | |
410 | + | let maxUsdt = getSwapLimit(addr) | |
411 | + | let curStats = getWlgStats("", [restContract, stakingContract, economyContract, govContract, wlgContract, puzzlePoolContract, investFundContract], usdtAssetId, 0) | |
412 | + | let curWlgAmount = curStats[idxWlgAmount] | |
413 | + | let sellPrice = fraction(curStats[idxWlgPrice], 4, 5) | |
414 | + | let usdtAmt = fraction(wlgAmt, sellPrice, MULT8) | |
415 | + | if ((usdtAmt > maxUsdt)) | |
416 | + | then throw((("You can get max " + fixedPoint(maxUsdt, 6)) + " USDT")) | |
417 | + | else if ((MINSHOPPAYMENT > usdtAmt)) | |
418 | + | then throw((("You can trade min " + fixedPoint(MINSHOPPAYMENT, 6)) + " USDT")) | |
419 | + | else if ((minAmount > usdtAmt)) | |
420 | + | then throw("Price changed during operation, please try again") | |
421 | + | else { | |
422 | + | let profitAmount = (usdtAmt / 4) | |
423 | + | let burned = fraction((usdtAmt + profitAmount), curWlgAmount, curStats[idxWlgFunds]) | |
424 | + | $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) | |
425 | + | } | |
426 | + | } | |
427 | + | } | |
428 | + | } | |
437 | 429 | ||
438 | 430 | ||
439 | 431 | ||
440 | 432 | @Callable(i) | |
441 | 433 | func claim () = { | |
442 | 434 | let prologResult = prolog() | |
443 | 435 | if ((size(i.payments) != 0)) | |
444 | 436 | then throw("No payments required") | |
445 | 437 | else { | |
446 | 438 | let actions = claimInternal(toString(i.caller))._1 | |
447 | 439 | $Tuple2(actions, prologResult) | |
448 | 440 | } | |
449 | 441 | } | |
450 | 442 | ||
451 | 443 | ||
452 | 444 | ||
453 | 445 | @Callable(i) | |
454 | 446 | func onStakeUnstakeLand (addr) = if ((i.caller != stakingContract)) | |
455 | 447 | then throw("Permission denied") | |
456 | 448 | else claimInternal(addr) | |
457 | 449 | ||
458 | 450 |
github/deemru/w8io/026f985 53.72 ms ◑