tx · 9o6RQBmnKktY7PVY2spYEQLrsLeLGRdjUASy1UbziKmJ 3NBPx1Fciu3JQNEGZ21jSnTdutLNGGBUSXh: -0.00900000 Waves 2024.09.12 19:18 [3280652] smart account 3NBPx1Fciu3JQNEGZ21jSnTdutLNGGBUSXh > SELF 0.00000000 Waves
{ "type": 13, "id": "9o6RQBmnKktY7PVY2spYEQLrsLeLGRdjUASy1UbziKmJ", "fee": 900000, "feeAssetId": null, "timestamp": 1726157973369, "version": 2, "chainId": 84, "sender": "3NBPx1Fciu3JQNEGZ21jSnTdutLNGGBUSXh", "senderPublicKey": "3QtfC1XbLZXdeawMDeSERy9vvjUmj1XYd2GFmrvx7pWQ", "proofs": [ "2GM33hTtBJrveVWD2Grn6zzMuAiHR1zwdyKPqqvXAnsTGKHs4nLS31NFKqpjmo33yf7VBhU5W3ZUbNuobaxGTVsf" ], "script": "base64:BgIgCAISBAoCCAgSBAoCCAESAwoBBBIDCgEBEgASABIAEgAlAANTRVACAl9fAAVNVUxUOACAwtcvABRXTEcyQUNSRVNfTVVMVElQTElFUgDIAQAFY2hhaW4JAMkBAgkAygECCAUEdGhpcwVieXRlcwABAAEAFmRlZmF1bHRSZXN0MkFkZHJlc3NTdHIEByRtYXRjaDAFBWNoYWluAwkAAAIBAVcFByRtYXRjaDACIzNQRndZdGE4YmlFejMxenBlRmU1REpLOHdFNXRyU3BRVkY4AwkAAAIBAVQFByRtYXRjaDACIzNON1V1WWFyNjI2NFA1OEZCaFZXS1BRQWg0WXVhMmhnbmd2CQACAQINVW5rbm93biBjaGFpbgAVb2xkU3Rha2luZ0NvbnRyYWN0U3RyBAckbWF0Y2gwBQVjaGFpbgMJAAACAQFXBQckbWF0Y2gwAiMzUExuY1h0UzFVODNENmNRYkZEM0g4ckJIUExnenhTRktaMQMJAAACAQFUBQckbWF0Y2gwAiMzTkRDeUJHNXE4NUp1YVJpaWdVZUV0YWlueWpDUVQzWHBabQkAAgECDVVua25vd24gY2hhaW4BD2dldFN0cmluZ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29udmVydE9sZFN0YWtlc1JFQURPTkxZAAkAlAoCBQNuaWwAAABIaQNU", "height": 3280652, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 62zA3erjkHtszfmhDVFqw3m4MmgxT4B1gYLGR9nZd6w5 Next: EAb2VRaotmCe9EYZtDqibgkXBDWcTfkg1YMvoKaNfTo1 Diff:
Old | New | Differences | |
---|---|---|---|
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | - | let MULT6 = 1000000 | |
6 | + | let MULT8 = 100000000 | |
7 | + | ||
8 | + | let WLG2ACRES_MULTIPLIER = 200 | |
7 | 9 | ||
8 | 10 | let chain = take(drop(this.bytes, 1), 1) | |
9 | 11 | ||
10 | - | let | |
12 | + | let defaultRest2AddressStr = match chain { | |
11 | 13 | case _ => | |
12 | 14 | if ((base58'2W' == $match0)) | |
13 | - | then | |
15 | + | then "3PFwYta8biEz31zpeFe5DJK8wE5trSpQVF8" | |
14 | 16 | else if ((base58'2T' == $match0)) | |
15 | - | then | |
17 | + | then "3N7UuYar6264P58FBhVWKPQAh4Yua2hgngv" | |
16 | 18 | else throw("Unknown chain") | |
17 | 19 | } | |
18 | 20 | ||
19 | - | let | |
21 | + | let oldStakingContractStr = match chain { | |
20 | 22 | case _ => | |
21 | 23 | if ((base58'2W' == $match0)) | |
22 | - | then " | |
24 | + | then "3PLncXtS1U83D6cQbFD3H8rBHPLgzxSFKZ1" | |
23 | 25 | else if ((base58'2T' == $match0)) | |
24 | - | then " | |
26 | + | then "3NDCyBG5q85JuaRiigUeEtainyjCQT3XpZm" | |
25 | 27 | else throw("Unknown chain") | |
26 | 28 | } | |
27 | 29 | ||
28 | 30 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
29 | 31 | ||
30 | 32 | ||
31 | - | let | |
33 | + | let IdxCfgAcres2Dapp = 1 | |
32 | 34 | ||
33 | 35 | let IdxCfgWlgDapp = 2 | |
34 | 36 | ||
35 | 37 | func keyRestCfg () = "%s__restConfig" | |
36 | 38 | ||
37 | 39 | ||
38 | - | func | |
40 | + | func keyRest2Address () = "%s__rest2Addr" | |
39 | 41 | ||
40 | 42 | ||
41 | 43 | func readRestCfgOrFail (rest) = split_4C(getStringOrFail(rest, keyRestCfg()), SEP) | |
42 | 44 | ||
43 | 45 | ||
44 | - | func getContractAddressOrFail ( | |
46 | + | func getContractAddressOrFail (rest2Cfg,idx) = valueOrErrorMessage(addressFromString(rest2Cfg[idx]), ("Rest cfg doesn't contain address at index " + toString(idx))) | |
45 | 47 | ||
46 | 48 | ||
47 | - | let | |
49 | + | let rest2Contract = addressFromStringValue(valueOrElse(getString(this, keyRest2Address()), defaultRest2AddressStr)) | |
48 | 50 | ||
49 | - | let | |
51 | + | let rest2Cfg = readRestCfgOrFail(rest2Contract) | |
50 | 52 | ||
51 | - | let | |
53 | + | let acres2Contract = getContractAddressOrFail(rest2Cfg, IdxCfgAcres2Dapp) | |
52 | 54 | ||
53 | - | let wlgContract = getContractAddressOrFail(restCfg, IdxCfgWlgDapp) | |
55 | + | let wlgContract = getContractAddressOrFail(rest2Cfg, IdxCfgWlgDapp) | |
56 | + | ||
57 | + | let oldAcresContractKey = "oldAcresContract" | |
54 | 58 | ||
55 | 59 | func keyBlocked () = "contractsBlocked" | |
56 | 60 | ||
58 | 62 | func keyLastTxIdByUser (addr) = ("lastTxIdByUser_" + addr) | |
59 | 63 | ||
60 | 64 | ||
65 | + | let wlgAssetIdKey = "wlg_assetId" | |
66 | + | ||
67 | + | let wlgAssetId = valueOrErrorMessage(getBinary(wlgContract, wlgAssetIdKey), "WLGOLD is not issued yet") | |
68 | + | ||
61 | 69 | let acresIssuedAmountKey = "acresIssuedAmount" | |
62 | 70 | ||
63 | 71 | let acresAssetIdKey = "acresAssetId" | |
64 | 72 | ||
65 | - | let acresAssetId = valueOrErrorMessage(getBinary( | |
73 | + | let acresAssetId = valueOrErrorMessage(getBinary(acres2Contract, acresAssetIdKey), "ACRES is not issued yet") | |
66 | 74 | ||
67 | 75 | func keyAcresStakedTimeByUser (addr) = ("acresStakedTimeByUser_" + addr) | |
76 | + | ||
77 | + | ||
78 | + | func keyStakedLandsByOwner (ownerAddr) = ("stakedLandsByOwner_" + ownerAddr) | |
79 | + | ||
80 | + | ||
81 | + | func keyStakedDuckByOwner (ownerAddr) = ("stakedDuckByOwner_" + ownerAddr) | |
82 | + | ||
83 | + | ||
84 | + | func asInt (v) = match v { | |
85 | + | case n: Int => | |
86 | + | n | |
87 | + | case _ => | |
88 | + | throw("fail to cast into Int") | |
89 | + | } | |
90 | + | ||
91 | + | ||
92 | + | func asTuple5Ints (val) = match val { | |
93 | + | case t: (Int, Int, Int, Int, Int) => | |
94 | + | t | |
95 | + | case _ => | |
96 | + | throw("fail to cast into (Int, Int, Int, Int, Int)") | |
97 | + | } | |
98 | + | ||
99 | + | ||
100 | + | func asTuple3Ints (val) = match val { | |
101 | + | case t: (Int, Int, Int) => | |
102 | + | t | |
103 | + | case _ => | |
104 | + | throw("fail to cast into (Int, Int, Int)") | |
105 | + | } | |
106 | + | ||
107 | + | ||
108 | + | func asTuple2Ints (val) = match val { | |
109 | + | case t: (Int, Int) => | |
110 | + | t._1 | |
111 | + | case _ => | |
112 | + | throw("fail to cast into (Int, Int)") | |
113 | + | } | |
68 | 114 | ||
69 | 115 | ||
70 | 116 | func fixedPoint (val,decimals) = { | |
75 | 121 | } | |
76 | 122 | ||
77 | 123 | ||
78 | - | func | |
124 | + | func keyAcresStakedAmtByUser (addr) = ("acresStakedAmountByUser_" + addr) | |
79 | 125 | ||
80 | 126 | ||
81 | - | ||
127 | + | let acresStakdTotalKey = "acresStakedAmountTotal" | |
82 | 128 | ||
83 | - | ||
84 | - | func keyAcresLockedEtaByUser (addr) = ("acresLockedEtaByUser_" + addr) | |
85 | - | ||
86 | - | ||
87 | - | let acresStakedTotalKey = "acresStakedAmountTotal" | |
88 | - | ||
89 | - | func prolog (i) = if (if ((i.originCaller != restContract)) | |
129 | + | func prolog (i) = if (if ((i.originCaller != rest2Contract)) | |
90 | 130 | then valueOrElse(getBoolean(keyBlocked()), false) | |
91 | 131 | else false) | |
92 | 132 | then throw("Contracts are under maintenance") | |
93 | 133 | else [StringEntry(keyLastTxIdByUser(toString(i.originCaller)), toBase58String(i.transactionId))] | |
94 | 134 | ||
95 | 135 | ||
96 | - | func claimAcresInternal (addr,acresAmount,lastClaimTime) = { | |
97 | - | let deltaTime = (lastBlock.timestamp - lastClaimTime) | |
98 | - | 42 | |
99 | - | } | |
100 | - | ||
101 | - | ||
102 | - | func claimInternal (addr,acresAmount,lastClaimTime) = { | |
103 | - | let deltaTime = (lastBlock.timestamp - lastClaimTime) | |
104 | - | if ((0 > deltaTime)) | |
105 | - | then throw(((("Saved timestamp is in future, saved = " + toString(lastClaimTime)) + ", current = ") + toString(lastBlock.timestamp))) | |
106 | - | else 42 | |
136 | + | func stakeAcresInternal (amt,address) = { | |
137 | + | let wlgResult = invoke(wlgContract, "onStakeUnstakeLand", [address], nil) | |
138 | + | if ((wlgResult == wlgResult)) | |
139 | + | then { | |
140 | + | let now = lastBlock.timestamp | |
141 | + | let timeKey = keyAcresStakedTimeByUser(address) | |
142 | + | let amountKey = keyAcresStakedAmtByUser(address) | |
143 | + | let oldAcresAmount = valueOrElse(getInteger(amountKey), 0) | |
144 | + | let oldTotal = valueOrElse(getInteger(acresStakdTotalKey), 0) | |
145 | + | $Tuple2([IntegerEntry(timeKey, lastBlock.timestamp), IntegerEntry(amountKey, (oldAcresAmount + amt)), IntegerEntry(acresStakdTotalKey, (oldTotal + amt))], wlgResult) | |
146 | + | } | |
147 | + | else throw("Strict value is not equal to itself.") | |
107 | 148 | } | |
108 | 149 | ||
109 | 150 | ||
110 | 151 | @Callable(i) | |
111 | - | func constructorV1 ( | |
152 | + | func constructorV1 (rest2Addr,oldAcrContract) = if ((i.caller != this)) | |
112 | 153 | then throw("Permission denied") | |
113 | 154 | else { | |
114 | 155 | let oldAcrContAddr = addressFromStringValue(oldAcrContract) | |
115 | - | [IntegerEntry(acresIssuedAmountKey, getIntegerValue(oldAcrContAddr, acresIssuedAmountKey)), BinaryEntry(acresAssetIdKey, getBinaryValue(oldAcrContAddr, acresAssetIdKey)), StringEntry( | |
156 | + | [IntegerEntry(acresIssuedAmountKey, getIntegerValue(oldAcrContAddr, acresIssuedAmountKey)), BinaryEntry(acresAssetIdKey, getBinaryValue(oldAcrContAddr, acresAssetIdKey)), StringEntry(keyRest2Address(), rest2Addr), StringEntry(oldAcresContractKey, oldAcrContract)] | |
116 | 157 | } | |
117 | 158 | ||
118 | 159 | ||
133 | 174 | ||
134 | 175 | @Callable(i) | |
135 | 176 | func unstakeAcres (amount) = { | |
136 | - | let prologResult = prolog(i) | |
137 | - | if ((prologResult == prologResult)) | |
138 | - | then if ((0 >= amount)) | |
139 | - | then throw("Amount should be positive") | |
140 | - | else { | |
141 | - | let address = toString(i.caller) | |
142 | - | if ((size(i.payments) != 0)) | |
143 | - | then throw("No payments required") | |
144 | - | else { | |
145 | - | let timeKey = keyAcresStakedTimeByUser(address) | |
146 | - | let amountKey = keyAcresStakedAmountByUser(address) | |
147 | - | let oldAcresAmount = valueOrElse(getInteger(amountKey), 0) | |
148 | - | if ((amount > oldAcresAmount)) | |
149 | - | then throw(((("You have only " + fixedPoint(oldAcresAmount, 8)) + " ACRES staked, tried to unstake ") + fixedPoint(amount, 8))) | |
150 | - | else { | |
151 | - | let lockedAmount = valueOrElse(getInteger(keyAcresLockedAmountByUser(address)), 0) | |
152 | - | let lockedETA = valueOrElse(getInteger(keyAcresLockedEtaByUser(address)), 0) | |
153 | - | let now = lastBlock.timestamp | |
154 | - | let unstakableAmount = (oldAcresAmount - lockedAmount) | |
155 | - | if (if ((lockedETA > now)) | |
156 | - | then (amount > unstakableAmount) | |
157 | - | else false) | |
158 | - | then throw(((("Only " + fixedPoint(unstakableAmount, 8)) + " ACRES can be unstaked now, wait until ") + toString(lockedETA))) | |
159 | - | else { | |
160 | - | let oldTotal = valueOrElse(getInteger(acresStakedTotalKey), 0) | |
161 | - | let wlgResult = invoke(wlgContract, "onStakeUnstakeLand", [address], nil) | |
162 | - | let claimedAcres = claimInternal(address, oldAcresAmount, valueOrElse(getInteger(timeKey), 0)) | |
163 | - | $Tuple2([IntegerEntry(timeKey, lastBlock.timestamp), IntegerEntry(amountKey, (oldAcresAmount - amount)), IntegerEntry(acresStakedTotalKey, (oldTotal - amount)), ScriptTransfer(i.caller, (amount + claimedAcres), acresAssetId)], $Tuple2(prologResult, wlgResult)) | |
164 | - | } | |
165 | - | } | |
166 | - | } | |
167 | - | } | |
168 | - | else throw("Strict value is not equal to itself.") | |
177 | + | let prologActions = prolog(i) | |
178 | + | if ((0 >= amount)) | |
179 | + | then throw("Amount should be positive") | |
180 | + | else { | |
181 | + | let address = toString(i.caller) | |
182 | + | if ((size(i.payments) != 0)) | |
183 | + | then throw("No payments required") | |
184 | + | else { | |
185 | + | let timeKey = keyAcresStakedTimeByUser(address) | |
186 | + | let amountKey = keyAcresStakedAmtByUser(address) | |
187 | + | let oldAcresAmount = valueOrElse(getInteger(amountKey), 0) | |
188 | + | if ((amount > oldAcresAmount)) | |
189 | + | then throw(((("You have only " + fixedPoint(oldAcresAmount, 8)) + " ACRES staked, tried to unstake ") + fixedPoint(amount, 8))) | |
190 | + | else { | |
191 | + | let oldTotal = valueOrElse(getInteger(acresStakdTotalKey), 0) | |
192 | + | let wlgResult = invoke(wlgContract, "onStakeUnstakeLand", [address], nil) | |
193 | + | $Tuple2(([IntegerEntry(timeKey, lastBlock.timestamp), IntegerEntry(amountKey, (oldAcresAmount - amount)), IntegerEntry(acresStakdTotalKey, (oldTotal - amount)), ScriptTransfer(i.caller, amount, acresAssetId)] ++ prologActions), wlgResult) | |
194 | + | } | |
195 | + | } | |
196 | + | } | |
169 | 197 | } | |
170 | 198 | ||
171 | 199 | ||
172 | 200 | ||
173 | 201 | @Callable(i) | |
174 | 202 | func stakeAcres () = { | |
175 | - | let prologResult = prolog(i) | |
176 | - | if ((prologResult == prologResult)) | |
177 | - | then { | |
178 | - | let address = toString(i.caller) | |
179 | - | if ((size(i.payments) != 1)) | |
180 | - | then throw("exactly 1 payment must be attached") | |
203 | + | let prologActions = prolog(i) | |
204 | + | let address = toString(i.caller) | |
205 | + | if ((size(i.payments) != 1)) | |
206 | + | then throw("exactly 1 payment must be attached") | |
207 | + | else { | |
208 | + | let pmt = i.payments[0] | |
209 | + | let amt = pmt.amount | |
210 | + | if (if (!(isDefined(pmt.assetId))) | |
211 | + | then true | |
212 | + | else (value(pmt.assetId) != acresAssetId)) | |
213 | + | then throw("ACRES payments only!") | |
181 | 214 | else { | |
182 | - | let pmt = i.payments[0] | |
183 | - | let amt = pmt.amount | |
184 | - | if (if (!(isDefined(pmt.assetId))) | |
185 | - | then true | |
186 | - | else (value(pmt.assetId) != acresAssetId)) | |
187 | - | then throw("ACRES payments only!") | |
188 | - | else { | |
189 | - | let wlgResult = invoke(wlgContract, "onStakeUnstakeLand", [address], nil) | |
190 | - | if ((wlgResult == wlgResult)) | |
191 | - | then { | |
192 | - | let now = lastBlock.timestamp | |
193 | - | let timeKey = keyAcresStakedTimeByUser(address) | |
194 | - | let amountKey = keyAcresStakedAmountByUser(address) | |
195 | - | let oldAcresAmount = valueOrElse(getInteger(amountKey), 0) | |
196 | - | let oldTotal = valueOrElse(getInteger(acresStakedTotalKey), 0) | |
197 | - | let claimedAcres = claimInternal(address, oldAcresAmount, valueOrElse(getInteger(timeKey), 0)) | |
198 | - | $Tuple2(((((if ((claimedAcres == 0)) | |
199 | - | then nil | |
200 | - | else [ScriptTransfer(i.caller, claimedAcres, acresAssetId)]) :+ IntegerEntry(timeKey, lastBlock.timestamp)) :+ IntegerEntry(amountKey, (oldAcresAmount + amt))) :+ IntegerEntry(acresStakedTotalKey, (oldTotal + amt))), $Tuple2(prologResult, wlgResult)) | |
201 | - | } | |
202 | - | else throw("Strict value is not equal to itself.") | |
203 | - | } | |
215 | + | let $t031333199 = stakeAcresInternal(amt, address) | |
216 | + | let actions = $t031333199._1 | |
217 | + | let wlgClaimedAmount = $t031333199._2 | |
218 | + | $Tuple2((actions ++ prologActions), wlgClaimedAmount) | |
204 | 219 | } | |
205 | 220 | } | |
206 | - | else throw("Strict value is not equal to itself.") | |
207 | 221 | } | |
208 | 222 | ||
209 | 223 | ||
210 | 224 | ||
211 | 225 | @Callable(i) | |
212 | 226 | func buyAcres () = { | |
213 | - | let prologResult = prolog(i) | |
214 | - | if ((prologResult == prologResult)) | |
215 | - | then { | |
216 | - | let address = toString(i.caller) | |
217 | - | if ((size(i.payments) != 1)) | |
218 | - | then throw("exactly 1 payment must be attached") | |
219 | - | else { | |
220 | - | let pmt = i.payments[0] | |
221 | - | let amt = pmt.amount | |
222 | - | if (if (!(isDefined(pmt.assetId))) | |
223 | - | then true | |
224 | - | else (value(pmt.assetId) != usdtAssetId)) | |
225 | - | then throw("USDT payments only!") | |
226 | - | else if ((MULT6 > amt)) | |
227 | - | then throw((("Min payment should be " + fixedPoint(MULT6, 6)) + " USDT")) | |
228 | - | else $Tuple2(nil, prologResult) | |
229 | - | } | |
227 | + | let prologActions = prolog(i) | |
228 | + | let address = toString(i.caller) | |
229 | + | if ((size(i.payments) != 1)) | |
230 | + | then throw("exactly 1 payment must be attached") | |
231 | + | else { | |
232 | + | let pmt = i.payments[0] | |
233 | + | let amt = pmt.amount | |
234 | + | if (if (!(isDefined(pmt.assetId))) | |
235 | + | then true | |
236 | + | else (value(pmt.assetId) != wlgAssetId)) | |
237 | + | then throw("WLGOLD payments only!") | |
238 | + | else if ((MULT8 > amt)) | |
239 | + | then throw((("Min payment should be " + fixedPoint(MULT8, 8)) + " WLGOLD")) | |
240 | + | else { | |
241 | + | let acresAmount = (amt * WLG2ACRES_MULTIPLIER) | |
242 | + | let wlgRemain = asInt(invoke(acres2Contract, "burnWlgold", nil, [AttachedPayment(wlgAssetId, amt)])) | |
243 | + | $Tuple2(([ScriptTransfer(i.caller, acresAmount, acresAssetId)] ++ prologActions), wlgRemain) | |
244 | + | } | |
230 | 245 | } | |
231 | - | else throw("Strict value is not equal to itself.") | |
232 | 246 | } | |
233 | 247 | ||
234 | 248 | ||
235 | 249 | ||
236 | 250 | @Callable(i) | |
237 | - | func claimAcres () = { | |
238 | - | let prologResult = prolog(i) | |
239 | - | if ((prologResult == prologResult)) | |
240 | - | then { | |
241 | - | let address = toString(i.caller) | |
242 | - | if ((size(i.payments) != 0)) | |
243 | - | then throw("No payments required") | |
244 | - | else { | |
245 | - | let timeKey = keyAcresStakedTimeByUser(address) | |
246 | - | let amountKey = keyAcresStakedAmountByUser(address) | |
247 | - | let acresAmount = valueOrElse(getInteger(amountKey), 0) | |
248 | - | let wlgResult = invoke(wlgContract, "onStakeUnstakeLand", [address], nil) | |
249 | - | let claimedAcres = claimInternal(address, acresAmount, valueOrElse(getInteger(timeKey), 0)) | |
250 | - | $Tuple2([IntegerEntry(timeKey, lastBlock.timestamp), ScriptTransfer(i.caller, claimedAcres, acresAssetId)], $Tuple2(prologResult, wlgResult)) | |
251 | + | func convertOldStakes () = { | |
252 | + | let address = toString(i.caller) | |
253 | + | if ((size(i.payments) != 0)) | |
254 | + | then throw("No payments required") | |
255 | + | else { | |
256 | + | let oldAcresAddress = addressFromStringValue(getStringValue(oldAcresContractKey)) | |
257 | + | let amount = valueOrElse(getInteger(oldAcresAddress, keyAcresStakedAmtByUser(address)), 0) | |
258 | + | let gotAcres0 = if ((amount > 0)) | |
259 | + | then asTuple2Ints(invoke(oldAcresAddress, "unstakeAcresCallback", [amount, address], nil)) | |
260 | + | else 0 | |
261 | + | let oldStakingAddress = addressFromStringValue(oldStakingContractStr) | |
262 | + | let landsStr = getString(oldStakingAddress, keyStakedLandsByOwner(address)) | |
263 | + | let landsResult = if (isDefined(landsStr)) | |
264 | + | then { | |
265 | + | let lands = split_51C(value(landsStr), "_") | |
266 | + | func oneLand (acc,landAssetId) = if ((landAssetId == "")) | |
267 | + | then throw("landAssetId is required") | |
268 | + | else { | |
269 | + | let r = asTuple5Ints(invoke(oldStakingAddress, "unstakeLandCallback", [landAssetId, address], nil)) | |
270 | + | $Tuple4((acc._1 + r._1), (acc._2 + r._2), (acc._3 + r._3), (acc._4 + r._4)) | |
271 | + | } | |
272 | + | ||
273 | + | let rr = { | |
274 | + | let $l = lands | |
275 | + | let $s = size($l) | |
276 | + | let $acc0 = $Tuple4(0, 0, 0, 0) | |
277 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
278 | + | then $a | |
279 | + | else oneLand($a, $l[$i]) | |
280 | + | ||
281 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
282 | + | then $a | |
283 | + | else throw("List size exceeds 100") | |
284 | + | ||
285 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50), 51), 52), 53), 54), 55), 56), 57), 58), 59), 60), 61), 62), 63), 64), 65), 66), 67), 68), 69), 70), 71), 72), 73), 74), 75), 76), 77), 78), 79), 80), 81), 82), 83), 84), 85), 86), 87), 88), 89), 90), 91), 92), 93), 94), 95), 96), 97), 98), 99), 100) | |
286 | + | } | |
287 | + | let finalize = invoke(oldStakingAddress, "unstakeLandsFinalizeCallback", [address], nil) | |
288 | + | if ((finalize == finalize)) | |
289 | + | then { | |
290 | + | let req = invoke(oldAcresAddress, "requestAcresCallback", [(((rr._1 + rr._2) + rr._3) + rr._4), address], nil) | |
291 | + | if ((req == req)) | |
292 | + | then { | |
293 | + | let issue = Issue("FPOWER10", "FarmingPower +10% NFT for WavesLands game", 1, 0, false) | |
294 | + | $Tuple5(rr._1, rr._2, rr._3, rr._4, [issue, ScriptTransfer(i.caller, 1, calculateAssetId(issue))]) | |
295 | + | } | |
296 | + | else throw("Strict value is not equal to itself.") | |
297 | + | } | |
298 | + | else throw("Strict value is not equal to itself.") | |
251 | 299 | } | |
300 | + | else $Tuple5(0, 0, 0, 0, nil) | |
301 | + | let duckAssetId = valueOrElse(getString(oldStakingAddress, keyStakedDuckByOwner(address)), "") | |
302 | + | let duckResult = if ((duckAssetId != "")) | |
303 | + | then asTuple3Ints(invoke(oldStakingAddress, "unstakeDuckCallback", [duckAssetId, address], nil)) | |
304 | + | else $Tuple3(0, 0, 0) | |
305 | + | let x = stakeAcresInternal((((((((gotAcres0 + landsResult._1) + landsResult._2) + landsResult._3) + landsResult._4) + duckResult._1) + duckResult._2) + duckResult._3), address) | |
306 | + | $Tuple2((landsResult._5 ++ x._1), x._2) | |
252 | 307 | } | |
253 | - | else throw("Strict value is not equal to itself.") | |
254 | 308 | } | |
255 | 309 | ||
256 | 310 | ||
257 | 311 | ||
258 | 312 | @Callable(i) | |
259 | - | func claimAcresREADONLY (address) = { | |
260 | - | let timeKey = keyAcresStakedTimeByUser(address) | |
261 | - | let amountKey = keyAcresStakedAmountByUser(address) | |
262 | - | let acresAmount = valueOrElse(getInteger(amountKey), 0) | |
263 | - | let lastTime = valueOrElse(getInteger(timeKey), 0) | |
264 | - | let claimedAcres = claimAcresInternal(address, acresAmount, lastTime) | |
265 | - | $Tuple2(nil, [claimedAcres, lastTime]) | |
266 | - | } | |
313 | + | func convertOldStakesREADONLY () = $Tuple2(nil, 0) | |
267 | 314 | ||
268 | 315 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | - | let MULT6 = 1000000 | |
6 | + | let MULT8 = 100000000 | |
7 | + | ||
8 | + | let WLG2ACRES_MULTIPLIER = 200 | |
7 | 9 | ||
8 | 10 | let chain = take(drop(this.bytes, 1), 1) | |
9 | 11 | ||
10 | - | let | |
12 | + | let defaultRest2AddressStr = match chain { | |
11 | 13 | case _ => | |
12 | 14 | if ((base58'2W' == $match0)) | |
13 | - | then | |
15 | + | then "3PFwYta8biEz31zpeFe5DJK8wE5trSpQVF8" | |
14 | 16 | else if ((base58'2T' == $match0)) | |
15 | - | then | |
17 | + | then "3N7UuYar6264P58FBhVWKPQAh4Yua2hgngv" | |
16 | 18 | else throw("Unknown chain") | |
17 | 19 | } | |
18 | 20 | ||
19 | - | let | |
21 | + | let oldStakingContractStr = match chain { | |
20 | 22 | case _ => | |
21 | 23 | if ((base58'2W' == $match0)) | |
22 | - | then " | |
24 | + | then "3PLncXtS1U83D6cQbFD3H8rBHPLgzxSFKZ1" | |
23 | 25 | else if ((base58'2T' == $match0)) | |
24 | - | then " | |
26 | + | then "3NDCyBG5q85JuaRiigUeEtainyjCQT3XpZm" | |
25 | 27 | else throw("Unknown chain") | |
26 | 28 | } | |
27 | 29 | ||
28 | 30 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
29 | 31 | ||
30 | 32 | ||
31 | - | let | |
33 | + | let IdxCfgAcres2Dapp = 1 | |
32 | 34 | ||
33 | 35 | let IdxCfgWlgDapp = 2 | |
34 | 36 | ||
35 | 37 | func keyRestCfg () = "%s__restConfig" | |
36 | 38 | ||
37 | 39 | ||
38 | - | func | |
40 | + | func keyRest2Address () = "%s__rest2Addr" | |
39 | 41 | ||
40 | 42 | ||
41 | 43 | func readRestCfgOrFail (rest) = split_4C(getStringOrFail(rest, keyRestCfg()), SEP) | |
42 | 44 | ||
43 | 45 | ||
44 | - | func getContractAddressOrFail ( | |
46 | + | func getContractAddressOrFail (rest2Cfg,idx) = valueOrErrorMessage(addressFromString(rest2Cfg[idx]), ("Rest cfg doesn't contain address at index " + toString(idx))) | |
45 | 47 | ||
46 | 48 | ||
47 | - | let | |
49 | + | let rest2Contract = addressFromStringValue(valueOrElse(getString(this, keyRest2Address()), defaultRest2AddressStr)) | |
48 | 50 | ||
49 | - | let | |
51 | + | let rest2Cfg = readRestCfgOrFail(rest2Contract) | |
50 | 52 | ||
51 | - | let | |
53 | + | let acres2Contract = getContractAddressOrFail(rest2Cfg, IdxCfgAcres2Dapp) | |
52 | 54 | ||
53 | - | let wlgContract = getContractAddressOrFail(restCfg, IdxCfgWlgDapp) | |
55 | + | let wlgContract = getContractAddressOrFail(rest2Cfg, IdxCfgWlgDapp) | |
56 | + | ||
57 | + | let oldAcresContractKey = "oldAcresContract" | |
54 | 58 | ||
55 | 59 | func keyBlocked () = "contractsBlocked" | |
56 | 60 | ||
57 | 61 | ||
58 | 62 | func keyLastTxIdByUser (addr) = ("lastTxIdByUser_" + addr) | |
59 | 63 | ||
60 | 64 | ||
65 | + | let wlgAssetIdKey = "wlg_assetId" | |
66 | + | ||
67 | + | let wlgAssetId = valueOrErrorMessage(getBinary(wlgContract, wlgAssetIdKey), "WLGOLD is not issued yet") | |
68 | + | ||
61 | 69 | let acresIssuedAmountKey = "acresIssuedAmount" | |
62 | 70 | ||
63 | 71 | let acresAssetIdKey = "acresAssetId" | |
64 | 72 | ||
65 | - | let acresAssetId = valueOrErrorMessage(getBinary( | |
73 | + | let acresAssetId = valueOrErrorMessage(getBinary(acres2Contract, acresAssetIdKey), "ACRES is not issued yet") | |
66 | 74 | ||
67 | 75 | func keyAcresStakedTimeByUser (addr) = ("acresStakedTimeByUser_" + addr) | |
76 | + | ||
77 | + | ||
78 | + | func keyStakedLandsByOwner (ownerAddr) = ("stakedLandsByOwner_" + ownerAddr) | |
79 | + | ||
80 | + | ||
81 | + | func keyStakedDuckByOwner (ownerAddr) = ("stakedDuckByOwner_" + ownerAddr) | |
82 | + | ||
83 | + | ||
84 | + | func asInt (v) = match v { | |
85 | + | case n: Int => | |
86 | + | n | |
87 | + | case _ => | |
88 | + | throw("fail to cast into Int") | |
89 | + | } | |
90 | + | ||
91 | + | ||
92 | + | func asTuple5Ints (val) = match val { | |
93 | + | case t: (Int, Int, Int, Int, Int) => | |
94 | + | t | |
95 | + | case _ => | |
96 | + | throw("fail to cast into (Int, Int, Int, Int, Int)") | |
97 | + | } | |
98 | + | ||
99 | + | ||
100 | + | func asTuple3Ints (val) = match val { | |
101 | + | case t: (Int, Int, Int) => | |
102 | + | t | |
103 | + | case _ => | |
104 | + | throw("fail to cast into (Int, Int, Int)") | |
105 | + | } | |
106 | + | ||
107 | + | ||
108 | + | func asTuple2Ints (val) = match val { | |
109 | + | case t: (Int, Int) => | |
110 | + | t._1 | |
111 | + | case _ => | |
112 | + | throw("fail to cast into (Int, Int)") | |
113 | + | } | |
68 | 114 | ||
69 | 115 | ||
70 | 116 | func fixedPoint (val,decimals) = { | |
71 | 117 | let tenPow = pow(10, 0, decimals, 0, 0, DOWN) | |
72 | 118 | let lowPart = toString((val % tenPow)) | |
73 | 119 | let zeroes = drop(toString(tenPow), (1 + size(lowPart))) | |
74 | 120 | (((toString((val / tenPow)) + ".") + zeroes) + lowPart) | |
75 | 121 | } | |
76 | 122 | ||
77 | 123 | ||
78 | - | func | |
124 | + | func keyAcresStakedAmtByUser (addr) = ("acresStakedAmountByUser_" + addr) | |
79 | 125 | ||
80 | 126 | ||
81 | - | ||
127 | + | let acresStakdTotalKey = "acresStakedAmountTotal" | |
82 | 128 | ||
83 | - | ||
84 | - | func keyAcresLockedEtaByUser (addr) = ("acresLockedEtaByUser_" + addr) | |
85 | - | ||
86 | - | ||
87 | - | let acresStakedTotalKey = "acresStakedAmountTotal" | |
88 | - | ||
89 | - | func prolog (i) = if (if ((i.originCaller != restContract)) | |
129 | + | func prolog (i) = if (if ((i.originCaller != rest2Contract)) | |
90 | 130 | then valueOrElse(getBoolean(keyBlocked()), false) | |
91 | 131 | else false) | |
92 | 132 | then throw("Contracts are under maintenance") | |
93 | 133 | else [StringEntry(keyLastTxIdByUser(toString(i.originCaller)), toBase58String(i.transactionId))] | |
94 | 134 | ||
95 | 135 | ||
96 | - | func claimAcresInternal (addr,acresAmount,lastClaimTime) = { | |
97 | - | let deltaTime = (lastBlock.timestamp - lastClaimTime) | |
98 | - | 42 | |
99 | - | } | |
100 | - | ||
101 | - | ||
102 | - | func claimInternal (addr,acresAmount,lastClaimTime) = { | |
103 | - | let deltaTime = (lastBlock.timestamp - lastClaimTime) | |
104 | - | if ((0 > deltaTime)) | |
105 | - | then throw(((("Saved timestamp is in future, saved = " + toString(lastClaimTime)) + ", current = ") + toString(lastBlock.timestamp))) | |
106 | - | else 42 | |
136 | + | func stakeAcresInternal (amt,address) = { | |
137 | + | let wlgResult = invoke(wlgContract, "onStakeUnstakeLand", [address], nil) | |
138 | + | if ((wlgResult == wlgResult)) | |
139 | + | then { | |
140 | + | let now = lastBlock.timestamp | |
141 | + | let timeKey = keyAcresStakedTimeByUser(address) | |
142 | + | let amountKey = keyAcresStakedAmtByUser(address) | |
143 | + | let oldAcresAmount = valueOrElse(getInteger(amountKey), 0) | |
144 | + | let oldTotal = valueOrElse(getInteger(acresStakdTotalKey), 0) | |
145 | + | $Tuple2([IntegerEntry(timeKey, lastBlock.timestamp), IntegerEntry(amountKey, (oldAcresAmount + amt)), IntegerEntry(acresStakdTotalKey, (oldTotal + amt))], wlgResult) | |
146 | + | } | |
147 | + | else throw("Strict value is not equal to itself.") | |
107 | 148 | } | |
108 | 149 | ||
109 | 150 | ||
110 | 151 | @Callable(i) | |
111 | - | func constructorV1 ( | |
152 | + | func constructorV1 (rest2Addr,oldAcrContract) = if ((i.caller != this)) | |
112 | 153 | then throw("Permission denied") | |
113 | 154 | else { | |
114 | 155 | let oldAcrContAddr = addressFromStringValue(oldAcrContract) | |
115 | - | [IntegerEntry(acresIssuedAmountKey, getIntegerValue(oldAcrContAddr, acresIssuedAmountKey)), BinaryEntry(acresAssetIdKey, getBinaryValue(oldAcrContAddr, acresAssetIdKey)), StringEntry( | |
156 | + | [IntegerEntry(acresIssuedAmountKey, getIntegerValue(oldAcrContAddr, acresIssuedAmountKey)), BinaryEntry(acresAssetIdKey, getBinaryValue(oldAcrContAddr, acresAssetIdKey)), StringEntry(keyRest2Address(), rest2Addr), StringEntry(oldAcresContractKey, oldAcrContract)] | |
116 | 157 | } | |
117 | 158 | ||
118 | 159 | ||
119 | 160 | ||
120 | 161 | @Callable(i) | |
121 | 162 | func saveInteger (key,amount) = if ((i.caller != this)) | |
122 | 163 | then throw("saveInteger is not public method") | |
123 | 164 | else [IntegerEntry(key, amount)] | |
124 | 165 | ||
125 | 166 | ||
126 | 167 | ||
127 | 168 | @Callable(i) | |
128 | 169 | func setBlocked (isBlocked) = if ((i.caller != this)) | |
129 | 170 | then throw("permission denied") | |
130 | 171 | else [BooleanEntry(keyBlocked(), isBlocked)] | |
131 | 172 | ||
132 | 173 | ||
133 | 174 | ||
134 | 175 | @Callable(i) | |
135 | 176 | func unstakeAcres (amount) = { | |
136 | - | let prologResult = prolog(i) | |
137 | - | if ((prologResult == prologResult)) | |
138 | - | then if ((0 >= amount)) | |
139 | - | then throw("Amount should be positive") | |
140 | - | else { | |
141 | - | let address = toString(i.caller) | |
142 | - | if ((size(i.payments) != 0)) | |
143 | - | then throw("No payments required") | |
144 | - | else { | |
145 | - | let timeKey = keyAcresStakedTimeByUser(address) | |
146 | - | let amountKey = keyAcresStakedAmountByUser(address) | |
147 | - | let oldAcresAmount = valueOrElse(getInteger(amountKey), 0) | |
148 | - | if ((amount > oldAcresAmount)) | |
149 | - | then throw(((("You have only " + fixedPoint(oldAcresAmount, 8)) + " ACRES staked, tried to unstake ") + fixedPoint(amount, 8))) | |
150 | - | else { | |
151 | - | let lockedAmount = valueOrElse(getInteger(keyAcresLockedAmountByUser(address)), 0) | |
152 | - | let lockedETA = valueOrElse(getInteger(keyAcresLockedEtaByUser(address)), 0) | |
153 | - | let now = lastBlock.timestamp | |
154 | - | let unstakableAmount = (oldAcresAmount - lockedAmount) | |
155 | - | if (if ((lockedETA > now)) | |
156 | - | then (amount > unstakableAmount) | |
157 | - | else false) | |
158 | - | then throw(((("Only " + fixedPoint(unstakableAmount, 8)) + " ACRES can be unstaked now, wait until ") + toString(lockedETA))) | |
159 | - | else { | |
160 | - | let oldTotal = valueOrElse(getInteger(acresStakedTotalKey), 0) | |
161 | - | let wlgResult = invoke(wlgContract, "onStakeUnstakeLand", [address], nil) | |
162 | - | let claimedAcres = claimInternal(address, oldAcresAmount, valueOrElse(getInteger(timeKey), 0)) | |
163 | - | $Tuple2([IntegerEntry(timeKey, lastBlock.timestamp), IntegerEntry(amountKey, (oldAcresAmount - amount)), IntegerEntry(acresStakedTotalKey, (oldTotal - amount)), ScriptTransfer(i.caller, (amount + claimedAcres), acresAssetId)], $Tuple2(prologResult, wlgResult)) | |
164 | - | } | |
165 | - | } | |
166 | - | } | |
167 | - | } | |
168 | - | else throw("Strict value is not equal to itself.") | |
177 | + | let prologActions = prolog(i) | |
178 | + | if ((0 >= amount)) | |
179 | + | then throw("Amount should be positive") | |
180 | + | else { | |
181 | + | let address = toString(i.caller) | |
182 | + | if ((size(i.payments) != 0)) | |
183 | + | then throw("No payments required") | |
184 | + | else { | |
185 | + | let timeKey = keyAcresStakedTimeByUser(address) | |
186 | + | let amountKey = keyAcresStakedAmtByUser(address) | |
187 | + | let oldAcresAmount = valueOrElse(getInteger(amountKey), 0) | |
188 | + | if ((amount > oldAcresAmount)) | |
189 | + | then throw(((("You have only " + fixedPoint(oldAcresAmount, 8)) + " ACRES staked, tried to unstake ") + fixedPoint(amount, 8))) | |
190 | + | else { | |
191 | + | let oldTotal = valueOrElse(getInteger(acresStakdTotalKey), 0) | |
192 | + | let wlgResult = invoke(wlgContract, "onStakeUnstakeLand", [address], nil) | |
193 | + | $Tuple2(([IntegerEntry(timeKey, lastBlock.timestamp), IntegerEntry(amountKey, (oldAcresAmount - amount)), IntegerEntry(acresStakdTotalKey, (oldTotal - amount)), ScriptTransfer(i.caller, amount, acresAssetId)] ++ prologActions), wlgResult) | |
194 | + | } | |
195 | + | } | |
196 | + | } | |
169 | 197 | } | |
170 | 198 | ||
171 | 199 | ||
172 | 200 | ||
173 | 201 | @Callable(i) | |
174 | 202 | func stakeAcres () = { | |
175 | - | let prologResult = prolog(i) | |
176 | - | if ((prologResult == prologResult)) | |
177 | - | then { | |
178 | - | let address = toString(i.caller) | |
179 | - | if ((size(i.payments) != 1)) | |
180 | - | then throw("exactly 1 payment must be attached") | |
203 | + | let prologActions = prolog(i) | |
204 | + | let address = toString(i.caller) | |
205 | + | if ((size(i.payments) != 1)) | |
206 | + | then throw("exactly 1 payment must be attached") | |
207 | + | else { | |
208 | + | let pmt = i.payments[0] | |
209 | + | let amt = pmt.amount | |
210 | + | if (if (!(isDefined(pmt.assetId))) | |
211 | + | then true | |
212 | + | else (value(pmt.assetId) != acresAssetId)) | |
213 | + | then throw("ACRES payments only!") | |
181 | 214 | else { | |
182 | - | let pmt = i.payments[0] | |
183 | - | let amt = pmt.amount | |
184 | - | if (if (!(isDefined(pmt.assetId))) | |
185 | - | then true | |
186 | - | else (value(pmt.assetId) != acresAssetId)) | |
187 | - | then throw("ACRES payments only!") | |
188 | - | else { | |
189 | - | let wlgResult = invoke(wlgContract, "onStakeUnstakeLand", [address], nil) | |
190 | - | if ((wlgResult == wlgResult)) | |
191 | - | then { | |
192 | - | let now = lastBlock.timestamp | |
193 | - | let timeKey = keyAcresStakedTimeByUser(address) | |
194 | - | let amountKey = keyAcresStakedAmountByUser(address) | |
195 | - | let oldAcresAmount = valueOrElse(getInteger(amountKey), 0) | |
196 | - | let oldTotal = valueOrElse(getInteger(acresStakedTotalKey), 0) | |
197 | - | let claimedAcres = claimInternal(address, oldAcresAmount, valueOrElse(getInteger(timeKey), 0)) | |
198 | - | $Tuple2(((((if ((claimedAcres == 0)) | |
199 | - | then nil | |
200 | - | else [ScriptTransfer(i.caller, claimedAcres, acresAssetId)]) :+ IntegerEntry(timeKey, lastBlock.timestamp)) :+ IntegerEntry(amountKey, (oldAcresAmount + amt))) :+ IntegerEntry(acresStakedTotalKey, (oldTotal + amt))), $Tuple2(prologResult, wlgResult)) | |
201 | - | } | |
202 | - | else throw("Strict value is not equal to itself.") | |
203 | - | } | |
215 | + | let $t031333199 = stakeAcresInternal(amt, address) | |
216 | + | let actions = $t031333199._1 | |
217 | + | let wlgClaimedAmount = $t031333199._2 | |
218 | + | $Tuple2((actions ++ prologActions), wlgClaimedAmount) | |
204 | 219 | } | |
205 | 220 | } | |
206 | - | else throw("Strict value is not equal to itself.") | |
207 | 221 | } | |
208 | 222 | ||
209 | 223 | ||
210 | 224 | ||
211 | 225 | @Callable(i) | |
212 | 226 | func buyAcres () = { | |
213 | - | let prologResult = prolog(i) | |
214 | - | if ((prologResult == prologResult)) | |
215 | - | then { | |
216 | - | let address = toString(i.caller) | |
217 | - | if ((size(i.payments) != 1)) | |
218 | - | then throw("exactly 1 payment must be attached") | |
219 | - | else { | |
220 | - | let pmt = i.payments[0] | |
221 | - | let amt = pmt.amount | |
222 | - | if (if (!(isDefined(pmt.assetId))) | |
223 | - | then true | |
224 | - | else (value(pmt.assetId) != usdtAssetId)) | |
225 | - | then throw("USDT payments only!") | |
226 | - | else if ((MULT6 > amt)) | |
227 | - | then throw((("Min payment should be " + fixedPoint(MULT6, 6)) + " USDT")) | |
228 | - | else $Tuple2(nil, prologResult) | |
229 | - | } | |
227 | + | let prologActions = prolog(i) | |
228 | + | let address = toString(i.caller) | |
229 | + | if ((size(i.payments) != 1)) | |
230 | + | then throw("exactly 1 payment must be attached") | |
231 | + | else { | |
232 | + | let pmt = i.payments[0] | |
233 | + | let amt = pmt.amount | |
234 | + | if (if (!(isDefined(pmt.assetId))) | |
235 | + | then true | |
236 | + | else (value(pmt.assetId) != wlgAssetId)) | |
237 | + | then throw("WLGOLD payments only!") | |
238 | + | else if ((MULT8 > amt)) | |
239 | + | then throw((("Min payment should be " + fixedPoint(MULT8, 8)) + " WLGOLD")) | |
240 | + | else { | |
241 | + | let acresAmount = (amt * WLG2ACRES_MULTIPLIER) | |
242 | + | let wlgRemain = asInt(invoke(acres2Contract, "burnWlgold", nil, [AttachedPayment(wlgAssetId, amt)])) | |
243 | + | $Tuple2(([ScriptTransfer(i.caller, acresAmount, acresAssetId)] ++ prologActions), wlgRemain) | |
244 | + | } | |
230 | 245 | } | |
231 | - | else throw("Strict value is not equal to itself.") | |
232 | 246 | } | |
233 | 247 | ||
234 | 248 | ||
235 | 249 | ||
236 | 250 | @Callable(i) | |
237 | - | func claimAcres () = { | |
238 | - | let prologResult = prolog(i) | |
239 | - | if ((prologResult == prologResult)) | |
240 | - | then { | |
241 | - | let address = toString(i.caller) | |
242 | - | if ((size(i.payments) != 0)) | |
243 | - | then throw("No payments required") | |
244 | - | else { | |
245 | - | let timeKey = keyAcresStakedTimeByUser(address) | |
246 | - | let amountKey = keyAcresStakedAmountByUser(address) | |
247 | - | let acresAmount = valueOrElse(getInteger(amountKey), 0) | |
248 | - | let wlgResult = invoke(wlgContract, "onStakeUnstakeLand", [address], nil) | |
249 | - | let claimedAcres = claimInternal(address, acresAmount, valueOrElse(getInteger(timeKey), 0)) | |
250 | - | $Tuple2([IntegerEntry(timeKey, lastBlock.timestamp), ScriptTransfer(i.caller, claimedAcres, acresAssetId)], $Tuple2(prologResult, wlgResult)) | |
251 | + | func convertOldStakes () = { | |
252 | + | let address = toString(i.caller) | |
253 | + | if ((size(i.payments) != 0)) | |
254 | + | then throw("No payments required") | |
255 | + | else { | |
256 | + | let oldAcresAddress = addressFromStringValue(getStringValue(oldAcresContractKey)) | |
257 | + | let amount = valueOrElse(getInteger(oldAcresAddress, keyAcresStakedAmtByUser(address)), 0) | |
258 | + | let gotAcres0 = if ((amount > 0)) | |
259 | + | then asTuple2Ints(invoke(oldAcresAddress, "unstakeAcresCallback", [amount, address], nil)) | |
260 | + | else 0 | |
261 | + | let oldStakingAddress = addressFromStringValue(oldStakingContractStr) | |
262 | + | let landsStr = getString(oldStakingAddress, keyStakedLandsByOwner(address)) | |
263 | + | let landsResult = if (isDefined(landsStr)) | |
264 | + | then { | |
265 | + | let lands = split_51C(value(landsStr), "_") | |
266 | + | func oneLand (acc,landAssetId) = if ((landAssetId == "")) | |
267 | + | then throw("landAssetId is required") | |
268 | + | else { | |
269 | + | let r = asTuple5Ints(invoke(oldStakingAddress, "unstakeLandCallback", [landAssetId, address], nil)) | |
270 | + | $Tuple4((acc._1 + r._1), (acc._2 + r._2), (acc._3 + r._3), (acc._4 + r._4)) | |
271 | + | } | |
272 | + | ||
273 | + | let rr = { | |
274 | + | let $l = lands | |
275 | + | let $s = size($l) | |
276 | + | let $acc0 = $Tuple4(0, 0, 0, 0) | |
277 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
278 | + | then $a | |
279 | + | else oneLand($a, $l[$i]) | |
280 | + | ||
281 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
282 | + | then $a | |
283 | + | else throw("List size exceeds 100") | |
284 | + | ||
285 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50), 51), 52), 53), 54), 55), 56), 57), 58), 59), 60), 61), 62), 63), 64), 65), 66), 67), 68), 69), 70), 71), 72), 73), 74), 75), 76), 77), 78), 79), 80), 81), 82), 83), 84), 85), 86), 87), 88), 89), 90), 91), 92), 93), 94), 95), 96), 97), 98), 99), 100) | |
286 | + | } | |
287 | + | let finalize = invoke(oldStakingAddress, "unstakeLandsFinalizeCallback", [address], nil) | |
288 | + | if ((finalize == finalize)) | |
289 | + | then { | |
290 | + | let req = invoke(oldAcresAddress, "requestAcresCallback", [(((rr._1 + rr._2) + rr._3) + rr._4), address], nil) | |
291 | + | if ((req == req)) | |
292 | + | then { | |
293 | + | let issue = Issue("FPOWER10", "FarmingPower +10% NFT for WavesLands game", 1, 0, false) | |
294 | + | $Tuple5(rr._1, rr._2, rr._3, rr._4, [issue, ScriptTransfer(i.caller, 1, calculateAssetId(issue))]) | |
295 | + | } | |
296 | + | else throw("Strict value is not equal to itself.") | |
297 | + | } | |
298 | + | else throw("Strict value is not equal to itself.") | |
251 | 299 | } | |
300 | + | else $Tuple5(0, 0, 0, 0, nil) | |
301 | + | let duckAssetId = valueOrElse(getString(oldStakingAddress, keyStakedDuckByOwner(address)), "") | |
302 | + | let duckResult = if ((duckAssetId != "")) | |
303 | + | then asTuple3Ints(invoke(oldStakingAddress, "unstakeDuckCallback", [duckAssetId, address], nil)) | |
304 | + | else $Tuple3(0, 0, 0) | |
305 | + | let x = stakeAcresInternal((((((((gotAcres0 + landsResult._1) + landsResult._2) + landsResult._3) + landsResult._4) + duckResult._1) + duckResult._2) + duckResult._3), address) | |
306 | + | $Tuple2((landsResult._5 ++ x._1), x._2) | |
252 | 307 | } | |
253 | - | else throw("Strict value is not equal to itself.") | |
254 | 308 | } | |
255 | 309 | ||
256 | 310 | ||
257 | 311 | ||
258 | 312 | @Callable(i) | |
259 | - | func claimAcresREADONLY (address) = { | |
260 | - | let timeKey = keyAcresStakedTimeByUser(address) | |
261 | - | let amountKey = keyAcresStakedAmountByUser(address) | |
262 | - | let acresAmount = valueOrElse(getInteger(amountKey), 0) | |
263 | - | let lastTime = valueOrElse(getInteger(timeKey), 0) | |
264 | - | let claimedAcres = claimAcresInternal(address, acresAmount, lastTime) | |
265 | - | $Tuple2(nil, [claimedAcres, lastTime]) | |
266 | - | } | |
313 | + | func convertOldStakesREADONLY () = $Tuple2(nil, 0) | |
267 | 314 | ||
268 | 315 |
github/deemru/w8io/026f985 48.08 ms ◑