tx · 8FurQAffAdR21eerYn7eGTv7kMunvoJhooZecsmtyTs4 3MsC1Cit1aGB6qPW1hvkyGP2Gx79K1mtUAk: -0.01700000 Waves 2023.01.17 13:50 [2408829] smart account 3MsC1Cit1aGB6qPW1hvkyGP2Gx79K1mtUAk > SELF 0.00000000 Waves
{ "type": 13, "id": "8FurQAffAdR21eerYn7eGTv7kMunvoJhooZecsmtyTs4", "fee": 1700000, "feeAssetId": null, "timestamp": 1673952632650, "version": 1, "sender": "3MsC1Cit1aGB6qPW1hvkyGP2Gx79K1mtUAk", "senderPublicKey": "2rdeGwVMkuRfRdUgrYaekNmjnegHokhyDx1z6TJq525F", "proofs": [ "54YbYnwG1x1oVkJbBXoYAqZdfppxR6QCzPsfiusCiUw5cadj5PsD5crbJyK9Hi5NvPujEv1avJsuLbjtiVD1oMPC" ], "script": "base64:AAIEAAAAAAAAB9wIAhIHCgUICAgBCBIDCgEBEgASABIFCgMICAgSAwoBCBIDCgEIIgNTRVAiD2dldFN0cmluZ09yRmFpbCIDa2V5IhBnZXRCb29sZWFuT3JGYWlsIg5mYWlsRXhlY3V0ZUdldCIDbXNnIgxiYXNlQXNzZXRTdHIiDnVzZXJBZGRyZXNzU3RyIgpnZXRUeElkU3RyIgtrZXlBc3NldENmZyIWa2V5TmV4dEludGVybmFsQXNzZXRJZCIMa2V5UHJpY2VMYXN0IhVpbnRlcm5hbEJhc2V0QXNzZXRTdHIiEmtleVRvcFVwTGFzdEhlaWdodCIGc2VuZGVyIg9rZXlQcmljZUhpc3RvcnkiAWgiCXRpbWVzdGFtcCIOa2V5VG90YWxMb2NrZWQiFGtleVRvdGFsTG9ja2VkQnlVc2VyIhRpbnRlcm5hbEJhc2VBc3NldFN0ciIfa2V5TWFwcGluZ3NJbnRlcm5hbDJiYXNlQXNzZXRJZCIRaW50ZXJuYWxCYXNlQXNzZXQiH2tleU1hcHBpbmdzQmFzZUFzc2V0MmludGVybmFsSWQiHGtleU1hcHBpbmdzU2hhcmUyYmFzZU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nJlbnRTeXNQYXJhbXNSRVNUBQAAAANuaWwFAAAAAWEJAAACAAAAAQUAAAACYmsAAAABAAAAAmJsAQAAAAJibQAAAAAJAAH0AAAAAwgFAAAAAmJsAAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACYmwAAAAGcHJvb2ZzAAAAAAAAAAAACQACWQAAAAECAAAALDJDYmQ4b3pHN0ExUnlSTkMzbk5uWmdIdTdSdTRLM0pDZnB5UGtocXI5enhx7qRurw==", "chainId": 84, "height": 2408829, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 28DAJQDGWMLhKmHRTCR72v11NDteh36ZBGJh2syKuDFX Next: none Diff:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | - | ||
6 | - | func wrapErr (msg) = makeString(["lp_staking.ride:", msg], " ") | |
7 | - | ||
8 | - | ||
9 | - | func throwErr (msg) = throw(wrapErr(msg)) | |
10 | - | ||
11 | 5 | ||
12 | 6 | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), ("No data for this.key=" + key)) | |
13 | 7 | ||
54 | 48 | func keyShutdownPutOperation (internalBaseAssetStr) = ("%s%s%d__shutdown__put__" + internalBaseAssetStr) | |
55 | 49 | ||
56 | 50 | ||
57 | - | func keyShutdown (internalBaseAssetStr) = ("%s%d__shutdown__" + internalBaseAssetStr) | |
58 | - | ||
59 | - | ||
60 | 51 | func keyShutdownManager (internalBaseAssetStr) = ("%s%s%d__shutdown__manager__" + internalBaseAssetStr) | |
61 | 52 | ||
62 | 53 | ||
69 | 60 | let IdxCfgDecimalsMultPrice = 4 | |
70 | 61 | ||
71 | 62 | let IdxCfgGetDelayBlocks = 5 | |
72 | - | ||
73 | - | func keyManagerPublicKey () = "%s__managerPublicKey" | |
74 | - | ||
75 | - | ||
76 | - | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
77 | - | ||
78 | - | ||
79 | - | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
80 | - | case s: String => | |
81 | - | fromBase58String(s) | |
82 | - | case _: Unit => | |
83 | - | unit | |
84 | - | case _ => | |
85 | - | throw("Match error") | |
86 | - | } | |
87 | - | ||
88 | - | ||
89 | - | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
90 | - | case s: String => | |
91 | - | fromBase58String(s) | |
92 | - | case _: Unit => | |
93 | - | unit | |
94 | - | case _ => | |
95 | - | throw("Match error") | |
96 | - | } | |
97 | - | ||
98 | - | ||
99 | - | let permissionDeniedError = throw("Permission denied") | |
100 | - | ||
101 | - | func mustThis (i) = if ((i.caller == this)) | |
102 | - | then true | |
103 | - | else permissionDeniedError | |
104 | - | ||
105 | - | ||
106 | - | func mustManager (i) = match managerPublicKeyOrUnit() { | |
107 | - | case pk: ByteVector => | |
108 | - | if ((i.callerPublicKey == pk)) | |
109 | - | then true | |
110 | - | else permissionDeniedError | |
111 | - | case _: Unit => | |
112 | - | mustThis(i) | |
113 | - | case _ => | |
114 | - | throw("Match error") | |
115 | - | } | |
116 | - | ||
117 | - | ||
118 | - | let lpStakingPoolsContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(makeString(["%s", "lpStakingPoolsContract"], SEP)), wrapErr("lp_staking_pools contract address is undefined"))), wrapErr("invalid lp_staking_pools contract address")) | |
119 | 63 | ||
120 | 64 | func dataAssetCfg (shareAssetStr,internalBaseAssetStr,decimalsMultBothAssets,decimalsMultPrice,getDelayInBlocks) = makeString(["%s%d%d%d%d", shareAssetStr, internalBaseAssetStr, toString(decimalsMultBothAssets), toString(decimalsMultPrice), toString(getDelayInBlocks)], SEP) | |
121 | 65 | ||
216 | 160 | func adminRegisterAsset (baseAssetStr,shareAssetName,shareAssetDescr,getDelayinBlocks,shutdownManagerAddress) = { | |
217 | 161 | let baseAssetId = fromBase58String(baseAssetStr) | |
218 | 162 | let decimals = value(assetInfo(baseAssetId)).decimals | |
219 | - | | |
220 | - | | |
221 | - | | |
163 | + | if ((i.caller != this)) | |
164 | + | then throw("permissions denied") | |
165 | + | else if ((toString(addressFromStringValue(shutdownManagerAddress)) != shutdownManagerAddress)) | |
222 | 166 | then throw("invalid shutdownManagerAddress") | |
223 | 167 | else if ((0 > getDelayinBlocks)) | |
224 | 168 | then throw(("invalid getDelayinBlocks=" + toString(getDelayinBlocks))) | |
233 | 177 | let internalBaseAssetStr = toString(internalBaseAssettId) | |
234 | 178 | [StringEntry(keyAssetCfg(baseAssetStr), dataAssetCfg(shareAssetStr, internalBaseAssetStr, decimalsMultBothAssets, decimalsMultPrice, getDelayinBlocks)), StringEntry(keyMappingsInternal2baseAssetId(internalBaseAssettId), baseAssetStr), StringEntry(keyMappingsBaseAsset2internalId(baseAssetStr), internalBaseAssetStr), StringEntry(keyMappingsShare2baseAssetId(shareAssetStr), baseAssetStr), StringEntry(keyMappingsBaseAsset2shareId(baseAssetStr), shareAssetStr), BooleanEntry(keyShutdownPutOperation(internalBaseAssetStr), false), StringEntry(keyShutdownManager(internalBaseAssetStr), shutdownManagerAddress), IntegerEntry(keyNextInternalAssetId(), (internalBaseAssettId + 1)), IntegerEntry(keyPriceLast(internalBaseAssetStr), startPrice), IntegerEntry(keyPriceHistory(internalBaseAssetStr, height, lastBlock.timestamp), startPrice), shareAssetIssueAction, Burn(shareAssetId, 1)] | |
235 | 179 | } | |
236 | - | else throw("Strict value is not equal to itself.") | |
237 | 180 | } | |
238 | 181 | ||
239 | 182 | ||
265 | 208 | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
266 | 209 | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
267 | 210 | let isPutBlocked = getBooleanOrFail(keyShutdownPutOperation(internalBaseAssetStr)) | |
268 | - | let shutdown = valueOrElse(getBoolean(keyShutdown(internalBaseAssetStr)), false) | |
269 | - | if (if (isPutBlocked) | |
270 | - | then true | |
271 | - | else shutdown) | |
211 | + | if (isPutBlocked) | |
272 | 212 | then throw("put operation is blocked") | |
273 | 213 | else { | |
274 | 214 | let price = calcPrice(internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
295 | 235 | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
296 | 236 | let getDelayBlocks = parseIntValue(cfgArray[IdxCfgGetDelayBlocks]) | |
297 | 237 | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
298 | - | let shutdown = valueOrElse(getBoolean(keyShutdown(internalBaseAssetStr)), false) | |
299 | - | if (shutdown) | |
300 | - | then throw("operation is blocked") | |
301 | - | else { | |
302 | - | let price = calcPrice(internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
303 | - | let baseAssetAmount = fraction(shareAssetAmount, price, decimalsMultPrice) | |
304 | - | let operationKey = keyOperation("G", internalBaseAssetStr, userAddressStr, toBase58String(i.transactionId)) | |
305 | - | let operationData = dataOperation("PENDING", shareAssetAmount, price, baseAssetAmount, height, lastBlock.timestamp, (height + getDelayBlocks), 0) | |
238 | + | let price = calcPrice(internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
239 | + | let baseAssetAmount = fraction(shareAssetAmount, price, decimalsMultPrice) | |
240 | + | let operationKey = keyOperation("G", internalBaseAssetStr, userAddressStr, toBase58String(i.transactionId)) | |
241 | + | let operationData = dataOperation("PENDING", shareAssetAmount, price, baseAssetAmount, height, lastBlock.timestamp, (height + getDelayBlocks), 0) | |
306 | 242 | [Burn(shareAssetId, shareAssetAmount), StringEntry(operationKey, operationData), incrementTotalLocked(keyTotalLocked(internalBaseAssetStr), shareAssetAmount, baseAssetAmount), incrementTotalLocked(keyTotalLockedByUser(internalBaseAssetStr, userAddressStr), shareAssetAmount, baseAssetAmount)] | |
307 | - | } | |
308 | 243 | } | |
309 | 244 | ||
310 | 245 | ||
316 | 251 | let shareAssetId = fromBase58String(assetCfgArray[IdxCfgShareAssetId]) | |
317 | 252 | let baseAssetId = fromBase58String(baseAssetStr) | |
318 | 253 | let internalBaseAssetStr = assetCfgArray[IdxCfgInternalBaseAsset] | |
319 | - | let shutdown = valueOrElse(getBoolean(keyShutdown(internalBaseAssetStr)), false) | |
320 | - | if (shutdown) | |
321 | - | then throw("operation is blocked") | |
322 | - | else { | |
323 | - | let operationKey = keyOperation("G", internalBaseAssetStr, userAddressStr, getTxIdStr) | |
324 | - | let operationArray = split(getStringOrFail(operationKey), SEP) | |
325 | - | let status = operationArray[IdxOperStatus] | |
326 | - | let endHeight = parseIntValue(operationArray[IdxOperEndHeight]) | |
327 | - | let inShareAmount = parseIntValue(operationArray[IdxOperInAmount]) | |
328 | - | let outBaseAmount = parseIntValue(operationArray[IdxOperOutAmount]) | |
329 | - | if ((status != "PENDING")) | |
330 | - | then failExecuteGet("Status is not PENDING", baseAssetStr, userAddressStr, getTxIdStr) | |
331 | - | else if ((endHeight > height)) | |
332 | - | then failExecuteGet(((("EndHeight[" + toString(endHeight)) + "] > ") + toString(height)), baseAssetStr, userAddressStr, getTxIdStr) | |
333 | - | else [ScriptTransfer(userAddress, outBaseAmount, baseAssetId), StringEntry(operationKey, dataOperationExecutionUpdate(operationArray, "FINISHED", lastBlock.timestamp)), decrementTotalLocked(keyTotalLocked(internalBaseAssetStr), inShareAmount, outBaseAmount), decrementTotalLocked(keyTotalLockedByUser(internalBaseAssetStr, userAddressStr), inShareAmount, outBaseAmount)] | |
334 | - | } | |
254 | + | let operationKey = keyOperation("G", internalBaseAssetStr, userAddressStr, getTxIdStr) | |
255 | + | let operationArray = split(getStringOrFail(operationKey), SEP) | |
256 | + | let status = operationArray[IdxOperStatus] | |
257 | + | let endHeight = parseIntValue(operationArray[IdxOperEndHeight]) | |
258 | + | let inShareAmount = parseIntValue(operationArray[IdxOperInAmount]) | |
259 | + | let outBaseAmount = parseIntValue(operationArray[IdxOperOutAmount]) | |
260 | + | if ((status != "PENDING")) | |
261 | + | then failExecuteGet("Status is not PENDING", baseAssetStr, userAddressStr, getTxIdStr) | |
262 | + | else if ((endHeight > height)) | |
263 | + | then failExecuteGet(((("EndHeight[" + toString(endHeight)) + "] > ") + toString(height)), baseAssetStr, userAddressStr, getTxIdStr) | |
264 | + | else [ScriptTransfer(userAddress, outBaseAmount, baseAssetId), StringEntry(operationKey, dataOperationExecutionUpdate(operationArray, "FINISHED", lastBlock.timestamp)), decrementTotalLocked(keyTotalLocked(internalBaseAssetStr), inShareAmount, outBaseAmount), decrementTotalLocked(keyTotalLockedByUser(internalBaseAssetStr, userAddressStr), inShareAmount, outBaseAmount)] | |
335 | 265 | } | |
336 | 266 | ||
337 | 267 | ||
348 | 278 | let internalBaseAssetStr = assetCfgArray[IdxCfgInternalBaseAsset] | |
349 | 279 | let topUpLastHeightKEY = keyTopUpLastHeight(internalBaseAssetStr, toString(i.caller)) | |
350 | 280 | let topUpLastHeight = valueOrElse(getInteger(this, topUpLastHeightKEY), 0) | |
351 | - | let shutdown = valueOrElse(getBoolean(keyShutdown(internalBaseAssetStr)), false) | |
352 | - | if (shutdown) | |
353 | - | then throw("operation is blocked") | |
354 | - | else if ((baseAssetStr != pmtAssetStr)) | |
355 | - | then throw("attached payment's asset id is NOT matched passed baseAssetStr") | |
356 | - | else if ((size(i.payments) > 1)) | |
357 | - | then throw("only one payment can be attached") | |
358 | - | else if ((100 > (height - topUpLastHeight))) | |
359 | - | then throw("1 topUp per 100 blocks from the same address is allowed") | |
360 | - | else { | |
361 | - | let price = genericCalcPrice(internalBaseAssetStr, pmtAssetId, pmt.amount, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
281 | + | if ((baseAssetStr != pmtAssetStr)) | |
282 | + | then throw("attached payment's asset id is NOT matched passed baseAssetStr") | |
283 | + | else if ((size(i.payments) > 1)) | |
284 | + | then throw("only one payment can be attached") | |
285 | + | else if ((100 > (height - topUpLastHeight))) | |
286 | + | then throw("1 topUp per 100 blocks from the same address is allowed") | |
287 | + | else { | |
288 | + | let price = genericCalcPrice(internalBaseAssetStr, pmtAssetId, pmt.amount, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
362 | 289 | [IntegerEntry(keyPriceLast(internalBaseAssetStr), price), IntegerEntry(keyPriceHistory(internalBaseAssetStr, height, lastBlock.timestamp), price), IntegerEntry(topUpLastHeightKEY, height)] | |
363 | - | } | |
364 | - | } | |
365 | - | ||
366 | - | ||
367 | - | ||
368 | - | @Callable(i) | |
369 | - | func emit (assetId,amount) = { | |
370 | - | let checks = [if ((i.caller == lpStakingPoolsContract)) | |
371 | - | then true | |
372 | - | else throwErr("permission denied"), if ((amount > 0)) | |
373 | - | then true | |
374 | - | else throwErr("invalid amount to emit"), if ((getString(keyMappingsShare2baseAssetId(toBase58String(assetId))) != unit)) | |
375 | - | then true | |
376 | - | else throwErr("invalid assetId")] | |
377 | - | if ((checks == checks)) | |
378 | - | then { | |
379 | - | let isReissuable = true | |
380 | - | $Tuple2([Reissue(assetId, amount, isReissuable), ScriptTransfer(lpStakingPoolsContract, amount, assetId)], amount) | |
381 | - | } | |
382 | - | else throw("Strict value is not equal to itself.") | |
383 | - | } | |
384 | - | ||
385 | - | ||
386 | - | ||
387 | - | @Callable(i) | |
388 | - | func burn (assetId,amount) = { | |
389 | - | let checks = [if ((i.caller == lpStakingPoolsContract)) | |
390 | - | then true | |
391 | - | else throwErr("permission denied"), if ((amount > 0)) | |
392 | - | then true | |
393 | - | else throwErr("invalid amount to burn"), if ((getString(keyMappingsShare2baseAssetId(toBase58String(assetId))) != unit)) | |
394 | - | then true | |
395 | - | else throwErr("invalid assetId")] | |
396 | - | if ((checks == checks)) | |
397 | - | then $Tuple2([Burn(assetId, amount)], amount) | |
398 | - | else throw("Strict value is not equal to itself.") | |
290 | + | } | |
399 | 291 | } | |
400 | 292 | ||
401 | 293 | ||
414 | 306 | } | |
415 | 307 | ||
416 | 308 | ||
417 | - | ||
418 | - | @Callable(i) | |
419 | - | func setManager (pendingManagerPublicKey) = { | |
420 | - | let checkCaller = mustManager(i) | |
421 | - | if ((checkCaller == checkCaller)) | |
422 | - | then { | |
423 | - | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
424 | - | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
425 | - | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
426 | - | else throw("Strict value is not equal to itself.") | |
427 | - | } | |
428 | - | else throw("Strict value is not equal to itself.") | |
429 | - | } | |
430 | - | ||
431 | - | ||
432 | - | ||
433 | - | @Callable(i) | |
434 | - | func confirmManager () = { | |
435 | - | let pm = pendingManagerPublicKeyOrUnit() | |
436 | - | let hasPM = if (isDefined(pm)) | |
437 | - | then true | |
438 | - | else throwErr("no pending manager") | |
439 | - | if ((hasPM == hasPM)) | |
440 | - | then { | |
441 | - | let checkPM = if ((i.callerPublicKey == value(pm))) | |
442 | - | then true | |
443 | - | else throwErr("you are not pending manager") | |
444 | - | if ((checkPM == checkPM)) | |
445 | - | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
446 | - | else throw("Strict value is not equal to itself.") | |
447 | - | } | |
448 | - | else throw("Strict value is not equal to itself.") | |
449 | - | } | |
450 | - | ||
451 | - | ||
452 | 309 | @Verifier(tx) | |
453 | - | func verify () = { | |
454 | - | let targetPublicKey = match managerPublicKeyOrUnit() { | |
455 | - | case pk: ByteVector => | |
456 | - | pk | |
457 | - | case _: Unit => | |
458 | - | tx.senderPublicKey | |
459 | - | case _ => | |
460 | - | throw("Match error") | |
461 | - | } | |
462 | - | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
463 | - | } | |
310 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String("2Cbd8ozG7A1RyRNC3nNnZgHu7Ru4K3JCfpyPkhqr9zxq")) | |
464 | 311 |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | - | ||
6 | - | func wrapErr (msg) = makeString(["lp_staking.ride:", msg], " ") | |
7 | - | ||
8 | - | ||
9 | - | func throwErr (msg) = throw(wrapErr(msg)) | |
10 | - | ||
11 | 5 | ||
12 | 6 | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), ("No data for this.key=" + key)) | |
13 | 7 | ||
14 | 8 | ||
15 | 9 | func getBooleanOrFail (key) = valueOrErrorMessage(getBoolean(this, key), ("No data for this.key=" + key)) | |
16 | 10 | ||
17 | 11 | ||
18 | 12 | func failExecuteGet (msg,baseAssetStr,userAddressStr,getTxIdStr) = throw(((((((msg + ": baseAssetStr=") + baseAssetStr) + " userAddressStr=") + userAddressStr) + " getTxIdStr=") + getTxIdStr)) | |
19 | 13 | ||
20 | 14 | ||
21 | 15 | func keyAssetCfg (baseAssetStr) = ("%s%s%s__config__asset__" + baseAssetStr) | |
22 | 16 | ||
23 | 17 | ||
24 | 18 | func keyNextInternalAssetId () = "%s__nextInternalAssetId" | |
25 | 19 | ||
26 | 20 | ||
27 | 21 | func keyPriceLast (internalBasetAssetStr) = ("%s%s%d__price__last__" + internalBasetAssetStr) | |
28 | 22 | ||
29 | 23 | ||
30 | 24 | func keyTopUpLastHeight (internalBasetAssetStr,sender) = makeString(["%s%s%s%d%s__topup__last__height", internalBasetAssetStr, sender], SEP) | |
31 | 25 | ||
32 | 26 | ||
33 | 27 | func keyPriceHistory (internalBasetAssetStr,h,timestamp) = makeString(["%s%s%d%d%d__price__history", internalBasetAssetStr, toString(h), toString(timestamp)], SEP) | |
34 | 28 | ||
35 | 29 | ||
36 | 30 | func keyTotalLocked (internalBasetAssetStr) = ("%s%s%d__total__locked__" + internalBasetAssetStr) | |
37 | 31 | ||
38 | 32 | ||
39 | 33 | func keyTotalLockedByUser (internalBaseAssetStr,userAddressStr) = makeString(["%s%s%d%s__total__locked", internalBaseAssetStr, userAddressStr], SEP) | |
40 | 34 | ||
41 | 35 | ||
42 | 36 | func keyMappingsInternal2baseAssetId (internalBaseAsset) = ("%s%s%d__mappings__internal2baseAssetId__" + toString(internalBaseAsset)) | |
43 | 37 | ||
44 | 38 | ||
45 | 39 | func keyMappingsBaseAsset2internalId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2internalId__" + baseAssetStr) | |
46 | 40 | ||
47 | 41 | ||
48 | 42 | func keyMappingsShare2baseAssetId (shareAssetStr) = ("%s%s%s__mappings__share2baseAssetId__" + shareAssetStr) | |
49 | 43 | ||
50 | 44 | ||
51 | 45 | func keyMappingsBaseAsset2shareId (baseAssetStr) = ("%s%s%s__mappings__baseAsset2shareId__" + baseAssetStr) | |
52 | 46 | ||
53 | 47 | ||
54 | 48 | func keyShutdownPutOperation (internalBaseAssetStr) = ("%s%s%d__shutdown__put__" + internalBaseAssetStr) | |
55 | 49 | ||
56 | 50 | ||
57 | - | func keyShutdown (internalBaseAssetStr) = ("%s%d__shutdown__" + internalBaseAssetStr) | |
58 | - | ||
59 | - | ||
60 | 51 | func keyShutdownManager (internalBaseAssetStr) = ("%s%s%d__shutdown__manager__" + internalBaseAssetStr) | |
61 | 52 | ||
62 | 53 | ||
63 | 54 | let IdxCfgShareAssetId = 1 | |
64 | 55 | ||
65 | 56 | let IdxCfgInternalBaseAsset = 2 | |
66 | 57 | ||
67 | 58 | let IdxCfgDecimalsMultBothAssets = 3 | |
68 | 59 | ||
69 | 60 | let IdxCfgDecimalsMultPrice = 4 | |
70 | 61 | ||
71 | 62 | let IdxCfgGetDelayBlocks = 5 | |
72 | - | ||
73 | - | func keyManagerPublicKey () = "%s__managerPublicKey" | |
74 | - | ||
75 | - | ||
76 | - | func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey" | |
77 | - | ||
78 | - | ||
79 | - | func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) { | |
80 | - | case s: String => | |
81 | - | fromBase58String(s) | |
82 | - | case _: Unit => | |
83 | - | unit | |
84 | - | case _ => | |
85 | - | throw("Match error") | |
86 | - | } | |
87 | - | ||
88 | - | ||
89 | - | func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) { | |
90 | - | case s: String => | |
91 | - | fromBase58String(s) | |
92 | - | case _: Unit => | |
93 | - | unit | |
94 | - | case _ => | |
95 | - | throw("Match error") | |
96 | - | } | |
97 | - | ||
98 | - | ||
99 | - | let permissionDeniedError = throw("Permission denied") | |
100 | - | ||
101 | - | func mustThis (i) = if ((i.caller == this)) | |
102 | - | then true | |
103 | - | else permissionDeniedError | |
104 | - | ||
105 | - | ||
106 | - | func mustManager (i) = match managerPublicKeyOrUnit() { | |
107 | - | case pk: ByteVector => | |
108 | - | if ((i.callerPublicKey == pk)) | |
109 | - | then true | |
110 | - | else permissionDeniedError | |
111 | - | case _: Unit => | |
112 | - | mustThis(i) | |
113 | - | case _ => | |
114 | - | throw("Match error") | |
115 | - | } | |
116 | - | ||
117 | - | ||
118 | - | let lpStakingPoolsContract = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(makeString(["%s", "lpStakingPoolsContract"], SEP)), wrapErr("lp_staking_pools contract address is undefined"))), wrapErr("invalid lp_staking_pools contract address")) | |
119 | 63 | ||
120 | 64 | func dataAssetCfg (shareAssetStr,internalBaseAssetStr,decimalsMultBothAssets,decimalsMultPrice,getDelayInBlocks) = makeString(["%s%d%d%d%d", shareAssetStr, internalBaseAssetStr, toString(decimalsMultBothAssets), toString(decimalsMultPrice), toString(getDelayInBlocks)], SEP) | |
121 | 65 | ||
122 | 66 | ||
123 | 67 | let IdxTotalLockedShare = 1 | |
124 | 68 | ||
125 | 69 | let IdxTotalLockedBase = 2 | |
126 | 70 | ||
127 | 71 | func dataTotalLocked (shareAssetAmount,baseAssetAmount) = makeString(["%d%d", toString(shareAssetAmount), toString(baseAssetAmount)], SEP) | |
128 | 72 | ||
129 | 73 | ||
130 | 74 | func readTotalLocked (key) = { | |
131 | 75 | let totalLockedArray = split(valueOrElse(getString(this, key), dataTotalLocked(0, 0)), SEP) | |
132 | 76 | [-1, parseIntValue(totalLockedArray[IdxTotalLockedShare]), parseIntValue(totalLockedArray[IdxTotalLockedBase])] | |
133 | 77 | } | |
134 | 78 | ||
135 | 79 | ||
136 | 80 | func keyOperation (operationType,internalBaseAssetStr,userAddress,txId) = makeString(["%s%d%s%s", operationType, internalBaseAssetStr, userAddress, txId], SEP) | |
137 | 81 | ||
138 | 82 | ||
139 | 83 | let IdxOperStatus = 1 | |
140 | 84 | ||
141 | 85 | let IdxOperInAmount = 2 | |
142 | 86 | ||
143 | 87 | let IdxOperPrice = 3 | |
144 | 88 | ||
145 | 89 | let IdxOperOutAmount = 4 | |
146 | 90 | ||
147 | 91 | let IdxOperStartHeight = 5 | |
148 | 92 | ||
149 | 93 | let IdxOperStartTimestamp = 6 | |
150 | 94 | ||
151 | 95 | let IdxOperEndHeight = 7 | |
152 | 96 | ||
153 | 97 | let IdxOperEndTimestamp = 8 | |
154 | 98 | ||
155 | 99 | func privateDataOperationAllStrings (status,inAssetAmount,price,outAssetAmount,startHeight,startTimestamp,endHeight,endTimestamp) = makeString(["%s%d%d%d%d%d%d%d", status, inAssetAmount, price, outAssetAmount, startHeight, startTimestamp, endHeight, endTimestamp], SEP) | |
156 | 100 | ||
157 | 101 | ||
158 | 102 | func dataOperation (status,inAssetAmount,price,outAssetAmount,startHeight,startTimestamp,endHeight,endTimestamp) = privateDataOperationAllStrings(status, toString(inAssetAmount), toString(price), toString(outAssetAmount), toString(startHeight), toString(startTimestamp), toString(endHeight), toString(endTimestamp)) | |
159 | 103 | ||
160 | 104 | ||
161 | 105 | func dataOperationExecutionUpdate (currOperArray,newStatus,newEndTimestamp) = privateDataOperationAllStrings(newStatus, currOperArray[IdxOperInAmount], currOperArray[IdxOperPrice], currOperArray[IdxOperOutAmount], currOperArray[IdxOperStartHeight], currOperArray[IdxOperStartTimestamp], currOperArray[IdxOperEndHeight], toString(newEndTimestamp)) | |
162 | 106 | ||
163 | 107 | ||
164 | 108 | func readAssetCfgOrFail (baseAssetStr) = { | |
165 | 109 | let key = keyAssetCfg(baseAssetStr) | |
166 | 110 | split(getStringOrFail(key), SEP) | |
167 | 111 | } | |
168 | 112 | ||
169 | 113 | ||
170 | 114 | func incrementTotalLocked (key,shareAssetAmount,baseAssetAmount) = { | |
171 | 115 | let dataArray = readTotalLocked(key) | |
172 | 116 | StringEntry(key, dataTotalLocked((dataArray[IdxTotalLockedShare] + shareAssetAmount), (dataArray[IdxTotalLockedBase] + baseAssetAmount))) | |
173 | 117 | } | |
174 | 118 | ||
175 | 119 | ||
176 | 120 | func decrementTotalLocked (key,shareAssetAmount,baseAssetAmount) = { | |
177 | 121 | let dataArray = readTotalLocked(key) | |
178 | 122 | StringEntry(key, dataTotalLocked((dataArray[IdxTotalLockedShare] - shareAssetAmount), (dataArray[IdxTotalLockedBase] - baseAssetAmount))) | |
179 | 123 | } | |
180 | 124 | ||
181 | 125 | ||
182 | 126 | func genericCalcPrice (internalBaseAssetStr,baseAssetId,topUpBaseAmount,shareAssetId,decimalsMultBothAssets,decimalsMultPrice) = { | |
183 | 127 | let totalLockedArray = readTotalLocked(keyTotalLocked(internalBaseAssetStr)) | |
184 | 128 | let totalLockedBaseAmount = totalLockedArray[IdxTotalLockedBase] | |
185 | 129 | let baseAssetBalance = assetBalance(this, baseAssetId) | |
186 | 130 | let baseAssetBalanceConsideringLock = ((baseAssetBalance - totalLockedBaseAmount) + topUpBaseAmount) | |
187 | 131 | if ((0 > baseAssetBalanceConsideringLock)) | |
188 | 132 | then throw(((("baseAssetBalanceConsideringLock < 0: baseAssetBalance=" + toString(baseAssetBalance)) + " baseAssetBalanceConsideringLock=") + toString(baseAssetBalanceConsideringLock))) | |
189 | 133 | else { | |
190 | 134 | let shareEmission = value(assetInfo(shareAssetId)).quantity | |
191 | 135 | let price = if ((shareEmission == 0)) | |
192 | 136 | then (1 * decimalsMultPrice) | |
193 | 137 | else fraction(baseAssetBalanceConsideringLock, decimalsMultPrice, shareEmission) | |
194 | 138 | $Tuple5(price, baseAssetBalance, totalLockedBaseAmount, baseAssetBalanceConsideringLock, shareEmission) | |
195 | 139 | } | |
196 | 140 | } | |
197 | 141 | ||
198 | 142 | ||
199 | 143 | func calcPrice (internalBaseAssetStr,baseAssetId,shareAssetId,decimalsMultBothAssets,decimalsMultPrice) = genericCalcPrice(internalBaseAssetStr, baseAssetId, 0, shareAssetId, decimalsMultBothAssets, decimalsMultPrice) | |
200 | 144 | ||
201 | 145 | ||
202 | 146 | func privateCurrentSysParamsREST (baseAssetStr) = { | |
203 | 147 | let baseAssetId = fromBase58String(baseAssetStr) | |
204 | 148 | let cfgArray = readAssetCfgOrFail(baseAssetStr) | |
205 | 149 | let shareAssetStr = cfgArray[IdxCfgShareAssetId] | |
206 | 150 | let shareAssetId = fromBase58String(shareAssetStr) | |
207 | 151 | let decimalsMultBothAssets = parseIntValue(cfgArray[IdxCfgDecimalsMultBothAssets]) | |
208 | 152 | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
209 | 153 | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
210 | 154 | let sysState = calcPrice(internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice) | |
211 | 155 | $Tuple6(IntegerEntry("price", sysState._1), IntegerEntry("decimalsMultPrice", decimalsMultPrice), IntegerEntry("baseAssetBalance", sysState._2), IntegerEntry("totalLockedBaseAmount", sysState._3), IntegerEntry("baseAssetBalanceConsideringLock", sysState._4), IntegerEntry("shareEmission", sysState._5)) | |
212 | 156 | } | |
213 | 157 | ||
214 | 158 | ||
215 | 159 | @Callable(i) | |
216 | 160 | func adminRegisterAsset (baseAssetStr,shareAssetName,shareAssetDescr,getDelayinBlocks,shutdownManagerAddress) = { | |
217 | 161 | let baseAssetId = fromBase58String(baseAssetStr) | |
218 | 162 | let decimals = value(assetInfo(baseAssetId)).decimals | |
219 | - | | |
220 | - | | |
221 | - | | |
163 | + | if ((i.caller != this)) | |
164 | + | then throw("permissions denied") | |
165 | + | else if ((toString(addressFromStringValue(shutdownManagerAddress)) != shutdownManagerAddress)) | |
222 | 166 | then throw("invalid shutdownManagerAddress") | |
223 | 167 | else if ((0 > getDelayinBlocks)) | |
224 | 168 | then throw(("invalid getDelayinBlocks=" + toString(getDelayinBlocks))) | |
225 | 169 | else { | |
226 | 170 | let shareAssetIssueAction = Issue(shareAssetName, shareAssetDescr, 1, decimals, true) | |
227 | 171 | let shareAssetId = calculateAssetId(shareAssetIssueAction) | |
228 | 172 | let shareAssetStr = toBase58String(shareAssetId) | |
229 | 173 | let decimalsMultPrice = ((100 * 1000) * 1000) | |
230 | 174 | let decimalsMultBothAssets = pow(10, 0, decimals, 0, 0, DOWN) | |
231 | 175 | let startPrice = (1 * decimalsMultPrice) | |
232 | 176 | let internalBaseAssettId = valueOrElse(getInteger(this, keyNextInternalAssetId()), 0) | |
233 | 177 | let internalBaseAssetStr = toString(internalBaseAssettId) | |
234 | 178 | [StringEntry(keyAssetCfg(baseAssetStr), dataAssetCfg(shareAssetStr, internalBaseAssetStr, decimalsMultBothAssets, decimalsMultPrice, getDelayinBlocks)), StringEntry(keyMappingsInternal2baseAssetId(internalBaseAssettId), baseAssetStr), StringEntry(keyMappingsBaseAsset2internalId(baseAssetStr), internalBaseAssetStr), StringEntry(keyMappingsShare2baseAssetId(shareAssetStr), baseAssetStr), StringEntry(keyMappingsBaseAsset2shareId(baseAssetStr), shareAssetStr), BooleanEntry(keyShutdownPutOperation(internalBaseAssetStr), false), StringEntry(keyShutdownManager(internalBaseAssetStr), shutdownManagerAddress), IntegerEntry(keyNextInternalAssetId(), (internalBaseAssettId + 1)), IntegerEntry(keyPriceLast(internalBaseAssetStr), startPrice), IntegerEntry(keyPriceHistory(internalBaseAssetStr, height, lastBlock.timestamp), startPrice), shareAssetIssueAction, Burn(shareAssetId, 1)] | |
235 | 179 | } | |
236 | - | else throw("Strict value is not equal to itself.") | |
237 | 180 | } | |
238 | 181 | ||
239 | 182 | ||
240 | 183 | ||
241 | 184 | @Callable(i) | |
242 | 185 | func shutdownPut (internalBaseAssetId) = { | |
243 | 186 | let internalBaseAssetIdStr = toString(internalBaseAssetId) | |
244 | 187 | let baseAssetIdStr = getStringOrFail(keyMappingsInternal2baseAssetId(internalBaseAssetId)) | |
245 | 188 | let shutdownManagerAddress = getStringOrFail(keyShutdownManager(internalBaseAssetIdStr)) | |
246 | 189 | if ((1 > size(baseAssetIdStr))) | |
247 | 190 | then throw("invalid internalBaseAssetId") | |
248 | 191 | else if ((toString(i.caller) != shutdownManagerAddress)) | |
249 | 192 | then throw("access denied") | |
250 | 193 | else [BooleanEntry(keyShutdownPutOperation(toString(internalBaseAssetId)), true)] | |
251 | 194 | } | |
252 | 195 | ||
253 | 196 | ||
254 | 197 | ||
255 | 198 | @Callable(i) | |
256 | 199 | func put () = { | |
257 | 200 | let pmt = value(i.payments[0]) | |
258 | 201 | let baseAssetId = value(pmt.assetId) | |
259 | 202 | let baseAssetStr = toBase58String(baseAssetId) | |
260 | 203 | let userAddressStr = toString(i.caller) | |
261 | 204 | let cfgArray = readAssetCfgOrFail(baseAssetStr) | |
262 | 205 | let shareAssetStr = cfgArray[IdxCfgShareAssetId] | |
263 | 206 | let shareAssetId = fromBase58String(shareAssetStr) | |
264 | 207 | let decimalsMultBothAssets = parseIntValue(cfgArray[IdxCfgDecimalsMultBothAssets]) | |
265 | 208 | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
266 | 209 | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
267 | 210 | let isPutBlocked = getBooleanOrFail(keyShutdownPutOperation(internalBaseAssetStr)) | |
268 | - | let shutdown = valueOrElse(getBoolean(keyShutdown(internalBaseAssetStr)), false) | |
269 | - | if (if (isPutBlocked) | |
270 | - | then true | |
271 | - | else shutdown) | |
211 | + | if (isPutBlocked) | |
272 | 212 | then throw("put operation is blocked") | |
273 | 213 | else { | |
274 | 214 | let price = calcPrice(internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
275 | 215 | let shareAssetAmount = fraction(pmt.amount, decimalsMultPrice, price) | |
276 | 216 | [Reissue(shareAssetId, shareAssetAmount, true), ScriptTransfer(i.caller, shareAssetAmount, shareAssetId), StringEntry(keyOperation("P", internalBaseAssetStr, userAddressStr, toBase58String(i.transactionId)), dataOperation("FINISHED", pmt.amount, price, shareAssetAmount, height, lastBlock.timestamp, height, lastBlock.timestamp))] | |
277 | 217 | } | |
278 | 218 | } | |
279 | 219 | ||
280 | 220 | ||
281 | 221 | ||
282 | 222 | @Callable(i) | |
283 | 223 | func submitGetRequest () = { | |
284 | 224 | let pmt = value(i.payments[0]) | |
285 | 225 | let shareAssetId = value(pmt.assetId) | |
286 | 226 | let shareAssetStr = toBase58String(shareAssetId) | |
287 | 227 | let callerPubStr = toBase58String(i.callerPublicKey) | |
288 | 228 | let userAddress = i.caller | |
289 | 229 | let userAddressStr = toString(userAddress) | |
290 | 230 | let shareAssetAmount = pmt.amount | |
291 | 231 | let baseAssetStr = getStringOrFail(keyMappingsShare2baseAssetId(shareAssetStr)) | |
292 | 232 | let baseAssetId = fromBase58String(baseAssetStr) | |
293 | 233 | let cfgArray = readAssetCfgOrFail(baseAssetStr) | |
294 | 234 | let decimalsMultBothAssets = parseIntValue(cfgArray[IdxCfgDecimalsMultBothAssets]) | |
295 | 235 | let decimalsMultPrice = parseIntValue(cfgArray[IdxCfgDecimalsMultPrice]) | |
296 | 236 | let getDelayBlocks = parseIntValue(cfgArray[IdxCfgGetDelayBlocks]) | |
297 | 237 | let internalBaseAssetStr = cfgArray[IdxCfgInternalBaseAsset] | |
298 | - | let shutdown = valueOrElse(getBoolean(keyShutdown(internalBaseAssetStr)), false) | |
299 | - | if (shutdown) | |
300 | - | then throw("operation is blocked") | |
301 | - | else { | |
302 | - | let price = calcPrice(internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
303 | - | let baseAssetAmount = fraction(shareAssetAmount, price, decimalsMultPrice) | |
304 | - | let operationKey = keyOperation("G", internalBaseAssetStr, userAddressStr, toBase58String(i.transactionId)) | |
305 | - | let operationData = dataOperation("PENDING", shareAssetAmount, price, baseAssetAmount, height, lastBlock.timestamp, (height + getDelayBlocks), 0) | |
238 | + | let price = calcPrice(internalBaseAssetStr, baseAssetId, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
239 | + | let baseAssetAmount = fraction(shareAssetAmount, price, decimalsMultPrice) | |
240 | + | let operationKey = keyOperation("G", internalBaseAssetStr, userAddressStr, toBase58String(i.transactionId)) | |
241 | + | let operationData = dataOperation("PENDING", shareAssetAmount, price, baseAssetAmount, height, lastBlock.timestamp, (height + getDelayBlocks), 0) | |
306 | 242 | [Burn(shareAssetId, shareAssetAmount), StringEntry(operationKey, operationData), incrementTotalLocked(keyTotalLocked(internalBaseAssetStr), shareAssetAmount, baseAssetAmount), incrementTotalLocked(keyTotalLockedByUser(internalBaseAssetStr, userAddressStr), shareAssetAmount, baseAssetAmount)] | |
307 | - | } | |
308 | 243 | } | |
309 | 244 | ||
310 | 245 | ||
311 | 246 | ||
312 | 247 | @Callable(i) | |
313 | 248 | func executeGetRequest (baseAssetStr,userAddressStr,getTxIdStr) = { | |
314 | 249 | let userAddress = addressFromStringValue(userAddressStr) | |
315 | 250 | let assetCfgArray = readAssetCfgOrFail(baseAssetStr) | |
316 | 251 | let shareAssetId = fromBase58String(assetCfgArray[IdxCfgShareAssetId]) | |
317 | 252 | let baseAssetId = fromBase58String(baseAssetStr) | |
318 | 253 | let internalBaseAssetStr = assetCfgArray[IdxCfgInternalBaseAsset] | |
319 | - | let shutdown = valueOrElse(getBoolean(keyShutdown(internalBaseAssetStr)), false) | |
320 | - | if (shutdown) | |
321 | - | then throw("operation is blocked") | |
322 | - | else { | |
323 | - | let operationKey = keyOperation("G", internalBaseAssetStr, userAddressStr, getTxIdStr) | |
324 | - | let operationArray = split(getStringOrFail(operationKey), SEP) | |
325 | - | let status = operationArray[IdxOperStatus] | |
326 | - | let endHeight = parseIntValue(operationArray[IdxOperEndHeight]) | |
327 | - | let inShareAmount = parseIntValue(operationArray[IdxOperInAmount]) | |
328 | - | let outBaseAmount = parseIntValue(operationArray[IdxOperOutAmount]) | |
329 | - | if ((status != "PENDING")) | |
330 | - | then failExecuteGet("Status is not PENDING", baseAssetStr, userAddressStr, getTxIdStr) | |
331 | - | else if ((endHeight > height)) | |
332 | - | then failExecuteGet(((("EndHeight[" + toString(endHeight)) + "] > ") + toString(height)), baseAssetStr, userAddressStr, getTxIdStr) | |
333 | - | else [ScriptTransfer(userAddress, outBaseAmount, baseAssetId), StringEntry(operationKey, dataOperationExecutionUpdate(operationArray, "FINISHED", lastBlock.timestamp)), decrementTotalLocked(keyTotalLocked(internalBaseAssetStr), inShareAmount, outBaseAmount), decrementTotalLocked(keyTotalLockedByUser(internalBaseAssetStr, userAddressStr), inShareAmount, outBaseAmount)] | |
334 | - | } | |
254 | + | let operationKey = keyOperation("G", internalBaseAssetStr, userAddressStr, getTxIdStr) | |
255 | + | let operationArray = split(getStringOrFail(operationKey), SEP) | |
256 | + | let status = operationArray[IdxOperStatus] | |
257 | + | let endHeight = parseIntValue(operationArray[IdxOperEndHeight]) | |
258 | + | let inShareAmount = parseIntValue(operationArray[IdxOperInAmount]) | |
259 | + | let outBaseAmount = parseIntValue(operationArray[IdxOperOutAmount]) | |
260 | + | if ((status != "PENDING")) | |
261 | + | then failExecuteGet("Status is not PENDING", baseAssetStr, userAddressStr, getTxIdStr) | |
262 | + | else if ((endHeight > height)) | |
263 | + | then failExecuteGet(((("EndHeight[" + toString(endHeight)) + "] > ") + toString(height)), baseAssetStr, userAddressStr, getTxIdStr) | |
264 | + | else [ScriptTransfer(userAddress, outBaseAmount, baseAssetId), StringEntry(operationKey, dataOperationExecutionUpdate(operationArray, "FINISHED", lastBlock.timestamp)), decrementTotalLocked(keyTotalLocked(internalBaseAssetStr), inShareAmount, outBaseAmount), decrementTotalLocked(keyTotalLockedByUser(internalBaseAssetStr, userAddressStr), inShareAmount, outBaseAmount)] | |
335 | 265 | } | |
336 | 266 | ||
337 | 267 | ||
338 | 268 | ||
339 | 269 | @Callable(i) | |
340 | 270 | func topUpBalance (baseAssetStr) = { | |
341 | 271 | let assetCfgArray = readAssetCfgOrFail(baseAssetStr) | |
342 | 272 | let pmt = value(i.payments[0]) | |
343 | 273 | let pmtAssetId = value(pmt.assetId) | |
344 | 274 | let pmtAssetStr = toBase58String(pmtAssetId) | |
345 | 275 | let shareAssetId = fromBase58String(assetCfgArray[IdxCfgShareAssetId]) | |
346 | 276 | let decimalsMultBothAssets = parseIntValue(assetCfgArray[IdxCfgDecimalsMultBothAssets]) | |
347 | 277 | let decimalsMultPrice = parseIntValue(assetCfgArray[IdxCfgDecimalsMultPrice]) | |
348 | 278 | let internalBaseAssetStr = assetCfgArray[IdxCfgInternalBaseAsset] | |
349 | 279 | let topUpLastHeightKEY = keyTopUpLastHeight(internalBaseAssetStr, toString(i.caller)) | |
350 | 280 | let topUpLastHeight = valueOrElse(getInteger(this, topUpLastHeightKEY), 0) | |
351 | - | let shutdown = valueOrElse(getBoolean(keyShutdown(internalBaseAssetStr)), false) | |
352 | - | if (shutdown) | |
353 | - | then throw("operation is blocked") | |
354 | - | else if ((baseAssetStr != pmtAssetStr)) | |
355 | - | then throw("attached payment's asset id is NOT matched passed baseAssetStr") | |
356 | - | else if ((size(i.payments) > 1)) | |
357 | - | then throw("only one payment can be attached") | |
358 | - | else if ((100 > (height - topUpLastHeight))) | |
359 | - | then throw("1 topUp per 100 blocks from the same address is allowed") | |
360 | - | else { | |
361 | - | let price = genericCalcPrice(internalBaseAssetStr, pmtAssetId, pmt.amount, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
281 | + | if ((baseAssetStr != pmtAssetStr)) | |
282 | + | then throw("attached payment's asset id is NOT matched passed baseAssetStr") | |
283 | + | else if ((size(i.payments) > 1)) | |
284 | + | then throw("only one payment can be attached") | |
285 | + | else if ((100 > (height - topUpLastHeight))) | |
286 | + | then throw("1 topUp per 100 blocks from the same address is allowed") | |
287 | + | else { | |
288 | + | let price = genericCalcPrice(internalBaseAssetStr, pmtAssetId, pmt.amount, shareAssetId, decimalsMultBothAssets, decimalsMultPrice)._1 | |
362 | 289 | [IntegerEntry(keyPriceLast(internalBaseAssetStr), price), IntegerEntry(keyPriceHistory(internalBaseAssetStr, height, lastBlock.timestamp), price), IntegerEntry(topUpLastHeightKEY, height)] | |
363 | - | } | |
364 | - | } | |
365 | - | ||
366 | - | ||
367 | - | ||
368 | - | @Callable(i) | |
369 | - | func emit (assetId,amount) = { | |
370 | - | let checks = [if ((i.caller == lpStakingPoolsContract)) | |
371 | - | then true | |
372 | - | else throwErr("permission denied"), if ((amount > 0)) | |
373 | - | then true | |
374 | - | else throwErr("invalid amount to emit"), if ((getString(keyMappingsShare2baseAssetId(toBase58String(assetId))) != unit)) | |
375 | - | then true | |
376 | - | else throwErr("invalid assetId")] | |
377 | - | if ((checks == checks)) | |
378 | - | then { | |
379 | - | let isReissuable = true | |
380 | - | $Tuple2([Reissue(assetId, amount, isReissuable), ScriptTransfer(lpStakingPoolsContract, amount, assetId)], amount) | |
381 | - | } | |
382 | - | else throw("Strict value is not equal to itself.") | |
383 | - | } | |
384 | - | ||
385 | - | ||
386 | - | ||
387 | - | @Callable(i) | |
388 | - | func burn (assetId,amount) = { | |
389 | - | let checks = [if ((i.caller == lpStakingPoolsContract)) | |
390 | - | then true | |
391 | - | else throwErr("permission denied"), if ((amount > 0)) | |
392 | - | then true | |
393 | - | else throwErr("invalid amount to burn"), if ((getString(keyMappingsShare2baseAssetId(toBase58String(assetId))) != unit)) | |
394 | - | then true | |
395 | - | else throwErr("invalid assetId")] | |
396 | - | if ((checks == checks)) | |
397 | - | then $Tuple2([Burn(assetId, amount)], amount) | |
398 | - | else throw("Strict value is not equal to itself.") | |
290 | + | } | |
399 | 291 | } | |
400 | 292 | ||
401 | 293 | ||
402 | 294 | ||
403 | 295 | @Callable(i) | |
404 | 296 | func currentSysParamsREST (baseAssetStr) = { | |
405 | 297 | let sysStateTuple = privateCurrentSysParamsREST(baseAssetStr) | |
406 | 298 | let price = sysStateTuple._1.value | |
407 | 299 | let decimalsMultPrice = sysStateTuple._2.value | |
408 | 300 | let baseAssetBalance = sysStateTuple._3.value | |
409 | 301 | let totalLockedBaseAmount = sysStateTuple._4.value | |
410 | 302 | let baseAssetBalanceConsideringLock = sysStateTuple._5.value | |
411 | 303 | let shareEmission = sysStateTuple._6.value | |
412 | 304 | let restData = makeString(["startCurrentSysParamsREST", toString(price), toString(decimalsMultPrice), toString(baseAssetBalance), toString(totalLockedBaseAmount), toString(baseAssetBalanceConsideringLock), toString(shareEmission), "endCurrentSysParamsREST"], SEP) | |
413 | 305 | throw(restData) | |
414 | 306 | } | |
415 | 307 | ||
416 | 308 | ||
417 | - | ||
418 | - | @Callable(i) | |
419 | - | func setManager (pendingManagerPublicKey) = { | |
420 | - | let checkCaller = mustManager(i) | |
421 | - | if ((checkCaller == checkCaller)) | |
422 | - | then { | |
423 | - | let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey) | |
424 | - | if ((checkManagerPublicKey == checkManagerPublicKey)) | |
425 | - | then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)] | |
426 | - | else throw("Strict value is not equal to itself.") | |
427 | - | } | |
428 | - | else throw("Strict value is not equal to itself.") | |
429 | - | } | |
430 | - | ||
431 | - | ||
432 | - | ||
433 | - | @Callable(i) | |
434 | - | func confirmManager () = { | |
435 | - | let pm = pendingManagerPublicKeyOrUnit() | |
436 | - | let hasPM = if (isDefined(pm)) | |
437 | - | then true | |
438 | - | else throwErr("no pending manager") | |
439 | - | if ((hasPM == hasPM)) | |
440 | - | then { | |
441 | - | let checkPM = if ((i.callerPublicKey == value(pm))) | |
442 | - | then true | |
443 | - | else throwErr("you are not pending manager") | |
444 | - | if ((checkPM == checkPM)) | |
445 | - | then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())] | |
446 | - | else throw("Strict value is not equal to itself.") | |
447 | - | } | |
448 | - | else throw("Strict value is not equal to itself.") | |
449 | - | } | |
450 | - | ||
451 | - | ||
452 | 309 | @Verifier(tx) | |
453 | - | func verify () = { | |
454 | - | let targetPublicKey = match managerPublicKeyOrUnit() { | |
455 | - | case pk: ByteVector => | |
456 | - | pk | |
457 | - | case _: Unit => | |
458 | - | tx.senderPublicKey | |
459 | - | case _ => | |
460 | - | throw("Match error") | |
461 | - | } | |
462 | - | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
463 | - | } | |
310 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], fromBase58String("2Cbd8ozG7A1RyRNC3nNnZgHu7Ru4K3JCfpyPkhqr9zxq")) | |
464 | 311 |
github/deemru/w8io/026f985 52.05 ms ◑