tx · BxPZ7X4yufcYK1hqHP97UCHkYEURPJiebXpSkxG5oL1u 3N9fXabcuBDojzpVYcucAWK8Ys1vQmj7TNw: -0.01800000 Waves 2020.08.26 12:36 [1149507] smart account 3N9fXabcuBDojzpVYcucAWK8Ys1vQmj7TNw > SELF 0.00000000 Waves
{ "type": 13, "id": "BxPZ7X4yufcYK1hqHP97UCHkYEURPJiebXpSkxG5oL1u", "fee": 1800000, "feeAssetId": null, "timestamp": 1598434637826, "version": 1, "sender": "3N9fXabcuBDojzpVYcucAWK8Ys1vQmj7TNw", "senderPublicKey": "JDHqBuFt75kbciu2V63iJuZoHvPwz5Hp4AWAi8W8YmiC", "proofs": [ "97X2LsB9pZXs4pkCYJjKzv34pnmw2xF5Hpn4nnrLX2FxN3kcLQRwQKvSmYQj6AicewsdFaQyFDUJuR5bDF6jhWt" ], "script": "base64:AAIDAAAAAAAAAA0IARIAEgASAwoBARIAAAAACAAAAAAFb3duZXIBAAAAGgFUkVp9YFceKxS4tZgdZWFQ73BG70sIYCklAAAAAAhJZFRva2VuQQIAAAAFV0FWRVMAAAAACElkVG9rZW5CAgAAACxEV2d3Y1pUTWhTdm55WUNvV0xSVVhYU0gxUlNrelRoWExKaHd3OWd3a3FkbgAAAAAJY29taXNzaW9uAAAAAAAAAAAAAAAAAAd2ZXJzaW9uAgAAAAUwLjAuMQEAAAAHYXNzZXRJZAAAAAEAAAAFYXNzZXQDCQAAAAAAAAIFAAAABWFzc2V0AgAAAAVXQVZFUwUAAAAEdW5pdAkAAlkAAAABBQAAAAVhc3NldAAAAAANYXNzZXRJZFRva2VuQQkBAAAAB2Fzc2V0SWQAAAABBQAAAAhJZFRva2VuQQAAAAANYXNzZXRJZFRva2VuQgkBAAAAB2Fzc2V0SWQAAAABBQAAAAhJZFRva2VuQgAAAAQAAAAKY29udGV4dE9iagEAAAAEZnVuZAAAAAAEAAAAB3BheW1lbnQEAAAAByRtYXRjaDAIBQAAAApjb250ZXh0T2JqAAAAB3BheW1lbnQD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AAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAApjb250ZXh0T2JqAAAABmNhbGxlcgUAAAANQmFsYW5jZVRva2VuQQUAAAANYXNzZXRJZFRva2VuQQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAAKY29udGV4dE9iagAAAAZjYWxsZXIFAAAADUJhbGFuY2VUb2tlbkIFAAAADWFzc2V0SWRUb2tlbkIFAAAAA25pbAkAAAIAAAABAgAAAB1Zb3UgYXJlIG5vdCBleGNoYW5nZXIncyBvd25lcgAAAAC/V0Ag", "chainId": 84, "height": 1149507, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let a = base58'3N3AeA5FWm7EHheHoik8BBEA3GXXJosnVY8' | |
5 | + | ||
6 | + | let b = "WAVES" | |
7 | + | ||
8 | + | let c = "DWgwcZTMhSvnyYCoWLRUXXSH1RSkzThXLJhww9gwkqdn" | |
9 | + | ||
10 | + | let d = 0 | |
11 | + | ||
12 | + | let e = "0.0.1" | |
13 | + | ||
14 | + | func f (g) = if ((g == "WAVES")) | |
15 | + | then unit | |
16 | + | else fromBase58String(g) | |
17 | + | ||
18 | + | ||
19 | + | let h = f(b) | |
20 | + | ||
21 | + | let i = f(c) | |
22 | + | ||
23 | + | @Callable(j) | |
24 | + | func fund () = { | |
25 | + | let k = { | |
26 | + | let l = j.payment | |
27 | + | if ($isInstanceOf(l, "AttachedPayment")) | |
28 | + | then { | |
29 | + | let m = l | |
30 | + | m | |
31 | + | } | |
32 | + | else throw("Payment not attached") | |
33 | + | } | |
34 | + | let n = k.assetId | |
35 | + | let o = k.amount | |
36 | + | if (isDefined(h)) | |
37 | + | then throw("aaaa") | |
38 | + | else if (if ((n == h)) | |
39 | + | then !(isDefined(getBoolean(this, "fundA"))) | |
40 | + | else false) | |
41 | + | then if (isDefined(getBoolean(this, "fundB"))) | |
42 | + | then WriteSet([DataEntry("amountTokenA", o), DataEntry("fundA", true), DataEntry("exchange_count", 0), DataEntry("status", true), DataEntry("assetIdTokenA", b), DataEntry("assetIdTokenB", c), DataEntry("comission", d), DataEntry("version", e), DataEntry("owner", toBase58String(a))]) | |
43 | + | else WriteSet([DataEntry("amountTokenA", o), DataEntry("assetIdTokenA", b), DataEntry("fundA", true)]) | |
44 | + | else if (if ((n == i)) | |
45 | + | then !(isDefined(getBoolean(this, "fundB"))) | |
46 | + | else false) | |
47 | + | then if (isDefined(getBoolean(this, "fundA"))) | |
48 | + | then WriteSet([DataEntry("amountTokenB", o), DataEntry("fundB", true), DataEntry("exchange_count", 0), DataEntry("status", true), DataEntry("assetIdTokenB", c), DataEntry("assetIdTokenB", c), DataEntry("comission", d), DataEntry("version", e), DataEntry("owner", toBase58String(a))]) | |
49 | + | else WriteSet([DataEntry("amountTokenB", o), DataEntry("assetIdTokenB", c), DataEntry("fundB", true)]) | |
50 | + | else throw("already funded or you try to fund with incorrect asset") | |
51 | + | } | |
52 | + | ||
53 | + | ||
54 | + | ||
55 | + | @Callable(j) | |
56 | + | func replenishment () = { | |
57 | + | let k = { | |
58 | + | let l = j.payment | |
59 | + | if ($isInstanceOf(l, "AttachedPayment")) | |
60 | + | then { | |
61 | + | let m = l | |
62 | + | m | |
63 | + | } | |
64 | + | else throw("Payment not attached") | |
65 | + | } | |
66 | + | let n = k.assetId | |
67 | + | let o = k.amount | |
68 | + | if (if ((n == h)) | |
69 | + | then isDefined(getBoolean(this, "fundA")) | |
70 | + | else false) | |
71 | + | then { | |
72 | + | let p = getIntegerValue(this, "amountTokenA") | |
73 | + | WriteSet([DataEntry("amountTokenA", (p + o))]) | |
74 | + | } | |
75 | + | else if (if ((n == i)) | |
76 | + | then isDefined(getBoolean(this, "fundB")) | |
77 | + | else false) | |
78 | + | then { | |
79 | + | let q = getIntegerValue(this, "amountTokenB") | |
80 | + | WriteSet([DataEntry("amountTokenB", (q + o))]) | |
81 | + | } | |
82 | + | else throw("there was an error in the replenishment") | |
83 | + | } | |
84 | + | ||
85 | + | ||
86 | + | ||
87 | + | @Callable(j) | |
88 | + | func exchanger (r) = if (if ((0 > d)) | |
89 | + | then true | |
90 | + | else (d > 100)) | |
91 | + | then throw("incorrect comission value") | |
92 | + | else { | |
93 | + | let q = getIntegerValue(this, "amountTokenB") | |
94 | + | let p = getIntegerValue(this, "amountTokenA") | |
95 | + | let k = { | |
96 | + | let l = j.payment | |
97 | + | if ($isInstanceOf(l, "AttachedPayment")) | |
98 | + | then { | |
99 | + | let m = l | |
100 | + | m | |
101 | + | } | |
102 | + | else throw("Payment not attached") | |
103 | + | } | |
104 | + | let n = k.assetId | |
105 | + | let o = k.amount | |
106 | + | let s = { | |
107 | + | let l = getInteger(this, "exchange_count") | |
108 | + | if ($isInstanceOf(l, "Int")) | |
109 | + | then { | |
110 | + | let t = l | |
111 | + | (value(getInteger(this, "exchange_count")) + t) | |
112 | + | } | |
113 | + | else 0 | |
114 | + | } | |
115 | + | if ((n == i)) | |
116 | + | then { | |
117 | + | let u = ((fraction(p, o, (o + q)) * (100 - d)) / 100) | |
118 | + | if ((r > u)) | |
119 | + | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") | |
120 | + | else { | |
121 | + | let v = h | |
122 | + | ScriptResult(WriteSet([DataEntry("amountTokenA", (p - u)), DataEntry("amountTokenB", (q + o)), DataEntry("exchange_count", (s + 1))]), TransferSet([ScriptTransfer(j.caller, u, v)])) | |
123 | + | } | |
124 | + | } | |
125 | + | else if ((n == h)) | |
126 | + | then { | |
127 | + | let u = ((fraction(q, o, (o + p)) * (100 - d)) / 100) | |
128 | + | if ((r > u)) | |
129 | + | then throw("Price has changed dramaticaly. Receiving token amount don't satisfy specified price level") | |
130 | + | else { | |
131 | + | let v = i | |
132 | + | ScriptResult(WriteSet([DataEntry("amountTokenA", (p + o)), DataEntry("amountTokenB", (q - u)), DataEntry("exchange_count", (s + 1))]), TransferSet([ScriptTransfer(j.caller, u, v)])) | |
133 | + | } | |
134 | + | } | |
135 | + | else throw("Asset is not allowed") | |
136 | + | } | |
137 | + | ||
138 | + | ||
139 | + | ||
140 | + | @Callable(j) | |
141 | + | func withdraw () = { | |
142 | + | let w = assetBalance(this, h) | |
143 | + | let x = assetBalance(this, i) | |
144 | + | if ((j.caller.bytes == a)) | |
145 | + | then ScriptResult(WriteSet([DataEntry("amountTokenA", "withdrawn"), DataEntry("amountTokenB", "withdrawn"), DataEntry("status", false)]), TransferSet([ScriptTransfer(j.caller, w, h), ScriptTransfer(j.caller, x, i)])) | |
146 | + | else throw("You are not exchanger's owner") | |
147 | + | } | |
148 | + | ||
149 | + |
github/deemru/w8io/026f985 16.96 ms ◑