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/+5AwkAAAIBAVQFByRtYXRjaDABIFWx2J9yh4Lv5eNbjawFq2XemkOhLxa7BfMat4el8cUYCQACAQINVW5rbm93biBjaGFpbgAVZGVmYXVsdFJlc3RBZGRyZXNzU3RyBAckbWF0Y2gwBQVjaGFpbgMJAAACAQFXBQckbWF0Y2gwAiMzUFFDdXZGYnZoNExrUFVucm5VMXozam5iQTFwOW0zV05odgMJAAACAQFUBQckbWF0Y2gwAiMzTXVta0dHenRDS0FYcFdEcXhrZGRvZnFYU1VicVFrdlNKeQkAAgECDVVua25vd24gY2hhaW4ADmFy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W5pZWQJAQ1jbGFpbUludGVybmFsAQkBEUBleHRyTmF0aXZlKDEwNjIpAQUEYWRkcgFpAQ1vblVuc3Rha2VMYW5kAQRhZGRyAwkBAiE9AggFAWkGY2FsbGVyBQ9zdGFraW5nQ29udHJhY3QJAAIBAhFQZXJtaXNzaW9uIGRlbmllZAkBDWNsYWltSW50ZXJuYWwBCQERQGV4dHJOYXRpdmUoMTA2MikBBQRhZGRyADE9pBo=", "height": 2646750, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AHMNGC3CAwwpLGD94tHVmMCM7HjxvbZtfp87jUJ3gu2m Next: 6eK19d1JP3qiR2a8AaK6PBGhZ9GXZL9EVFoU65mehnvT Diff:
OldNewDifferences
186186 let restUsd = assetBalance(restContract, usdtAssetId)
187187 let wlgUsd = assetBalance(wlgContract, usdtAssetId)
188188 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)))
191197 }
192198
193199
216222 let marketingAddrKey = "marketingAddr"
217223
218224 let teamAddrKey = "teamAddr"
225+
226+let profitAddrKey = "profitAddr"
219227
220228 let lastMarketingTimeKey = "lastClaimedTime_marketing"
221229
254262 }
255263
256264
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) = {
337266 let callerAddr = toString(caller)
338267 let now = lastBlock.timestamp
339268 let issueTime = valueOrErrorMessage(getInteger(wlgIssueTimeKey), "Not initialized")
357286 let lastUserTime = valueOrElse(getInteger(userTimeKey), issueTime)
358287 let userAmount = fraction(fraction(curPeriodDistribution, eff[IdxEffUser], totalPieces), (now - lastUserTime), (3 * YEARMILLIS))
359288 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)], prologResult)
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)
361290 }
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)
362386 }
363387
364388
366390 @Callable(i)
367391 func onStakeLand (addr) = if ((i.caller != stakingContract))
368392 then throw("Permission denied")
369- else $Tuple2([IntegerEntry(keyLastClaimedTimeByUser(addr), lastBlock.timestamp)], lastBlock.timestamp)
393+ else claimInternal(addressFromStringValue(addr))
370394
371395
372396
373397 @Callable(i)
374398 func onUnstakeLand (addr) = if ((i.caller != stakingContract))
375399 then throw("Permission denied")
376- else $Tuple2([DeleteEntry(keyLastClaimedTimeByUser(addr))], 0)
400+ else claimInternal(addressFromStringValue(addr))
377401
378402
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 func keyBlocked () = "contractsBlocked"
55
66
77 let IdxEffTotal = 0
88
99 let IdxEffUser = 1
1010
1111 let chain = take(drop(this.bytes, 1), 1)
1212
1313 let usdtAssetId = match chain {
1414 case _ =>
1515 if ((base58'2W' == $match0))
1616 then base58'9wc3LXNA4TEBsXyKtoLE9mrbDD7WMHXvXrCjZvabLAsi'
1717 else if ((base58'2T' == $match0))
1818 then base58'6mWwf9mZBjVgkC54idpyaZLQfAosD914wT8fGf2iiY63'
1919 else throw("Unknown chain")
2020 }
2121
2222 let defaultRestAddressStr = match chain {
2323 case _ =>
2424 if ((base58'2W' == $match0))
2525 then "3PQCuvFbvh4LkPUnrnU1z3jnbA1p9m3WNhv"
2626 else if ((base58'2T' == $match0))
2727 then "3MumkGGztCKAXpWDqxkddofqXSUbqQkvSJy"
2828 else throw("Unknown chain")
2929 }
3030
3131 let arbitrageDelay = match chain {
3232 case _ =>
3333 if ((base58'2W' == $match0))
3434 then 600000
3535 else if ((base58'2T' == $match0))
3636 then 60000
3737 else throw("Unknown chain")
3838 }
3939
4040 let SEP = "__"
4141
4242 let MULT6 = 1000000
4343
4444 let MULT8 = 100000000
4545
4646 let SSIZE = 25
4747
4848 let MSIZE = 100
4949
5050 let LSIZE = 225
5151
5252 let XLSIZE = 400
5353
5454 let XXLSIZE = 625
5555
5656 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
5757
5858
5959 let IdxCfgStakingDapp = 1
6060
6161 let IdxCfgEconomyDapp = 2
6262
6363 let IdxCfgWlgDapp = 4
6464
6565 let IdxCfgPuzzlePoolDapp = 5
6666
6767 func keyRestCfg () = "%s__restConfig"
6868
6969
7070 func keyRestAddress () = "%s__restAddr"
7171
7272
7373 func readRestCfgOrFail (rest) = split_4C(getStringOrFail(rest, keyRestCfg()), SEP)
7474
7575
7676 func getContractAddressOrFail (restCfg,idx) = valueOrErrorMessage(addressFromString(restCfg[idx]), ("Rest cfg doesn't contain address at index " + toString(idx)))
7777
7878
7979 let restContract = addressFromStringValue(valueOrElse(getString(this, keyRestAddress()), defaultRestAddressStr))
8080
8181 let restCfg = readRestCfgOrFail(restContract)
8282
8383 let stakingContract = getContractAddressOrFail(restCfg, IdxCfgStakingDapp)
8484
8585 let economyContract = getContractAddressOrFail(restCfg, IdxCfgEconomyDapp)
8686
8787 let wlgContract = getContractAddressOrFail(restCfg, IdxCfgWlgDapp)
8888
8989 let puzzlePoolContract = getContractAddressOrFail(restCfg, IdxCfgPuzzlePoolDapp)
9090
9191 let recLandSize = 1
9292
9393 func keyResProportions () = "resTypesProportions"
9494
9595
9696 func keyStakedLandsByOwner (ownerAddr) = ("stakedLandsByOwner_" + ownerAddr)
9797
9898
9999 let wlgIssuedAmountKey = "wlg_issuedAmount"
100100
101101 let wlgAssetIdKey = "wlg_assetId"
102102
103103 let wlgAssetId = valueOrErrorMessage(getBinary(wlgContract, wlgAssetIdKey), "Not initialized yet")
104104
105105 let idxWlgAmount = 0
106106
107107 let idxWlgPrice = 1
108108
109109 let idxWlgFunds = 2
110110
111111 func asInt (v) = match v {
112112 case n: Int =>
113113 n
114114 case _ =>
115115 throw("fail to cast into Int")
116116 }
117117
118118
119119 func numPiecesBySize (landSize) = match landSize {
120120 case _ =>
121121 if (("S" == $match0))
122122 then SSIZE
123123 else if (("M" == $match0))
124124 then MSIZE
125125 else if (("L" == $match0))
126126 then LSIZE
127127 else if (("XL" == $match0))
128128 then XLSIZE
129129 else if (("XXL" == $match0))
130130 then XXLSIZE
131131 else throw("Unknown land size")
132132 }
133133
134134
135135 func getVotingPower (userAddrStrOrEmpty) = {
136136 let props = split(valueOrElse(getString(stakingContract, keyResProportions()), "0_0_0_0_0_0"), "_")
137137 func adder (acc,item) = (acc + parseIntValue(item))
138138
139139 let totalPower = {
140140 let $l = props
141141 let $s = size($l)
142142 let $acc0 = 0
143143 func $f0_1 ($a,$i) = if (($i >= $s))
144144 then $a
145145 else adder($a, $l[$i])
146146
147147 func $f0_2 ($a,$i) = if (($i >= $s))
148148 then $a
149149 else throw("List size exceeds 6")
150150
151151 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6)
152152 }
153153 let usersPower = if ((userAddrStrOrEmpty == ""))
154154 then 0
155155 else {
156156 let landsStr = getString(stakingContract, keyStakedLandsByOwner(userAddrStrOrEmpty))
157157 let lands = if (isDefined(landsStr))
158158 then split_51C(value(landsStr), "_")
159159 else nil
160160 func oneLand (acc,landAssetId) = {
161161 let asset = value(assetInfo(fromBase58String(landAssetId)))
162162 let landSize = split(asset.description, "_")[recLandSize]
163163 (acc + numPiecesBySize(landSize))
164164 }
165165
166166 let $l = lands
167167 let $s = size($l)
168168 let $acc0 = 0
169169 func $f1_1 ($a,$i) = if (($i >= $s))
170170 then $a
171171 else oneLand($a, $l[$i])
172172
173173 func $f1_2 ($a,$i) = if (($i >= $s))
174174 then $a
175175 else throw("List size exceeds 100")
176176
177177 $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)
178178 }
179179 [totalPower, usersPower]
180180 }
181181
182182
183183 func getWlgStats () = {
184184 let issuedAmount = valueOrErrorMessage(getInteger(wlgContract, wlgIssuedAmountKey), "WLGOLD is not issued yet")
185185 let economyUsd = assetBalance(economyContract, usdtAssetId)
186186 let restUsd = assetBalance(restContract, usdtAssetId)
187187 let wlgUsd = assetBalance(wlgContract, usdtAssetId)
188188 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)))
191197 }
192198
193199
194200 let MULT14 = 100000000000000
195201
196202 let MARKETINGSHARE = 100000
197203
198204 let TEAMSHARE = 200000
199205
200206 let ACTIVITYSHARE = 100000
201207
202208 let PLAYERSHARE = 400000
203209
204210 let YEARMILLIS = 31557600000
205211
206212 let WEEKMILLIS = 604800000
207213
208214 let MAXPERIOD = 156
209215
210216 let A6 = 100000000
211217
212218 let B8 = 50000000
213219
214220 let wlgIssueTimeKey = "wlg_issueTime"
215221
216222 let marketingAddrKey = "marketingAddr"
217223
218224 let teamAddrKey = "teamAddr"
225+
226+let profitAddrKey = "profitAddr"
219227
220228 let lastMarketingTimeKey = "lastClaimedTime_marketing"
221229
222230 let lastTeamTimeKey = "lastClaimedTime_team"
223231
224232 let lastActivitiesTimeKey = "lastClaimedTime_activities"
225233
226234 func keyLastClaimedTimeByUser (addr) = ("lastClaimedTimeUser_" + addr)
227235
228236
229237 func keyLastArbTimeByUser (addr) = ("lastArbTimeUser_" + addr)
230238
231239
232240 let stakersAmountLeftKey = "stakersAmountLeft"
233241
234242 let stakersAmountPaidTotalKey = "stakersAmountPaidTotal"
235243
236244 func keyStakersAmountPaidUser (addr) = ("stakersAmountPaidUser_" + addr)
237245
238246
239247 func prolog () = if (valueOrElse(getBoolean(stakingContract, keyBlocked()), false))
240248 then throw("Contracts are under maintenance")
241249 else asInt(invoke(stakingContract, "saveLastTx", nil, nil))
242250
243251
244252 func getSwapLimit (addr) = {
245253 let lastTime = valueOrElse(getInteger(keyLastArbTimeByUser(addr)), 0)
246254 let now = lastBlock.timestamp
247255 if ((arbitrageDelay > (now - lastTime)))
248256 then throw("Arbitrages are possible once a 10 minutes")
249257 else {
250258 let pieces = getVotingPower(addr)[IdxEffUser]
251259 let pow8 = pow(pieces, 0, B8, 8, 8, CEILING)
252260 fraction(A6, pow8, MULT8)
253261 }
254262 }
255263
256264
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) = {
337266 let callerAddr = toString(caller)
338267 let now = lastBlock.timestamp
339268 let issueTime = valueOrErrorMessage(getInteger(wlgIssueTimeKey), "Not initialized")
340269 let lastMarketingTime = valueOrElse(getInteger(lastMarketingTimeKey), issueTime)
341270 let marketingAddr = addressFromStringValue(value(getString(marketingAddrKey)))
342271 let marketingAmount = fraction(fraction(MULT14, MARKETINGSHARE, MULT6), (now - lastMarketingTime), YEARMILLIS)
343272 let lastTeamTime = valueOrElse(getInteger(lastTeamTimeKey), issueTime)
344273 let teamAddr = addressFromStringValue(value(getString(teamAddrKey)))
345274 let teamAmount = fraction(fraction(MULT14, TEAMSHARE, MULT6), (now - lastTeamTime), (3 * YEARMILLIS))
346275 let lastActivitiesTime = valueOrElse(getInteger(lastActivitiesTimeKey), issueTime)
347276 let actAmount = fraction(fraction(MULT14, ACTIVITYSHARE, MULT6), (now - lastActivitiesTime), (3 * YEARMILLIS))
348277 let curPeriod = ((now - issueTime) / WEEKMILLIS)
349278 if ((curPeriod > (MAXPERIOD / 2)))
350279 then throw("Please modify contract for next 1.5 years, according to stats")
351280 else {
352281 let eff = getVotingPower(callerAddr)
353282 let totalPieces = eff[IdxEffTotal]
354283 let amountLeftTotal = valueOrElse(getInteger(stakersAmountLeftKey), 0)
355284 let curPeriodDistribution = fraction(amountLeftTotal, (2 * totalPieces), (totalPieces + (max([100000, totalPieces]) * (MAXPERIOD - curPeriod))))
356285 let userTimeKey = keyLastClaimedTimeByUser(callerAddr)
357286 let lastUserTime = valueOrElse(getInteger(userTimeKey), issueTime)
358287 let userAmount = fraction(fraction(curPeriodDistribution, eff[IdxEffUser], totalPieces), (now - lastUserTime), (3 * YEARMILLIS))
359288 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)], prologResult)
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)
361290 }
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)
362386 }
363387
364388
365389
366390 @Callable(i)
367391 func onStakeLand (addr) = if ((i.caller != stakingContract))
368392 then throw("Permission denied")
369- else $Tuple2([IntegerEntry(keyLastClaimedTimeByUser(addr), lastBlock.timestamp)], lastBlock.timestamp)
393+ else claimInternal(addressFromStringValue(addr))
370394
371395
372396
373397 @Callable(i)
374398 func onUnstakeLand (addr) = if ((i.caller != stakingContract))
375399 then throw("Permission denied")
376- else $Tuple2([DeleteEntry(keyLastClaimedTimeByUser(addr))], 0)
400+ else claimInternal(addressFromStringValue(addr))
377401
378402

github/deemru/w8io/026f985 
64.17 ms