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