tx · ZEyNxuFEWDP4ZzyYi1yrabGhF5apn1mxqbbPiA2X3me

3MtjjEoEs6Rcqkh8tYjPmBxZND58FuMtRWN:  -0.05000000 Waves

2022.09.08 16:53 [2220209] smart account 3MtjjEoEs6Rcqkh8tYjPmBxZND58FuMtRWN > SELF 0.00000000 Waves

{ "type": 13, "id": "ZEyNxuFEWDP4ZzyYi1yrabGhF5apn1mxqbbPiA2X3me", "fee": 5000000, "feeAssetId": null, "timestamp": 1662645213357, "version": 2, "chainId": 84, "sender": "3MtjjEoEs6Rcqkh8tYjPmBxZND58FuMtRWN", "senderPublicKey": "GR35NTmt1JUgBMwuwSK6aFSmLN7g6eZKbYvfSV3ThdWR", "proofs": [ "zTWmNj5iknBf4FpE7ri89re9UWBjxecBrpvJ87Crh8521tYVoepBe3sDFLki9XS7fax28ipFHLqgbifH2k2wCnc" ], "script": "base64:AAIFAAAAAAAAABMIAhIECgIIARIDCgEIEgQKAggIAAAABQAAAAAPcHJveHlBZGRyZXNzU3RyAgAAACMzTkFtM3A2MmJvNHEzeU16V2pKNk00ZUVEQlJZWHhxa1hMUQEAAAAMdHJ5R2V0U3RyaW5nAAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWIFAAAAByRtYXRjaDAFAAAAAWICAAAAAAEAAAANdHJ5R2V0SW50ZWdlcgAAAAEAAAADa2V5BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAAAAAAAAAAAAAQAAAA5nZXRBc3NldFN0cmluZwAAAAEAAAAHYXNzZXRJZAQAAAAHJG1hdGNoMAUAAAAHYXNzZXRJZAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAKQnl0ZVZlY3RvcgQAAA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AAQIAAAAXWW91IGNhbm5vdCBjYW5jZWwgb3JkZXIDAwkAAAAAAAACCQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMFAAAAD3Byb3h5QWRkcmVzc1N0cgkBAAAAAiE9AAAAAgUAAAALcHJveHlDYWxsZXIFAAAACm9yZGVyT3duZXIHCQAAAgAAAAECAAAAF1lvdSBjYW5ub3QgY2FuY2VsIG9yZGVyAwkBAAAAAiE9AAAAAgUAAAALb3JkZXJTdGF0dXMCAAAABmFjdGl2ZQkAAAIAAAABAgAAABtvcmRlciBpcyBjbG9zZWQgb3IgY2FuY2VsZWQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAEUBleHRyTmF0aXZlKDEwNjIpAAAAAQUAAAAKb3JkZXJPd25lcgUAAAAQb3JkZXJBbW91bnQwTGVmdAkBAAAADWdldEFzc2V0Qnl0ZXMAAAABBQAAAAtvcmRlckFzc2V0MAkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAGb3JkZXJfBQAAAAdvcmRlcklkAgAAAAdfc3RhdHVzAgAAAAhjYW5jZWxlZAUAAAADbmlsAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXlVa58M", "height": 2220209, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6Mg8yw3pcR9ACUaWfYJmtemXxjVtzEFijULHqBHi8Tn1 Next: none Diff:
OldNewDifferences
9999 let orderFulfilled0 = valueOrErrorMessage(getInteger((("order_" + orderId) + "_fulfilled0")), "Cannot find fulfilled0")
100100 let orderAmount0Left = (orderAmount0 - orderFulfilled0)
101101 if (if ((toBase58String(i.caller.bytes) != orderOwner))
102- then true
103- else (toBase58String(i.caller.bytes) != proxyAddressStr))
102+ then (toBase58String(i.caller.bytes) != proxyAddressStr)
103+ else false)
104104 then throw("You cannot cancel order")
105105 else if (if ((toBase58String(i.caller.bytes) == proxyAddressStr))
106106 then (proxyCaller != orderOwner)
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let proxyAddressStr = "3NAm3p62bo4q3yMzWjJ6M4eEDBRYXxqkXLQ"
55
66 func tryGetString (key) = match getString(this, key) {
77 case b: String =>
88 b
99 case _ =>
1010 ""
1111 }
1212
1313
1414 func tryGetInteger (key) = match getInteger(this, key) {
1515 case b: Int =>
1616 b
1717 case _ =>
1818 0
1919 }
2020
2121
2222 func getAssetString (assetId) = match assetId {
2323 case b: ByteVector =>
2424 toBase58String(b)
2525 case _ =>
2626 "WAVES"
2727 }
2828
2929
3030 func getAssetBytes (assetIdStr) = if ((assetIdStr == "WAVES"))
3131 then unit
3232 else fromBase58String(assetIdStr)
3333
3434
3535 @Callable(i)
3636 func createOrder (asset1,amount1) = {
3737 let newOrdersAmount = (tryGetInteger("global_ordersAmount") + 1)
3838 let orderId = toString(newOrdersAmount)
3939 if ((size(i.payments) != 1))
4040 then throw("You should to provide payment")
4141 else if ((0 >= amount1))
4242 then throw("Amount1 cannot be less or equals 0")
4343 else {
4444 let asset0 = getAssetString(i.payments[0].assetId)
4545 let amount0 = i.payments[0].amount
4646 let userOrders = tryGetString((("user_" + toString(i.caller)) + "_orders"))
4747 let newUserOrders = match userOrders {
4848 case _ =>
4949 if (("" == $match0))
5050 then orderId
5151 else ((userOrders + ",") + orderId)
5252 }
5353 [IntegerEntry("global_ordersAmount", newOrdersAmount), StringEntry((("order_" + orderId) + "_token0"), asset0), IntegerEntry((("order_" + orderId) + "_amount0"), amount0), IntegerEntry((("order_" + orderId) + "_amount1"), amount1), StringEntry((("order_" + orderId) + "_token1"), asset1), IntegerEntry((("order_" + orderId) + "_fulfilled0"), 0), IntegerEntry((("order_" + orderId) + "_fulfilled1"), 0), StringEntry((("order_" + orderId) + "_owner"), toString(i.caller)), StringEntry((("order_" + orderId) + "_status"), "active"), StringEntry((("user_" + toString(i.caller)) + "_orders"), newUserOrders)]
5454 }
5555 }
5656
5757
5858
5959 @Callable(i)
6060 func fulfillOrder (orderId) = {
6161 let orderOwner = valueOrErrorMessage(getString((("order_" + orderId) + "_owner")), "Cannot find order owner")
6262 let orderStatus = getString((("order_" + orderId) + "_status"))
6363 let orderAsset0 = valueOrErrorMessage(getString((("order_" + orderId) + "_token0")), "Cannot find token0")
6464 let orderAmount0 = valueOrErrorMessage(getInteger((("order_" + orderId) + "_amount0")), "Cannot find amount0")
6565 let orderFulfilled0 = valueOrErrorMessage(getInteger((("order_" + orderId) + "_fulfilled0")), "Cannot find fulfilled0")
6666 let orderAmount0Left = (orderAmount0 - orderFulfilled0)
6767 let orderAsset1 = valueOrErrorMessage(getString((("order_" + orderId) + "_token1")), "Cannot find token1")
6868 let orderAmount1 = valueOrErrorMessage(getInteger((("order_" + orderId) + "_amount1")), "Cannot find amount1")
6969 let orderFulfilled1 = valueOrErrorMessage(getInteger((("order_" + orderId) + "_fulfilled1")), "Cannot find fulfilled1")
7070 let orderAmount1Left = (orderAmount1 - orderFulfilled1)
7171 if ((orderStatus != "active"))
7272 then throw("Order already closed or canceled")
7373 else if ((size(i.payments) != 1))
7474 then throw("You should to provide payment")
7575 else {
7676 let callerAddress = i.caller
7777 let ownerAddress = addressFromStringValue(orderOwner)
7878 let paymentAsset1 = getAssetString(i.payments[0].assetId)
7979 let paymentAmount1 = i.payments[0].amount
8080 if ((paymentAsset1 != orderAsset1))
8181 then throw("Wrong payment asset")
8282 else if ((paymentAmount1 >= orderAmount1Left))
8383 then [ScriptTransfer(callerAddress, (paymentAmount1 - orderAmount1Left), getAssetBytes(orderAsset1)), ScriptTransfer(callerAddress, orderAmount0Left, getAssetBytes(orderAsset0)), ScriptTransfer(ownerAddress, orderAmount1Left, getAssetBytes(paymentAsset1)), IntegerEntry((("order_" + orderId) + "_fulfilled0"), (orderFulfilled0 + orderAmount0Left)), IntegerEntry((("order_" + orderId) + "_fulfilled1"), (orderFulfilled1 + orderAmount1Left)), StringEntry((("order_" + orderId) + "_status"), "closed")]
8484 else {
8585 let amount0 = fraction(orderAmount0, paymentAmount1, orderAmount1, FLOOR)
8686 [ScriptTransfer(ownerAddress, paymentAmount1, getAssetBytes(paymentAsset1)), ScriptTransfer(callerAddress, amount0, getAssetBytes(orderAsset0)), IntegerEntry((("order_" + orderId) + "_fulfilled0"), (orderFulfilled0 + amount0)), IntegerEntry((("order_" + orderId) + "_fulfilled1"), (orderFulfilled1 + paymentAmount1))]
8787 }
8888 }
8989 }
9090
9191
9292
9393 @Callable(i)
9494 func cancelOrder (orderId,proxyCaller) = {
9595 let orderOwner = valueOrErrorMessage(getString((("order_" + orderId) + "_owner")), "Cannot find order owner")
9696 let orderStatus = getString((("order_" + orderId) + "_status"))
9797 let orderAsset0 = valueOrErrorMessage(getString((("order_" + orderId) + "_token0")), "Cannot find token0")
9898 let orderAmount0 = valueOrErrorMessage(getInteger((("order_" + orderId) + "_amount0")), "Cannot find amount0")
9999 let orderFulfilled0 = valueOrErrorMessage(getInteger((("order_" + orderId) + "_fulfilled0")), "Cannot find fulfilled0")
100100 let orderAmount0Left = (orderAmount0 - orderFulfilled0)
101101 if (if ((toBase58String(i.caller.bytes) != orderOwner))
102- then true
103- else (toBase58String(i.caller.bytes) != proxyAddressStr))
102+ then (toBase58String(i.caller.bytes) != proxyAddressStr)
103+ else false)
104104 then throw("You cannot cancel order")
105105 else if (if ((toBase58String(i.caller.bytes) == proxyAddressStr))
106106 then (proxyCaller != orderOwner)
107107 else false)
108108 then throw("You cannot cancel order")
109109 else if ((orderStatus != "active"))
110110 then throw("order is closed or canceled")
111111 else [ScriptTransfer(addressFromStringValue(orderOwner), orderAmount0Left, getAssetBytes(orderAsset0)), StringEntry((("order_" + orderId) + "_status"), "canceled")]
112112 }
113113
114114
115115 @Verifier(tx)
116116 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
117117

github/deemru/w8io/026f985 
48.84 ms