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