tx · 5wHtuzsJN8qKzeog6CWqPU1Uke6Y3jfr4wqxLNi9vWsW 3N3FVhMzaZRoXmBR4fKKaVPC3MuquNGFr2X: -0.01400000 Waves 2019.10.04 13:15 [704842] smart account 3N3FVhMzaZRoXmBR4fKKaVPC3MuquNGFr2X > SELF 0.00000000 Waves
{ "type": 13, "id": "5wHtuzsJN8qKzeog6CWqPU1Uke6Y3jfr4wqxLNi9vWsW", "fee": 1400000, "feeAssetId": null, "timestamp": 1570183736882, "version": 1, "sender": "3N3FVhMzaZRoXmBR4fKKaVPC3MuquNGFr2X", "senderPublicKey": "DivDKB9nvX99D8JQaqsuYpazAF6czdJeeLkHiTwujziu", "proofs": [ "4isgantXXhknYHLYohtjAPCZMpK2qRvyWQLRjMf2xgqymwV2FQPmgv6vPmz9UyikSL1rLMv3HL7ULS969mXnHehv" ], "script": "base64:AAIDAAAAAAAAAA0IARIAEgASAwoBARIAAAAABAAAAAAFb3duZXIBAAAAGgFUkkWBznq2O1f29pbkny82o1O33dqu+9V8AAAAAA1hc3NldElkVG9rZW5BBQAAAAR1bml0AAAAAA1hc3NldElkVG9rZW5CAQAAACDDkQjhcLsN6Xt8b2FiEwssvgl7CbrT6dBGVW0IHBxljQAAAAAJY29taXNzaW9uAAAAAAAAAAAKAAAABAAAAApjb250ZXh0T2JqAQAAAARmdW5kAAAAAAQAAAAHcGF5bWVudAQAAAAHJG1hdGNoMAgFAAAACmNvbnRleHRPYmoAAAAHcGF5bWVudAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAPQXR0YWNoZWRQYXltZW50BAAAAAFwBQAAAAckbWF0Y2gwBQAAAAFwCQAAAgAAAAECAAAAFFBheW1lbnQgbm90IGF0dGFjaGVkBAAAAA9hc3NldElkUmVjZWl2ZWQIBQAAAAdwYXltZW50AAAAB2Fzc2V0SWQEAAAAEnRva2VuUmVjZWl2ZUFtb3VudAgFAAAAB3BheW1lbnQAAAAGYW1vdW50AwMJAAAAAAAAAgUAAAAPYXNzZXR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Rva2VuQQIAAAAJd2l0aGRyYXduCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACAgAAAAxhbW91bnRUb2tlbkICAAAACXdpdGhkcmF3bgUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAApjb250ZXh0T2JqAAAABmNhbGxlcgUAAAANQmFsYW5jZVRva2VuQQUAAAANYXNzZXRJZFRva2VuQQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAAKY29udGV4dE9iagAAAAZjYWxsZXIFAAAADUJhbGFuY2VUb2tlbkIFAAAADWFzc2V0SWRUb2tlbkIFAAAAA25pbAkAAAIAAAABAgAAAB1Zb3UgYXJlIG5vdCBleGNoYW5nZXIncyBvd25lcgAAAAEAAAAKY29udGV4dE9iagEAAAAGdmVyaWZ5AAAAAAb3jNlu", "chainId": 84, "height": 704842, "spentComplexity": 0 } View: original | compacted Prev: EBucVkCtu9JTgSYdkT9rfMmqABDKJLy8seXjEKnUpuEC Next: DDK7hBfUJXgYLJ4kfoAscGX1hT7qRedhnrkEKgmHu4zQ Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let owner = base58'3N3FVhMzaZRoXmBR4fKKaVPC3MuquNGFr2X' | |
5 | 5 | ||
6 | 6 | let assetIdTokenA = unit | |
7 | 7 | ||
8 | 8 | let assetIdTokenB = base58'EAQmgtbWGdquUu2mz853vKXRmHaUw83tSWAQfkdsevNp' | |
9 | 9 | ||
10 | 10 | let comission = 10 | |
11 | 11 | ||
12 | 12 | @Callable(contextObj) | |
13 | 13 | func fund () = { | |
14 | 14 | let payment = match contextObj.payment { | |
15 | 15 | case p: AttachedPayment => | |
16 | 16 | p | |
17 | 17 | case _ => | |
18 | 18 | throw("Payment not attached") | |
19 | 19 | } | |
20 | 20 | let assetIdReceived = payment.assetId | |
21 | 21 | let tokenReceiveAmount = payment.amount | |
22 | 22 | if (if ((assetIdReceived == assetIdTokenA)) | |
23 | 23 | then !(isDefined(getBoolean(this, "fundA"))) | |
24 | 24 | else false) | |
25 | 25 | then WriteSet([DataEntry("amountTokenA", tokenReceiveAmount), DataEntry("fundA", true)]) | |
26 | 26 | else if (if ((assetIdReceived == assetIdTokenB)) | |
27 | 27 | then !(isDefined(getBoolean(this, "fundB"))) | |
28 | 28 | else false) | |
29 | 29 | then WriteSet([DataEntry("amountTokenB", tokenReceiveAmount), DataEntry("fundB", true)]) | |
30 | 30 | else throw("already funded or you try to fund with incorrect asset") | |
31 | 31 | } | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | ||
35 | 35 | @Callable(contextObj) | |
36 | 36 | func replenishment () = { | |
37 | 37 | let payment = match contextObj.payment { | |
38 | 38 | case p: AttachedPayment => | |
39 | 39 | p | |
40 | 40 | case _ => | |
41 | 41 | throw("Payment not attached") | |
42 | 42 | } | |
43 | 43 | let assetIdReceived = payment.assetId | |
44 | 44 | let tokenReceiveAmount = payment.amount | |
45 | 45 | if (if ((assetIdReceived == assetIdTokenA)) | |
46 | 46 | then isDefined(getBoolean(this, "fundA")) | |
47 | 47 | else false) | |
48 | 48 | then { | |
49 | 49 | let amountTokenA = getIntegerValue(this, "amountTokenA") | |
50 | 50 | WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount))]) | |
51 | 51 | } | |
52 | 52 | else if (if ((assetIdReceived == assetIdTokenB)) | |
53 | 53 | then isDefined(getBoolean(this, "fundB")) | |
54 | 54 | else false) | |
55 | 55 | then { | |
56 | 56 | let amountTokenB = getIntegerValue(this, "amountTokenB") | |
57 | 57 | WriteSet([DataEntry("amountTokenA", (amountTokenB + tokenReceiveAmount))]) | |
58 | 58 | } | |
59 | 59 | else throw("there was an error in the replenishment") | |
60 | 60 | } | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | ||
64 | 64 | @Callable(contextObj) | |
65 | 65 | func exchanger (minTokenRecieve) = if (if ((0 > comission)) | |
66 | 66 | then true | |
67 | 67 | else (comission > 100)) | |
68 | 68 | then throw("incorrect comission value") | |
69 | 69 | else { | |
70 | 70 | let amountTokenB = getIntegerValue(this, "amountTokenB") | |
71 | 71 | let amountTokenA = getIntegerValue(this, "amountTokenA") | |
72 | 72 | let payment = match contextObj.payment { | |
73 | 73 | case p: AttachedPayment => | |
74 | 74 | p | |
75 | 75 | case _ => | |
76 | 76 | throw("Payment not attached") | |
77 | 77 | } | |
78 | 78 | let assetIdReceived = payment.assetId | |
79 | 79 | let tokenReceiveAmount = payment.amount | |
80 | 80 | let count = match getInteger(this, "exchange_count") { | |
81 | 81 | case i: Int => | |
82 | 82 | value(getInteger(this, "exchange_count")) | |
83 | 83 | case _ => | |
84 | 84 | 0 | |
85 | 85 | } | |
86 | 86 | if ((assetIdReceived == assetIdTokenB)) | |
87 | 87 | then { | |
88 | 88 | let tokenSendAmount = ((fraction(amountTokenA, tokenReceiveAmount, (tokenReceiveAmount + amountTokenB)) * (100 - comission)) / 100) | |
89 | 89 | if ((minTokenRecieve > tokenSendAmount)) | |
90 | 90 | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") | |
91 | 91 | else { | |
92 | 92 | let assetIdSent = assetIdTokenA | |
93 | 93 | ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA - tokenSendAmount)), DataEntry("amountTokenB", (amountTokenB + tokenReceiveAmount)), DataEntry("exchange_count", (count + 1))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) | |
94 | 94 | } | |
95 | 95 | } | |
96 | 96 | else if ((assetIdReceived == assetIdTokenA)) | |
97 | 97 | then { | |
98 | 98 | let tokenSendAmount = ((fraction(amountTokenB, tokenReceiveAmount, (tokenReceiveAmount + amountTokenA)) * (100 - comission)) / 100) | |
99 | 99 | if ((minTokenRecieve > tokenSendAmount)) | |
100 | 100 | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") | |
101 | 101 | else { | |
102 | 102 | let assetIdSent = assetIdTokenB | |
103 | 103 | ScriptResult(WriteSet([DataEntry("amountTokenA", (amountTokenA + tokenReceiveAmount)), DataEntry("amountTokenB", (amountTokenB - tokenSendAmount)), DataEntry("exchange_count", (count + 1))]), TransferSet([ScriptTransfer(contextObj.caller, tokenSendAmount, assetIdSent)])) | |
104 | 104 | } | |
105 | 105 | } | |
106 | 106 | else throw("Asset is not allowed") | |
107 | 107 | } | |
108 | 108 | ||
109 | 109 | ||
110 | 110 | ||
111 | 111 | @Callable(contextObj) | |
112 | 112 | func withdraw () = { | |
113 | 113 | let BalanceTokenA = assetBalance(this, assetIdTokenA) | |
114 | 114 | let BalanceTokenB = assetBalance(this, assetIdTokenB) | |
115 | 115 | if ((contextObj.caller.bytes == owner)) | |
116 | 116 | then ScriptResult(WriteSet([DataEntry("amountTokenA", "withdrawn"), DataEntry("amountTokenB", "withdrawn")]), TransferSet([ScriptTransfer(contextObj.caller, BalanceTokenA, assetIdTokenA), ScriptTransfer(contextObj.caller, BalanceTokenB, assetIdTokenB)])) | |
117 | 117 | else throw("You are not exchanger's owner") | |
118 | 118 | } | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | @Verifier(contextObj) | |
122 | 122 | func verify () = true | |
123 | 123 |
github/deemru/w8io/026f985 26.70 ms ◑