tx · 17LkWHi8uHNZqxHsyqip8yV7u8cMv2JTVnaNjQY7JrT

3Msgbu1TscFoJHmvwjkBrpD7yDhKqnfGq9m:  -0.00500000 Waves

2023.03.16 11:34 [2492340] smart account 3Msgbu1TscFoJHmvwjkBrpD7yDhKqnfGq9m > SELF 0.00000000 Waves

{ "type": 13, "id": "17LkWHi8uHNZqxHsyqip8yV7u8cMv2JTVnaNjQY7JrT", "fee": 500000, "feeAssetId": null, "timestamp": 1678955708901, "version": 2, "chainId": 84, "sender": "3Msgbu1TscFoJHmvwjkBrpD7yDhKqnfGq9m", "senderPublicKey": "8wgMB6DsPfRBQi5WJTP6xMrbCZXWYhzUUpGNB7HYqYXa", "proofs": [ "4kcGGfMQau35VEMTmfjFaJTMei8C99Xd1xu4nwTByLEiz7qi681DdEzzVjdaY68ub8Lv4R1wU3GuByijFSL5rBzh" ], "script": null, "height": 2492340, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BCVqT33RGVjywx1ymM5Vx7fqHJMDJKQqvHpi8CBXi3vu Next: 2W6vscTWZkbecLRAWv4wodrY8WArdYNecVwjB9UcjoCc Full:
OldNewDifferences
1-{-# STDLIB_VERSION 5 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let SEP = "__"
5-
6-let EMPTY = ""
7-
8-func keyManagerPublicKey () = "%s__managerPublicKey"
9-
10-
11-func keyPendingManagerPublicKey () = "%s__pendingManagerPublicKey"
12-
13-
14-func keyAdminPubKeys () = "%s__adminPubKeys"
15-
16-
17-func keyUser (assetId,address) = makeString(["%s%s", assetId, address], SEP)
18-
19-
20-func keyUserFixedDeposit (assetId,address,block) = makeString(["%s%s%s%d", "fixedDeposit", assetId, address, toString(block)], SEP)
21-
22-
23-func keyRevoked (assetId,address) = makeString(["%s%s%s", "revoked", assetId, address], SEP)
24-
25-
26-func keyRevokedTotal (assetId) = makeString(["%s%s", "revokedTotal", assetId], SEP)
27-
28-
29-func keyUserVestingStart (assetId,address) = makeString(["%s%s%s", "vestingStart", assetId, address], SEP)
30-
31-
32-func keyUserVestingEnd (assetId,address) = makeString(["%s%s%s", "vestingEnd", assetId, address], SEP)
33-
34-
35-func keyUserAmountPerBlock (assetId,address) = makeString(["%s%s%s", "amountPerBlock", assetId, address], SEP)
36-
37-
38-func keyClaimDenied (assetId) = makeString(["%s%s", "claimDenied", assetId], SEP)
39-
40-
41-func throwErr (msg) = throw(makeString(["vesting_multiasset.ride:", msg], " "))
42-
43-
44-func managerPublicKeyOrUnit () = match getString(keyManagerPublicKey()) {
45- case s: String =>
46- fromBase58String(s)
47- case _: Unit =>
48- unit
49- case _ =>
50- throw("Match error")
51-}
52-
53-
54-func pendingManagerPublicKeyOrUnit () = match getString(keyPendingManagerPublicKey()) {
55- case s: String =>
56- fromBase58String(s)
57- case _: Unit =>
58- unit
59- case _ =>
60- throw("Match error")
61-}
62-
63-
64-func mustManager (i) = {
65- let pd = throwErr("permission denied")
66- match managerPublicKeyOrUnit() {
67- case pk: ByteVector =>
68- if ((i.callerPublicKey == pk))
69- then true
70- else pd
71- case _: Unit =>
72- if ((i.caller == this))
73- then true
74- else pd
75- case _ =>
76- throw("Match error")
77- }
78- }
79-
80-
81-func mustAdmin (i) = {
82- let adminPKs = split(valueOrElse(getString(keyAdminPubKeys()), EMPTY), SEP)
83- if (containsElement(adminPKs, toBase58String(i.callerPublicKey)))
84- then true
85- else {
86- let isManager = mustManager(i)
87- if ((isManager == isManager))
88- then true
89- else throw("Strict value is not equal to itself.")
90- }
91- }
92-
93-
94-func valueUserS (totalAmount,remainingAmount,claimedWXAmount,lastClaimedHeight) = makeString(["%d%d%d%d%d", totalAmount, remainingAmount, "0", claimedWXAmount, lastClaimedHeight], SEP)
95-
96-
97-func valueUser (totalAmount,remainingAmount,claimedWXAmount,lastClaimedHeight) = valueUserS(toString(totalAmount), toString(remainingAmount), toString(claimedWXAmount), toString(lastClaimedHeight))
98-
99-
100-func getUserTotalAmount (assetId,address) = parseIntValue(split(value(getString(keyUser(assetId, address))), SEP)[1])
101-
102-
103-func getUserRemainingAmount (assetId,address) = parseIntValue(split(value(getString(keyUser(assetId, address))), SEP)[2])
104-
105-
106-func getUserClaimedAmount (assetId,address) = parseIntValue(split(value(getString(keyUser(assetId, address))), SEP)[3])
107-
108-
109-func getUserLastClaimedHeight (assetId,address) = parseIntValue(split(value(getString(keyUser(assetId, address))), SEP)[5])
110-
111-
112-func availableToClaimNow (assetId,address) = {
113- let isRevokedUser = valueOrElse(getBoolean(keyRevoked(assetId, address)), false)
114- if (isRevokedUser)
115- then getUserRemainingAmount(assetId, address)
116- else {
117- let lastHeight = getUserLastClaimedHeight(assetId, address)
118- if ((lastHeight >= height))
119- then 0
120- else {
121- let end = value(getInteger(keyUserVestingEnd(assetId, address)))
122- if ((height > end))
123- then getUserRemainingAmount(assetId, address)
124- else {
125- let unclaimedPeriod = (height - lastHeight)
126- (value(getInteger(keyUserAmountPerBlock(assetId, address))) * unclaimedPeriod)
127- }
128- }
129- }
130- }
131-
132-
133-func availableToClaimFixed (assetId,address,releaseBlock) = valueOrElse(getInteger(keyUserFixedDeposit(assetId, address, releaseBlock)), 0)
134-
135-
136-func claimInternal (assetId,address) = {
137- let addr = addressFromStringValue(address)
138- let asset = fromBase58String(assetId)
139- let amount = availableToClaimNow(assetId, address)
140- let checks = [if ((valueOrElse(getBoolean(keyClaimDenied(assetId)), false) == false))
141- then true
142- else throwErr("asset claim denied"), if ((amount != 0))
143- then true
144- else throwErr("nothing to claim")]
145- if ((checks == checks))
146- then {
147- let totalAmount = getUserTotalAmount(assetId, address)
148- let remainingAmount = getUserRemainingAmount(assetId, address)
149- let claimedAmount = getUserClaimedAmount(assetId, address)
150- let isRevokedUser = valueOrElse(getBoolean(keyRevoked(assetId, address)), false)
151- if (isRevokedUser)
152- then [ScriptTransfer(addr, remainingAmount, asset), StringEntry(keyUser(assetId, address), valueUser(totalAmount, 0, (claimedAmount + remainingAmount), height))]
153- else [ScriptTransfer(addr, amount, asset), StringEntry(keyUser(assetId, address), valueUser(totalAmount, (remainingAmount - amount), (claimedAmount + amount), height))]
154- }
155- else throw("Strict value is not equal to itself.")
156- }
157-
158-
159-func claimFixedInternal (assetId,address,releaseBlock) = {
160- let userFixedDeposit = getInteger(keyUserFixedDeposit(assetId, address, releaseBlock))
161- let checks = [if ((valueOrElse(getBoolean(keyClaimDenied(assetId)), false) == false))
162- then true
163- else throwErr("asset claim denied"), if ((height > releaseBlock))
164- then true
165- else throwErr("current height must be more than releaseBlock for fixed deposit"), if ((valueOrElse(userFixedDeposit, 0) != 0))
166- then true
167- else throwErr("no fixed deposit for assetId/address/height")]
168- if ((checks == checks))
169- then {
170- let addr = addressFromStringValue(address)
171- let asset = fromBase58String(assetId)
172- let amount = value(userFixedDeposit)
173-[ScriptTransfer(addr, amount, asset), IntegerEntry(keyUserFixedDeposit(assetId, address, releaseBlock), 0)]
174- }
175- else throw("Strict value is not equal to itself.")
176- }
177-
178-
179-@Callable(i)
180-func withdrawRevoked (assetId) = {
181- let amount = valueOrElse(getInteger(keyRevokedTotal(assetId)), 0)
182- let asset = fromBase58String(assetId)
183- let checks = [mustManager(i), if ((amount > 0))
184- then true
185- else throwErr("revoked amount is zero, nothing to withdraw")]
186- if ((checks == checks))
187- then [ScriptTransfer(i.caller, amount, asset), IntegerEntry(keyRevokedTotal(assetId), 0)]
188- else throw("Strict value is not equal to itself.")
189- }
190-
191-
192-
193-@Callable(i)
194-func createDepositFor (address,blocksDuration) = {
195- let amount = i.payments[0].amount
196- let assetId = toBase58String(value(i.payments[0].assetId))
197- let endHeight = (height + blocksDuration)
198- let vestingLen = (endHeight - height)
199- let amountPerBlock = (amount / vestingLen)
200- let checks = [if ((endHeight > height))
201- then true
202- else throwErr("endHeight must be more than height"), if ((getString(keyUser(assetId, address)) == unit))
203- then true
204- else throwErr("deposit of this asset for user already exists"), if ((amountPerBlock != 0))
205- then true
206- else throwErr("attached amount too small or blocksDuration too large — will claimed zero per block")]
207- if ((checks == checks))
208- then [StringEntry(keyUser(assetId, address), valueUser(amount, amount, 0, height)), IntegerEntry(keyUserVestingStart(assetId, address), height), IntegerEntry(keyUserVestingEnd(assetId, address), endHeight), IntegerEntry(keyUserAmountPerBlock(assetId, address), amountPerBlock)]
209- else throw("Strict value is not equal to itself.")
210- }
211-
212-
213-
214-@Callable(i)
215-func increaseDepositFor (address) = {
216- let amount = i.payments[0].amount
217- let assetId = toBase58String(value(i.payments[0].assetId))
218- let availableToClaim = availableToClaimNow(assetId, address)
219- let forceClaim = if ((availableToClaim > 0))
220- then claimInternal(assetId, address)
221- else unit
222- if ((forceClaim == forceClaim))
223- then {
224- let endHeight = value(getInteger(keyUserVestingEnd(assetId, address)))
225- let vestingLen = (endHeight - height)
226- let amountPerBlock = value(getInteger(keyUserAmountPerBlock(assetId, address)))
227- let incAmountPerBlock = (amount / vestingLen)
228- let userTotalAmount = getUserTotalAmount(assetId, address)
229- let userRemainingAmount = getUserRemainingAmount(assetId, address)
230- let userClaimedAmount = getUserClaimedAmount(assetId, address)
231- let userLastClaimedHeight = getUserLastClaimedHeight(assetId, address)
232- let checks = [if ((valueOrElse(getBoolean(keyRevoked(assetId, address)), false) == false))
233- then true
234- else throwErr("deposit for user is revoked"), if ((getString(keyUser(assetId, address)) != unit))
235- then true
236- else throwErr("deposit for user doesn't exists"), if ((incAmountPerBlock != 0))
237- then true
238- else throwErr("attached amount too small — increase is zero per block")]
239- if ((checks == checks))
240- then [StringEntry(keyUser(assetId, address), valueUser((userTotalAmount + amount), (userRemainingAmount + amount), userClaimedAmount, userLastClaimedHeight)), IntegerEntry(keyUserAmountPerBlock(assetId, address), (amountPerBlock + incAmountPerBlock))]
241- else throw("Strict value is not equal to itself.")
242- }
243- else throw("Strict value is not equal to itself.")
244- }
245-
246-
247-
248-@Callable(i)
249-func revokeDepositFor (assetId,address) = {
250- let totalAmount = getUserTotalAmount(assetId, address)
251- let remainingAmount = getUserRemainingAmount(assetId, address)
252- let claimedWXAmount = getUserClaimedAmount(assetId, address)
253- let lastClaimedHeight = getUserLastClaimedHeight(assetId, address)
254- let unclaimedAmountNow = availableToClaimNow(assetId, address)
255- let revokedTotal = valueOrElse(getInteger(keyRevokedTotal(assetId)), 0)
256- let amountToRevoke = (remainingAmount - unclaimedAmountNow)
257- let newRevokedTotal = (revokedTotal + amountToRevoke)
258- let checks = [mustAdmin(i), if ((getString(keyUser(assetId, address)) != unit))
259- then true
260- else throwErr("deposit of this asset for user is not exists"), if ((newRevokedTotal > revokedTotal))
261- then true
262- else throwErr("newRevokedTotal can't be less or equal than revokedTotal")]
263- if ((checks == checks))
264- then [BooleanEntry(keyRevoked(assetId, address), true), IntegerEntry(keyRevokedTotal(assetId), newRevokedTotal), StringEntry(keyUser(assetId, address), valueUser(totalAmount, unclaimedAmountNow, claimedWXAmount, lastClaimedHeight))]
265- else throw("Strict value is not equal to itself.")
266- }
267-
268-
269-
270-@Callable(i)
271-func claim (assetId) = claimInternal(assetId, toBase58String(i.caller.bytes))
272-
273-
274-
275-@Callable(i)
276-func claimFor (assetId,address) = claimInternal(assetId, address)
277-
278-
279-
280-@Callable(i)
281-func claimREADONLY (assetId,address) = {
282- let amount = availableToClaimNow(assetId, address)
283- $Tuple2(nil, amount)
284- }
285-
286-
287-
288-@Callable(i)
289-func createFixedDepositFor (address,releaseBlock) = {
290- let amount = i.payments[0].amount
291- let assetId = toBase58String(value(i.payments[0].assetId))
292- let userFixedDeposit = keyUserFixedDeposit(assetId, address, releaseBlock)
293- let checks = [if ((releaseBlock > height))
294- then true
295- else throwErr("releaseBlock must be more than height"), if ((getInteger(userFixedDeposit) == unit))
296- then true
297- else throwErr("deposit for this height for user already exists")]
298- if ((checks == checks))
299- then [IntegerEntry(userFixedDeposit, amount)]
300- else throw("Strict value is not equal to itself.")
301- }
302-
303-
304-
305-@Callable(i)
306-func claimFixed (assetId,releaseBlock) = claimFixedInternal(assetId, toBase58String(i.caller.bytes), releaseBlock)
307-
308-
309-
310-@Callable(i)
311-func claimFixedFor (assetId,address,releaseBlock) = claimFixedInternal(assetId, address, releaseBlock)
312-
313-
314-
315-@Callable(i)
316-func claimFixedREADONLY (assetId,address,releaseBlock) = {
317- let amount = availableToClaimFixed(assetId, address, releaseBlock)
318- $Tuple2(nil, amount)
319- }
320-
321-
322-
323-@Callable(i)
324-func revokeFixedDepositFor (assetId,address,releaseBlock) = {
325- let checks = [mustAdmin(i), if ((releaseBlock > height))
326- then true
327- else throwErr("can't revoke deposit in past"), if ((valueOrElse(getInteger(keyUserFixedDeposit(assetId, address, releaseBlock)), 0) != 0))
328- then true
329- else throwErr("deposit for this height for user not exists")]
330- if ((checks == checks))
331- then {
332- let amount = value(getInteger(keyUserFixedDeposit(assetId, address, releaseBlock)))
333-[IntegerEntry(keyRevokedTotal(assetId), amount), IntegerEntry(keyUserFixedDeposit(assetId, address, releaseBlock), 0)]
334- }
335- else throw("Strict value is not equal to itself.")
336- }
337-
338-
339-
340-@Callable(i)
341-func denyAssetClaim (assetId) = {
342- let checks = [mustAdmin(i), if ((valueOrElse(getBoolean(keyClaimDenied(assetId)), false) == false))
343- then true
344- else throwErr("asset already denied")]
345- if ((checks == checks))
346- then [BooleanEntry(keyClaimDenied(assetId), true)]
347- else throw("Strict value is not equal to itself.")
348- }
349-
350-
351-
352-@Callable(i)
353-func allowAssetClaim (assetId) = {
354- let checks = [mustAdmin(i), if ((valueOrElse(getBoolean(keyClaimDenied(assetId)), false) == true))
355- then true
356- else throwErr("asset already allowed")]
357- if ((checks == checks))
358- then [DeleteEntry(keyClaimDenied(assetId))]
359- else throw("Strict value is not equal to itself.")
360- }
361-
362-
363-
364-@Callable(i)
365-func stats (assetId,address) = $Tuple2(nil, [value(getInteger(keyUserVestingStart(assetId, address))), value(getInteger(keyUserVestingEnd(assetId, address))), getUserTotalAmount(assetId, address), getUserClaimedAmount(assetId, address), getUserRemainingAmount(assetId, address), availableToClaimNow(assetId, address)])
366-
367-
368-
369-@Callable(i)
370-func setManager (pendingManagerPublicKey) = {
371- let checkCaller = mustManager(i)
372- if ((checkCaller == checkCaller))
373- then {
374- let checkManagerPublicKey = fromBase58String(pendingManagerPublicKey)
375- if ((checkManagerPublicKey == checkManagerPublicKey))
376- then [StringEntry(keyPendingManagerPublicKey(), pendingManagerPublicKey)]
377- else throw("Strict value is not equal to itself.")
378- }
379- else throw("Strict value is not equal to itself.")
380- }
381-
382-
383-
384-@Callable(i)
385-func confirmManager () = {
386- let pm = pendingManagerPublicKeyOrUnit()
387- let hasPM = if (isDefined(pm))
388- then true
389- else throwErr("no pending manager")
390- if ((hasPM == hasPM))
391- then {
392- let checkPM = if ((i.callerPublicKey == value(pm)))
393- then true
394- else throwErr("you are not pending manager")
395- if ((checkPM == checkPM))
396- then [StringEntry(keyManagerPublicKey(), toBase58String(value(pm))), DeleteEntry(keyPendingManagerPublicKey())]
397- else throw("Strict value is not equal to itself.")
398- }
399- else throw("Strict value is not equal to itself.")
400- }
401-
402-
403-@Verifier(tx)
404-func verify () = {
405- let targetPublicKey = match managerPublicKeyOrUnit() {
406- case pk: ByteVector =>
407- pk
408- case _: Unit =>
409- tx.senderPublicKey
410- case _ =>
411- throw("Match error")
412- }
413- sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey)
414- }
415-
1+# no script

github/deemru/w8io/169f3d6 
36.31 ms