tx · 6QJENVqWfBiNxmp9p3wSFhtSCNxJ1yiCq2echg6uYU1E

3N7HtrKeFFLz5oy6PfGv1Lg3GwPk4gCPdGy:  -0.01500000 Waves

2023.06.19 02:34 [2628736] smart account 3N7HtrKeFFLz5oy6PfGv1Lg3GwPk4gCPdGy > SELF 0.00000000 Waves

{ "type": 13, "id": "6QJENVqWfBiNxmp9p3wSFhtSCNxJ1yiCq2echg6uYU1E", "fee": 1500000, "feeAssetId": null, "timestamp": 1687131286151, "version": 2, "chainId": 84, "sender": "3N7HtrKeFFLz5oy6PfGv1Lg3GwPk4gCPdGy", "senderPublicKey": "FsR18761ZAsUqsTd7TK3XmR6bhihs1UXVmpHYxz5JzQ1", "proofs": [ "5s3BiDCjfs4agd6zctmtNRy6aC3esiKonK3HjzMgaDAdTm7AEiejUGHxo84z7E3zSSokyDcEfg5gmcCZ6Qdj5vom" ], "script": "base64:BgISCAISBQoDCAgIEgASAwoBARIAkwEABWNoYWluCQDJAQIJAMoBAggFBHRoaXMFYnl0ZXMAAQABAAt1c2R0QXNzZXRJZAQHJG1hdGNoMAUFY2hhaW4DCQAAAgEBVwUHJG1hdGNoMAEghNp6sggDP07Ru8qO7ouTvMmC3Qtd+geWqNQj+agP/7kDCQAAAgEBVAUHJG1hdGNoMAEgVbHYn3KHgu/l41uNrAWrZd6aQ6EvFrsF8xq3h6XxxRgJAAIBAg1Vbmtub3duIGNoYWluABVkZWZhdWx0UmVzdEFkZHJlc3NTdHIEByRtYXRjaDAFBWNoYWluAwkAAAIBAVcFByRtYXRjaDACIzNQUUN1dkZidmg0TGtQVW5yblUxejNqbmJBMXA5bTNXTmh2AwkAAAIBAVQFByRtYXRjaDACIzNNdW1rR0d6dENLQVhwV0RxeGtkZG9mcVhTVWJxUWt2U0p5CQACAQINVW5rbm93biBjaGFpbgARSW5mcmFVcGdyYWRlQ29zdFMEByRtYXRjaDAFBWNoYWluAwkAAAIBAVcFByRtYXRjaDAAgMivoCUDCQAAAgEBVAUHJG1hd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WdlckVudHJ5AgUHdXNlcktleQkAZAIJAQt2YWx1ZU9yRWxzZQIJAJ8IAQUHdXNlcktleQAABQp1c2VyQW1vdW50CQDMCAIJAQxJbnRlZ2VyRW50cnkCBRlzdGFrZXJzQW1vdW50UGFpZFRvdGFsS2V5CQBkAgkBC3ZhbHVlT3JFbHNlAgkAnwgBBRlzdGFrZXJzQW1vdW50UGFpZFRvdGFsS2V5AAAFCnVzZXJBbW91bnQJAMwIAgkBDEludGVnZXJFbnRyeQIFFHN0YWtlcnNBbW91bnRMZWZ0S2V5CQBlAgUPYW1vdW50TGVmdFRvdGFsBQp1c2VyQW1vdW50CQDMCAIJAQxJbnRlZ2VyRW50cnkCBRRsYXN0TWFya2V0aW5nVGltZUtleQUDbm93CQDMCAIJAQxJbnRlZ2VyRW50cnkCBQ9sYXN0VGVhbVRpbWVLZXkFA25vdwkAzAgCCQEMSW50ZWdlckVudHJ5AgUVbGFzdEFjdGl2aXRpZXNUaW1lS2V5BQNub3cJAMwIAgkBDEludGVnZXJFbnRyeQIFC3VzZXJUaW1lS2V5BQNub3cFA25pbAUMcHJvbG9nUmVzdWx0ADO5uMQ=", "height": 2628736, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CdqR3XTDofvQ9yRXju6iewBEpyHWM6VUcn8jhg3Eb3Tq Next: ButLAkeJDdpehchQ3czV3PWrdeoC1MXvUhvUh1xcaMZX Diff:
OldNewDifferences
216216 func keyStakedLandsByOwner (ownerAddr) = ("stakedLandsByOwner_" + ownerAddr)
217217
218218
219+func keyStakedPiecesByOwner (ownerAddr) = ("stakedPiecesByOwner_" + ownerAddr)
220+
221+
219222 func keyDuckAssetIdToCustomName (assetId) = ("duckCustomNameByAssetId_" + assetId)
220223
221224
394397
395398 let YEARMILLIS = 31557600000
396399
400+let WEEKMILLIS = 604800000
401+
402+let MAXPERIOD = 156
403+
404+let TENMINUTESMILLIS = 600000
405+
406+let A6 = 100000000
407+
408+let B8 = 50000000
409+
397410 let wlgAssetIdKey = "wlg_assetId"
398411
399412 let wlgIssueTimeKey = "wlg_issueTime"
413+
414+let wlgIssuedAmountKey = "wlg_issuedAmount"
400415
401416 let marketingAddrKey = "marketingAddr"
402417
408423
409424 let lastActivitiesTimeKey = "lastClaimedTime_activities"
410425
411-func keyLastClaimedTimeByUser (addr) = "lastClaimedTimeUser_ + addr"
426+func keyLastClaimedTimeByUser (addr) = ("lastClaimedTimeUser_" + addr)
427+
428+
429+func keyLastArbTimeByUser (addr) = ("lastArbTimeUser_" + addr)
430+
431+
432+let stakersAmountLeftKey = "stakersAmountLeft"
433+
434+let stakersAmountPaidTotalKey = "stakersAmountPaidTotal"
435+
436+func keyStakersAmountPaidUser (addr) = ("stakersAmountPaidUser_" + addr)
437+
438+
439+let idxWlgAmount = 0
440+
441+let idxWlgPrice = 1
442+
443+let idxWlgFunds = 2
444+
445+let wlgAssetId = valueOrErrorMessage(getBinary(wlgAssetIdKey), "Not initialized yet")
446+
447+func prolog () = if (valueOrElse(getBoolean(stakingContract, keyBlocked()), false))
448+ then throw("Contracts are under maintenance")
449+ else asInt(invoke(stakingContract, "saveLastTx", nil, nil))
450+
451+
452+func getWlgStats () = {
453+ let issuedAmount = valueOrErrorMessage(getInteger(wlgIssuedAmountKey), "WLGOLD is not issued yet")
454+ let funds = ((assetBalance(economyContract, usdtAssetId) + assetBalance(restContract, usdtAssetId)) + assetBalance(this, usdtAssetId))
455+[issuedAmount, fraction(funds, MULT8, issuedAmount), funds]
456+ }
457+
458+
459+func getSwapLimit (addr) = {
460+ let lastTime = valueOrElse(getInteger(keyLastArbTimeByUser(addr)), 0)
461+ let now = lastBlock.timestamp
462+ if ((TENMINUTESMILLIS > (now - lastTime)))
463+ then throw("Arbitrages are possible once a 10 minutes")
464+ else {
465+ let pieces = getVotingPower(addr)[IdxEffUser]
466+ let pow8 = pow(pieces, 0, B8, 8, 8, CEILING)
467+ fraction(A6, pow8, MULT8)
468+ }
469+ }
412470
413471
414472 @Callable(i)
415473 func constructorV1 (restAddr,marketingAddr,teamAddr) = if ((i.caller != this))
416474 then throw("Permission denied")
417- else if (isDefined(getString(wlgAssetIdKey)))
475+ else if (isDefined(getBinary(wlgAssetIdKey)))
418476 then throw("Already initialized")
419477 else {
420- let issue = Issue("WLGOLD", "WavesLands Gold investment token", MULT14, 8, true, unit, 0)
478+ let issuedAmount = MULT14
479+ let issue = Issue("WLGOLD", "WavesLands Gold investment token", issuedAmount, 8, true, unit, 0)
421480 let assetId = calculateAssetId(issue)
422-[issue, IntegerEntry(wlgIssueTimeKey, lastBlock.timestamp), BinaryEntry(wlgAssetIdKey, assetId), StringEntry(keyRestAddress(), restAddr), StringEntry(marketingAddrKey, marketingAddr), StringEntry(teamAddrKey, teamAddr)]
481+[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)]
423482 }
424483
425484
426485
427486 @Callable(i)
428-func buyWlg (amount) = nil
487+func buyWlg () = {
488+ let prologResult = prolog()
489+ if ((size(i.payments) != 1))
490+ then throw("exactly 1 payment must be attached")
491+ else {
492+ let pmt = i.payments[0]
493+ let usdtAmt = pmt.amount
494+ let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment")
495+ if ((pmtAssetId != usdtAssetId))
496+ then throw("USDT payments only!")
497+ else {
498+ let caller = i.caller
499+ let addr = toString(caller)
500+ let maxUsdt = getSwapLimit(addr)
501+ if ((usdtAmt > maxUsdt))
502+ then throw((("You can spend max " + toString(maxUsdt)) + " USDT"))
503+ else {
504+ let curStats = getWlgStats()
505+ let curAmount = curStats[idxWlgAmount]
506+ let buyPrice = fraction(curStats[idxWlgPrice], 6, 5)
507+ let wlgAmount = fraction(usdtAmt, MULT8, buyPrice)
508+ let reissued = fraction(usdtAmt, curAmount, (curStats[idxWlgFunds] - usdtAmt))
509+ $Tuple2([Reissue(wlgAssetId, reissued, true), IntegerEntry(wlgIssuedAmountKey, (curAmount + reissued)), IntegerEntry(keyLastArbTimeByUser(addr), lastBlock.timestamp), ScriptTransfer(caller, wlgAmount, wlgAssetId)], prologResult)
510+ }
511+ }
512+ }
513+ }
429514
430515
431516
432517 @Callable(i)
433-func sellWlg (amount) = nil
518+func sellWlg (amount) = {
519+ let prologResult = prolog()
520+ if ((size(i.payments) != 1))
521+ then throw("exactly 1 payment must be attached")
522+ else {
523+ let pmt = i.payments[0]
524+ let wlgAmt = pmt.amount
525+ let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment")
526+ if ((pmtAssetId != wlgAssetId))
527+ then throw("WLGOLD payments only!")
528+ else {
529+ let caller = i.caller
530+ let addr = toString(caller)
531+ let maxUsdt = getSwapLimit(addr)
532+ let curStats = getWlgStats()
533+ let curAmount = (curStats[idxWlgAmount] - wlgAmt)
534+ let curPrice = curStats[idxWlgPrice]
535+ let sellPrice = (curPrice - (curPrice / 5))
536+ let usdtAmount = fraction(wlgAmt, sellPrice, MULT8)
537+ if ((usdtAmount > maxUsdt))
538+ then throw((("You can get max " + toString(maxUsdt)) + " USDT"))
539+ else {
540+ let burned = fraction(usdtAmount, curAmount, curStats[idxWlgFunds])
541+ $Tuple2([Burn(wlgAssetId, burned), IntegerEntry(wlgIssuedAmountKey, (curAmount - burned)), IntegerEntry(keyLastArbTimeByUser(addr), lastBlock.timestamp), ScriptTransfer(caller, usdtAmount, usdtAssetId)], prologResult)
542+ }
543+ }
544+ }
545+ }
434546
435547
436548
437549 @Callable(i)
438550 func claim () = {
551+ let prologResult = prolog()
439552 let caller = i.caller
440553 let callerAddr = toString(caller)
441554 let now = lastBlock.timestamp
442555 let issueTime = valueOrErrorMessage(getInteger(wlgIssueTimeKey), "Not initialized")
443- let wlgAssetId = value(getBinary(wlgAssetIdKey))
444556 let lastMarketingTime = valueOrElse(getInteger(lastMarketingTimeKey), issueTime)
445557 let marketingAddr = addressFromStringValue(value(getString(marketingAddrKey)))
446558 let marketingAmount = fraction(fraction(MULT14, MARKETINGSHARE, MULT6), (now - lastMarketingTime), YEARMILLIS)
449561 let teamAmount = fraction(fraction(MULT14, TEAMSHARE, MULT6), (now - lastTeamTime), (3 * YEARMILLIS))
450562 let lastActivitiesTime = valueOrElse(getInteger(lastActivitiesTimeKey), issueTime)
451563 let actAmount = fraction(fraction(MULT14, ACTIVITYSHARE, MULT6), (now - lastActivitiesTime), (3 * YEARMILLIS))
452- let userTimeKey = keyLastClaimedTimeByUser(callerAddr)
453- let lastUserTime = valueOrElse(getInteger(userTimeKey), issueTime)
454- let eff = getVotingPower(callerAddr)
455- let userAmount = fraction(fraction(fraction(MULT14, PLAYERSHARE, MULT6), eff[IdxEffUser], eff[IdxEffTotal]), (now - lastUserTime), (3 * YEARMILLIS))
456-[ScriptTransfer(marketingAddr, marketingAmount, wlgAssetId), ScriptTransfer(teamAddr, teamAmount, wlgAssetId), ScriptTransfer(restContract, actAmount, wlgAssetId), ScriptTransfer(caller, userAmount, wlgAssetId), IntegerEntry(lastMarketingTimeKey, now), IntegerEntry(lastTeamTimeKey, now), IntegerEntry(lastActivitiesTimeKey, now), IntegerEntry(userTimeKey, now)]
564+ let curPeriod = ((now - issueTime) / WEEKMILLIS)
565+ if ((curPeriod > (MAXPERIOD / 2)))
566+ then throw("Please modify contract for next 1.5 years, according to stats")
567+ else {
568+ let eff = getVotingPower(callerAddr)
569+ let totalPieces = eff[IdxEffTotal]
570+ let amountLeftTotal = valueOrElse(getInteger(stakersAmountLeftKey), 0)
571+ let curPeriodDistribution = fraction(amountLeftTotal, (2 * totalPieces), (totalPieces + (max([100000, totalPieces]) * (MAXPERIOD - curPeriod))))
572+ let userTimeKey = keyLastClaimedTimeByUser(callerAddr)
573+ let lastUserTime = valueOrElse(getInteger(userTimeKey), issueTime)
574+ let userAmount = fraction(fraction(curPeriodDistribution, eff[IdxEffUser], totalPieces), (now - lastUserTime), (3 * YEARMILLIS))
575+ let userKey = keyStakersAmountPaidUser(callerAddr)
576+ $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)], prologResult)
577+ }
457578 }
458579
459580
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let chain = take(drop(this.bytes, 1), 1)
55
66 let usdtAssetId = match chain {
77 case _ =>
88 if ((base58'2W' == $match0))
99 then base58'9wc3LXNA4TEBsXyKtoLE9mrbDD7WMHXvXrCjZvabLAsi'
1010 else if ((base58'2T' == $match0))
1111 then base58'6mWwf9mZBjVgkC54idpyaZLQfAosD914wT8fGf2iiY63'
1212 else throw("Unknown chain")
1313 }
1414
1515 let defaultRestAddressStr = match chain {
1616 case _ =>
1717 if ((base58'2W' == $match0))
1818 then "3PQCuvFbvh4LkPUnrnU1z3jnbA1p9m3WNhv"
1919 else if ((base58'2T' == $match0))
2020 then "3MumkGGztCKAXpWDqxkddofqXSUbqQkvSJy"
2121 else throw("Unknown chain")
2222 }
2323
2424 let InfraUpgradeCostS = match chain {
2525 case _ =>
2626 if ((base58'2W' == $match0))
2727 then 10000000000
2828 else if ((base58'2T' == $match0))
2929 then 100000000
3030 else throw("Unknown chain")
3131 }
3232
3333 let SEP = "__"
3434
3535 let MULT6 = 1000000
3636
3737 let MULT7 = 10000000
3838
3939 let MULT8 = 100000000
4040
4141 let MULT10 = 10000000000
4242
4343 let LANDPREFIX = "LAND"
4444
4545 let DUCKPREFIX = "DUCK"
4646
4747 let ARTPRESALE = "PRESALE"
4848
4949 let NUMRES = 6
5050
5151 let SSIZE = 25
5252
5353 let MSIZE = 100
5454
5555 let LSIZE = 225
5656
5757 let XLSIZE = 400
5858
5959 let XXLSIZE = 625
6060
6161 let DAILYRESBYPIECE = 3456000
6262
6363 let DAYMILLIS = 86400000
6464
6565 let WHMULTIPLIER = 10000000000
6666
6767 let DEFAULTLOCATION = "Africa_F_Africa"
6868
6969 let RESOURCEPRICEMIN = 39637
7070
7171 let ESMAXPACKAGES = 3
7272
7373 let ESBUYCOEF = 4
7474
7575 let ESSELLCOEF = 10
7676
7777 let MAXHP = 100
7878
7979 let resTypes = ["Oil", "Ore", "Wood", "Sand", "Clay", "Organic"]
8080
8181 let matTypes = ["Fuel", "Metal", "Plank", "Glass", "Plastic", "Protein"]
8282
8383 let prodTypes = ["First Aid Kit L1", "First Aid Kit L2", "First Aid Kit L3", "Backpack L1", "Backpack L2", "Backpack L3", "Food Ration L1", "Food Ration L2", "Food Ration L3", "Jet Pack L1", "Jet Pack L2", "Jet Pack L3", "Shield L1", "Shield L2", "Shield L3"]
8484
8585 let continents = ["Americas", "Europe", "Asia", "Africa", "Oceania"]
8686
8787 let productionMatrix = ["1_1_1_2_2_5_1_10_0", "2_2_2_4_4_10_1_10_0", "3_3_3_6_6_15_1_10_0", "2_5_5_2_7_5_2_100_1", "4_10_10_4_14_10_2_100_1", "6_15_15_6_21_15_2_100_1", "1_1_1_1_1_8_1_10_2", "2_2_2_2_2_16_1_10_2", "3_3_3_3_3_24_1_10_2", "9_9_1_5_5_1_5_100_3", "18_18_2_10_10_2_5_100_3", "27_27_3_15_15_3_5_100_3", "2_2_1_2_2_2_1_10_4", "4_4_2_4_4_4_1_10_4", "6_6_3_6_6_6_1_10_4"]
8888
8989 let contIdxAmericas = 0
9090
9191 let contIdxEurope = 1
9292
9393 let contIdxAsia = 2
9494
9595 let contIdxAfrica = 3
9696
9797 let contIdxOceania = 4
9898
9999 let recipeIdxFuel = 0
100100
101101 let recipeIdxMetal = 1
102102
103103 let recipeIdxPlank = 2
104104
105105 let recipeIdxGlass = 3
106106
107107 let recipeIdxPlastic = 4
108108
109109 let recipeIdxProtein = 5
110110
111111 let recipeIdxWeight = 6
112112
113113 let recipeIdxPacksize = 7
114114
115115 let recipeIdxContinent = 8
116116
117117 let recLandNum = 0
118118
119119 let recLandSize = 1
120120
121121 let recTerrains = 2
122122
123123 let recContinent = 3
124124
125125 let whIdxLevels = 0
126126
127127 let whIdxRes = 1
128128
129129 let whIdxMat = 2
130130
131131 let whIdxProd = 3
132132
133133 let whIdxLOFT = 4
134134
135135 let volLocked = 0
136136
137137 let volOccupied = 1
138138
139139 let volFree = 2
140140
141141 let volTotal = 3
142142
143143 let bpIdxLevel = 0
144144
145145 let bpIdxRes = 1
146146
147147 let bpIdxMat = 2
148148
149149 let bpIdxProd = 3
150150
151151 func getPkgSize (prodIdx) = parseIntValue(split(productionMatrix[prodIdx], "_")[recipeIdxPacksize])
152152
153153
154154 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
155155
156156
157157 func getIntOrElse (key,defaultVal) = valueOrElse(getInteger(this, key), defaultVal)
158158
159159
160160 let IdxCfgStakingDapp = 1
161161
162162 let IdxCfgEconomyDapp = 2
163163
164164 let IdxCfgGovernanceDapp = 3
165165
166166 let IdxCfgWlgDapp = 4
167167
168168 func keyRestCfg () = "%s__restConfig"
169169
170170
171171 func keyRestAddress () = "%s__restAddr"
172172
173173
174174 func readRestCfgOrFail (rest) = split_4C(getStringOrFail(rest, keyRestCfg()), SEP)
175175
176176
177177 func getContractAddressOrFail (restCfg,idx) = valueOrErrorMessage(addressFromString(restCfg[idx]), ("Rest cfg doesn't contain address at index " + toString(idx)))
178178
179179
180180 let restContract = addressFromStringValue(valueOrElse(getString(this, keyRestAddress()), defaultRestAddressStr))
181181
182182 let restCfg = readRestCfgOrFail(restContract)
183183
184184 let stakingContract = getContractAddressOrFail(restCfg, IdxCfgStakingDapp)
185185
186186 let economyContract = getContractAddressOrFail(restCfg, IdxCfgEconomyDapp)
187187
188188 let govContract = getContractAddressOrFail(restCfg, IdxCfgGovernanceDapp)
189189
190190 let wlgContract = getContractAddressOrFail(restCfg, IdxCfgWlgDapp)
191191
192192 func keyLastTxIdByUser (addr) = ("lastTxIdByUser_" + addr)
193193
194194
195195 func keyLandAssetIdToOwner (assetId) = ("nftOwner_" + assetId)
196196
197197
198198 func keyLandAssetIdToCustomName (assetId) = ("landCustomNameByAssetId_" + assetId)
199199
200200
201201 func keyStakedTimeByAssetId (assetId) = ("stakedTime_" + assetId)
202202
203203
204204 func keyInfraLevelByAssetId (assetId) = ("infraLevel_" + assetId)
205205
206206
207207 func keyLandArtStatusByTypeAndAssetId (type,assetId) = makeString(["landArtStatus", type, assetId], "_")
208208
209209
210210 func keyStakedTimeByTypeAssetIdAndOwner (nftType,assetId,ownerAddr) = ((((("stakedTimeByTypeAssetIdAndOwner_" + nftType) + "_") + assetId) + "_") + ownerAddr)
211211
212212
213213 func keyWarehouseByLand (landAssetId) = ("wareHouse_" + landAssetId)
214214
215215
216216 func keyStakedLandsByOwner (ownerAddr) = ("stakedLandsByOwner_" + ownerAddr)
217217
218218
219+func keyStakedPiecesByOwner (ownerAddr) = ("stakedPiecesByOwner_" + ownerAddr)
220+
221+
219222 func keyDuckAssetIdToCustomName (assetId) = ("duckCustomNameByAssetId_" + assetId)
220223
221224
222225 func keyAddressToCustomName (addr) = ("accountCustomNameByAddr_" + addr)
223226
224227
225228 func keyAddressRefBy (addr) = ("accRefBy_" + addr)
226229
227230
228231 func keyAddressReferrals (addr) = ("accReferrals_" + addr)
229232
230233
231234 func keyDuckIdToOwner (assetId) = ("duckOwner_" + assetId)
232235
233236
234237 func keyStakedDuckByOwner (ownerAddr) = ("stakedDuckByOwner_" + ownerAddr)
235238
236239
237240 func keyBackpackByDuck (duckAssetId) = ("backPack_" + duckAssetId)
238241
239242
240243 func keyDuckLocation (duckAssetId) = ("duckLocation_" + duckAssetId)
241244
242245
243246 func keyDuckHealth (duckAssetId) = ("duckHealth_" + duckAssetId)
244247
245248
246249 func keyResProportions () = "resTypesProportions"
247250
248251
249252 func keyBlocked () = "contractsBlocked"
250253
251254
252255 func keyUserGwlReleaseTime (userAddr) = ("%s%s__userGwlReleaseTime__" + userAddr)
253256
254257
255258 func keyOrderByLand (landAssetId) = ("landOrder_" + landAssetId)
256259
257260
258261 func keyEsWarehouse () = "emergencyWarehouseProducts"
259262
260263
261264 let locIdxContinent = 0
262265
263266 let locIdxType = 1
264267
265268 let locIdxId = 2
266269
267270 func asString (v) = match v {
268271 case s: String =>
269272 s
270273 case _ =>
271274 throw("fail to cast into String")
272275 }
273276
274277
275278 func asInt (v) = match v {
276279 case n: Int =>
277280 n
278281 case _ =>
279282 throw("fail to cast into Int")
280283 }
281284
282285
283286 func asAnyList (v) = match v {
284287 case l: List[Any] =>
285288 l
286289 case _ =>
287290 throw("fail to cast into List[Any]")
288291 }
289292
290293
291294 func asBoolean (v) = match v {
292295 case s: Boolean =>
293296 s
294297 case _ =>
295298 throw("fail to cast into Boolean")
296299 }
297300
298301
299302 func numPiecesBySize (landSize) = match landSize {
300303 case _ =>
301304 if (("S" == $match0))
302305 then SSIZE
303306 else if (("M" == $match0))
304307 then MSIZE
305308 else if (("L" == $match0))
306309 then LSIZE
307310 else if (("XL" == $match0))
308311 then XLSIZE
309312 else if (("XXL" == $match0))
310313 then XXLSIZE
311314 else throw("Unknown land size")
312315 }
313316
314317
315318 let IdxEffTotal = 0
316319
317320 let IdxEffUser = 1
318321
319322 func getVotingPower (userAddrStrOrEmpty) = {
320323 let props = split(valueOrElse(getString(stakingContract, keyResProportions()), "0_0_0_0_0_0"), "_")
321324 func adder (acc,item) = (acc + parseIntValue(item))
322325
323326 let totalPower = {
324327 let $l = props
325328 let $s = size($l)
326329 let $acc0 = 0
327330 func $f0_1 ($a,$i) = if (($i >= $s))
328331 then $a
329332 else adder($a, $l[$i])
330333
331334 func $f0_2 ($a,$i) = if (($i >= $s))
332335 then $a
333336 else throw("List size exceeds 6")
334337
335338 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6)
336339 }
337340 let usersPower = if ((userAddrStrOrEmpty == ""))
338341 then 0
339342 else {
340343 let landsStr = getString(stakingContract, keyStakedLandsByOwner(userAddrStrOrEmpty))
341344 let lands = if (isDefined(landsStr))
342345 then split_51C(value(landsStr), "_")
343346 else nil
344347 func oneLand (acc,landAssetId) = {
345348 let asset = value(assetInfo(fromBase58String(landAssetId)))
346349 let landSize = split(asset.description, "_")[recLandSize]
347350 (acc + numPiecesBySize(landSize))
348351 }
349352
350353 let $l = lands
351354 let $s = size($l)
352355 let $acc0 = 0
353356 func $f1_1 ($a,$i) = if (($i >= $s))
354357 then $a
355358 else oneLand($a, $l[$i])
356359
357360 func $f1_2 ($a,$i) = if (($i >= $s))
358361 then $a
359362 else throw("List size exceeds 100")
360363
361364 $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)
362365 }
363366 [totalPower, usersPower]
364367 }
365368
366369
367370 func getRecipeMaterials (recipe) = {
368371 func addMat (ac,j) = (ac + parseIntValue(recipe[j]))
369372
370373 let $l = [0, 1, 2, 3, 4, 5]
371374 let $s = size($l)
372375 let $acc0 = 0
373376 func $f0_1 ($a,$i) = if (($i >= $s))
374377 then $a
375378 else addMat($a, $l[$i])
376379
377380 func $f0_2 ($a,$i) = if (($i >= $s))
378381 then $a
379382 else throw("List size exceeds 6")
380383
381384 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6)
382385 }
383386
384387
385388 let MULT14 = 100000000000000
386389
387390 let MARKETINGSHARE = 100000
388391
389392 let TEAMSHARE = 200000
390393
391394 let ACTIVITYSHARE = 100000
392395
393396 let PLAYERSHARE = 400000
394397
395398 let YEARMILLIS = 31557600000
396399
400+let WEEKMILLIS = 604800000
401+
402+let MAXPERIOD = 156
403+
404+let TENMINUTESMILLIS = 600000
405+
406+let A6 = 100000000
407+
408+let B8 = 50000000
409+
397410 let wlgAssetIdKey = "wlg_assetId"
398411
399412 let wlgIssueTimeKey = "wlg_issueTime"
413+
414+let wlgIssuedAmountKey = "wlg_issuedAmount"
400415
401416 let marketingAddrKey = "marketingAddr"
402417
403418 let teamAddrKey = "teamAddr"
404419
405420 let lastMarketingTimeKey = "lastClaimedTime_marketing"
406421
407422 let lastTeamTimeKey = "lastClaimedTime_team"
408423
409424 let lastActivitiesTimeKey = "lastClaimedTime_activities"
410425
411-func keyLastClaimedTimeByUser (addr) = "lastClaimedTimeUser_ + addr"
426+func keyLastClaimedTimeByUser (addr) = ("lastClaimedTimeUser_" + addr)
427+
428+
429+func keyLastArbTimeByUser (addr) = ("lastArbTimeUser_" + addr)
430+
431+
432+let stakersAmountLeftKey = "stakersAmountLeft"
433+
434+let stakersAmountPaidTotalKey = "stakersAmountPaidTotal"
435+
436+func keyStakersAmountPaidUser (addr) = ("stakersAmountPaidUser_" + addr)
437+
438+
439+let idxWlgAmount = 0
440+
441+let idxWlgPrice = 1
442+
443+let idxWlgFunds = 2
444+
445+let wlgAssetId = valueOrErrorMessage(getBinary(wlgAssetIdKey), "Not initialized yet")
446+
447+func prolog () = if (valueOrElse(getBoolean(stakingContract, keyBlocked()), false))
448+ then throw("Contracts are under maintenance")
449+ else asInt(invoke(stakingContract, "saveLastTx", nil, nil))
450+
451+
452+func getWlgStats () = {
453+ let issuedAmount = valueOrErrorMessage(getInteger(wlgIssuedAmountKey), "WLGOLD is not issued yet")
454+ let funds = ((assetBalance(economyContract, usdtAssetId) + assetBalance(restContract, usdtAssetId)) + assetBalance(this, usdtAssetId))
455+[issuedAmount, fraction(funds, MULT8, issuedAmount), funds]
456+ }
457+
458+
459+func getSwapLimit (addr) = {
460+ let lastTime = valueOrElse(getInteger(keyLastArbTimeByUser(addr)), 0)
461+ let now = lastBlock.timestamp
462+ if ((TENMINUTESMILLIS > (now - lastTime)))
463+ then throw("Arbitrages are possible once a 10 minutes")
464+ else {
465+ let pieces = getVotingPower(addr)[IdxEffUser]
466+ let pow8 = pow(pieces, 0, B8, 8, 8, CEILING)
467+ fraction(A6, pow8, MULT8)
468+ }
469+ }
412470
413471
414472 @Callable(i)
415473 func constructorV1 (restAddr,marketingAddr,teamAddr) = if ((i.caller != this))
416474 then throw("Permission denied")
417- else if (isDefined(getString(wlgAssetIdKey)))
475+ else if (isDefined(getBinary(wlgAssetIdKey)))
418476 then throw("Already initialized")
419477 else {
420- let issue = Issue("WLGOLD", "WavesLands Gold investment token", MULT14, 8, true, unit, 0)
478+ let issuedAmount = MULT14
479+ let issue = Issue("WLGOLD", "WavesLands Gold investment token", issuedAmount, 8, true, unit, 0)
421480 let assetId = calculateAssetId(issue)
422-[issue, IntegerEntry(wlgIssueTimeKey, lastBlock.timestamp), BinaryEntry(wlgAssetIdKey, assetId), StringEntry(keyRestAddress(), restAddr), StringEntry(marketingAddrKey, marketingAddr), StringEntry(teamAddrKey, teamAddr)]
481+[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)]
423482 }
424483
425484
426485
427486 @Callable(i)
428-func buyWlg (amount) = nil
487+func buyWlg () = {
488+ let prologResult = prolog()
489+ if ((size(i.payments) != 1))
490+ then throw("exactly 1 payment must be attached")
491+ else {
492+ let pmt = i.payments[0]
493+ let usdtAmt = pmt.amount
494+ let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment")
495+ if ((pmtAssetId != usdtAssetId))
496+ then throw("USDT payments only!")
497+ else {
498+ let caller = i.caller
499+ let addr = toString(caller)
500+ let maxUsdt = getSwapLimit(addr)
501+ if ((usdtAmt > maxUsdt))
502+ then throw((("You can spend max " + toString(maxUsdt)) + " USDT"))
503+ else {
504+ let curStats = getWlgStats()
505+ let curAmount = curStats[idxWlgAmount]
506+ let buyPrice = fraction(curStats[idxWlgPrice], 6, 5)
507+ let wlgAmount = fraction(usdtAmt, MULT8, buyPrice)
508+ let reissued = fraction(usdtAmt, curAmount, (curStats[idxWlgFunds] - usdtAmt))
509+ $Tuple2([Reissue(wlgAssetId, reissued, true), IntegerEntry(wlgIssuedAmountKey, (curAmount + reissued)), IntegerEntry(keyLastArbTimeByUser(addr), lastBlock.timestamp), ScriptTransfer(caller, wlgAmount, wlgAssetId)], prologResult)
510+ }
511+ }
512+ }
513+ }
429514
430515
431516
432517 @Callable(i)
433-func sellWlg (amount) = nil
518+func sellWlg (amount) = {
519+ let prologResult = prolog()
520+ if ((size(i.payments) != 1))
521+ then throw("exactly 1 payment must be attached")
522+ else {
523+ let pmt = i.payments[0]
524+ let wlgAmt = pmt.amount
525+ let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment")
526+ if ((pmtAssetId != wlgAssetId))
527+ then throw("WLGOLD payments only!")
528+ else {
529+ let caller = i.caller
530+ let addr = toString(caller)
531+ let maxUsdt = getSwapLimit(addr)
532+ let curStats = getWlgStats()
533+ let curAmount = (curStats[idxWlgAmount] - wlgAmt)
534+ let curPrice = curStats[idxWlgPrice]
535+ let sellPrice = (curPrice - (curPrice / 5))
536+ let usdtAmount = fraction(wlgAmt, sellPrice, MULT8)
537+ if ((usdtAmount > maxUsdt))
538+ then throw((("You can get max " + toString(maxUsdt)) + " USDT"))
539+ else {
540+ let burned = fraction(usdtAmount, curAmount, curStats[idxWlgFunds])
541+ $Tuple2([Burn(wlgAssetId, burned), IntegerEntry(wlgIssuedAmountKey, (curAmount - burned)), IntegerEntry(keyLastArbTimeByUser(addr), lastBlock.timestamp), ScriptTransfer(caller, usdtAmount, usdtAssetId)], prologResult)
542+ }
543+ }
544+ }
545+ }
434546
435547
436548
437549 @Callable(i)
438550 func claim () = {
551+ let prologResult = prolog()
439552 let caller = i.caller
440553 let callerAddr = toString(caller)
441554 let now = lastBlock.timestamp
442555 let issueTime = valueOrErrorMessage(getInteger(wlgIssueTimeKey), "Not initialized")
443- let wlgAssetId = value(getBinary(wlgAssetIdKey))
444556 let lastMarketingTime = valueOrElse(getInteger(lastMarketingTimeKey), issueTime)
445557 let marketingAddr = addressFromStringValue(value(getString(marketingAddrKey)))
446558 let marketingAmount = fraction(fraction(MULT14, MARKETINGSHARE, MULT6), (now - lastMarketingTime), YEARMILLIS)
447559 let lastTeamTime = valueOrElse(getInteger(lastTeamTimeKey), issueTime)
448560 let teamAddr = addressFromStringValue(value(getString(teamAddrKey)))
449561 let teamAmount = fraction(fraction(MULT14, TEAMSHARE, MULT6), (now - lastTeamTime), (3 * YEARMILLIS))
450562 let lastActivitiesTime = valueOrElse(getInteger(lastActivitiesTimeKey), issueTime)
451563 let actAmount = fraction(fraction(MULT14, ACTIVITYSHARE, MULT6), (now - lastActivitiesTime), (3 * YEARMILLIS))
452- let userTimeKey = keyLastClaimedTimeByUser(callerAddr)
453- let lastUserTime = valueOrElse(getInteger(userTimeKey), issueTime)
454- let eff = getVotingPower(callerAddr)
455- let userAmount = fraction(fraction(fraction(MULT14, PLAYERSHARE, MULT6), eff[IdxEffUser], eff[IdxEffTotal]), (now - lastUserTime), (3 * YEARMILLIS))
456-[ScriptTransfer(marketingAddr, marketingAmount, wlgAssetId), ScriptTransfer(teamAddr, teamAmount, wlgAssetId), ScriptTransfer(restContract, actAmount, wlgAssetId), ScriptTransfer(caller, userAmount, wlgAssetId), IntegerEntry(lastMarketingTimeKey, now), IntegerEntry(lastTeamTimeKey, now), IntegerEntry(lastActivitiesTimeKey, now), IntegerEntry(userTimeKey, now)]
564+ let curPeriod = ((now - issueTime) / WEEKMILLIS)
565+ if ((curPeriod > (MAXPERIOD / 2)))
566+ then throw("Please modify contract for next 1.5 years, according to stats")
567+ else {
568+ let eff = getVotingPower(callerAddr)
569+ let totalPieces = eff[IdxEffTotal]
570+ let amountLeftTotal = valueOrElse(getInteger(stakersAmountLeftKey), 0)
571+ let curPeriodDistribution = fraction(amountLeftTotal, (2 * totalPieces), (totalPieces + (max([100000, totalPieces]) * (MAXPERIOD - curPeriod))))
572+ let userTimeKey = keyLastClaimedTimeByUser(callerAddr)
573+ let lastUserTime = valueOrElse(getInteger(userTimeKey), issueTime)
574+ let userAmount = fraction(fraction(curPeriodDistribution, eff[IdxEffUser], totalPieces), (now - lastUserTime), (3 * YEARMILLIS))
575+ let userKey = keyStakersAmountPaidUser(callerAddr)
576+ $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)], prologResult)
577+ }
457578 }
458579
459580

github/deemru/w8io/026f985 
81.56 ms