tx · HDqqj1i84RuVvKDKeGfbwwBkirSQxERXh5YjDzmgJBAx

3N2viee3La2jqpP4cxMfmsLbu4LShePR6F2:  -0.01000000 Waves

2019.09.26 16:21 [693379] smart account 3N2viee3La2jqpP4cxMfmsLbu4LShePR6F2 > SELF 0.00000000 Waves

{ "type": 13, "id": "HDqqj1i84RuVvKDKeGfbwwBkirSQxERXh5YjDzmgJBAx", "fee": 1000000, "feeAssetId": null, "timestamp": 1569504101833, "version": 1, "sender": "3N2viee3La2jqpP4cxMfmsLbu4LShePR6F2", "senderPublicKey": "2WbK8r7jxZbWuB3stBQqbfdRchGDMcMLxAynZMNMriVz", "proofs": [ "59V3zrkh1k2GgC2GFhkbH6mqXNTExkmFjMMz4WeYoaNWCscj2DjZYwp6PAPBngg4gtqupkpCFNy7mLKwzPfZJEHp" ], "script": "base64:AAIDAAAAAAAAAA0IARIAEgASAwoBARIAAAAACAAAAAAFb3duZXIBAAAAGgFUcDRNylIF8rMhayYjpver9p7zXEqccbKCAAAAAAhJZFRva2VuQQIAAAAFV0FWRVMAAAAACElkVG9rZW5CAgAAACtia1luNEF5aks1ZEw1QUVOZGdQUEhFeUtWenZWWEtZN0RBaFdyNGNrZUFxAAAAAAljb21pc3Npb24AAAAAAAAAAAQAAAAAB3ZlcnNpb24CAAAABTAuMC4wAQAAAAdhc3NldElkAAAAAQAAAAVhc3NldAMJAAAAAAAAAgUAAAAFYXNzZXQCAAAABVdBVkVTBQAAAAR1bml0CQACWQAAAAEFAAAABWFzc2V0AAAAAA1hc3NldElkVG9rZW5BCQEAAAAHYXNzZXRJZAAAAAEFAAAACElkVG9rZW5BAAAAAA1hc3NldElkVG9rZW5CCQEAAAAHYXNzZXRJZAAAAAEFAAAACElkVG9rZW5CAAAABAAAAApjb250ZXh0T2JqAQAAAARmdW5kAAAAAAQAAAAHcGF5bWVudAQAAAAHJG1hdGNoMAgFAAAACmNvbnRleHRPYmoAAAAHcGF5bWVudAMJAAABAAAAAgUAAAAHJG1hdGNo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BCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAApjb250ZXh0T2JqAAAABmNhbGxlcgUAAAANQmFsYW5jZVRva2VuQgUAAAANYXNzZXRJZFRva2VuQgUAAAADbmlsCQAAAgAAAAECAAAAHVlvdSBhcmUgbm90IGV4Y2hhbmdlcidzIG93bmVyAAAAAQAAAApjb250ZXh0T2JqAQAAAAZ2ZXJpZnkAAAAAB05au74=", "chainId": 84, "height": 693379, "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'3Mz9N7YPfZPWGd4yYaX6H53Gcgrq6ifYiH7'
5+
6+let IdTokenA = "WAVES"
7+
8+let IdTokenB = "bkYn4AyjK5dL5AENdgPPHEyKVzvVXKY7DAhWr4ckeAq"
9+
10+let comission = 4
11+
12+let version = "0.0.0"
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 (if ((assetIdReceived == assetIdTokenA))
34+ then !(isDefined(getBoolean(this, "fundA")))
35+ else false)
36+ then if (isDefined(getBoolean(this, "fundB")))
37+ 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))])
38+ else WriteSet([DataEntry("amountTokenA", tokenReceiveAmount), DataEntry("assetIdTokenA", IdTokenA), DataEntry("fundA", true)])
39+ else if (if ((assetIdReceived == assetIdTokenB))
40+ then !(isDefined(getBoolean(this, "fundB")))
41+ else false)
42+ then if (isDefined(getBoolean(this, "fundA")))
43+ 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))])
44+ else WriteSet([DataEntry("amountTokenB", tokenReceiveAmount), DataEntry("assetIdTokenB", IdTokenB), DataEntry("fundB", true)])
45+ else throw("already funded or you try to fund with incorrect asset")
46+ }
47+
48+
49+
50+@Callable(contextObj)
51+func replenishment () = {
52+ let payment = match contextObj.payment {
53+ case p: AttachedPayment =>
54+ p
55+ case _ =>
56+ throw("Payment not attached")
57+ }
58+ let assetIdReceived = payment.assetId
59+ let tokenReceiveAmount = payment.amount
60+ if (if ((assetIdReceived == assetIdTokenA))
61+ then isDefined(getBoolean(this, "fundA"))
62+ else false)
63+ then {
64+ let amountTokenA = getIntegerValue(this, "amountTokenA")
65+ WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount))])
66+ }
67+ else if (if ((assetIdReceived == assetIdTokenB))
68+ then isDefined(getBoolean(this, "fundB"))
69+ else false)
70+ then {
71+ let amountTokenB = getIntegerValue(this, "amountTokenB")
72+ WriteSet([DataEntry("amountTokenB", (amountTokenB + tokenReceiveAmount))])
73+ }
74+ else throw("there was an error in the replenishment")
75+ }
76+
77+
78+
79+@Callable(contextObj)
80+func exchanger (minTokenRecieve) = if (if ((0 > comission))
81+ then true
82+ else (comission > 100))
83+ then throw("incorrect comission value")
84+ else {
85+ let amountTokenB = getIntegerValue(this, "amountTokenB")
86+ let amountTokenA = getIntegerValue(this, "amountTokenA")
87+ let payment = match contextObj.payment {
88+ case p: AttachedPayment =>
89+ p
90+ case _ =>
91+ throw("Payment not attached")
92+ }
93+ let assetIdReceived = payment.assetId
94+ let tokenReceiveAmount = payment.amount
95+ let count = match getInteger(this, "exchange_count") {
96+ case i: Int =>
97+ value(getInteger(this, "exchange_count"))
98+ case _ =>
99+ 0
100+ }
101+ if ((assetIdReceived == assetIdTokenB))
102+ then {
103+ let tokenSendAmount = ((fraction(amountTokenA, tokenReceiveAmount, (tokenReceiveAmount + amountTokenB)) * (100 - comission)) / 100)
104+ if ((minTokenRecieve > tokenSendAmount))
105+ then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
106+ else {
107+ let assetIdSent = assetIdTokenA
108+ ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA - tokenSendAmount)), DataEntry("amountTokenB", (amountTokenB + tokenReceiveAmount)), DataEntry("exchange_count", (count + 1))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
109+ }
110+ }
111+ else if ((assetIdReceived == assetIdTokenA))
112+ then {
113+ let tokenSendAmount = ((fraction(amountTokenB, tokenReceiveAmount, (tokenReceiveAmount + amountTokenA)) * (100 - comission)) / 100)
114+ if ((minTokenRecieve > tokenSendAmount))
115+ then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
116+ else {
117+ let assetIdSent = assetIdTokenB
118+ ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount)), DataEntry("amountTokenB", (amountTokenB - tokenSendAmount)), DataEntry("exchange_count", (count + 1))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
119+ }
120+ }
121+ else throw("Asset is not allowed")
122+ }
123+
124+
125+
126+@Callable(contextObj)
127+func withdraw () = {
128+ let BalanceTokenA = assetBalance(this, assetIdTokenA)
129+ let BalanceTokenB = assetBalance(this, assetIdTokenB)
130+ if ((contextObj.caller.bytes == owner))
131+ then ScriptResult(WriteSet([DataEntry("amountTokenA", "withdrawn"), DataEntry("amountTokenB", "withdrawn"), DataEntry("status", false)]), TransferSet([ScriptTransfer(contextObj.caller, BalanceTokenA, assetIdTokenA), ScriptTransfer(contextObj.caller, BalanceTokenB, assetIdTokenB)]))
132+ else throw("You are not exchanger's owner")
133+ }
134+
135+
136+@Verifier(contextObj)
137+func verify () = false
138+

github/deemru/w8io/169f3d6 
29.15 ms