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