tx · C68ZfrTy2wxS19nEA25EyD4insSHB6HcuXBaTmGYqpyF 3N56nks16Jc8AqtjwsZodYaGekvnUDK6UvY: -0.01000000 Waves 2019.09.20 17:36 [684774] smart account 3N56nks16Jc8AqtjwsZodYaGekvnUDK6UvY > SELF 0.00000000 Waves
{ "type": 13, "id": "C68ZfrTy2wxS19nEA25EyD4insSHB6HcuXBaTmGYqpyF", "fee": 1000000, "feeAssetId": null, "timestamp": 1568990217492, "version": 1, "sender": "3N56nks16Jc8AqtjwsZodYaGekvnUDK6UvY", "senderPublicKey": "5a2ApQ4qQoKZVxFsukvYNzUyDwPF8FZCKhEaLFps2eeF", "proofs": [ "xhemSbLQQ8xobLbHNNncpRpH6yJYfPizvNm3mCcGNdAGcRV3nLqy2XTPazsa1fwEpHcWUkhX7wi4keKjLFGkJBv" ], "script": "base64:AAIDAAAAAAAAAA0IARIAEgASAwoBARIAAAAACAAAAAAFb3duZXIBAAAAGgFUcDRNylIF8rMhayYjpver9p7zXEqccbKCAAAAAAhJZFRva2VuQQIAAAAFV0FWRVMAAAAACElkVG9rZW5CAgAAACxFcTVZYzJ0Z2p4ZEUyQmVRbVdjeGlzOVJLRENrVXJhRG9UUmR5bXJqUHVhMwAAAAAJY29taXNzaW9uAAAAAAAAAAAFAAAAAAd2ZXJzaW9uAgAAAAUwLjAuMAEAAAAHYXNzZXRJZAAAAAEAAAAFYXNzZXQDCQAAAAAAAAIFAAAABWFzc2V0AgAAAAVXQVZFUwUAAAAEdW5pdAkAAlkAAAABBQAAAAVhc3NldAAAAAANYXNzZXRJZFRva2VuQQkBAAAAB2Fzc2V0SWQAAAABBQAAAAhJZFRva2VuQQAAAAANYXNzZXRJZFRva2VuQgkBAAAAB2Fzc2V0SWQAAAABBQAAAAhJZFRva2VuQgAAAAQAAAAKY29udGV4dE9iagEAAAAEZnVuZAAAAAAEAAAAB3BheW1lbnQEAAAAByRtYXRjaDAIBQAAAApjb250ZXh0T2JqAAAAB3BheW1lbnQDCQAAAQAA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FRva2VuQQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAAKY29udGV4dE9iagAAAAZjYWxsZXIFAAAADUJhbGFuY2VUb2tlbkIFAAAADWFzc2V0SWRUb2tlbkIFAAAAA25pbAkAAAIAAAABAgAAAB1Zb3UgYXJlIG5vdCBleGNoYW5nZXIncyBvd25lcgAAAAEAAAAKY29udGV4dE9iagEAAAAGdmVyaWZ5AAAAAAd+3KFu", "chainId": 84, "height": 684774, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let a = base58'3Mz9N7YPfZPWGd4yYaX6H53Gcgrq6ifYiH7' | |
5 | + | ||
6 | + | let b = "WAVES" | |
7 | + | ||
8 | + | let c = "Eq5Yc2tgjxdE2BeQmWcxis9RKDCkUraDoTRdymrjPua3" | |
9 | + | ||
10 | + | let d = 5 | |
11 | + | ||
12 | + | let e = "0.0.0" | |
13 | + | ||
14 | + | func f (g) = if ((g == "WAVES")) | |
15 | + | then unit | |
16 | + | else fromBase58String(g) | |
17 | + | ||
18 | + | ||
19 | + | let h = f(b) | |
20 | + | ||
21 | + | let i = f(c) | |
22 | + | ||
23 | + | @Callable(j) | |
24 | + | func fund () = { | |
25 | + | let k = { | |
26 | + | let l = j.payment | |
27 | + | if ($isInstanceOf(l, "AttachedPayment")) | |
28 | + | then { | |
29 | + | let m = l | |
30 | + | m | |
31 | + | } | |
32 | + | else throw("Payment not attached") | |
33 | + | } | |
34 | + | let n = k.assetId | |
35 | + | let o = k.amount | |
36 | + | if (if ((n == h)) | |
37 | + | then !(isDefined(getBoolean(this, "fundA"))) | |
38 | + | else false) | |
39 | + | then if (isDefined(getBoolean(this, "fundB"))) | |
40 | + | then WriteSet([DataEntry("amountTokenA", o), DataEntry("fundA", true), DataEntry("exchange_count", 0), DataEntry("status", true), DataEntry("assetIdTokenA", b), DataEntry("assetIdTokenB", c), DataEntry("comission", d), DataEntry("version", e), DataEntry("owner", toBase58String(a))]) | |
41 | + | else WriteSet([DataEntry("amountTokenA", o), DataEntry("assetIdTokenA", b), DataEntry("fundA", true)]) | |
42 | + | else if (if ((n == i)) | |
43 | + | then !(isDefined(getBoolean(this, "fundB"))) | |
44 | + | else false) | |
45 | + | then if (isDefined(getBoolean(this, "fundA"))) | |
46 | + | then WriteSet([DataEntry("amountTokenB", o), DataEntry("fundB", true), DataEntry("exchange_count", 0), DataEntry("status", true), DataEntry("assetIdTokenB", c), DataEntry("assetIdTokenB", c), DataEntry("comission", d), DataEntry("version", e), DataEntry("owner", toBase58String(a))]) | |
47 | + | else WriteSet([DataEntry("amountTokenB", o), DataEntry("assetIdTokenB", c), DataEntry("fundB", true)]) | |
48 | + | else throw("already funded or you try to fund with incorrect asset") | |
49 | + | } | |
50 | + | ||
51 | + | ||
52 | + | ||
53 | + | @Callable(j) | |
54 | + | func replenishment () = { | |
55 | + | let k = { | |
56 | + | let l = j.payment | |
57 | + | if ($isInstanceOf(l, "AttachedPayment")) | |
58 | + | then { | |
59 | + | let m = l | |
60 | + | m | |
61 | + | } | |
62 | + | else throw("Payment not attached") | |
63 | + | } | |
64 | + | let n = k.assetId | |
65 | + | let o = k.amount | |
66 | + | if (if ((n == h)) | |
67 | + | then isDefined(getBoolean(this, "fundA")) | |
68 | + | else false) | |
69 | + | then { | |
70 | + | let p = getIntegerValue(this, "amountTokenA") | |
71 | + | WriteSet([DataEntry("amountTokenA", (p + o))]) | |
72 | + | } | |
73 | + | else if (if ((n == i)) | |
74 | + | then isDefined(getBoolean(this, "fundB")) | |
75 | + | else false) | |
76 | + | then { | |
77 | + | let q = getIntegerValue(this, "amountTokenB") | |
78 | + | WriteSet([DataEntry("amountTokenB", (q + o))]) | |
79 | + | } | |
80 | + | else throw("there was an error in the replenishment") | |
81 | + | } | |
82 | + | ||
83 | + | ||
84 | + | ||
85 | + | @Callable(j) | |
86 | + | func exchanger (r) = if (if ((0 > d)) | |
87 | + | then true | |
88 | + | else (d > 100)) | |
89 | + | then throw("incorrect comission value") | |
90 | + | else { | |
91 | + | let q = getIntegerValue(this, "amountTokenB") | |
92 | + | let p = getIntegerValue(this, "amountTokenA") | |
93 | + | let k = { | |
94 | + | let l = j.payment | |
95 | + | if ($isInstanceOf(l, "AttachedPayment")) | |
96 | + | then { | |
97 | + | let m = l | |
98 | + | m | |
99 | + | } | |
100 | + | else throw("Payment not attached") | |
101 | + | } | |
102 | + | let n = k.assetId | |
103 | + | let o = k.amount | |
104 | + | let s = { | |
105 | + | let l = getInteger(this, "exchange_count") | |
106 | + | if ($isInstanceOf(l, "Int")) | |
107 | + | then { | |
108 | + | let t = l | |
109 | + | value(getInteger(this, "exchange_count")) | |
110 | + | } | |
111 | + | else 0 | |
112 | + | } | |
113 | + | if ((n == i)) | |
114 | + | then { | |
115 | + | let u = ((fraction(p, o, (o + q)) * (100 - d)) / 100) | |
116 | + | if ((r > u)) | |
117 | + | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") | |
118 | + | else { | |
119 | + | let v = h | |
120 | + | ScriptResult(WriteSet([DataEntry("amountTokenA", (p - u)), DataEntry("amountTokenB", (q + o)), DataEntry("exchange_count", (s + 1))]), TransferSet([ScriptTransfer(j.caller, u, v)])) | |
121 | + | } | |
122 | + | } | |
123 | + | else if ((n == h)) | |
124 | + | then { | |
125 | + | let u = ((fraction(q, o, (o + p)) * (100 - d)) / 100) | |
126 | + | if ((r > u)) | |
127 | + | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") | |
128 | + | else { | |
129 | + | let v = i | |
130 | + | ScriptResult(WriteSet([DataEntry("amountTokenA", (p + o)), DataEntry("amountTokenB", (q - u)), DataEntry("exchange_count", (s + 1))]), TransferSet([ScriptTransfer(j.caller, u, v)])) | |
131 | + | } | |
132 | + | } | |
133 | + | else throw("Asset is not allowed") | |
134 | + | } | |
135 | + | ||
136 | + | ||
137 | + | ||
138 | + | @Callable(j) | |
139 | + | func withdraw () = { | |
140 | + | let w = assetBalance(this, h) | |
141 | + | let x = assetBalance(this, i) | |
142 | + | if ((j.caller.bytes == a)) | |
143 | + | then ScriptResult(WriteSet([DataEntry("amountTokenA", "withdrawn"), DataEntry("amountTokenB", "withdrawn"), DataEntry("status", false)]), TransferSet([ScriptTransfer(j.caller, w, h), ScriptTransfer(j.caller, x, i)])) | |
144 | + | else throw("You are not exchanger's owner") | |
145 | + | } | |
146 | + | ||
147 | + | ||
148 | + | @Verifier(j) | |
149 | + | func y () = false | |
150 | + |
github/deemru/w8io/026f985 37.51 ms ◑