tx · GWecBuefRy863qXkyR1zwKtQE3w1fyEKp1SyNcxEnAC4 3N8y4wxX3JC4TdrCJBXX16SjWf6X256hrep: -0.01000000 Waves 2022.12.14 23:12 [2360451] smart account 3N8y4wxX3JC4TdrCJBXX16SjWf6X256hrep > SELF 0.00000000 Waves
{ "type": 13, "id": "GWecBuefRy863qXkyR1zwKtQE3w1fyEKp1SyNcxEnAC4", "fee": 1000000, "feeAssetId": null, "timestamp": 1671048778004, "version": 2, "chainId": 84, "sender": "3N8y4wxX3JC4TdrCJBXX16SjWf6X256hrep", "senderPublicKey": "7v5L7QkXxfkirALdyqmox38QCsa9jtfAtgUfHTh34eWq", "proofs": [ "LevTmvy5pUDacuz3P7gs8c4Diy6HrCk7gBeXeBrs3LtZxR2bJ92SSMMhzJZLFW2X1U9CQyN3N31u3JxE7BDZSEP" ], "script": "base64:BgIWCAISBQoDAQEBEgQKAhEREgUKAwEBAR0ABU1VTFQ2AMCEPQAFTVVMVDgAgMLXLwAFY2hhaW4JALAJAQkAyQECCQDKAQIIBQR0aGlzBWJ5dGVzAAEAAQALdXNkbkFzc2V0SWQEByRtYXRjaDAFBWNoYWluAwkAAAICAVcFByRtYXRjaDABILYmKcME9c5TkaQOS3UkL2SMUbH6369UKb1I0h0qsqrRAwkAAAICAVQFByRtYXRjaDABIPd26vf3g8pl224T7gI7z1gplanB0Y3yS9ps2B1igMjeCQACAQINVW5rbm93biBjaGFpbgAPc3Rha2luZ0NvbnRyYWN0CQERQGV4dHJOYXRpdmUoMTA2MikBBAckbWF0Y2gwBQVjaGFpbgMJAAACAgFXBQckbWF0Y2gwAiMzUExuY1h0UzFVODNENmNRYkZEM0g4ckJIUExnenhTRktaMQMJAAACAgFUBQckbWF0Y2gwAiMzTkRDeUJHNXE4NUp1YVJpaWdVZUV0YWlueWpDUVQzWHBabQkAAgECDVVua25vd24gY2hhaW4AD0RFRkFVTFRMT0NBVElPTgIPQWZyaWNhX0ZfQWZyaWNhAAZOVU1SRVMABgATRkFDV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WxsZXIJAGUCBQNhbXQIBQFiAl8yBQt1c2RuQXNzZXRJZAUDbmlsBQNuaWwJAJQKAgkAzQgCBQRyZXN0CAUBYgJfMQUGcmVzdWx0AAFuWXo=", "height": 2360451, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: J1yu5iTdahLA9Uo5ZUwXDVsxwhffx9hVUUZ7M8LdLYZp Next: B9qtHUB1u6bPNGS6AyHsk1ZYCRaK5Yx1o82XvZ5ZsAVd Diff:
Old | New | Differences | |
---|---|---|---|
33 | 33 | ||
34 | 34 | let RESOURCEPRICEMIN = 158549 | |
35 | 35 | ||
36 | + | let MINPAYMENT = 10000 | |
37 | + | ||
36 | 38 | let resTypes = ["Oil", "Ore", "Wood", "Sand", "Clay", "Organic"] | |
39 | + | ||
40 | + | let matTypes = ["Fuel", "Metal", "Plank", "Glass", "Plastic", "Protein"] | |
37 | 41 | ||
38 | 42 | let continents = ["Americas", "Europe", "Asia", "Africa", "Oceania"] | |
39 | 43 | ||
94 | 98 | } | |
95 | 99 | ||
96 | 100 | ||
97 | - | func buyInternal (locId,resType,amount,minPrice) = { | |
101 | + | func addMat (matList,matType,amount) = { | |
102 | + | func increaser (acc,i) = (acc :+ (if ((i == matType)) | |
103 | + | then toString((parseIntValue(matList[i]) + amount)) | |
104 | + | else matList[i])) | |
105 | + | ||
106 | + | let m = { | |
107 | + | let $l = [0, 1, 2, 3, 4, 5] | |
108 | + | let $s = size($l) | |
109 | + | let $acc0 = nil | |
110 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
111 | + | then $a | |
112 | + | else increaser($a, $l[$i]) | |
113 | + | ||
114 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
115 | + | then $a | |
116 | + | else throw("List size exceeds 6") | |
117 | + | ||
118 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
119 | + | } | |
120 | + | makeString(m, "_") | |
121 | + | } | |
122 | + | ||
123 | + | ||
124 | + | func sellInternal (locId,resType,amount,minPrice) = { | |
98 | 125 | let whKey = keyFactoryWarehouseByIdAndType(locId, resType) | |
99 | 126 | let w0 = valueOrElse(getInteger(whKey), 0) | |
100 | 127 | let r0 = if ((w0 > FACTORYMAXWAREHOUSE)) | |
107 | 134 | if (((min99 * amount) > (usdnReceived * MULT8))) | |
108 | 135 | then throw((((((((((("Actual price = " + toString(usdnReceived)) + " / ") + toString(amount)) + " < minPrice = ") + toString(minPrice)) + ", (") + locId) + ", ") + resTypes[resType]) + ")")) | |
109 | 136 | else $Tuple2(IntegerEntry(whKey, (w0 + amount)), usdnReceived) | |
137 | + | } | |
138 | + | ||
139 | + | ||
140 | + | func buyInternal (locId,matType,amount,maxPrice) = { | |
141 | + | let whKey = keyFactoryWarehouseByIdAndType(locId, matType) | |
142 | + | let w0 = valueOrElse(getInteger(whKey), 0) | |
143 | + | let m1 = if ((w0 > FACTORYMAXWAREHOUSE)) | |
144 | + | then min([amount, (w0 - FACTORYMAXWAREHOUSE)]) | |
145 | + | else 0 | |
146 | + | let m0 = min([w0, (amount - m1)]) | |
147 | + | let m = (m0 + m1) | |
148 | + | let usdnSpent = (fraction(m0, ((3 * RESOURCEPRICEMIN) - fraction((w0 - (m0 / 2)), RESOURCEPRICEMIN, FACTORYMAXWAREHOUSE)), MULT8) + fraction(m1, (2 * RESOURCEPRICEMIN), MULT8)) | |
149 | + | let max101 = (maxPrice + (maxPrice / 100)) | |
150 | + | if (((usdnSpent * MULT8) > (max101 * m))) | |
151 | + | then throw((((((((((("Actual price = " + toString(usdnSpent)) + " / ") + toString(m)) + " > maxPrice = ") + toString(maxPrice)) + ", (") + locId) + ", ") + matTypes[matType]) + ")")) | |
152 | + | else $Tuple3(IntegerEntry(whKey, (w0 - m)), usdnSpent, m) | |
110 | 153 | } | |
111 | 154 | ||
112 | 155 | ||
126 | 169 | if ((curLocation[locIdxType] != "F")) | |
127 | 170 | then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType])) | |
128 | 171 | else { | |
129 | - | let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0::"), ":") | |
172 | + | let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0:0_0_0_0_0_0:"), ":") | |
130 | 173 | let resList = split(currentPack[bpIdxRes], "_") | |
131 | 174 | let currentRes = parseIntValue(resList[resType]) | |
132 | 175 | if ((amount > currentRes)) | |
133 | 176 | then throw(((((("You have " + toString(currentRes)) + " of ") + resTypes[resType]) + " in backpack, but tried to sell ") + toString(amount))) | |
134 | 177 | else { | |
135 | - | let b = | |
178 | + | let b = sellInternal(curLocation[locIdxId], resType, amount, minPrice) | |
136 | 179 | let bpRes = subRes(resList, resType, amount) | |
137 | 180 | let newPack = makeString([currentPack[bpIdxLevel], bpRes, currentPack[bpIdxMat], currentPack[bpIdxProd]], ":") | |
138 | 181 | let result = asString(invoke(stakingContract, "updateBackpack", [duckAssetId, newPack], nil)) | |
155 | 198 | then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType])) | |
156 | 199 | else { | |
157 | 200 | let locId = curLocation[locIdxId] | |
158 | - | let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0::"), ":") | |
201 | + | let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0:0_0_0_0_0_0:"), ":") | |
159 | 202 | let resList = split(currentPack[bpIdxRes], "_") | |
160 | 203 | func adder (acc,idx) = { | |
161 | 204 | let j = indexOf(resTypes, idx) | |
162 | 205 | if (isDefined(j)) | |
163 | 206 | then { | |
164 | - | let b = | |
207 | + | let b = sellInternal(locId, idx, parseIntValue(resList[idx]), minPrices[value(j)]) | |
165 | 208 | $Tuple3((acc._1 :+ b._1), (acc._2 :+ "0"), (acc._3 + b._2)) | |
166 | 209 | } | |
167 | 210 | else $Tuple3(acc._1, (acc._2 :+ resList[idx]), acc._3) | |
189 | 232 | } | |
190 | 233 | ||
191 | 234 | ||
235 | + | ||
236 | + | @Callable(i) | |
237 | + | func buyMaterial (matType,amount,maxPrice) = if (if ((0 > matType)) | |
238 | + | then true | |
239 | + | else (matType >= NUMRES)) | |
240 | + | then throw(("Unknown material: " + toString(matType))) | |
241 | + | else if ((0 >= amount)) | |
242 | + | then throw(("Amount should be positive! " + toString(amount))) | |
243 | + | else { | |
244 | + | let duckAssetId = valueOrErrorMessage(getString(stakingContract, keyStakedDuckByOwner(toString(i.caller))), "You don't have a duck staked") | |
245 | + | if ((size(i.payments) != 1)) | |
246 | + | then throw("exactly 1 payment must be attached") | |
247 | + | else { | |
248 | + | let pmt = i.payments[0] | |
249 | + | let amt = pmt.amount | |
250 | + | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment") | |
251 | + | if ((pmtAssetId != usdnAssetId)) | |
252 | + | then throw("USDN payments only!") | |
253 | + | else { | |
254 | + | let curLocation = split(valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION), "_") | |
255 | + | if ((curLocation[locIdxType] != "F")) | |
256 | + | then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType])) | |
257 | + | else { | |
258 | + | let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0:0_0_0_0_0_0:"), ":") | |
259 | + | let matList = split(currentPack[bpIdxMat], "_") | |
260 | + | let currentMat = parseIntValue(matList[matType]) | |
261 | + | let b = buyInternal(curLocation[locIdxId], matType, amount, maxPrice) | |
262 | + | if ((b._2 > amt)) | |
263 | + | then throw(((((((("Your spending = " + toString(b._2)) + " USDN for ") + toString(b._3)) + " of ") + matTypes[matType]) + " is > attached payment = ") + toString(amt))) | |
264 | + | else if ((MINPAYMENT > b._2)) | |
265 | + | then throw(((((((("Your spending = " + toString(b._2)) + " USDN for ") + toString(b._3)) + " of ") + matTypes[matType]) + " is < minimal = ") + toString(MINPAYMENT))) | |
266 | + | else { | |
267 | + | let bpMat = addMat(matList, matType, b._3) | |
268 | + | let newPack = makeString([currentPack[bpIdxLevel], currentPack[bpIdxRes], bpMat, currentPack[bpIdxProd]], ":") | |
269 | + | let result = asString(invoke(stakingContract, "updateBackpack", [duckAssetId, newPack], nil)) | |
270 | + | let rest = if (((amt - b._2) > 0)) | |
271 | + | then [ScriptTransfer(i.caller, (amt - b._2), usdnAssetId)] | |
272 | + | else nil | |
273 | + | $Tuple2((rest :+ b._1), result) | |
274 | + | } | |
275 | + | } | |
276 | + | } | |
277 | + | } | |
278 | + | } | |
279 | + | ||
280 | + |
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 | + | let MINPAYMENT = 10000 | |
37 | + | ||
36 | 38 | let resTypes = ["Oil", "Ore", "Wood", "Sand", "Clay", "Organic"] | |
39 | + | ||
40 | + | let matTypes = ["Fuel", "Metal", "Plank", "Glass", "Plastic", "Protein"] | |
37 | 41 | ||
38 | 42 | let continents = ["Americas", "Europe", "Asia", "Africa", "Oceania"] | |
39 | 43 | ||
40 | 44 | func keyFactoryWarehouseByIdAndType (factoryId,resType) = ((("factoryWhByContinentAndRes_" + factoryId) + "_") + toString(resType)) | |
41 | 45 | ||
42 | 46 | ||
43 | 47 | func keyStakedDuckByOwner (ownerAddr) = ("stakedDuckByOwner_" + ownerAddr) | |
44 | 48 | ||
45 | 49 | ||
46 | 50 | func keyBackpackByDuck (duckAssetId) = ("backPack_" + duckAssetId) | |
47 | 51 | ||
48 | 52 | ||
49 | 53 | func keyDuckLocation (duckAssetId) = ("duckLocation_" + duckAssetId) | |
50 | 54 | ||
51 | 55 | ||
52 | 56 | let locIdxContinent = 0 | |
53 | 57 | ||
54 | 58 | let locIdxType = 1 | |
55 | 59 | ||
56 | 60 | let locIdxId = 2 | |
57 | 61 | ||
58 | 62 | let bpIdxLevel = 0 | |
59 | 63 | ||
60 | 64 | let bpIdxRes = 1 | |
61 | 65 | ||
62 | 66 | let bpIdxMat = 2 | |
63 | 67 | ||
64 | 68 | let bpIdxProd = 3 | |
65 | 69 | ||
66 | 70 | func asString (v) = match v { | |
67 | 71 | case s: String => | |
68 | 72 | s | |
69 | 73 | case _ => | |
70 | 74 | throw("fail to cast into String") | |
71 | 75 | } | |
72 | 76 | ||
73 | 77 | ||
74 | 78 | func subRes (resList,resType,amount) = { | |
75 | 79 | func subber (acc,i) = (acc :+ (if ((i == resType)) | |
76 | 80 | then toString((parseIntValue(resList[i]) - amount)) | |
77 | 81 | else resList[i])) | |
78 | 82 | ||
79 | 83 | let r = { | |
80 | 84 | let $l = [0, 1, 2, 3, 4, 5] | |
81 | 85 | let $s = size($l) | |
82 | 86 | let $acc0 = nil | |
83 | 87 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
84 | 88 | then $a | |
85 | 89 | else subber($a, $l[$i]) | |
86 | 90 | ||
87 | 91 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
88 | 92 | then $a | |
89 | 93 | else throw("List size exceeds 6") | |
90 | 94 | ||
91 | 95 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
92 | 96 | } | |
93 | 97 | makeString(r, "_") | |
94 | 98 | } | |
95 | 99 | ||
96 | 100 | ||
97 | - | func buyInternal (locId,resType,amount,minPrice) = { | |
101 | + | func addMat (matList,matType,amount) = { | |
102 | + | func increaser (acc,i) = (acc :+ (if ((i == matType)) | |
103 | + | then toString((parseIntValue(matList[i]) + amount)) | |
104 | + | else matList[i])) | |
105 | + | ||
106 | + | let m = { | |
107 | + | let $l = [0, 1, 2, 3, 4, 5] | |
108 | + | let $s = size($l) | |
109 | + | let $acc0 = nil | |
110 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
111 | + | then $a | |
112 | + | else increaser($a, $l[$i]) | |
113 | + | ||
114 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
115 | + | then $a | |
116 | + | else throw("List size exceeds 6") | |
117 | + | ||
118 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
119 | + | } | |
120 | + | makeString(m, "_") | |
121 | + | } | |
122 | + | ||
123 | + | ||
124 | + | func sellInternal (locId,resType,amount,minPrice) = { | |
98 | 125 | let whKey = keyFactoryWarehouseByIdAndType(locId, resType) | |
99 | 126 | let w0 = valueOrElse(getInteger(whKey), 0) | |
100 | 127 | let r0 = if ((w0 > FACTORYMAXWAREHOUSE)) | |
101 | 128 | then 0 | |
102 | 129 | else if (((w0 + amount) > FACTORYMAXWAREHOUSE)) | |
103 | 130 | then (FACTORYMAXWAREHOUSE - w0) | |
104 | 131 | else amount | |
105 | 132 | let usdnReceived = (fraction(r0, ((2 * RESOURCEPRICEMIN) - fraction((w0 + (r0 / 2)), RESOURCEPRICEMIN, FACTORYMAXWAREHOUSE)), MULT8) + fraction((amount - r0), RESOURCEPRICEMIN, MULT8)) | |
106 | 133 | let min99 = (minPrice - (minPrice / 100)) | |
107 | 134 | if (((min99 * amount) > (usdnReceived * MULT8))) | |
108 | 135 | then throw((((((((((("Actual price = " + toString(usdnReceived)) + " / ") + toString(amount)) + " < minPrice = ") + toString(minPrice)) + ", (") + locId) + ", ") + resTypes[resType]) + ")")) | |
109 | 136 | else $Tuple2(IntegerEntry(whKey, (w0 + amount)), usdnReceived) | |
137 | + | } | |
138 | + | ||
139 | + | ||
140 | + | func buyInternal (locId,matType,amount,maxPrice) = { | |
141 | + | let whKey = keyFactoryWarehouseByIdAndType(locId, matType) | |
142 | + | let w0 = valueOrElse(getInteger(whKey), 0) | |
143 | + | let m1 = if ((w0 > FACTORYMAXWAREHOUSE)) | |
144 | + | then min([amount, (w0 - FACTORYMAXWAREHOUSE)]) | |
145 | + | else 0 | |
146 | + | let m0 = min([w0, (amount - m1)]) | |
147 | + | let m = (m0 + m1) | |
148 | + | let usdnSpent = (fraction(m0, ((3 * RESOURCEPRICEMIN) - fraction((w0 - (m0 / 2)), RESOURCEPRICEMIN, FACTORYMAXWAREHOUSE)), MULT8) + fraction(m1, (2 * RESOURCEPRICEMIN), MULT8)) | |
149 | + | let max101 = (maxPrice + (maxPrice / 100)) | |
150 | + | if (((usdnSpent * MULT8) > (max101 * m))) | |
151 | + | then throw((((((((((("Actual price = " + toString(usdnSpent)) + " / ") + toString(m)) + " > maxPrice = ") + toString(maxPrice)) + ", (") + locId) + ", ") + matTypes[matType]) + ")")) | |
152 | + | else $Tuple3(IntegerEntry(whKey, (w0 - m)), usdnSpent, m) | |
110 | 153 | } | |
111 | 154 | ||
112 | 155 | ||
113 | 156 | @Callable(i) | |
114 | 157 | func sellResource (resType,amount,minPrice) = if (if ((0 > resType)) | |
115 | 158 | then true | |
116 | 159 | else (resType >= NUMRES)) | |
117 | 160 | then throw(("Unknown resource: " + toString(resType))) | |
118 | 161 | else if ((0 >= amount)) | |
119 | 162 | then throw(("Amount should be positive! " + toString(amount))) | |
120 | 163 | else { | |
121 | 164 | let duckAssetId = valueOrErrorMessage(getString(stakingContract, keyStakedDuckByOwner(toString(i.caller))), "You don't have a duck staked") | |
122 | 165 | if ((size(i.payments) != 0)) | |
123 | 166 | then throw("sellResources doesn't require any payments") | |
124 | 167 | else { | |
125 | 168 | let curLocation = split(valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION), "_") | |
126 | 169 | if ((curLocation[locIdxType] != "F")) | |
127 | 170 | then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType])) | |
128 | 171 | else { | |
129 | - | let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0::"), ":") | |
172 | + | let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0:0_0_0_0_0_0:"), ":") | |
130 | 173 | let resList = split(currentPack[bpIdxRes], "_") | |
131 | 174 | let currentRes = parseIntValue(resList[resType]) | |
132 | 175 | if ((amount > currentRes)) | |
133 | 176 | then throw(((((("You have " + toString(currentRes)) + " of ") + resTypes[resType]) + " in backpack, but tried to sell ") + toString(amount))) | |
134 | 177 | else { | |
135 | - | let b = | |
178 | + | let b = sellInternal(curLocation[locIdxId], resType, amount, minPrice) | |
136 | 179 | let bpRes = subRes(resList, resType, amount) | |
137 | 180 | let newPack = makeString([currentPack[bpIdxLevel], bpRes, currentPack[bpIdxMat], currentPack[bpIdxProd]], ":") | |
138 | 181 | let result = asString(invoke(stakingContract, "updateBackpack", [duckAssetId, newPack], nil)) | |
139 | 182 | $Tuple2([b._1, ScriptTransfer(i.caller, b._2, usdnAssetId)], result) | |
140 | 183 | } | |
141 | 184 | } | |
142 | 185 | } | |
143 | 186 | } | |
144 | 187 | ||
145 | 188 | ||
146 | 189 | ||
147 | 190 | @Callable(i) | |
148 | 191 | func sellResources (resTypes,minPrices) = { | |
149 | 192 | let duckAssetId = valueOrErrorMessage(getString(stakingContract, keyStakedDuckByOwner(toString(i.caller))), "You don't have a duck staked") | |
150 | 193 | if ((size(i.payments) != 0)) | |
151 | 194 | then throw("sellResources doesn't require any payments") | |
152 | 195 | else { | |
153 | 196 | let curLocation = split(valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION), "_") | |
154 | 197 | if ((curLocation[locIdxType] != "F")) | |
155 | 198 | then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType])) | |
156 | 199 | else { | |
157 | 200 | let locId = curLocation[locIdxId] | |
158 | - | let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0::"), ":") | |
201 | + | let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0:0_0_0_0_0_0:"), ":") | |
159 | 202 | let resList = split(currentPack[bpIdxRes], "_") | |
160 | 203 | func adder (acc,idx) = { | |
161 | 204 | let j = indexOf(resTypes, idx) | |
162 | 205 | if (isDefined(j)) | |
163 | 206 | then { | |
164 | - | let b = | |
207 | + | let b = sellInternal(locId, idx, parseIntValue(resList[idx]), minPrices[value(j)]) | |
165 | 208 | $Tuple3((acc._1 :+ b._1), (acc._2 :+ "0"), (acc._3 + b._2)) | |
166 | 209 | } | |
167 | 210 | else $Tuple3(acc._1, (acc._2 :+ resList[idx]), acc._3) | |
168 | 211 | } | |
169 | 212 | ||
170 | 213 | let merged = { | |
171 | 214 | let $l = [0, 1, 2, 3, 4, 5] | |
172 | 215 | let $s = size($l) | |
173 | 216 | let $acc0 = $Tuple3(nil, nil, 0) | |
174 | 217 | func $f0_1 ($a,$i) = if (($i >= $s)) | |
175 | 218 | then $a | |
176 | 219 | else adder($a, $l[$i]) | |
177 | 220 | ||
178 | 221 | func $f0_2 ($a,$i) = if (($i >= $s)) | |
179 | 222 | then $a | |
180 | 223 | else throw("List size exceeds 6") | |
181 | 224 | ||
182 | 225 | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6) | |
183 | 226 | } | |
184 | 227 | let newPack = makeString([currentPack[bpIdxLevel], makeString(merged._2, "_"), currentPack[bpIdxMat], currentPack[bpIdxProd]], ":") | |
185 | 228 | let result = asString(invoke(stakingContract, "updateBackpack", [duckAssetId, newPack], nil)) | |
186 | 229 | $Tuple2((merged._1 :+ ScriptTransfer(i.caller, merged._3, usdnAssetId)), result) | |
187 | 230 | } | |
188 | 231 | } | |
189 | 232 | } | |
190 | 233 | ||
191 | 234 | ||
235 | + | ||
236 | + | @Callable(i) | |
237 | + | func buyMaterial (matType,amount,maxPrice) = if (if ((0 > matType)) | |
238 | + | then true | |
239 | + | else (matType >= NUMRES)) | |
240 | + | then throw(("Unknown material: " + toString(matType))) | |
241 | + | else if ((0 >= amount)) | |
242 | + | then throw(("Amount should be positive! " + toString(amount))) | |
243 | + | else { | |
244 | + | let duckAssetId = valueOrErrorMessage(getString(stakingContract, keyStakedDuckByOwner(toString(i.caller))), "You don't have a duck staked") | |
245 | + | if ((size(i.payments) != 1)) | |
246 | + | then throw("exactly 1 payment must be attached") | |
247 | + | else { | |
248 | + | let pmt = i.payments[0] | |
249 | + | let amt = pmt.amount | |
250 | + | let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment") | |
251 | + | if ((pmtAssetId != usdnAssetId)) | |
252 | + | then throw("USDN payments only!") | |
253 | + | else { | |
254 | + | let curLocation = split(valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION), "_") | |
255 | + | if ((curLocation[locIdxType] != "F")) | |
256 | + | then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType])) | |
257 | + | else { | |
258 | + | let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0:0_0_0_0_0_0:"), ":") | |
259 | + | let matList = split(currentPack[bpIdxMat], "_") | |
260 | + | let currentMat = parseIntValue(matList[matType]) | |
261 | + | let b = buyInternal(curLocation[locIdxId], matType, amount, maxPrice) | |
262 | + | if ((b._2 > amt)) | |
263 | + | then throw(((((((("Your spending = " + toString(b._2)) + " USDN for ") + toString(b._3)) + " of ") + matTypes[matType]) + " is > attached payment = ") + toString(amt))) | |
264 | + | else if ((MINPAYMENT > b._2)) | |
265 | + | then throw(((((((("Your spending = " + toString(b._2)) + " USDN for ") + toString(b._3)) + " of ") + matTypes[matType]) + " is < minimal = ") + toString(MINPAYMENT))) | |
266 | + | else { | |
267 | + | let bpMat = addMat(matList, matType, b._3) | |
268 | + | let newPack = makeString([currentPack[bpIdxLevel], currentPack[bpIdxRes], bpMat, currentPack[bpIdxProd]], ":") | |
269 | + | let result = asString(invoke(stakingContract, "updateBackpack", [duckAssetId, newPack], nil)) | |
270 | + | let rest = if (((amt - b._2) > 0)) | |
271 | + | then [ScriptTransfer(i.caller, (amt - b._2), usdnAssetId)] | |
272 | + | else nil | |
273 | + | $Tuple2((rest :+ b._1), result) | |
274 | + | } | |
275 | + | } | |
276 | + | } | |
277 | + | } | |
278 | + | } | |
279 | + | ||
280 | + |
github/deemru/w8io/169f3d6 74.07 ms ◑