tx · 5ufjCRb8mag4i6s7bRHKrZguwfyGD1SDYUYf2RLfgNvP

3NC5E3y11PtakmAUxN9Nfdvx7XjWsffcJrr:  -0.05000000 Waves

2020.09.09 11:53 [1169571] smart account 3NC5E3y11PtakmAUxN9Nfdvx7XjWsffcJrr > SELF 0.00000000 Waves

{ "type": 13, "id": "5ufjCRb8mag4i6s7bRHKrZguwfyGD1SDYUYf2RLfgNvP", "fee": 5000000, "feeAssetId": null, "timestamp": 1599641673539, "version": 2, "chainId": 84, "sender": "3NC5E3y11PtakmAUxN9Nfdvx7XjWsffcJrr", "senderPublicKey": "DuSyT6XMpGpexrez81rru35TfpmHJcYQP1WJxT9wjcry", "proofs": [ "64jR4AyV47LDq6BEQLK3NH4VzoNFz3xfXgm7uWE2HxFw4Q8A8oML86ykaohEGn3Rz4uwctgbADjxjrNswymMRYfE" ], "script": "base64:AAIDAAAAAAAAABYIARIDCgEBEgMKAQESAwoBARIDCgEBAAAABAAAAAANUkVDT1ZFUllQSEFTRQAAAAAAAAAAZAAAAAALUFJJQ0VPUkFDTEUCAAAAIzNONE5TN2Q0Sm85YTZGMTRMaUZVS0tZVmRVa2tmMmVQNFp4AQAAABJnZXREYXRhRW50cnlGb3JLZXkAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABeAUAAAAHJG1hdGNoMAUAAAABeAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAEVW5pdAAAAAAAAAAAAAkAAAIAAAABAgAAAAtNYXRjaCBlcnJvcgEAAAAMcGF5b3V0Q2FsbGVyAAAAAwAAAAZ0YXJnZXQAAAAGY2FsbGVyAAAABnBheW91dAkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAICAAAABWx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AGY2FsbGVyBAAAAA1sb25nc1RvdGFsS2V5CQABLAAAAAICAAAADGxvbmdzX3RvdGFsXwkAAaQAAAABBQAAAApsb25nVGFyZ2V0BAAAABtjdXJyZW50TG9uZ0Ftb3VudEZvckFkZHJlc3MJAQAAABJnZXREYXRhRW50cnlGb3JLZXkAAAABBQAAAA5sb25nQWRkcmVzc0tleQQAAAAMY3VycmVudExvbmdzCQEAAAASZ2V0RGF0YUVudHJ5Rm9yS2V5AAAAAQUAAAANbG9uZ3NUb3RhbEtleQQAAAAHcGF5bWVudAkBAAAAB2V4dHJhY3QAAAABCAUAAAABaQAAAAdwYXltZW50BAAAAAZhbW91bnQIBQAAAAdwYXltZW50AAAABmFtb3VudAMJAQAAAAlpc0RlZmluZWQAAAABCAUAAAAHcGF5bWVudAAAAAdhc3NldElkCQAAAgAAAAECAAAAJk9ubHkgV2F2ZXMgcGF5bWVudHMgYWxsb3dlZCBjdXJyZW50bHkhAwkAAGcAAAACCQAAZAAAAAIFAAAABmhlaWdodAUAAAANUkVDT1ZFUllQSEFTRQUAAAAKbG9uZ1RhcmdldAkAAAIAAAABAgAAAFNSZWNvdmVyeSBwaGFzZSBhY3RpdmUuIFlvdSBjYW4gbm8gbG9uZ2VyIGdvIGxvbmcgdG93YXJkcyB0aGlzIGxvbmcgdGFyZ2V0IC8gaGVpZ2h0IQkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAObG9uZ0FkZHJlc3NLZXkJAABkAAAAAgUAAAAbY3VycmVudExvbmdBbW91bnRGb3JBZGRyZXNzBQAAAAZhbW91bnQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAADWxvbmdzVG90YWxLZXkJAABkAAAAAgUAAAAMY3VycmVudExvbmdzBQAAAAZhbW91bnQFAAAAA25pbAAAAACCemgG", "height": 1169571, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3M46Ya3cDg9cHAK74GPjD4bFYQYmPMUXAk8dXMCFdAYF Next: 6GXZHfA8NZPnaFa5y2RYEZiTUwHuLPsUgrhYBaxeY9vG Diff:
OldNewDifferences
1414 }
1515 else if ($isInstanceOf(e, "Unit"))
1616 then 0
17- else throw()
17+ else throw("Match error")
1818 }
1919
2020
21-@Callable(g)
21+func g (h,i,j) = ScriptResult(WriteSet([DataEntry(((("long_" + toString(h)) + "_") + toString(i)), 0), DataEntry(((("short_" + toString(h)) + "_") + toString(i)), 0)]), TransferSet([ScriptTransfer(i, j, unit)]))
22+
23+
24+@Callable(k)
25+func withdraw (h) = if (((h + 1) > height))
26+ then throw("End of predictions for this height not reached yet!")
27+ else {
28+ let l = getIntegerValue(addressFromStringValue(b), ("price_" + toString(h)))
29+ if ((l == 0))
30+ then throw("Could not determine price at target height!")
31+ else {
32+ let i = k.caller
33+ let m = getIntegerValue(this, ("target_price_" + toString(h)))
34+ let n = c(("longs_total_" + toString(h)))
35+ let o = c(("shorts_total_" + toString(h)))
36+ if ((l > m))
37+ then {
38+ let p = c(((("long_" + toString(h)) + "_") + toString(i)))
39+ let j = ((p / (n + o)) * (n + o))
40+ g(h, i, j)
41+ }
42+ else if ((m > l))
43+ then {
44+ let p = c(((("short_" + toString(h)) + "_") + toString(i)))
45+ let j = ((p / (n + o)) * (n + o))
46+ g(h, i, j)
47+ }
48+ else {
49+ let q = c(((("long_" + toString(h)) + "_") + toString(i)))
50+ let r = c(((("short_" + toString(h)) + "_") + toString(i)))
51+ let j = (((q / n) * n) + ((r / o) * o))
52+ g(h, i, j)
53+ }
54+ }
55+ }
56+
57+
58+
59+@Callable(k)
2260 func initiate (h) = {
23- let i = getIntegerValue(addressFromStringValue(b), "price")
61+ let s = getIntegerValue(addressFromStringValue(b), "price")
2462 if (((height + a) >= h))
2563 then throw(("No new future instantiable for the given height: " + toString(h)))
26- else WriteSet([DataEntry(("target_price_" + toString(h)), i), DataEntry(("shorts_total_" + toString(h)), 0), DataEntry(("longs_total_" + toString(h)), 0)])
64+ else WriteSet([DataEntry(("target_price_" + toString(h)), s), DataEntry(("shorts_total_" + toString(h)), 0), DataEntry(("longs_total_" + toString(h)), 0)])
2765 }
2866
2967
3068
31-@Callable(g)
32-func short (j) = {
33- let k = toString(g.caller)
34- let l = ((("short_" + toString(j)) + "_") + k)
35- let m = ("shorts_total_" + toString(j))
36- let n = c(l)
37- let o = c(m)
38- let p = extract(g.payment)
39- let q = p.amount
40- if (isDefined(p.assetId))
41- then throw("Only Waves payments allowed currently!")
42- else if (((height + a) >= j))
43- then throw("Recovery phase active. You can no longer go short towards this short target / height!")
44- else WriteSet([DataEntry(l, (n + q)), DataEntry(m, (o + q))])
69+@Callable(k)
70+func short (t) = {
71+ let m = c(("target_price_" + toString(t)))
72+ if ((m == 0))
73+ then throw("Target not initialized!")
74+ else {
75+ let i = toString(k.caller)
76+ let u = ((("short_" + toString(t)) + "_") + i)
77+ let v = ("shorts_total_" + toString(t))
78+ let w = c(u)
79+ let x = c(v)
80+ let y = extract(k.payment)
81+ let z = y.amount
82+ if (isDefined(y.assetId))
83+ then throw("Only Waves payments allowed currently!")
84+ else if (((height + a) >= t))
85+ then throw("Recovery phase active. You can no longer go short towards this short target / height!")
86+ else WriteSet([DataEntry(u, (w + z)), DataEntry(v, (x + z))])
87+ }
4588 }
4689
4790
4891
49-@Callable(g)
50-func long (r) = {
51- let k = toString(g.caller)
52- let s = ((("long_" + toString(r)) + "_") + k)
53- let t = ("longs_total_" + toString(r))
54- let u = c(s)
55- let v = c(t)
56- let p = extract(g.payment)
57- let q = p.amount
58- if (isDefined(p.assetId))
59- then throw("Only Waves payments allowed currently!")
60- else if (((height + a) >= r))
61- then throw("Recovery phase active. You can no longer go long towards this long target / height!")
62- else WriteSet([DataEntry(s, (u + q)), DataEntry(t, (v + q))])
92+@Callable(k)
93+func long (A) = {
94+ let m = c(("target_price_" + toString(A)))
95+ if ((m == 0))
96+ then throw("Target not initialized!")
97+ else {
98+ let i = toString(k.caller)
99+ let B = ((("long_" + toString(A)) + "_") + i)
100+ let C = ("longs_total_" + toString(A))
101+ let D = c(B)
102+ let E = c(C)
103+ let y = extract(k.payment)
104+ let z = y.amount
105+ if (isDefined(y.assetId))
106+ then throw("Only Waves payments allowed currently!")
107+ else if (((height + a) >= A))
108+ then throw("Recovery phase active. You can no longer go long towards this long target / height!")
109+ else WriteSet([DataEntry(B, (D + z)), DataEntry(C, (E + z))])
110+ }
63111 }
64112
65113
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let a = 100
55
66 let b = "3N4NS7d4Jo9a6F14LiFUKKYVdUkkf2eP4Zx"
77
88 func c (d) = {
99 let e = getInteger(this, d)
1010 if ($isInstanceOf(e, "Int"))
1111 then {
1212 let f = e
1313 f
1414 }
1515 else if ($isInstanceOf(e, "Unit"))
1616 then 0
17- else throw()
17+ else throw("Match error")
1818 }
1919
2020
21-@Callable(g)
21+func g (h,i,j) = ScriptResult(WriteSet([DataEntry(((("long_" + toString(h)) + "_") + toString(i)), 0), DataEntry(((("short_" + toString(h)) + "_") + toString(i)), 0)]), TransferSet([ScriptTransfer(i, j, unit)]))
22+
23+
24+@Callable(k)
25+func withdraw (h) = if (((h + 1) > height))
26+ then throw("End of predictions for this height not reached yet!")
27+ else {
28+ let l = getIntegerValue(addressFromStringValue(b), ("price_" + toString(h)))
29+ if ((l == 0))
30+ then throw("Could not determine price at target height!")
31+ else {
32+ let i = k.caller
33+ let m = getIntegerValue(this, ("target_price_" + toString(h)))
34+ let n = c(("longs_total_" + toString(h)))
35+ let o = c(("shorts_total_" + toString(h)))
36+ if ((l > m))
37+ then {
38+ let p = c(((("long_" + toString(h)) + "_") + toString(i)))
39+ let j = ((p / (n + o)) * (n + o))
40+ g(h, i, j)
41+ }
42+ else if ((m > l))
43+ then {
44+ let p = c(((("short_" + toString(h)) + "_") + toString(i)))
45+ let j = ((p / (n + o)) * (n + o))
46+ g(h, i, j)
47+ }
48+ else {
49+ let q = c(((("long_" + toString(h)) + "_") + toString(i)))
50+ let r = c(((("short_" + toString(h)) + "_") + toString(i)))
51+ let j = (((q / n) * n) + ((r / o) * o))
52+ g(h, i, j)
53+ }
54+ }
55+ }
56+
57+
58+
59+@Callable(k)
2260 func initiate (h) = {
23- let i = getIntegerValue(addressFromStringValue(b), "price")
61+ let s = getIntegerValue(addressFromStringValue(b), "price")
2462 if (((height + a) >= h))
2563 then throw(("No new future instantiable for the given height: " + toString(h)))
26- else WriteSet([DataEntry(("target_price_" + toString(h)), i), DataEntry(("shorts_total_" + toString(h)), 0), DataEntry(("longs_total_" + toString(h)), 0)])
64+ else WriteSet([DataEntry(("target_price_" + toString(h)), s), DataEntry(("shorts_total_" + toString(h)), 0), DataEntry(("longs_total_" + toString(h)), 0)])
2765 }
2866
2967
3068
31-@Callable(g)
32-func short (j) = {
33- let k = toString(g.caller)
34- let l = ((("short_" + toString(j)) + "_") + k)
35- let m = ("shorts_total_" + toString(j))
36- let n = c(l)
37- let o = c(m)
38- let p = extract(g.payment)
39- let q = p.amount
40- if (isDefined(p.assetId))
41- then throw("Only Waves payments allowed currently!")
42- else if (((height + a) >= j))
43- then throw("Recovery phase active. You can no longer go short towards this short target / height!")
44- else WriteSet([DataEntry(l, (n + q)), DataEntry(m, (o + q))])
69+@Callable(k)
70+func short (t) = {
71+ let m = c(("target_price_" + toString(t)))
72+ if ((m == 0))
73+ then throw("Target not initialized!")
74+ else {
75+ let i = toString(k.caller)
76+ let u = ((("short_" + toString(t)) + "_") + i)
77+ let v = ("shorts_total_" + toString(t))
78+ let w = c(u)
79+ let x = c(v)
80+ let y = extract(k.payment)
81+ let z = y.amount
82+ if (isDefined(y.assetId))
83+ then throw("Only Waves payments allowed currently!")
84+ else if (((height + a) >= t))
85+ then throw("Recovery phase active. You can no longer go short towards this short target / height!")
86+ else WriteSet([DataEntry(u, (w + z)), DataEntry(v, (x + z))])
87+ }
4588 }
4689
4790
4891
49-@Callable(g)
50-func long (r) = {
51- let k = toString(g.caller)
52- let s = ((("long_" + toString(r)) + "_") + k)
53- let t = ("longs_total_" + toString(r))
54- let u = c(s)
55- let v = c(t)
56- let p = extract(g.payment)
57- let q = p.amount
58- if (isDefined(p.assetId))
59- then throw("Only Waves payments allowed currently!")
60- else if (((height + a) >= r))
61- then throw("Recovery phase active. You can no longer go long towards this long target / height!")
62- else WriteSet([DataEntry(s, (u + q)), DataEntry(t, (v + q))])
92+@Callable(k)
93+func long (A) = {
94+ let m = c(("target_price_" + toString(A)))
95+ if ((m == 0))
96+ then throw("Target not initialized!")
97+ else {
98+ let i = toString(k.caller)
99+ let B = ((("long_" + toString(A)) + "_") + i)
100+ let C = ("longs_total_" + toString(A))
101+ let D = c(B)
102+ let E = c(C)
103+ let y = extract(k.payment)
104+ let z = y.amount
105+ if (isDefined(y.assetId))
106+ then throw("Only Waves payments allowed currently!")
107+ else if (((height + a) >= A))
108+ then throw("Recovery phase active. You can no longer go long towards this long target / height!")
109+ else WriteSet([DataEntry(B, (D + z)), DataEntry(C, (E + z))])
110+ }
63111 }
64112
65113

github/deemru/w8io/169f3d6 
29.94 ms