tx · EUrYp8FeoW1q4jR2T9BcHqfLuX9h75oJHvSwaMPXC98Y 3N4ngEpA29qJdUKnRto5zUzXvJJLwUuNs5J: -0.01400000 Waves 2021.10.25 17:48 [1761983] smart account 3N4ngEpA29qJdUKnRto5zUzXvJJLwUuNs5J > SELF 0.00000000 Waves
{ "type": 13, "id": "EUrYp8FeoW1q4jR2T9BcHqfLuX9h75oJHvSwaMPXC98Y", "fee": 1400000, "feeAssetId": null, "timestamp": 1635173330352, "version": 1, "sender": "3N4ngEpA29qJdUKnRto5zUzXvJJLwUuNs5J", "senderPublicKey": "B7ayemTreAJnAMuzH9P3MnVXhpL6PTtRBrV29h7EUS1H", "proofs": [ "5axjPySuo4HMa7fbsrdU4BQi4DXt18S4WSEfYzSa9e2FMdeTESce2w4A9SdUquYqbQ1GabpG9ZEnsBQ77EK7cPGn" ], "script": "base64:AAIFAAAAAAAAACMIAhIGCgQICAgBEgQKAggEEgMKAQESAwoBCBIAEgMKAQESAAAAAAsAAAAADlNXT1Bnb3Zlcm5hbmNlCQAEJgAAAAEJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQdAAAAAgUAAAAEdGhpcwIAAAAPU1dPUF9nb3Zlcm5hbmNlAgAAACFFbXB0eSBrZXkgU1dPUF9nb3Zlcm5hbmNlX2FkZHJlc3MAAAAADVdhdmVzVXNkblBvb2wJAQAAAAV2YWx1ZQAAAAEJAAQmAAAAAQkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABB0AAAACBQAAAAR0aGlzAgAAAA9XQVZFU19VU0ROX1Bvb2wCAAAAIUVtcHR5IGtleSBTV09QX2dvdmVybmFuY2VfYWRkcmVzcwAAAAAXZGVmaWhlbHBlck1hbmFnZXJQdWJLZXkJAAJZAAAAAQkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABB0AAAACBQAAAAR0aGlzAgAAABlkZWZpaGVscGVyX21hbmFnZXJfUHViS2V5AgAAACNFbXB0eSBrZXkgZGVmaWhlbHBlcl9tYW5h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XJCYWxhbmNlAAAAAQUAAAAJY2FsbGVyU3RyAwkAAGYAAAACBQAAAAt3aXRoZHJhd0FtdAUAAAANY2FsbGVyQmFsYW5jZQkAAAIAAAABAgAAABt3aXRoZHJhd0FtdCA+IGNhbGxlckJhbGFuY2UJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgUAAAAJY2FsbGVyU3RyBQAAAAprZXlCYWxhbmNlCQAAZQAAAAIFAAAADWNhbGxlckJhbGFuY2UFAAAAC3dpdGhkcmF3QW10CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAALd2l0aGRyYXdBbXQFAAAABHVuaXQFAAAAA25pbAAAAAFpAQAAAAhzaHV0ZG93bgAAAAADCQEAAAABIQAAAAEFAAAAEGlzUHJvdG9jb2xBY3RpdmUJAAACAAAAAQIAAAAXUHJvdG9sIHN0b3BwZWQgYnkgYWRtaW4DCQEAAAABIQAAAAEJAQAAAA9jb250YWluc0VsZW1lbnQAAAACCQAETAAAAAIFAAAADGFkbWluUHViS2V5MQkABEwAAAACBQAAAAxhZG1pblB1YktleTIJAARMAAAAAgUAAAAMYWRtaW5QdWJLZXkzCQAETAAAAAIFAAAAF2RlZmloZWxwZXJNYW5hZ2VyUHViS2V5BQAAAANuaWwIBQAAAAFpAAAAD2NhbGxlclB1YmxpY0tleQkAAAIAAAABAgAAACFPbmx5IGFkbWluIGNhbiBjYWxsIHRoaXMgZnVuY3Rpb24JAARMAAAAAgkBAAAADEJvb2xlYW5FbnRyeQAAAAICAAAAEGlzUHJvdG9jb2xBY3RpdmUHBQAAAANuaWwAAAAAL9rc+Q==", "chainId": 84, "height": 1761983, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3cmV7haLVPsmk9pP2xgxyvC1dsMz4tFkAj6kjmsXa3Du Next: HxTU4UQX7Dx82PMfy3sFZwW3LkxhnZ5hq4doBKw7Aekq Diff:
Old | New | Differences | |
---|---|---|---|
83 | 83 | then throw("This automate is inactive") | |
84 | 84 | else { | |
85 | 85 | let B = p() | |
86 | - | let C = valueOrErrorMessage(getInteger(this, (z + g)), (("Empty key user + keyBalance: " + z) + g)) | |
87 | - | [IntegerEntry((z + g), (C - B))] | |
86 | + | if (true) | |
87 | + | then throw(toString(B)) | |
88 | + | else { | |
89 | + | let C = valueOrErrorMessage(getInteger(this, (z + g)), (("Empty key user + keyBalance: " + z) + g)) | |
90 | + | let D = (C - B) | |
91 | + | if ((0 > D)) | |
92 | + | then throw(("Insufficient balance:" + toString(D))) | |
93 | + | else [IntegerEntry((z + g), D)] | |
94 | + | } | |
88 | 95 | } | |
89 | 96 | } | |
90 | 97 | ||
94 | 101 | func replanishBalance () = if (!(i)) | |
95 | 102 | then throw("Protol stopped by admin") | |
96 | 103 | else { | |
97 | - | let | |
98 | - | let | |
99 | - | let | |
100 | - | if (( | |
104 | + | let E = $Tuple2(u.payments[0].amount, u.payments[0].assetId) | |
105 | + | let F = E._1 | |
106 | + | let G = E._2 | |
107 | + | if ((G != unit)) | |
101 | 108 | then throw("Only WAVES available for replanishment") | |
102 | 109 | else { | |
103 | 110 | let k = toString(u.caller) | |
104 | 111 | let l = j(k) | |
105 | - | [IntegerEntry((k + g), (l + | |
112 | + | [IntegerEntry((k + g), (l + F))] | |
106 | 113 | } | |
107 | 114 | } | |
108 | 115 | ||
109 | 116 | ||
110 | 117 | ||
111 | 118 | @Callable(u) | |
112 | - | func withdraw ( | |
119 | + | func withdraw (H) = if (!(i)) | |
113 | 120 | then throw("Protol stopped by admin") | |
114 | 121 | else { | |
115 | 122 | let k = toString(u.caller) | |
116 | 123 | let l = j(k) | |
117 | - | if (( | |
124 | + | if ((H > l)) | |
118 | 125 | then throw("withdrawAmt > callerBalance") | |
119 | - | else [IntegerEntry((k + g), (l - | |
126 | + | else [IntegerEntry((k + g), (l - H)), ScriptTransfer(u.caller, H, unit)] | |
120 | 127 | } | |
121 | 128 | ||
122 | 129 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = addressFromString(valueOrElse(getString(this, "SWOP_governance"), "Empty key SWOP_governance_address")) | |
5 | 5 | ||
6 | 6 | let b = value(addressFromString(valueOrElse(getString(this, "WAVES_USDN_Pool"), "Empty key SWOP_governance_address"))) | |
7 | 7 | ||
8 | 8 | let c = fromBase58String(valueOrElse(getString(this, "defihelper_manager_PubKey"), "Empty key defihelper_manager_PubKey")) | |
9 | 9 | ||
10 | 10 | let d = base58'Aqj7onZFvn779uRCiW2zCmXG1RKsGeA6k3SWXmH7s5Lv' | |
11 | 11 | ||
12 | 12 | let e = base58'Aqj7onZFvn779uRCiW2zCmXG1RKsGeA6k3SWXmH7s5Lv' | |
13 | 13 | ||
14 | 14 | let f = base58'Aqj7onZFvn779uRCiW2zCmXG1RKsGeA6k3SWXmH7s5Lv' | |
15 | 15 | ||
16 | 16 | let g = "_balance" | |
17 | 17 | ||
18 | 18 | let h = "fee_in_usdn" | |
19 | 19 | ||
20 | 20 | let i = valueOrErrorMessage(getBoolean(this, "isProtocolActive"), "Empty key isProtocolActive") | |
21 | 21 | ||
22 | 22 | func j (k) = { | |
23 | 23 | let l = { | |
24 | 24 | let m = getInteger(this, (k + g)) | |
25 | 25 | if ($isInstanceOf(m, "Int")) | |
26 | 26 | then { | |
27 | 27 | let n = m | |
28 | 28 | n | |
29 | 29 | } | |
30 | 30 | else if ($isInstanceOf(m, "Unit")) | |
31 | 31 | then { | |
32 | 32 | let o = m | |
33 | 33 | 0 | |
34 | 34 | } | |
35 | 35 | else throw("Match error") | |
36 | 36 | } | |
37 | 37 | l | |
38 | 38 | } | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func p () = { | |
42 | 42 | let q = valueOrErrorMessage(getInteger(b, "B_asset_balance"), "Empty B_asset_balance") | |
43 | 43 | let r = valueOrErrorMessage(getInteger(b, "A_asset_balance"), "Empty A_asset_balance") | |
44 | 44 | let s = valueOrErrorMessage(getInteger(this, "protocol_fee_in_usdn"), "Empty protocol_fee_in_usdn") | |
45 | 45 | let t = fraction((q * 100), s, r) | |
46 | 46 | t | |
47 | 47 | } | |
48 | 48 | ||
49 | 49 | ||
50 | 50 | @Callable(u) | |
51 | 51 | func init (c,b,v,w) = if (if (isDefined(getString(this, "WAVES_USDN_Pool"))) | |
52 | 52 | then true | |
53 | 53 | else isDefined(getString(this, "defihelper_manager_PubKey"))) | |
54 | 54 | then throw("Already initialized") | |
55 | 55 | else [StringEntry("defihelper_manager_PubKey", c), StringEntry("WAVES_USDN_Pool", b), StringEntry("SWOP_governance", v), IntegerEntry("protocol_fee_in_usdn", w), BooleanEntry("isProtocolActive", true)] | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | ||
59 | 59 | @Callable(u) | |
60 | 60 | func updateAutomateStatus (x,y) = if (!(i)) | |
61 | 61 | then throw("Protol stopped by admin") | |
62 | 62 | else if (!(containsElement([c], u.callerPublicKey))) | |
63 | 63 | then throw("Only admin can call this function") | |
64 | 64 | else [BooleanEntry(x, y)] | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | ||
68 | 68 | @Callable(u) | |
69 | 69 | func updateProtocolFee (w) = if (!(i)) | |
70 | 70 | then throw("Protol stopped by admin") | |
71 | 71 | else if (!(containsElement([c], u.callerPublicKey))) | |
72 | 72 | then throw("Only admin can call this function") | |
73 | 73 | else [IntegerEntry("protocol_fee_in_usdn", w)] | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | ||
77 | 77 | @Callable(u) | |
78 | 78 | func extractFee (z) = if (!(i)) | |
79 | 79 | then throw("Protol stopped by admin") | |
80 | 80 | else { | |
81 | 81 | let A = valueOrErrorMessage(getBoolean(this, toString(u.caller)), ("Empty key i.caller: " + toString(u.caller))) | |
82 | 82 | if (!(A)) | |
83 | 83 | then throw("This automate is inactive") | |
84 | 84 | else { | |
85 | 85 | let B = p() | |
86 | - | let C = valueOrErrorMessage(getInteger(this, (z + g)), (("Empty key user + keyBalance: " + z) + g)) | |
87 | - | [IntegerEntry((z + g), (C - B))] | |
86 | + | if (true) | |
87 | + | then throw(toString(B)) | |
88 | + | else { | |
89 | + | let C = valueOrErrorMessage(getInteger(this, (z + g)), (("Empty key user + keyBalance: " + z) + g)) | |
90 | + | let D = (C - B) | |
91 | + | if ((0 > D)) | |
92 | + | then throw(("Insufficient balance:" + toString(D))) | |
93 | + | else [IntegerEntry((z + g), D)] | |
94 | + | } | |
88 | 95 | } | |
89 | 96 | } | |
90 | 97 | ||
91 | 98 | ||
92 | 99 | ||
93 | 100 | @Callable(u) | |
94 | 101 | func replanishBalance () = if (!(i)) | |
95 | 102 | then throw("Protol stopped by admin") | |
96 | 103 | else { | |
97 | - | let | |
98 | - | let | |
99 | - | let | |
100 | - | if (( | |
104 | + | let E = $Tuple2(u.payments[0].amount, u.payments[0].assetId) | |
105 | + | let F = E._1 | |
106 | + | let G = E._2 | |
107 | + | if ((G != unit)) | |
101 | 108 | then throw("Only WAVES available for replanishment") | |
102 | 109 | else { | |
103 | 110 | let k = toString(u.caller) | |
104 | 111 | let l = j(k) | |
105 | - | [IntegerEntry((k + g), (l + | |
112 | + | [IntegerEntry((k + g), (l + F))] | |
106 | 113 | } | |
107 | 114 | } | |
108 | 115 | ||
109 | 116 | ||
110 | 117 | ||
111 | 118 | @Callable(u) | |
112 | - | func withdraw ( | |
119 | + | func withdraw (H) = if (!(i)) | |
113 | 120 | then throw("Protol stopped by admin") | |
114 | 121 | else { | |
115 | 122 | let k = toString(u.caller) | |
116 | 123 | let l = j(k) | |
117 | - | if (( | |
124 | + | if ((H > l)) | |
118 | 125 | then throw("withdrawAmt > callerBalance") | |
119 | - | else [IntegerEntry((k + g), (l - | |
126 | + | else [IntegerEntry((k + g), (l - H)), ScriptTransfer(u.caller, H, unit)] | |
120 | 127 | } | |
121 | 128 | ||
122 | 129 | ||
123 | 130 | ||
124 | 131 | @Callable(u) | |
125 | 132 | func shutdown () = if (!(i)) | |
126 | 133 | then throw("Protol stopped by admin") | |
127 | 134 | else if (!(containsElement([d, e, f, c], u.callerPublicKey))) | |
128 | 135 | then throw("Only admin can call this function") | |
129 | 136 | else [BooleanEntry("isProtocolActive", false)] | |
130 | 137 | ||
131 | 138 |
github/deemru/w8io/169f3d6 35.23 ms ◑