tx · BHEjHgmBh55akQ9VE6ibfAYhfiSwqmW8uNYMb2gh8n63

3Mvsbd5G4Xoyy4ib7gLCVSix21CyMr4K7jb:  -0.01500000 Waves

2023.07.27 12:32 [2684077] smart account 3Mvsbd5G4Xoyy4ib7gLCVSix21CyMr4K7jb > SELF 0.00000000 Waves

{ "type": 13, "id": "BHEjHgmBh55akQ9VE6ibfAYhfiSwqmW8uNYMb2gh8n63", "fee": 1500000, "feeAssetId": null, "timestamp": 1690450378670, "version": 2, "chainId": 84, "sender": "3Mvsbd5G4Xoyy4ib7gLCVSix21CyMr4K7jb", "senderPublicKey": "8fnW16MobFGpeokNqZLUEqPaJUXn5zaSGf4ch9A3Ctk7", "proofs": [ "241ctTGE99zkczDrKeRS6fd8RJ9kbYhUF9NmuvceUFj6pK7F9LSJA5cSnfcXHNk2zKwvHHyYgNNEt3yLGCNv8Rke" ], "script": "base64:BgIfCAISAwoBARIAEgMKAQgSAwoBARIDCgEIEgASAwoBCDAADGNvbnRyYWN0RmlsZQIRbDJtcF9zdGFraW5nLnJpZGUAA1NFUAICX18ABnNjYWxlOACAwtcvAAdzY2FsZTE4AICAkLu61q3wDQANc2NhbGUxOEJpZ0ludAkAtgIBBQdzY2FsZTE4ABJBRERSRVNTX0JZVEVTX1NJWkUAGgANQkxPQ0tTX0lOX0RBWQCgCwEIdGhyb3dFcnIBA21zZwkAAgEJAKwCAgkArAICBQxjb250cmFjdEZpbGUCAjogBQNtc2cACmtleUFzc2V0SWQJALkJAgkAzAgCAgIlcwkAzAgCAgdhc3NldElkBQNuaWwFA1NFUAATa2V5RW1pc3Npb25QZXJCbG9jawkAuQkCCQDMCAICAiVzCQDMCAICEGVtaXNzaW9uUGVyQmxvY2sFA25pbAUDU0VQABlrZXlFbWlzc2lvblBlcmlvZEluQmxvY2tzCQC5CQIJAMwIAgICJXMJAMwIAgIWZW1pc3Npb25QZXJpb2RJbkJsb2NrcwUDbmlsBQNTRVAADWtleVN0YXJ0QmxvY2sJALkJAgkA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JZVEVTX0xFTkdUSAYJAQh0aHJvd0VycgEJAKwCAgUEdHhJZAISIGlzIG5vdCB2YWxpZCB0eElkCQDMCAIDAwkAAAIFEWFsbG93ZWRUeElkT3B0aW9uBQR1bml0BgkBAiE9AgkBBXZhbHVlAQURYWxsb3dlZFR4SWRPcHRpb24FBHR4SWQGCQEIdGhyb3dFcnIBCQCsAgIFBHR4SWQCEyBpcyBhbHJlYWR5IGFsbG93ZWQFA25pbAMJAAACBQNlcnIFA2VycgkBDHZvdGVJTlRFUk5BTAQFE2NhbGxlckFkZHJlc3NTdHJpbmcFCWtleVByZWZpeAUGUVVPUlVNBQZyZXN1bHQJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAnR4AQZ2ZXJpZnkABAhieUFkbWlucwkAAAIIBQJ0eAJpZAkA2QQBCQELdmFsdWVPckVsc2UCCQCdCAIFBHRoaXMJAQ5rZXlBbGxvd2VkVHhJZAACAAQHYnlPd25lcgMJAGcCCQCQAwEJAQ1nZXRBZG1pbnNMaXN0AAUGUVVPUlVNBwkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleQMFCGJ5QWRtaW5zBgUHYnlPd25lckhMyrM=", "height": 2684077, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Ha51a6tmTwi8QBQAPQiLmMvVdmnNyQRYii4b7W4iV2Gp Next: none Diff:
OldNewDifferences
66 let SEP = "__"
77
88 let scale8 = 100000000
9+
10+let scale18 = 1000000000000000000
11+
12+let scale18BigInt = toBigInt(scale18)
913
1014 let ADDRESS_BYTES_SIZE = 26
1115
8791
8892
8993 func genVotesKeysHelper (a,adminAddress) = {
90- let $t026392663 = a
91- let result = $t026392663._1
92- let prefix = $t026392663._2
94+ let $t027182742 = a
95+ let result = $t027182742._1
96+ let prefix = $t027182742._2
9397 $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix)
9498 }
9599
96100
97101 func genVotesKeys (keyPrefix) = {
98102 let adminList = keyAdminAddressList()
99- let $t028102894 = {
103+ let $t028892973 = {
100104 let $l = getAdminsList()
101105 let $s = size($l)
102106 let $acc0 = $Tuple2(nil, keyPrefix)
110114
111115 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
112116 }
113- let result = $t028102894._1
114- let prefix = $t028102894._2
117+ let result = $t028892973._1
118+ let prefix = $t028892973._2
115119 result
116120 }
117121
203207
204208
205209 func getCurrentPrice () = if ((totalLpAmount != 0))
206- then fraction(getTotalAssetAmountWithProfitOrMaxAvailable(), scale8, totalLpAmount)
207- else (1 * scale8)
210+ then fraction(toBigInt(getTotalAssetAmountWithProfitOrMaxAvailable()), scale18BigInt, toBigInt(totalLpAmount))
211+ else scale18BigInt
208212
209213
210214 func getUserLpAmount (userAddress) = valueOrElse(getInteger(this, keyUserLpAmount(userAddress)), 0)
212216
213217 func getUserAvailableAssetsToWithdraw (userAddress) = {
214218 let userLpAmount = getUserLpAmount(userAddress)
215- let userAvailableAssetToWithdraw = fraction(userLpAmount, getCurrentPrice(), scale8)
219+ let userAvailableAssetToWithdraw = toInt(fraction(toBigInt(userLpAmount), getCurrentPrice(), scale18BigInt))
216220 if ((0 > userAvailableAssetToWithdraw))
217221 then 0
218222 else userAvailableAssetToWithdraw
230234 if ((checks == checks))
231235 then {
232236 let paymentAmount = i.payments[0].amount
233- let paymentLpAmount = fraction(paymentAmount, scale8, getCurrentPrice())
237+ let paymentLpAmount = toInt(fraction(toBigInt(paymentAmount), scale18BigInt, getCurrentPrice()))
234238 let userLpAmount = getUserLpAmount(userAddress)
235239 let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0)
236240 let newTotalLpAmount = (totalLpAmount + paymentLpAmount)
257261 if ((check == check))
258262 then {
259263 let newUserLpAmount = (userLpAmount - lpAssetWithdrawAmount)
260- let withdrawAssetAmount = fraction(lpAssetWithdrawAmount, getCurrentPrice(), scale8)
264+ let withdrawAssetAmount = toInt(fraction(toBigInt(lpAssetWithdrawAmount), getCurrentPrice(), scale18BigInt))
261265 let newTotalLpAmount = (totalLpAmount - lpAssetWithdrawAmount)
262- let newTotalAssetAmount = fraction(newTotalLpAmount, getCurrentPrice(), scale8)
266+ let newTotalAssetAmount = toInt(fraction(toBigInt(newTotalLpAmount), getCurrentPrice(), scale18BigInt))
263267 let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0)
264268 let newUserTotalAssetWithdrawn = (userTotalAssetWithdrawn + withdrawAssetAmount)
265269 [IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)]
301305 func withdraw (withdrawAssetAmount) = {
302306 let userAddress = toString(i.caller)
303307 let userLpAmount = getUserLpAmount(userAddress)
304- let lpAmountToWithdraw = fraction(withdrawAssetAmount, scale8, getCurrentPrice())
308+ let lpAmountToWithdraw = toInt(fraction(toBigInt(withdrawAssetAmount), scale18BigInt, getCurrentPrice()))
305309 let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress)
306- let minWithdrawAssetAmount = fraction(getCurrentPrice(), 1, scale8, CEILING)
310+ let minWithdrawAssetAmount = toInt(fraction(getCurrentPrice(), toBigInt(1), scale18BigInt, CEILING))
307311 let check = [if ((withdrawAssetAmount > 0))
308312 then true
309313 else throwErr("withdraw amount should be more than 0"), if ((userAvailableAssetToWithdraw >= withdrawAssetAmount))
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let contractFile = "l2mp_staking.ride"
55
66 let SEP = "__"
77
88 let scale8 = 100000000
9+
10+let scale18 = 1000000000000000000
11+
12+let scale18BigInt = toBigInt(scale18)
913
1014 let ADDRESS_BYTES_SIZE = 26
1115
1216 let BLOCKS_IN_DAY = 1440
1317
1418 func throwErr (msg) = throw(((contractFile + ": ") + msg))
1519
1620
1721 let keyAssetId = makeString(["%s", "assetId"], SEP)
1822
1923 let keyEmissionPerBlock = makeString(["%s", "emissionPerBlock"], SEP)
2024
2125 let keyEmissionPeriodInBlocks = makeString(["%s", "emissionPeriodInBlocks"], SEP)
2226
2327 let keyStartBlock = makeString(["%s", "startBlock"], SEP)
2428
2529 let keyTotalLpAmount = makeString(["%s", "totalLpAmount"], SEP)
2630
2731 let keyTotalAssetAmount = makeString(["%s", "totalAssetAmount"], SEP)
2832
2933 func keyUserLpAmount (userAddress) = makeString(["%s%s", "userLpAmount", userAddress], SEP)
3034
3135
3236 func keyUserTotalAssetWithdrawn (userAddress) = makeString(["%s%s", "totalAssetWithdrawn", userAddress], SEP)
3337
3438
3539 func keyUserTotalAssetStaked (userAddress) = makeString(["%s%s", "totalAssetStaked", userAddress], SEP)
3640
3741
3842 let totalLpAmount = valueOrElse(getInteger(this, keyTotalLpAmount), 0)
3943
4044 let totalAssetAmount = valueOrElse(getInteger(this, keyTotalAssetAmount), 0)
4145
4246 let assetIdString = valueOrElse(getString(this, keyAssetId), "WAVES")
4347
4448 let assetIdBytes = if ((assetIdString == "WAVES"))
4549 then unit
4650 else fromBase58String(assetIdString)
4751
4852 let emissionPeriodInBlocks = valueOrElse(getInteger(this, keyEmissionPeriodInBlocks), BLOCKS_IN_DAY)
4953
5054 let emissionPerPeriod = (valueOrElse(getInteger(this, keyEmissionPerBlock), 0) * emissionPeriodInBlocks)
5155
5256 let heightInPeriods = fraction(height, 1, emissionPeriodInBlocks)
5357
5458 let ADMIN_LIST_SIZE = 5
5559
5660 let QUORUM = 3
5761
5862 let TXID_BYTES_LENGTH = 32
5963
6064 func keyAllowedTxIdVotePrefix (txId) = makeString(["%s%s%s", "allowTxId", txId], SEP)
6165
6266
6367 func keyFullAdminVote (prefix,adminAddress) = makeString([prefix, adminAddress], SEP)
6468
6569
6670 func keyAdminAddressList () = makeString(["%s", "adminAddressList"], SEP)
6771
6872
6973 func keyAllowedTxId () = makeString(["%s", "txId"], SEP)
7074
7175
7276 func getAdminVote (prefix,admin) = {
7377 let voteKey = keyFullAdminVote(prefix, admin)
7478 valueOrElse(getInteger(voteKey), 0)
7579 }
7680
7781
7882 func getAdminsList () = match getString(this, keyAdminAddressList()) {
7983 case s: String =>
8084 split(s, SEP)
8185 case _ =>
8286 nil
8387 }
8488
8589
8690 func isInAdminList (address) = containsElement(getAdminsList(), address)
8791
8892
8993 func genVotesKeysHelper (a,adminAddress) = {
90- let $t026392663 = a
91- let result = $t026392663._1
92- let prefix = $t026392663._2
94+ let $t027182742 = a
95+ let result = $t027182742._1
96+ let prefix = $t027182742._2
9397 $Tuple2((result :+ keyFullAdminVote(prefix, adminAddress)), prefix)
9498 }
9599
96100
97101 func genVotesKeys (keyPrefix) = {
98102 let adminList = keyAdminAddressList()
99- let $t028102894 = {
103+ let $t028892973 = {
100104 let $l = getAdminsList()
101105 let $s = size($l)
102106 let $acc0 = $Tuple2(nil, keyPrefix)
103107 func $f0_1 ($a,$i) = if (($i >= $s))
104108 then $a
105109 else genVotesKeysHelper($a, $l[$i])
106110
107111 func $f0_2 ($a,$i) = if (($i >= $s))
108112 then $a
109113 else throw("List size exceeds 5")
110114
111115 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
112116 }
113- let result = $t028102894._1
114- let prefix = $t028102894._2
117+ let result = $t028892973._1
118+ let prefix = $t028892973._2
115119 result
116120 }
117121
118122
119123 func countVotesHelper (result,voteKey) = (result + valueOrElse(getInteger(voteKey), 0))
120124
121125
122126 func countVotes (prefix) = {
123127 let votes = genVotesKeys(prefix)
124128 let $l = votes
125129 let $s = size($l)
126130 let $acc0 = 0
127131 func $f0_1 ($a,$i) = if (($i >= $s))
128132 then $a
129133 else countVotesHelper($a, $l[$i])
130134
131135 func $f0_2 ($a,$i) = if (($i >= $s))
132136 then $a
133137 else throw("List size exceeds 5")
134138
135139 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
136140 }
137141
138142
139143 func clearVotesHelper (result,key) = (result :+ DeleteEntry(key))
140144
141145
142146 func getClearVoteEntries (prefix) = {
143147 let votes = genVotesKeys(prefix)
144148 let $l = votes
145149 let $s = size($l)
146150 let $acc0 = nil
147151 func $f0_1 ($a,$i) = if (($i >= $s))
148152 then $a
149153 else clearVotesHelper($a, $l[$i])
150154
151155 func $f0_2 ($a,$i) = if (($i >= $s))
152156 then $a
153157 else throw("List size exceeds 5")
154158
155159 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5)
156160 }
157161
158162
159163 func voteINTERNAL (callerAddressString,keyPrefix,minVotes,voteResult) = {
160164 let voteKey = keyFullAdminVote(keyPrefix, callerAddressString)
161165 let adminCurrentVote = getAdminVote(keyPrefix, callerAddressString)
162166 let err = if (!(isInAdminList(callerAddressString)))
163167 then throwErr((("Address: " + callerAddressString) + " not in Admin list"))
164168 else if ((adminCurrentVote == 1))
165169 then throwErr((voteKey + " you already voted"))
166170 else unit
167171 if ((err == err))
168172 then {
169173 let votes = countVotes(keyPrefix)
170174 if (((votes + 1) >= minVotes))
171175 then {
172176 let clearVoteEntries = getClearVoteEntries(keyPrefix)
173177 (clearVoteEntries ++ voteResult)
174178 }
175179 else [IntegerEntry(voteKey, 1)]
176180 }
177181 else throw("Strict value is not equal to itself.")
178182 }
179183
180184
181185 func calcTotalProfit () = {
182186 let startBlock = valueOrElse(getInteger(this, keyStartBlock), 0)
183187 let startPeriod = fraction(startBlock, 1, emissionPeriodInBlocks)
184188 let elapsedPeriods = (heightInPeriods - startPeriod)
185189 max([0, (emissionPerPeriod * elapsedPeriods)])
186190 }
187191
188192
189193 func getTotalAssetAmountWithProfitOrMaxAvailable () = {
190194 let totalAssetAmountWithProfit = (totalAssetAmount + calcTotalProfit())
191195 let totalAmount = match assetIdBytes {
192196 case u: Unit =>
193197 min([totalAssetAmountWithProfit, wavesBalance(this).available])
194198 case b: ByteVector =>
195199 min([totalAssetAmountWithProfit, assetBalance(this, b)])
196200 case _ =>
197201 throw("Match error")
198202 }
199203 if ((totalLpAmount == 0))
200204 then 0
201205 else totalAmount
202206 }
203207
204208
205209 func getCurrentPrice () = if ((totalLpAmount != 0))
206- then fraction(getTotalAssetAmountWithProfitOrMaxAvailable(), scale8, totalLpAmount)
207- else (1 * scale8)
210+ then fraction(toBigInt(getTotalAssetAmountWithProfitOrMaxAvailable()), scale18BigInt, toBigInt(totalLpAmount))
211+ else scale18BigInt
208212
209213
210214 func getUserLpAmount (userAddress) = valueOrElse(getInteger(this, keyUserLpAmount(userAddress)), 0)
211215
212216
213217 func getUserAvailableAssetsToWithdraw (userAddress) = {
214218 let userLpAmount = getUserLpAmount(userAddress)
215- let userAvailableAssetToWithdraw = fraction(userLpAmount, getCurrentPrice(), scale8)
219+ let userAvailableAssetToWithdraw = toInt(fraction(toBigInt(userLpAmount), getCurrentPrice(), scale18BigInt))
216220 if ((0 > userAvailableAssetToWithdraw))
217221 then 0
218222 else userAvailableAssetToWithdraw
219223 }
220224
221225
222226 func getStakeActions (i,userAddress) = {
223227 let checks = [if ((size(i.payments) == 1))
224228 then true
225229 else throwErr("should include 1 payment"), if ((i.payments[0].assetId == assetIdBytes))
226230 then true
227231 else throwErr(("payment should be in " + assetIdString)), if ((i.payments[0].amount > 0))
228232 then true
229233 else "payment amount should be greater than 0"]
230234 if ((checks == checks))
231235 then {
232236 let paymentAmount = i.payments[0].amount
233- let paymentLpAmount = fraction(paymentAmount, scale8, getCurrentPrice())
237+ let paymentLpAmount = toInt(fraction(toBigInt(paymentAmount), scale18BigInt, getCurrentPrice()))
234238 let userLpAmount = getUserLpAmount(userAddress)
235239 let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0)
236240 let newTotalLpAmount = (totalLpAmount + paymentLpAmount)
237241 let newTotalAssetAmount = (totalAssetAmount + paymentAmount)
238242 let newUserLpAmount = (userLpAmount + paymentLpAmount)
239243 let newUserTotalStakedAmount = (userTotalStakedAmount + paymentAmount)
240244 let updateStartHeightAction = if ((totalLpAmount == 0))
241245 then [IntegerEntry(keyStartBlock, height)]
242246 else nil
243247 ([IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetStaked(userAddress), newUserTotalStakedAmount)] ++ updateStartHeightAction)
244248 }
245249 else throw("Strict value is not equal to itself.")
246250 }
247251
248252
249253 func getWithdrawActions (i,lpAssetWithdrawAmount) = {
250254 let userAddress = toString(i.caller)
251255 let userLpAmount = getUserLpAmount(userAddress)
252256 let check = [if ((lpAssetWithdrawAmount > 0))
253257 then true
254258 else throwErr("LP amount should be more than 0"), if ((userLpAmount >= lpAssetWithdrawAmount))
255259 then true
256260 else throwErr((("cannot withdraw more than available LP (" + toString(userLpAmount)) + ")"))]
257261 if ((check == check))
258262 then {
259263 let newUserLpAmount = (userLpAmount - lpAssetWithdrawAmount)
260- let withdrawAssetAmount = fraction(lpAssetWithdrawAmount, getCurrentPrice(), scale8)
264+ let withdrawAssetAmount = toInt(fraction(toBigInt(lpAssetWithdrawAmount), getCurrentPrice(), scale18BigInt))
261265 let newTotalLpAmount = (totalLpAmount - lpAssetWithdrawAmount)
262- let newTotalAssetAmount = fraction(newTotalLpAmount, getCurrentPrice(), scale8)
266+ let newTotalAssetAmount = toInt(fraction(toBigInt(newTotalLpAmount), getCurrentPrice(), scale18BigInt))
263267 let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0)
264268 let newUserTotalAssetWithdrawn = (userTotalAssetWithdrawn + withdrawAssetAmount)
265269 [IntegerEntry(keyTotalLpAmount, newTotalLpAmount), IntegerEntry(keyTotalAssetAmount, newTotalAssetAmount), IntegerEntry(keyUserLpAmount(userAddress), newUserLpAmount), IntegerEntry(keyUserTotalAssetWithdrawn(userAddress), newUserTotalAssetWithdrawn), IntegerEntry(keyStartBlock, height), ScriptTransfer(i.caller, withdrawAssetAmount, assetIdBytes)]
266270 }
267271 else throw("Strict value is not equal to itself.")
268272 }
269273
270274
271275 @Callable(i)
272276 func setEmissionPerBlock (emissionPerBlock) = {
273277 let check = [if ((i.caller == this))
274278 then true
275279 else throwErr("permission denied")]
276280 if ((check == check))
277281 then [IntegerEntry(keyTotalAssetAmount, getTotalAssetAmountWithProfitOrMaxAvailable()), IntegerEntry(keyStartBlock, height), IntegerEntry(keyEmissionPerBlock, max([0, emissionPerBlock]))]
278282 else throw("Strict value is not equal to itself.")
279283 }
280284
281285
282286
283287 @Callable(i)
284288 func stake () = getStakeActions(i, toString(i.caller))
285289
286290
287291
288292 @Callable(i)
289293 func stakeFor (userAddress) = {
290294 let check = [if ((size(fromBase58String(userAddress)) == ADDRESS_BYTES_SIZE))
291295 then true
292296 else throwErr("address is not valid")]
293297 if ((check == check))
294298 then getStakeActions(i, userAddress)
295299 else throw("Strict value is not equal to itself.")
296300 }
297301
298302
299303
300304 @Callable(i)
301305 func withdraw (withdrawAssetAmount) = {
302306 let userAddress = toString(i.caller)
303307 let userLpAmount = getUserLpAmount(userAddress)
304- let lpAmountToWithdraw = fraction(withdrawAssetAmount, scale8, getCurrentPrice())
308+ let lpAmountToWithdraw = toInt(fraction(toBigInt(withdrawAssetAmount), scale18BigInt, getCurrentPrice()))
305309 let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress)
306- let minWithdrawAssetAmount = fraction(getCurrentPrice(), 1, scale8, CEILING)
310+ let minWithdrawAssetAmount = toInt(fraction(getCurrentPrice(), toBigInt(1), scale18BigInt, CEILING))
307311 let check = [if ((withdrawAssetAmount > 0))
308312 then true
309313 else throwErr("withdraw amount should be more than 0"), if ((userAvailableAssetToWithdraw >= withdrawAssetAmount))
310314 then true
311315 else throwErr((("cannot withdraw more than available (" + toString(userAvailableAssetToWithdraw)) + ")")), if ((withdrawAssetAmount >= minWithdrawAssetAmount))
312316 then true
313317 else throwErr((("withdraw amount is too small. Min: (" + toString(minWithdrawAssetAmount)) + ")"))]
314318 if ((check == check))
315319 then getWithdrawActions(i, lpAmountToWithdraw)
316320 else throw("Strict value is not equal to itself.")
317321 }
318322
319323
320324
321325 @Callable(i)
322326 func getUserAssetsREADONLY (userAddress) = {
323327 let userLpAmount = getUserLpAmount(userAddress)
324328 let userAvailableAssetToWithdraw = getUserAvailableAssetsToWithdraw(userAddress)
325329 let userTotalStakedAmount = valueOrElse(getInteger(this, keyUserTotalAssetStaked(userAddress)), 0)
326330 let userTotalAssetWithdrawn = valueOrElse(getInteger(this, keyUserTotalAssetWithdrawn(userAddress)), 0)
327331 $Tuple2(nil, $Tuple5(userLpAmount, userAvailableAssetToWithdraw, getCurrentPrice(), userTotalStakedAmount, userTotalAssetWithdrawn))
328332 }
329333
330334
331335
332336 @Callable(i)
333337 func getTotalAssetsREADONLY () = $Tuple2(nil, $Tuple3(totalLpAmount, getTotalAssetAmountWithProfitOrMaxAvailable(), getCurrentPrice()))
334338
335339
336340
337341 @Callable(i)
338342 func voteForTxId (txId) = {
339343 let callerAddressString = toBase58String(i.caller.bytes)
340344 let keyPrefix = keyAllowedTxIdVotePrefix(txId)
341345 let result = [StringEntry(keyAllowedTxId(), txId)]
342346 let allowedTxIdOption = getString(this, keyAllowedTxId())
343347 let err = [if ((size(fromBase58String(txId)) == TXID_BYTES_LENGTH))
344348 then true
345349 else throwErr((txId + " is not valid txId")), if (if ((allowedTxIdOption == unit))
346350 then true
347351 else (value(allowedTxIdOption) != txId))
348352 then true
349353 else throwErr((txId + " is already allowed"))]
350354 if ((err == err))
351355 then voteINTERNAL(callerAddressString, keyPrefix, QUORUM, result)
352356 else throw("Strict value is not equal to itself.")
353357 }
354358
355359
356360 @Verifier(tx)
357361 func verify () = {
358362 let byAdmins = (tx.id == fromBase58String(valueOrElse(getString(this, keyAllowedTxId()), "")))
359363 let byOwner = if ((size(getAdminsList()) >= QUORUM))
360364 then false
361365 else sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
362366 if (byAdmins)
363367 then true
364368 else byOwner
365369 }
366370

github/deemru/w8io/026f985 
45.37 ms