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