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:BgIcCAISBQoDAQEBEgQKAhEREgUKAwEBARIECgIRER4ABU1VTFQ2AMCEPQAFTVVMVDgAgMLXLwAFY2hhaW4JALAJAQkAyQECCQDKAQIIBQR0aGlzBWJ5dGVzAAEAAQALdXNkbkFzc2V0SWQEByRtYXRjaDAFBWNoYWluAwkAAAICAVcFByRtYXRjaDABILYmKcME9c5TkaQOS3UkL2SMUbH6369UKb1I0h0qsqrRAwkAAAICAVQFByRtYXRjaDABIPd26vf3g8pl224T7gI7z1gplanB0Y3yS9ps2B1igMjeCQACAQINVW5rbm93biBjaGFpbgAPc3Rha2luZ0NvbnRyYWN0CQERQGV4dHJOYXRpdmUoMTA2MikBBAckbWF0Y2gwBQVjaGFpbgMJAAACAgFXBQckbWF0Y2gwAiMzUExuY1h0UzFVODNENmNRYkZEM0g4ckJIUExnenhTRktaMQMJAAACAgFUBQckbWF0Y2gwAiMzTkRDeUJHNXE4NUp1YVJpaWdVZUV0YWlueWpDUVQzWHBabQkAAgECDVVua25vd24gY2hhaW4AD0RFRkFVTFRMT0NBVElPTgIPQWZyaWNhX0ZfQWZyaWNhAAZOVU1SRV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AEAAgADAAQABQAGAwkAZgIIBQZtZXJnZWQCXzMFA2FtdAkAAgEJAKwCAgkArAICCQCsAgICH0luc3VmZmljaWVudCBwYXltZW50ISBBdHRhY2hlZD0JAKQDAQUDYW10AgssIHJlcXVpcmVkPQkApAMBCAUGbWVyZ2VkAl8zBAduZXdQYWNrCQC5CQIJAMwIAgkAkQMCBQtjdXJyZW50UGFjawUKYnBJZHhMZXZlbAkAzAgCCQCRAwIFC2N1cnJlbnRQYWNrBQhicElkeFJlcwkAzAgCCQC5CQIIBQZtZXJnZWQCXzICAV8JAMwIAgkAkQMCBQtjdXJyZW50UGFjawUJYnBJZHhQcm9kBQNuaWwCAToEBnJlc3VsdAkBCGFzU3RyaW5nAQkA/AcEBQ9zdGFraW5nQ29udHJhY3QCDnVwZGF0ZUJhY2twYWNrCQDMCAIFC2R1Y2tBc3NldElkCQDMCAIFB25ld1BhY2sFA25pbAUDbmlsBARyZXN0AwkAZgIJAGUCBQNhbXQIBQZtZXJnZWQCXzMAAAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIJAGUCBQNhbXQIBQZtZXJnZWQCXzMFC3VzZG5Bc3NldElkBQNuaWwFA25pbAkAlAoCCQDOCAIIBQZtZXJnZWQCXzEFBHJlc3QFBnJlc3VsdABTA/Xd", "height": 2375113, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: B9qtHUB1u6bPNGS6AyHsk1ZYCRaK5Yx1o82XvZ5ZsAVd Next: EJj4FnSCZMQb4oixJba7kViPwDXYRrgaQ5EpLZk3MsLv Diff:
OldNewDifferences
153153 }
154154
155155
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+
156166 @Callable(i)
157167 func sellResource (resType,amount,minPrice) = if (if ((0 > resType))
158168 then true
169179 if ((curLocation[locIdxType] != "F"))
170180 then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType]))
171181 else {
172- let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0:0_0_0_0_0_0:"), ":")
182+ let currentPack = getBackpack(keyBackpackByDuck(duckAssetId))
173183 let resList = split(currentPack[bpIdxRes], "_")
174184 let currentRes = parseIntValue(resList[resType])
175185 if ((amount > currentRes))
198208 then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType]))
199209 else {
200210 let locId = curLocation[locIdxId]
201- let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0:0_0_0_0_0_0:"), ":")
211+ let currentPack = getBackpack(keyBackpackByDuck(duckAssetId))
202212 let resList = split(currentPack[bpIdxRes], "_")
203213 func adder (acc,idx) = {
204214 let j = indexOf(resTypes, idx)
255265 if ((curLocation[locIdxType] != "F"))
256266 then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType]))
257267 else {
258- let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0:0_0_0_0_0_0:"), ":")
268+ let currentPack = getBackpack(keyBackpackByDuck(duckAssetId))
259269 let matList = split(currentPack[bpIdxMat], "_")
260270 let currentMat = parseIntValue(matList[matType])
261271 let b = buyInternal(curLocation[locIdxId], matType, amount, maxPrice)
296306 then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType]))
297307 else {
298308 let locId = curLocation[locIdxId]
299- let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0:0_0_0_0_0_0:"), ":")
309+ let currentPack = getBackpack(keyBackpackByDuck(duckAssetId))
300310 let matList = split(currentPack[bpIdxMat], "_")
301311 func mUpdater (acc,j) = if ((amounts[j] > 0))
302312 then {
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let MULT6 = 1000000
55
66 let MULT8 = 100000000
77
88 let chain = toUtf8String(take(drop(this.bytes, 1), 1))
99
1010 let usdnAssetId = match chain {
1111 case _ =>
1212 if (("W" == $match0))
1313 then base58'DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p'
1414 else if (("T" == $match0))
1515 then base58'HezsdQuRDtzksAYUy97gfhKy7Z1NW2uXYSHA3bgqenNZ'
1616 else throw("Unknown chain")
1717 }
1818
1919 let stakingContract = addressFromStringValue(match chain {
2020 case _ =>
2121 if (("W" == $match0))
2222 then "3PLncXtS1U83D6cQbFD3H8rBHPLgzxSFKZ1"
2323 else if (("T" == $match0))
2424 then "3NDCyBG5q85JuaRiigUeEtainyjCQT3XpZm"
2525 else throw("Unknown chain")
2626 })
2727
2828 let DEFAULTLOCATION = "Africa_F_Africa"
2929
3030 let NUMRES = 6
3131
3232 let FACTORYMAXWAREHOUSE = 10000000000
3333
3434 let RESOURCEPRICEMIN = 158549
3535
3636 let MINPAYMENT = 10000
3737
3838 let resTypes = ["Oil", "Ore", "Wood", "Sand", "Clay", "Organic"]
3939
4040 let matTypes = ["Fuel", "Metal", "Plank", "Glass", "Plastic", "Protein"]
4141
4242 let continents = ["Americas", "Europe", "Asia", "Africa", "Oceania"]
4343
4444 func keyFactoryWarehouseByIdAndType (factoryId,resType) = ((("factoryWhByContinentAndRes_" + factoryId) + "_") + toString(resType))
4545
4646
4747 func keyStakedDuckByOwner (ownerAddr) = ("stakedDuckByOwner_" + ownerAddr)
4848
4949
5050 func keyBackpackByDuck (duckAssetId) = ("backPack_" + duckAssetId)
5151
5252
5353 func keyDuckLocation (duckAssetId) = ("duckLocation_" + duckAssetId)
5454
5555
5656 let locIdxContinent = 0
5757
5858 let locIdxType = 1
5959
6060 let locIdxId = 2
6161
6262 let bpIdxLevel = 0
6363
6464 let bpIdxRes = 1
6565
6666 let bpIdxMat = 2
6767
6868 let bpIdxProd = 3
6969
7070 func asString (v) = match v {
7171 case s: String =>
7272 s
7373 case _ =>
7474 throw("fail to cast into String")
7575 }
7676
7777
7878 func subRes (resList,resType,amount) = {
7979 func subber (acc,i) = (acc :+ (if ((i == resType))
8080 then toString((parseIntValue(resList[i]) - amount))
8181 else resList[i]))
8282
8383 let r = {
8484 let $l = [0, 1, 2, 3, 4, 5]
8585 let $s = size($l)
8686 let $acc0 = nil
8787 func $f0_1 ($a,$i) = if (($i >= $s))
8888 then $a
8989 else subber($a, $l[$i])
9090
9191 func $f0_2 ($a,$i) = if (($i >= $s))
9292 then $a
9393 else throw("List size exceeds 6")
9494
9595 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6)
9696 }
9797 makeString(r, "_")
9898 }
9999
100100
101101 func addMat (matList,matType,amount) = {
102102 func increaser (acc,i) = (acc :+ (if ((i == matType))
103103 then toString((parseIntValue(matList[i]) + amount))
104104 else matList[i]))
105105
106106 let m = {
107107 let $l = [0, 1, 2, 3, 4, 5]
108108 let $s = size($l)
109109 let $acc0 = nil
110110 func $f0_1 ($a,$i) = if (($i >= $s))
111111 then $a
112112 else increaser($a, $l[$i])
113113
114114 func $f0_2 ($a,$i) = if (($i >= $s))
115115 then $a
116116 else throw("List size exceeds 6")
117117
118118 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6)
119119 }
120120 makeString(m, "_")
121121 }
122122
123123
124124 func sellInternal (locId,resType,amount,minPrice) = {
125125 let whKey = keyFactoryWarehouseByIdAndType(locId, resType)
126126 let w0 = valueOrElse(getInteger(whKey), 0)
127127 let r0 = if ((w0 > FACTORYMAXWAREHOUSE))
128128 then 0
129129 else if (((w0 + amount) > FACTORYMAXWAREHOUSE))
130130 then (FACTORYMAXWAREHOUSE - w0)
131131 else amount
132132 let usdnReceived = (fraction(r0, ((2 * RESOURCEPRICEMIN) - fraction((w0 + (r0 / 2)), RESOURCEPRICEMIN, FACTORYMAXWAREHOUSE)), MULT8) + fraction((amount - r0), RESOURCEPRICEMIN, MULT8))
133133 let min99 = (minPrice - (minPrice / 100))
134134 if (((min99 * amount) > (usdnReceived * MULT8)))
135135 then throw((((((((((("Actual price = " + toString(usdnReceived)) + " / ") + toString(amount)) + " < minPrice = ") + toString(minPrice)) + ", (") + locId) + ", ") + resTypes[resType]) + ")"))
136136 else $Tuple2(IntegerEntry(whKey, (w0 + amount)), usdnReceived)
137137 }
138138
139139
140140 func buyInternal (locId,matType,amount,maxPrice) = {
141141 let whKey = keyFactoryWarehouseByIdAndType(locId, matType)
142142 let w0 = valueOrElse(getInteger(whKey), 0)
143143 let m1 = if ((w0 > FACTORYMAXWAREHOUSE))
144144 then min([amount, (w0 - FACTORYMAXWAREHOUSE)])
145145 else 0
146146 let m0 = min([w0, (amount - m1)])
147147 let m = (m0 + m1)
148148 let usdnSpent = (fraction(m0, ((3 * RESOURCEPRICEMIN) - fraction((w0 - (m0 / 2)), RESOURCEPRICEMIN, FACTORYMAXWAREHOUSE)), MULT8) + fraction(m1, (2 * RESOURCEPRICEMIN), MULT8))
149149 let max101 = (maxPrice + (maxPrice / 100))
150150 if (((usdnSpent * MULT8) > (max101 * m)))
151151 then throw((((((((((("Actual price = " + toString(usdnSpent)) + " / ") + toString(m)) + " > maxPrice = ") + toString(maxPrice)) + ", (") + locId) + ", ") + matTypes[matType]) + ")"))
152152 else $Tuple3(IntegerEntry(whKey, (w0 - m)), usdnSpent, m)
153153 }
154154
155155
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+
156166 @Callable(i)
157167 func sellResource (resType,amount,minPrice) = if (if ((0 > resType))
158168 then true
159169 else (resType >= NUMRES))
160170 then throw(("Unknown resource: " + toString(resType)))
161171 else if ((0 >= amount))
162172 then throw(("Amount should be positive! " + toString(amount)))
163173 else {
164174 let duckAssetId = valueOrErrorMessage(getString(stakingContract, keyStakedDuckByOwner(toString(i.caller))), "You don't have a duck staked")
165175 if ((size(i.payments) != 0))
166176 then throw("sellResources doesn't require any payments")
167177 else {
168178 let curLocation = split(valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION), "_")
169179 if ((curLocation[locIdxType] != "F"))
170180 then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType]))
171181 else {
172- let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0:0_0_0_0_0_0:"), ":")
182+ let currentPack = getBackpack(keyBackpackByDuck(duckAssetId))
173183 let resList = split(currentPack[bpIdxRes], "_")
174184 let currentRes = parseIntValue(resList[resType])
175185 if ((amount > currentRes))
176186 then throw(((((("You have " + toString(currentRes)) + " of ") + resTypes[resType]) + " in backpack, but tried to sell ") + toString(amount)))
177187 else {
178188 let b = sellInternal(curLocation[locIdxId], resType, amount, minPrice)
179189 let bpRes = subRes(resList, resType, amount)
180190 let newPack = makeString([currentPack[bpIdxLevel], bpRes, currentPack[bpIdxMat], currentPack[bpIdxProd]], ":")
181191 let result = asString(invoke(stakingContract, "updateBackpack", [duckAssetId, newPack], nil))
182192 $Tuple2([b._1, ScriptTransfer(i.caller, b._2, usdnAssetId)], result)
183193 }
184194 }
185195 }
186196 }
187197
188198
189199
190200 @Callable(i)
191201 func sellResources (resTypes,minPrices) = {
192202 let duckAssetId = valueOrErrorMessage(getString(stakingContract, keyStakedDuckByOwner(toString(i.caller))), "You don't have a duck staked")
193203 if ((size(i.payments) != 0))
194204 then throw("sellResources doesn't require any payments")
195205 else {
196206 let curLocation = split(valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION), "_")
197207 if ((curLocation[locIdxType] != "F"))
198208 then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType]))
199209 else {
200210 let locId = curLocation[locIdxId]
201- let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0:0_0_0_0_0_0:"), ":")
211+ let currentPack = getBackpack(keyBackpackByDuck(duckAssetId))
202212 let resList = split(currentPack[bpIdxRes], "_")
203213 func adder (acc,idx) = {
204214 let j = indexOf(resTypes, idx)
205215 if (isDefined(j))
206216 then {
207217 let b = sellInternal(locId, idx, parseIntValue(resList[idx]), minPrices[value(j)])
208218 $Tuple3((acc._1 :+ b._1), (acc._2 :+ "0"), (acc._3 + b._2))
209219 }
210220 else $Tuple3(acc._1, (acc._2 :+ resList[idx]), acc._3)
211221 }
212222
213223 let merged = {
214224 let $l = [0, 1, 2, 3, 4, 5]
215225 let $s = size($l)
216226 let $acc0 = $Tuple3(nil, nil, 0)
217227 func $f0_1 ($a,$i) = if (($i >= $s))
218228 then $a
219229 else adder($a, $l[$i])
220230
221231 func $f0_2 ($a,$i) = if (($i >= $s))
222232 then $a
223233 else throw("List size exceeds 6")
224234
225235 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6)
226236 }
227237 let newPack = makeString([currentPack[bpIdxLevel], makeString(merged._2, "_"), currentPack[bpIdxMat], currentPack[bpIdxProd]], ":")
228238 let result = asString(invoke(stakingContract, "updateBackpack", [duckAssetId, newPack], nil))
229239 $Tuple2((merged._1 :+ ScriptTransfer(i.caller, merged._3, usdnAssetId)), result)
230240 }
231241 }
232242 }
233243
234244
235245
236246 @Callable(i)
237247 func buyMaterial (matType,amount,maxPrice) = if (if ((0 > matType))
238248 then true
239249 else (matType >= NUMRES))
240250 then throw(("Unknown material: " + toString(matType)))
241251 else if ((0 >= amount))
242252 then throw(("Amount should be positive! " + toString(amount)))
243253 else {
244254 let duckAssetId = valueOrErrorMessage(getString(stakingContract, keyStakedDuckByOwner(toString(i.caller))), "You don't have a duck staked")
245255 if ((size(i.payments) != 1))
246256 then throw("exactly 1 payment must be attached")
247257 else {
248258 let pmt = i.payments[0]
249259 let amt = pmt.amount
250260 let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment")
251261 if ((pmtAssetId != usdnAssetId))
252262 then throw("USDN payments only!")
253263 else {
254264 let curLocation = split(valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION), "_")
255265 if ((curLocation[locIdxType] != "F"))
256266 then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType]))
257267 else {
258- let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0:0_0_0_0_0_0:"), ":")
268+ let currentPack = getBackpack(keyBackpackByDuck(duckAssetId))
259269 let matList = split(currentPack[bpIdxMat], "_")
260270 let currentMat = parseIntValue(matList[matType])
261271 let b = buyInternal(curLocation[locIdxId], matType, amount, maxPrice)
262272 if ((b._2 > amt))
263273 then throw(((((((("Your spending = " + toString(b._2)) + " USDN for ") + toString(b._3)) + " of ") + matTypes[matType]) + " is > attached payment = ") + toString(amt)))
264274 else if ((MINPAYMENT > b._2))
265275 then throw(((((((("Your spending = " + toString(b._2)) + " USDN for ") + toString(b._3)) + " of ") + matTypes[matType]) + " is < minimal = ") + toString(MINPAYMENT)))
266276 else {
267277 let bpMat = addMat(matList, matType, b._3)
268278 let newPack = makeString([currentPack[bpIdxLevel], currentPack[bpIdxRes], bpMat, currentPack[bpIdxProd]], ":")
269279 let result = asString(invoke(stakingContract, "updateBackpack", [duckAssetId, newPack], nil))
270280 let rest = if (((amt - b._2) > 0))
271281 then [ScriptTransfer(i.caller, (amt - b._2), usdnAssetId)]
272282 else nil
273283 $Tuple2((rest :+ b._1), result)
274284 }
275285 }
276286 }
277287 }
278288 }
279289
280290
281291
282292 @Callable(i)
283293 func buyMaterials (amounts,maxPrices) = {
284294 let duckAssetId = valueOrErrorMessage(getString(stakingContract, keyStakedDuckByOwner(toString(i.caller))), "You don't have a duck staked")
285295 if ((size(i.payments) != 1))
286296 then throw("exactly 1 payment must be attached")
287297 else {
288298 let pmt = i.payments[0]
289299 let amt = pmt.amount
290300 let pmtAssetId = valueOrErrorMessage(pmt.assetId, "WAVES can't be used as payment")
291301 if ((pmtAssetId != usdnAssetId))
292302 then throw("USDN payments only!")
293303 else {
294304 let curLocation = split(valueOrElse(getString(stakingContract, keyDuckLocation(duckAssetId)), DEFAULTLOCATION), "_")
295305 if ((curLocation[locIdxType] != "F"))
296306 then throw(("Duck location type should be Factory, but is " + curLocation[locIdxType]))
297307 else {
298308 let locId = curLocation[locIdxId]
299- let currentPack = split(valueOrElse(getString(stakingContract, keyBackpackByDuck(duckAssetId)), "0:0_0_0_0_0_0:0_0_0_0_0_0:"), ":")
309+ let currentPack = getBackpack(keyBackpackByDuck(duckAssetId))
300310 let matList = split(currentPack[bpIdxMat], "_")
301311 func mUpdater (acc,j) = if ((amounts[j] > 0))
302312 then {
303313 let b = buyInternal(locId, j, amounts[j], maxPrices[j])
304314 $Tuple3((acc._1 :+ b._1), (acc._2 :+ toString((parseIntValue(matList[j]) + b._3))), (acc._3 + b._2))
305315 }
306316 else $Tuple3(acc._1, (acc._2 :+ matList[j]), acc._3)
307317
308318 let merged = {
309319 let $l = [0, 1, 2, 3, 4, 5]
310320 let $s = size($l)
311321 let $acc0 = $Tuple3(nil, nil, 0)
312322 func $f0_1 ($a,$i) = if (($i >= $s))
313323 then $a
314324 else mUpdater($a, $l[$i])
315325
316326 func $f0_2 ($a,$i) = if (($i >= $s))
317327 then $a
318328 else throw("List size exceeds 6")
319329
320330 $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6)
321331 }
322332 if ((merged._3 > amt))
323333 then throw(((("Insufficient payment! Attached=" + toString(amt)) + ", required=") + toString(merged._3)))
324334 else {
325335 let newPack = makeString([currentPack[bpIdxLevel], currentPack[bpIdxRes], makeString(merged._2, "_"), currentPack[bpIdxProd]], ":")
326336 let result = asString(invoke(stakingContract, "updateBackpack", [duckAssetId, newPack], nil))
327337 let rest = if (((amt - merged._3) > 0))
328338 then [ScriptTransfer(i.caller, (amt - merged._3), usdnAssetId)]
329339 else nil
330340 $Tuple2((merged._1 ++ rest), result)
331341 }
332342 }
333343 }
334344 }
335345 }
336346
337347

github/deemru/w8io/169f3d6 
48.80 ms