tx · 4no98v29mnw8hLzuYyD3cNcvC7FNgrWnS8QJW1SiRdEL

3N6KuDDYL9ZpT5CQ1HuzW9G1UfGRXizWbqp:  -0.01400000 Waves

2020.08.10 17:19 [1126508] smart account 3N6KuDDYL9ZpT5CQ1HuzW9G1UfGRXizWbqp > SELF 0.00000000 Waves

{ "type": 13, "id": "4no98v29mnw8hLzuYyD3cNcvC7FNgrWnS8QJW1SiRdEL", "fee": 1400000, "feeAssetId": null, "timestamp": 1597069227156, "version": 1, "sender": "3N6KuDDYL9ZpT5CQ1HuzW9G1UfGRXizWbqp", "senderPublicKey": "6WhtgU8um8x2gsT5riuxYih51LoJYx91dzcx7TCx7JT1", "proofs": [ "37kAL9WKBrcbCG8LLuoaV9ajdqNCX95sxhfnV7zUQRb7oJJYc7nzy4gJirfZcTPZmLJEMjBxaP37jjcbbwQeFYyb" ], "script": "base64:AAIDAAAAAAAAAA0IARIAEgASAwoBARIAAAAACAAAAAAFb3duZXIBAAAAGgFUkVp9YFceKxS4tZgdZWFQ73BG70sIYCklAAAAAAhJZFRva2VuQQIAAAAFV0FWRVMAAAAACElkVG9rZW5CAgAAACxKNGVlMWJGcU5TcmRheUZvVWVnWHZCWGQxWFltSnRYaDFOUW51RkxDUHFvVwAAAAAJY29taXNzaW9uAAAAAAAAAAAAAAAAAAd2ZXJzaW9uAgAAAAUwLjAuMQEAAAAHYXNzZXRJZAAAAAEAAAAFYXNzZXQDCQAAAAAAAAIFAAAABWFzc2V0AgAAAAVXQVZFUwUAAAAEdW5pdAkAAlkAAAABBQAAAAVhc3NldAAAAAANYXNzZXRJZFRva2VuQQkBAAAAB2Fzc2V0SWQAAAABBQAAAAhJZFRva2VuQQAAAAANYXNzZXRJZFRva2VuQgkBAAAAB2Fzc2V0SWQAAAABBQAAAAhJZFRva2VuQgAAAAQAAAAKY29udGV4dE9iagEAAAAEZnVuZAAAAAAEAAAAB3BheW1lbnQEAAAAByRtYXRjaDAIBQAAAApjb250ZXh0T2JqAAAAB3Bhe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0dXMHBQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAACmNvbnRleHRPYmoAAAAGY2FsbGVyBQAAAA1CYWxhbmNlVG9rZW5BBQAAAA1hc3NldElkVG9rZW5BCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAApjb250ZXh0T2JqAAAABmNhbGxlcgUAAAANQmFsYW5jZVRva2VuQgUAAAANYXNzZXRJZFRva2VuQgUAAAADbmlsCQAAAgAAAAECAAAAHVlvdSBhcmUgbm90IGV4Y2hhbmdlcidzIG93bmVyAAAAAMrp8ro=", "chainId": 84, "height": 1126508, "spentComplexity": 0 } View: original | compacted Prev: 9kZWSUyzWZVzFyiJEEfvYjBdCw6pK6AGHhwJUoUD5HhU Next: 8xQBuvy28ebD6nT31wE13235LhjxRM3eRWzWPHmD1rHX Diff:
OldNewDifferences
8383 then true
8484 else (comission > 100))
8585 then throw("incorrect comission value")
86- else if (true)
87- then throw(toString(123))
88- else {
89- let amountTokenB = getIntegerValue(this, "amountTokenB")
90- let amountTokenA = getIntegerValue(this, "amountTokenA")
91- let payment = match contextObj.payment {
92- case p: AttachedPayment =>
93- p
94- case _ =>
95- throw("Payment not attached")
96- }
97- let assetIdReceived = payment.assetId
98- let tokenReceiveAmount = payment.amount
99- let count = match getInteger(this, "exchange_count") {
100- case i: Int =>
101- (value(getInteger(this, "exchangecount")) + i)
102- case _ =>
103- 0
104- }
105- if ((assetIdReceived == assetIdTokenB))
106- then {
107- let tokenSendAmount = ((fraction(amountTokenA, tokenReceiveAmount, (tokenReceiveAmount + amountTokenB)) * (100 - comission)) / 100)
108- 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- }
114- }
115- else if ((assetIdReceived == assetIdTokenA))
86+ else {
87+ let amountTokenB = getIntegerValue(this, "amountTokenB")
88+ let amountTokenA = getIntegerValue(this, "amountTokenA")
89+ if (true)
90+ then throw(toString(123))
91+ else {
92+ let payment = match contextObj.payment {
93+ case p: AttachedPayment =>
94+ p
95+ case _ =>
96+ throw("Payment not attached")
97+ }
98+ let assetIdReceived = payment.assetId
99+ let tokenReceiveAmount = payment.amount
100+ let count = match getInteger(this, "exchange_count") {
101+ case i: Int =>
102+ (value(getInteger(this, "exchangecount")) + i)
103+ case _ =>
104+ 0
105+ }
106+ if ((assetIdReceived == assetIdTokenB))
116107 then {
117- let tokenSendAmount = ((fraction(amountTokenB, tokenReceiveAmount, (tokenReceiveAmount + amountTokenA)) * (100 - comission)) / 100)
108+ let tokenSendAmount = ((fraction(amountTokenA, tokenReceiveAmount, (tokenReceiveAmount + amountTokenB)) * (100 - comission)) / 100)
118109 if ((minTokenRecieve > tokenSendAmount))
119110 then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
120111 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)]))
112+ let assetIdSent = assetIdTokenA
113+ ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA - tokenSendAmount)), DataEntry("amountTokenB", (amountTokenB + tokenReceiveAmount)), DataEntry("exchange_count", (count + 1))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
123114 }
124115 }
125- else throw("Asset is not allowed")
126- }
116+ else if ((assetIdReceived == assetIdTokenA))
117+ then {
118+ let tokenSendAmount = ((fraction(amountTokenB, tokenReceiveAmount, (tokenReceiveAmount + amountTokenA)) * (100 - comission)) / 100)
119+ if ((minTokenRecieve > tokenSendAmount))
120+ then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
121+ else {
122+ let assetIdSent = assetIdTokenB
123+ ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount)), DataEntry("amountTokenB", (amountTokenB - tokenSendAmount)), DataEntry("exchange_count", (count + 1))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
124+ }
125+ }
126+ else throw("Asset is not allowed")
127+ }
128+ }
127129
128130
129131
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let owner = base58'3N3AeA5FWm7EHheHoik8BBEA3GXXJosnVY8'
55
66 let IdTokenA = "WAVES"
77
88 let IdTokenB = "J4ee1bFqNSrdayFoUegXvBXd1XYmJtXh1NQnuFLCPqoW"
99
1010 let comission = 0
1111
1212 let version = "0.0.1"
1313
1414 func assetId (asset) = if ((asset == "WAVES"))
1515 then unit
1616 else fromBase58String(asset)
1717
1818
1919 let assetIdTokenA = assetId(IdTokenA)
2020
2121 let assetIdTokenB = assetId(IdTokenB)
2222
2323 @Callable(contextObj)
2424 func fund () = {
2525 let payment = match contextObj.payment {
2626 case p: AttachedPayment =>
2727 p
2828 case _ =>
2929 throw("Payment not attached")
3030 }
3131 let assetIdReceived = payment.assetId
3232 let tokenReceiveAmount = payment.amount
3333 if (isDefined(assetIdTokenA))
3434 then throw("aaaa")
3535 else if (if ((assetIdReceived == assetIdTokenA))
3636 then !(isDefined(getBoolean(this, "fundA")))
3737 else false)
3838 then if (isDefined(getBoolean(this, "fundB")))
3939 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))])
4040 else WriteSet([DataEntry("amountTokenA", tokenReceiveAmount), DataEntry("assetIdTokenA", IdTokenA), DataEntry("fundA", true)])
4141 else if (if ((assetIdReceived == assetIdTokenB))
4242 then !(isDefined(getBoolean(this, "fundB")))
4343 else false)
4444 then if (isDefined(getBoolean(this, "fundA")))
4545 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))])
4646 else WriteSet([DataEntry("amountTokenB", tokenReceiveAmount), DataEntry("assetIdTokenB", IdTokenB), DataEntry("fundB", true)])
4747 else throw("already funded or you try to fund with incorrect asset")
4848 }
4949
5050
5151
5252 @Callable(contextObj)
5353 func replenishment () = {
5454 let payment = match contextObj.payment {
5555 case p: AttachedPayment =>
5656 p
5757 case _ =>
5858 throw("Payment not attached")
5959 }
6060 let assetIdReceived = payment.assetId
6161 let tokenReceiveAmount = payment.amount
6262 if (if ((assetIdReceived == assetIdTokenA))
6363 then isDefined(getBoolean(this, "fundA"))
6464 else false)
6565 then {
6666 let amountTokenA = getIntegerValue(this, "amountTokenA")
6767 WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount))])
6868 }
6969 else if (if ((assetIdReceived == assetIdTokenB))
7070 then isDefined(getBoolean(this, "fundB"))
7171 else false)
7272 then {
7373 let amountTokenB = getIntegerValue(this, "amountTokenB")
7474 WriteSet([DataEntry("amountTokenB", (amountTokenB + tokenReceiveAmount))])
7575 }
7676 else throw("there was an error in the replenishment")
7777 }
7878
7979
8080
8181 @Callable(contextObj)
8282 func exchanger (minTokenRecieve) = if (if ((0 > comission))
8383 then true
8484 else (comission > 100))
8585 then throw("incorrect comission value")
86- else if (true)
87- then throw(toString(123))
88- else {
89- let amountTokenB = getIntegerValue(this, "amountTokenB")
90- let amountTokenA = getIntegerValue(this, "amountTokenA")
91- let payment = match contextObj.payment {
92- case p: AttachedPayment =>
93- p
94- case _ =>
95- throw("Payment not attached")
96- }
97- let assetIdReceived = payment.assetId
98- let tokenReceiveAmount = payment.amount
99- let count = match getInteger(this, "exchange_count") {
100- case i: Int =>
101- (value(getInteger(this, "exchangecount")) + i)
102- case _ =>
103- 0
104- }
105- if ((assetIdReceived == assetIdTokenB))
106- then {
107- let tokenSendAmount = ((fraction(amountTokenA, tokenReceiveAmount, (tokenReceiveAmount + amountTokenB)) * (100 - comission)) / 100)
108- 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- }
114- }
115- else if ((assetIdReceived == assetIdTokenA))
86+ else {
87+ let amountTokenB = getIntegerValue(this, "amountTokenB")
88+ let amountTokenA = getIntegerValue(this, "amountTokenA")
89+ if (true)
90+ then throw(toString(123))
91+ else {
92+ let payment = match contextObj.payment {
93+ case p: AttachedPayment =>
94+ p
95+ case _ =>
96+ throw("Payment not attached")
97+ }
98+ let assetIdReceived = payment.assetId
99+ let tokenReceiveAmount = payment.amount
100+ let count = match getInteger(this, "exchange_count") {
101+ case i: Int =>
102+ (value(getInteger(this, "exchangecount")) + i)
103+ case _ =>
104+ 0
105+ }
106+ if ((assetIdReceived == assetIdTokenB))
116107 then {
117- let tokenSendAmount = ((fraction(amountTokenB, tokenReceiveAmount, (tokenReceiveAmount + amountTokenA)) * (100 - comission)) / 100)
108+ let tokenSendAmount = ((fraction(amountTokenA, tokenReceiveAmount, (tokenReceiveAmount + amountTokenB)) * (100 - comission)) / 100)
118109 if ((minTokenRecieve > tokenSendAmount))
119110 then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
120111 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)]))
112+ let assetIdSent = assetIdTokenA
113+ ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA - tokenSendAmount)), DataEntry("amountTokenB", (amountTokenB + tokenReceiveAmount)), DataEntry("exchange_count", (count + 1))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
123114 }
124115 }
125- else throw("Asset is not allowed")
126- }
116+ else if ((assetIdReceived == assetIdTokenA))
117+ then {
118+ let tokenSendAmount = ((fraction(amountTokenB, tokenReceiveAmount, (tokenReceiveAmount + amountTokenA)) * (100 - comission)) / 100)
119+ if ((minTokenRecieve > tokenSendAmount))
120+ then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
121+ else {
122+ let assetIdSent = assetIdTokenB
123+ ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount)), DataEntry("amountTokenB", (amountTokenB - tokenSendAmount)), DataEntry("exchange_count", (count + 1))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
124+ }
125+ }
126+ else throw("Asset is not allowed")
127+ }
128+ }
127129
128130
129131
130132 @Callable(contextObj)
131133 func withdraw () = {
132134 let BalanceTokenA = assetBalance(this, assetIdTokenA)
133135 let BalanceTokenB = assetBalance(this, assetIdTokenB)
134136 if ((contextObj.caller.bytes == owner))
135137 then ScriptResult(WriteSet([DataEntry("amountTokenA", "withdrawn"), DataEntry("amountTokenB", "withdrawn"), DataEntry("status", false)]), TransferSet([ScriptTransfer(contextObj.caller, BalanceTokenA, assetIdTokenA), ScriptTransfer(contextObj.caller, BalanceTokenB, assetIdTokenB)]))
136138 else throw("You are not exchanger's owner")
137139 }
138140
139141

github/deemru/w8io/169f3d6 
38.78 ms