tx · 4EfPqzkJAHf9sjnjyccdb8Y8pb8Xw9u5kfHdvXj8PCWZ 3MxaubN2nHCzE5spNox3ZCbPbDMfczSFrZS: -0.01400000 Waves 2021.10.25 17:02 [1761936] smart account 3MxaubN2nHCzE5spNox3ZCbPbDMfczSFrZS > SELF 0.00000000 Waves
{ "type": 13, "id": "4EfPqzkJAHf9sjnjyccdb8Y8pb8Xw9u5kfHdvXj8PCWZ", "fee": 1400000, "feeAssetId": null, "timestamp": 1635170543926, "version": 1, "sender": "3MxaubN2nHCzE5spNox3ZCbPbDMfczSFrZS", "senderPublicKey": "FWDMjbKuHyuUuAo4utnjwDgcbsiysMPDjX835SxvtLHq", "proofs": [ "4W237JWobSZcz7dHviZUSikQgKKf9i94qhKKka15TxgLJ8aGfycRgvgndujptZsgLHgaDPg6hGcwD7jksdMe7X7q" ], "script": "base64:AAIFAAAAAAAAABAIAhIAEgASAwoBARIDCgEBAAAAFgAAAAAHYmFsYW5jZQkBAAAAB0FkZHJlc3MAAAABAQAAABoBVKMjU/C0oWt5judpFHXM19dztnXKmPy+aQAAAAARU1dPUGdvdmVybmFuY2VBZHIJAQAAAAV2YWx1ZQAAAAEJAAQmAAAAAQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEHQAAAAIFAAAAB2JhbGFuY2UCAAAAD1NXT1BfZ292ZXJuYW5jZQIAAAAVRW1wdHkgU1dPUF9nb3Zlcm5hbmNlAAAAAA1XYXZlc1VzZG5Qb29sCQEAAAAFdmFsdWUAAAABCQAEJgAAAAEJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABB0AAAACBQAAAAdiYWxhbmNlAgAAAA9XQVZFU19VU0ROX1Bvb2wCAAAAFUVtcHR5IFdBVkVTX1VTRE5fUG9vbAAAAAAXZGVmaWhlbHBlck1hbmFnZXJQdWJLZXkJAAJZAAAAAQkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABB0AAAACBQAAAAdiYWxhbmNlAgAA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AAAABAgAAACpBbW91bnQgdG8gY2xhaW0gaXMgbGVzcyB0aGFuIG1pblNXT1ByZXdhcmQEAAAAAXoJAAP8AAAABAUAAAARU1dPUGdvdmVybmFuY2VBZHICAAAAEWNsYWltQW5kU3Rha2VTV09QBQAAAANuaWwFAAAAA25pbAMJAAAAAAAAAgUAAAABegUAAAABegQAAAABeQkAA/wAAAAEBQAAAAdiYWxhbmNlAgAAAApleHRyYWN0RmVlCQAETAAAAAIFAAAAC3Byb3RvY29sRmVlBQAAAANuaWwFAAAAA25pbAMJAAAAAAAAAgUAAAABeQUAAAABeQUAAAADbmlsCQAAAgAAAAECAAAAJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AAAABaQEAAAASZ292ZXJuYW5jZVdpdGhkcmF3AAAAAQAAAA1hbXRUb1dpdGhkcmF3AwkBAAAAAiE9AAAAAggFAAAAAWkAAAAGY2FsbGVyBQAAAAVvd25lcgkAAAIAAAABAgAAACFPbmx5IG93bmVyIGNhbiBjYWxsIHRoaXMgZnVuY3Rpb24EAAAAAXoJAAP8AAAABAUAAAARU1dPUGdvdmVybmFuY2VBZHICAAAADHdpdGhkcmF3U1dPUAkABEwAAAACBQAAAA1hbXRUb1dpdGhkcmF3BQAAAANuaWwFAAAAA25pbAMJAAAAAAAAAgUAAAABegUAAAABegkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAADWFtdFRvV2l0aGRyYXcFAAAABFNXT1AFAAAAA25pbAkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AAAAAIPNHXg==", "chainId": 84, "height": 1761936, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BxWSwRmVGqTQY44FN4CsVzqK8mT9B8rGytL5PZL4W8Ng Next: 5DnPEMBev1fh4HZZUEYfdfJVFdfccUijNWXCzHWpXKJF Diff:
Old | New | Differences | |
---|---|---|---|
17 | 17 | ||
18 | 18 | let h = "owner" | |
19 | 19 | ||
20 | - | let i = | |
20 | + | let i = "isProtocolActive" | |
21 | 21 | ||
22 | - | let j = valueOrErrorMessage( | |
22 | + | let j = addressFromString(valueOrErrorMessage(getString(this, h), "Empty keyOwner")) | |
23 | 23 | ||
24 | - | let k = " | |
24 | + | let k = valueOrErrorMessage(getBoolean(a, i), "Empty key isProtocolActive") | |
25 | 25 | ||
26 | - | let l = "_ | |
26 | + | let l = "last_interest" | |
27 | 27 | ||
28 | - | let m = "_ | |
28 | + | let m = "_SWOP_amount" | |
29 | 29 | ||
30 | - | let n = | |
30 | + | let n = "_last_interest" | |
31 | 31 | ||
32 | - | let o = | |
32 | + | let o = base58'Ccgesc9iWMSg1f8CqFP5nZwgF6xsGirReDhpvNp1JAWW' | |
33 | 33 | ||
34 | - | func p () = { | |
35 | - | let q = valueOrElse(getInteger(b, k), 0) | |
36 | - | q | |
34 | + | let p = 100000000 | |
35 | + | ||
36 | + | func q () = { | |
37 | + | let r = valueOrElse(getInteger(b, l), 0) | |
38 | + | r | |
37 | 39 | } | |
38 | 40 | ||
39 | 41 | ||
40 | - | func | |
41 | - | let | |
42 | - | let | |
43 | - | let | |
44 | - | let | |
45 | - | | |
42 | + | func s () = { | |
43 | + | let t = valueOrErrorMessage(getInteger(c, "B_asset_balance"), "Empty B_asset_balance") | |
44 | + | let u = valueOrErrorMessage(getInteger(c, "A_asset_balance"), "Empty A_asset_balance") | |
45 | + | let v = valueOrErrorMessage(getInteger(a, "protocol_fee_in_usdn"), "Empty protocol_fee_in_usdn") | |
46 | + | let w = fraction(t, v, u) | |
47 | + | w | |
46 | 48 | } | |
47 | 49 | ||
48 | 50 | ||
49 | - | func | |
51 | + | func x (y) = valueOrElse(getInteger(b, (toString(y) + m)), 0) | |
50 | 52 | ||
51 | 53 | ||
52 | - | func | |
53 | - | let | |
54 | - | let | |
55 | - | let | |
56 | - | let | |
57 | - | if ($isInstanceOf( | |
54 | + | func z (y,r) = { | |
55 | + | let A = x(y) | |
56 | + | let B = getInteger(b, (toString(y) + n)) | |
57 | + | let C = { | |
58 | + | let D = B | |
59 | + | if ($isInstanceOf(D, "Int")) | |
58 | 60 | then { | |
59 | - | let | |
60 | - | | |
61 | + | let B = D | |
62 | + | B | |
61 | 63 | } | |
62 | - | else | |
64 | + | else r | |
63 | 65 | } | |
64 | - | $Tuple2( | |
66 | + | $Tuple2(C, A) | |
65 | 67 | } | |
66 | 68 | ||
67 | 69 | ||
68 | - | func | |
69 | - | let | |
70 | - | let | |
71 | - | let | |
72 | - | let | |
73 | - | let | |
74 | - | let | |
75 | - | $Tuple2( | |
70 | + | func E (F) = { | |
71 | + | let r = q() | |
72 | + | let G = z(F, r) | |
73 | + | let B = G._1 | |
74 | + | let H = G._2 | |
75 | + | let I = fraction(H, (r - B), p) | |
76 | + | let J = r | |
77 | + | $Tuple2(J, I) | |
76 | 78 | } | |
77 | 79 | ||
78 | 80 | ||
79 | - | let | |
81 | + | let K = s() | |
80 | 82 | ||
81 | - | @Callable( | |
83 | + | @Callable(L) | |
82 | 84 | func init () = if (isDefined(getString(this, h))) | |
83 | 85 | then throw("Contract already initialized") | |
84 | - | else if ((size( | |
85 | - | then [StringEntry(h, toString( | |
86 | - | else if ((size( | |
86 | + | else if ((size(L.payments) == 0)) | |
87 | + | then [StringEntry(h, toString(L.caller))] | |
88 | + | else if ((size(L.payments) == 1)) | |
87 | 89 | then { | |
88 | - | let | |
89 | - | let | |
90 | - | let | |
91 | - | if (( | |
90 | + | let M = $Tuple2(L.payments[0].amount, L.payments[0].assetId) | |
91 | + | let N = M._1 | |
92 | + | let O = M._2 | |
93 | + | if ((O != o)) | |
92 | 94 | then throw("Only SWOP payment available in init()") | |
93 | 95 | else { | |
94 | - | let | |
95 | - | if (( | |
96 | - | then [StringEntry(h, toString( | |
96 | + | let P = invoke(b, "lockSWOP", nil, [AttachedPayment(o, N)]) | |
97 | + | if ((P == P)) | |
98 | + | then [StringEntry(h, toString(L.caller))] | |
97 | 99 | else throw("Strict value is not equal to itself.") | |
98 | 100 | } | |
99 | 101 | } | |
101 | 103 | ||
102 | 104 | ||
103 | 105 | ||
104 | - | @Callable( | |
106 | + | @Callable(L) | |
105 | 107 | func governanceLockSWOP () = { | |
106 | - | let | |
107 | - | let | |
108 | - | let | |
109 | - | if (( | |
108 | + | let Q = $Tuple2(L.payments[0].amount, L.payments[0].assetId) | |
109 | + | let N = Q._1 | |
110 | + | let O = Q._2 | |
111 | + | if ((O != o)) | |
110 | 112 | then throw("Only SWOP payment available in governanceLockSWOP()") | |
111 | 113 | else { | |
112 | - | let | |
113 | - | if (( | |
114 | + | let P = invoke(b, "lockSWOP", nil, [AttachedPayment(o, N)]) | |
115 | + | if ((P == P)) | |
114 | 116 | then nil | |
115 | 117 | else throw("Strict value is not equal to itself.") | |
116 | 118 | } | |
118 | 120 | ||
119 | 121 | ||
120 | 122 | ||
121 | - | @Callable( | |
122 | - | func governanceClaimAndStake ( | |
123 | - | then ( | |
123 | + | @Callable(L) | |
124 | + | func governanceClaimAndStake (R) = if (if ((L.caller != j)) | |
125 | + | then (L.callerPublicKey != d) | |
124 | 126 | else false) | |
125 | 127 | then throw("Only owner or admin can call this function") | |
126 | 128 | else { | |
127 | - | let | |
128 | - | if (( | |
129 | + | let I = E(this)._2 | |
130 | + | if ((R > I)) | |
129 | 131 | then throw("Amount to claim is less than minSWOPreward") | |
130 | 132 | else { | |
131 | - | let | |
132 | - | if (( | |
133 | + | let P = invoke(b, "claimAndStakeSWOP", nil, nil) | |
134 | + | if ((P == P)) | |
133 | 135 | then { | |
134 | - | let | |
135 | - | if (( | |
136 | + | let S = invoke(a, "extractFee", [K], nil) | |
137 | + | if ((S == S)) | |
136 | 138 | then nil | |
137 | 139 | else throw("Strict value is not equal to itself.") | |
138 | 140 | } | |
142 | 144 | ||
143 | 145 | ||
144 | 146 | ||
145 | - | @Callable( | |
146 | - | func governanceWithdraw ( | |
147 | + | @Callable(L) | |
148 | + | func governanceWithdraw (T) = if ((L.caller != j)) | |
147 | 149 | then throw("Only owner can call this function") | |
148 | 150 | else { | |
149 | - | let | |
150 | - | if (( | |
151 | - | then [ScriptTransfer( | |
151 | + | let P = invoke(b, "withdrawSWOP", [T], nil) | |
152 | + | if ((P == P)) | |
153 | + | then [ScriptTransfer(L.caller, T, o)] | |
152 | 154 | else throw("Strict value is not equal to itself.") | |
153 | 155 | } | |
154 | 156 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = Address(base58'3N4ngEpA29qJdUKnRto5zUzXvJJLwUuNs5J') | |
5 | 5 | ||
6 | 6 | let b = value(addressFromString(valueOrErrorMessage(getString(a, "SWOP_governance"), "Empty SWOP_governance"))) | |
7 | 7 | ||
8 | 8 | let c = value(addressFromString(valueOrErrorMessage(getString(a, "WAVES_USDN_Pool"), "Empty WAVES_USDN_Pool"))) | |
9 | 9 | ||
10 | 10 | let d = fromBase58String(valueOrElse(getString(a, "defihelper_manager_PubKey"), "Empty key defihelper_manager_PubKey")) | |
11 | 11 | ||
12 | 12 | let e = base58'Aqj7onZFvn779uRCiW2zCmXG1RKsGeA6k3SWXmH7s5Lv' | |
13 | 13 | ||
14 | 14 | let f = base58'Aqj7onZFvn779uRCiW2zCmXG1RKsGeA6k3SWXmH7s5Lv' | |
15 | 15 | ||
16 | 16 | let g = base58'Aqj7onZFvn779uRCiW2zCmXG1RKsGeA6k3SWXmH7s5Lv' | |
17 | 17 | ||
18 | 18 | let h = "owner" | |
19 | 19 | ||
20 | - | let i = | |
20 | + | let i = "isProtocolActive" | |
21 | 21 | ||
22 | - | let j = valueOrErrorMessage( | |
22 | + | let j = addressFromString(valueOrErrorMessage(getString(this, h), "Empty keyOwner")) | |
23 | 23 | ||
24 | - | let k = " | |
24 | + | let k = valueOrErrorMessage(getBoolean(a, i), "Empty key isProtocolActive") | |
25 | 25 | ||
26 | - | let l = "_ | |
26 | + | let l = "last_interest" | |
27 | 27 | ||
28 | - | let m = "_ | |
28 | + | let m = "_SWOP_amount" | |
29 | 29 | ||
30 | - | let n = | |
30 | + | let n = "_last_interest" | |
31 | 31 | ||
32 | - | let o = | |
32 | + | let o = base58'Ccgesc9iWMSg1f8CqFP5nZwgF6xsGirReDhpvNp1JAWW' | |
33 | 33 | ||
34 | - | func p () = { | |
35 | - | let q = valueOrElse(getInteger(b, k), 0) | |
36 | - | q | |
34 | + | let p = 100000000 | |
35 | + | ||
36 | + | func q () = { | |
37 | + | let r = valueOrElse(getInteger(b, l), 0) | |
38 | + | r | |
37 | 39 | } | |
38 | 40 | ||
39 | 41 | ||
40 | - | func | |
41 | - | let | |
42 | - | let | |
43 | - | let | |
44 | - | let | |
45 | - | | |
42 | + | func s () = { | |
43 | + | let t = valueOrErrorMessage(getInteger(c, "B_asset_balance"), "Empty B_asset_balance") | |
44 | + | let u = valueOrErrorMessage(getInteger(c, "A_asset_balance"), "Empty A_asset_balance") | |
45 | + | let v = valueOrErrorMessage(getInteger(a, "protocol_fee_in_usdn"), "Empty protocol_fee_in_usdn") | |
46 | + | let w = fraction(t, v, u) | |
47 | + | w | |
46 | 48 | } | |
47 | 49 | ||
48 | 50 | ||
49 | - | func | |
51 | + | func x (y) = valueOrElse(getInteger(b, (toString(y) + m)), 0) | |
50 | 52 | ||
51 | 53 | ||
52 | - | func | |
53 | - | let | |
54 | - | let | |
55 | - | let | |
56 | - | let | |
57 | - | if ($isInstanceOf( | |
54 | + | func z (y,r) = { | |
55 | + | let A = x(y) | |
56 | + | let B = getInteger(b, (toString(y) + n)) | |
57 | + | let C = { | |
58 | + | let D = B | |
59 | + | if ($isInstanceOf(D, "Int")) | |
58 | 60 | then { | |
59 | - | let | |
60 | - | | |
61 | + | let B = D | |
62 | + | B | |
61 | 63 | } | |
62 | - | else | |
64 | + | else r | |
63 | 65 | } | |
64 | - | $Tuple2( | |
66 | + | $Tuple2(C, A) | |
65 | 67 | } | |
66 | 68 | ||
67 | 69 | ||
68 | - | func | |
69 | - | let | |
70 | - | let | |
71 | - | let | |
72 | - | let | |
73 | - | let | |
74 | - | let | |
75 | - | $Tuple2( | |
70 | + | func E (F) = { | |
71 | + | let r = q() | |
72 | + | let G = z(F, r) | |
73 | + | let B = G._1 | |
74 | + | let H = G._2 | |
75 | + | let I = fraction(H, (r - B), p) | |
76 | + | let J = r | |
77 | + | $Tuple2(J, I) | |
76 | 78 | } | |
77 | 79 | ||
78 | 80 | ||
79 | - | let | |
81 | + | let K = s() | |
80 | 82 | ||
81 | - | @Callable( | |
83 | + | @Callable(L) | |
82 | 84 | func init () = if (isDefined(getString(this, h))) | |
83 | 85 | then throw("Contract already initialized") | |
84 | - | else if ((size( | |
85 | - | then [StringEntry(h, toString( | |
86 | - | else if ((size( | |
86 | + | else if ((size(L.payments) == 0)) | |
87 | + | then [StringEntry(h, toString(L.caller))] | |
88 | + | else if ((size(L.payments) == 1)) | |
87 | 89 | then { | |
88 | - | let | |
89 | - | let | |
90 | - | let | |
91 | - | if (( | |
90 | + | let M = $Tuple2(L.payments[0].amount, L.payments[0].assetId) | |
91 | + | let N = M._1 | |
92 | + | let O = M._2 | |
93 | + | if ((O != o)) | |
92 | 94 | then throw("Only SWOP payment available in init()") | |
93 | 95 | else { | |
94 | - | let | |
95 | - | if (( | |
96 | - | then [StringEntry(h, toString( | |
96 | + | let P = invoke(b, "lockSWOP", nil, [AttachedPayment(o, N)]) | |
97 | + | if ((P == P)) | |
98 | + | then [StringEntry(h, toString(L.caller))] | |
97 | 99 | else throw("Strict value is not equal to itself.") | |
98 | 100 | } | |
99 | 101 | } | |
100 | 102 | else throw("Incorrect paynemt. You should attach SWOP or empty payment") | |
101 | 103 | ||
102 | 104 | ||
103 | 105 | ||
104 | - | @Callable( | |
106 | + | @Callable(L) | |
105 | 107 | func governanceLockSWOP () = { | |
106 | - | let | |
107 | - | let | |
108 | - | let | |
109 | - | if (( | |
108 | + | let Q = $Tuple2(L.payments[0].amount, L.payments[0].assetId) | |
109 | + | let N = Q._1 | |
110 | + | let O = Q._2 | |
111 | + | if ((O != o)) | |
110 | 112 | then throw("Only SWOP payment available in governanceLockSWOP()") | |
111 | 113 | else { | |
112 | - | let | |
113 | - | if (( | |
114 | + | let P = invoke(b, "lockSWOP", nil, [AttachedPayment(o, N)]) | |
115 | + | if ((P == P)) | |
114 | 116 | then nil | |
115 | 117 | else throw("Strict value is not equal to itself.") | |
116 | 118 | } | |
117 | 119 | } | |
118 | 120 | ||
119 | 121 | ||
120 | 122 | ||
121 | - | @Callable( | |
122 | - | func governanceClaimAndStake ( | |
123 | - | then ( | |
123 | + | @Callable(L) | |
124 | + | func governanceClaimAndStake (R) = if (if ((L.caller != j)) | |
125 | + | then (L.callerPublicKey != d) | |
124 | 126 | else false) | |
125 | 127 | then throw("Only owner or admin can call this function") | |
126 | 128 | else { | |
127 | - | let | |
128 | - | if (( | |
129 | + | let I = E(this)._2 | |
130 | + | if ((R > I)) | |
129 | 131 | then throw("Amount to claim is less than minSWOPreward") | |
130 | 132 | else { | |
131 | - | let | |
132 | - | if (( | |
133 | + | let P = invoke(b, "claimAndStakeSWOP", nil, nil) | |
134 | + | if ((P == P)) | |
133 | 135 | then { | |
134 | - | let | |
135 | - | if (( | |
136 | + | let S = invoke(a, "extractFee", [K], nil) | |
137 | + | if ((S == S)) | |
136 | 138 | then nil | |
137 | 139 | else throw("Strict value is not equal to itself.") | |
138 | 140 | } | |
139 | 141 | else throw("Strict value is not equal to itself.") | |
140 | 142 | } | |
141 | 143 | } | |
142 | 144 | ||
143 | 145 | ||
144 | 146 | ||
145 | - | @Callable( | |
146 | - | func governanceWithdraw ( | |
147 | + | @Callable(L) | |
148 | + | func governanceWithdraw (T) = if ((L.caller != j)) | |
147 | 149 | then throw("Only owner can call this function") | |
148 | 150 | else { | |
149 | - | let | |
150 | - | if (( | |
151 | - | then [ScriptTransfer( | |
151 | + | let P = invoke(b, "withdrawSWOP", [T], nil) | |
152 | + | if ((P == P)) | |
153 | + | then [ScriptTransfer(L.caller, T, o)] | |
152 | 154 | else throw("Strict value is not equal to itself.") | |
153 | 155 | } | |
154 | 156 | ||
155 | 157 |
github/deemru/w8io/169f3d6 66.58 ms ◑