tx · DBVc3UGRuiuA1fS9S9QzoJ1JdZEySDWEUg9NWbVzg9tk 3MxnfLmkQdmBHFpvMrtUBZ6oU1BnTHt7wCk: -0.01000000 Waves 2020.09.22 21:07 [1188851] smart account 3MxnfLmkQdmBHFpvMrtUBZ6oU1BnTHt7wCk > SELF 0.00000000 Waves
{ "type": 13, "id": "DBVc3UGRuiuA1fS9S9QzoJ1JdZEySDWEUg9NWbVzg9tk", "fee": 1000000, "feeAssetId": null, "timestamp": 1600798100038, "version": 1, "sender": "3MxnfLmkQdmBHFpvMrtUBZ6oU1BnTHt7wCk", "senderPublicKey": "55rB1q3MKx9sFwZpomq8X1LrY9sSqqHu1uDFDEhhHSWe", "proofs": [ "3KgvP9vVA1yy2mZtkV5tRfekWBcunH2365tf5M4KKKe8wLTW3pkUhi6JkKhVCBWSVo2J952qbUD7iEF688tivq2W" ], "script": "base64:AAIEAAAAAAAAABAIAhIECgIIARIAEgQKAgEIAAAAFwEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQkBAAAAC3ZhbHVlT3JFbHNlAAAAAgkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkAAAAAAAAAAAABAAAADmdldFN0cmluZ0J5S2V5AAAAAQAAAANrZXkJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AgAAAAABAAAADGdldEJvb2xCeUtleQAAAAEAAAADa2V5CQEAAAALdmFsdWVPckVsc2UAAAACCQAEGwAAAAIFAAAABHRoaXMFAAAAA2tleQcBAAAAGGdldE51bWJlckJ5QWRkcmVzc0FuZEtleQAAAAIAAAAHYWRkcmVzcwAAAANrZXkJAQAAAAt2YWx1ZU9yRWxzZQAAAAIJAAQaAAAAAgkBAAAAEUBleHRyTmF0aXZlKDEwNjIpAAAAAQUAAAAHYWRkcmVzcwUAAAADa2V5AAAAAAAAAAAAAQAAABhnZXRTdHJpbmdCeUFkZHJlc3NBbmRLZXkAAAACAAAAB2FkZ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GVnZXJFbnRyeQAAAAIJAQAAABFnZXRVc2VyQmFsYW5jZUtleQAAAAIFAAAAB2FjY291bnQFAAAADWFzc2V0SWRTdHJpbmcFAAAAB2JhbGFuY2UJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAEUBleHRyTmF0aXZlKDEwNjIpAAAAAQUAAAAHYWNjb3VudAUAAAAMdW5sb2NrQW1vdW50BQAAAAdhc3NldElkBQAAAANuaWwAAAAAEKcZYA==", "chainId": 84, "height": 1188851, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: Fmb2N7vrr8LSKUmSbPFvVfAZ9MiqHG45nvgAppmWZ88w Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 4 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | func getNumberByKey (key) = valueOrElse(getInteger(this, key), 0) | |
5 | + | ||
6 | + | ||
7 | + | func getStringByKey (key) = valueOrElse(getString(this, key), "") | |
8 | + | ||
9 | + | ||
10 | + | func getBoolByKey (key) = valueOrElse(getBoolean(this, key), false) | |
11 | + | ||
12 | + | ||
13 | + | func getNumberByAddressAndKey (address,key) = valueOrElse(getInteger(addressFromStringValue(address), key), 0) | |
14 | + | ||
15 | + | ||
16 | + | func getStringByAddressAndKey (address,key) = valueOrElse(getString(address, key), "") | |
17 | + | ||
18 | + | ||
19 | + | let separator = "__" | |
20 | + | ||
21 | + | let factoryContractAddressKey = (("%s" + separator) + "factory") | |
22 | + | ||
23 | + | let keyAssetStatus = 3 | |
24 | + | ||
25 | + | func getStakingAssetBalanceKey (assetId) = (((("%s%s" + separator) + "stakingBalance") + separator) + assetId) | |
26 | + | ||
27 | + | ||
28 | + | func getUserBalanceKey (owner,assetId) = (((((("%s%s%s" + separator) + "stakingBalance") + separator) + assetId) + separator) + owner) | |
29 | + | ||
30 | + | ||
31 | + | func getAssetConfigKey (assetAddress) = (((("%s%s" + separator) + "defoAsset") + separator) + assetAddress) | |
32 | + | ||
33 | + | ||
34 | + | func getRewardsConfigKey (owner,share,receiver) = (((((((("%s%s%s%s" + separator) + "stakingConfig") + separator) + owner) + separator) + toString(share)) + separator) + receiver) | |
35 | + | ||
36 | + | ||
37 | + | func getCurrentRewardsConfigKey (owner) = (((("%s%s" + separator) + "stakingConfigCurrent") + separator) + owner) | |
38 | + | ||
39 | + | ||
40 | + | func getRewardsConfigStartKey (configKey,isStart) = (configKey + (if (isStart) | |
41 | + | then (separator + "start") | |
42 | + | else (separator + "end"))) | |
43 | + | ||
44 | + | ||
45 | + | func getRewardConfigInitialShare (owner) = (((("%s%s" + separator) + owner) + separator) + "initialShare") | |
46 | + | ||
47 | + | ||
48 | + | func getAssetAddressByAssetIdKey (assetId) = (((((("%s%s%s" + separator) + "defoAssetId") + separator) + assetId) + separator) + "contract") | |
49 | + | ||
50 | + | ||
51 | + | func convertJsonArrayToList (jsonArray,splitSymbol) = split(jsonArray, splitSymbol) | |
52 | + | ||
53 | + | ||
54 | + | let factoryContract = addressFromStringValue(valueOrErrorMessage(getString(this, factoryContractAddressKey), "No factory contract specified.")) | |
55 | + | ||
56 | + | func getUserBalance (owner,assetId) = getNumberByKey(getUserBalanceKey(owner, assetId)) | |
57 | + | ||
58 | + | ||
59 | + | func getStakingAssetBalance (assetId) = getNumberByKey(getStakingAssetBalanceKey(assetId)) | |
60 | + | ||
61 | + | ||
62 | + | func getSyntheticContractByAssetId (assetId) = getString(factoryContract, getAssetAddressByAssetIdKey(assetId)) | |
63 | + | ||
64 | + | ||
65 | + | func getAssetConfigArray (assetAddress) = convertJsonArrayToList(valueOrErrorMessage(getStringByAddressAndKey(factoryContract, getAssetConfigKey(assetAddress)), (("No DEFO Asset " + assetAddress) + "config present")), separator) | |
66 | + | ||
67 | + | ||
68 | + | func internallock (i,receiver,share) = { | |
69 | + | let pmt = valueOrErrorMessage(i.payments[0], "No asset pased in payment.") | |
70 | + | let assetIdString = toBase58String(value(pmt.assetId)) | |
71 | + | let syntheticAssetContract = valueOrErrorMessage(getSyntheticContractByAssetId(assetIdString), "Passed payment asset is not valid.") | |
72 | + | let syntheticAssetConfig = getAssetConfigArray(syntheticAssetContract) | |
73 | + | if (!(isDefined(addressFromString(receiver)))) | |
74 | + | then throw(("Invalid address format " + receiver)) | |
75 | + | else if ((share > 100)) | |
76 | + | then throw("staking rewards share cannot be higher than 100%") | |
77 | + | else if ((1 > share)) | |
78 | + | then throw("staking rewards share cannot be lower than 1%") | |
79 | + | else if ((syntheticAssetConfig[keyAssetStatus] != "ISSUED")) | |
80 | + | then throw("Synthetic asset should be with ISSUED status") | |
81 | + | else { | |
82 | + | let account = toString(i.caller) | |
83 | + | let currentConfig = getStringByKey(getCurrentRewardsConfigKey(account)) | |
84 | + | let correctData = if ((currentConfig != "")) | |
85 | + | then { | |
86 | + | let currentConfigData = split(currentConfig, separator) | |
87 | + | let currShare = parseIntValue(currentConfigData[3]) | |
88 | + | let currReceiver = currentConfigData[4] | |
89 | + | let notMigratedInitialShare = getNumberByKey(getRewardConfigInitialShare(account)) | |
90 | + | let actualInitialShare = if ((notMigratedInitialShare == 0)) | |
91 | + | then currShare | |
92 | + | else notMigratedInitialShare | |
93 | + | let newShare = if (if ((actualInitialShare > share)) | |
94 | + | then true | |
95 | + | else (currReceiver != receiver)) | |
96 | + | then actualInitialShare | |
97 | + | else share | |
98 | + | [toString(actualInitialShare), toString(newShare), currReceiver] | |
99 | + | } | |
100 | + | else [toString(share), toString(share), receiver] | |
101 | + | let correctInitialShare = parseIntValue(correctData[0]) | |
102 | + | let correctShare = parseIntValue(correctData[1]) | |
103 | + | let correctReceiver = correctData[2] | |
104 | + | let newCurrentConfig = getRewardsConfigKey(account, correctShare, correctReceiver) | |
105 | + | let isNewConfig = !((currentConfig == newCurrentConfig)) | |
106 | + | let end = if (isNewConfig) | |
107 | + | then height | |
108 | + | else 0 | |
109 | + | let start = if (isNewConfig) | |
110 | + | then height | |
111 | + | else getNumberByKey(getRewardsConfigStartKey(newCurrentConfig, true)) | |
112 | + | [IntegerEntry(getStakingAssetBalanceKey(assetIdString), (getStakingAssetBalance(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)] | |
113 | + | } | |
114 | + | } | |
115 | + | ||
116 | + | ||
117 | + | @Callable(i) | |
118 | + | func startStakingSP (receiver,share) = internallock(i, receiver, share) | |
119 | + | ||
120 | + | ||
121 | + | ||
122 | + | @Callable(i) | |
123 | + | func startStaking () = internallock(i, toString(i.caller), 100) | |
124 | + | ||
125 | + | ||
126 | + | ||
127 | + | @Callable(i) | |
128 | + | func stopStaking (unlockAmount,assetIdString) = { | |
129 | + | let account = toString(i.caller) | |
130 | + | let assetId = fromBase58String(assetIdString) | |
131 | + | let syntheticAssetContract = valueOrErrorMessage(getSyntheticContractByAssetId(assetIdString), "Passed payment asset is not valid.") | |
132 | + | let syntheticAssetConfig = getAssetConfigArray(syntheticAssetContract) | |
133 | + | let balance = (getUserBalance(account, assetIdString) - unlockAmount) | |
134 | + | if ((0 > balance)) | |
135 | + | then throw("invalid amount") | |
136 | + | else if ((syntheticAssetConfig[keyAssetStatus] != "ISSUED")) | |
137 | + | then throw("Synthetic asset should be with ISSUED status") | |
138 | + | else [IntegerEntry(getStakingAssetBalanceKey(assetIdString), (getStakingAssetBalance(assetIdString) - unlockAmount)), IntegerEntry(getUserBalanceKey(account, assetIdString), balance), ScriptTransfer(addressFromStringValue(account), unlockAmount, assetId)] | |
139 | + | } | |
140 | + | ||
141 | + |
github/deemru/w8io/169f3d6 23.40 ms ◑