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