tx · BG3hvuFjaWQ5f1hffcaoqPjZuecSwt589Kg1yCs8Q6ko

3Mu7bwtYrymjrXt1ttcqaQbFc1PqGhZndhv:  -0.01400000 Waves

2019.09.13 03:10 [673648] smart account 3Mu7bwtYrymjrXt1ttcqaQbFc1PqGhZndhv > SELF 0.00000000 Waves

{ "type": 13, "id": "BG3hvuFjaWQ5f1hffcaoqPjZuecSwt589Kg1yCs8Q6ko", "fee": 1400000, "feeAssetId": null, "timestamp": 1568333405108, "version": 1, "sender": "3Mu7bwtYrymjrXt1ttcqaQbFc1PqGhZndhv", "senderPublicKey": "BxHnTcjvN9ZtnKfdKYp6aKRdkMB4ZHxHnTDr5dWx5Vz2", "proofs": [ "4464iQErCsaKGe9XT3ox3LmDtW553Hkxg1fj68aFaHYKA6CQoo4a8N2T4nGzxEfuKsi7cfuf9WYyMvZwBEam6Apv" ], "script": "base64:AAIDAAAAAAAAAAAAAAAAAAAABAAAAAFpAQAAAAhtYWtlU2VsbAAAAAIAAAAKcHJpY2VBc3NldAAAAAVwcmljZQMDCQEAAAACIT0AAAACBQAAAApwcmljZUFzc2V0AgAAAAVXQVZFUwkBAAAAASEAAAABCQEAAAAJaXNEZWZpbmVkAAAAAQkAA+wAAAABCQACWQAAAAEFAAAACnByaWNlQXNzZXQHCQAAAgAAAAECAAAAI1RoZXJlIGlzIG5vIGFzc2V0IHdpdGggc3BlY2lmaWVkIGlkAwkAAGcAAAACAAAAAAAAAAAABQAAAAVwcmljZQkAAAIAAAABAgAAABZwcmljZSBtdXN0IGJlIHBvc2l0aXZlBAAAAAdwYXltZW50CQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIIBQAAAAFpAAAAB3BheW1lbnQCAAAAEXdoZXJlIGlzIHBheW1lbnQ/AwkAAGcAAAACAAAAAAAAAAAACAUAAAAHcGF5bWVudAAAAAZhbW91bnQJAAACAAAAAQIAAAAXYW1vdW50IG11c3QgYmUgcG9zaXRpdmUEAAAAB29yZGVySWQJAAEsAAAAAg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ACBQAAAApwcmljZUFzc2V0AgAAAAVXQVZFUwUAAAAEdW5pdAkAAlkAAAABBQAAAApwcmljZUFzc2V0CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAABW93bmVyCAUAAAAHcGF5bWVudAAAAAZhbW91bnQDCQAAAAAAAAIFAAAAC2Ftb3VudEFzc2V0AgAAAAVXQVZFUwUAAAAEdW5pdAkAAlkAAAABBQAAAAthbW91bnRBc3NldAUAAAADbmlsAAAAABgNDlU=", "chainId": 84, "height": 673648, "spentComplexity": 0 } View: original | compacted Prev: B6C4rbbVf18caKMfr48GnkkMvazvDrDErEHEGe3pijsY Next: Do9boHeu51KxmWGzdqvKSVHdSNrJ6c1EKyFaKrHexBmN Diff:
OldNewDifferences
122122 let price = getIntegerValue(this, (orderId + "_price"))
123123 let amount = getIntegerValue(this, (orderId + "_amount"))
124124 let priceAsset = getStringValue(this, (orderId + "_price_asset"))
125- let priceAssetDecimals = if ((priceAsset == "WAVES"))
125+ let amountAssetDecimals = if ((amountAsset == "WAVES"))
126126 then 8
127- else value(assetInfo(fromBase58String(priceAsset))).decimals
128- let priceAmount = ((payment.amount * price) / pow(10, 0, priceAssetDecimals, 0, 0, CEILING))
127+ else value(assetInfo(fromBase58String(amountAsset))).decimals
128+ let priceAmount = ((payment.amount * price) / pow(10, 0, amountAssetDecimals, 0, 0, CEILING))
129129 if ((priceAmount == 0))
130130 then throw("invalid amount")
131131 else {
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 let amountAssetDecimals = if ((amountAsset == "WAVES"))
5151 then 8
5252 else value(assetInfo(fromBase58String(amountAsset))).decimals
5353 let buyAmount = ((payment.amount * pow(10, 0, amountAssetDecimals, 0, 0, CEILING)) / price)
5454 if ((buyAmount == 0))
5555 then throw("invalid buy amount")
5656 else WriteSet([DataEntry((orderId + "_amount"), buyAmount), 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)])
5757 }
5858 }
5959
6060
6161
6262 @Callable(i)
6363 func takeSell (id) = {
6464 let payment = valueOrErrorMessage(i.payment, "where is payment?")
6565 if ((0 >= payment.amount))
6666 then throw("amount must be positive")
6767 else {
6868 let orderId = ("sell_" + id)
6969 let paymentAsset = match payment.assetId {
7070 case p: ByteVector =>
7171 toBase58String(p)
7272 case _ =>
7373 "WAVES"
7474 }
7575 let priceAsset = valueOrErrorMessage(getString(this, (orderId + "_price_asset")), "there is no order with specified id")
7676 if ((priceAsset != paymentAsset))
7777 then throw(("payment asset must be " + priceAsset))
7878 else {
7979 let price = getIntegerValue(this, (orderId + "_price"))
8080 let amount = getIntegerValue(this, (orderId + "_amount"))
8181 let amountAsset = getStringValue(this, (orderId + "_amount_asset"))
8282 let amountAssetDecimals = if ((amountAsset == "WAVES"))
8383 then 8
8484 else value(assetInfo(fromBase58String(amountAsset))).decimals
8585 let buyAmount = ((payment.amount * pow(10, 0, amountAssetDecimals, 0, 0, CEILING)) / price)
8686 if ((buyAmount == 0))
8787 then throw("invalid amount")
8888 else {
8989 let owner = value(addressFromString(getStringValue(this, (orderId + "_owner"))))
9090 let spent = getIntegerValue(this, (orderId + "_spent"))
9191 if ((buyAmount > (amount - spent)))
9292 then throw("not enougth asset in order")
9393 else ScriptResult(WriteSet([DataEntry((orderId + "_spent"), (spent + buyAmount))]), TransferSet([ScriptTransfer(i.caller, buyAmount, if ((amountAsset == "WAVES"))
9494 then unit
9595 else fromBase58String(amountAsset)), ScriptTransfer(owner, payment.amount, if ((priceAsset == "WAVES"))
9696 then unit
9797 else fromBase58String(priceAsset))]))
9898 }
9999 }
100100 }
101101 }
102102
103103
104104
105105 @Callable(i)
106106 func takeBuy (id) = {
107107 let payment = valueOrErrorMessage(i.payment, "where is payment?")
108108 if ((0 >= payment.amount))
109109 then throw("amount must be positive")
110110 else {
111111 let orderId = ("buy_" + id)
112112 let paymentAsset = match payment.assetId {
113113 case p: ByteVector =>
114114 toBase58String(p)
115115 case _ =>
116116 "WAVES"
117117 }
118118 let amountAsset = valueOrErrorMessage(getString(this, (orderId + "_amount_asset")), "there is no order with specified id")
119119 if ((amountAsset != paymentAsset))
120120 then throw(("payment asset must be " + amountAsset))
121121 else {
122122 let price = getIntegerValue(this, (orderId + "_price"))
123123 let amount = getIntegerValue(this, (orderId + "_amount"))
124124 let priceAsset = getStringValue(this, (orderId + "_price_asset"))
125- let priceAssetDecimals = if ((priceAsset == "WAVES"))
125+ let amountAssetDecimals = if ((amountAsset == "WAVES"))
126126 then 8
127- else value(assetInfo(fromBase58String(priceAsset))).decimals
128- let priceAmount = ((payment.amount * price) / pow(10, 0, priceAssetDecimals, 0, 0, CEILING))
127+ else value(assetInfo(fromBase58String(amountAsset))).decimals
128+ let priceAmount = ((payment.amount * price) / pow(10, 0, amountAssetDecimals, 0, 0, CEILING))
129129 if ((priceAmount == 0))
130130 then throw("invalid amount")
131131 else {
132132 let owner = value(addressFromString(getStringValue(this, (orderId + "_owner"))))
133133 let spent = getIntegerValue(this, (orderId + "_spent"))
134134 if ((payment.amount > (amount - spent)))
135135 then throw("not enougth asset in order")
136136 else ScriptResult(WriteSet([DataEntry((orderId + "_spent"), (spent + payment.amount))]), TransferSet([ScriptTransfer(i.caller, priceAmount, if ((priceAsset == "WAVES"))
137137 then unit
138138 else fromBase58String(priceAsset)), ScriptTransfer(owner, payment.amount, if ((amountAsset == "WAVES"))
139139 then unit
140140 else fromBase58String(amountAsset))]))
141141 }
142142 }
143143 }
144144 }
145145
146146

github/deemru/w8io/169f3d6 
32.30 ms