tx · 2LGc8cRxx5izekjMvJpWnuXndk2Kn8twtdcj91wAbyEy
3N8XBzcbxt5snTdkqVSobDjtDGbTns27DdY: -0.01400000 Waves
2020.10.08 21:48 [1211971] smart account 3N8XBzcbxt5snTdkqVSobDjtDGbTns27DdY > SELF 0.00000000 Waves
{
"type": 13,
"id": "2LGc8cRxx5izekjMvJpWnuXndk2Kn8twtdcj91wAbyEy",
"fee": 1400000,
"feeAssetId": null,
"timestamp": 1602182895462,
"version": 2,
"chainId": 84,
"sender": "3N8XBzcbxt5snTdkqVSobDjtDGbTns27DdY",
"senderPublicKey": "HhWoKsFPjXVx9nYfPydpV9BwLmuUdJyJ8ydtyVJVxg9Z",
"proofs": [
"6793qyVPMXhEbrgUhULzJwh7QuiJPg4azbZrNwLcHjEaPLaFuc69eGk1PyHetoD5bw5w6yL9V9PmNJNomiY4C2BN"
],
"script": "base64:AAIDAAAAAAAAAAkIARIAEgMKAQEAAAAEAAAAAA9mcm9zdEJsb2NrQ291bnQAAAAAAAAAAGQAAAAAB3BlcmNlbnQAAAAAAAAAABQBAAAADGdldFN0YXRpc3RpYwAAAAAEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwIAAAAJc3RhdGlzdGljAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWECAAAACzBfMF8wXzBfMF8wAQAAAAdnZXRVc2VyAAAAAQAAAAR1c2VyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAABHVzZXIDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQIAAAAXMF8wXzBfMF8wXzBfMF8wXzBfMF8wXzAAAAACAAAAAWkBAAAAB2RlcG9zaXQAAAAABAAAAANwbXQJAQAAAAdleHRyYWN0AAAAAQgFAAAAAWkAAAAHcGF5bWVudAMJAQAAAAlpc0RlZmluZWQAAAABCAU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AAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAABAAAAIPgb6qyNYjD3bXWOBO2BlnqNMLOmuqdvK91V6Ckp5DxkBjanoik=",
"height": 1211971,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: 3Wmo52xxpKt3aLTa4YiQaimAovU8QHDnSpHrSpecwNoE
Next: DfkYxUiHqmeKLmeVxTJQYH1JdJ3fsR4sPFTtkPQCfu4w
Diff:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 3 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
| 4 | + | let frostBlockCount = 100 |
---|
| 5 | + | |
---|
| 6 | + | let percent = 20 |
---|
| 7 | + | |
---|
| 8 | + | func getStatistic () = match getString(this, "statistic") { |
---|
| 9 | + | case a: String => |
---|
| 10 | + | a |
---|
| 11 | + | case _ => |
---|
| 12 | + | "0_0_0_0_0_0" |
---|
| 13 | + | } |
---|
| 14 | + | |
---|
| 15 | + | |
---|
| 16 | + | func getUser (user) = match getString(this, user) { |
---|
| 17 | + | case a: String => |
---|
| 18 | + | a |
---|
| 19 | + | case _ => |
---|
| 20 | + | "0_0_0_0_0_0_0_0_0_0_0_0" |
---|
| 21 | + | } |
---|
4 | 22 | | |
---|
5 | 23 | | |
---|
6 | 24 | | @Callable(i) |
---|
7 | 25 | | func deposit () = { |
---|
8 | 26 | | let pmt = extract(i.payment) |
---|
9 | | - | let blockHeight = lastBlock.height |
---|
10 | 27 | | if (isDefined(pmt.assetId)) |
---|
11 | 28 | | then throw("can hodl waves only at the moment") |
---|
12 | 29 | | else { |
---|
13 | 30 | | let currentKey = toBase58String(i.caller.bytes) |
---|
14 | | - | if (!(isDefined(getString(this, currentKey)))) |
---|
15 | | - | then WriteSet([DataEntry(currentKey, (((toString(((pmt.amount / 100) * 120)) + "_") + toString(blockHeight)) + "_0"))]) |
---|
| 31 | + | let statistic = split(getStatistic(), "_") |
---|
| 32 | + | if ((currentKey == "3N8XBzcbxt5snTdkqVSobDjtDGbTns27DdY")) |
---|
| 33 | + | then WriteSet(nil) |
---|
16 | 34 | | else { |
---|
17 | | - | let oldData = split( match getString(this, currentKey) { |
---|
18 | | - | case str: String => |
---|
19 | | - | str |
---|
20 | | - | case _ => |
---|
21 | | - | throw("error") |
---|
22 | | - | }, "_") |
---|
23 | | - | let currentAmount = parseIntValue(oldData[0]) |
---|
24 | | - | WriteSet([DataEntry(currentKey, (((toString((currentAmount + ((pmt.amount / 100) * 120))) + "_") + toString(blockHeight)) + "_0"))]) |
---|
| 35 | + | let blockHeight = lastBlock.height |
---|
| 36 | + | let sum = ((pmt.amount / 100) * (100 + percent)) |
---|
| 37 | + | let user = split(getUser(currentKey), "_") |
---|
| 38 | + | let userData2 = parseIntValue(user[2]) |
---|
| 39 | + | WriteSet([DataEntry("statistic", (((((((((toString((parseIntValue(statistic[0]) + pmt.amount)) + "_") + toString((parseIntValue(statistic[1]) + 1))) + "_") + statistic[2]) + "_") + statistic[3]) + "_") + statistic[4]) + statistic[5])), DataEntry(currentKey, (((((((((((((((((((((toString((parseIntValue(user[0]) + pmt.amount)) + "_") + toString((parseIntValue(user[1]) + sum))) + "_") + toString((userData2 + sum))) + "_") + toString(((userData2 + sum) / frostBlockCount))) + "_") + toString(blockHeight)) + user[5]) + "_") + user[6]) + "_") + user[7]) + "_") + user[8]) + "_") + user[9]) + "_") + user[10]) + "_") + user[11]))]) |
---|
25 | 40 | | } |
---|
26 | 41 | | } |
---|
27 | 42 | | } |
---|
|
30 | 45 | | |
---|
31 | 46 | | @Callable(i) |
---|
32 | 47 | | func withdraw (amount) = { |
---|
33 | | - | let frostBlockCount = 100 |
---|
34 | 48 | | let currentKey = toBase58String(i.caller.bytes) |
---|
35 | | - | let oldData = split( match getString(this, currentKey) { |
---|
36 | | - | case str: String => |
---|
37 | | - | str |
---|
38 | | - | case _ => |
---|
39 | | - | throw("error") |
---|
40 | | - | }, "_") |
---|
41 | | - | let oldAmount = parseIntValue(oldData[0]) |
---|
| 49 | + | let user = split(getUser(currentKey), "_") |
---|
| 50 | + | let statistic = split(getStatistic(), "_") |
---|
| 51 | + | let oldAmount = parseIntValue(user[2]) |
---|
42 | 52 | | let newAmount = (oldAmount - amount) |
---|
43 | 53 | | let blockHeight = lastBlock.height |
---|
44 | | - | let frostBlockHeight = parseIntValue(oldData[1]) |
---|
| 54 | + | let frostBlockHeight = parseIntValue(user[1]) |
---|
45 | 55 | | let defrostBlockHeight = (frostBlockHeight + frostBlockCount) |
---|
46 | | - | let sumWithdraw = (parseIntValue(oldData[2]) + amount) |
---|
| 56 | + | let sumWithdraw = (parseIntValue(user[2]) + amount) |
---|
47 | 57 | | let maxWithdraw = if ((blockHeight >= defrostBlockHeight)) |
---|
48 | 58 | | then oldAmount |
---|
49 | 59 | | else ((frostBlockCount - (defrostBlockHeight - blockHeight)) * (oldAmount / frostBlockCount)) |
---|
|
53 | 63 | | then throw(("Max sum: " + toString(maxWithdraw))) |
---|
54 | 64 | | else if ((0 > newAmount)) |
---|
55 | 65 | | then throw("Not enough balance") |
---|
56 | | - | else ScriptResult(WriteSet([DataEntry(currentKey, ((((((((((((toString(newAmount) + "_") + oldData[1]) + "_") + toString(sumWithdraw)) + "_xxxxxxxxxx_from-test(maxWithdraw):") + toString(maxWithdraw)) + "_from-test(amount):") + toString(amount)) + "_from-test(block-after-deposit):") + toString((frostBlockCount - (defrostBlockHeight - blockHeight)))) + "_from-test(sum-for-block):") + toString((oldAmount / frostBlockCount))))]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) |
---|
| 66 | + | else ScriptResult(WriteSet([DataEntry("statistic", (((((((((statistic[0] + "_") + statistic[1]) + "_") + toString((parseIntValue(statistic[2]) + amount))) + "_") + toString((parseIntValue(statistic[1]) + 1))) + "_") + statistic[4]) + statistic[5])), DataEntry(currentKey, ((((((((((((((((((((((user[0] + "_") + user[1]) + "_") + toString(newAmount)) + "_") + user[3]) + "_") + toString(blockHeight)) + "_") + toString((parseIntValue(user[5]) + amount))) + "_") + toString((parseIntValue(user[6]) + amount))) + "_") + user[7]) + "_") + user[8]) + "_") + user[9]) + "_") + user[10]) + "_") + user[11]))]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) |
---|
57 | 67 | | } |
---|
58 | 68 | | |
---|
59 | 69 | | |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 3 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
| 4 | + | let frostBlockCount = 100 |
---|
| 5 | + | |
---|
| 6 | + | let percent = 20 |
---|
| 7 | + | |
---|
| 8 | + | func getStatistic () = match getString(this, "statistic") { |
---|
| 9 | + | case a: String => |
---|
| 10 | + | a |
---|
| 11 | + | case _ => |
---|
| 12 | + | "0_0_0_0_0_0" |
---|
| 13 | + | } |
---|
| 14 | + | |
---|
| 15 | + | |
---|
| 16 | + | func getUser (user) = match getString(this, user) { |
---|
| 17 | + | case a: String => |
---|
| 18 | + | a |
---|
| 19 | + | case _ => |
---|
| 20 | + | "0_0_0_0_0_0_0_0_0_0_0_0" |
---|
| 21 | + | } |
---|
4 | 22 | | |
---|
5 | 23 | | |
---|
6 | 24 | | @Callable(i) |
---|
7 | 25 | | func deposit () = { |
---|
8 | 26 | | let pmt = extract(i.payment) |
---|
9 | | - | let blockHeight = lastBlock.height |
---|
10 | 27 | | if (isDefined(pmt.assetId)) |
---|
11 | 28 | | then throw("can hodl waves only at the moment") |
---|
12 | 29 | | else { |
---|
13 | 30 | | let currentKey = toBase58String(i.caller.bytes) |
---|
14 | | - | if (!(isDefined(getString(this, currentKey)))) |
---|
15 | | - | then WriteSet([DataEntry(currentKey, (((toString(((pmt.amount / 100) * 120)) + "_") + toString(blockHeight)) + "_0"))]) |
---|
| 31 | + | let statistic = split(getStatistic(), "_") |
---|
| 32 | + | if ((currentKey == "3N8XBzcbxt5snTdkqVSobDjtDGbTns27DdY")) |
---|
| 33 | + | then WriteSet(nil) |
---|
16 | 34 | | else { |
---|
17 | | - | let oldData = split( match getString(this, currentKey) { |
---|
18 | | - | case str: String => |
---|
19 | | - | str |
---|
20 | | - | case _ => |
---|
21 | | - | throw("error") |
---|
22 | | - | }, "_") |
---|
23 | | - | let currentAmount = parseIntValue(oldData[0]) |
---|
24 | | - | WriteSet([DataEntry(currentKey, (((toString((currentAmount + ((pmt.amount / 100) * 120))) + "_") + toString(blockHeight)) + "_0"))]) |
---|
| 35 | + | let blockHeight = lastBlock.height |
---|
| 36 | + | let sum = ((pmt.amount / 100) * (100 + percent)) |
---|
| 37 | + | let user = split(getUser(currentKey), "_") |
---|
| 38 | + | let userData2 = parseIntValue(user[2]) |
---|
| 39 | + | WriteSet([DataEntry("statistic", (((((((((toString((parseIntValue(statistic[0]) + pmt.amount)) + "_") + toString((parseIntValue(statistic[1]) + 1))) + "_") + statistic[2]) + "_") + statistic[3]) + "_") + statistic[4]) + statistic[5])), DataEntry(currentKey, (((((((((((((((((((((toString((parseIntValue(user[0]) + pmt.amount)) + "_") + toString((parseIntValue(user[1]) + sum))) + "_") + toString((userData2 + sum))) + "_") + toString(((userData2 + sum) / frostBlockCount))) + "_") + toString(blockHeight)) + user[5]) + "_") + user[6]) + "_") + user[7]) + "_") + user[8]) + "_") + user[9]) + "_") + user[10]) + "_") + user[11]))]) |
---|
25 | 40 | | } |
---|
26 | 41 | | } |
---|
27 | 42 | | } |
---|
28 | 43 | | |
---|
29 | 44 | | |
---|
30 | 45 | | |
---|
31 | 46 | | @Callable(i) |
---|
32 | 47 | | func withdraw (amount) = { |
---|
33 | | - | let frostBlockCount = 100 |
---|
34 | 48 | | let currentKey = toBase58String(i.caller.bytes) |
---|
35 | | - | let oldData = split( match getString(this, currentKey) { |
---|
36 | | - | case str: String => |
---|
37 | | - | str |
---|
38 | | - | case _ => |
---|
39 | | - | throw("error") |
---|
40 | | - | }, "_") |
---|
41 | | - | let oldAmount = parseIntValue(oldData[0]) |
---|
| 49 | + | let user = split(getUser(currentKey), "_") |
---|
| 50 | + | let statistic = split(getStatistic(), "_") |
---|
| 51 | + | let oldAmount = parseIntValue(user[2]) |
---|
42 | 52 | | let newAmount = (oldAmount - amount) |
---|
43 | 53 | | let blockHeight = lastBlock.height |
---|
44 | | - | let frostBlockHeight = parseIntValue(oldData[1]) |
---|
| 54 | + | let frostBlockHeight = parseIntValue(user[1]) |
---|
45 | 55 | | let defrostBlockHeight = (frostBlockHeight + frostBlockCount) |
---|
46 | | - | let sumWithdraw = (parseIntValue(oldData[2]) + amount) |
---|
| 56 | + | let sumWithdraw = (parseIntValue(user[2]) + amount) |
---|
47 | 57 | | let maxWithdraw = if ((blockHeight >= defrostBlockHeight)) |
---|
48 | 58 | | then oldAmount |
---|
49 | 59 | | else ((frostBlockCount - (defrostBlockHeight - blockHeight)) * (oldAmount / frostBlockCount)) |
---|
50 | 60 | | if ((0 > amount)) |
---|
51 | 61 | | then throw("Can't withdraw negative amount") |
---|
52 | 62 | | else if ((amount > maxWithdraw)) |
---|
53 | 63 | | then throw(("Max sum: " + toString(maxWithdraw))) |
---|
54 | 64 | | else if ((0 > newAmount)) |
---|
55 | 65 | | then throw("Not enough balance") |
---|
56 | | - | else ScriptResult(WriteSet([DataEntry(currentKey, ((((((((((((toString(newAmount) + "_") + oldData[1]) + "_") + toString(sumWithdraw)) + "_xxxxxxxxxx_from-test(maxWithdraw):") + toString(maxWithdraw)) + "_from-test(amount):") + toString(amount)) + "_from-test(block-after-deposit):") + toString((frostBlockCount - (defrostBlockHeight - blockHeight)))) + "_from-test(sum-for-block):") + toString((oldAmount / frostBlockCount))))]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) |
---|
| 66 | + | else ScriptResult(WriteSet([DataEntry("statistic", (((((((((statistic[0] + "_") + statistic[1]) + "_") + toString((parseIntValue(statistic[2]) + amount))) + "_") + toString((parseIntValue(statistic[1]) + 1))) + "_") + statistic[4]) + statistic[5])), DataEntry(currentKey, ((((((((((((((((((((((user[0] + "_") + user[1]) + "_") + toString(newAmount)) + "_") + user[3]) + "_") + toString(blockHeight)) + "_") + toString((parseIntValue(user[5]) + amount))) + "_") + toString((parseIntValue(user[6]) + amount))) + "_") + user[7]) + "_") + user[8]) + "_") + user[9]) + "_") + user[10]) + "_") + user[11]))]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) |
---|
57 | 67 | | } |
---|
58 | 68 | | |
---|
59 | 69 | | |
---|
60 | 70 | | @Verifier(tx) |
---|
61 | 71 | | func verify () = match tx { |
---|
62 | 72 | | case d: SetScriptTransaction => |
---|
63 | 73 | | sigVerify(tx.bodyBytes, tx.proofs[0], base58'HhWoKsFPjXVx9nYfPydpV9BwLmuUdJyJ8ydtyVJVxg9Z') |
---|
64 | 74 | | case _ => |
---|
65 | 75 | | true |
---|
66 | 76 | | } |
---|
67 | 77 | | |
---|