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:AAIDAAAAAAAAABYIARIDCgEBEgMKAQESAwoBARIDCgEBAAAABAAAAAANUkVDT1ZFUllQSEFTRQAAAAAAAAAAZAAAAAALUFJJQ0VPUkFDTEUCAAAAIzNONE5TN2Q0Sm85YTZGMTRMaUZVS0tZVmRVa2tmMmVQNFp4AQAAABJnZXREYXRhRW50cnlGb3JLZXkAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABeAUAAAAHJG1hdGNoMAUAAAABeAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAEVW5pdAAAAAAAAAAAAAkAAAIAAAABAgAAAAtNYXRjaCBlcnJvcgEAAAAMcGF5b3V0Q2FsbGVyAAAAAwAAAAZ0YXJnZXQAAAAGY2FsbGVyAAAABnBheW91dAkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAICAAAABWxv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GY2FsbGVyBAAAAA1sb25nc1RvdGFsS2V5CQABLAAAAAICAAAADGxvbmdzX3RvdGFsXwkAAaQAAAABBQAAAApsb25nVGFyZ2V0BAAAABtjdXJyZW50TG9uZ0Ftb3VudEZvckFkZHJlc3MJAQAAABJnZXREYXRhRW50cnlGb3JLZXkAAAABBQAAAA5sb25nQWRkcmVzc0tleQQAAAAMY3VycmVudExvbmdzCQEAAAASZ2V0RGF0YUVudHJ5Rm9yS2V5AAAAAQUAAAANbG9uZ3NUb3RhbEtleQQAAAAHcGF5bWVudAkBAAAAB2V4dHJhY3QAAAABCAUAAAABaQAAAAdwYXltZW50BAAAAAZhbW91bnQIBQAAAAdwYXltZW50AAAABmFtb3VudAMJAQAAAAlpc0RlZmluZWQAAAABCAUAAAAHcGF5bWVudAAAAAdhc3NldElkCQAAAgAAAAECAAAAJk9ubHkgV2F2ZXMgcGF5bWVudHMgYWxsb3dlZCBjdXJyZW50bHkhAwkAAGcAAAACCQAAZAAAAAIFAAAABmhlaWdodAUAAAANUkVDT1ZFUllQSEFTRQUAAAAKbG9uZ1RhcmdldAkAAAIAAAABAgAAAFNSZWNvdmVyeSBwaGFzZSBhY3RpdmUuIFlvdSBjYW4gbm8gbG9uZ2VyIGdvIGxvbmcgdG93YXJkcyB0aGlzIGxvbmcgdGFyZ2V0IC8gaGVpZ2h0IQkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAObG9uZ0FkZHJlc3NLZXkJAABkAAAAAgUAAAAbY3VycmVudExvbmdBbW91bnRGb3JBZGRyZXNzBQAAAAZhbW91bnQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAADWxvbmdzVG90YWxLZXkJAABkAAAAAgUAAAAMY3VycmVudExvbmdzBQAAAAZhbW91bnQFAAAAA25pbAAAAACCemgG", "height": 1169571, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3M46Ya3cDg9cHAK74GPjD4bFYQYmPMUXAk8dXMCFdAYF Next: 6GXZHfA8NZPnaFa5y2RYEZiTUwHuLPsUgrhYBaxeY9vG Diff:
Old | New | Differences | |
---|---|---|---|
14 | 14 | } | |
15 | 15 | else if ($isInstanceOf(e, "Unit")) | |
16 | 16 | then 0 | |
17 | - | else throw() | |
17 | + | else throw("Match error") | |
18 | 18 | } | |
19 | 19 | ||
20 | 20 | ||
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) | |
22 | 60 | func initiate (h) = { | |
23 | - | let | |
61 | + | let s = getIntegerValue(addressFromStringValue(b), "price") | |
24 | 62 | if (((height + a) >= h)) | |
25 | 63 | then throw(("No new future instantiable for the given height: " + toString(h))) | |
26 | - | else WriteSet([DataEntry(("target_price_" + toString(h)), | |
64 | + | else WriteSet([DataEntry(("target_price_" + toString(h)), s), DataEntry(("shorts_total_" + toString(h)), 0), DataEntry(("longs_total_" + toString(h)), 0)]) | |
27 | 65 | } | |
28 | 66 | ||
29 | 67 | ||
30 | 68 | ||
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 | + | } | |
45 | 88 | } | |
46 | 89 | ||
47 | 90 | ||
48 | 91 | ||
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 | + | } | |
63 | 111 | } | |
64 | 112 | ||
65 | 113 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = 100 | |
5 | 5 | ||
6 | 6 | let b = "3N4NS7d4Jo9a6F14LiFUKKYVdUkkf2eP4Zx" | |
7 | 7 | ||
8 | 8 | func c (d) = { | |
9 | 9 | let e = getInteger(this, d) | |
10 | 10 | if ($isInstanceOf(e, "Int")) | |
11 | 11 | then { | |
12 | 12 | let f = e | |
13 | 13 | f | |
14 | 14 | } | |
15 | 15 | else if ($isInstanceOf(e, "Unit")) | |
16 | 16 | then 0 | |
17 | - | else throw() | |
17 | + | else throw("Match error") | |
18 | 18 | } | |
19 | 19 | ||
20 | 20 | ||
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) | |
22 | 60 | func initiate (h) = { | |
23 | - | let | |
61 | + | let s = getIntegerValue(addressFromStringValue(b), "price") | |
24 | 62 | if (((height + a) >= h)) | |
25 | 63 | then throw(("No new future instantiable for the given height: " + toString(h))) | |
26 | - | else WriteSet([DataEntry(("target_price_" + toString(h)), | |
64 | + | else WriteSet([DataEntry(("target_price_" + toString(h)), s), DataEntry(("shorts_total_" + toString(h)), 0), DataEntry(("longs_total_" + toString(h)), 0)]) | |
27 | 65 | } | |
28 | 66 | ||
29 | 67 | ||
30 | 68 | ||
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 | + | } | |
45 | 88 | } | |
46 | 89 | ||
47 | 90 | ||
48 | 91 | ||
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 | + | } | |
63 | 111 | } | |
64 | 112 | ||
65 | 113 |
github/deemru/w8io/169f3d6 29.94 ms ◑