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