tx · DDK7hBfUJXgYLJ4kfoAscGX1hT7qRedhnrkEKgmHu4zQ

3N3FVhMzaZRoXmBR4fKKaVPC3MuquNGFr2X:  -0.01400000 Waves

2019.10.04 13:16 [704843] smart account 3N3FVhMzaZRoXmBR4fKKaVPC3MuquNGFr2X > SELF 0.00000000 Waves

{ "type": 13, "id": "DDK7hBfUJXgYLJ4kfoAscGX1hT7qRedhnrkEKgmHu4zQ", "fee": 1400000, "feeAssetId": null, "timestamp": 1570184181151, "version": 1, "sender": "3N3FVhMzaZRoXmBR4fKKaVPC3MuquNGFr2X", "senderPublicKey": "DivDKB9nvX99D8JQaqsuYpazAF6czdJeeLkHiTwujziu", "proofs": [ "4HhDAamzyYCRc986uDawQ34CE4oDRKZeYvrmLvcSC46GhUHp9sWnbhfUC1jRL4rjVwGwVnYWpM57ubzZCcijkmrB" ], "script": "base64:AAIDAAAAAAAAAA0IARIAEgASAwoBARIAAAAACAAAAAAFb3duZXIBAAAAGgFUKZu16zz0P7yUdi6t8UaXs5JHLsd1lCKHAAAAAAhJZFRva2VuQQIAAAAFV0FWRVMAAAAACElkVG9rZW5CAgAAACxDVjR2ZmprZXZuM2FKNHRLYU1uOWdQSHVnWXp0dTZSaER3MmV0ZTM0U3hpVgAAAAAJY29taXNzaW9uAAAAAAAAAAALAAAAAAd2ZXJzaW9uAgAAAAUwLjAuMAEAAAAHYXNzZXRJZAAAAAEAAAAFYXNzZXQDCQAAAAAAAAIFAAAABWFzc2V0AgAAAAVXQVZFUwUAAAAEdW5pdAkAAlkAAAABBQAAAAVhc3NldAAAAAANYXNzZXRJZFRva2VuQQkBAAAAB2Fzc2V0SWQAAAABBQAAAAhJZFRva2VuQQAAAAANYXNzZXRJZFRva2VuQgkBAAAAB2Fzc2V0SWQAAAABBQAAAAhJZFRva2VuQgAAAAQAAAAKY29udGV4dE9iagEAAAAEZnVuZAAAAAAEAAAAB3BheW1lbnQEAAAAByRtYXRjaDAIBQAAAApjb250ZXh0T2JqAAAAB3BheW1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AAAANYXNzZXRJZFRva2VuQQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAAKY29udGV4dE9iagAAAAZjYWxsZXIFAAAADUJhbGFuY2VUb2tlbkIFAAAADWFzc2V0SWRUb2tlbkIFAAAAA25pbAkAAAIAAAABAgAAAB1Zb3UgYXJlIG5vdCBleGNoYW5nZXIncyBvd25lcgAAAAEAAAAKY29udGV4dE9iagEAAAAGdmVyaWZ5AAAAAAcDiC0+", "chainId": 84, "height": 704843, "spentComplexity": 0 } View: original | compacted Prev: 5wHtuzsJN8qKzeog6CWqPU1Uke6Y3jfr4wqxLNi9vWsW Next: none Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let owner = base58'3N3FVhMzaZRoXmBR4fKKaVPC3MuquNGFr2X'
4+let owner = base58'3Msi61kQWW3QpgS2L1t7wcprGhPxyPj5b6W'
55
6-let assetIdTokenA = unit
6+let IdTokenA = "WAVES"
77
8-let assetIdTokenB = base58'EAQmgtbWGdquUu2mz853vKXRmHaUw83tSWAQfkdsevNp'
8+let IdTokenB = "CV4vfjkevn3aJ4tKaMn9gPHugYztu6RhDw2ete34SxiV"
99
10-let comission = 10
10+let comission = 11
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)
1122
1223 @Callable(contextObj)
1324 func fund () = {
2233 if (if ((assetIdReceived == assetIdTokenA))
2334 then !(isDefined(getBoolean(this, "fundA")))
2435 else false)
25- then WriteSet([DataEntry("amountTokenA", tokenReceiveAmount), DataEntry("fundA", true)])
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)])
2639 else if (if ((assetIdReceived == assetIdTokenB))
2740 then !(isDefined(getBoolean(this, "fundB")))
2841 else false)
29- then WriteSet([DataEntry("amountTokenB", tokenReceiveAmount), DataEntry("fundB", true)])
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)])
3045 else throw("already funded or you try to fund with incorrect asset")
3146 }
3247
5469 else false)
5570 then {
5671 let amountTokenB = getIntegerValue(this, "amountTokenB")
57- WriteSet([DataEntry("amountTokenA", (amountTokenB + tokenReceiveAmount))])
72+ WriteSet([DataEntry("amountTokenB", (amountTokenB + tokenReceiveAmount))])
5873 }
5974 else throw("there was an error in the replenishment")
6075 }
113128 let BalanceTokenA = assetBalance(this, assetIdTokenA)
114129 let BalanceTokenB = assetBalance(this, assetIdTokenB)
115130 if ((contextObj.caller.bytes == owner))
116- then ScriptResult(WriteSet([DataEntry("amountTokenA", "withdrawn"), DataEntry("amountTokenB", "withdrawn")]), TransferSet([ScriptTransfer(contextObj.caller, BalanceTokenA, assetIdTokenA), ScriptTransfer(contextObj.caller, BalanceTokenB, assetIdTokenB)]))
131+ then ScriptResult(WriteSet([DataEntry("amountTokenA", "withdrawn"), DataEntry("amountTokenB", "withdrawn"), DataEntry("status", false)]), TransferSet([ScriptTransfer(contextObj.caller, BalanceTokenA, assetIdTokenA), ScriptTransfer(contextObj.caller, BalanceTokenB, assetIdTokenB)]))
117132 else throw("You are not exchanger's owner")
118133 }
119134
120135
121136 @Verifier(contextObj)
122-func verify () = true
137+func verify () = false
123138
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let owner = base58'3N3FVhMzaZRoXmBR4fKKaVPC3MuquNGFr2X'
4+let owner = base58'3Msi61kQWW3QpgS2L1t7wcprGhPxyPj5b6W'
55
6-let assetIdTokenA = unit
6+let IdTokenA = "WAVES"
77
8-let assetIdTokenB = base58'EAQmgtbWGdquUu2mz853vKXRmHaUw83tSWAQfkdsevNp'
8+let IdTokenB = "CV4vfjkevn3aJ4tKaMn9gPHugYztu6RhDw2ete34SxiV"
99
10-let comission = 10
10+let comission = 11
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)
1122
1223 @Callable(contextObj)
1324 func fund () = {
1425 let payment = match contextObj.payment {
1526 case p: AttachedPayment =>
1627 p
1728 case _ =>
1829 throw("Payment not attached")
1930 }
2031 let assetIdReceived = payment.assetId
2132 let tokenReceiveAmount = payment.amount
2233 if (if ((assetIdReceived == assetIdTokenA))
2334 then !(isDefined(getBoolean(this, "fundA")))
2435 else false)
25- then WriteSet([DataEntry("amountTokenA", tokenReceiveAmount), DataEntry("fundA", true)])
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)])
2639 else if (if ((assetIdReceived == assetIdTokenB))
2740 then !(isDefined(getBoolean(this, "fundB")))
2841 else false)
29- then WriteSet([DataEntry("amountTokenB", tokenReceiveAmount), DataEntry("fundB", true)])
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)])
3045 else throw("already funded or you try to fund with incorrect asset")
3146 }
3247
3348
3449
3550 @Callable(contextObj)
3651 func replenishment () = {
3752 let payment = match contextObj.payment {
3853 case p: AttachedPayment =>
3954 p
4055 case _ =>
4156 throw("Payment not attached")
4257 }
4358 let assetIdReceived = payment.assetId
4459 let tokenReceiveAmount = payment.amount
4560 if (if ((assetIdReceived == assetIdTokenA))
4661 then isDefined(getBoolean(this, "fundA"))
4762 else false)
4863 then {
4964 let amountTokenA = getIntegerValue(this, "amountTokenA")
5065 WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount))])
5166 }
5267 else if (if ((assetIdReceived == assetIdTokenB))
5368 then isDefined(getBoolean(this, "fundB"))
5469 else false)
5570 then {
5671 let amountTokenB = getIntegerValue(this, "amountTokenB")
57- WriteSet([DataEntry("amountTokenA", (amountTokenB + tokenReceiveAmount))])
72+ WriteSet([DataEntry("amountTokenB", (amountTokenB + tokenReceiveAmount))])
5873 }
5974 else throw("there was an error in the replenishment")
6075 }
6176
6277
6378
6479 @Callable(contextObj)
6580 func exchanger (minTokenRecieve) = if (if ((0 > comission))
6681 then true
6782 else (comission > 100))
6883 then throw("incorrect comission value")
6984 else {
7085 let amountTokenB = getIntegerValue(this, "amountTokenB")
7186 let amountTokenA = getIntegerValue(this, "amountTokenA")
7287 let payment = match contextObj.payment {
7388 case p: AttachedPayment =>
7489 p
7590 case _ =>
7691 throw("Payment not attached")
7792 }
7893 let assetIdReceived = payment.assetId
7994 let tokenReceiveAmount = payment.amount
8095 let count = match getInteger(this, "exchange_count") {
8196 case i: Int =>
8297 value(getInteger(this, "exchange_count"))
8398 case _ =>
8499 0
85100 }
86101 if ((assetIdReceived == assetIdTokenB))
87102 then {
88103 let tokenSendAmount = ((fraction(amountTokenA, tokenReceiveAmount, (tokenReceiveAmount + amountTokenB)) * (100 - comission)) / 100)
89104 if ((minTokenRecieve > tokenSendAmount))
90105 then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
91106 else {
92107 let assetIdSent = assetIdTokenA
93108 ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA - tokenSendAmount)), DataEntry("amountTokenB", (amountTokenB + tokenReceiveAmount)), DataEntry("exchange_count", (count + 1))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
94109 }
95110 }
96111 else if ((assetIdReceived == assetIdTokenA))
97112 then {
98113 let tokenSendAmount = ((fraction(amountTokenB, tokenReceiveAmount, (tokenReceiveAmount + amountTokenA)) * (100 - comission)) / 100)
99114 if ((minTokenRecieve > tokenSendAmount))
100115 then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level")
101116 else {
102117 let assetIdSent = assetIdTokenB
103118 ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount)), DataEntry("amountTokenB", (amountTokenB - tokenSendAmount)), DataEntry("exchange_count", (count + 1))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)]))
104119 }
105120 }
106121 else throw("Asset is not allowed")
107122 }
108123
109124
110125
111126 @Callable(contextObj)
112127 func withdraw () = {
113128 let BalanceTokenA = assetBalance(this, assetIdTokenA)
114129 let BalanceTokenB = assetBalance(this, assetIdTokenB)
115130 if ((contextObj.caller.bytes == owner))
116- then ScriptResult(WriteSet([DataEntry("amountTokenA", "withdrawn"), DataEntry("amountTokenB", "withdrawn")]), TransferSet([ScriptTransfer(contextObj.caller, BalanceTokenA, assetIdTokenA), ScriptTransfer(contextObj.caller, BalanceTokenB, assetIdTokenB)]))
131+ then ScriptResult(WriteSet([DataEntry("amountTokenA", "withdrawn"), DataEntry("amountTokenB", "withdrawn"), DataEntry("status", false)]), TransferSet([ScriptTransfer(contextObj.caller, BalanceTokenA, assetIdTokenA), ScriptTransfer(contextObj.caller, BalanceTokenB, assetIdTokenB)]))
117132 else throw("You are not exchanger's owner")
118133 }
119134
120135
121136 @Verifier(contextObj)
122-func verify () = true
137+func verify () = false
123138

github/deemru/w8io/169f3d6 
50.48 ms