tx · GKrvFEC1Rr9F1UqrkouUbZXSfRsEDvnUoSWWFdpEojkU 3Mqufnn29JVaZuJUTECwo4nTsidsA4NxLJQ: -0.01400000 Waves 2021.10.31 13:36 [1770378] smart account 3Mqufnn29JVaZuJUTECwo4nTsidsA4NxLJQ > SELF 0.00000000 Waves
{ "type": 13, "id": "GKrvFEC1Rr9F1UqrkouUbZXSfRsEDvnUoSWWFdpEojkU", "fee": 1400000, "feeAssetId": null, "timestamp": 1635676663874, "version": 1, "sender": "3Mqufnn29JVaZuJUTECwo4nTsidsA4NxLJQ", "senderPublicKey": "Cgkxt6Emvt7a3mQhTv2Hri7Wnebey4J3kgRAhF1f1mdp", "proofs": [ "33qfPKk1FFiHjLNNQR9mcUjUY3jvCrorNNnm9RhcY34FudXi1hL3WBM3BgVmBFnF1kzJddJKgYp8suLrvz8tJujy" ], "script": "base64:AAIFAAAAAAAAABIIAhIAEgASAwoBARIDCgEBEgAAAAAWAAAAAAZvcmFjbGUJAQAAAAdBZGRyZXNzAAAAAQEAAAAaAVT2TjOFXpjVdjyOj0sBjic2NFJc9Kx4msUAAAAAB2JhbGFuY2UJAQAAABFAZXh0ck5hdGl2ZSgxMDYyKQAAAAEJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABB0AAAACBQAAAAZvcmFjbGUCAAAAD2JhbGFuY2VfYWRkcmVzcwIAAAAZRW1wdHkga2V5IGJhbGFuY2VfYWRkcmVzcwAAAAARU1dPUGdvdmVybmFuY2VBZHIJAQAAABFAZXh0ck5hdGl2ZSgxMDYyKQAAAAEJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABB0AAAACBQAAAAZvcmFjbGUCAAAAD3N3b3BfZ292ZXJuYW5jZQIAAAAZRW1wdHkga2V5IHN3b3BfZ292ZXJuYW5jZQAAAAAEU1dPUAkAAlkAAAABCQEAAAATdmFsdWVPckVycm9yTWVzc2FnZQAAAAIJAAQdAAAAAgUAAAAGb3JhY2xlAgAAA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taW4xU2lnbmVkAwkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABBsAAAACBQAAAAZhZG1pbjECAAAABXR4U3RyBwAAAAAAAAAAAQAAAAAAAAAAAAQAAAAMYWRtaW4yU2lnbmVkAwkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABBsAAAACBQAAAAZhZG1pbjICAAAABXR4U3RyBwAAAAAAAAAAAQAAAAAAAAAAAAQAAAAMYWRtaW4zU2lnbmVkAwkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABBsAAAACBQAAAAZhZG1pbjMCAAAABXR4U3RyBwAAAAAAAAAAAQAAAAAAAAAAAAkAAGcAAAACCQAAZAAAAAIJAABkAAAAAgUAAAAMYWRtaW4xU2lnbmVkBQAAAAxhZG1pbjJTaWduZWQFAAAADGFkbWluM1NpZ25lZAAAAAAAAAAAAqCe70o=", "chainId": 84, "height": 1770378, "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'3NCNRgdSsFaF8y8V1ghhGiU5KoSBMhQbzJg') | |
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 isProtocolActive = valueOrErrorMessage(getBoolean(oracle, "is_protocol_active"), "Empty key is_protocol_active") | |
21 | + | ||
22 | + | let keyOwner = "owner" | |
23 | + | ||
24 | + | let keyIsDappActive = "is_dapp_active" | |
25 | + | ||
26 | + | let owner = addressFromString(valueOrErrorMessage(getString(this, keyOwner), "Empty keyOwner")) | |
27 | + | ||
28 | + | let ownerStr = valueOrErrorMessage(getString(this, keyOwner), "Empty keyOwner") | |
29 | + | ||
30 | + | let isDappActive = valueOrErrorMessage(getBoolean(this, keyIsDappActive), "Empty key is_dapp_active") | |
31 | + | ||
32 | + | let keyLastInterest = "last_interest" | |
33 | + | ||
34 | + | let keyUserSWOPLocked = "_SWOP_amount" | |
35 | + | ||
36 | + | let keyUserLastInterest = "_last_interest" | |
37 | + | ||
38 | + | let scaleValue = 100000000 | |
39 | + | ||
40 | + | func getLastInterestInfo () = { | |
41 | + | let lastInterest = valueOrElse(getInteger(SWOPgovernanceAdr, keyLastInterest), 0) | |
42 | + | lastInterest | |
43 | + | } | |
44 | + | ||
45 | + | ||
46 | + | func getUserSWOPLocked (user) = valueOrElse(getInteger(SWOPgovernanceAdr, (toString(user) + keyUserSWOPLocked)), 0) | |
47 | + | ||
48 | + | ||
49 | + | func getUserInterestInfo (user,lastInterest) = { | |
50 | + | let userSWOPAmount = getUserSWOPLocked(user) | |
51 | + | let userLastInterest = getInteger(SWOPgovernanceAdr, (toString(user) + keyUserLastInterest)) | |
52 | + | let userLastInterestValue = match userLastInterest { | |
53 | + | case userLastInterest: Int => | |
54 | + | userLastInterest | |
55 | + | case _ => | |
56 | + | lastInterest | |
57 | + | } | |
58 | + | $Tuple2(userLastInterestValue, userSWOPAmount) | |
59 | + | } | |
60 | + | ||
61 | + | ||
62 | + | func claimCalc (caller) = { | |
63 | + | let lastInterest = getLastInterestInfo() | |
64 | + | let uifo = getUserInterestInfo(caller, lastInterest) | |
65 | + | let userLastInterest = uifo._1 | |
66 | + | let userSWOPLocked = uifo._2 | |
67 | + | let claimAmount = fraction(userSWOPLocked, (lastInterest - userLastInterest), scaleValue) | |
68 | + | let userNewInterest = lastInterest | |
69 | + | $Tuple2(userNewInterest, claimAmount) | |
70 | + | } | |
71 | + | ||
72 | + | ||
73 | + | @Callable(i) | |
74 | + | func init () = if (!(isProtocolActive)) | |
75 | + | then throw("Protol stopped by admin") | |
76 | + | else if (isDefined(getString(this, keyOwner))) | |
77 | + | then throw("Automate already initialized") | |
78 | + | else if ((size(i.payments) == 0)) | |
79 | + | then [StringEntry(keyOwner, toString(i.caller)), BooleanEntry(keyIsDappActive, true)] | |
80 | + | else if ((size(i.payments) == 1)) | |
81 | + | then { | |
82 | + | let $t031443219 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
83 | + | let pmtAmount = $t031443219._1 | |
84 | + | let pmtAssetId = $t031443219._2 | |
85 | + | if ((pmtAssetId != SWOP)) | |
86 | + | then throw("Only SWOP payment available in init()") | |
87 | + | else { | |
88 | + | let z = invoke(SWOPgovernanceAdr, "lockSWOP", nil, [AttachedPayment(SWOP, pmtAmount)]) | |
89 | + | if ((z == z)) | |
90 | + | then [StringEntry(keyOwner, toString(i.caller)), BooleanEntry(keyIsDappActive, true)] | |
91 | + | else throw("Strict value is not equal to itself.") | |
92 | + | } | |
93 | + | } | |
94 | + | else throw("Incorrect paynemt. You should attach SWOP or empty payment") | |
95 | + | ||
96 | + | ||
97 | + | ||
98 | + | @Callable(i) | |
99 | + | func governanceLockSWOP () = if (!(if (isProtocolActive) | |
100 | + | then isDappActive | |
101 | + | else false)) | |
102 | + | then throw("Protol stopped by admin") | |
103 | + | else { | |
104 | + | let $t037643839 = $Tuple2(i.payments[0].amount, i.payments[0].assetId) | |
105 | + | let pmtAmount = $t037643839._1 | |
106 | + | let pmtAssetId = $t037643839._2 | |
107 | + | if ((pmtAssetId != SWOP)) | |
108 | + | then throw("Only SWOP payment available in governanceLockSWOP()") | |
109 | + | else { | |
110 | + | let z = invoke(SWOPgovernanceAdr, "lockSWOP", nil, [AttachedPayment(SWOP, pmtAmount)]) | |
111 | + | if ((z == z)) | |
112 | + | then nil | |
113 | + | else throw("Strict value is not equal to itself.") | |
114 | + | } | |
115 | + | } | |
116 | + | ||
117 | + | ||
118 | + | ||
119 | + | @Callable(i) | |
120 | + | func governanceClaimAndStake (minSWOPreward) = if (!(if (isProtocolActive) | |
121 | + | then isDappActive | |
122 | + | else false)) | |
123 | + | then throw("Protol stopped by admin") | |
124 | + | else if (if ((i.caller != owner)) | |
125 | + | then !(containsElement(consumers, toBase58String(i.caller.bytes))) | |
126 | + | else false) | |
127 | + | then throw("Only owner or admin can call this function") | |
128 | + | else { | |
129 | + | let claimAmount = claimCalc(this)._2 | |
130 | + | if ((minSWOPreward > claimAmount)) | |
131 | + | then throw("Amount to claim is less than minSWOPreward") | |
132 | + | else { | |
133 | + | let isFeeExtract = if ((i.caller == owner)) | |
134 | + | then false | |
135 | + | else true | |
136 | + | let z = invoke(SWOPgovernanceAdr, "claimAndStakeSWOP", nil, nil) | |
137 | + | if ((z == z)) | |
138 | + | then { | |
139 | + | let y = invoke(balance, "extractFee", [ownerStr, isFeeExtract], nil) | |
140 | + | if ((y == y)) | |
141 | + | then nil | |
142 | + | else throw("Strict value is not equal to itself.") | |
143 | + | } | |
144 | + | else throw("Strict value is not equal to itself.") | |
145 | + | } | |
146 | + | } | |
147 | + | ||
148 | + | ||
149 | + | ||
150 | + | @Callable(i) | |
151 | + | func governanceWithdraw (amtToWithdraw) = if (!(if (isProtocolActive) | |
152 | + | then isDappActive | |
153 | + | else false)) | |
154 | + | then throw("Protol stopped by admin") | |
155 | + | else if ((i.caller != owner)) | |
156 | + | then throw("Only owner can call this function") | |
157 | + | else { | |
158 | + | let z = invoke(SWOPgovernanceAdr, "withdrawSWOP", [amtToWithdraw], nil) | |
159 | + | if ((z == z)) | |
160 | + | then [ScriptTransfer(i.caller, amtToWithdraw, SWOP)] | |
161 | + | else throw("Strict value is not equal to itself.") | |
162 | + | } | |
163 | + | ||
164 | + | ||
165 | + | ||
166 | + | @Callable(i) | |
167 | + | func shutdownDapp () = if (!(if (isProtocolActive) | |
168 | + | then isDappActive | |
169 | + | else false)) | |
170 | + | then throw("Protol stopped by admin") | |
171 | + | else if (if (!(containsElement([admin1, admin2, admin3], i.caller))) | |
172 | + | then !(containsElement(consumers, toBase58String(i.caller.bytes))) | |
173 | + | else false) | |
174 | + | then throw("Only admin can call this function") | |
175 | + | else [BooleanEntry("is_dapp_active", false)] | |
176 | + | ||
177 | + | ||
178 | + | @Verifier(tx) | |
179 | + | func verify () = { | |
180 | + | let admin1Signed = if (valueOrElse(getBoolean(admin1, "txStr"), false)) | |
181 | + | then 1 | |
182 | + | else 0 | |
183 | + | let admin2Signed = if (valueOrElse(getBoolean(admin2, "txStr"), false)) | |
184 | + | then 1 | |
185 | + | else 0 | |
186 | + | let admin3Signed = if (valueOrElse(getBoolean(admin3, "txStr"), false)) | |
187 | + | then 1 | |
188 | + | else 0 | |
189 | + | (((admin1Signed + admin2Signed) + admin3Signed) >= 2) | |
190 | + | } | |
191 | + |
github/deemru/w8io/026f985 35.30 ms ◑