tx · 6uzvbZbnnQZsZtWCWKEfzUVLYaZyJF2AEyPTbWHQdd6Y 3MsaYMAGjgngDLDfCRz2zM1PFkWsEWrqQKo: -0.01400000 Waves 2021.12.03 01:23 [1817253] smart account 3MsaYMAGjgngDLDfCRz2zM1PFkWsEWrqQKo > SELF 0.00000000 Waves
{ "type": 13, "id": "6uzvbZbnnQZsZtWCWKEfzUVLYaZyJF2AEyPTbWHQdd6Y", "fee": 1400000, "feeAssetId": null, "timestamp": 1638483806980, "version": 1, "sender": "3MsaYMAGjgngDLDfCRz2zM1PFkWsEWrqQKo", "senderPublicKey": "2TjQMiex51XzQHmuRKxZLYE7L1GHvUdc5xD6qGwWqsnB", "proofs": [ "S7bqfRVPvoLi7ndvoMyrk4FvyeobdufbSxnNxbLoUhBCNB3eDUXSyGsh7Td7nUr7XZkCiRqn6sNHNGA2pgM2Ddp" ], "script": "base64:AAIFAAAAAAAAABAIAhIAEgMKAQESAwoBARIAAAAAGAAAAAAGb3JhY2xlCQEAAAAHQWRkcmVzcwAAAAEBAAAAGgFU+1HL0ASlajd9LXjglRa/LZYurUe0gyHKAAAAAAdiYWxhbmNlCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABCQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQdAAAAAgUAAAAGb3JhY2xlAgAAAA9iYWxhbmNlX2FkZHJlc3MCAAAAGUVtcHR5IGtleSBiYWxhbmNlX2FkZHJlc3MAAAAAEVNXT1Bnb3Zlcm5hbmNlQWRyCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABCQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQdAAAAAgUAAAAGb3JhY2xlAgAAAA9zd29wX2dvdmVybmFuY2UCAAAAGUVtcHR5IGtleSBzd29wX2dvdmVybmFuY2UAAAAABFNXT1AJAAJZAAAAAQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEHQAAAAIFAAAABm9yYWNsZQIAAA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wAAAAIFAAAABmFkbWluMQkAAlgAAAABCAUAAAACdHgAAAACaWQHAAAAAAAAAAABAAAAAAAAAAAABAAAAAxhZG1pbjJTaWduZWQDCQEAAAALdmFsdWVPckVsc2UAAAACCQAEGwAAAAIFAAAABmFkbWluMgkAAlgAAAABCAUAAAACdHgAAAACaWQHAAAAAAAAAAABAAAAAAAAAAAABAAAAAxhZG1pbjNTaWduZWQDCQEAAAALdmFsdWVPckVsc2UAAAACCQAEGwAAAAIFAAAABmFkbWluMwkAAlgAAAABCAUAAAACdHgAAAACaWQHAAAAAAAAAAABAAAAAAAAAAAABAAAAAxhZG1pbjRTaWduZWQDCQEAAAALdmFsdWVPckVsc2UAAAACCQAEGwAAAAIFAAAABmFkbWluNAkAAlgAAAABCAUAAAACdHgAAAACaWQHAAAAAAAAAAABAAAAAAAAAAAABAAAAAxhZG1pbjVTaWduZWQDCQEAAAALdmFsdWVPckVsc2UAAAACCQAEGwAAAAIFAAAABmFkbWluNQkAAlgAAAABCAUAAAACdHgAAAACaWQHAAAAAAAAAAABAAAAAAAAAAAACQAAZwAAAAIJAABkAAAAAgkAAGQAAAACCQAAZAAAAAIJAABkAAAAAgUAAAAMYWRtaW4xU2lnbmVkBQAAAAxhZG1pbjJTaWduZWQFAAAADGFkbWluM1NpZ25lZAUAAAAMYWRtaW40U2lnbmVkBQAAAAxhZG1pbjVTaWduZWQAAAAAAAAAAAPH9XqX", "chainId": 84, "height": 1817253, "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 oracle = Address(base58'3NCpwNNAC2S7fnPp8hHaKiHtuLFEMTKxTWR') | |
5 | + | ||
6 | + | let balance = addressFromStringValue(valueOrErrorMessage(getString(oracle, "balance_address"), "Empty key balance_address")) | |
7 | + | ||
8 | + | let SWOPgovernanceAdr = addressFromStringValue(valueOrErrorMessage(getString(oracle, "swop_governance"), "Empty key swop_governance")) | |
9 | + | ||
10 | + | let SWOP = fromBase58String(valueOrErrorMessage(getString(oracle, "SWOP"), "Empty key SWOP")) | |
11 | + | ||
12 | + | let consumers = split(valueOrElse(getString(oracle, "consumers"), "Empty key consumer"), ",") | |
13 | + | ||
14 | + | let admin1 = addressFromStringValue(valueOrElse(getString(oracle, "admin_1"), "Empty key admin_1")) | |
15 | + | ||
16 | + | let admin2 = addressFromStringValue(valueOrElse(getString(oracle, "admin_2"), "Empty key admin_2")) | |
17 | + | ||
18 | + | let admin3 = addressFromStringValue(valueOrElse(getString(oracle, "admin_3"), "Empty key admin_3")) | |
19 | + | ||
20 | + | let admin4 = addressFromStringValue(valueOrElse(getString(oracle, "admin_4"), "Empty key admin_4")) | |
21 | + | ||
22 | + | let admin5 = addressFromStringValue(valueOrElse(getString(oracle, "admin_5"), "Empty key admin_5")) | |
23 | + | ||
24 | + | let isProtocolActive = valueOrErrorMessage(getBoolean(oracle, "is_protocol_active"), "Empty key is_protocol_active") | |
25 | + | ||
26 | + | let keyIsDappActive = "is_dapp_active" | |
27 | + | ||
28 | + | let keyAutomateOwner = "owner" | |
29 | + | ||
30 | + | let isDappActive = valueOrErrorMessage(getBoolean(this, keyIsDappActive), "Empty key is_dapp_active") | |
31 | + | ||
32 | + | let ownerStr = valueOrErrorMessage(getString(this, keyAutomateOwner), "Empty keyAutomateOwner") | |
33 | + | ||
34 | + | let owner = addressFromString(ownerStr) | |
35 | + | ||
36 | + | let keyLastInterest = "last_interest" | |
37 | + | ||
38 | + | let keyUserSWOPLocked = "_SWOP_amount" | |
39 | + | ||
40 | + | let keyUserLastInterest = "_last_interest" | |
41 | + | ||
42 | + | let scaleValue = 100000000 | |
43 | + | ||
44 | + | func getLastInterestInfo () = { | |
45 | + | let lastInterest = valueOrElse(getInteger(SWOPgovernanceAdr, keyLastInterest), 0) | |
46 | + | lastInterest | |
47 | + | } | |
48 | + | ||
49 | + | ||
50 | + | func getUserSWOPLocked (user) = valueOrElse(getInteger(SWOPgovernanceAdr, (toString(user) + keyUserSWOPLocked)), 0) | |
51 | + | ||
52 | + | ||
53 | + | func getUserInterestInfo (user,lastInterest) = { | |
54 | + | let userSWOPAmount = getUserSWOPLocked(user) | |
55 | + | let userLastInterest = getInteger(SWOPgovernanceAdr, (toString(user) + keyUserLastInterest)) | |
56 | + | let userLastInterestValue = match userLastInterest { | |
57 | + | case userLastInterest: Int => | |
58 | + | userLastInterest | |
59 | + | case _ => | |
60 | + | lastInterest | |
61 | + | } | |
62 | + | $Tuple2(userLastInterestValue, userSWOPAmount) | |
63 | + | } | |
64 | + | ||
65 | + | ||
66 | + | func claimCalc (caller) = { | |
67 | + | let lastInterest = getLastInterestInfo() | |
68 | + | let uifo = getUserInterestInfo(caller, lastInterest) | |
69 | + | let userLastInterest = uifo._1 | |
70 | + | let userSWOPLocked = uifo._2 | |
71 | + | let claimAmount = fraction(userSWOPLocked, (lastInterest - userLastInterest), scaleValue) | |
72 | + | let userNewInterest = lastInterest | |
73 | + | $Tuple2(userNewInterest, claimAmount) | |
74 | + | } | |
75 | + | ||
76 | + | ||
77 | + | @Callable(i) | |
78 | + | func governanceLockSWOP () = if (!(if (isProtocolActive) | |
79 | + | then isDappActive | |
80 | + | else false)) | |
81 | + | then throw("Protol stopped by admin") | |
82 | + | else { | |
83 | + | let $t031063181 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
84 | + | let pmtAmount = $t031063181._1 | |
85 | + | let pmtAssetId = $t031063181._2 | |
86 | + | if ((pmtAssetId != SWOP)) | |
87 | + | then throw("Only SWOP payment available in governanceLockSWOP()") | |
88 | + | else { | |
89 | + | let z = invoke(SWOPgovernanceAdr, "lockSWOP", nil, [AttachedPayment(SWOP, pmtAmount)]) | |
90 | + | if ((z == z)) | |
91 | + | then nil | |
92 | + | else throw("Strict value is not equal to itself.") | |
93 | + | } | |
94 | + | } | |
95 | + | ||
96 | + | ||
97 | + | ||
98 | + | @Callable(i) | |
99 | + | func governanceClaimAndStake (minSWOPreward) = if (!(if (isProtocolActive) | |
100 | + | then isDappActive | |
101 | + | else false)) | |
102 | + | then throw("Protol stopped by admin") | |
103 | + | else if (if ((i.caller != owner)) | |
104 | + | then !(containsElement(consumers, toBase58String(i.caller.bytes))) | |
105 | + | else false) | |
106 | + | then throw("Only owner or admin can call this function") | |
107 | + | else { | |
108 | + | let claimAmount = claimCalc(this)._2 | |
109 | + | if ((minSWOPreward > claimAmount)) | |
110 | + | then throw("Amount to claim is less than minSWOPreward") | |
111 | + | else { | |
112 | + | let isFeeExtract = if ((i.caller == owner)) | |
113 | + | then false | |
114 | + | else true | |
115 | + | let z = invoke(SWOPgovernanceAdr, "claimAndStakeSWOP", nil, nil) | |
116 | + | if ((z == z)) | |
117 | + | then { | |
118 | + | let y = invoke(balance, "extractFee", [isFeeExtract], nil) | |
119 | + | if ((y == y)) | |
120 | + | then nil | |
121 | + | else throw("Strict value is not equal to itself.") | |
122 | + | } | |
123 | + | else throw("Strict value is not equal to itself.") | |
124 | + | } | |
125 | + | } | |
126 | + | ||
127 | + | ||
128 | + | ||
129 | + | @Callable(i) | |
130 | + | func governanceWithdraw (amtToWithdraw) = if (!(if (isProtocolActive) | |
131 | + | then isDappActive | |
132 | + | else false)) | |
133 | + | then throw("Protol stopped by admin") | |
134 | + | else if ((i.caller != owner)) | |
135 | + | then throw("Only owner can call this function") | |
136 | + | else { | |
137 | + | let z = invoke(SWOPgovernanceAdr, "withdrawSWOP", [amtToWithdraw], nil) | |
138 | + | if ((z == z)) | |
139 | + | then [ScriptTransfer(i.caller, amtToWithdraw, SWOP)] | |
140 | + | else throw("Strict value is not equal to itself.") | |
141 | + | } | |
142 | + | ||
143 | + | ||
144 | + | ||
145 | + | @Callable(i) | |
146 | + | func shutdownDapp () = if (!(if (isProtocolActive) | |
147 | + | then isDappActive | |
148 | + | else false)) | |
149 | + | then throw("Protol stopped by admin") | |
150 | + | else if (if (!(containsElement([admin1, admin2, admin3, admin4, admin5, owner], i.caller))) | |
151 | + | then !(containsElement(consumers, toBase58String(i.caller.bytes))) | |
152 | + | else false) | |
153 | + | then throw("Only admin can call this function") | |
154 | + | else [BooleanEntry("is_dapp_active", false)] | |
155 | + | ||
156 | + | ||
157 | + | @Verifier(tx) | |
158 | + | func verify () = { | |
159 | + | let admin1Signed = if (valueOrElse(getBoolean(admin1, toBase58String(tx.id)), false)) | |
160 | + | then 1 | |
161 | + | else 0 | |
162 | + | let admin2Signed = if (valueOrElse(getBoolean(admin2, toBase58String(tx.id)), false)) | |
163 | + | then 1 | |
164 | + | else 0 | |
165 | + | let admin3Signed = if (valueOrElse(getBoolean(admin3, toBase58String(tx.id)), false)) | |
166 | + | then 1 | |
167 | + | else 0 | |
168 | + | let admin4Signed = if (valueOrElse(getBoolean(admin4, toBase58String(tx.id)), false)) | |
169 | + | then 1 | |
170 | + | else 0 | |
171 | + | let admin5Signed = if (valueOrElse(getBoolean(admin5, toBase58String(tx.id)), false)) | |
172 | + | then 1 | |
173 | + | else 0 | |
174 | + | (((((admin1Signed + admin2Signed) + admin3Signed) + admin4Signed) + admin5Signed) >= 3) | |
175 | + | } | |
176 | + |
github/deemru/w8io/169f3d6 18.59 ms ◑