tx · BbLk8C1M5Vo1HkoTnLT6BgboxV2HnSgWgEzs3mptBYXv

3Mw231rSjoAzBonqXaA6tAJ7Y8W164HZ231:  -0.01000000 Waves

2019.08.30 13:09 [653846] smart account 3Mw231rSjoAzBonqXaA6tAJ7Y8W164HZ231 > SELF 0.00000000 Waves

{ "type": 13, "id": "BbLk8C1M5Vo1HkoTnLT6BgboxV2HnSgWgEzs3mptBYXv", "fee": 1000000, "feeAssetId": null, "timestamp": 1567159867677, "version": 1, "sender": "3Mw231rSjoAzBonqXaA6tAJ7Y8W164HZ231", "senderPublicKey": "rkomEX9j7Kw9ADRkrMU9iUaM1az7zojHSXiuBRFd1ZJ", "proofs": [ "5yM4TbYPBzz36fs2N6opmM32FmSqaj6VHDXo6CjauZxJkUiJF7DiuBoqou32Hw2w5zvSUJaBcGu21f2UJpR54XiE" ], "script": "base64:AAIDAAAAAAAAAAkIARIAEgMKAQgAAAAMAAAAAAZtYXhGZWUAAAAAAAAPQkAAAAAACW1pbkFtb3VudAkBAAAAEUBleHRyTmF0aXZlKDEwNTApAAAAAgUAAAAEdGhpcwIAAAARY29uZmlnX21pbl9hbW91bnQAAAAADmFjY2VwdEJldFVudGlsCQEAAAARQGV4dHJOYXRpdmUoMTA1MCkAAAACBQAAAAR0aGlzAgAAABBjb25maWdfYmV0X3VudGlsAAAAAAp0cmFkZVN0YXJ0CQEAAAARQGV4dHJOYXRpdmUoMTA1MCkAAAACBQAAAAR0aGlzAgAAABJjb25maWdfdHJhZGVfc3RhcnQAAAAACHRyYWRlRW5kCQEAAAARQGV4dHJOYXRpdmUoMTA1MCkAAAACBQAAAAR0aGlzAgAAABBjb25maWdfdHJhZGVfZW5kAAAAAAxhY2NlcHRBc3NldHMJAARMAAAAAgkBAAAAEUBleHRyTmF0aXZlKDEwNTMpAAAAAgUAAAAEdGhpcwIAAAAOY29uZmlnX2Fzc2V0XzEJAARMAAAAAgkBAAAAEUBleHRyTmF0aXZlKDEwNTMpAAAAAgUAAAAEdGhpc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HJlYWR5IHJlZ2lzdGVyZWQDCQAAZgAAAAIFAAAACW1pbkFtb3VudAUAAAAGYW1vdW50CQAAAgAAAAEJAAEsAAAAAgIAAAAObWluIGFtb3VudCBpcyAJAAGkAAAAAQUAAAAJbWluQW1vdW50AwkAAGYAAAACBQAAAA5hY2NlcHRCZXRVbnRpbAUAAAALdHhUaW1lc3RhbXAJAQAAAAhyZXBheUZlZQAAAAUFAAAAA2ludgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAMYmV0UmVzdWx0S2V5AgAAAAhhY2NlcHRlZAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAMYmV0QW1vdW50S2V5CQAAZAAAAAIJAQAAAA1nZXRJbnREZWZhdWx0AAAAAgUAAAAMYmV0QW1vdW50S2V5AAAAAAAAAAAABQAAAAZhbW91bnQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAAEWJldFRvdGFsQW1vdW50S2V5CQAAZAAAAAIJAQAAAA1nZXRJbnREZWZhdWx0AAAAAgUAAAARYmV0VG90YWxBbW91bnRLZXkAAAAAAAAAAAAFAAAABmFtb3VudAUAAAADbmlsCAUAAAADaW52AAAABmNhbGxlcgAAAAAAAAAAAAUAAAAEdW5pdAkBAAAACHJlcGF5RmVlAAAABQUAAAADaW52CQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAxiZXRSZXN1bHRLZXkCAAAACHJldHVybmVkBQAAAANuaWwIBQAAAAZ0eERhdGEAAAAGc2VuZGVyBQAAAAZhbW91bnQIBQAAAAZ0eERhdGEAAAAHYXNzZXRJZAAAAAA2ErDi", "chainId": 84, "height": 653846, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 3 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let maxFee = 1000000
5+
6+let minAmount = getIntegerValue(this, "config_min_amount")
7+
8+let acceptBetUntil = getIntegerValue(this, "config_bet_until")
9+
10+let tradeStart = getIntegerValue(this, "config_trade_start")
11+
12+let tradeEnd = getIntegerValue(this, "config_trade_end")
13+
14+let acceptAssets = [getStringValue(this, "config_asset_1"), getStringValue(this, "config_asset_2")]
15+
16+let tradeAccount = addressFromStringValue(getStringValue(this, "config_trade_account"))
17+
18+func repayFee (i,ws,address,amount,asset) = if ((i.fee > maxFee))
19+ then throw("unreasonable large fee")
20+ else if ((i.feeAssetId != unit))
21+ then throw("fee must be in WAVES")
22+ else ScriptResult(ws, TransferSet([ScriptTransfer(i.caller, i.fee, unit), ScriptTransfer(address, amount, asset)]))
23+
24+
25+func assetMnemonic (assetId) = match assetId {
26+ case u: Unit =>
27+ "WAVES"
28+ case b: ByteVector =>
29+ toBase58String(b)
30+ case _ =>
31+ throw()
32+}
33+
34+
35+func getIntDefault (key,default) = match getInteger(this, key) {
36+ case i: Int =>
37+ i
38+ case _ =>
39+ default
40+}
41+
42+
43+func getAssetBalance (assetId) = if ((assetId == "WAVES"))
44+ then (wavesBalance(this) - minAmount)
45+ else assetBalance(this, extract(fromBase58String(assetId)))
46+
47+
48+func getAssetIdFromMnemonic (assetId) = if ((assetId == "WAVES"))
49+ then unit
50+ else fromBase58String(assetId)
51+
52+
53+@Callable(i)
54+func letsTrade () = {
55+ let tradeStartedKey = "trade_started"
56+ if ((getBoolean(this, tradeStartedKey) == true))
57+ then throw("Trades start already triggered")
58+ else if ((tradeStart > lastBlock.timestamp))
59+ then throw("Trades no ready to start yet")
60+ else if ((lastBlock.timestamp > tradeEnd))
61+ then throw("Trades finished")
62+ else if ((i.fee > maxFee))
63+ then throw("unreasonable large fee")
64+ else if ((i.feeAssetId != unit))
65+ then throw("fee must be in WAVES")
66+ else {
67+ let asset1Balance = getAssetBalance(acceptAssets[0])
68+ let asset2Balance = getAssetBalance(acceptAssets[1])
69+ if (if ((0 > asset1Balance))
70+ then true
71+ else (0 > asset2Balance))
72+ then throw("not enought bets to start trades")
73+ else ScriptResult(WriteSet([DataEntry(tradeStartedKey, true)]), TransferSet([ScriptTransfer(i.caller, i.fee, unit), ScriptTransfer(tradeAccount, asset1Balance, getAssetIdFromMnemonic(acceptAssets[0])), ScriptTransfer(tradeAccount, asset2Balance, getAssetIdFromMnemonic(acceptAssets[1]))]))
74+ }
75+ }
76+
77+
78+
79+@Callable(inv)
80+func registerBetTx (tx) = {
81+ let txData = extract(transferTransactionById(fromBase58String(tx)))
82+ let owner = toBase58String(txData.sender.bytes)
83+ let asset = assetMnemonic(txData.assetId)
84+ let amount = txData.amount
85+ let txTimestamp = extract(blockInfoByHeight(extract(transactionHeightById(fromBase58String(tx))))).timestamp
86+ let betAmountKey = (((("bet_" + owner) + "_") + asset) + "_amount")
87+ let betTotalAmountKey = (("bet_total_" + asset) + "_amount")
88+ let betResultKey = (("tx_" + tx) + "_result")
89+ if ((txData.recipient != this))
90+ then throw("invalid destination")
91+ else if (if ((asset != acceptAssets[0]))
92+ then (asset != acceptAssets[1])
93+ else false)
94+ then throw("asset not accepted")
95+ else if (isDefined(getInteger(this, betResultKey)))
96+ then throw("tx already registered")
97+ else if ((minAmount > amount))
98+ then throw(("min amount is " + toString(minAmount)))
99+ else if ((acceptBetUntil > txTimestamp))
100+ then repayFee(inv, WriteSet([DataEntry(betResultKey, "accepted"), DataEntry(betAmountKey, (getIntDefault(betAmountKey, 0) + amount)), DataEntry(betTotalAmountKey, (getIntDefault(betTotalAmountKey, 0) + amount))]), inv.caller, 0, unit)
101+ else repayFee(inv, WriteSet([DataEntry(betResultKey, "returned")]), txData.sender, amount, txData.assetId)
102+ }
103+
104+

github/deemru/w8io/026f985 
20.67 ms