tx · AYJdCZva5qSDbVZPiiGLMtFC9CQdTX9rB7NG54goP9nc

3MtFf3CUhD56xuEpnR9kRhZupdNHeXgKXSp:  -0.00500000 Waves

2023.03.20 10:01 [2498003] smart account 3MtFf3CUhD56xuEpnR9kRhZupdNHeXgKXSp > SELF 0.00000000 Waves

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

github/deemru/w8io/169f3d6 
137.44 ms