tx · BNTmFe1gxhB7dFTPouzucf7hfw552fVJ1i7BpTZ6L4AY 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h: -0.01100000 Waves 2024.02.05 17:04 [2963056] smart account 3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h > SELF 0.00000000 Waves
{ "type": 13, "id": "BNTmFe1gxhB7dFTPouzucf7hfw552fVJ1i7BpTZ6L4AY", "fee": 1100000, "feeAssetId": null, "timestamp": 1707141934661, "version": 2, "chainId": 84, "sender": "3NCWFHDzdPHZC6636ZkMLNDup9mjpbTLs7h", "senderPublicKey": "3z8Q6Zu3KppVmn6fJJvrLc1Wo3krVHSvfaNcerm82md2", "proofs": [ "5kDGJMgsTrgS9LLZAJrW6zHp515ADFYKBeKaSkNaC4CGHmMrEu6xuqaQ2n6ZWRBYqAX2fzBdiHjMXpWzFy3h4Eip" ], "script": "base64:BgIoCAISAwoBARIDCgEIEgQKAggIEgMKAQgSBAoCCAESBAoCCAESAwoBASIADGNvbnRyYWN0RmlsZQIRbDJtcF9sZWFzaW5nLnJpZGUAA1NFUAICX18ABnNjYWxlOACAwtcvAQh0aHJvd0VycgEDbXNnCQACAQkArAICCQCsAgIFDGNvbnRyYWN0RmlsZQICOiAFA21zZwAKa2V5QXNzZXRJZAkAuQkCCQDMCAICAiVzCQDMCAICB2Fzc2V0SWQFA25pbAUDU0VQABFrZXlQZXJpb2RPZmZzZXRJZAkAuQkCCQDMCAICAiVzCQDMCAICCG9mZnNldElkBQNuaWwFA1NFUAAVa2V5UGVyaW9kT2Zmc2V0SGVpZ2h0CQC5CQIJAMwIAgICJXMJAMwIAgIMb2Zmc2V0SGVpZ2h0BQNuaWwFA1NFUAAPa2V5UGVyaW9kTGVuZ3RoCQC5CQIJAMwIAgICJXMJAMwIAgIMcGVyaW9kTGVuZ3RoBQNuaWwFA1NFUAAOcGVyaW9kT2Zmc2V0SWQJAQt2YWx1ZU9yRWxzZQIJAJoIAgUEdGhpcwURa2V5UGVyaW9k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Q2xhaW0FCG5vZGVMaXN0AWkBCHN0YWtlRm9yAgtub2RlQWRkcmVzcwt1c2VyQWRkcmVzcwkBD2dldFN0YWtlQWN0aW9ucwMFC25vZGVBZGRyZXNzBQt1c2VyQWRkcmVzcwUBaQFpAQVzdGFrZQELbm9kZUFkZHJlc3MEC3VzZXJBZGRyZXNzCQClCAEIBQFpBmNhbGxlcgkBD2dldFN0YWtlQWN0aW9ucwMFC25vZGVBZGRyZXNzBQt1c2VyQWRkcmVzcwUBaQFpARFzdGFrZUZyb21VbmxvY2tlZAILbm9kZUFkZHJlc3MGYW1vdW50BAt1c2VyQWRkcmVzcwkApQgBCAUBaQZjYWxsZXIJARtnZXRTdGFrZUZyb21VbmxvY2tlZEFjdGlvbnMDBQtub2RlQWRkcmVzcwULdXNlckFkZHJlc3MFBmFtb3VudAFpAQd1bnN0YWtlAgtub2RlQWRkcmVzcwZhbW91bnQEC3VzZXJBZGRyZXNzCQClCAEIBQFpBmNhbGxlcgkBEWdldFVuc3Rha2VBY3Rpb25zAwULbm9kZUFkZHJlc3MFC3VzZXJBZGRyZXNzBQZhbW91bnQBaQEFY2xhaW0BBmFtb3VudAQLdXNlckFkZHJlc3MJAKUIAQgFAWkGY2FsbGVyCQEXZ2V0Q2xhaW1VbmxvY2tlZEFjdGlvbnMCBQt1c2VyQWRkcmVzcwUGYW1vdW50ACN5g00=", "height": 2963056, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GXqANHgwu7bmDdDXLT2WC9P85qgcbpcrh7RaLaWsYLkF Next: 6aEtkic7w2kjoqE2KDr9ihPFQHfxwFKF9L5D11sWxXGK Diff:
Old | New | Differences | |
---|---|---|---|
177 | 177 | let toUnlock = $t058645936._3 | |
178 | 178 | let toClaim = $t058645936._4 | |
179 | 179 | let newLeased = (leased + userLeasingAmount) | |
180 | - | [getLeasingNodeEntry(nodeAddress, newTotalLease), getUserLeasingEntry(nodeAddress, userAddress, newUserTotalLease), getUserBalancesEntry(userAddress, | |
180 | + | [getLeasingNodeEntry(nodeAddress, newTotalLease), getUserLeasingEntry(nodeAddress, userAddress, newUserTotalLease), getUserBalancesEntry(userAddress, periodId, newLeased, toUnlock, toClaim), getUserNodeListEntry(userAddress, addNodeToNodeList(userAddress, nodeAddress))] | |
181 | 181 | } | |
182 | 182 | else throw("Strict value is not equal to itself.") | |
183 | 183 | } | |
201 | 201 | then { | |
202 | 202 | let newTotalLease = (totalNodeLeased - unstakeAmount) | |
203 | 203 | let newUserTotalLease = (userTotalLeased - unstakeAmount) | |
204 | - | let $ | |
205 | - | let periodId = $ | |
206 | - | let leased = $ | |
207 | - | let toUnlock = $ | |
208 | - | let toClaim = $ | |
204 | + | let $t072127284 = getUserBalances(userAddress) | |
205 | + | let periodId = $t072127284._1 | |
206 | + | let leased = $t072127284._2 | |
207 | + | let toUnlock = $t072127284._3 | |
208 | + | let toClaim = $t072127284._4 | |
209 | 209 | let newLeased = (leased - unstakeAmount) | |
210 | 210 | let newToUnlock = (toUnlock + unstakeAmount) | |
211 | 211 | let removeNodeActions = if ((newUserTotalLease == 0)) | |
218 | 218 | ||
219 | 219 | ||
220 | 220 | func getClaimUnlockedActions (userAddress,claimAmount) = { | |
221 | - | let $ | |
222 | - | let periodId = $ | |
223 | - | let leased = $ | |
224 | - | let toUnlock = $ | |
225 | - | let toClaim = $ | |
221 | + | let $t078857957 = getUserBalances(userAddress) | |
222 | + | let periodId = $t078857957._1 | |
223 | + | let leased = $t078857957._2 | |
224 | + | let toUnlock = $t078857957._3 | |
225 | + | let toClaim = $t078857957._4 | |
226 | 226 | let checks = [if ((claimAmount > 0)) | |
227 | 227 | then true | |
228 | 228 | else throwErr("claim amount should be greater than 0"), if ((toClaim >= claimAmount)) | |
234 | 234 | then { | |
235 | 235 | let newToClaim = (toClaim - claimAmount) | |
236 | 236 | [getUserBalancesEntry(userAddress, currentPeriodId, leased, toUnlock, newToClaim)] | |
237 | + | } | |
238 | + | else throw("Strict value is not equal to itself.") | |
239 | + | } | |
240 | + | ||
241 | + | ||
242 | + | func getStakeFromUnlockedActions (nodeAddress,userAddress,userLeasingAmount) = { | |
243 | + | let $t085348606 = getUserBalances(userAddress) | |
244 | + | let periodId = $t085348606._1 | |
245 | + | let leased = $t085348606._2 | |
246 | + | let toUnlock = $t085348606._3 | |
247 | + | let toClaim = $t085348606._4 | |
248 | + | let available = (toUnlock + toClaim) | |
249 | + | let checks = [if ((userLeasingAmount > 0)) | |
250 | + | then true | |
251 | + | else throwErr("amount should be greater than 0"), if ((available >= userLeasingAmount)) | |
252 | + | then true | |
253 | + | else throwErr("amount should be less or equal to available"), if (isValidAddress(nodeAddress)) | |
254 | + | then true | |
255 | + | else throwErr(makeString(["node address is not valid:", nodeAddress], " ")), if (isValidAddress(userAddress)) | |
256 | + | then true | |
257 | + | else throwErr(makeString(["user address is not valid:", userAddress], " "))] | |
258 | + | if ((checks == checks)) | |
259 | + | then { | |
260 | + | let totalNodeLeased = getLeasingNodeData(nodeAddress) | |
261 | + | let newTotalLease = (totalNodeLeased + userLeasingAmount) | |
262 | + | let userTotalLeased = getUserLeasingData(nodeAddress, userAddress) | |
263 | + | let newUserTotalLease = (userTotalLeased + userLeasingAmount) | |
264 | + | let newLeased = (leased + userLeasingAmount) | |
265 | + | let newToUnlock = max([0, (toUnlock - userLeasingAmount)]) | |
266 | + | let newToClaim = min([toClaim, (toClaim + (toUnlock - userLeasingAmount))]) | |
267 | + | [getLeasingNodeEntry(nodeAddress, newTotalLease), getUserLeasingEntry(nodeAddress, userAddress, newUserTotalLease), getUserBalancesEntry(userAddress, periodId, newLeased, newToUnlock, newToClaim), getUserNodeListEntry(userAddress, addNodeToNodeList(userAddress, nodeAddress))] | |
237 | 268 | } | |
238 | 269 | else throw("Strict value is not equal to itself.") | |
239 | 270 | } | |
262 | 293 | ||
263 | 294 | @Callable(i) | |
264 | 295 | func getUserData (userAddress) = { | |
265 | - | let $ | |
266 | - | let periodId = $ | |
267 | - | let leased = $ | |
268 | - | let toUnlock = $ | |
269 | - | let toClaim = $ | |
296 | + | let $t01075810830 = getUserBalances(userAddress) | |
297 | + | let periodId = $t01075810830._1 | |
298 | + | let leased = $t01075810830._2 | |
299 | + | let toUnlock = $t01075810830._3 | |
300 | + | let toClaim = $t01075810830._4 | |
270 | 301 | let nodeList = getUserLeasingNodeList(userAddress) | |
271 | - | $Tuple2(nil, $ | |
302 | + | $Tuple2(nil, $Tuple6($Tuple2(currentPeriodId, periodLength), leased, toUnlock, toClaim, (toUnlock + toClaim), nodeList)) | |
272 | 303 | } | |
273 | 304 | ||
274 | 305 | ||
282 | 313 | func stake (nodeAddress) = { | |
283 | 314 | let userAddress = toString(i.caller) | |
284 | 315 | getStakeActions(nodeAddress, userAddress, i) | |
316 | + | } | |
317 | + | ||
318 | + | ||
319 | + | ||
320 | + | @Callable(i) | |
321 | + | func stakeFromUnlocked (nodeAddress,amount) = { | |
322 | + | let userAddress = toString(i.caller) | |
323 | + | getStakeFromUnlockedActions(nodeAddress, userAddress, amount) | |
285 | 324 | } | |
286 | 325 | ||
287 | 326 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let contractFile = "l2mp_leasing.ride" | |
5 | 5 | ||
6 | 6 | let SEP = "__" | |
7 | 7 | ||
8 | 8 | let scale8 = 100000000 | |
9 | 9 | ||
10 | 10 | func throwErr (msg) = throw(((contractFile + ": ") + msg)) | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | let keyAssetId = makeString(["%s", "assetId"], SEP) | |
14 | 14 | ||
15 | 15 | let keyPeriodOffsetId = makeString(["%s", "offsetId"], SEP) | |
16 | 16 | ||
17 | 17 | let keyPeriodOffsetHeight = makeString(["%s", "offsetHeight"], SEP) | |
18 | 18 | ||
19 | 19 | let keyPeriodLength = makeString(["%s", "periodLength"], SEP) | |
20 | 20 | ||
21 | 21 | let periodOffsetId = valueOrElse(getInteger(this, keyPeriodOffsetId), 0) | |
22 | 22 | ||
23 | 23 | let periodLength = valueOrElse(getInteger(this, keyPeriodLength), 10000) | |
24 | 24 | ||
25 | 25 | let periodOffsetHeight = valueOrElse(getInteger(this, keyPeriodOffsetHeight), -1) | |
26 | 26 | ||
27 | 27 | let currentPeriodId = if (if ((height > periodOffsetHeight)) | |
28 | 28 | then (periodOffsetHeight != -1) | |
29 | 29 | else false) | |
30 | 30 | then (((height - periodOffsetHeight) / periodLength) + periodOffsetId) | |
31 | 31 | else max([0, (periodOffsetId - 1)]) | |
32 | 32 | ||
33 | 33 | func keyLeasingNodeData (nodeAddress) = makeString(["%s", "leasingNode", nodeAddress], SEP) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func keyUserLeasingNodeList (userAddress) = makeString(["%s%s", "userLeasingNodeList", userAddress], SEP) | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | func keyUserLeasingNodeData (userAddress,nodeAddress) = makeString(["%s%s", "userLeasingNodeData", userAddress, nodeAddress], SEP) | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | func keyUserBalances (userAddress) = makeString(["%s%s", "userBalances", userAddress], SEP) | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | let assetIdString = valueOrElse(getString(this, keyAssetId), "WAVES") | |
46 | 46 | ||
47 | 47 | let assetIdBytes = if ((assetIdString == "WAVES")) | |
48 | 48 | then unit | |
49 | 49 | else fromBase58String(assetIdString) | |
50 | 50 | ||
51 | 51 | func isValidAddress (address) = match addressFromString(address) { | |
52 | 52 | case a: Address => | |
53 | 53 | true | |
54 | 54 | case _ => | |
55 | 55 | false | |
56 | 56 | } | |
57 | 57 | ||
58 | 58 | ||
59 | 59 | func getLeasingNodeEntry (nodeAddress,totalLeased) = { | |
60 | 60 | let valueString = makeString(["%d", toString(totalLeased)], SEP) | |
61 | 61 | StringEntry(keyLeasingNodeData(nodeAddress), valueString) | |
62 | 62 | } | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func getLeasingNodeData (nodeAddress) = { | |
66 | 66 | let leasingDataStringRaw = getString(this, keyLeasingNodeData(nodeAddress)) | |
67 | 67 | match leasingDataStringRaw { | |
68 | 68 | case ds: String => | |
69 | 69 | let dataList = split(ds, SEP) | |
70 | 70 | let totalLeased = parseIntValue(dataList[1]) | |
71 | 71 | totalLeased | |
72 | 72 | case _ => | |
73 | 73 | 0 | |
74 | 74 | } | |
75 | 75 | } | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | func getUserLeasingEntry (nodeAddress,userAddress,totalUserLeased) = { | |
79 | 79 | let valueString = makeString(["%d", toString(totalUserLeased)], SEP) | |
80 | 80 | StringEntry(keyUserLeasingNodeData(userAddress, nodeAddress), valueString) | |
81 | 81 | } | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func getUserLeasingData (nodeAddress,userAddress) = { | |
85 | 85 | let leasingDataStringRaw = getString(this, keyUserLeasingNodeData(userAddress, nodeAddress)) | |
86 | 86 | match leasingDataStringRaw { | |
87 | 87 | case ds: String => | |
88 | 88 | let dataList = split(ds, SEP) | |
89 | 89 | let totalLeased = parseIntValue(dataList[1]) | |
90 | 90 | totalLeased | |
91 | 91 | case _ => | |
92 | 92 | 0 | |
93 | 93 | } | |
94 | 94 | } | |
95 | 95 | ||
96 | 96 | ||
97 | 97 | func getUserBalancesEntry (userAddress,periodId,leased,toUnlock,toClaim) = { | |
98 | 98 | let valueString = makeString(["%d%d%d%d", toString(periodId), toString(leased), toString(toUnlock), toString(toClaim)], SEP) | |
99 | 99 | StringEntry(keyUserBalances(userAddress), valueString) | |
100 | 100 | } | |
101 | 101 | ||
102 | 102 | ||
103 | 103 | func getUserBalances (userAddress) = { | |
104 | 104 | let leasingDataStringRaw = getString(this, keyUserBalances(userAddress)) | |
105 | 105 | match leasingDataStringRaw { | |
106 | 106 | case ds: String => | |
107 | 107 | let dataList = split(ds, SEP) | |
108 | 108 | let periodId = parseIntValue(dataList[1]) | |
109 | 109 | let leased = parseIntValue(dataList[2]) | |
110 | 110 | let toUnlock = parseIntValue(dataList[3]) | |
111 | 111 | let toClaim = parseIntValue(dataList[4]) | |
112 | 112 | if (((currentPeriodId - periodId) > 0)) | |
113 | 113 | then $Tuple4(periodId, leased, 0, (toClaim + toUnlock)) | |
114 | 114 | else $Tuple4(periodId, leased, toUnlock, toClaim) | |
115 | 115 | case _ => | |
116 | 116 | $Tuple4(0, 0, 0, 0) | |
117 | 117 | } | |
118 | 118 | } | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | func getUserLeasingNodeList (userAddress) = { | |
122 | 122 | let leasingDataStringRaw = getString(this, keyUserLeasingNodeList(userAddress)) | |
123 | 123 | match leasingDataStringRaw { | |
124 | 124 | case ds: String => | |
125 | 125 | let dataList = split_51C(ds, SEP) | |
126 | 126 | dataList | |
127 | 127 | case _ => | |
128 | 128 | nil | |
129 | 129 | } | |
130 | 130 | } | |
131 | 131 | ||
132 | 132 | ||
133 | 133 | func getUserNodeListEntry (userAddress,nodeList) = if ((size(nodeList) == 0)) | |
134 | 134 | then DeleteEntry(keyUserLeasingNodeList(userAddress)) | |
135 | 135 | else StringEntry(keyUserLeasingNodeList(userAddress), makeString_11C(nodeList, SEP)) | |
136 | 136 | ||
137 | 137 | ||
138 | 138 | func addNodeToNodeList (userAddress,nodeAddress) = { | |
139 | 139 | let nodeList = getUserLeasingNodeList(userAddress) | |
140 | 140 | if (containsElement(nodeList, nodeAddress)) | |
141 | 141 | then nodeList | |
142 | 142 | else (nodeList :+ nodeAddress) | |
143 | 143 | } | |
144 | 144 | ||
145 | 145 | ||
146 | 146 | func removeNodeFromNodeList (userAddress,nodeAddress) = { | |
147 | 147 | let nodeList = getUserLeasingNodeList(userAddress) | |
148 | 148 | match indexOf(nodeList, nodeAddress) { | |
149 | 149 | case index: Int => | |
150 | 150 | removeByIndex(nodeList, index) | |
151 | 151 | case _ => | |
152 | 152 | nodeList | |
153 | 153 | } | |
154 | 154 | } | |
155 | 155 | ||
156 | 156 | ||
157 | 157 | func getStakeActions (nodeAddress,userAddress,i) = { | |
158 | 158 | let checks = [if ((size(i.payments) == 1)) | |
159 | 159 | then true | |
160 | 160 | else throwErr("payment size should be exactly 1"), if ((i.payments[0].assetId == assetIdBytes)) | |
161 | 161 | then true | |
162 | 162 | else throwErr(makeString(["payment assetId should be:", assetIdString], " ")), if (isValidAddress(nodeAddress)) | |
163 | 163 | then true | |
164 | 164 | else throwErr(makeString(["node address is not valid:", nodeAddress], " ")), if (isValidAddress(userAddress)) | |
165 | 165 | then true | |
166 | 166 | else throwErr(makeString(["user address is not valid:", userAddress], " "))] | |
167 | 167 | if ((checks == checks)) | |
168 | 168 | then { | |
169 | 169 | let userLeasingAmount = i.payments[0].amount | |
170 | 170 | let totalNodeLeased = getLeasingNodeData(nodeAddress) | |
171 | 171 | let newTotalLease = (totalNodeLeased + userLeasingAmount) | |
172 | 172 | let userTotalLeased = getUserLeasingData(nodeAddress, userAddress) | |
173 | 173 | let newUserTotalLease = (userTotalLeased + userLeasingAmount) | |
174 | 174 | let $t058645936 = getUserBalances(userAddress) | |
175 | 175 | let periodId = $t058645936._1 | |
176 | 176 | let leased = $t058645936._2 | |
177 | 177 | let toUnlock = $t058645936._3 | |
178 | 178 | let toClaim = $t058645936._4 | |
179 | 179 | let newLeased = (leased + userLeasingAmount) | |
180 | - | [getLeasingNodeEntry(nodeAddress, newTotalLease), getUserLeasingEntry(nodeAddress, userAddress, newUserTotalLease), getUserBalancesEntry(userAddress, | |
180 | + | [getLeasingNodeEntry(nodeAddress, newTotalLease), getUserLeasingEntry(nodeAddress, userAddress, newUserTotalLease), getUserBalancesEntry(userAddress, periodId, newLeased, toUnlock, toClaim), getUserNodeListEntry(userAddress, addNodeToNodeList(userAddress, nodeAddress))] | |
181 | 181 | } | |
182 | 182 | else throw("Strict value is not equal to itself.") | |
183 | 183 | } | |
184 | 184 | ||
185 | 185 | ||
186 | 186 | func getUnstakeActions (nodeAddress,userAddress,unstakeAmount) = { | |
187 | 187 | let totalNodeLeased = getLeasingNodeData(nodeAddress) | |
188 | 188 | let userTotalLeased = getUserLeasingData(nodeAddress, userAddress) | |
189 | 189 | let checks = [if ((unstakeAmount > 0)) | |
190 | 190 | then true | |
191 | 191 | else throwErr("unstake amount should be greater than 0"), if ((userTotalLeased >= unstakeAmount)) | |
192 | 192 | then true | |
193 | 193 | else throwErr("unstake amount should be less or equal user staked amount"), if ((totalNodeLeased >= unstakeAmount)) | |
194 | 194 | then true | |
195 | 195 | else throwErr("unstake amount should be less or equal node staked amount"), if (isValidAddress(nodeAddress)) | |
196 | 196 | then true | |
197 | 197 | else throwErr(makeString(["node address is not valid:", nodeAddress], " ")), if (isValidAddress(userAddress)) | |
198 | 198 | then true | |
199 | 199 | else throwErr(makeString(["user address is not valid:", userAddress], " "))] | |
200 | 200 | if ((checks == checks)) | |
201 | 201 | then { | |
202 | 202 | let newTotalLease = (totalNodeLeased - unstakeAmount) | |
203 | 203 | let newUserTotalLease = (userTotalLeased - unstakeAmount) | |
204 | - | let $ | |
205 | - | let periodId = $ | |
206 | - | let leased = $ | |
207 | - | let toUnlock = $ | |
208 | - | let toClaim = $ | |
204 | + | let $t072127284 = getUserBalances(userAddress) | |
205 | + | let periodId = $t072127284._1 | |
206 | + | let leased = $t072127284._2 | |
207 | + | let toUnlock = $t072127284._3 | |
208 | + | let toClaim = $t072127284._4 | |
209 | 209 | let newLeased = (leased - unstakeAmount) | |
210 | 210 | let newToUnlock = (toUnlock + unstakeAmount) | |
211 | 211 | let removeNodeActions = if ((newUserTotalLease == 0)) | |
212 | 212 | then [getUserNodeListEntry(userAddress, removeNodeFromNodeList(userAddress, nodeAddress))] | |
213 | 213 | else nil | |
214 | 214 | ([getLeasingNodeEntry(nodeAddress, newTotalLease), getUserLeasingEntry(nodeAddress, userAddress, newUserTotalLease), getUserBalancesEntry(userAddress, currentPeriodId, newLeased, newToUnlock, toClaim)] ++ removeNodeActions) | |
215 | 215 | } | |
216 | 216 | else throw("Strict value is not equal to itself.") | |
217 | 217 | } | |
218 | 218 | ||
219 | 219 | ||
220 | 220 | func getClaimUnlockedActions (userAddress,claimAmount) = { | |
221 | - | let $ | |
222 | - | let periodId = $ | |
223 | - | let leased = $ | |
224 | - | let toUnlock = $ | |
225 | - | let toClaim = $ | |
221 | + | let $t078857957 = getUserBalances(userAddress) | |
222 | + | let periodId = $t078857957._1 | |
223 | + | let leased = $t078857957._2 | |
224 | + | let toUnlock = $t078857957._3 | |
225 | + | let toClaim = $t078857957._4 | |
226 | 226 | let checks = [if ((claimAmount > 0)) | |
227 | 227 | then true | |
228 | 228 | else throwErr("claim amount should be greater than 0"), if ((toClaim >= claimAmount)) | |
229 | 229 | then true | |
230 | 230 | else throwErr("claim amount should be less or equal unlocked amount"), if (isValidAddress(userAddress)) | |
231 | 231 | then true | |
232 | 232 | else throwErr(makeString(["user address is not valid:", userAddress], " "))] | |
233 | 233 | if ((checks == checks)) | |
234 | 234 | then { | |
235 | 235 | let newToClaim = (toClaim - claimAmount) | |
236 | 236 | [getUserBalancesEntry(userAddress, currentPeriodId, leased, toUnlock, newToClaim)] | |
237 | + | } | |
238 | + | else throw("Strict value is not equal to itself.") | |
239 | + | } | |
240 | + | ||
241 | + | ||
242 | + | func getStakeFromUnlockedActions (nodeAddress,userAddress,userLeasingAmount) = { | |
243 | + | let $t085348606 = getUserBalances(userAddress) | |
244 | + | let periodId = $t085348606._1 | |
245 | + | let leased = $t085348606._2 | |
246 | + | let toUnlock = $t085348606._3 | |
247 | + | let toClaim = $t085348606._4 | |
248 | + | let available = (toUnlock + toClaim) | |
249 | + | let checks = [if ((userLeasingAmount > 0)) | |
250 | + | then true | |
251 | + | else throwErr("amount should be greater than 0"), if ((available >= userLeasingAmount)) | |
252 | + | then true | |
253 | + | else throwErr("amount should be less or equal to available"), if (isValidAddress(nodeAddress)) | |
254 | + | then true | |
255 | + | else throwErr(makeString(["node address is not valid:", nodeAddress], " ")), if (isValidAddress(userAddress)) | |
256 | + | then true | |
257 | + | else throwErr(makeString(["user address is not valid:", userAddress], " "))] | |
258 | + | if ((checks == checks)) | |
259 | + | then { | |
260 | + | let totalNodeLeased = getLeasingNodeData(nodeAddress) | |
261 | + | let newTotalLease = (totalNodeLeased + userLeasingAmount) | |
262 | + | let userTotalLeased = getUserLeasingData(nodeAddress, userAddress) | |
263 | + | let newUserTotalLease = (userTotalLeased + userLeasingAmount) | |
264 | + | let newLeased = (leased + userLeasingAmount) | |
265 | + | let newToUnlock = max([0, (toUnlock - userLeasingAmount)]) | |
266 | + | let newToClaim = min([toClaim, (toClaim + (toUnlock - userLeasingAmount))]) | |
267 | + | [getLeasingNodeEntry(nodeAddress, newTotalLease), getUserLeasingEntry(nodeAddress, userAddress, newUserTotalLease), getUserBalancesEntry(userAddress, periodId, newLeased, newToUnlock, newToClaim), getUserNodeListEntry(userAddress, addNodeToNodeList(userAddress, nodeAddress))] | |
237 | 268 | } | |
238 | 269 | else throw("Strict value is not equal to itself.") | |
239 | 270 | } | |
240 | 271 | ||
241 | 272 | ||
242 | 273 | func getSetNewPeriodLengthActions (newPeriodLength) = { | |
243 | 274 | let check = [if ((newPeriodLength > 0)) | |
244 | 275 | then true | |
245 | 276 | else throwErr("period length should be greater than 0")] | |
246 | 277 | if ((check == check)) | |
247 | 278 | then if ((periodOffsetHeight == -1)) | |
248 | 279 | then [IntegerEntry(keyPeriodLength, newPeriodLength), IntegerEntry(keyPeriodOffsetHeight, height)] | |
249 | 280 | else { | |
250 | 281 | let newPeriodOffsetId = (currentPeriodId + 1) | |
251 | 282 | let newOffsetHeight = ((periodLength * (newPeriodOffsetId - periodOffsetId)) + periodOffsetHeight) | |
252 | 283 | [IntegerEntry(keyPeriodOffsetId, newPeriodOffsetId), IntegerEntry(keyPeriodOffsetHeight, newOffsetHeight), IntegerEntry(keyPeriodLength, newPeriodLength)] | |
253 | 284 | } | |
254 | 285 | else throw("Strict value is not equal to itself.") | |
255 | 286 | } | |
256 | 287 | ||
257 | 288 | ||
258 | 289 | @Callable(i) | |
259 | 290 | func setNewPeriodLength (newPeriodLength) = getSetNewPeriodLengthActions(newPeriodLength) | |
260 | 291 | ||
261 | 292 | ||
262 | 293 | ||
263 | 294 | @Callable(i) | |
264 | 295 | func getUserData (userAddress) = { | |
265 | - | let $ | |
266 | - | let periodId = $ | |
267 | - | let leased = $ | |
268 | - | let toUnlock = $ | |
269 | - | let toClaim = $ | |
296 | + | let $t01075810830 = getUserBalances(userAddress) | |
297 | + | let periodId = $t01075810830._1 | |
298 | + | let leased = $t01075810830._2 | |
299 | + | let toUnlock = $t01075810830._3 | |
300 | + | let toClaim = $t01075810830._4 | |
270 | 301 | let nodeList = getUserLeasingNodeList(userAddress) | |
271 | - | $Tuple2(nil, $ | |
302 | + | $Tuple2(nil, $Tuple6($Tuple2(currentPeriodId, periodLength), leased, toUnlock, toClaim, (toUnlock + toClaim), nodeList)) | |
272 | 303 | } | |
273 | 304 | ||
274 | 305 | ||
275 | 306 | ||
276 | 307 | @Callable(i) | |
277 | 308 | func stakeFor (nodeAddress,userAddress) = getStakeActions(nodeAddress, userAddress, i) | |
278 | 309 | ||
279 | 310 | ||
280 | 311 | ||
281 | 312 | @Callable(i) | |
282 | 313 | func stake (nodeAddress) = { | |
283 | 314 | let userAddress = toString(i.caller) | |
284 | 315 | getStakeActions(nodeAddress, userAddress, i) | |
316 | + | } | |
317 | + | ||
318 | + | ||
319 | + | ||
320 | + | @Callable(i) | |
321 | + | func stakeFromUnlocked (nodeAddress,amount) = { | |
322 | + | let userAddress = toString(i.caller) | |
323 | + | getStakeFromUnlockedActions(nodeAddress, userAddress, amount) | |
285 | 324 | } | |
286 | 325 | ||
287 | 326 | ||
288 | 327 | ||
289 | 328 | @Callable(i) | |
290 | 329 | func unstake (nodeAddress,amount) = { | |
291 | 330 | let userAddress = toString(i.caller) | |
292 | 331 | getUnstakeActions(nodeAddress, userAddress, amount) | |
293 | 332 | } | |
294 | 333 | ||
295 | 334 | ||
296 | 335 | ||
297 | 336 | @Callable(i) | |
298 | 337 | func claim (amount) = { | |
299 | 338 | let userAddress = toString(i.caller) | |
300 | 339 | getClaimUnlockedActions(userAddress, amount) | |
301 | 340 | } | |
302 | 341 | ||
303 | 342 |
github/deemru/w8io/169f3d6 43.78 ms ◑