tx · DyCbjGcAJwMHyz1FMLjUHGm493mA17Rw6QWrtYYNKF33 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H: -0.10000000 Waves 2022.11.07 14:40 [2306677] smart account 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H > SELF 0.00000000 Waves
{ "type": 13, "id": "DyCbjGcAJwMHyz1FMLjUHGm493mA17Rw6QWrtYYNKF33", "fee": 10000000, "feeAssetId": null, "timestamp": 1667821231135, "version": 2, "chainId": 84, "sender": "3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H", "senderPublicKey": "BDeCphaaC4MZvfmbJqQZ78EvuEBZTJ1VEW7fbxue8BUu", "proofs": [ "nDskrcNERSoQtwsFRf6h5tRUTYyE1DM5mZkuxgv4uXT3hFVWJQ7LgtX4C6uJfNzkhjnzhKTabE6fqpJwotS8H8p" ], "script": "base64:AAIFAAAAAAAAACQIAhIDCgEBEgYKBAEBAQESAwoBCBIDCgEIEgMKAQgSBAoCCAEAAAAmAAAAAAlzZXBhcmF0b3ICAAAAAV8AAAAACGtBdWN0aW9uAgAAAAdhdWN0aW9uAAAAAAVrU2VsbAIAAAAEc2VsbAAAAAAIa1RydXN0ZWQCAAAAB3RydXN0ZWQAAAAABmtQcmljZQIAAAAFcHJpY2UBAAAACmdldFNsb3RLZXkAAAACAAAABnByZWZpeAAAAAVuZnRJZAkAASwAAAACCQABLAAAAAIFAAAABnByZWZpeAUAAAAJc2VwYXJhdG9yCQACWAAAAAEFAAAABW5mdElkAQAAAAtnZXRQcmljZUtleQAAAAEAAAAFbmZ0SWQJAAEsAAAAAgkAASwAAAACBQAAAAZrUHJpY2UFAAAACXNlcGFyYXRvcgkAAlgAAAABBQAAAAVuZnRJZAEAAAAKZ2V0U2VsbEtleQAAAAEAAAAFbmZ0SWQJAAEsAAAAAgkAASwAAAACBQAAAAVrU2VsbAUAAAAJc2VwYXJhdG9yCQACWAAAAAEFAAAABW5mdElkAQAAAA1nZXRBdWN0aW9uS2V5A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1cnJlbnRNb21lbnQAAAACBQAAAAdhc3NldElkBQAAAAZtb21lbnQEAAAABnNlbGxlcggFAAAACyR0MDgzMDQ4MzY3AAAAAl8xBAAAAAVwcmljZQgFAAAACyR0MDgzMDQ4MzY3AAAAAl8yCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACCQEAAAALZ2V0UHJpY2VLZXkAAAABBQAAAAdhc3NldElkBQAAAAVwcmljZQUAAAADbmlsAAAAABz0Z2w=", "height": 2306677, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: WVSsHH5VQvfZETML6aBa5gDiJDBszKbZpuq5TqUqkGt Next: 9wuEB5QZmcXQ8SjdzgfbM9CzXd9dhyYq1TAbJodqZ3TR Diff:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "_" | |
5 | 5 | ||
6 | - | let | |
6 | + | let kAuction = "auction" | |
7 | 7 | ||
8 | 8 | let kSell = "sell" | |
9 | 9 | ||
10 | + | let kTrusted = "trusted" | |
11 | + | ||
10 | 12 | let kPrice = "price" | |
13 | + | ||
14 | + | func getSlotKey (prefix,nftId) = ((prefix + separator) + toBase58String(nftId)) | |
15 | + | ||
16 | + | ||
17 | + | func getPriceKey (nftId) = ((kPrice + separator) + toBase58String(nftId)) | |
18 | + | ||
19 | + | ||
20 | + | func getSellKey (nftId) = ((kSell + separator) + toBase58String(nftId)) | |
21 | + | ||
22 | + | ||
23 | + | func getAuctionKey (nftId) = ((kAuction + separator) + toBase58String(nftId)) | |
24 | + | ||
25 | + | ||
26 | + | func getTrustedKey (issuer) = ((kTrusted + separator) + toString(issuer)) | |
27 | + | ||
28 | + | ||
29 | + | func addToList (accum,nextValue) = (accum ++ [nextValue]) | |
30 | + | ||
31 | + | ||
32 | + | func joinString (params) = { | |
33 | + | let length = size(params) | |
34 | + | if ((length == 0)) | |
35 | + | then throw("Empty params") | |
36 | + | else if ((length == 1)) | |
37 | + | then makeString({ | |
38 | + | let $l = params | |
39 | + | let $s = size($l) | |
40 | + | let $acc0 = nil | |
41 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
42 | + | then $a | |
43 | + | else addToList($a, $l[$i]) | |
44 | + | ||
45 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
46 | + | then $a | |
47 | + | else throw("List size exceeds 1") | |
48 | + | ||
49 | + | $f0_2($f0_1($acc0, 0), 1) | |
50 | + | }, separator) | |
51 | + | else if ((length == 2)) | |
52 | + | then makeString({ | |
53 | + | let $l = params | |
54 | + | let $s = size($l) | |
55 | + | let $acc0 = nil | |
56 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
57 | + | then $a | |
58 | + | else addToList($a, $l[$i]) | |
59 | + | ||
60 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
61 | + | then $a | |
62 | + | else throw("List size exceeds 2") | |
63 | + | ||
64 | + | $f0_2($f0_1($f0_1($acc0, 0), 1), 2) | |
65 | + | }, separator) | |
66 | + | else if ((length == 3)) | |
67 | + | then makeString({ | |
68 | + | let $l = params | |
69 | + | let $s = size($l) | |
70 | + | let $acc0 = nil | |
71 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
72 | + | then $a | |
73 | + | else addToList($a, $l[$i]) | |
74 | + | ||
75 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
76 | + | then $a | |
77 | + | else throw("List size exceeds 3") | |
78 | + | ||
79 | + | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
80 | + | }, separator) | |
81 | + | else if ((length == 4)) | |
82 | + | then makeString({ | |
83 | + | let $l = params | |
84 | + | let $s = size($l) | |
85 | + | let $acc0 = nil | |
86 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
87 | + | then $a | |
88 | + | else addToList($a, $l[$i]) | |
89 | + | ||
90 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
91 | + | then $a | |
92 | + | else throw("List size exceeds 4") | |
93 | + | ||
94 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4) | |
95 | + | }, separator) | |
96 | + | else if ((length == 5)) | |
97 | + | then makeString({ | |
98 | + | let $l = params | |
99 | + | let $s = size($l) | |
100 | + | let $acc0 = nil | |
101 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
102 | + | then $a | |
103 | + | else addToList($a, $l[$i]) | |
104 | + | ||
105 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
106 | + | then $a | |
107 | + | else throw("List size exceeds 5") | |
108 | + | ||
109 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
110 | + | }, separator) | |
111 | + | else throw("Max number of parameters exceeded") | |
112 | + | } | |
113 | + | ||
114 | + | ||
115 | + | func parseAsAuction (details) = { | |
116 | + | let res = split(details, separator) | |
117 | + | $Tuple5(addressFromStringValue(res[0]), parseIntValue(res[1]), parseIntValue(res[2]), parseIntValue(res[3]), parseIntValue(res[4])) | |
118 | + | } | |
119 | + | ||
120 | + | ||
121 | + | func parseAsSell (details) = { | |
122 | + | let res = split(details, separator) | |
123 | + | $Tuple2(addressFromStringValue(res[0]), parseIntValue(res[1])) | |
124 | + | } | |
125 | + | ||
126 | + | ||
127 | + | func joinStruct (params) = match params { | |
128 | + | case auction: (Address, Int, Int, Int, Int) => | |
129 | + | joinString([toString(auction._1), toString(auction._2), toString(auction._3), toString(auction._4), toString(auction._5)]) | |
130 | + | case sell: (Address, Int) => | |
131 | + | joinString([toString(sell._1), toString(sell._2)]) | |
132 | + | case _ => | |
133 | + | throw("Wrong params tupple") | |
134 | + | } | |
135 | + | ||
136 | + | ||
137 | + | func setAuction (seller,nftId,startPrice,endPrice,start,end) = StringEntry(getAuctionKey(nftId), joinStruct($Tuple5(seller, startPrice, endPrice, start, end))) | |
138 | + | ||
139 | + | ||
140 | + | func setSell (nftId,celler,price) = StringEntry(getSellKey(nftId), joinStruct($Tuple2(celler, price))) | |
141 | + | ||
142 | + | ||
143 | + | func getAuction (nftId) = value(getString(this, getAuctionKey(nftId))) | |
144 | + | ||
145 | + | ||
146 | + | func getSell (nftId) = value(getString(this, getSellKey(nftId))) | |
147 | + | ||
148 | + | ||
149 | + | func calcPriceAtCurrentMoment (assetId,moment) = { | |
150 | + | let details = getAuction(assetId) | |
151 | + | let $t028172921 = parseAsAuction(details) | |
152 | + | let seller = $t028172921._1 | |
153 | + | let startPriceValue = $t028172921._2 | |
154 | + | let endPriceValue = $t028172921._3 | |
155 | + | let startPeriodValue = $t028172921._4 | |
156 | + | let endPeriodValue = $t028172921._5 | |
157 | + | if ((moment >= endPeriodValue)) | |
158 | + | then $Tuple2(seller, endPriceValue) | |
159 | + | else { | |
160 | + | let deltaPrice = (startPriceValue - endPriceValue) | |
161 | + | let period = (endPeriodValue - startPeriodValue) | |
162 | + | let spended = (moment - startPeriodValue) | |
163 | + | $Tuple2(seller, (startPriceValue - fraction(spended, deltaPrice, period))) | |
164 | + | } | |
165 | + | } | |
166 | + | ||
11 | 167 | ||
12 | 168 | func isNft (assetId) = match assetInfo(assetId) { | |
13 | 169 | case token: Asset => | |
21 | 177 | } | |
22 | 178 | ||
23 | 179 | ||
180 | + | func isTrustedNft (assetId) = { | |
181 | + | let issuer = value(assetInfo(assetId)).issuer | |
182 | + | valueOrElse(getBoolean(this, getTrustedKey(issuer)), false) | |
183 | + | } | |
184 | + | ||
185 | + | ||
186 | + | func isSellExist (assetId) = isDefined(getString(this, getSellKey(assetId))) | |
187 | + | ||
188 | + | ||
189 | + | func isAuctionExist (assetId) = isDefined(getString(this, getAuctionKey(assetId))) | |
190 | + | ||
191 | + | ||
192 | + | func isCorrectSellPrice (price) = (price > 0) | |
193 | + | ||
194 | + | ||
195 | + | func isCorrectAuctionPeriod (start,end) = (end > start) | |
196 | + | ||
197 | + | ||
198 | + | func isCorrectAuctionPrices (startPrice,endPrice) = (startPrice > endPrice) | |
199 | + | ||
200 | + | ||
201 | + | func isAdmin (caller) = (caller == this) | |
202 | + | ||
203 | + | ||
204 | + | func isValidCaller (caller,seller) = if ((caller == this)) | |
205 | + | then true | |
206 | + | else (caller == seller) | |
207 | + | ||
208 | + | ||
209 | + | func isAuctionEnded (now,end) = (now > end) | |
210 | + | ||
211 | + | ||
212 | + | func isEnoughFunds (payment,currentMomentPrice) = (payment >= currentMomentPrice) | |
213 | + | ||
214 | + | ||
215 | + | func isWawes (assetId) = (assetId == unit) | |
216 | + | ||
217 | + | ||
218 | + | func isCorrectNft (nftId) = if (!(isNft(nftId))) | |
219 | + | then throw("Token is not Nft") | |
220 | + | else if (isSellExist(nftId)) | |
221 | + | then throw("Sell already exists") | |
222 | + | else if (isAuctionExist(nftId)) | |
223 | + | then throw("Auction already exists") | |
224 | + | else unit | |
225 | + | ||
226 | + | ||
227 | + | func isCorrectPayments (paymentAsset,paymentAmount,price) = if (!(isWawes(paymentAsset))) | |
228 | + | then throw("Payment must be at WAVES") | |
229 | + | else if (!(isEnoughFunds(paymentAmount, price))) | |
230 | + | then throw("Not enough funds") | |
231 | + | else unit | |
232 | + | ||
233 | + | ||
234 | + | func calcFee () = 0 | |
235 | + | ||
236 | + | ||
237 | + | func calcTrustedFee () = 0 | |
238 | + | ||
239 | + | ||
240 | + | func resultFundsAmounts (isTrusted,paymentAmount,actualPrice) = if (isTrusted) | |
241 | + | then $Tuple2((actualPrice - calcTrustedFee()), (paymentAmount - actualPrice)) | |
242 | + | else $Tuple2((actualPrice - calcFee()), (paymentAmount - actualPrice)) | |
243 | + | ||
244 | + | ||
245 | + | func getSlot (nftId) = if (isSellExist(nftId)) | |
246 | + | then $Tuple2(kSell, getSell(nftId)) | |
247 | + | else if (isAuctionExist(nftId)) | |
248 | + | then $Tuple2(kAuction, getAuction(nftId)) | |
249 | + | else throw("Slot doesn`t exist") | |
250 | + | ||
251 | + | ||
24 | 252 | @Callable(i) | |
25 | - | func issueNft (name,meta,price) = { | |
26 | - | let newToken = Issue(name, meta, 1, 0, false) | |
27 | - | let issueId = calculateAssetId(newToken) | |
28 | - | [newToken, StringEntry(((kPrice + separator) + toBase58String(issueId)), toString(price))] | |
253 | + | func addSell (price) = { | |
254 | + | let nftId = value(i.payments[0].assetId) | |
255 | + | valueOrElse(isCorrectNft(nftId), if (!(isCorrectSellPrice(price))) | |
256 | + | then throw("Price must be > 0") | |
257 | + | else [setSell(nftId, i.caller, price)]) | |
29 | 258 | } | |
30 | 259 | ||
31 | 260 | ||
32 | 261 | ||
33 | 262 | @Callable(i) | |
34 | - | func buyNFT (nftID) = { | |
35 | - | let assetId = fromBase58String(nftID) | |
36 | - | let amount = value(i.payments[0].amount) | |
37 | - | let price = valueOrErrorMessage(getString(((kPrice + separator) + nftID)), "There is no price for this nft") | |
38 | - | if ((i.payments[0].assetId != unit)) | |
39 | - | then throw("pay in waves") | |
40 | - | else if ((parseIntValue(price) > amount)) | |
41 | - | then throw("Invalid payment") | |
42 | - | else [ScriptTransfer(i.caller, 1, assetId), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))] | |
263 | + | func addAuction (startPrice,endPrice,start,end) = { | |
264 | + | let nftId = value(i.payments[0].assetId) | |
265 | + | valueOrElse(isCorrectNft(nftId), if (!(isCorrectAuctionPeriod(start, end))) | |
266 | + | then throw("Period is not correct") | |
267 | + | else if (!(isCorrectAuctionPrices(startPrice, endPrice))) | |
268 | + | then throw("Start price must be > endPrice") | |
269 | + | else [setAuction(i.caller, nftId, startPrice, endPrice, start, end)]) | |
43 | 270 | } | |
44 | 271 | ||
45 | 272 | ||
46 | 273 | ||
47 | 274 | @Callable(i) | |
48 | - | func sellNFT () = { | |
49 | - | let $t011731258 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
50 | - | let token0 = $t011731258._1 | |
51 | - | let amount0 = $t011731258._2 | |
52 | - | let price = getStringValue(((kPrice + separator) + valueOrErrorMessage(toBase58String(token0), "There is no price for this nft"))) | |
53 | - | if (!(isNft(token0))) | |
54 | - | then throw("Token is not NFT") | |
55 | - | else [ScriptTransfer(i.caller, parseIntValue(price), unit), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))] | |
275 | + | func buyFromSlot (nftId) = { | |
276 | + | let $t060146103 = $Tuple2(i.payments[0].assetId, value(i.payments[0].amount)) | |
277 | + | let paymentAsset = $t060146103._1 | |
278 | + | let paymentAmount = $t060146103._2 | |
279 | + | let assetId = fromBase58String(nftId) | |
280 | + | let $t061476185 = getSlot(assetId) | |
281 | + | let type = $t061476185._1 | |
282 | + | let details = $t061476185._2 | |
283 | + | let baseRes = [ScriptTransfer(i.caller, 1, assetId), DeleteEntry(getSlotKey(type, assetId))] | |
284 | + | if ((type == kSell)) | |
285 | + | then { | |
286 | + | let $t063276374 = parseAsSell(details) | |
287 | + | let seller = $t063276374._1 | |
288 | + | let priceValue = $t063276374._2 | |
289 | + | valueOrElse(isCorrectPayments(paymentAsset, paymentAmount, priceValue), { | |
290 | + | let $t064596561 = resultFundsAmounts(isTrustedNft(assetId), paymentAmount, priceValue) | |
291 | + | let sellerAmount = $t064596561._1 | |
292 | + | let buyerAmount = $t064596561._2 | |
293 | + | let updatedRes = (baseRes ++ [ScriptTransfer(seller, sellerAmount, unit)]) | |
294 | + | if ((buyerAmount > 0)) | |
295 | + | then (updatedRes ++ [ScriptTransfer(i.caller, buyerAmount, unit)]) | |
296 | + | else updatedRes | |
297 | + | }) | |
298 | + | } | |
299 | + | else { | |
300 | + | let $t067786847 = calcPriceAtCurrentMoment(assetId, height) | |
301 | + | let seller = $t067786847._1 | |
302 | + | let actualPrice = $t067786847._2 | |
303 | + | valueOrElse(isCorrectPayments(paymentAsset, paymentAmount, actualPrice), { | |
304 | + | let $t069337036 = resultFundsAmounts(isTrustedNft(assetId), paymentAmount, actualPrice) | |
305 | + | let sellerAmount = $t069337036._1 | |
306 | + | let buyerAmount = $t069337036._2 | |
307 | + | let updatedRes = (baseRes ++ [ScriptTransfer(seller, sellerAmount, unit)]) | |
308 | + | if ((buyerAmount > 0)) | |
309 | + | then (updatedRes ++ [ScriptTransfer(i.caller, buyerAmount, unit)]) | |
310 | + | else updatedRes | |
311 | + | }) | |
312 | + | } | |
313 | + | } | |
314 | + | ||
315 | + | ||
316 | + | ||
317 | + | @Callable(i) | |
318 | + | func declineSlot (nftId) = { | |
319 | + | let assetId = fromBase58String(nftId) | |
320 | + | let $t073377375 = getSlot(assetId) | |
321 | + | let type = $t073377375._1 | |
322 | + | let details = $t073377375._2 | |
323 | + | let baseRes = [DeleteEntry(getSlotKey(type, assetId))] | |
324 | + | if ((type == kSell)) | |
325 | + | then { | |
326 | + | let $t074677514 = parseAsSell(details) | |
327 | + | let seller = $t074677514._1 | |
328 | + | let priceValue = $t074677514._2 | |
329 | + | if (!(isValidCaller(i.caller, seller))) | |
330 | + | then throw("Invalid caller") | |
331 | + | else (baseRes ++ [ScriptTransfer(seller, 1, assetId)]) | |
332 | + | } | |
333 | + | else { | |
334 | + | let $t076597763 = parseAsAuction(details) | |
335 | + | let seller = $t076597763._1 | |
336 | + | let startPriceValue = $t076597763._2 | |
337 | + | let endPriceValue = $t076597763._3 | |
338 | + | let startPeriodValue = $t076597763._4 | |
339 | + | let endPeriodValue = $t076597763._5 | |
340 | + | if (!(isValidCaller(i.caller, seller))) | |
341 | + | then throw("Invalid caller") | |
342 | + | else if (!(isAuctionEnded(height, endPeriodValue))) | |
343 | + | then throw("Wait for end of auction") | |
344 | + | else (baseRes ++ [ScriptTransfer(seller, 1, assetId)]) | |
345 | + | } | |
346 | + | } | |
347 | + | ||
348 | + | ||
349 | + | ||
350 | + | @Callable(i) | |
351 | + | func setTrustedIssuer (trustedAddr) = if (!(isAdmin(i.caller))) | |
352 | + | then throw("Only admin") | |
353 | + | else [BooleanEntry(getTrustedKey(addressFromStringValue(trustedAddr)), true)] | |
354 | + | ||
355 | + | ||
356 | + | ||
357 | + | @Callable(i) | |
358 | + | func getPriceAtCurrentMoment (nftId,moment) = { | |
359 | + | let assetId = fromBase58String(nftId) | |
360 | + | let $t083048367 = calcPriceAtCurrentMoment(assetId, moment) | |
361 | + | let seller = $t083048367._1 | |
362 | + | let price = $t083048367._2 | |
363 | + | [IntegerEntry(getPriceKey(assetId), price)] | |
56 | 364 | } | |
57 | 365 | ||
58 | 366 |
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "_" | |
5 | 5 | ||
6 | - | let | |
6 | + | let kAuction = "auction" | |
7 | 7 | ||
8 | 8 | let kSell = "sell" | |
9 | 9 | ||
10 | + | let kTrusted = "trusted" | |
11 | + | ||
10 | 12 | let kPrice = "price" | |
13 | + | ||
14 | + | func getSlotKey (prefix,nftId) = ((prefix + separator) + toBase58String(nftId)) | |
15 | + | ||
16 | + | ||
17 | + | func getPriceKey (nftId) = ((kPrice + separator) + toBase58String(nftId)) | |
18 | + | ||
19 | + | ||
20 | + | func getSellKey (nftId) = ((kSell + separator) + toBase58String(nftId)) | |
21 | + | ||
22 | + | ||
23 | + | func getAuctionKey (nftId) = ((kAuction + separator) + toBase58String(nftId)) | |
24 | + | ||
25 | + | ||
26 | + | func getTrustedKey (issuer) = ((kTrusted + separator) + toString(issuer)) | |
27 | + | ||
28 | + | ||
29 | + | func addToList (accum,nextValue) = (accum ++ [nextValue]) | |
30 | + | ||
31 | + | ||
32 | + | func joinString (params) = { | |
33 | + | let length = size(params) | |
34 | + | if ((length == 0)) | |
35 | + | then throw("Empty params") | |
36 | + | else if ((length == 1)) | |
37 | + | then makeString({ | |
38 | + | let $l = params | |
39 | + | let $s = size($l) | |
40 | + | let $acc0 = nil | |
41 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
42 | + | then $a | |
43 | + | else addToList($a, $l[$i]) | |
44 | + | ||
45 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
46 | + | then $a | |
47 | + | else throw("List size exceeds 1") | |
48 | + | ||
49 | + | $f0_2($f0_1($acc0, 0), 1) | |
50 | + | }, separator) | |
51 | + | else if ((length == 2)) | |
52 | + | then makeString({ | |
53 | + | let $l = params | |
54 | + | let $s = size($l) | |
55 | + | let $acc0 = nil | |
56 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
57 | + | then $a | |
58 | + | else addToList($a, $l[$i]) | |
59 | + | ||
60 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
61 | + | then $a | |
62 | + | else throw("List size exceeds 2") | |
63 | + | ||
64 | + | $f0_2($f0_1($f0_1($acc0, 0), 1), 2) | |
65 | + | }, separator) | |
66 | + | else if ((length == 3)) | |
67 | + | then makeString({ | |
68 | + | let $l = params | |
69 | + | let $s = size($l) | |
70 | + | let $acc0 = nil | |
71 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
72 | + | then $a | |
73 | + | else addToList($a, $l[$i]) | |
74 | + | ||
75 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
76 | + | then $a | |
77 | + | else throw("List size exceeds 3") | |
78 | + | ||
79 | + | $f0_2($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3) | |
80 | + | }, separator) | |
81 | + | else if ((length == 4)) | |
82 | + | then makeString({ | |
83 | + | let $l = params | |
84 | + | let $s = size($l) | |
85 | + | let $acc0 = nil | |
86 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
87 | + | then $a | |
88 | + | else addToList($a, $l[$i]) | |
89 | + | ||
90 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
91 | + | then $a | |
92 | + | else throw("List size exceeds 4") | |
93 | + | ||
94 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4) | |
95 | + | }, separator) | |
96 | + | else if ((length == 5)) | |
97 | + | then makeString({ | |
98 | + | let $l = params | |
99 | + | let $s = size($l) | |
100 | + | let $acc0 = nil | |
101 | + | func $f0_1 ($a,$i) = if (($i >= $s)) | |
102 | + | then $a | |
103 | + | else addToList($a, $l[$i]) | |
104 | + | ||
105 | + | func $f0_2 ($a,$i) = if (($i >= $s)) | |
106 | + | then $a | |
107 | + | else throw("List size exceeds 5") | |
108 | + | ||
109 | + | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5) | |
110 | + | }, separator) | |
111 | + | else throw("Max number of parameters exceeded") | |
112 | + | } | |
113 | + | ||
114 | + | ||
115 | + | func parseAsAuction (details) = { | |
116 | + | let res = split(details, separator) | |
117 | + | $Tuple5(addressFromStringValue(res[0]), parseIntValue(res[1]), parseIntValue(res[2]), parseIntValue(res[3]), parseIntValue(res[4])) | |
118 | + | } | |
119 | + | ||
120 | + | ||
121 | + | func parseAsSell (details) = { | |
122 | + | let res = split(details, separator) | |
123 | + | $Tuple2(addressFromStringValue(res[0]), parseIntValue(res[1])) | |
124 | + | } | |
125 | + | ||
126 | + | ||
127 | + | func joinStruct (params) = match params { | |
128 | + | case auction: (Address, Int, Int, Int, Int) => | |
129 | + | joinString([toString(auction._1), toString(auction._2), toString(auction._3), toString(auction._4), toString(auction._5)]) | |
130 | + | case sell: (Address, Int) => | |
131 | + | joinString([toString(sell._1), toString(sell._2)]) | |
132 | + | case _ => | |
133 | + | throw("Wrong params tupple") | |
134 | + | } | |
135 | + | ||
136 | + | ||
137 | + | func setAuction (seller,nftId,startPrice,endPrice,start,end) = StringEntry(getAuctionKey(nftId), joinStruct($Tuple5(seller, startPrice, endPrice, start, end))) | |
138 | + | ||
139 | + | ||
140 | + | func setSell (nftId,celler,price) = StringEntry(getSellKey(nftId), joinStruct($Tuple2(celler, price))) | |
141 | + | ||
142 | + | ||
143 | + | func getAuction (nftId) = value(getString(this, getAuctionKey(nftId))) | |
144 | + | ||
145 | + | ||
146 | + | func getSell (nftId) = value(getString(this, getSellKey(nftId))) | |
147 | + | ||
148 | + | ||
149 | + | func calcPriceAtCurrentMoment (assetId,moment) = { | |
150 | + | let details = getAuction(assetId) | |
151 | + | let $t028172921 = parseAsAuction(details) | |
152 | + | let seller = $t028172921._1 | |
153 | + | let startPriceValue = $t028172921._2 | |
154 | + | let endPriceValue = $t028172921._3 | |
155 | + | let startPeriodValue = $t028172921._4 | |
156 | + | let endPeriodValue = $t028172921._5 | |
157 | + | if ((moment >= endPeriodValue)) | |
158 | + | then $Tuple2(seller, endPriceValue) | |
159 | + | else { | |
160 | + | let deltaPrice = (startPriceValue - endPriceValue) | |
161 | + | let period = (endPeriodValue - startPeriodValue) | |
162 | + | let spended = (moment - startPeriodValue) | |
163 | + | $Tuple2(seller, (startPriceValue - fraction(spended, deltaPrice, period))) | |
164 | + | } | |
165 | + | } | |
166 | + | ||
11 | 167 | ||
12 | 168 | func isNft (assetId) = match assetInfo(assetId) { | |
13 | 169 | case token: Asset => | |
14 | 170 | if (if ((token.decimals == 0)) | |
15 | 171 | then (token.quantity == 1) | |
16 | 172 | else false) | |
17 | 173 | then (token.reissuable == false) | |
18 | 174 | else false | |
19 | 175 | case _ => | |
20 | 176 | false | |
21 | 177 | } | |
22 | 178 | ||
23 | 179 | ||
180 | + | func isTrustedNft (assetId) = { | |
181 | + | let issuer = value(assetInfo(assetId)).issuer | |
182 | + | valueOrElse(getBoolean(this, getTrustedKey(issuer)), false) | |
183 | + | } | |
184 | + | ||
185 | + | ||
186 | + | func isSellExist (assetId) = isDefined(getString(this, getSellKey(assetId))) | |
187 | + | ||
188 | + | ||
189 | + | func isAuctionExist (assetId) = isDefined(getString(this, getAuctionKey(assetId))) | |
190 | + | ||
191 | + | ||
192 | + | func isCorrectSellPrice (price) = (price > 0) | |
193 | + | ||
194 | + | ||
195 | + | func isCorrectAuctionPeriod (start,end) = (end > start) | |
196 | + | ||
197 | + | ||
198 | + | func isCorrectAuctionPrices (startPrice,endPrice) = (startPrice > endPrice) | |
199 | + | ||
200 | + | ||
201 | + | func isAdmin (caller) = (caller == this) | |
202 | + | ||
203 | + | ||
204 | + | func isValidCaller (caller,seller) = if ((caller == this)) | |
205 | + | then true | |
206 | + | else (caller == seller) | |
207 | + | ||
208 | + | ||
209 | + | func isAuctionEnded (now,end) = (now > end) | |
210 | + | ||
211 | + | ||
212 | + | func isEnoughFunds (payment,currentMomentPrice) = (payment >= currentMomentPrice) | |
213 | + | ||
214 | + | ||
215 | + | func isWawes (assetId) = (assetId == unit) | |
216 | + | ||
217 | + | ||
218 | + | func isCorrectNft (nftId) = if (!(isNft(nftId))) | |
219 | + | then throw("Token is not Nft") | |
220 | + | else if (isSellExist(nftId)) | |
221 | + | then throw("Sell already exists") | |
222 | + | else if (isAuctionExist(nftId)) | |
223 | + | then throw("Auction already exists") | |
224 | + | else unit | |
225 | + | ||
226 | + | ||
227 | + | func isCorrectPayments (paymentAsset,paymentAmount,price) = if (!(isWawes(paymentAsset))) | |
228 | + | then throw("Payment must be at WAVES") | |
229 | + | else if (!(isEnoughFunds(paymentAmount, price))) | |
230 | + | then throw("Not enough funds") | |
231 | + | else unit | |
232 | + | ||
233 | + | ||
234 | + | func calcFee () = 0 | |
235 | + | ||
236 | + | ||
237 | + | func calcTrustedFee () = 0 | |
238 | + | ||
239 | + | ||
240 | + | func resultFundsAmounts (isTrusted,paymentAmount,actualPrice) = if (isTrusted) | |
241 | + | then $Tuple2((actualPrice - calcTrustedFee()), (paymentAmount - actualPrice)) | |
242 | + | else $Tuple2((actualPrice - calcFee()), (paymentAmount - actualPrice)) | |
243 | + | ||
244 | + | ||
245 | + | func getSlot (nftId) = if (isSellExist(nftId)) | |
246 | + | then $Tuple2(kSell, getSell(nftId)) | |
247 | + | else if (isAuctionExist(nftId)) | |
248 | + | then $Tuple2(kAuction, getAuction(nftId)) | |
249 | + | else throw("Slot doesn`t exist") | |
250 | + | ||
251 | + | ||
24 | 252 | @Callable(i) | |
25 | - | func issueNft (name,meta,price) = { | |
26 | - | let newToken = Issue(name, meta, 1, 0, false) | |
27 | - | let issueId = calculateAssetId(newToken) | |
28 | - | [newToken, StringEntry(((kPrice + separator) + toBase58String(issueId)), toString(price))] | |
253 | + | func addSell (price) = { | |
254 | + | let nftId = value(i.payments[0].assetId) | |
255 | + | valueOrElse(isCorrectNft(nftId), if (!(isCorrectSellPrice(price))) | |
256 | + | then throw("Price must be > 0") | |
257 | + | else [setSell(nftId, i.caller, price)]) | |
29 | 258 | } | |
30 | 259 | ||
31 | 260 | ||
32 | 261 | ||
33 | 262 | @Callable(i) | |
34 | - | func buyNFT (nftID) = { | |
35 | - | let assetId = fromBase58String(nftID) | |
36 | - | let amount = value(i.payments[0].amount) | |
37 | - | let price = valueOrErrorMessage(getString(((kPrice + separator) + nftID)), "There is no price for this nft") | |
38 | - | if ((i.payments[0].assetId != unit)) | |
39 | - | then throw("pay in waves") | |
40 | - | else if ((parseIntValue(price) > amount)) | |
41 | - | then throw("Invalid payment") | |
42 | - | else [ScriptTransfer(i.caller, 1, assetId), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount)))] | |
263 | + | func addAuction (startPrice,endPrice,start,end) = { | |
264 | + | let nftId = value(i.payments[0].assetId) | |
265 | + | valueOrElse(isCorrectNft(nftId), if (!(isCorrectAuctionPeriod(start, end))) | |
266 | + | then throw("Period is not correct") | |
267 | + | else if (!(isCorrectAuctionPrices(startPrice, endPrice))) | |
268 | + | then throw("Start price must be > endPrice") | |
269 | + | else [setAuction(i.caller, nftId, startPrice, endPrice, start, end)]) | |
43 | 270 | } | |
44 | 271 | ||
45 | 272 | ||
46 | 273 | ||
47 | 274 | @Callable(i) | |
48 | - | func sellNFT () = { | |
49 | - | let $t011731258 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
50 | - | let token0 = $t011731258._1 | |
51 | - | let amount0 = $t011731258._2 | |
52 | - | let price = getStringValue(((kPrice + separator) + valueOrErrorMessage(toBase58String(token0), "There is no price for this nft"))) | |
53 | - | if (!(isNft(token0))) | |
54 | - | then throw("Token is not NFT") | |
55 | - | else [ScriptTransfer(i.caller, parseIntValue(price), unit), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))] | |
275 | + | func buyFromSlot (nftId) = { | |
276 | + | let $t060146103 = $Tuple2(i.payments[0].assetId, value(i.payments[0].amount)) | |
277 | + | let paymentAsset = $t060146103._1 | |
278 | + | let paymentAmount = $t060146103._2 | |
279 | + | let assetId = fromBase58String(nftId) | |
280 | + | let $t061476185 = getSlot(assetId) | |
281 | + | let type = $t061476185._1 | |
282 | + | let details = $t061476185._2 | |
283 | + | let baseRes = [ScriptTransfer(i.caller, 1, assetId), DeleteEntry(getSlotKey(type, assetId))] | |
284 | + | if ((type == kSell)) | |
285 | + | then { | |
286 | + | let $t063276374 = parseAsSell(details) | |
287 | + | let seller = $t063276374._1 | |
288 | + | let priceValue = $t063276374._2 | |
289 | + | valueOrElse(isCorrectPayments(paymentAsset, paymentAmount, priceValue), { | |
290 | + | let $t064596561 = resultFundsAmounts(isTrustedNft(assetId), paymentAmount, priceValue) | |
291 | + | let sellerAmount = $t064596561._1 | |
292 | + | let buyerAmount = $t064596561._2 | |
293 | + | let updatedRes = (baseRes ++ [ScriptTransfer(seller, sellerAmount, unit)]) | |
294 | + | if ((buyerAmount > 0)) | |
295 | + | then (updatedRes ++ [ScriptTransfer(i.caller, buyerAmount, unit)]) | |
296 | + | else updatedRes | |
297 | + | }) | |
298 | + | } | |
299 | + | else { | |
300 | + | let $t067786847 = calcPriceAtCurrentMoment(assetId, height) | |
301 | + | let seller = $t067786847._1 | |
302 | + | let actualPrice = $t067786847._2 | |
303 | + | valueOrElse(isCorrectPayments(paymentAsset, paymentAmount, actualPrice), { | |
304 | + | let $t069337036 = resultFundsAmounts(isTrustedNft(assetId), paymentAmount, actualPrice) | |
305 | + | let sellerAmount = $t069337036._1 | |
306 | + | let buyerAmount = $t069337036._2 | |
307 | + | let updatedRes = (baseRes ++ [ScriptTransfer(seller, sellerAmount, unit)]) | |
308 | + | if ((buyerAmount > 0)) | |
309 | + | then (updatedRes ++ [ScriptTransfer(i.caller, buyerAmount, unit)]) | |
310 | + | else updatedRes | |
311 | + | }) | |
312 | + | } | |
313 | + | } | |
314 | + | ||
315 | + | ||
316 | + | ||
317 | + | @Callable(i) | |
318 | + | func declineSlot (nftId) = { | |
319 | + | let assetId = fromBase58String(nftId) | |
320 | + | let $t073377375 = getSlot(assetId) | |
321 | + | let type = $t073377375._1 | |
322 | + | let details = $t073377375._2 | |
323 | + | let baseRes = [DeleteEntry(getSlotKey(type, assetId))] | |
324 | + | if ((type == kSell)) | |
325 | + | then { | |
326 | + | let $t074677514 = parseAsSell(details) | |
327 | + | let seller = $t074677514._1 | |
328 | + | let priceValue = $t074677514._2 | |
329 | + | if (!(isValidCaller(i.caller, seller))) | |
330 | + | then throw("Invalid caller") | |
331 | + | else (baseRes ++ [ScriptTransfer(seller, 1, assetId)]) | |
332 | + | } | |
333 | + | else { | |
334 | + | let $t076597763 = parseAsAuction(details) | |
335 | + | let seller = $t076597763._1 | |
336 | + | let startPriceValue = $t076597763._2 | |
337 | + | let endPriceValue = $t076597763._3 | |
338 | + | let startPeriodValue = $t076597763._4 | |
339 | + | let endPeriodValue = $t076597763._5 | |
340 | + | if (!(isValidCaller(i.caller, seller))) | |
341 | + | then throw("Invalid caller") | |
342 | + | else if (!(isAuctionEnded(height, endPeriodValue))) | |
343 | + | then throw("Wait for end of auction") | |
344 | + | else (baseRes ++ [ScriptTransfer(seller, 1, assetId)]) | |
345 | + | } | |
346 | + | } | |
347 | + | ||
348 | + | ||
349 | + | ||
350 | + | @Callable(i) | |
351 | + | func setTrustedIssuer (trustedAddr) = if (!(isAdmin(i.caller))) | |
352 | + | then throw("Only admin") | |
353 | + | else [BooleanEntry(getTrustedKey(addressFromStringValue(trustedAddr)), true)] | |
354 | + | ||
355 | + | ||
356 | + | ||
357 | + | @Callable(i) | |
358 | + | func getPriceAtCurrentMoment (nftId,moment) = { | |
359 | + | let assetId = fromBase58String(nftId) | |
360 | + | let $t083048367 = calcPriceAtCurrentMoment(assetId, moment) | |
361 | + | let seller = $t083048367._1 | |
362 | + | let price = $t083048367._2 | |
363 | + | [IntegerEntry(getPriceKey(assetId), price)] | |
56 | 364 | } | |
57 | 365 | ||
58 | 366 |
github/deemru/w8io/169f3d6 45.61 ms ◑