tx · FfyAK5oJ4T7L8KFXMAK4MrU3gJ6NykijhpygHAE7dmiW

3Mu7bwtYrymjrXt1ttcqaQbFc1PqGhZndhv:  -0.01400000 Waves

2019.09.13 00:54 [673507] smart account 3Mu7bwtYrymjrXt1ttcqaQbFc1PqGhZndhv > SELF 0.00000000 Waves

{ "type": 13, "id": "FfyAK5oJ4T7L8KFXMAK4MrU3gJ6NykijhpygHAE7dmiW", "fee": 1400000, "feeAssetId": null, "timestamp": 1568325297689, "version": 1, "sender": "3Mu7bwtYrymjrXt1ttcqaQbFc1PqGhZndhv", "senderPublicKey": "BxHnTcjvN9ZtnKfdKYp6aKRdkMB4ZHxHnTDr5dWx5Vz2", "proofs": [ "2wqr7ygQhfkyVxBW811657pt6hmzzGgXic2LMiYttavQyC5Jscm12Y5Qkyd5E9kEgSxyheKnDYtGWDXUpAFNed4w" ], "script": "base64:AAIDAAAAAAAAAAAAAAAAAAAAAwAAAAFpAQAAAAhtYWtlU2VsbAAAAAIAAAAKcHJpY2VBc3NldAAAAAVwcmljZQMDCQEAAAACIT0AAAACBQAAAApwcmljZUFzc2V0AgAAAAVXQVZFUwkBAAAAASEAAAABCQEAAAAJaXNEZWZpbmVkAAAAAQkAA+wAAAABCQACWQAAAAEFAAAACnByaWNlQXNzZXQHCQAAAgAAAAECAAAAI1RoZXJlIGlzIG5vIGFzc2V0IHdpdGggc3BlY2lmaWVkIGlkAwkAAGcAAAACAAAAAAAAAAAABQAAAAVwcmljZQkAAAIAAAABAgAAABZwcmljZSBtdXN0IGJlIHBvc2l0aXZlBAAAAAdwYXltZW50CQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIIBQAAAAFpAAAAB3BheW1lbnQCAAAAEXdoZXJlIGlzIHBheW1lbnQ/AwkAAGcAAAACAAAAAAAAAAAACAUAAAAHcGF5bWVudAAAAAZhbW91bnQJAAACAAAAAQIAAAAXYW1vdW50IG11c3QgYmUgcG9zaXRpdmUEAAAAB29yZGVySWQJAAEsAAAAAgI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AAEsAAAAAgUAAAAHb3JkZXJJZAIAAAAGX3NwZW50CQAAZAAAAAIFAAAABXNwZW50BQAAAAlidXlBbW91bnQFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAACWJ1eUFtb3VudAMJAAAAAAAAAgUAAAALYW1vdW50QXNzZXQCAAAABVdBVkVTBQAAAAR1bml0CQACWQAAAAEFAAAAC2Ftb3VudEFzc2V0CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAABW93bmVyCAUAAAAHcGF5bWVudAAAAAZhbW91bnQDCQAAAAAAAAIFAAAACnByaWNlQXNzZXQCAAAABVdBVkVTBQAAAAR1bml0CQACWQAAAAEFAAAACnByaWNlQXNzZXQFAAAAA25pbAAAAACi/5Q6", "chainId": 84, "height": 673507, "spentComplexity": 0 } View: original | compacted Prev: 1Mh8dJKr6Hedyb3EnSz3RA5LaLFGZjK8NcsfJyA4Pb2 Next: 2o3byrNsvjNQE8iZ2QJxWZ3ZYTwiAyezBtfjabg81wx8 Diff:
OldNewDifferences
7272 else {
7373 let price = getIntegerValue(this, (orderId + "_price"))
7474 let amount = getIntegerValue(this, (orderId + "_amount"))
75- let buyAmount = (payment.amount / price)
75+ let paymentAssetDecimals = if ((paymentAsset == "WAVES"))
76+ then 8
77+ else value(assetInfo(fromBase58String(paymentAsset))).decimals
78+ let buyAmount = ((payment.amount * pow(10, 0, paymentAssetDecimals, 0, 0, CEILING)) / price)
7679 let owner = value(addressFromString(getStringValue(this, (orderId + "_owner"))))
7780 let amountAsset = getStringValue(this, (orderId + "_amount_asset"))
7881 let spent = getIntegerValue(this, (orderId + "_spent"))
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44
55
66 @Callable(i)
77 func makeSell (priceAsset,price) = if (if ((priceAsset != "WAVES"))
88 then !(isDefined(assetInfo(fromBase58String(priceAsset))))
99 else false)
1010 then throw("There is no asset with specified id")
1111 else if ((0 >= price))
1212 then throw("price must be positive")
1313 else {
1414 let payment = valueOrErrorMessage(i.payment, "where is payment?")
1515 if ((0 >= payment.amount))
1616 then throw("amount must be positive")
1717 else {
1818 let orderId = ("sell_" + toBase58String(i.transactionId))
1919 let amountAsset = match payment.assetId {
2020 case p: ByteVector =>
2121 toBase58String(p)
2222 case _ =>
2323 "WAVES"
2424 }
2525 WriteSet([DataEntry((orderId + "_amount"), payment.amount), DataEntry((orderId + "_amount_asset"), amountAsset), DataEntry((orderId + "_price"), price), DataEntry((orderId + "_price_asset"), priceAsset), DataEntry((orderId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((orderId + "_spent"), 0)])
2626 }
2727 }
2828
2929
3030
3131 @Callable(i)
3232 func makeBuy (amountAsset,price) = if (if ((amountAsset != "WAVES"))
3333 then !(isDefined(assetInfo(fromBase58String(amountAsset))))
3434 else false)
3535 then throw("There is no asset with specified id")
3636 else if ((0 >= price))
3737 then throw("price must be positive")
3838 else {
3939 let payment = valueOrErrorMessage(i.payment, "where is payment?")
4040 if ((0 >= payment.amount))
4141 then throw("amount must be positive")
4242 else {
4343 let orderId = ("buy_" + toBase58String(i.transactionId))
4444 let priceAsset = match payment.assetId {
4545 case p: ByteVector =>
4646 toBase58String(p)
4747 case _ =>
4848 "WAVES"
4949 }
5050 WriteSet([DataEntry((orderId + "_amount"), (payment.amount / price)), DataEntry((orderId + "_amount_asset"), amountAsset), DataEntry((orderId + "_price"), price), DataEntry((orderId + "_price_asset"), priceAsset), DataEntry((orderId + "_owner"), toBase58String(i.caller.bytes)), DataEntry((orderId + "_spent"), 0)])
5151 }
5252 }
5353
5454
5555
5656 @Callable(i)
5757 func takeSell (id) = {
5858 let payment = valueOrErrorMessage(i.payment, "where is payment?")
5959 if ((0 >= payment.amount))
6060 then throw("amount must be positive")
6161 else {
6262 let orderId = ("sell_" + id)
6363 let paymentAsset = match payment.assetId {
6464 case p: ByteVector =>
6565 toBase58String(p)
6666 case _ =>
6767 "WAVES"
6868 }
6969 let priceAsset = valueOrErrorMessage(getString(this, (orderId + "_price_asset")), "there is no order with specified id")
7070 if ((priceAsset != paymentAsset))
7171 then throw(("payment asset must be " + priceAsset))
7272 else {
7373 let price = getIntegerValue(this, (orderId + "_price"))
7474 let amount = getIntegerValue(this, (orderId + "_amount"))
75- let buyAmount = (payment.amount / price)
75+ let paymentAssetDecimals = if ((paymentAsset == "WAVES"))
76+ then 8
77+ else value(assetInfo(fromBase58String(paymentAsset))).decimals
78+ let buyAmount = ((payment.amount * pow(10, 0, paymentAssetDecimals, 0, 0, CEILING)) / price)
7679 let owner = value(addressFromString(getStringValue(this, (orderId + "_owner"))))
7780 let amountAsset = getStringValue(this, (orderId + "_amount_asset"))
7881 let spent = getIntegerValue(this, (orderId + "_spent"))
7982 if ((buyAmount > (amount - spent)))
8083 then throw("not enougth asset in order")
8184 else ScriptResult(WriteSet([DataEntry((orderId + "_spent"), (spent + buyAmount))]), TransferSet([ScriptTransfer(i.caller, buyAmount, if ((amountAsset == "WAVES"))
8285 then unit
8386 else fromBase58String(amountAsset)), ScriptTransfer(owner, payment.amount, if ((priceAsset == "WAVES"))
8487 then unit
8588 else fromBase58String(priceAsset))]))
8689 }
8790 }
8891 }
8992
9093

github/deemru/w8io/169f3d6 
25.62 ms