tx · 8SdN8zFaAmoeoGNaAXkVPgfhVN7xpggXiwiGikZtJMNJ

3Mrfs8X5WEzqypoGxGFMBYSr1SsvrBbQnFM:  -0.01800000 Waves

2020.08.11 10:46 [1127571] smart account 3Mrfs8X5WEzqypoGxGFMBYSr1SsvrBbQnFM > SELF 0.00000000 Waves

{ "type": 13, "id": "8SdN8zFaAmoeoGNaAXkVPgfhVN7xpggXiwiGikZtJMNJ", "fee": 1800000, "feeAssetId": null, "timestamp": 1597132019578, "version": 1, "sender": "3Mrfs8X5WEzqypoGxGFMBYSr1SsvrBbQnFM", "senderPublicKey": "HUrghLi67MP4Asd8PDQroCdnCj1QcSQK2PRRkUyhYDJ9", "proofs": [ "2iGY7Sq8zCa46BshDqtvmGqadvpG149jBBXDc4cLPr2pz6ioR7Hbz4b1uiWuZSmXXy1HVB5aFq2MC6DsN7hsQioY" ], "script": "base64:AAIDAAAAAAAAAA0IARIAEgASAwoBARIAAAAACAAAAAAFb3duZXIBAAAAGgFUkVp9YFceKxS4tZgdZWFQ73BG70sIYCklAAAAAAhJZFRva2VuQQIAAAAFV0FWRVMAAAAACElkVG9rZW5CAgAAACxKNGVlMWJGcU5TcmRheUZvVWVnWHZCWGQxWFltSnRYaDFOUW51RkxDUHFvVwAAAAAJY29taXNzaW9uAAAAAAAAAAAAAAAAAAd2ZXJzaW9uAgAAAAUwLjAuMQEAAAAHYXNzZXRJZAAAAAEAAAAFYXNzZXQDCQAAAAAAAAIFAAAABWFzc2V0AgAAAAVXQVZFUwUAAAAEdW5pdAkAAlkAAAABBQAAAAVhc3NldAAAAAANYXNzZXRJZFRva2VuQQkBAAAAB2Fzc2V0SWQAAAABBQAAAAhJZFRva2VuQQAAAAANYXNzZXRJZFRva2VuQgkBAAAAB2Fzc2V0SWQAAAABBQAAAAhJZFRva2VuQgAAAAQAAAAKY29udGV4dE9iagEAAAAEZnVuZAAAAAAEAAAAB3BheW1lbnQEAAAAByRtYXRjaDAIBQAAAApjb250ZXh0T2JqAAAA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ETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAApjb250ZXh0T2JqAAAABmNhbGxlcgUAAAANQmFsYW5jZVRva2VuQQUAAAANYXNzZXRJZFRva2VuQQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAAKY29udGV4dE9iagAAAAZjYWxsZXIFAAAADUJhbGFuY2VUb2tlbkIFAAAADWFzc2V0SWRUb2tlbkIFAAAAA25pbAkAAAIAAAABAgAAAB1Zb3UgYXJlIG5vdCBleGNoYW5nZXIncyBvd25lcgAAAAAockKy", "chainId": 84, "height": 1127571, "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 owner = base58'3N3AeA5FWm7EHheHoik8BBEA3GXXJosnVY8'
5+
6+let IdTokenA = "WAVES"
7+
8+let IdTokenB = "J4ee1bFqNSrdayFoUegXvBXd1XYmJtXh1NQnuFLCPqoW"
9+
10+let comission = 0
11+
12+let version = "0.0.1"
13+
14+func assetId (asset) = if ((asset == "WAVES"))
15+ then unit
16+ else fromBase58String(asset)
17+
18+
19+let assetIdTokenA = assetId(IdTokenA)
20+
21+let assetIdTokenB = assetId(IdTokenB)
22+
23+@Callable(contextObj)
24+func fund () = {
25+ let payment = match contextObj.payment {
26+ case p: AttachedPayment =>
27+ p
28+ case _ =>
29+ throw("Payment not attached")
30+ }
31+ let assetIdReceived = payment.assetId
32+ let tokenReceiveAmount = payment.amount
33+ if (isDefined(assetIdTokenA))
34+ then throw("aaaa")
35+ else if (if ((assetIdReceived == assetIdTokenA))
36+ then !(isDefined(getBoolean(this, "fundA")))
37+ else false)
38+ then if (isDefined(getBoolean(this, "fundB")))
39+ 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))])
40+ else WriteSet([DataEntry("amountTokenA", tokenReceiveAmount), DataEntry("assetIdTokenA", IdTokenA), DataEntry("fundA", true)])
41+ else if (if ((assetIdReceived == assetIdTokenB))
42+ then !(isDefined(getBoolean(this, "fundB")))
43+ else false)
44+ then if (isDefined(getBoolean(this, "fundA")))
45+ 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))])
46+ else WriteSet([DataEntry("amountTokenB", tokenReceiveAmount), DataEntry("assetIdTokenB", IdTokenB), DataEntry("fundB", true)])
47+ else throw("already funded or you try to fund with incorrect asset")
48+ }
49+
50+
51+
52+@Callable(contextObj)
53+func replenishment () = {
54+ let payment = match contextObj.payment {
55+ case p: AttachedPayment =>
56+ p
57+ case _ =>
58+ throw("Payment not attached")
59+ }
60+ let assetIdReceived = payment.assetId
61+ let tokenReceiveAmount = payment.amount
62+ if (if ((assetIdReceived == assetIdTokenA))
63+ then isDefined(getBoolean(this, "fundA"))
64+ else false)
65+ then {
66+ let amountTokenA = getIntegerValue(this, "amountTokenA")
67+ WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount))])
68+ }
69+ else if (if ((assetIdReceived == assetIdTokenB))
70+ then isDefined(getBoolean(this, "fundB"))
71+ else false)
72+ then {
73+ let amountTokenB = getIntegerValue(this, "amountTokenB")
74+ WriteSet([DataEntry("amountTokenB", (amountTokenB + tokenReceiveAmount))])
75+ }
76+ else throw("there was an error in the replenishment")
77+ }
78+
79+
80+
81+@Callable(contextObj)
82+func exchanger (minTokenRecieve) = if (if ((0 > comission))
83+ then true
84+ else (comission > 100))
85+ then throw("incorrect comission value")
86+ else {
87+ let amountTokenB = getIntegerValue(this, "amountTokenB")
88+ let amountTokenA = getIntegerValue(this, "amountTokenA")
89+ let payment = match contextObj.payment {
90+ case p: AttachedPayment =>
91+ p
92+ case _ =>
93+ throw("Payment not attached")
94+ }
95+ let assetIdReceived = payment.assetId
96+ let tokenReceiveAmount = payment.amount
97+ let count = match getInteger(this, "exchange_count") {
98+ case i: Int =>
99+ (value(getInteger(this, "exchange_count")) + i)
100+ case _ =>
101+ 0
102+ }
103+ if ((assetIdReceived == assetIdTokenB))
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+ }
113+ else if ((assetIdReceived == assetIdTokenA))
114+ then {
115+ let tokenSendAmount = ((fraction(amountTokenB, tokenReceiveAmount, (tokenReceiveAmount + amountTokenA)) * (100 - comission)) / 100)
116+ if ((minTokenRecieve > tokenSendAmount))
117+ then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
118+ else {
119+ let assetIdSent = assetIdTokenB
120+ ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount)), DataEntry("amountTokenB", (amountTokenB - tokenSendAmount)), DataEntry("exchange_count", (count + 1))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
121+ }
122+ }
123+ else throw("Asset is not allowed")
124+ }
125+
126+
127+
128+@Callable(contextObj)
129+func withdraw () = {
130+ let BalanceTokenA = assetBalance(this, assetIdTokenA)
131+ let BalanceTokenB = assetBalance(this, assetIdTokenB)
132+ if ((contextObj.caller.bytes == owner))
133+ then ScriptResult(WriteSet([DataEntry("amountTokenA", "withdrawn"), DataEntry("amountTokenB", "withdrawn"), DataEntry("status", false)]), TransferSet([ScriptTransfer(contextObj.caller, BalanceTokenA, assetIdTokenA), ScriptTransfer(contextObj.caller, BalanceTokenB, assetIdTokenB)]))
134+ else throw("You are not exchanger's owner")
135+ }
136+
137+

github/deemru/w8io/169f3d6 
30.05 ms