tx · 6pFs9KvsXyVLXmfK7N3Bau6hWrRcxeq61qXApLprsThV 3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq: -0.02000000 Waves 2023.07.21 15:55 [2675643] smart account 3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq > SELF 0.00000000 Waves
{ "type": 13, "id": "6pFs9KvsXyVLXmfK7N3Bau6hWrRcxeq61qXApLprsThV", "fee": 2000000, "feeAssetId": null, "timestamp": 1689944189016, "version": 2, "chainId": 84, "sender": "3MpMuGN8rW9EpPwzETAQz88Pe9TQhSwiriq", "senderPublicKey": "57SkjQUEwC1ayCqLbXLuzBqifK6B6SR6rfxtGsbAo3zW", "proofs": [ "2XAK9j63ZnAtUajG3GbUMiNYZvZ3kx4skycbkCvH2DbrpBfPVb2whEXUskuDPtE9TDCnRyPGXAiPu7QNMg7gNusf" ], "script": "base64:BgIfCAISAwoBARIAEgMKAQgSAwoBARIDCgEIEgASAwoBCC8ADGNvbnRyYWN0RmlsZQIQbXB0X3N0YWtpbmcucmlkZQADU0VQAgJfXwAGc2NhbGU4AIDC1y8AEkFERFJFU1NfQllURVNfU0laRQAaAA1CTE9DS1NfSU5fREFZAKALAQh0aHJvd0VycgEDbXNnCQACAQkArAICCQCsAgIFDGNvbnRyYWN0RmlsZQICOiAFA21zZwAKa2V5QXNzZXRJZAkAuQkCCQDMCAICAiVzCQDMCAICB2Fzc2V0SWQFA25pbAUDU0VQABNrZXlFbWlzc2lvblBlckJsb2NrCQC5CQIJAMwIAgICJXMJAMwIAgIQZW1pc3Npb25QZXJCbG9jawUDbmlsBQNTRVAAGWtleUVtaXNzaW9uUGVyaW9kSW5CbG9ja3MJALkJAgkAzAgCAgIlcwkAzAgCAhZlbWlzc2lvblBlcmlvZEluQmxvY2tzBQNuaWwFA1NFUAANa2V5U3RhcnRCbG9jawkAuQkCCQDMCAICAiVzCQDMCAICCnN0YXJ0QmxvY2sFA25pbAUDU0VQABBrZXlUb3RhbExwQW1vdW50CQC5CQI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ZQEFEWFsbG93ZWRUeElkT3B0aW9uBQR0eElkBgkBCHRocm93RXJyAQkArAICBQR0eElkAhMgaXMgYWxyZWFkeSBhbGxvd2VkBQNuaWwDCQAAAgUDZXJyBQNlcnIJAQx2b3RlSU5URVJOQUwEBRNjYWxsZXJBZGRyZXNzU3RyaW5nBQlrZXlQcmVmaXgFBlFVT1JVTQUGcmVzdWx0CQACAQIkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAQJ0eAEGdmVyaWZ5AAQIYnlBZG1pbnMJAAACCAUCdHgCaWQJANkEAQkBC3ZhbHVlT3JFbHNlAgkAnQgCBQR0aGlzCQEOa2V5QWxsb3dlZFR4SWQAAgAEB2J5T3duZXIDCQBnAgkAkAMBCQENZ2V0QWRtaW5zTGlzdAAFBlFVT1JVTQcJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXkDBQhieUFkbWlucwYFB2J5T3duZXKK0ZJV", "height": 2675643, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Hsg6jYUKLzTPdprb9HQy6se7vceLiAAMjJvCzGbJePSW Next: GNgVpsstBv7bavKTgTETGZYsy6cQaeSpTNXBXTYkAZgf Diff:
Old | New | Differences | |
---|---|---|---|
186 | 186 | } | |
187 | 187 | ||
188 | 188 | ||
189 | - | func | |
189 | + | func debugPeriod () = { | |
190 | 190 | let startBlock = valueOrElse(getInteger(this, keyStartBlock), 0) | |
191 | 191 | let startPeriod = fraction(startBlock, 1, emissionPeriodInBlocks) | |
192 | 192 | let elapsedPeriods = (heightInPeriods - startPeriod) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let contractFile = "mpt_staking.ride" | |
5 | 5 | ||
6 | 6 | let SEP = "__" | |
7 | 7 | ||
8 | 8 | let scale8 = 100000000 | |
9 | 9 | ||
10 | 10 | let ADDRESS_BYTES_SIZE = 26 | |
11 | 11 | ||
12 | 12 | let BLOCKS_IN_DAY = 1440 | |
13 | 13 | ||
14 | 14 | func throwErr (msg) = throw(((contractFile + ": ") + msg)) | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | let keyAssetId = makeString(["%s", "assetId"], SEP) | |
18 | 18 | ||
19 | 19 | let keyEmissionPerBlock = makeString(["%s", "emissionPerBlock"], SEP) | |
20 | 20 | ||
21 | 21 | let keyEmissionPeriodInBlocks = makeString(["%s", "emissionPeriodInBlocks"], SEP) | |
22 | 22 | ||
23 | 23 | let keyStartBlock = makeString(["%s", "startBlock"], SEP) | |
24 | 24 | ||
25 | 25 | let keyTotalLpAmount = makeString(["%s", "totalLpAmount"], SEP) | |
26 | 26 | ||
27 | 27 | let keyTotalAssetAmount = makeString(["%s", "totalAssetAmount"], SEP) | |
28 | 28 | ||
29 | 29 | func keyUserLpAmount (userAddress) = makeString(["%s%s", "userLpAmount", userAddress], SEP) | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func keyUserTotalAssetWithdrawn (userAddress) = makeString(["%s%s", "totalAssetWithdrawn", userAddress], SEP) | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func keyUserTotalAssetStaked (userAddress) = makeString(["%s%s", "totalAssetStaked", userAddress], SEP) | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | let totalLpAmount = valueOrElse(getInteger(this, keyTotalLpAmount), 0) | |
39 | 39 | ||
40 | 40 | let totalAssetAmount = valueOrElse(getInteger(this, keyTotalAssetAmount), 0) | |
41 | 41 | ||
42 | 42 | let assetIdString = valueOrElse(getString(this, keyAssetId), "WAVES") | |
43 | 43 | ||
44 | 44 | let assetIdBytes = if ((assetIdString == "WAVES")) | |
45 | 45 | then unit | |
46 | 46 | else fromBase58String(assetIdString) | |
47 | 47 | ||
48 | 48 | let emissionPeriodInBlocks = valueOrElse(getInteger(this, keyEmissionPeriodInBlocks), BLOCKS_IN_DAY) | |
49 | 49 | ||
50 | 50 | let emissionPerPeriod = (valueOrElse(getInteger(this, keyEmissionPerBlock), 0) * emissionPeriodInBlocks) | |
51 | 51 | ||
52 | 52 | let heightInPeriods = fraction(height, 1, emissionPeriodInBlocks) | |
53 | 53 | ||
54 | 54 | let ADMIN_LIST_SIZE = 5 | |
55 | 55 | ||
56 | 56 | let QUORUM = 3 | |
57 | 57 | ||
58 | 58 | let TXID_BYTES_LENGTH = 32 | |
59 | 59 | ||
60 | 60 | func keyAllowedTxIdVotePrefix (txId) = makeString(["%s%s%s", "allowTxId", txId], SEP) | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | func keyFullAdminVote (prefix,adminAddress) = makeString([prefix, adminAddress], SEP) | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | func keyAdminAddressList () = makeString(["%s", "adminAddressList"], SEP) | |
67 | 67 | ||
68 | 68 | ||
69 | 69 | func keyAllowedTxId () = makeString(["%s", "txId"], SEP) | |
70 | 70 | ||
71 | 71 | ||
72 | 72 | func getAdminVote (prefix,admin) = { | |
73 | 73 | let voteKey = keyFullAdminVote(prefix, admin) | |
74 | 74 | valueOrElse(getInteger(voteKey), 0) | |
75 | 75 | } | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | func getAdminsList () = match getString(this, keyAdminAddressList()) { | |
79 | 79 | case s: String => | |
80 | 80 | split(s, SEP) | |
81 | 81 | case _ => | |
82 | 82 | nil | |
83 | 83 | } | |
84 | 84 | ||
85 | 85 | ||
86 | 86 | func isInAdminList (address) = containsElement(getAdminsList(), address) | |
87 | 87 | ||
88 | 88 | ||
89 | 89 | func genVotesKeysHelper (a,adminAddress) = { | |
90 | 90 | let $t026382662 = a | |
91 | 91 | let result = $t026382662._1 | |
92 | 92 | let prefix = $t026382662._2 | |
93 | 93 | $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix) | |
94 | 94 | } | |
95 | 95 | ||
96 | 96 | ||
97 | 97 | func genVotesKeys (keyPrefix) = { | |
98 | 98 | let adminList = keyAdminAddressList() | |
99 | 99 | let $t028092893 = { | |
100 | 100 | let $l = getAdminsList() | |
101 | 101 | let $s = size($l) | |
102 | 102 | let $acc0 = $Tuple2(nil, keyPrefix) | |
103 | 103 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
104 | 104 | then $a | |
105 | 105 | else genVotesKeysHelper($a, $l[$i]) | |
106 | 106 | ||
107 | 107 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
108 | 108 | then $a | |
109 | 109 | else throw("List size exceeds 5") | |
110 | 110 | ||
111 | 111 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
112 | 112 | } | |
113 | 113 | let result = $t028092893._1 | |
114 | 114 | let prefix = $t028092893._2 | |
115 | 115 | result | |
116 | 116 | } | |
117 | 117 | ||
118 | 118 | ||
119 | 119 | func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0)) | |
120 | 120 | ||
121 | 121 | ||
122 | 122 | func countVotes (prefix) = { | |
123 | 123 | let votes = genVotesKeys(prefix) | |
124 | 124 | let $l = votes | |
125 | 125 | let $s = size($l) | |
126 | 126 | let $acc0 = 0 | |
127 | 127 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
128 | 128 | then $a | |
129 | 129 | else countVotesHelper($a, $l[$i]) | |
130 | 130 | ||
131 | 131 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
132 | 132 | then $a | |
133 | 133 | else throw("List size exceeds 5") | |
134 | 134 | ||
135 | 135 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
136 | 136 | } | |
137 | 137 | ||
138 | 138 | ||
139 | 139 | func clearVotesHelper (result,key) = (result :+ DeleteEntry(key)) | |
140 | 140 | ||
141 | 141 | ||
142 | 142 | func getClearVoteEntries (prefix) = { | |
143 | 143 | let votes = genVotesKeys(prefix) | |
144 | 144 | let $l = votes | |
145 | 145 | let $s = size($l) | |
146 | 146 | let $acc0 = nil | |
147 | 147 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
148 | 148 | then $a | |
149 | 149 | else clearVotesHelper($a, $l[$i]) | |
150 | 150 | ||
151 | 151 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
152 | 152 | then $a | |
153 | 153 | else throw("List size exceeds 5") | |
154 | 154 | ||
155 | 155 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
156 | 156 | } | |
157 | 157 | ||
158 | 158 | ||
159 | 159 | func voteINTERNAL (callerAddressString,keyPrefix,minVotes,voteResult) = { | |
160 | 160 | let voteKey = keyFullAdminVote(keyPrefix, callerAddressString) | |
161 | 161 | let adminCurrentVote = getAdminVote(keyPrefix, callerAddressString) | |
162 | 162 | let err = if (!(isInAdminList(callerAddressString))) | |
163 | 163 | then throwErr((("Address: " + callerAddressString) + " not in Admin list")) | |
164 | 164 | else if ((adminCurrentVote == 1)) | |
165 | 165 | then throwErr((voteKey + " you already voted")) | |
166 | 166 | else unit | |
167 | 167 | if ((err == err)) | |
168 | 168 | then { | |
169 | 169 | let votes = countVotes(keyPrefix) | |
170 | 170 | if (((votes + 1) >= minVotes)) | |
171 | 171 | then { | |
172 | 172 | let clearVoteEntries = getClearVoteEntries(keyPrefix) | |
173 | 173 | (clearVoteEntries ++ voteResult) | |
174 | 174 | } | |
175 | 175 | else [IntegerEntry(voteKey, 1)] | |
176 | 176 | } | |
177 | 177 | else throw("Strict value is not equal to itself.") | |
178 | 178 | } | |
179 | 179 | ||
180 | 180 | ||
181 | 181 | func calcTotalProfit () = { | |
182 | 182 | let startBlock = valueOrElse(getInteger(this, keyStartBlock), 0) | |
183 | 183 | let startPeriod = fraction(startBlock, 1, emissionPeriodInBlocks) | |
184 | 184 | let elapsedPeriods = (heightInPeriods - startPeriod) | |
185 | 185 | max([0, (emissionPerPeriod * elapsedPeriods)]) | |
186 | 186 | } | |
187 | 187 | ||
188 | 188 | ||
189 | - | func | |
189 | + | func debugPeriod () = { | |
190 | 190 | let startBlock = valueOrElse(getInteger(this, keyStartBlock), 0) | |
191 | 191 | let startPeriod = fraction(startBlock, 1, emissionPeriodInBlocks) | |
192 | 192 | let elapsedPeriods = (heightInPeriods - startPeriod) | |
193 | 193 | $Tuple5(startPeriod, heightInPeriods, elapsedPeriods, startBlock, height) | |
194 | 194 | } | |
195 | 195 | ||
196 | 196 | ||
197 | 197 | func getTotalAssetAmountWithProfitOrMaxAvailable () = { | |
198 | 198 | let totalAssetAmountWithProfit = (totalAssetAmount + calcTotalProfit()) | |
199 | 199 | let totalAmount = match assetIdBytes { | |
200 | 200 | case u: Unit => | |
201 | 201 | min([totalAssetAmountWithProfit, wavesBalance(this).available]) | |
202 | 202 | case b: ByteVector => | |
203 | 203 | min([totalAssetAmountWithProfit, assetBalance(this, b)]) | |
204 | 204 | case _ => | |
205 | 205 | throw("Match error") | |
206 | 206 | } | |
207 | 207 | if ((totalLpAmount == 0)) | |
208 | 208 | then 0 | |
209 | 209 | else totalAmount | |
210 | 210 | } | |
211 | 211 | ||
212 | 212 | ||
213 | 213 | func getCurrentPrice () = if ((totalLpAmount != 0)) | |
214 | 214 | then fraction(getTotalAssetAmountWithProfitOrMaxAvailable(), scale8, totalLpAmount) | |
215 | 215 | else (1 * scale8) | |
216 | 216 | ||
217 | 217 | ||
218 | 218 | func getUserLpAmount (userAddress) = valueOrElse(getInteger(this, keyUserLpAmount(userAddress)), 0) | |
219 | 219 | ||
220 | 220 | ||
221 | 221 | func getUserAvailableAssetsToWithdraw (userAddress) = { | |
222 | 222 | let userLpAmount = getUserLpAmount(userAddress) | |
223 | 223 | let userAvailableAssetToWithdraw = fraction(userLpAmount, getCurrentPrice(), scale8) | |
224 | 224 | if ((getCurrentPrice() > (userAvailableAssetToWithdraw * scale8))) | |
225 | 225 | then 0 | |
226 | 226 | else userAvailableAssetToWithdraw | |
227 | 227 | } | |
228 | 228 | ||
229 | 229 | ||
230 | 230 | func getStakeActions (i,userAddress) = { | |
231 | 231 | let checks = [if ((size(i.payments) == 1)) | |
232 | 232 | then true | |
233 | 233 | else throwErr("should include 1 payment"), if ((i.payments[0].assetId == assetIdBytes)) | |
234 | 234 | then true | |
235 | 235 | else throwErr(("payment should be in " + assetIdString)), if ((i.payments[0].amount > 0)) | |
236 | 236 | then true | |
237 | 237 | else "payment amount should be greater than 0"] | |
238 | 238 | if ((checks == checks)) | |
239 | 239 | then { | |
240 | 240 | let paymentAmount = i.payments[0].amount | |
241 | 241 | let paymentLpAmount = fraction(paymentAmount, scale8, getCurrentPrice()) | |
242 | 242 | let userLpAmount = getUserLpAmount(userAddress) | |
243 | 243 | let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0) | |
244 | 244 | let newTotalLpAmount = (totalLpAmount + paymentLpAmount) | |
245 | 245 | let newTotalAssetAmount = (totalAssetAmount + paymentAmount) | |
246 | 246 | let newUserLpAmount = (userLpAmount + paymentLpAmount) | |
247 | 247 | let newUserTotalStakedAmount = (userTotalStakedAmount + paymentAmount) | |
248 | 248 | let updateStartHeightAction = if ((totalLpAmount == 0)) | |
249 | 249 | then [IntegerEntry(keyStartBlock, height)] | |
250 | 250 | else nil | |
251 | 251 | ([IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalStakedAmount)] ++ updateStartHeightAction) | |
252 | 252 | } | |
253 | 253 | else throw("Strict value is not equal to itself.") | |
254 | 254 | } | |
255 | 255 | ||
256 | 256 | ||
257 | 257 | func getWithdrawActions (i,lpAssetWithdrawAmount) = { | |
258 | 258 | let userAddress = toString(i.caller) | |
259 | 259 | let userLpAmount = getUserLpAmount(userAddress) | |
260 | 260 | let check = [if ((lpAssetWithdrawAmount > 0)) | |
261 | 261 | then true | |
262 | 262 | else throwErr("LP amount should be more than 0"), if ((userLpAmount >= lpAssetWithdrawAmount)) | |
263 | 263 | then true | |
264 | 264 | else throwErr((("cannot withdraw more than available LP (" + toString(userLpAmount)) + ")"))] | |
265 | 265 | if ((check == check)) | |
266 | 266 | then { | |
267 | 267 | let newUserLpAmount = (userLpAmount - lpAssetWithdrawAmount) | |
268 | 268 | let withdrawAssetAmount = fraction(lpAssetWithdrawAmount, getCurrentPrice(), scale8) | |
269 | 269 | let newTotalLpAmount = (totalLpAmount - lpAssetWithdrawAmount) | |
270 | 270 | let newTotalAssetAmount = fraction(newTotalLpAmount, getCurrentPrice(), scale8) | |
271 | 271 | let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0) | |
272 | 272 | let newUserTotalAssetWithdrawn = (userTotalAssetWithdrawn + withdrawAssetAmount) | |
273 | 273 | [IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)] | |
274 | 274 | } | |
275 | 275 | else throw("Strict value is not equal to itself.") | |
276 | 276 | } | |
277 | 277 | ||
278 | 278 | ||
279 | 279 | @Callable(i) | |
280 | 280 | func setEmissionPerBlock (emissionPerBlock) = { | |
281 | 281 | let check = [if ((i.caller == this)) | |
282 | 282 | then true | |
283 | 283 | else throwErr("permission denied")] | |
284 | 284 | if ((check == check)) | |
285 | 285 | then [IntegerEntry(keyTotalAssetAmount, getTotalAssetAmountWithProfitOrMaxAvailable()), IntegerEntry(keyStartBlock, height), IntegerEntry(keyEmissionPerBlock, max([0, emissionPerBlock]))] | |
286 | 286 | else throw("Strict value is not equal to itself.") | |
287 | 287 | } | |
288 | 288 | ||
289 | 289 | ||
290 | 290 | ||
291 | 291 | @Callable(i) | |
292 | 292 | func stake () = getStakeActions(i, toString(i.caller)) | |
293 | 293 | ||
294 | 294 | ||
295 | 295 | ||
296 | 296 | @Callable(i) | |
297 | 297 | func stakeFor (userAddress) = { | |
298 | 298 | let check = [if ((size(fromBase58String(userAddress)) == ADDRESS_BYTES_SIZE)) | |
299 | 299 | then true | |
300 | 300 | else throwErr("address is not valid")] | |
301 | 301 | if ((check == check)) | |
302 | 302 | then getStakeActions(i, userAddress) | |
303 | 303 | else throw("Strict value is not equal to itself.") | |
304 | 304 | } | |
305 | 305 | ||
306 | 306 | ||
307 | 307 | ||
308 | 308 | @Callable(i) | |
309 | 309 | func withdraw (withdrawAssetAmount) = { | |
310 | 310 | let userAddress = toString(i.caller) | |
311 | 311 | let userLpAmount = getUserLpAmount(userAddress) | |
312 | 312 | let lpAmountToWithdraw = fraction(withdrawAssetAmount, scale8, getCurrentPrice()) | |
313 | 313 | let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress) | |
314 | 314 | let check = [if ((withdrawAssetAmount > 0)) | |
315 | 315 | then true | |
316 | 316 | else throwErr("withdraw amount should be more than 0"), if ((userAvailableAssetToWithdraw >= withdrawAssetAmount)) | |
317 | 317 | then true | |
318 | 318 | else throwErr((("cannot withdraw more than available (" + toString(userAvailableAssetToWithdraw)) + ")"))] | |
319 | 319 | if ((check == check)) | |
320 | 320 | then getWithdrawActions(i, lpAmountToWithdraw) | |
321 | 321 | else throw("Strict value is not equal to itself.") | |
322 | 322 | } | |
323 | 323 | ||
324 | 324 | ||
325 | 325 | ||
326 | 326 | @Callable(i) | |
327 | 327 | func getUserAssetsREADONLY (userAddress) = { | |
328 | 328 | let userLpAmount = getUserLpAmount(userAddress) | |
329 | 329 | let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress) | |
330 | 330 | let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0) | |
331 | 331 | let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0) | |
332 | 332 | $Tuple2(nil, $Tuple5(userLpAmount, userAvailableAssetToWithdraw, getCurrentPrice(), userTotalStakedAmount, userTotalAssetWithdrawn)) | |
333 | 333 | } | |
334 | 334 | ||
335 | 335 | ||
336 | 336 | ||
337 | 337 | @Callable(i) | |
338 | 338 | func getTotalAssetsREADONLY () = $Tuple2(nil, $Tuple3(totalLpAmount, getTotalAssetAmountWithProfitOrMaxAvailable(), getCurrentPrice())) | |
339 | 339 | ||
340 | 340 | ||
341 | 341 | ||
342 | 342 | @Callable(i) | |
343 | 343 | func voteForTxId (txId) = { | |
344 | 344 | let callerAddressString = toBase58String(i.caller.bytes) | |
345 | 345 | let keyPrefix = keyAllowedTxIdVotePrefix(txId) | |
346 | 346 | let result = [StringEntry(keyAllowedTxId(), txId)] | |
347 | 347 | let allowedTxIdOption = getString(this, keyAllowedTxId()) | |
348 | 348 | let err = [if ((size(fromBase58String(txId)) == TXID_BYTES_LENGTH)) | |
349 | 349 | then true | |
350 | 350 | else throwErr((txId + " is not valid txId")), if (if ((allowedTxIdOption == unit)) | |
351 | 351 | then true | |
352 | 352 | else (value(allowedTxIdOption) != txId)) | |
353 | 353 | then true | |
354 | 354 | else throwErr((txId + " is already allowed"))] | |
355 | 355 | if ((err == err)) | |
356 | 356 | then voteINTERNAL(callerAddressString, keyPrefix, QUORUM, result) | |
357 | 357 | else throw("Strict value is not equal to itself.") | |
358 | 358 | } | |
359 | 359 | ||
360 | 360 | ||
361 | 361 | @Verifier(tx) | |
362 | 362 | func verify () = { | |
363 | 363 | let byAdmins = (tx.id == fromBase58String(valueOrElse(getString(this, keyAllowedTxId()), ""))) | |
364 | 364 | let byOwner = if ((size(getAdminsList()) >= QUORUM)) | |
365 | 365 | then false | |
366 | 366 | else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
367 | 367 | if (byAdmins) | |
368 | 368 | then true | |
369 | 369 | else byOwner | |
370 | 370 | } | |
371 | 371 |
github/deemru/w8io/169f3d6 41.82 ms ◑