tx · RyChEmEcJRAFXuTxqNJ7ijmhFb6RFCihta3D2iLDxRg 3NBPx1Fciu3JQNEGZ21jSnTdutLNGGBUSXh: -0.00700000 Waves 2024.09.01 21:11 [3264838] smart account 3NBPx1Fciu3JQNEGZ21jSnTdutLNGGBUSXh > SELF 0.00000000 Waves
{ "type": 13, "id": "RyChEmEcJRAFXuTxqNJ7ijmhFb6RFCihta3D2iLDxRg", "fee": 700000, "feeAssetId": null, "timestamp": 1725214390405, "version": 2, "chainId": 84, "sender": "3NBPx1Fciu3JQNEGZ21jSnTdutLNGGBUSXh", "senderPublicKey": "3QtfC1XbLZXdeawMDeSERy9vvjUmj1XYd2GFmrvx7pWQ", "proofs": [ "3AfdHCzYDW18JbUC8uins3vB7rsTGJf3HTnuKd8ieM4DxzPY9gKqsmUamaYRyPWTynkf6kfPzo2cZm2KjwYdT61i" ], "script": "base64:BgIiCAISAwoBCBIECgIIARIDCgEEEgMKAQESABIAEgASAwoBCB0AA1NFUAICX18ABU1VTFQ2AMCEPQAFY2hhaW4JAMkBAgkAygECCAUEdGhpcwVieXRlcwABAAEAC3VzZHRBc3NldElkBAckbWF0Y2gwBQVjaGFpbgMJAAACAQFXBQckbWF0Y2gwASCE2nqyCAM/TtG7yo7ui5O8yYLdC136B5ao1CP5qA//uQMJAAACAQFUBQckbWF0Y2gwASBVsdifcoeC7+XjW42sBatl3ppDoS8WuwXzGreHpfHFGAkAAgECDVVua25vd24gY2hhaW4AFWRlZmF1bHRSZXN0QWRkcmVzc1N0cgQHJG1hdGNoMAUFY2hhaW4DCQAAAgEBVwUHJG1hdGNoMAIFM1AuLi4DCQAAAgEBVAUHJG1hdGNoMAIFM00uLi4JAAIBAg1Vbmtub3duIGNoYWluAQ9nZXRTdHJpbmdPckZhaWwCB2FkZHJlc3MDa2V5CQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJ0IAgUHYWRkcmVzcwUDa2V5CQC5CQIJAMwIAgIKbWFuZGF0b3J5IAkAzAgCCQClCAEFB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Q==", "height": 3264838, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 62zA3erjkHtszfmhDVFqw3m4MmgxT4B1gYLGR9nZd6w5 Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 6 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let SEP = "__" | |
5 | + | ||
6 | + | let MULT6 = 1000000 | |
7 | + | ||
8 | + | let chain = take(drop(this.bytes, 1), 1) | |
9 | + | ||
10 | + | let usdtAssetId = match chain { | |
11 | + | case _ => | |
12 | + | if ((base58'2W' == $match0)) | |
13 | + | then base58'9wc3LXNA4TEBsXyKtoLE9mrbDD7WMHXvXrCjZvabLAsi' | |
14 | + | else if ((base58'2T' == $match0)) | |
15 | + | then base58'6mWwf9mZBjVgkC54idpyaZLQfAosD914wT8fGf2iiY63' | |
16 | + | else throw("Unknown chain") | |
17 | + | } | |
18 | + | ||
19 | + | let defaultRestAddressStr = match chain { | |
20 | + | case _ => | |
21 | + | if ((base58'2W' == $match0)) | |
22 | + | then "3P..." | |
23 | + | else if ((base58'2T' == $match0)) | |
24 | + | then "3M..." | |
25 | + | else throw("Unknown chain") | |
26 | + | } | |
27 | + | ||
28 | + | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
29 | + | ||
30 | + | ||
31 | + | let IdxCfgAcresDapp = 1 | |
32 | + | ||
33 | + | let IdxCfgWlgDapp = 2 | |
34 | + | ||
35 | + | func keyRestCfg () = "%s__restConfig" | |
36 | + | ||
37 | + | ||
38 | + | func keyRestAddress () = "%s__restAddr" | |
39 | + | ||
40 | + | ||
41 | + | func readRestCfgOrFail (rest) = split_4C(getStringOrFail(rest, keyRestCfg()), SEP) | |
42 | + | ||
43 | + | ||
44 | + | func getContractAddressOrFail (restCfg,idx) = valueOrErrorMessage(addressFromString(restCfg[idx]), ("Rest cfg doesn't contain address at index " + toString(idx))) | |
45 | + | ||
46 | + | ||
47 | + | let restContract = addressFromStringValue(valueOrElse(getString(this, keyRestAddress()), defaultRestAddressStr)) | |
48 | + | ||
49 | + | let restCfg = readRestCfgOrFail(restContract) | |
50 | + | ||
51 | + | let stakingContract = getContractAddressOrFail(restCfg, IdxCfgAcresDapp) | |
52 | + | ||
53 | + | let wlgContract = getContractAddressOrFail(restCfg, IdxCfgWlgDapp) | |
54 | + | ||
55 | + | func keyBlocked () = "contractsBlocked" | |
56 | + | ||
57 | + | ||
58 | + | func keyLastTxIdByUser (addr) = ("lastTxIdByUser_" + addr) | |
59 | + | ||
60 | + | ||
61 | + | let acresAssetIdKey = "acresAssetId" | |
62 | + | ||
63 | + | let acresAssetId = valueOrErrorMessage(getBinary(stakingContract, acresAssetIdKey), "ACRES is not issued yet") | |
64 | + | ||
65 | + | func keyAcresStakedTimeByUser (addr) = ("acresStakedTimeByUser_" + addr) | |
66 | + | ||
67 | + | ||
68 | + | func fixedPoint (val,decimals) = { | |
69 | + | let tenPow = pow(10, 0, decimals, 0, 0, DOWN) | |
70 | + | let lowPart = toString((val % tenPow)) | |
71 | + | let zeroes = drop(toString(tenPow), (1 + size(lowPart))) | |
72 | + | (((toString((val / tenPow)) + ".") + zeroes) + lowPart) | |
73 | + | } | |
74 | + | ||
75 | + | ||
76 | + | func keyAcresStakedAmountByUser (addr) = ("acresStakedAmountByUser_" + addr) | |
77 | + | ||
78 | + | ||
79 | + | func keyAcresLockedAmountByUser (addr) = ("acresLockedAmountByUser_" + addr) | |
80 | + | ||
81 | + | ||
82 | + | func keyAcresLockedEtaByUser (addr) = ("acresLockedEtaByUser_" + addr) | |
83 | + | ||
84 | + | ||
85 | + | let acresStakedTotalKey = "acresStakedAmountTotal" | |
86 | + | ||
87 | + | func prolog (i) = if (if ((i.originCaller != restContract)) | |
88 | + | then valueOrElse(getBoolean(keyBlocked()), false) | |
89 | + | else false) | |
90 | + | then throw("Contracts are under maintenance") | |
91 | + | else [StringEntry(keyLastTxIdByUser(toString(i.originCaller)), toBase58String(i.transactionId))] | |
92 | + | ||
93 | + | ||
94 | + | func claimAcresInternal (addr,acresAmount,lastClaimTime) = { | |
95 | + | let deltaTime = (lastBlock.timestamp - lastClaimTime) | |
96 | + | 42 | |
97 | + | } | |
98 | + | ||
99 | + | ||
100 | + | func claimInternal (addr,acresAmount,lastClaimTime) = { | |
101 | + | let deltaTime = (lastBlock.timestamp - lastClaimTime) | |
102 | + | if ((0 > deltaTime)) | |
103 | + | then throw(((("Saved timestamp is in future, saved = " + toString(lastClaimTime)) + ", current = ") + toString(lastBlock.timestamp))) | |
104 | + | else 42 | |
105 | + | } | |
106 | + | ||
107 | + | ||
108 | + | @Callable(i) | |
109 | + | func constructorV1 (restAddr) = if ((i.caller != this)) | |
110 | + | then throw("Permission denied") | |
111 | + | else [StringEntry(keyRestAddress(), restAddr)] | |
112 | + | ||
113 | + | ||
114 | + | ||
115 | + | @Callable(i) | |
116 | + | func saveInteger (key,amount) = if ((i.caller != this)) | |
117 | + | then throw("saveInteger is not public method") | |
118 | + | else [IntegerEntry(key, amount)] | |
119 | + | ||
120 | + | ||
121 | + | ||
122 | + | @Callable(i) | |
123 | + | func setBlocked (isBlocked) = if ((i.caller != this)) | |
124 | + | then throw("permission denied") | |
125 | + | else [BooleanEntry(keyBlocked(), isBlocked)] | |
126 | + | ||
127 | + | ||
128 | + | ||
129 | + | @Callable(i) | |
130 | + | func unstakeAcres (amount) = { | |
131 | + | let prologResult = prolog(i) | |
132 | + | if ((prologResult == prologResult)) | |
133 | + | then if ((0 >= amount)) | |
134 | + | then throw("Amount should be positive") | |
135 | + | else { | |
136 | + | let address = toString(i.caller) | |
137 | + | if ((size(i.payments) != 0)) | |
138 | + | then throw("No payments required") | |
139 | + | else { | |
140 | + | let timeKey = keyAcresStakedTimeByUser(address) | |
141 | + | let amountKey = keyAcresStakedAmountByUser(address) | |
142 | + | let oldAcresAmount = valueOrElse(getInteger(amountKey), 0) | |
143 | + | if ((amount > oldAcresAmount)) | |
144 | + | then throw(((("You have only " + fixedPoint(oldAcresAmount, 8)) + " ACRES staked, tried to unstake ") + fixedPoint(amount, 8))) | |
145 | + | else { | |
146 | + | let lockedAmount = valueOrElse(getInteger(keyAcresLockedAmountByUser(address)), 0) | |
147 | + | let lockedETA = valueOrElse(getInteger(keyAcresLockedEtaByUser(address)), 0) | |
148 | + | let now = lastBlock.timestamp | |
149 | + | let unstakableAmount = (oldAcresAmount - lockedAmount) | |
150 | + | if (if ((lockedETA > now)) | |
151 | + | then (amount > unstakableAmount) | |
152 | + | else false) | |
153 | + | then throw(((("Only " + fixedPoint(unstakableAmount, 8)) + " ACRES can be unstaked now, wait until ") + toString(lockedETA))) | |
154 | + | else { | |
155 | + | let oldTotal = valueOrElse(getInteger(acresStakedTotalKey), 0) | |
156 | + | let wlgResult = invoke(wlgContract, "onStakeUnstakeLand", [address], nil) | |
157 | + | let claimedAcres = claimInternal(address, oldAcresAmount, valueOrElse(getInteger(timeKey), 0)) | |
158 | + | $Tuple2([IntegerEntry(timeKey, lastBlock.timestamp), IntegerEntry(amountKey, (oldAcresAmount - amount)), IntegerEntry(acresStakedTotalKey, (oldTotal - amount)), ScriptTransfer(i.caller, (amount + claimedAcres), acresAssetId)], $Tuple2(prologResult, wlgResult)) | |
159 | + | } | |
160 | + | } | |
161 | + | } | |
162 | + | } | |
163 | + | else throw("Strict value is not equal to itself.") | |
164 | + | } | |
165 | + | ||
166 | + | ||
167 | + | ||
168 | + | @Callable(i) | |
169 | + | func stakeAcres () = { | |
170 | + | let prologResult = prolog(i) | |
171 | + | if ((prologResult == prologResult)) | |
172 | + | then { | |
173 | + | let address = toString(i.caller) | |
174 | + | if ((size(i.payments) != 1)) | |
175 | + | then throw("exactly 1 payment must be attached") | |
176 | + | else { | |
177 | + | let pmt = i.payments[0] | |
178 | + | let amt = pmt.amount | |
179 | + | if (if (!(isDefined(pmt.assetId))) | |
180 | + | then true | |
181 | + | else (value(pmt.assetId) != acresAssetId)) | |
182 | + | then throw("ACRES payments only!") | |
183 | + | else { | |
184 | + | let wlgResult = invoke(wlgContract, "onStakeUnstakeLand", [address], nil) | |
185 | + | if ((wlgResult == wlgResult)) | |
186 | + | then { | |
187 | + | let now = lastBlock.timestamp | |
188 | + | let timeKey = keyAcresStakedTimeByUser(address) | |
189 | + | let amountKey = keyAcresStakedAmountByUser(address) | |
190 | + | let oldAcresAmount = valueOrElse(getInteger(amountKey), 0) | |
191 | + | let oldTotal = valueOrElse(getInteger(acresStakedTotalKey), 0) | |
192 | + | let claimedAcres = claimInternal(address, oldAcresAmount, valueOrElse(getInteger(timeKey), 0)) | |
193 | + | $Tuple2(((((if ((claimedAcres == 0)) | |
194 | + | then nil | |
195 | + | else [ScriptTransfer(i.caller, claimedAcres, acresAssetId)]) :+ IntegerEntry(timeKey, lastBlock.timestamp)) :+ IntegerEntry(amountKey, (oldAcresAmount + amt))) :+ IntegerEntry(acresStakedTotalKey, (oldTotal + amt))), $Tuple2(prologResult, wlgResult)) | |
196 | + | } | |
197 | + | else throw("Strict value is not equal to itself.") | |
198 | + | } | |
199 | + | } | |
200 | + | } | |
201 | + | else throw("Strict value is not equal to itself.") | |
202 | + | } | |
203 | + | ||
204 | + | ||
205 | + | ||
206 | + | @Callable(i) | |
207 | + | func buyAcres () = { | |
208 | + | let prologResult = prolog(i) | |
209 | + | if ((prologResult == prologResult)) | |
210 | + | then { | |
211 | + | let address = toString(i.caller) | |
212 | + | if ((size(i.payments) != 1)) | |
213 | + | then throw("exactly 1 payment must be attached") | |
214 | + | else { | |
215 | + | let pmt = i.payments[0] | |
216 | + | let amt = pmt.amount | |
217 | + | if (if (!(isDefined(pmt.assetId))) | |
218 | + | then true | |
219 | + | else (value(pmt.assetId) != usdtAssetId)) | |
220 | + | then throw("USDT payments only!") | |
221 | + | else if ((MULT6 > amt)) | |
222 | + | then throw((("Min payment should be " + fixedPoint(MULT6, 6)) + " USDT")) | |
223 | + | else $Tuple2(nil, prologResult) | |
224 | + | } | |
225 | + | } | |
226 | + | else throw("Strict value is not equal to itself.") | |
227 | + | } | |
228 | + | ||
229 | + | ||
230 | + | ||
231 | + | @Callable(i) | |
232 | + | func claimAcres () = { | |
233 | + | let prologResult = prolog(i) | |
234 | + | if ((prologResult == prologResult)) | |
235 | + | then { | |
236 | + | let address = toString(i.caller) | |
237 | + | if ((size(i.payments) != 0)) | |
238 | + | then throw("No payments required") | |
239 | + | else { | |
240 | + | let timeKey = keyAcresStakedTimeByUser(address) | |
241 | + | let amountKey = keyAcresStakedAmountByUser(address) | |
242 | + | let acresAmount = valueOrElse(getInteger(amountKey), 0) | |
243 | + | let wlgResult = invoke(wlgContract, "onStakeUnstakeLand", [address], nil) | |
244 | + | let claimedAcres = claimInternal(address, acresAmount, valueOrElse(getInteger(timeKey), 0)) | |
245 | + | $Tuple2([IntegerEntry(timeKey, lastBlock.timestamp), ScriptTransfer(i.caller, claimedAcres, acresAssetId)], $Tuple2(prologResult, wlgResult)) | |
246 | + | } | |
247 | + | } | |
248 | + | else throw("Strict value is not equal to itself.") | |
249 | + | } | |
250 | + | ||
251 | + | ||
252 | + | ||
253 | + | @Callable(i) | |
254 | + | func claimAcresREADONLY (address) = { | |
255 | + | let timeKey = keyAcresStakedTimeByUser(address) | |
256 | + | let amountKey = keyAcresStakedAmountByUser(address) | |
257 | + | let acresAmount = valueOrElse(getInteger(amountKey), 0) | |
258 | + | let lastTime = valueOrElse(getInteger(timeKey), 0) | |
259 | + | let claimedAcres = claimAcresInternal(address, acresAmount, lastTime) | |
260 | + | $Tuple2(nil, [claimedAcres, lastTime]) | |
261 | + | } | |
262 | + | ||
263 | + |
github/deemru/w8io/026f985 20.11 ms ◑