tx · 58zjRREcNt9CTGG6p5JLrq8AniaXRtnFGsfWyVtAt6Gz

3N6q7sCGSSLBUXDdjBdYGTJbZGZfhhh8cNg:  -0.01000000 Waves

2021.04.02 16:02 [1464857] smart account 3N6q7sCGSSLBUXDdjBdYGTJbZGZfhhh8cNg > SELF 0.00000000 Waves

{ "type": 13, "id": "58zjRREcNt9CTGG6p5JLrq8AniaXRtnFGsfWyVtAt6Gz", "fee": 1000000, "feeAssetId": null, "timestamp": 1617368606717, "version": 2, "chainId": 84, "sender": "3N6q7sCGSSLBUXDdjBdYGTJbZGZfhhh8cNg", "senderPublicKey": "6RxCbWeRD4VWkRJtcAR8HBRkrBbEzZWucSBL6YrSFQrE", "proofs": [ "3nYVDTgZ5PMYMLFMK22wEFEpTRjBUKj28AL11sEU1hurCtQCEPVXHRfNRshjN9k996yufNb9qVaHeTXLXz8YtQyK" ], "script": "base64:AAIEAAAAAAAAAAIIAgAAABMAAAAAD25ldXRyaW5vQXNzZXRJZAEAAAAgbySjyqsw3FIpmOgsYVruWn8jTcItdbvpnapU4NLQB8EAAAAAC25zYnRBc3NldElkAQAAACAfMcqomheEmok3YjT1FeDjokifQYVi6vQeAO1aIhqpJAAAAAATTmV1dHJpbm9Db250cmFjdEtleQEAAAAaAVS5ic3PR3G6l3LsuEUPM7CqSYXRDXgyAm0AAAAACFVTRE5UWVBFAgAAAARVU0ROAAAAAAhOU0JUVFlQRQIAAAAETlNCVAAAAAAKQmFsYW5jZUtleQIAAAALcnBkX2JhbGFuY2UBAAAAEWdldFVzZXJCYWxhbmNlS2V5AAAAAgAAAAVvd25lcgAAAAdhc3NldElkCQAEuQAAAAIJAARMAAAAAgUAAAAKQmFsYW5jZUtleQkABEwAAAACBQAAAAdhc3NldElkCQAETAAAAAIFAAAABW93bmVyBQAAAANuaWwCAAAAAV8BAAAADmdldFN0cmluZ0J5S2V5AAAAAQAAAANrZXkJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQdAAAAAgUAAAAEdGhp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GVnZXJFbnRyeQAAAAIJAQAAABVnZXRDb250cmFjdEJhbGFuY2VLZXkAAAABBQAAAA1hc3NldElkU3RyaW5nCQAAZAAAAAIJAQAAABJnZXRDb250cmFjdEJhbGFuY2UAAAABBQAAAA1hc3NldElkU3RyaW5nCAUAAAADcG10AAAABmFtb3VudAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAEWdldFVzZXJCYWxhbmNlS2V5AAAAAgUAAAAHYWNjb3VudAUAAAANYXNzZXRJZFN0cmluZwkAAGQAAAACCQEAAAAOZ2V0VXNlckJhbGFuY2UAAAACBQAAAAdhY2NvdW50BQAAAA1hc3NldElkU3RyaW5nCAUAAAADcG10AAAABmFtb3VudAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAGGdldFJld2FyZHNDb25maWdTdGFydEtleQAAAAIFAAAADWN1cnJlbnRDb25maWcHBQAAAANlbmQJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAABhnZXRSZXdhcmRzQ29uZmlnU3RhcnRLZXkAAAACBQAAABBuZXdDdXJyZW50Q29uZmlnBgUAAAAFc3RhcnQJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAABtnZXRSZXdhcmRDb25maWdJbml0aWFsU2hhcmUAAAABBQAAAAdhY2NvdW50BQAAABNjb3JyZWN0SW5pdGlhbFNoYXJlCQAETAAAAAIJAQAAAAtTdHJpbmdFbnRyeQAAAAIJAQAAABpnZXRDdXJyZW50UmV3YXJkc0NvbmZpZ0tleQAAAAEFAAAAB2FjY291bnQFAAAAEG5ld0N1cnJlbnRDb25maWcFAAAAA25pbAAAAAAAAAAAZDiu4w==", "height": 1464857, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 8NWqnMqxqwuYUBfiu5kUMQkCpvLrEHx3AtZehYq2Z4J5 Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 4 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let neutrinoAssetId = base58'8UrfDVd5GreeUwm7uPk7eYz1eMv376kzR52C6sANPkwS'
5+
6+let nsbtAssetId = base58'36mg8NZTaFRDygiVwb8uBnLR51hetJruUCZcxhaVcHj9'
7+
8+let NeutrinoContractKey = base58'3N6q7sCGSSLBUXDdjBdYGTJbZGZfhhh8cNg'
9+
10+let USDNTYPE = "USDN"
11+
12+let NSBTTYPE = "NSBT"
13+
14+let BalanceKey = "rpd_balance"
15+
16+func getUserBalanceKey (owner,assetId) = makeString([BalanceKey, assetId, owner], "_")
17+
18+
19+func getStringByKey (key) = valueOrElse(getString(this, key), "")
20+
21+
22+func getNumberByKey (key) = valueOrElse(getInteger(this, key), 0)
23+
24+
25+func getRewardConfigInitialShare (owner) = (owner + "_initialShare")
26+
27+
28+func getRewardsConfigKey (owner,share,receiver) = makeString(["stakingconfig", owner, toString(share), receiver], "_")
29+
30+
31+func getUserBalance (owner,assetId) = getNumberByKey(getUserBalanceKey(owner, assetId))
32+
33+
34+func getValidStakingAssetOrFail (stakingType,assetId) = if (if ((stakingType == USDNTYPE))
35+ then (assetId != neutrinoAssetId)
36+ else false)
37+ then throw("can use USDN only")
38+ else if (if ((stakingType == NSBTTYPE))
39+ then (assetId != nsbtAssetId)
40+ else false)
41+ then throw("can use NSBT only")
42+ else if (if ((stakingType != USDNTYPE))
43+ then (stakingType != NSBTTYPE)
44+ else false)
45+ then throw(("unsupported staking type " + stakingType))
46+ else assetId
47+
48+
49+func getCurrentRewardsConfigKey (owner) = ("stakingconfig_current_" + owner)
50+
51+
52+func getRewardsConfigStartKey (configKey,isStart) = (configKey + (if (isStart)
53+ then "_start"
54+ else "_end"))
55+
56+
57+func getContractBalanceKey (assetId) = ((BalanceKey + "_") + assetId)
58+
59+
60+func getContractBalance (assetId) = getNumberByKey(getContractBalanceKey(assetId))
61+
62+
63+func internalUnlock (stakingType,i,unlockAmount,assetIdParam) = {
64+ let account = toString(i.caller)
65+ let assetId = getValidStakingAssetOrFail(stakingType, fromBase58String(assetIdParam))
66+ let assetIdString = toBase58String(assetId)
67+ let balance = (getUserBalance(account, assetIdString) - unlockAmount)
68+ if ((0 > balance))
69+ then throw("invalid amount")
70+ else [IntegerEntry(getContractBalanceKey(assetIdString), (getContractBalance(assetIdString) - unlockAmount)), IntegerEntry(getUserBalanceKey(account, assetIdString), balance), ScriptTransfer(addressFromStringValue(account), unlockAmount, assetId)]
71+ }
72+
73+
74+func internalLockNeutrino (stakingType,i,receiver,share) = {
75+ let pmt = value(i.payments[0])
76+ let assetId = getValidStakingAssetOrFail(stakingType, value(pmt.assetId))
77+ if (!(isDefined(addressFromString(receiver))))
78+ then throw(("Invalid address format " + receiver))
79+ else if ((share > 100))
80+ then throw("staking rewards share cannot be higher than 100%")
81+ else if ((1 > share))
82+ then throw("staking rewards share cannot be lower than 1%")
83+ else {
84+ let account = toString(i.caller)
85+ let assetIdString = toBase58String(assetId)
86+ let currentConfig = getStringByKey(getCurrentRewardsConfigKey(account))
87+ let correctData = if ((currentConfig != ""))
88+ then {
89+ let currentConfigData = split(currentConfig, "_")
90+ let currShare = parseIntValue(currentConfigData[2])
91+ let currReceiver = currentConfigData[3]
92+ let notMigratedInitialShare = getNumberByKey(getRewardConfigInitialShare(account))
93+ let actualInitialShare = if ((notMigratedInitialShare == 0))
94+ then currShare
95+ else notMigratedInitialShare
96+ let newShare = if (if ((actualInitialShare > share))
97+ then true
98+ else (currReceiver != receiver))
99+ then actualInitialShare
100+ else share
101+[toString(actualInitialShare), toString(newShare), currReceiver]
102+ }
103+ else [toString(share), toString(share), receiver]
104+ let correctInitialShare = parseIntValue(correctData[0])
105+ let correctShare = parseIntValue(correctData[1])
106+ let correctReceiver = correctData[2]
107+ let newCurrentConfig = getRewardsConfigKey(account, correctShare, correctReceiver)
108+ let isNewConfig = !((currentConfig == newCurrentConfig))
109+ let end = if (isNewConfig)
110+ then height
111+ else 0
112+ let start = if (isNewConfig)
113+ then height
114+ else getNumberByKey(getRewardsConfigStartKey(newCurrentConfig, true))
115+[IntegerEntry(getContractBalanceKey(assetIdString), (getContractBalance(assetIdString) + pmt.amount)), IntegerEntry(getUserBalanceKey(account, assetIdString), (getUserBalance(account, assetIdString) + pmt.amount)), IntegerEntry(getRewardsConfigStartKey(currentConfig, false), end), IntegerEntry(getRewardsConfigStartKey(newCurrentConfig, true), start), IntegerEntry(getRewardConfigInitialShare(account), correctInitialShare), StringEntry(getCurrentRewardsConfigKey(account), newCurrentConfig)]
116+ }
117+ }
118+
119+
120+

github/deemru/w8io/026f985 
18.07 ms