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:AAIDAAAAAAAAAA0IARIAEgASAwoBARIAAAAACAAAAAAFb3duZXIBAAAAGgFUkVp9YFceKxS4tZgdZWFQ73BG70sIYCklAAAAAAhJZFRva2VuQQIAAAAFV0FWRVMAAAAACElkVG9rZW5CAgAAACxKNGVlMWJGcU5TcmRheUZvVWVnWHZCWGQxWFltSnRYaDFOUW51RkxDUHFvVwAAAAAJY29taXNzaW9uAAAAAAAAAAAAAAAAAAd2ZXJzaW9uAgAAAAUwLjAuMQEAAAAHYXNzZXRJZAAAAAEAAAAFYXNzZXQDCQAAAAAAAAIFAAAABWFzc2V0AgAAAAVXQVZFUwUAAAAEdW5pdAkAAlkAAAABBQAAAAVhc3NldAAAAAANYXNzZXRJZFRva2VuQQkBAAAAB2Fzc2V0SWQAAAABBQAAAAhJZFRva2VuQQAAAAANYXNzZXRJZFRva2VuQgkBAAAAB2Fzc2V0SWQAAAABBQAAAAhJZFRva2VuQgAAAAQAAAAKY29udGV4dE9iagEAAAAEZnVuZAAAAAAEAAAAB3BheW1lbnQEAAAAByRtYXRjaDAIBQAAAApjb250ZXh0T2JqAAAAB3BheW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dXMHBQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAACmNvbnRleHRPYmoAAAAGY2FsbGVyBQAAAA1CYWxhbmNlVG9rZW5BBQAAAA1hc3NldElkVG9rZW5BCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAApjb250ZXh0T2JqAAAABmNhbGxlcgUAAAANQmFsYW5jZVRva2VuQgUAAAANYXNzZXRJZFRva2VuQgUAAAADbmlsCQAAAgAAAAECAAAAHVlvdSBhcmUgbm90IGV4Y2hhbmdlcidzIG93bmVyAAAAAGPE9Hs=", "chainId": 84, "height": 1126510, "spentComplexity": 0 } View: original | compacted Prev: 9wiCq1E65LZcAgqYn9gqL22Usmdd1SHKdDJUeLK2Z1DV Next: AQ68bg7ELPZFQHdeTC8ao5PfBhWNMcNRkynGx8BnniMG Diff:
OldNewDifferences
101101 0
102102 }
103103 if ((assetIdReceived == assetIdTokenB))
104- then if (true)
105- then throw(toString(123))
106- else {
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- }
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+ }
115113 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- }
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+ }
125125 else throw("Asset is not allowed")
126126 }
127127
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")
8686 else {
8787 let amountTokenB = getIntegerValue(this, "amountTokenB")
8888 let amountTokenA = getIntegerValue(this, "amountTokenA")
8989 let payment = match contextObj.payment {
9090 case p: AttachedPayment =>
9191 p
9292 case _ =>
9393 throw("Payment not attached")
9494 }
9595 let assetIdReceived = payment.assetId
9696 let tokenReceiveAmount = payment.amount
9797 let count = match getInteger(this, "exchange_count") {
9898 case i: Int =>
9999 (value(getInteger(this, "exchangecount")) + i)
100100 case _ =>
101101 0
102102 }
103103 if ((assetIdReceived == assetIdTokenB))
104- then if (true)
105- then throw(toString(123))
106- else {
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- }
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+ }
115113 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- }
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+ }
125125 else throw("Asset is not allowed")
126126 }
127127
128128
129129
130130 @Callable(contextObj)
131131 func withdraw () = {
132132 let BalanceTokenA = assetBalance(this, assetIdTokenA)
133133 let BalanceTokenB = assetBalance(this, assetIdTokenB)
134134 if ((contextObj.caller.bytes == owner))
135135 then ScriptResult(WriteSet([DataEntry("amountTokenA", "withdrawn"), DataEntry("amountTokenB", "withdrawn"), DataEntry("status", false)]), TransferSet([ScriptTransfer(contextObj.caller, BalanceTokenA, assetIdTokenA), ScriptTransfer(contextObj.caller, BalanceTokenB, assetIdTokenB)]))
136136 else throw("You are not exchanger's owner")
137137 }
138138
139139

github/deemru/w8io/169f3d6 
35.19 ms