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