tx · 57ad17Ua1vmHgNEMT5sAZecN66jH9DpCeWNgxTWXDtH7

3PCkHc6gumSN4CMKsjBdQVR1AmxZXYNjHrf:  -0.01400000 Waves

2022.03.04 21:31 [3014702] smart account 3PCkHc6gumSN4CMKsjBdQVR1AmxZXYNjHrf > SELF 0.00000000 Waves

{ "type": 13, "id": "57ad17Ua1vmHgNEMT5sAZecN66jH9DpCeWNgxTWXDtH7", "fee": 1400000, "feeAssetId": null, "timestamp": 1646418738433, "version": 2, "chainId": 87, "sender": "3PCkHc6gumSN4CMKsjBdQVR1AmxZXYNjHrf", "senderPublicKey": "ACKrafHkMbzFmKWpEisYJpYBsanVaHCiventLdguW5dS", "proofs": [ "5qefCKAoLrKGJJHQofwaqGhK4Miz5sm8sZU3M9zeriWPQeLRjs8NqjN3vT6U6EhmGxhY4itH7c3DLssR8CwHHvmS" ], "script": null, "height": 3014702, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BV6av8ire5HjiLhwxF9zY2XRA4Dk812H8yahFnrCaXh Next: none Full:
OldNewDifferences
1-{-# STDLIB_VERSION 5 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let startBlock = 2914870
5-
6-let targetBlock = 2920630
7-
8-let maximumAmount = 50000000
9-
10-let nsbtAssetId = base58'6nSpVyNH7yM69eg446wrQR94ipbbcmZMU1ENPwanC97g'
11-
12-let usdnAssetId = base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p'
13-
14-let eurnAssetId = base58'DUk2YTxhRoAqMJLus4G2b3fR8hMHVh6eiyFx5r29VR6t'
15-
16-let rubnAssetId = base58'eWeMD5KNeuRaALCAb4uuJKtAvon2JcTyXQyoBMhuN2X'
17-
18-let cnynAssetId = base58'9LNqjybyCX1oexCub4yY7hdJf6aeP4HeV5LpsjcNHwRR'
19-
20-let jpynAssetId = base58'8inca5fv4xr6KZtRMRPYr7vADfk8fd6G2z1gMoRkbUYS'
21-
22-let uahnAssetId = base58'8zKqZF6asB6yiK8rv9nMUkJ7wAVBJndSmkC7SXJhRrM3'
23-
24-let brlnAssetId = base58'DxFwXxS1r3uZ2QEiSqhe6uoXMJBsz4ShLtHvr4HDzNri'
25-
26-let gbpnAssetId = base58'DhaaqiG8xz8njeBuMtTM2G6avg9Jdhfrxw5onm5GaXx1'
27-
28-let trynAssetId = base58'DGbqkzM6Ds5NAF2B3GHYfyZRmWKt7xLYRYcwpMm7D6V4'
29-
30-let neutrinoAddress = Address(base58'3PNikM6yp4NqcSU8guxQtmR5onr2D4e8yTJ')
31-
32-let viresAssetId = base58'DSbbhLsSTeDg5Lsiufk2Aneh3DjVqJuPr2M9uU1gwy5p'
33-
34-let viresAddress = Address(base58'3PAZv9tgK1PX7dKR7b4kchq5qdpUS3G5sYT')
35-
36-let viresWavesDeposit = "3P8G747fnB1DTQ4d5uD114vjAaeezCW4FaM"
37-
38-let viresUsdnDeposit = "3PCwFXSq8vj8iKitA5zrrLRbuqehfmimpce"
39-
40-let viresEurnDeposit = "3PBjqiMwwag72VWUtHNnVrxTBrNK8D7bVcN"
41-
42-@Callable(i)
43-func init () = {
44- let isInitialized = valueOrElse(getBoolean(this, "initialized"), false)
45- if (if (if ((height >= startBlock))
46- then (targetBlock > height)
47- else false)
48- then !(isInitialized)
49- else false)
50- then {
51- let assetIssue = Issue(("LNSBT_" + toString(targetBlock)), ("Liquid NSBT, target block height: " + toString(targetBlock)), 1, 6, true)
52- let assetId = calculateAssetId(assetIssue)
53- let assetIdString = toBase58String(assetId)
54- $Tuple2([assetIssue, Burn(assetId, 1), StringEntry((("LNSBT_" + toString(targetBlock)) + "_asset_id"), assetIdString), IntegerEntry("initialized_block", height), BooleanEntry("initialized", true)], unit)
55- }
56- else throw("")
57- }
58-
59-
60-
61-@Callable(i)
62-func lockNsbt () = {
63- let isInitialized = valueOrElse(getBoolean(this, "initialized"), false)
64- let validBlock = if ((height >= startBlock))
65- then (targetBlock > height)
66- else false
67- if (if (if (isInitialized)
68- then validBlock
69- else false)
70- then (size(i.payments) == 1)
71- else false)
72- then {
73- let payment = i.payments[0]
74- let availableAmount = (maximumAmount - valueOrElse(getInteger(this, "total_nsbt_lock"), 0))
75- if (if (if ((payment.assetId == nsbtAssetId))
76- then (availableAmount >= payment.amount)
77- else false)
78- then (payment.amount > 0)
79- else false)
80- then {
81- let amount = payment.amount
82- let share = ((targetBlock - height) * amount)
83- let walletPreviousAmount = valueOrElse(getInteger(this, (toString(i.caller) + "_nsbt_lock")), 0)
84- let walletNewAmount = (walletPreviousAmount + amount)
85- let walletPreviousShare = valueOrElse(getInteger(this, (toString(i.caller) + "_share")), 0)
86- let walletNewShare = (walletPreviousShare + share)
87- let previousNsbtLockAmount = valueOrElse(getInteger("total_nsbt_lock"), 0)
88- let newNsbtLockAmount = (previousNsbtLockAmount + amount)
89- let previousTotalShare = valueOrElse(getInteger("total_share"), 0)
90- let newTotalShare = (previousTotalShare + share)
91- let lnsbtAssetId = fromBase58String(getStringValue(this, (("LNSBT_" + toString(targetBlock)) + "_asset_id")))
92- let nsbtLockCall = invoke(neutrinoAddress, "lockNsbt", nil, [AttachedPayment(nsbtAssetId, amount)])
93- if ((nsbtLockCall == nsbtLockCall))
94- then $Tuple2([Reissue(lnsbtAssetId, amount, true), ScriptTransfer(i.caller, amount, lnsbtAssetId), IntegerEntry((toString(i.caller) + "_nsbt_lock"), walletNewAmount), IntegerEntry((toString(i.caller) + "_share"), walletNewShare), IntegerEntry("total_nsbt_lock", newNsbtLockAmount), IntegerEntry("total_share", newTotalShare)], unit)
95- else throw("Strict value is not equal to itself.")
96- }
97- else throw("")
98- }
99- else throw("")
100- }
101-
102-
103-
104-@Callable(i)
105-func stakeWaves () = {
106- let isInitialized = valueOrElse(getBoolean(this, "initialized"), false)
107- let validBlock = if ((height >= startBlock))
108- then (targetBlock > height)
109- else false
110- let accountWavesBalance = wavesBalance(this).regular
111- if (if (if (isInitialized)
112- then validBlock
113- else false)
114- then (accountWavesBalance > 0)
115- else false)
116- then {
117- let wavesStakeCall = invoke(viresAddress, "deposit", [viresWavesDeposit, false], [AttachedPayment(unit, accountWavesBalance)])
118- if ((wavesStakeCall == wavesStakeCall))
119- then {
120- let totalWavesStaked = (valueOrElse(getInteger(this, "total_staked_waves"), 0) + accountWavesBalance)
121- $Tuple2([IntegerEntry("total_staked_waves", totalWavesStaked), ScriptTransfer(i.caller, assetBalance(this, rubnAssetId), rubnAssetId), ScriptTransfer(i.caller, assetBalance(this, cnynAssetId), cnynAssetId), ScriptTransfer(i.caller, assetBalance(this, jpynAssetId), jpynAssetId)], unit)
122- }
123- else throw("Strict value is not equal to itself.")
124- }
125- else throw("")
126- }
127-
128-
129-
130-@Callable(i)
131-func stakeUsdn () = {
132- let isInitialized = valueOrElse(getBoolean(this, "initialized"), false)
133- let validBlock = if ((height >= startBlock))
134- then (targetBlock > height)
135- else false
136- let usdnBalance = assetBalance(this, usdnAssetId)
137- if (if (if (isInitialized)
138- then validBlock
139- else false)
140- then (usdnBalance > 0)
141- else false)
142- then {
143- let usdnStakeCall = invoke(viresAddress, "deposit", [viresUsdnDeposit, false], [AttachedPayment(usdnAssetId, usdnBalance)])
144- if ((usdnStakeCall == usdnStakeCall))
145- then {
146- let totalStakedUsdn = (valueOrElse(getInteger(this, "total_staked_usdn"), 0) + usdnBalance)
147- $Tuple2([IntegerEntry("total_staked_usdn", totalStakedUsdn), ScriptTransfer(i.caller, assetBalance(this, uahnAssetId), uahnAssetId), ScriptTransfer(i.caller, assetBalance(this, brlnAssetId), brlnAssetId)], unit)
148- }
149- else throw("Strict value is not equal to itself.")
150- }
151- else throw("")
152- }
153-
154-
155-
156-@Callable(i)
157-func stakeEurn () = {
158- let isInitialized = valueOrElse(getBoolean(this, "initialized"), false)
159- let validBlock = if ((height >= startBlock))
160- then (targetBlock > height)
161- else false
162- let accountEurnBalance = assetBalance(this, eurnAssetId)
163- if (if (if (isInitialized)
164- then validBlock
165- else false)
166- then (accountEurnBalance > 0)
167- else false)
168- then {
169- let eurnStakeCall = invoke(viresAddress, "deposit", [viresEurnDeposit, false], [AttachedPayment(eurnAssetId, accountEurnBalance)])
170- if ((eurnStakeCall == eurnStakeCall))
171- then {
172- let totalStakedEurn = (valueOrElse(getInteger(this, "total_staked_eurn"), 0) + accountEurnBalance)
173- $Tuple2([IntegerEntry("total_staked_eurn", totalStakedEurn), ScriptTransfer(i.caller, assetBalance(this, gbpnAssetId), gbpnAssetId), ScriptTransfer(i.caller, assetBalance(this, trynAssetId), trynAssetId)], unit)
174- }
175- else throw("Strict value is not equal to itself.")
176- }
177- else throw("")
178- }
179-
180-
181-
182-@Callable(i)
183-func end () = {
184- let isInitialized = valueOrElse(getBoolean(this, "initialized"), false)
185- let isEnded = valueOrElse(getBoolean(this, "ended"), false)
186- let validBlock = (height >= targetBlock)
187- if (if (if (isInitialized)
188- then validBlock
189- else false)
190- then !(isEnded)
191- else false)
192- then {
193- let stakedNsbt = valueOrElse(getInteger(this, "total_nsbt_lock"), 0)
194- let nsbtUnstakeCall = invoke(neutrinoAddress, "unlockNsbt", [stakedNsbt, toBase58String(nsbtAssetId)], nil)
195- if ((nsbtUnstakeCall == nsbtUnstakeCall))
196- then $Tuple2([BooleanEntry("ended", true), IntegerEntry("end_block", height), BooleanEntry("nsbt_unstaked", true)], unit)
197- else throw("Strict value is not equal to itself.")
198- }
199- else throw("")
200- }
201-
202-
203-
204-@Callable(i)
205-func redeemNsbt () = {
206- let isEnded = valueOrElse(getBoolean(this, "ended"), false)
207- let lnsbtAssetId = fromBase58String(getStringValue(this, (("LNSBT_" + toString(targetBlock)) + "_asset_id")))
208- if (if (if (if (isEnded)
209- then (size(i.payments) == 1)
210- else false)
211- then (i.payments[0].amount > 0)
212- else false)
213- then (i.payments[0].assetId == lnsbtAssetId)
214- else false)
215- then {
216- let payment = i.payments[0]
217- let address = toString(i.caller)
218- let walletPreviousRedeemedAmount = valueOrElse(getInteger(this, (address + "_redeemed_nsbt_amount")), 0)
219- let walletNewRedeemedAmount = (walletPreviousRedeemedAmount + payment.amount)
220- let previousRedeemedAmount = valueOrElse(getInteger(this, "total_redeemed_nsbt_amount"), 0)
221- let newRedeemedAmount = (previousRedeemedAmount + payment.amount)
222- $Tuple2([Burn(lnsbtAssetId, payment.amount), ScriptTransfer(i.caller, payment.amount, nsbtAssetId), IntegerEntry("total_redeemed_nsbt_amount", newRedeemedAmount), IntegerEntry((address + "_redeemed_nsbt_amount"), walletNewRedeemedAmount)], unit)
223- }
224- else throw("")
225- }
226-
227-
228-
229-@Callable(i)
230-func unstakeWaves () = {
231- let isEnded = valueOrElse(getBoolean(this, "ended"), false)
232- let isWavesUnstaked = valueOrElse(getBoolean(this, "waves_unstaked"), false)
233- if (if (isEnded)
234- then !(isWavesUnstaked)
235- else false)
236- then {
237- let wavesUnstakeCall = invoke(viresAddress, "withdraw", ["WAVES", -1], nil)
238- if ((wavesUnstakeCall == wavesUnstakeCall))
239- then $Tuple2([BooleanEntry("waves_unstaked", true)], unit)
240- else throw("Strict value is not equal to itself.")
241- }
242- else throw("")
243- }
244-
245-
246-
247-@Callable(i)
248-func unstakeUsdn () = {
249- let isEnded = valueOrElse(getBoolean(this, "ended"), false)
250- let isUsdnUnstaked = valueOrElse(getBoolean(this, "usdn_unstaked"), false)
251- if (if (isEnded)
252- then !(isUsdnUnstaked)
253- else false)
254- then {
255- let usdnUnstakeCall = invoke(viresAddress, "withdraw", [toBase58String(usdnAssetId), -1], nil)
256- if ((usdnUnstakeCall == usdnUnstakeCall))
257- then $Tuple2([BooleanEntry("usdn_unstaked", true)], unit)
258- else throw("Strict value is not equal to itself.")
259- }
260- else throw("")
261- }
262-
263-
264-
265-@Callable(i)
266-func unstakeEurn () = {
267- let isEnded = valueOrElse(getBoolean(this, "ended"), false)
268- let isEurnUnstaked = valueOrElse(getBoolean(this, "eurn_unstaked"), false)
269- if (if (isEnded)
270- then !(isEurnUnstaked)
271- else false)
272- then {
273- let eurnUnstakeCall = invoke(viresAddress, "withdraw", [toBase58String(eurnAssetId), -1], nil)
274- if ((eurnUnstakeCall == eurnUnstakeCall))
275- then $Tuple2([BooleanEntry("eurn_unstaked", true)], unit)
276- else throw("Strict value is not equal to itself.")
277- }
278- else throw("")
279- }
280-
281-
282-
283-@Callable(i)
284-func claimVires () = {
285- let isEnded = valueOrElse(getBoolean(this, "ended"), false)
286- let isWavesUnstaked = valueOrElse(getBoolean(this, "waves_unstaked"), false)
287- let isUsdnUnstaked = valueOrElse(getBoolean(this, "usdn_unstaked"), false)
288- let isEurnUnstaked = valueOrElse(getBoolean(this, "eurn_unstaked"), false)
289- let isViresClaimed = valueOrElse(getBoolean(this, "vires_claimed"), false)
290- if (if (if (if (if (isEnded)
291- then isWavesUnstaked
292- else false)
293- then isUsdnUnstaked
294- else false)
295- then isEurnUnstaked
296- else false)
297- then !(isViresClaimed)
298- else false)
299- then {
300- let viresClaimCall = invoke(viresAddress, "claimAllRewardsAndAllEbAvailable", [false], nil)
301- if ((viresClaimCall == viresClaimCall))
302- then $Tuple2([BooleanEntry("vires_claimed", true)], unit)
303- else throw("Strict value is not equal to itself.")
304- }
305- else throw("")
306- }
307-
308-
309-
310-@Callable(i)
311-func activateClaim () = {
312- let isEnded = valueOrElse(getBoolean(this, "ended"), false)
313- let isWavesUnstaked = valueOrElse(getBoolean(this, "waves_unstaked"), false)
314- let isUsdnUnstaked = valueOrElse(getBoolean(this, "usdn_unstaked"), false)
315- let isEurnUnstaked = valueOrElse(getBoolean(this, "eurn_unstaked"), false)
316- let isViresClaimed = valueOrElse(getBoolean(this, "vires_claimed"), false)
317- let isClaimActive = valueOrElse(getBoolean(this, "claim_active"), false)
318- if (if (if (if (if (if (isEnded)
319- then isWavesUnstaked
320- else false)
321- then isUsdnUnstaked
322- else false)
323- then isEurnUnstaked
324- else false)
325- then isViresClaimed
326- else false)
327- then !(isClaimActive)
328- else false)
329- then {
330- let contractWavesBalance = wavesBalance(this).regular
331- let usdnBalance = assetBalance(this, usdnAssetId)
332- let eurnBalance = assetBalance(this, eurnAssetId)
333- let viresBalance = assetBalance(this, viresAssetId)
334- $Tuple2([BooleanEntry("claim_active", true), IntegerEntry("claimable_waves_balance", contractWavesBalance), IntegerEntry("claimable_usdn_balance", usdnBalance), IntegerEntry("claimable_eurn_balance", eurnBalance), IntegerEntry("claimable_vires_balance", viresBalance), ScriptTransfer(i.caller, assetBalance(this, rubnAssetId), rubnAssetId), ScriptTransfer(i.caller, assetBalance(this, cnynAssetId), cnynAssetId), ScriptTransfer(i.caller, assetBalance(this, jpynAssetId), jpynAssetId), ScriptTransfer(i.caller, assetBalance(this, uahnAssetId), uahnAssetId), ScriptTransfer(i.caller, assetBalance(this, brlnAssetId), brlnAssetId), ScriptTransfer(i.caller, assetBalance(this, gbpnAssetId), gbpnAssetId), ScriptTransfer(i.caller, assetBalance(this, trynAssetId), trynAssetId)], unit)
335- }
336- else throw("")
337- }
338-
339-
340-
341-@Callable(i)
342-func claim () = {
343- let isClaimActive = valueOrElse(getBoolean(this, "claim_active"), false)
344- if (isClaimActive)
345- then {
346- let callerShare = valueOrElse(getInteger(this, (toString(i.caller) + "_share")), 0)
347- let callerClaimed = valueOrElse(getBoolean(this, (toString(i.caller) + "_claimed")), false)
348- if (if ((callerShare > 0))
349- then !(callerClaimed)
350- else false)
351- then {
352- let totalShare = getIntegerValue(this, "total_share")
353- let claimableWavesBalance = getIntegerValue(this, "claimable_waves_balance")
354- let claimableUsdnBalance = getIntegerValue(this, "claimable_usdn_balance")
355- let claimableEurnBalance = getIntegerValue(this, "claimable_eurn_balance")
356- let claimableViresBalance = getIntegerValue(this, "claimable_vires_balance")
357- let callerWavesAmount = fraction(callerShare, claimableWavesBalance, totalShare, CEILING)
358- let callerUsdnAmount = fraction(callerShare, claimableUsdnBalance, totalShare, CEILING)
359- let callerEurnAmount = fraction(callerShare, claimableEurnBalance, totalShare, CEILING)
360- let callerViresAmount = fraction(callerShare, claimableViresBalance, totalShare, CEILING)
361- let totalClaimedWaves = (valueOrElse(getInteger(this, "total_claimed_waves"), 0) + callerWavesAmount)
362- let totalClaimedUsdn = (valueOrElse(getInteger(this, "total_claimed_usdn"), 0) + callerUsdnAmount)
363- let totalClaimedEurn = (valueOrElse(getInteger(this, "total_claimed_eurn"), 0) + callerEurnAmount)
364- let totalClaimedVires = (valueOrElse(getInteger(this, "total_claimed_vires"), 0) + callerViresAmount)
365- $Tuple2([ScriptTransfer(i.caller, callerWavesAmount, unit), IntegerEntry((toString(i.caller) + "_claimed_waves"), callerWavesAmount), ScriptTransfer(i.caller, callerUsdnAmount, usdnAssetId), IntegerEntry((toString(i.caller) + "_claimed_usdn"), callerUsdnAmount), ScriptTransfer(i.caller, callerEurnAmount, eurnAssetId), IntegerEntry((toString(i.caller) + "_claimed_eurn"), callerEurnAmount), ScriptTransfer(i.caller, callerViresAmount, viresAssetId), IntegerEntry((toString(i.caller) + "_claimed_vires"), callerViresAmount), IntegerEntry("total_claimed_waves", totalClaimedWaves), IntegerEntry("total_claimed_usdn", totalClaimedUsdn), IntegerEntry("total_claimed_eurn", totalClaimedEurn), IntegerEntry("total_claimed_vires", totalClaimedVires), BooleanEntry((toString(i.caller) + "_claimed"), true)], unit)
366- }
367- else throw("")
368- }
369- else throw("")
370- }
371-
372-
373-@Verifier(tx)
374-func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
375-
1+# no script

github/deemru/w8io/6500d08 
39.40 ms