tx · 2EtLNkU94tRNb1e4b2V8JKFWfGcGKgV1vuxLQo5PFZrb

3N7cpB3gLp1VwFPqYcoAW17HJabmVY2LyQi:  -0.00400000 Waves

2024.11.04 14:45 [3356691] smart account 3N7cpB3gLp1VwFPqYcoAW17HJabmVY2LyQi > SELF 0.00000000 Waves

{ "type": 13, "id": "2EtLNkU94tRNb1e4b2V8JKFWfGcGKgV1vuxLQo5PFZrb", "fee": 400000, "feeAssetId": null, "timestamp": 1730720833150, "version": 2, "chainId": 84, "sender": "3N7cpB3gLp1VwFPqYcoAW17HJabmVY2LyQi", "senderPublicKey": "GXBpVcVJAC2qR8gUieH65SreStheBpEcANqkWZqMCVp3", "proofs": [ "2C6MXHiXAshRhKFnboQEAvPAhn6hQPxHNmTttC898D4DGDMx97rs6X7vDcNiBy7UCCLCtkwv2VeZjdVxWTw5TNis" ], "script": "base64:BgIWCAISABIDCgEBEgQKAggBEgMKAQgSABUBEHdyaXRlQ29uc3RTdHJpbmcCA2tleQV2YWx1ZQMJAQEhAQkBCWlzRGVmaW5lZAEJAJ0IAgUEdGhpcwUDa2V5CQELU3RyaW5nRW50cnkCBQNrZXkFBXZhbHVlCQACAQkArAICAhVhbHJlYWR5IGluaXRpYWxpemVkOiAFA2tleQEId3JpdGVJbnQCA2tleQV2YWx1ZQMJAGYCAAAFBXZhbHVlCQACAQkArAICCQCsAgIJAKwCAgIXd3JpdGluZyBuZWdhdGl2ZSB2YWx1ZSAJAKQDAQUFdmFsdWUCCSBmb3Iga2V5IAUDa2V5CQEMSW50ZWdlckVudHJ5AgUDa2V5BQV2YWx1ZQEIY2hhbmdlQnkCA2tleQV2YWx1ZQkBCHdyaXRlSW50AgUDa2V5CQBkAgkBC3ZhbHVlT3JFbHNlAgkAmggCBQR0aGlzBQNrZXkAAAUFdmFsdWUAEmNvbmZpZ0FkZHJlc3NTdG9yZQIGY29uZmlnAAZjb25maWcJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkApggBCQETdmFsdWVPckV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CBQZjb25maWcJAQ5vcEFsbG93ZWRTdG9yZQECGHNlbGZfZ292ZXJuYW5jZV9hcHBseV90eAYDCQEBIQEFB2VuYWJsZWQJAAIBAit0eCBhcHBsaWNhdGlvbiB0aHJvdyBnb3Zlcm5hbmNlIG5vdCBlbmFibGVkBAJpZAkA2AQBCAUCdHgCaWQEDXZvdGluZ1Jlc3VsdHMJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkApggBCQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJ0IAgUGY29uZmlnAhZjb250cmFjdF92b3RpbmdfcmVzdWx0AiJzdGFraW5nOiBubyBjb250cmFjdF92b3RpbmdfcmVzdWx0Ah5pbnZhbGlkIGNvbnRyYWN0X3ZvdGluZ19yZXN1bHQJAGcCBQZoZWlnaHQJARFAZXh0ck5hdGl2ZSgxMDUwKQIFDXZvdGluZ1Jlc3VsdHMJAKwCAgkArAICCQCsAgICGXByb3Bvc2FsX2FsbG93X2Jyb2FkY2FzdF8JAKUIAQUEdGhpcwIBXwUCaWRKfsdm", "height": 3356691, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 6 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+func writeConstString (key,value) = if (!(isDefined(getString(this, key))))
5+ then StringEntry(key, value)
6+ else throw(("already initialized: " + key))
7+
8+
9+func writeInt (key,value) = if ((0 > value))
10+ then throw(((("writing negative value " + toString(value)) + " for key ") + key))
11+ else IntegerEntry(key, value)
12+
13+
14+func changeBy (key,value) = writeInt(key, (valueOrElse(getInteger(this, key), 0) + value))
15+
16+
17+let configAddressStore = "config"
18+
19+let config = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(this, configAddressStore), "config address not found")), "invalid config address")
20+
21+let voting = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(config, "contract_voting"), "contract_voting not set")), "invalid contract_voting address")
22+
23+func allowed (op) = invoke(config, "opAllowed", [op], nil)
24+
25+
26+let unitsAssetIdStr = valueOrErrorMessage(getString(config, "units_asset"), "units_asset not found")
27+
28+let unitsAssetId = fromBase58String(unitsAssetIdStr)
29+
30+let stakingAddressesStore = "stakingAddresses"
31+
32+let stakingAddresses = valueOrElse(getString(config, stakingAddressesStore), "")
33+
34+func stakedStore (address) = ("staked_" + address)
35+
36+
37+func lockBlock (address) = ("block_lock_" + address)
38+
39+
40+func unlockBlock (address) = ("block_unlock_" + address)
41+
42+
43+func staked (address) = valueOrElse(getInteger(this, stakedStore(address)), 0)
44+
45+
46+let totalStakedStore = "staked_total"
47+
48+let totalStaked = valueOrElse(getInteger(this, totalStakedStore), 0)
49+
50+let minLockTime = valueOrErrorMessage(getInteger(config, (toString(this) + "_min_lock_blocks")), "_min_lock_blocks not set")
51+
52+let HEIGHT = height
53+
54+func advise () = ((("height: " + toString(HEIGHT)) + ", total_staked: ") + toString(totalStaked))
55+
56+
57+func adviseUser (account) = {
58+ let userStaked = staked(account)
59+ (((((("height: " + toString(HEIGHT)) + ", account: ") + account) + ", staked: ") + toString(userStaked)) + (if ((userStaked == 0))
60+ then ", lock_block: -1, unlock_block: -1"
61+ else (((", lock_block: " + toString(getIntegerValue(lockBlock(account)))) + ", unlock_block: ") + toString(getIntegerValue(unlockBlock(account))))))
62+ }
63+
64+
65+@Callable(i)
66+func stake () = {
67+ let a = allowed("stake")
68+ if ((a == a))
69+ then if ((size(i.payments) != 1))
70+ then throw("single payment is allowed")
71+ else if ((i.payments[0].assetId != unitsAssetId))
72+ then throw("invalid payment asset")
73+ else {
74+ let user = toString(i.caller)
75+ let userStaked = stakedStore(user)
76+ let additionalStake = i.payments[0].amount
77+ let currentUnlock = valueOrElse(getInteger(unlockBlock(user)), 0)
78+ let unlock = (HEIGHT + minLockTime)
79+ ([changeBy(userStaked, additionalStake), IntegerEntry(lockBlock(user), HEIGHT), changeBy(totalStakedStore, additionalStake)] ++ (if ((currentUnlock >= unlock))
80+ then nil
81+ else [IntegerEntry(unlockBlock(user), unlock)]))
82+ }
83+ else throw("Strict value is not equal to itself.")
84+ }
85+
86+
87+
88+@Callable(i)
89+func unstake (amount) = {
90+ let a = allowed("unstake")
91+ if ((a == a))
92+ then if ((0 >= amount))
93+ then throw("amount should be positive")
94+ else {
95+ let user = toString(i.caller)
96+ let userStaked = stakedStore(user)
97+ let stakedAmount = getIntegerValue(this, userStaked)
98+ if ((0 >= stakedAmount))
99+ then throw("nothing staked")
100+ else {
101+ let unlockHeight = getIntegerValue(unlockBlock(user))
102+ if ((unlockHeight > HEIGHT))
103+ then throw(("locked till block " + toString(unlockHeight)))
104+ else ([changeBy(totalStakedStore, -(amount)), ScriptTransfer(i.caller, amount, unitsAssetId)] ++ (if ((stakedAmount == amount))
105+ then [DeleteEntry(userStaked), DeleteEntry(lockBlock(user)), DeleteEntry(unlockBlock(user))]
106+ else [changeBy(userStaked, -(amount))]))
107+ }
108+ }
109+ else throw("Strict value is not equal to itself.")
110+ }
111+
112+
113+
114+@Callable(i)
115+func lockFor (address,unlock) = if ((i.caller != voting))
116+ then throw("denied")
117+ else {
118+ let currentUnlock = valueOrElse(getInteger(unlockBlock(address)), 0)
119+ if ((currentUnlock >= unlock))
120+ then nil
121+ else [IntegerEntry(unlockBlock(address), unlock)]
122+ }
123+
124+
125+
126+@Callable(i)
127+func userStake (address) = $Tuple2(nil, staked(address))
128+
129+
130+
131+@Callable(i)
132+func totalStake () = $Tuple2(nil, totalStaked)
133+
134+
135+@Verifier(tx)
136+func verify () = {
137+ func opAllowedStore (op) = (("op_" + op) + "_allowed")
138+
139+ let enabled = valueOrElse(getBoolean(config, opAllowedStore("self_governance_apply_tx")), true)
140+ if (!(enabled))
141+ then throw("tx application throw governance not enabled")
142+ else {
143+ let id = toBase58String(tx.id)
144+ let votingResults = valueOrErrorMessage(addressFromString(valueOrErrorMessage(getString(config, "contract_voting_result"), "staking: no contract_voting_result")), "invalid contract_voting_result")
145+ (height >= getIntegerValue(votingResults, ((("proposal_allow_broadcast_" + toString(this)) + "_") + id)))
146+ }
147+ }
148+

github/deemru/w8io/026f985 
15.69 ms