tx · 7eXNt4PRZqPCLE69bzUiUh9iaKLcdckk2bKNx5rXCKZ6

3N6KuDDYL9ZpT5CQ1HuzW9G1UfGRXizWbqp:  -0.01400000 Waves

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

{ "type": 13, "id": "7eXNt4PRZqPCLE69bzUiUh9iaKLcdckk2bKNx5rXCKZ6", "fee": 1400000, "feeAssetId": null, "timestamp": 1597069185487, "version": 1, "sender": "3N6KuDDYL9ZpT5CQ1HuzW9G1UfGRXizWbqp", "senderPublicKey": "6WhtgU8um8x2gsT5riuxYih51LoJYx91dzcx7TCx7JT1", "proofs": [ "3oRB77bWLuERaKcZWGPiFU33TMa6DzxdhmBatGvC4PPzUjuinRzJaqcbuThiQgu6YihK6enVRhwMWxAuVbLVqjP5" ], "script": "base64:AAIDAAAAAAAAAA0IARIAEgASAwoBARIAAAAACAAAAAAFb3duZXIBAAAAGgFUkVp9YFceKxS4tZgdZWFQ73BG70sIYCklAAAAAAhJZFRva2VuQQIAAAAFV0FWRVMAAAAACElkVG9rZW5CAgAAACxKNGVlMWJGcU5TcmRheUZvVWVnWHZCWGQxWFltSnRYaDFOUW51RkxDUHFvVwAAAAAJY29taXNzaW9uAAAAAAAAAAAAAAAAAAd2ZXJzaW9uAgAAAAUwLjAuMQEAAAAHYXNzZXRJZAAAAAEAAAAFYXNzZXQDCQAAAAAAAAIFAAAABWFzc2V0AgAAAAVXQVZFUwUAAAAEdW5pdAkAAlkAAAABBQAAAAVhc3NldAAAAAANYXNzZXRJZFRva2VuQQkBAAAAB2Fzc2V0SWQAAAABBQAAAAhJZFRva2VuQQAAAAANYXNzZXRJZFRva2VuQgkBAAAAB2Fzc2V0SWQAAAABBQAAAAhJZFRva2VuQgAAAAQAAAAKY29udGV4dE9iagEAAAAEZnVuZAAAAAAEAAAAB3BheW1lbnQEAAAAByRtYXRjaDAIBQAAAApjb250ZXh0T2JqAAAAB3Bhe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dXMHBQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAACmNvbnRleHRPYmoAAAAGY2FsbGVyBQAAAA1CYWxhbmNlVG9rZW5BBQAAAA1hc3NldElkVG9rZW5BCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAApjb250ZXh0T2JqAAAABmNhbGxlcgUAAAANQmFsYW5jZVRva2VuQgUAAAANYXNzZXRJZFRva2VuQgUAAAADbmlsCQAAAgAAAAECAAAAHVlvdSBhcmUgbm90IGV4Y2hhbmdlcidzIG93bmVyAAAAADld2Wo=", "chainId": 84, "height": 1126508, "spentComplexity": 0 } View: original | compacted Prev: AmZirsPHdkszRZVT4X8C45v5JDdzze74C8st3trBfaNd Next: 9kZWSUyzWZVzFyiJEEfvYjBdCw6pK6AGHhwJUoUD5HhU Diff:
OldNewDifferences
8383 then true
8484 else (comission > 100))
8585 then throw("incorrect comission value")
86- else {
87- let amountTokenB = getIntegerValue(this, "amountTokenB")
88- let amountTokenA = getIntegerValue(this, "amountTokenA")
89- let payment = match contextObj.payment {
90- case p: AttachedPayment =>
91- p
92- case _ =>
93- throw("Payment not attached")
94- }
95- let assetIdReceived = payment.assetId
96- let tokenReceiveAmount = payment.amount
97- let count = match getInteger(this, "exchange_count") {
98- case i: Int =>
99- (value(getInteger(this, "exchangecount")) + i)
100- case _ =>
101- 0
102- }
103- if ((assetIdReceived == assetIdTokenB))
104- then {
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- }
112- }
113- else if ((assetIdReceived == assetIdTokenA))
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))
114106 then {
115- let tokenSendAmount = ((fraction(amountTokenB, tokenReceiveAmount, (tokenReceiveAmount + amountTokenA)) * (100 - comission)) / 100)
107+ let tokenSendAmount = ((fraction(amountTokenA, tokenReceiveAmount, (tokenReceiveAmount + amountTokenB)) * (100 - comission)) / 100)
116108 if ((minTokenRecieve > tokenSendAmount))
117109 then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
118110 else {
119- let assetIdSent = assetIdTokenB
120- ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount)), DataEntry("amountTokenB", (amountTokenB - tokenSendAmount)), DataEntry("exchange_count", (count + 1))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
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)]))
121113 }
122114 }
123- else throw("Asset is not allowed")
124- }
115+ else if ((assetIdReceived == assetIdTokenA))
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+ else throw("Asset is not allowed")
126+ }
125127
126128
127129
129131 func withdraw () = {
130132 let BalanceTokenA = assetBalance(this, assetIdTokenA)
131133 let BalanceTokenB = assetBalance(this, assetIdTokenB)
132- if (true)
133- then throw(toString(BalanceTokenA))
134- else if ((contextObj.caller.bytes == owner))
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- else throw("You are not exchanger's owner")
134+ if ((contextObj.caller.bytes == owner))
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+ else throw("You are not exchanger's owner")
137137 }
138138
139139
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 {
87- let amountTokenB = getIntegerValue(this, "amountTokenB")
88- let amountTokenA = getIntegerValue(this, "amountTokenA")
89- let payment = match contextObj.payment {
90- case p: AttachedPayment =>
91- p
92- case _ =>
93- throw("Payment not attached")
94- }
95- let assetIdReceived = payment.assetId
96- let tokenReceiveAmount = payment.amount
97- let count = match getInteger(this, "exchange_count") {
98- case i: Int =>
99- (value(getInteger(this, "exchangecount")) + i)
100- case _ =>
101- 0
102- }
103- if ((assetIdReceived == assetIdTokenB))
104- then {
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- }
112- }
113- else if ((assetIdReceived == assetIdTokenA))
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))
114106 then {
115- let tokenSendAmount = ((fraction(amountTokenB, tokenReceiveAmount, (tokenReceiveAmount + amountTokenA)) * (100 - comission)) / 100)
107+ let tokenSendAmount = ((fraction(amountTokenA, tokenReceiveAmount, (tokenReceiveAmount + amountTokenB)) * (100 - comission)) / 100)
116108 if ((minTokenRecieve > tokenSendAmount))
117109 then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
118110 else {
119- let assetIdSent = assetIdTokenB
120- ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount)), DataEntry("amountTokenB", (amountTokenB - tokenSendAmount)), DataEntry("exchange_count", (count + 1))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
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)]))
121113 }
122114 }
123- else throw("Asset is not allowed")
124- }
115+ else if ((assetIdReceived == assetIdTokenA))
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+ else throw("Asset is not allowed")
126+ }
125127
126128
127129
128130 @Callable(contextObj)
129131 func withdraw () = {
130132 let BalanceTokenA = assetBalance(this, assetIdTokenA)
131133 let BalanceTokenB = assetBalance(this, assetIdTokenB)
132- if (true)
133- then throw(toString(BalanceTokenA))
134- else if ((contextObj.caller.bytes == owner))
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- else throw("You are not exchanger's owner")
134+ if ((contextObj.caller.bytes == owner))
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+ else throw("You are not exchanger's owner")
137137 }
138138
139139

github/deemru/w8io/169f3d6 
34.20 ms