tx · 2ADxAXYA6kfNgyHVtebV4eiLV8fRVQMhPNC9vciJhjwf 3N4ngEpA29qJdUKnRto5zUzXvJJLwUuNs5J: -0.01400000 Waves 2021.10.25 17:13 [1761946] smart account 3N4ngEpA29qJdUKnRto5zUzXvJJLwUuNs5J > SELF 0.00000000 Waves
{ "type": 13, "id": "2ADxAXYA6kfNgyHVtebV4eiLV8fRVQMhPNC9vciJhjwf", "fee": 1400000, "feeAssetId": null, "timestamp": 1635171207954, "version": 1, "sender": "3N4ngEpA29qJdUKnRto5zUzXvJJLwUuNs5J", "senderPublicKey": "B7ayemTreAJnAMuzH9P3MnVXhpL6PTtRBrV29h7EUS1H", "proofs": [ "3PPiZjS78JUJHkUpyfEQgmq5qSLw7twbiNwVTw65XckUZdtFzhRbnS7FGUuhMErT8BTiJYAcDd1qirmKjZFK7qGQ" ], "script": "base64:AAIFAAAAAAAAACQIAhIGCgQICAgBEgQKAggEEgMKAQESBAoCAQgSABIDCgEBEgAAAAAKAAAAAA5TV09QZ292ZXJuYW5jZQkABCYAAAABCQEAAAALdmFsdWVPckVsc2UAAAACCQAEHQAAAAIFAAAABHRoaXMCAAAAD1NXT1BfZ292ZXJuYW5jZQIAAAAhRW1wdHkga2V5IFNXT1BfZ292ZXJuYW5jZV9hZGRyZXNzAAAAAA1XYXZlc1VzZG5Qb29sCQAEJgAAAAEJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQdAAAAAgUAAAAEdGhpcwIAAAAPV0FWRVNfVVNETl9Qb29sAgAAACFFbXB0eSBrZXkgU1dPUF9nb3Zlcm5hbmNlX2FkZHJlc3MAAAAAF2RlZmloZWxwZXJNYW5hZ2VyUHViS2V5CQACWQAAAAEJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQdAAAAAgUAAAAEdGhpcwIAAAAZZGVmaWhlbHBlcl9tYW5hZ2VyX1B1YktleQIAAAAjRW1wdHkga2V5IGRlZmloZWxwZXJfbWFuYWdlcl9QdWJLZXkAAAAADGFkb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WxsZXIEAAAADWNhbGxlckJhbGFuY2UJAQAAABBnZXRDYWxsZXJCYWxhbmNlAAAAAQUAAAAJY2FsbGVyU3RyAwkAAGYAAAACBQAAAAt3aXRoZHJhd0FtdAUAAAANY2FsbGVyQmFsYW5jZQkAAAIAAAABAgAAABt3aXRoZHJhd0FtdCA+IGNhbGxlckJhbGFuY2UJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAAEsAAAAAgUAAAAJY2FsbGVyU3RyBQAAAAprZXlCYWxhbmNlCQAAZQAAAAIFAAAADWNhbGxlckJhbGFuY2UFAAAAC3dpdGhkcmF3QW10CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAALd2l0aGRyYXdBbXQFAAAABHVuaXQFAAAAA25pbAAAAAFpAQAAAAhzaHV0ZG93bgAAAAADCQEAAAABIQAAAAEFAAAAEGlzUHJvdG9jb2xBY3RpdmUJAAACAAAAAQIAAAAXUHJvdG9sIHN0b3BwZWQgYnkgYWRtaW4DCQEAAAABIQAAAAEJAQAAAA9jb250YWluc0VsZW1lbnQAAAACCQAETAAAAAIFAAAADGFkbWluUHViS2V5MQkABEwAAAACBQAAAAxhZG1pblB1YktleTIJAARMAAAAAgUAAAAMYWRtaW5QdWJLZXkzCQAETAAAAAIFAAAAF2RlZmloZWxwZXJNYW5hZ2VyUHViS2V5BQAAAANuaWwIBQAAAAFpAAAAD2NhbGxlclB1YmxpY0tleQkAAAIAAAABAgAAACFPbmx5IGFkbWluIGNhbiBjYWxsIHRoaXMgZnVuY3Rpb24JAARMAAAAAgkBAAAADEJvb2xlYW5FbnRyeQAAAAICAAAAEGlzUHJvdG9jb2xBY3RpdmUHBQAAAANuaWwAAAAAmFpgYQ==", "chainId": 84, "height": 1761946, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9npXyE9QumvxL87rrqYytAJ8tS2PHNU5EN3YZnTh5Nc3 Next: BVPtun9bc8j2ioFCCUFm3zDwMxvx6v254qF96yLXyZGR Diff:
Old | New | Differences | |
---|---|---|---|
39 | 39 | ||
40 | 40 | ||
41 | 41 | @Callable(p) | |
42 | - | func init (c,b,q) = if (if (isDefined(getString(this, "WAVES_USDN_Pool"))) | |
42 | + | func init (c,b,q,r) = if (if (isDefined(getString(this, "WAVES_USDN_Pool"))) | |
43 | 43 | then true | |
44 | 44 | else isDefined(getString(this, "defihelper_manager_PubKey"))) | |
45 | 45 | then throw("Already initialized") | |
46 | - | else [StringEntry("defihelper_manager_PubKey", c), StringEntry("WAVES_USDN_Pool", b), IntegerEntry("fee_in_usdn", | |
46 | + | else [StringEntry("defihelper_manager_PubKey", c), StringEntry("WAVES_USDN_Pool", b), StringEntry("SWOP_governance", q), IntegerEntry("protocol_fee_in_usdn", r), BooleanEntry("isProtocolActive", true)] | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | ||
50 | 50 | @Callable(p) | |
51 | - | func updateAutomateStatus ( | |
51 | + | func updateAutomateStatus (s,t) = if (!(i)) | |
52 | 52 | then throw("Protol stopped by admin") | |
53 | 53 | else if (!(containsElement([c], p.callerPublicKey))) | |
54 | 54 | then throw("Only admin can call this function") | |
55 | - | else [BooleanEntry( | |
55 | + | else [BooleanEntry(s, t)] | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | ||
59 | 59 | @Callable(p) | |
60 | - | func updateProtocolFee ( | |
60 | + | func updateProtocolFee (r) = if (!(i)) | |
61 | 61 | then throw("Protol stopped by admin") | |
62 | 62 | else if (!(containsElement([c], p.callerPublicKey))) | |
63 | 63 | then throw("Only admin can call this function") | |
64 | - | else [IntegerEntry("protocol_fee_in_usdn", | |
64 | + | else [IntegerEntry("protocol_fee_in_usdn", r)] | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | ||
68 | 68 | @Callable(p) | |
69 | - | func extractFee ( | |
69 | + | func extractFee (u,v) = if (!(i)) | |
70 | 70 | then throw("Protol stopped by admin") | |
71 | 71 | else { | |
72 | - | let u = toString(p.caller) | |
73 | - | let v = valueOrErrorMessage(getBoolean(this, u), ("Empty key newUser: " + u)) | |
74 | - | if (!(v)) | |
72 | + | let w = valueOrErrorMessage(getBoolean(this, v), ("Empty key newUser: " + v)) | |
73 | + | if (!(w)) | |
75 | 74 | then throw("This automate is inactive") | |
76 | 75 | else { | |
77 | - | let | |
78 | - | [IntegerEntry( | |
76 | + | let x = valueOrErrorMessage(getInteger(this, (v + g)), (("Empty key user + keyBalance: " + v) + g)) | |
77 | + | [IntegerEntry((v + g), (x - u))] | |
79 | 78 | } | |
80 | 79 | } | |
81 | 80 | ||
85 | 84 | func replanishBalance () = if (!(i)) | |
86 | 85 | then throw("Protol stopped by admin") | |
87 | 86 | else { | |
88 | - | let | |
89 | - | let | |
90 | - | let | |
91 | - | if (( | |
87 | + | let y = $Tuple2(p.payments[0].amount, p.payments[0].assetId) | |
88 | + | let z = y._1 | |
89 | + | let A = y._2 | |
90 | + | if ((A != unit)) | |
92 | 91 | then throw("Only WAVES available for replanishment") | |
93 | 92 | else { | |
94 | 93 | let k = toString(p.caller) | |
95 | 94 | let l = j(k) | |
96 | - | [IntegerEntry((k + g), (l + | |
95 | + | [IntegerEntry((k + g), (l + z))] | |
97 | 96 | } | |
98 | 97 | } | |
99 | 98 | ||
100 | 99 | ||
101 | 100 | ||
102 | 101 | @Callable(p) | |
103 | - | func withdraw ( | |
102 | + | func withdraw (B) = if (!(i)) | |
104 | 103 | then throw("Protol stopped by admin") | |
105 | 104 | else { | |
106 | 105 | let k = toString(p.caller) | |
107 | 106 | let l = j(k) | |
108 | - | if (( | |
107 | + | if ((B > l)) | |
109 | 108 | then throw("withdrawAmt > callerBalance") | |
110 | - | else [IntegerEntry((k + g), (l - | |
109 | + | else [IntegerEntry((k + g), (l - B)), ScriptTransfer(p.caller, B, unit)] | |
111 | 110 | } | |
112 | 111 | ||
113 | 112 |
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 = 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 | @Callable(p) | |
42 | - | func init (c,b,q) = if (if (isDefined(getString(this, "WAVES_USDN_Pool"))) | |
42 | + | func init (c,b,q,r) = if (if (isDefined(getString(this, "WAVES_USDN_Pool"))) | |
43 | 43 | then true | |
44 | 44 | else isDefined(getString(this, "defihelper_manager_PubKey"))) | |
45 | 45 | then throw("Already initialized") | |
46 | - | else [StringEntry("defihelper_manager_PubKey", c), StringEntry("WAVES_USDN_Pool", b), IntegerEntry("fee_in_usdn", | |
46 | + | else [StringEntry("defihelper_manager_PubKey", c), StringEntry("WAVES_USDN_Pool", b), StringEntry("SWOP_governance", q), IntegerEntry("protocol_fee_in_usdn", r), BooleanEntry("isProtocolActive", true)] | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | ||
50 | 50 | @Callable(p) | |
51 | - | func updateAutomateStatus ( | |
51 | + | func updateAutomateStatus (s,t) = if (!(i)) | |
52 | 52 | then throw("Protol stopped by admin") | |
53 | 53 | else if (!(containsElement([c], p.callerPublicKey))) | |
54 | 54 | then throw("Only admin can call this function") | |
55 | - | else [BooleanEntry( | |
55 | + | else [BooleanEntry(s, t)] | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | ||
59 | 59 | @Callable(p) | |
60 | - | func updateProtocolFee ( | |
60 | + | func updateProtocolFee (r) = if (!(i)) | |
61 | 61 | then throw("Protol stopped by admin") | |
62 | 62 | else if (!(containsElement([c], p.callerPublicKey))) | |
63 | 63 | then throw("Only admin can call this function") | |
64 | - | else [IntegerEntry("protocol_fee_in_usdn", | |
64 | + | else [IntegerEntry("protocol_fee_in_usdn", r)] | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | ||
68 | 68 | @Callable(p) | |
69 | - | func extractFee ( | |
69 | + | func extractFee (u,v) = if (!(i)) | |
70 | 70 | then throw("Protol stopped by admin") | |
71 | 71 | else { | |
72 | - | let u = toString(p.caller) | |
73 | - | let v = valueOrErrorMessage(getBoolean(this, u), ("Empty key newUser: " + u)) | |
74 | - | if (!(v)) | |
72 | + | let w = valueOrErrorMessage(getBoolean(this, v), ("Empty key newUser: " + v)) | |
73 | + | if (!(w)) | |
75 | 74 | then throw("This automate is inactive") | |
76 | 75 | else { | |
77 | - | let | |
78 | - | [IntegerEntry( | |
76 | + | let x = valueOrErrorMessage(getInteger(this, (v + g)), (("Empty key user + keyBalance: " + v) + g)) | |
77 | + | [IntegerEntry((v + g), (x - u))] | |
79 | 78 | } | |
80 | 79 | } | |
81 | 80 | ||
82 | 81 | ||
83 | 82 | ||
84 | 83 | @Callable(p) | |
85 | 84 | func replanishBalance () = if (!(i)) | |
86 | 85 | then throw("Protol stopped by admin") | |
87 | 86 | else { | |
88 | - | let | |
89 | - | let | |
90 | - | let | |
91 | - | if (( | |
87 | + | let y = $Tuple2(p.payments[0].amount, p.payments[0].assetId) | |
88 | + | let z = y._1 | |
89 | + | let A = y._2 | |
90 | + | if ((A != unit)) | |
92 | 91 | then throw("Only WAVES available for replanishment") | |
93 | 92 | else { | |
94 | 93 | let k = toString(p.caller) | |
95 | 94 | let l = j(k) | |
96 | - | [IntegerEntry((k + g), (l + | |
95 | + | [IntegerEntry((k + g), (l + z))] | |
97 | 96 | } | |
98 | 97 | } | |
99 | 98 | ||
100 | 99 | ||
101 | 100 | ||
102 | 101 | @Callable(p) | |
103 | - | func withdraw ( | |
102 | + | func withdraw (B) = if (!(i)) | |
104 | 103 | then throw("Protol stopped by admin") | |
105 | 104 | else { | |
106 | 105 | let k = toString(p.caller) | |
107 | 106 | let l = j(k) | |
108 | - | if (( | |
107 | + | if ((B > l)) | |
109 | 108 | then throw("withdrawAmt > callerBalance") | |
110 | - | else [IntegerEntry((k + g), (l - | |
109 | + | else [IntegerEntry((k + g), (l - B)), ScriptTransfer(p.caller, B, unit)] | |
111 | 110 | } | |
112 | 111 | ||
113 | 112 | ||
114 | 113 | ||
115 | 114 | @Callable(p) | |
116 | 115 | func shutdown () = if (!(i)) | |
117 | 116 | then throw("Protol stopped by admin") | |
118 | 117 | else if (!(containsElement([d, e, f, c], p.callerPublicKey))) | |
119 | 118 | then throw("Only admin can call this function") | |
120 | 119 | else [BooleanEntry("isProtocolActive", false)] | |
121 | 120 | ||
122 | 121 |
github/deemru/w8io/169f3d6 48.86 ms ◑