tx · 6p4KtqPMjd65JpcEk7jao7JR9RgZCYo1KSmVyesZPZcv 3N8y4wxX3JC4TdrCJBXX16SjWf6X256hrep: -0.01100000 Waves 2022.12.25 03:44 [2375113] smart account 3N8y4wxX3JC4TdrCJBXX16SjWf6X256hrep > SELF 0.00000000 Waves
{ "type": 13, "id": "6p4KtqPMjd65JpcEk7jao7JR9RgZCYo1KSmVyesZPZcv", "fee": 1100000, "feeAssetId": null, "timestamp": 1671929102199, "version": 2, "chainId": 84, "sender": "3N8y4wxX3JC4TdrCJBXX16SjWf6X256hrep", "senderPublicKey": "7v5L7QkXxfkirALdyqmox38QCsa9jtfAtgUfHTh34eWq", "proofs": [ "y1ZVXMKVRU9F14daQYR3cnhDMfaZeiRbQMmf6vyDJKmAFyyUaNBqeDvPUXUuaAG2a3PAAxWxEnfVD67vbpfkFck" ], "script": "base64:BgIcCAISBQoDAQEBEgQKAhEREgUKAwEBARIECgIRER4ABU1VTFQ2AMCEPQAFTVVMVDgAgMLXLwAFY2hhaW4JALAJAQkAyQECCQDKAQIIBQR0aGlzBWJ5dGVzAAEAAQALdXNkbkFzc2V0SWQEByRtYXRjaDAFBWNoYWluAwkAAAICAVcFByRtYXRjaDABILYmKcME9c5TkaQOS3UkL2SMUbH6369UKb1I0h0qsqrRAwkAAAICAVQFByRtYXRjaDABIPd26vf3g8pl224T7gI7z1gplanB0Y3yS9ps2B1igMjeCQACAQINVW5rbm93biBjaGFpbgAPc3Rha2luZ0NvbnRyYWN0CQERQGV4dHJOYXRpdmUoMTA2MikBBAckbWF0Y2gwBQVjaGFpbgMJAAACAgFXBQckbWF0Y2gwAiMzUExuY1h0UzFVODNENmNRYkZEM0g4ckJIUExnenhTRktaMQMJAAACAgFUBQckbWF0Y2gwAiMzTkRDeUJHNXE4NUp1YVJpaWdVZUV0YWlueWpDUVQzWHBabQkAAgECDVVua25vd24gY2hhaW4AD0RFRkFVTFRMT0NBVElPTgIPQWZyaWNhX0ZfQWZyaWNhAAZOVU1SRVM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EAAgADAAQABQAGAwkAZgIIBQZtZXJnZWQCXzMFA2FtdAkAAgEJAKwCAgkArAICCQCsAgICH0luc3VmZmljaWVudCBwYXltZW50ISBBdHRhY2hlZD0JAKQDAQUDYW10AgssIHJlcXVpcmVkPQkApAMBCAUGbWVyZ2VkAl8zBAduZXdQYWNrCQC5CQIJAMwIAgkAkQMCBQtjdXJyZW50UGFjawUKYnBJZHhMZXZlbAkAzAgCCQCRAwIFC2N1cnJlbnRQYWNrBQhicElkeFJlcwkAzAgCCQC5CQIIBQZtZXJnZWQCXzICAV8JAMwIAgkAkQMCBQtjdXJyZW50UGFjawUJYnBJZHhQcm9kBQNuaWwCAToEBnJlc3VsdAkBCGFzU3RyaW5nAQkA/AcEBQ9zdGFraW5nQ29udHJhY3QCDnVwZGF0ZUJhY2twYWNrCQDMCAIFC2R1Y2tBc3NldElkCQDMCAIFB25ld1BhY2sFA25pbAUDbmlsBARyZXN0AwkAZgIJAGUCBQNhbXQIBQZtZXJnZWQCXzMAAAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIJAGUCBQNhbXQIBQZtZXJnZWQCXzMFC3VzZG5Bc3NldElkBQNuaWwFA25pbAkAlAoCCQDOCAIIBQZtZXJnZWQCXzEFBHJlc3QFBnJlc3VsdABTA/Xd", "height": 2375113, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: B9qtHUB1u6bPNGS6AyHsk1ZYCRaK5Yx1o82XvZ5ZsAVd Next: EJj4FnSCZMQb4oixJba7kViPwDXYRrgaQ5EpLZk3MsLv Diff:
Old | New | Differences | |
---|---|---|---|
153 | 153 | } | |
154 | 154 | ||
155 | 155 | ||
156 | + | func getBackpack (bpKey) = { | |
157 | + | let p = split(valueOrElse(getString(stakingContract, bpKey), "0:0_0_0_0_0_0:0_0_0_0_0_0:"), ":") | |
158 | + | [toString(valueOrElse(parseInt(p[bpIdxLevel]), 0)), if ((size(split(p[bpIdxRes], "_")) == NUMRES)) | |
159 | + | then p[bpIdxRes] | |
160 | + | else "0_0_0_0_0_0", if ((size(split(p[bpIdxMat], "_")) == NUMRES)) | |
161 | + | then p[bpIdxMat] | |
162 | + | else "0_0_0_0_0_0", p[bpIdxProd]] | |
163 | + | } | |
164 | + | ||
165 | + | ||
156 | 166 | @Callable(i) | |
157 | 167 | func sellResource (resType,amount,minPrice) = if (if ((0 > resType)) | |
158 | 168 | then true | |
169 | 179 | if ((curLocation[locIdxType] != "F")) | |
170 | 180 | then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType])) | |
171 | 181 | else { | |
172 | - | let currentPack = | |
182 | + | let currentPack = getBackpack(keyBackpackByDuck(duckAssetId)) | |
173 | 183 | let resList = split(currentPack[bpIdxRes], "_") | |
174 | 184 | let currentRes = parseIntValue(resList[resType]) | |
175 | 185 | if ((amount > currentRes)) | |
198 | 208 | then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType])) | |
199 | 209 | else { | |
200 | 210 | let locId = curLocation[locIdxId] | |
201 | - | let currentPack = | |
211 | + | let currentPack = getBackpack(keyBackpackByDuck(duckAssetId)) | |
202 | 212 | let resList = split(currentPack[bpIdxRes], "_") | |
203 | 213 | func adder (acc,idx) = { | |
204 | 214 | let j = indexOf(resTypes, idx) | |
255 | 265 | if ((curLocation[locIdxType] != "F")) | |
256 | 266 | then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType])) | |
257 | 267 | else { | |
258 | - | let currentPack = | |
268 | + | let currentPack = getBackpack(keyBackpackByDuck(duckAssetId)) | |
259 | 269 | let matList = split(currentPack[bpIdxMat], "_") | |
260 | 270 | let currentMat = parseIntValue(matList[matType]) | |
261 | 271 | let b = buyInternal(curLocation[locIdxId], matType, amount, maxPrice) | |
296 | 306 | then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType])) | |
297 | 307 | else { | |
298 | 308 | let locId = curLocation[locIdxId] | |
299 | - | let currentPack = | |
309 | + | let currentPack = getBackpack(keyBackpackByDuck(duckAssetId)) | |
300 | 310 | let matList = split(currentPack[bpIdxMat], "_") | |
301 | 311 | func mUpdater (acc,j) = if ((amounts[j] > 0)) | |
302 | 312 | then { |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let MULT6 = 1000000 | |
5 | 5 | ||
6 | 6 | let MULT8 = 100000000 | |
7 | 7 | ||
8 | 8 | let chain = toUtf8String(take(drop(this.bytes, 1), 1)) | |
9 | 9 | ||
10 | 10 | let usdnAssetId = match chain { | |
11 | 11 | case _ => | |
12 | 12 | if (("W" == $match0)) | |
13 | 13 | then base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p' | |
14 | 14 | else if (("T" == $match0)) | |
15 | 15 | then base58'HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ' | |
16 | 16 | else throw("Unknown chain") | |
17 | 17 | } | |
18 | 18 | ||
19 | 19 | let stakingContract = addressFromStringValue(match chain { | |
20 | 20 | case _ => | |
21 | 21 | if (("W" == $match0)) | |
22 | 22 | then "3PLncXtS1U83D6cQbFD3H8rBHPLgzxSFKZ1" | |
23 | 23 | else if (("T" == $match0)) | |
24 | 24 | then "3NDCyBG5q85JuaRiigUeEtainyjCQT3XpZm" | |
25 | 25 | else throw("Unknown chain") | |
26 | 26 | }) | |
27 | 27 | ||
28 | 28 | let DEFAULTLOCATION = "Africa_F_Africa" | |
29 | 29 | ||
30 | 30 | let NUMRES = 6 | |
31 | 31 | ||
32 | 32 | let FACTORYMAXWAREHOUSE = 10000000000 | |
33 | 33 | ||
34 | 34 | let RESOURCEPRICEMIN = 158549 | |
35 | 35 | ||
36 | 36 | let MINPAYMENT = 10000 | |
37 | 37 | ||
38 | 38 | let resTypes = ["Oil", "Ore", "Wood", "Sand", "Clay", "Organic"] | |
39 | 39 | ||
40 | 40 | let matTypes = ["Fuel", "Metal", "Plank", "Glass", "Plastic", "Protein"] | |
41 | 41 | ||
42 | 42 | let continents = ["Americas", "Europe", "Asia", "Africa", "Oceania"] | |
43 | 43 | ||
44 | 44 | func keyFactoryWarehouseByIdAndType (factoryId,resType) = ((("factoryWhByContinentAndRes_" + factoryId) + "_") + toString(resType)) | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | func keyStakedDuckByOwner (ownerAddr) = ("stakedDuckByOwner_" + ownerAddr) | |
48 | 48 | ||
49 | 49 | ||
50 | 50 | func keyBackpackByDuck (duckAssetId) = ("backPack_" + duckAssetId) | |
51 | 51 | ||
52 | 52 | ||
53 | 53 | func keyDuckLocation (duckAssetId) = ("duckLocation_" + duckAssetId) | |
54 | 54 | ||
55 | 55 | ||
56 | 56 | let locIdxContinent = 0 | |
57 | 57 | ||
58 | 58 | let locIdxType = 1 | |
59 | 59 | ||
60 | 60 | let locIdxId = 2 | |
61 | 61 | ||
62 | 62 | let bpIdxLevel = 0 | |
63 | 63 | ||
64 | 64 | let bpIdxRes = 1 | |
65 | 65 | ||
66 | 66 | let bpIdxMat = 2 | |
67 | 67 | ||
68 | 68 | let bpIdxProd = 3 | |
69 | 69 | ||
70 | 70 | func asString (v) = match v { | |
71 | 71 | case s: String => | |
72 | 72 | s | |
73 | 73 | case _ => | |
74 | 74 | throw("fail to cast into String") | |
75 | 75 | } | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | func subRes (resList,resType,amount) = { | |
79 | 79 | func subber (acc,i) = (acc :+ (if ((i == resType)) | |
80 | 80 | then toString((parseIntValue(resList[i]) - amount)) | |
81 | 81 | else resList[i])) | |
82 | 82 | ||
83 | 83 | let r = { | |
84 | 84 | let $l = [0, 1, 2, 3, 4, 5] | |
85 | 85 | let $s = size($l) | |
86 | 86 | let $acc0 = nil | |
87 | 87 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
88 | 88 | then $a | |
89 | 89 | else subber($a, $l[$i]) | |
90 | 90 | ||
91 | 91 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
92 | 92 | then $a | |
93 | 93 | else throw("List size exceeds 6") | |
94 | 94 | ||
95 | 95 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
96 | 96 | } | |
97 | 97 | makeString(r, "_") | |
98 | 98 | } | |
99 | 99 | ||
100 | 100 | ||
101 | 101 | func addMat (matList,matType,amount) = { | |
102 | 102 | func increaser (acc,i) = (acc :+ (if ((i == matType)) | |
103 | 103 | then toString((parseIntValue(matList[i]) + amount)) | |
104 | 104 | else matList[i])) | |
105 | 105 | ||
106 | 106 | let m = { | |
107 | 107 | let $l = [0, 1, 2, 3, 4, 5] | |
108 | 108 | let $s = size($l) | |
109 | 109 | let $acc0 = nil | |
110 | 110 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
111 | 111 | then $a | |
112 | 112 | else increaser($a, $l[$i]) | |
113 | 113 | ||
114 | 114 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
115 | 115 | then $a | |
116 | 116 | else throw("List size exceeds 6") | |
117 | 117 | ||
118 | 118 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
119 | 119 | } | |
120 | 120 | makeString(m, "_") | |
121 | 121 | } | |
122 | 122 | ||
123 | 123 | ||
124 | 124 | func sellInternal (locId,resType,amount,minPrice) = { | |
125 | 125 | let whKey = keyFactoryWarehouseByIdAndType(locId, resType) | |
126 | 126 | let w0 = valueOrElse(getInteger(whKey), 0) | |
127 | 127 | let r0 = if ((w0 > FACTORYMAXWAREHOUSE)) | |
128 | 128 | then 0 | |
129 | 129 | else if (((w0 + amount) > FACTORYMAXWAREHOUSE)) | |
130 | 130 | then (FACTORYMAXWAREHOUSE - w0) | |
131 | 131 | else amount | |
132 | 132 | let usdnReceived = (fraction(r0, ((2 * RESOURCEPRICEMIN) - fraction((w0 + (r0 / 2)), RESOURCEPRICEMIN, FACTORYMAXWAREHOUSE)), MULT8) + fraction((amount - r0), RESOURCEPRICEMIN, MULT8)) | |
133 | 133 | let min99 = (minPrice - (minPrice / 100)) | |
134 | 134 | if (((min99 * amount) > (usdnReceived * MULT8))) | |
135 | 135 | then throw((((((((((("Actual price = " + toString(usdnReceived)) + " / ") + toString(amount)) + " < minPrice = ") + toString(minPrice)) + ", (") + locId) + ", ") + resTypes[resType]) + ")")) | |
136 | 136 | else $Tuple2(IntegerEntry(whKey, (w0 + amount)), usdnReceived) | |
137 | 137 | } | |
138 | 138 | ||
139 | 139 | ||
140 | 140 | func buyInternal (locId,matType,amount,maxPrice) = { | |
141 | 141 | let whKey = keyFactoryWarehouseByIdAndType(locId, matType) | |
142 | 142 | let w0 = valueOrElse(getInteger(whKey), 0) | |
143 | 143 | let m1 = if ((w0 > FACTORYMAXWAREHOUSE)) | |
144 | 144 | then min([amount, (w0 - FACTORYMAXWAREHOUSE)]) | |
145 | 145 | else 0 | |
146 | 146 | let m0 = min([w0, (amount - m1)]) | |
147 | 147 | let m = (m0 + m1) | |
148 | 148 | let usdnSpent = (fraction(m0, ((3 * RESOURCEPRICEMIN) - fraction((w0 - (m0 / 2)), RESOURCEPRICEMIN, FACTORYMAXWAREHOUSE)), MULT8) + fraction(m1, (2 * RESOURCEPRICEMIN), MULT8)) | |
149 | 149 | let max101 = (maxPrice + (maxPrice / 100)) | |
150 | 150 | if (((usdnSpent * MULT8) > (max101 * m))) | |
151 | 151 | then throw((((((((((("Actual price = " + toString(usdnSpent)) + " / ") + toString(m)) + " > maxPrice = ") + toString(maxPrice)) + ", (") + locId) + ", ") + matTypes[matType]) + ")")) | |
152 | 152 | else $Tuple3(IntegerEntry(whKey, (w0 - m)), usdnSpent, m) | |
153 | 153 | } | |
154 | 154 | ||
155 | 155 | ||
156 | + | func getBackpack (bpKey) = { | |
157 | + | let p = split(valueOrElse(getString(stakingContract, bpKey), "0:0_0_0_0_0_0:0_0_0_0_0_0:"), ":") | |
158 | + | [toString(valueOrElse(parseInt(p[bpIdxLevel]), 0)), if ((size(split(p[bpIdxRes], "_")) == NUMRES)) | |
159 | + | then p[bpIdxRes] | |
160 | + | else "0_0_0_0_0_0", if ((size(split(p[bpIdxMat], "_")) == NUMRES)) | |
161 | + | then p[bpIdxMat] | |
162 | + | else "0_0_0_0_0_0", p[bpIdxProd]] | |
163 | + | } | |
164 | + | ||
165 | + | ||
156 | 166 | @Callable(i) | |
157 | 167 | func sellResource (resType,amount,minPrice) = if (if ((0 > resType)) | |
158 | 168 | then true | |
159 | 169 | else (resType >= NUMRES)) | |
160 | 170 | then throw(("Unknown resource: " + toString(resType))) | |
161 | 171 | else if ((0 >= amount)) | |
162 | 172 | then throw(("Amount should be positive! " + toString(amount))) | |
163 | 173 | else { | |
164 | 174 | let duckAssetId = valueOrErrorMessage(getString(stakingContract, keyStakedDuckByOwner(toString(i.caller))), "You don't have a duck staked") | |
165 | 175 | if ((size(i.payments) != 0)) | |
166 | 176 | then throw("sellResources doesn't require any payments") | |
167 | 177 | else { | |
168 | 178 | let curLocation = split(valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION), "_") | |
169 | 179 | if ((curLocation[locIdxType] != "F")) | |
170 | 180 | then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType])) | |
171 | 181 | else { | |
172 | - | let currentPack = | |
182 | + | let currentPack = getBackpack(keyBackpackByDuck(duckAssetId)) | |
173 | 183 | let resList = split(currentPack[bpIdxRes], "_") | |
174 | 184 | let currentRes = parseIntValue(resList[resType]) | |
175 | 185 | if ((amount > currentRes)) | |
176 | 186 | then throw(((((("You have " + toString(currentRes)) + " of ") + resTypes[resType]) + " in backpack, but tried to sell ") + toString(amount))) | |
177 | 187 | else { | |
178 | 188 | let b = sellInternal(curLocation[locIdxId], resType, amount, minPrice) | |
179 | 189 | let bpRes = subRes(resList, resType, amount) | |
180 | 190 | let newPack = makeString([currentPack[bpIdxLevel], bpRes, currentPack[bpIdxMat], currentPack[bpIdxProd]], ":") | |
181 | 191 | let result = asString(invoke(stakingContract, "updateBackpack", [duckAssetId, newPack], nil)) | |
182 | 192 | $Tuple2([b._1, ScriptTransfer(i.caller, b._2, usdnAssetId)], result) | |
183 | 193 | } | |
184 | 194 | } | |
185 | 195 | } | |
186 | 196 | } | |
187 | 197 | ||
188 | 198 | ||
189 | 199 | ||
190 | 200 | @Callable(i) | |
191 | 201 | func sellResources (resTypes,minPrices) = { | |
192 | 202 | let duckAssetId = valueOrErrorMessage(getString(stakingContract, keyStakedDuckByOwner(toString(i.caller))), "You don't have a duck staked") | |
193 | 203 | if ((size(i.payments) != 0)) | |
194 | 204 | then throw("sellResources doesn't require any payments") | |
195 | 205 | else { | |
196 | 206 | let curLocation = split(valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION), "_") | |
197 | 207 | if ((curLocation[locIdxType] != "F")) | |
198 | 208 | then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType])) | |
199 | 209 | else { | |
200 | 210 | let locId = curLocation[locIdxId] | |
201 | - | let currentPack = | |
211 | + | let currentPack = getBackpack(keyBackpackByDuck(duckAssetId)) | |
202 | 212 | let resList = split(currentPack[bpIdxRes], "_") | |
203 | 213 | func adder (acc,idx) = { | |
204 | 214 | let j = indexOf(resTypes, idx) | |
205 | 215 | if (isDefined(j)) | |
206 | 216 | then { | |
207 | 217 | let b = sellInternal(locId, idx, parseIntValue(resList[idx]), minPrices[value(j)]) | |
208 | 218 | $Tuple3((acc._1 :+ b._1), (acc._2 :+ "0"), (acc._3 + b._2)) | |
209 | 219 | } | |
210 | 220 | else $Tuple3(acc._1, (acc._2 :+ resList[idx]), acc._3) | |
211 | 221 | } | |
212 | 222 | ||
213 | 223 | let merged = { | |
214 | 224 | let $l = [0, 1, 2, 3, 4, 5] | |
215 | 225 | let $s = size($l) | |
216 | 226 | let $acc0 = $Tuple3(nil, nil, 0) | |
217 | 227 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
218 | 228 | then $a | |
219 | 229 | else adder($a, $l[$i]) | |
220 | 230 | ||
221 | 231 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
222 | 232 | then $a | |
223 | 233 | else throw("List size exceeds 6") | |
224 | 234 | ||
225 | 235 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
226 | 236 | } | |
227 | 237 | let newPack = makeString([currentPack[bpIdxLevel], makeString(merged._2, "_"), currentPack[bpIdxMat], currentPack[bpIdxProd]], ":") | |
228 | 238 | let result = asString(invoke(stakingContract, "updateBackpack", [duckAssetId, newPack], nil)) | |
229 | 239 | $Tuple2((merged._1 :+ ScriptTransfer(i.caller, merged._3, usdnAssetId)), result) | |
230 | 240 | } | |
231 | 241 | } | |
232 | 242 | } | |
233 | 243 | ||
234 | 244 | ||
235 | 245 | ||
236 | 246 | @Callable(i) | |
237 | 247 | func buyMaterial (matType,amount,maxPrice) = if (if ((0 > matType)) | |
238 | 248 | then true | |
239 | 249 | else (matType >= NUMRES)) | |
240 | 250 | then throw(("Unknown material: " + toString(matType))) | |
241 | 251 | else if ((0 >= amount)) | |
242 | 252 | then throw(("Amount should be positive! " + toString(amount))) | |
243 | 253 | else { | |
244 | 254 | let duckAssetId = valueOrErrorMessage(getString(stakingContract, keyStakedDuckByOwner(toString(i.caller))), "You don't have a duck staked") | |
245 | 255 | if ((size(i.payments) != 1)) | |
246 | 256 | then throw("exactly 1 payment must be attached") | |
247 | 257 | else { | |
248 | 258 | let pmt = i.payments[0] | |
249 | 259 | let amt = pmt.amount | |
250 | 260 | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment") | |
251 | 261 | if ((pmtAssetId != usdnAssetId)) | |
252 | 262 | then throw("USDN payments only!") | |
253 | 263 | else { | |
254 | 264 | let curLocation = split(valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION), "_") | |
255 | 265 | if ((curLocation[locIdxType] != "F")) | |
256 | 266 | then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType])) | |
257 | 267 | else { | |
258 | - | let currentPack = | |
268 | + | let currentPack = getBackpack(keyBackpackByDuck(duckAssetId)) | |
259 | 269 | let matList = split(currentPack[bpIdxMat], "_") | |
260 | 270 | let currentMat = parseIntValue(matList[matType]) | |
261 | 271 | let b = buyInternal(curLocation[locIdxId], matType, amount, maxPrice) | |
262 | 272 | if ((b._2 > amt)) | |
263 | 273 | then throw(((((((("Your spending = " + toString(b._2)) + " USDN for ") + toString(b._3)) + " of ") + matTypes[matType]) + " is > attached payment = ") + toString(amt))) | |
264 | 274 | else if ((MINPAYMENT > b._2)) | |
265 | 275 | then throw(((((((("Your spending = " + toString(b._2)) + " USDN for ") + toString(b._3)) + " of ") + matTypes[matType]) + " is < minimal = ") + toString(MINPAYMENT))) | |
266 | 276 | else { | |
267 | 277 | let bpMat = addMat(matList, matType, b._3) | |
268 | 278 | let newPack = makeString([currentPack[bpIdxLevel], currentPack[bpIdxRes], bpMat, currentPack[bpIdxProd]], ":") | |
269 | 279 | let result = asString(invoke(stakingContract, "updateBackpack", [duckAssetId, newPack], nil)) | |
270 | 280 | let rest = if (((amt - b._2) > 0)) | |
271 | 281 | then [ScriptTransfer(i.caller, (amt - b._2), usdnAssetId)] | |
272 | 282 | else nil | |
273 | 283 | $Tuple2((rest :+ b._1), result) | |
274 | 284 | } | |
275 | 285 | } | |
276 | 286 | } | |
277 | 287 | } | |
278 | 288 | } | |
279 | 289 | ||
280 | 290 | ||
281 | 291 | ||
282 | 292 | @Callable(i) | |
283 | 293 | func buyMaterials (amounts,maxPrices) = { | |
284 | 294 | let duckAssetId = valueOrErrorMessage(getString(stakingContract, keyStakedDuckByOwner(toString(i.caller))), "You don't have a duck staked") | |
285 | 295 | if ((size(i.payments) != 1)) | |
286 | 296 | then throw("exactly 1 payment must be attached") | |
287 | 297 | else { | |
288 | 298 | let pmt = i.payments[0] | |
289 | 299 | let amt = pmt.amount | |
290 | 300 | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment") | |
291 | 301 | if ((pmtAssetId != usdnAssetId)) | |
292 | 302 | then throw("USDN payments only!") | |
293 | 303 | else { | |
294 | 304 | let curLocation = split(valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION), "_") | |
295 | 305 | if ((curLocation[locIdxType] != "F")) | |
296 | 306 | then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType])) | |
297 | 307 | else { | |
298 | 308 | let locId = curLocation[locIdxId] | |
299 | - | let currentPack = | |
309 | + | let currentPack = getBackpack(keyBackpackByDuck(duckAssetId)) | |
300 | 310 | let matList = split(currentPack[bpIdxMat], "_") | |
301 | 311 | func mUpdater (acc,j) = if ((amounts[j] > 0)) | |
302 | 312 | then { | |
303 | 313 | let b = buyInternal(locId, j, amounts[j], maxPrices[j]) | |
304 | 314 | $Tuple3((acc._1 :+ b._1), (acc._2 :+ toString((parseIntValue(matList[j]) + b._3))), (acc._3 + b._2)) | |
305 | 315 | } | |
306 | 316 | else $Tuple3(acc._1, (acc._2 :+ matList[j]), acc._3) | |
307 | 317 | ||
308 | 318 | let merged = { | |
309 | 319 | let $l = [0, 1, 2, 3, 4, 5] | |
310 | 320 | let $s = size($l) | |
311 | 321 | let $acc0 = $Tuple3(nil, nil, 0) | |
312 | 322 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
313 | 323 | then $a | |
314 | 324 | else mUpdater($a, $l[$i]) | |
315 | 325 | ||
316 | 326 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
317 | 327 | then $a | |
318 | 328 | else throw("List size exceeds 6") | |
319 | 329 | ||
320 | 330 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
321 | 331 | } | |
322 | 332 | if ((merged._3 > amt)) | |
323 | 333 | then throw(((("Insufficient payment! Attached=" + toString(amt)) + ", required=") + toString(merged._3))) | |
324 | 334 | else { | |
325 | 335 | let newPack = makeString([currentPack[bpIdxLevel], currentPack[bpIdxRes], makeString(merged._2, "_"), currentPack[bpIdxProd]], ":") | |
326 | 336 | let result = asString(invoke(stakingContract, "updateBackpack", [duckAssetId, newPack], nil)) | |
327 | 337 | let rest = if (((amt - merged._3) > 0)) | |
328 | 338 | then [ScriptTransfer(i.caller, (amt - merged._3), usdnAssetId)] | |
329 | 339 | else nil | |
330 | 340 | $Tuple2((merged._1 ++ rest), result) | |
331 | 341 | } | |
332 | 342 | } | |
333 | 343 | } | |
334 | 344 | } | |
335 | 345 | } | |
336 | 346 | ||
337 | 347 |
github/deemru/w8io/169f3d6 48.80 ms ◑